/* DREAMBIG trading workstation. Component rules share one token and spacing scale. */
:root {
  color-scheme: dark;
  --color-canvas: #101419;
  --color-sidebar: #141a20;
  --color-header: #141a20;
  --color-surface: #192128;
  --color-surface-hover: #26323c;
  --color-surface-active: #303c46;
  --color-surface-raised: #202a33;
  --color-border: #3b4955;
  --color-border-subtle: #2e3a45;
  --color-border-hover: #788b9b;
  --color-text-primary: #eff3f6;
  --color-text-secondary: #c2cdd5;
  --color-text-muted: #a9b7c2;
  --color-text-dim: #9eafbd;
  --color-accent: #b1c6ff;
  --color-accent-subtle: #293b60;
  --color-on-accent: #101419;
  --color-on-action: #101419;
  --color-positive: #80d6bc;
  --color-positive-subtle: #223c34;
  --color-on-positive: #101419;
  --color-negative: #ff939c;
  --color-negative-subtle: #432b30;
  --color-on-negative: #101419;
  --color-warning: #e9bf75;
  --color-warning-subtle: #3e3527;
  --color-cyan: #8abedb;
  --color-cyan-subtle: #263742;
  --font-sans: 'DM Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-display: var(--font-sans);
  --font-mono: 'JetBrains Mono', ui-monospace, Consolas, monospace;
  --font-heading-resolved: var(--font-display);
  --font-body-resolved: var(--font-sans);
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;
  --radius-xs: 3px;
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 10px;
  --radius-xl: 12px;
  --badge-radius: var(--radius-xs);
  --ease-out: cubic-bezier(.2, .7, .2, 1);
  --radius-full: 999px;
  --header-height: 58px;
  --sidebar-width: 212px;
  --canvas-texture: none;
  --canvas-texture-size: auto;
  --shadow-bevel: inset 0 1px 0 rgba(255, 255, 255, 0.04);
  --shadow-card: 0 1px 2px rgba(0, 0, 0, 0.28);
  --shadow-card-hover: 0 6px 16px rgba(0, 0, 0, 0.36);
  --shadow-elevated: 0 10px 28px rgba(0, 0, 0, 0.44);
  --shadow-floating: 0 18px 44px rgba(0, 0, 0, 0.56);
  --shadow-button-tactile: inset 0 1px 0 rgba(255, 255, 255, 0.06), 0 1px 2px rgba(0, 0, 0, 0.24);
}

:root[data-theme="light"] {
  color-scheme: light;
  --color-canvas: #f3f0e8;
  --color-sidebar: #142e45;
  --color-header: #fcfaf5;
  --color-surface: #fffdf7;
  --color-surface-hover: #edf1ee;
  --color-surface-active: #e1e8e3;
  --color-surface-raised: #f6f8f5;
  --color-border: #c5cfc8;
  --color-border-subtle: #dce3dd;
  --color-border-hover: #6a7c70;
  --color-text-primary: #1c2922;
  --color-text-secondary: #41594b;
  --color-text-muted: #52665a;
  --color-text-dim: #5c7063;
  --color-accent: #294fb9;
  --color-accent-subtle: #e7edff;
  --color-on-accent: #ffffff;
  --color-on-action: #ffffff;
  --color-positive: #1c704c;
  --color-positive-subtle: #e3f0e8;
  --color-on-positive: #ffffff;
  --color-warning-subtle: #f6eddb;
  --color-cyan-subtle: #e3eef5;
  --color-negative: #b82c43;
  --color-negative-subtle: #fae8ec;
  --color-on-negative: #ffffff;
  --color-warning: #835c0b;
  --shadow-bevel: inset 0 1px 0 rgba(255, 255, 255, 0.85);
  --shadow-card: 0 1px 2px rgba(18, 28, 24, 0.05), 0 2px 6px rgba(18, 28, 24, 0.03);
  --shadow-card-hover: 0 6px 16px rgba(18, 28, 24, 0.09);
  --shadow-elevated: 0 10px 28px rgba(18, 28, 24, 0.12);
  --shadow-floating: 0 18px 46px rgba(18, 28, 24, 0.18);
  --shadow-button-tactile: inset 0 1px 0 rgba(255, 255, 255, 0.85), 0 1px 2px rgba(18, 28, 24, 0.06);
}

* { box-sizing: border-box; }
html, body { margin: 0; width: 100%; height: 100%; }
body {
  background: var(--color-canvas);
  color: var(--color-text-primary);
  font: 14px/1.5 var(--font-body-resolved, var(--font-sans));
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

button, input, select, textarea { font: inherit; }
button, select { cursor: pointer; }

button {
  color: var(--color-text-secondary);
  background: var(--color-surface-raised);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  min-height: 36px;
  font-size: 12px;
  font-weight: 600;
  box-shadow: var(--shadow-button-tactile);
  transition: background-color .16s var(--ease-out), border-color .16s var(--ease-out), color .16s var(--ease-out), box-shadow .16s var(--ease-out), transform .14s var(--ease-out);
}
button:hover:not(:disabled) {
  background: var(--color-surface-hover);
  border-color: var(--color-border-hover);
  color: var(--color-text-primary);
}
button:active:not(:disabled) { transform: translateY(1px); }
button:disabled { opacity: .5; cursor: not-allowed; transform: none; }

a { color: inherit; text-decoration: none; }

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
summary:focus-visible,
[tabindex]:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}

input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="file"]),
select,
textarea {
  color: var(--color-text-primary);
  background: var(--color-canvas);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 7px 10px;
  min-height: 36px;
  max-width: 100%;
  transition: border-color .16s var(--ease-out), background-color .16s var(--ease-out);
}
input:not([type="checkbox"]):not([type="radio"]):not([type="file"]):hover,
select:hover,
textarea:hover {
  border-color: var(--color-border-hover);
}
input::placeholder,
textarea::placeholder { color: var(--color-text-dim); opacity: 1; }

input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  min-height: 16px;
  padding: 0;
  margin: 0;
  border: 1px solid var(--color-border-hover);
  border-radius: var(--radius-xs);
  background: var(--color-canvas);
  display: inline-grid;
  place-content: center;
  cursor: pointer;
  flex-shrink: 0;
  accent-color: var(--color-accent);
  transition: background-color .14s var(--ease-out), border-color .14s var(--ease-out);
}
input[type="checkbox"]::before {
  content: '';
  width: 9px;
  height: 9px;
  transform: scale(0);
  transition: transform .12s var(--ease-out);
  background: var(--color-on-accent);
  clip-path: polygon(14% 44%, 0 65%, 50% 100%, 100% 16%, 80% 0%, 43% 62%);
}
input[type="checkbox"]:checked {
  background: var(--color-accent);
  border-color: var(--color-accent);
}
input[type="checkbox"]:checked::before { transform: scale(1); }

input[type="radio"] {
  appearance: none;
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  min-height: 16px;
  padding: 0;
  border: 1px solid var(--color-border-hover);
  border-radius: 50%;
  background: var(--color-canvas);
  display: inline-grid;
  place-content: center;
  cursor: pointer;
  accent-color: var(--color-accent);
}
input[type="radio"]::before {
  content: '';
  width: 8px;
  height: 8px;
  border-radius: 50%;
  transform: scale(0);
  background: var(--color-on-accent);
  transition: transform .12s var(--ease-out);
}
input[type="radio"]:checked {
  background: var(--color-accent);
  border-color: var(--color-accent);
}
input[type="radio"]:checked::before { transform: scale(1); }

input[type="file"] {
  padding: 4px 8px;
  min-height: 36px;
  background: var(--color-canvas);
  color: var(--color-text-secondary);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  font-size: 12px;
  max-width: 100%;
}
input[type="file"]::file-selector-button {
  margin-right: 10px;
  padding: 5px 10px;
  min-height: 26px;
  background: var(--color-surface-raised);
  color: var(--color-text-primary);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xs);
  font: 600 11px/1.2 var(--font-sans);
  cursor: pointer;
  transition: background-color .16s var(--ease-out), border-color .16s var(--ease-out);
}
input[type="file"]::file-selector-button:hover {
  background: var(--color-surface-hover);
  border-color: var(--color-border-hover);
}

.mono-num,
.kpi-value,
.metric-box-val,
.pro-table,
#header_clock,
.session-clock-pill,
.ticker-strip,
.topbar-ticker-tape {
  font-variant-numeric: tabular-nums;
}

.mono-num {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: .94em;
  letter-spacing: -.025em;
}

#header_clock,
.clock-display {
  white-space: nowrap;
  flex-shrink: 0;
  font-size: 11px;
  color: var(--color-text-muted);
}

.app-container {
  height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ── Single-Row Architectural Top Command Bar ── */
.header-bar,
.top-command-bar {
  min-height: var(--header-height);
  padding: 8px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: var(--color-header);
  border-bottom: 1px solid var(--color-border-subtle);
  box-shadow: var(--shadow-bevel);
  flex-shrink: 0;
  flex-wrap: nowrap;
  position: relative;
  z-index: 30;
  min-width: 0;
  max-width: 100%;
}

.brand-section,
.brand-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  flex-shrink: 0;
}
.brand-logo { gap: 10px; min-width: 120px; }
.brand-logo > svg { padding: 2px; width: 26px; height: 26px; flex-shrink: 0; }
.brand-title { font-size: 15px; font-weight: 700; letter-spacing: .06em; white-space: nowrap; }
.brand-badge {
  display: inline-block;
  font-size: 10.5px;
  color: var(--color-text-muted);
  font-weight: 500;
  margin-top: 2px;
  white-space: nowrap;
}
.legend-val.pos { color: var(--color-positive); }
.legend-val.neg { color: var(--color-negative); }

.asset-select { min-width: 140px; max-width: 224px; font-size: 12px; }

.header-controls {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  min-width: 0;
  flex: 1 1 auto;
}

.ticker-strip {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 6px;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: none;
  white-space: nowrap;
  padding: 2px 0;
}
.ticker-strip::-webkit-scrollbar { display: none; }

.ticker-chip,
.ticker-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 28px;
  padding: 3px 9px;
  background: var(--color-surface);
  border: 1px solid var(--color-border-subtle);
  border-radius: var(--radius-xs);
  color: var(--color-text-secondary);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  flex-shrink: 0;
}
.ticker-chip strong,
.ticker-item strong { color: var(--color-text-primary); font-family: var(--font-mono); font-weight: 600; }

.topbar-ticker-tape {
  background: var(--color-surface) !important;
  border: 1px solid var(--color-border-subtle) !important;
  border-radius: var(--radius-xs) !important;
  white-space: nowrap;
  flex-shrink: 1;
  min-width: 0;
  overflow: hidden;
}

.topbar-icon-btn,
.auth-btn {
  background: var(--color-surface) !important;
  border: 1px solid var(--color-border) !important;
  color: var(--color-text-secondary) !important;
  min-height: 34px;
  white-space: nowrap;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.topbar-icon-btn:hover,
.auth-btn:hover {
  background: var(--color-surface-hover) !important;
  border-color: var(--color-border-hover) !important;
  color: var(--color-text-primary) !important;
}
.topbar-icon-btn { min-width: 34px; padding: 0 10px; }

.btn-quick-add {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 34px;
  padding: 0 12px;
  background: var(--color-accent);
  color: var(--color-on-accent);
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .01em;
  white-space: nowrap;
  flex-shrink: 0;
  box-shadow: var(--shadow-button-tactile);
}
.btn-quick-add:hover:not(:disabled) {
  background: var(--color-accent);
  color: var(--color-on-accent);
  filter: brightness(1.06);
  border-color: var(--color-border-hover);
}

.session-clock-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 32px;
  padding: 4px 10px;
  background: var(--color-surface);
  border: 1px solid var(--color-border-subtle);
  border-radius: var(--radius-full);
  color: var(--color-text-secondary);
  font: 500 11px/1 var(--font-mono);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  flex-shrink: 0;
}

.status-pill {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 11px;
  white-space: nowrap;
  color: var(--color-text-secondary);
  flex-shrink: 0;
}
.status-dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--color-text-dim);
  flex-shrink: 0;
}
.status-dot.live { background: var(--color-positive); }
.status-dot.stale { background: var(--color-warning); }
.status-dot.offline { background: var(--color-text-muted); }

.mobile-menu-toggle { display: none; }

/* ── App Shell & Sidebar ── */
.app-body { display: flex; flex: 1; min-height: 0; overflow: hidden; }
.app-sidebar {
  width: var(--sidebar-width);
  flex-shrink: 0;
  padding: 20px 12px 72px;
  background: var(--color-sidebar);
  border-right: 1px solid var(--color-border-subtle);
  overflow-y: auto;
  overflow-x: hidden;
}
.nav-category {
  margin: 24px 12px 8px;
  color: var(--color-text-dim);
  text-transform: uppercase;
  font-size: 10px;
  font-weight: 650;
  letter-spacing: .1em;
}
.nav-category:first-child { margin-top: 0; }
.nav-item {
  transition: background-color .16s var(--ease-out), color .16s var(--ease-out), border-color .16s var(--ease-out);
  display: flex;
  align-items: center;
  min-height: 40px;
  padding: 8px 12px;
  gap: 12px;
  border-radius: var(--radius-sm);
  margin-bottom: 4px;
  color: var(--color-text-secondary);
  font-size: 12px;
  border: 1px solid transparent;
}
.nav-item:hover { background: var(--color-surface-hover); color: var(--color-text-primary); }
.nav-item.active {
  color: var(--color-accent);
  background: var(--color-accent-subtle);
  border-color: var(--color-border);
  font-weight: 650;
}
.nav-icon { width: 16px; height: 16px; display: inline-flex; flex-shrink: 0; opacity: .82; }
.nav-item.active .nav-icon { opacity: 1; }

.main-content {
  flex: 1;
  min-width: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 24px 28px 84px;
  background-color: var(--color-canvas);
  background-image: var(--canvas-texture, none);
  background-size: var(--canvas-texture-size, auto);
  background-attachment: local;
}

.view-panel { display: none; width: 100%; max-width: 1720px; margin: 0 auto; min-width: 0; scroll-margin-top: 24px; }
.view-panel.active { display: block; animation: view-arrive .24s var(--ease-out); }

.view-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
  margin-bottom: 24px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--color-border-subtle);
}
.view-title-group h1 {
  margin: 0 0 4px;
  font-size: 27px;
  line-height: 1.3;
  font-weight: 600;
  letter-spacing: -.035em;
}
.view-title-group p { color: var(--color-text-muted); margin: 0; font-size: 12px; }

/* ── KPI & Metric Ribbons ── */
.kpi-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 24px; }
.kpi-card,
.metric-box {
  box-shadow: var(--shadow-card);
  padding: 20px;
  min-width: 0;
  background: var(--color-surface);
  border: 1px solid var(--color-border-subtle);
  border-radius: var(--radius-md);
}
.kpi-card:first-child { border-top: 2px solid var(--color-accent); }
.kpi-card:not(:first-child) { border-top: 2px solid var(--color-border); }
.kpi-label,
.metric-box-title {
  color: var(--color-text-muted);
  text-transform: uppercase;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: .045em;
}
.kpi-value {
  margin: 14px 0 10px;
  font-size: 30px;
  font-weight: 500;
  letter-spacing: -.04em;
  line-height: 1.25;
  font-variant-numeric: tabular-nums;
}
.kpi-subtext,
.metric-box-sub { color: var(--color-text-dim); font-size: 11px; }

/* ── Panels & Grids ── */
.workspace-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 16px;
  align-items: start;
  margin-bottom: 16px;
}
.panel {
  box-shadow: var(--shadow-card);
  min-width: 0;
  background: var(--color-surface);
  border: 1px solid var(--color-border-subtle);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 12px 16px;
  min-height: 54px;
  border-bottom: 1px solid var(--color-border-subtle);
}
.panel-title { font-size: 13px; font-weight: 600; }

.chart-controls { display: flex; gap: 4px; flex-wrap: wrap; }
.tf-btn { padding: 6px 10px; min-height: 32px; font-size: 11px; box-shadow: none; }
.tf-btn.active,
.filter-btn.active,
.chip-btn.active,
.order-type-btn.active {
  background: var(--color-accent-subtle);
  color: var(--color-accent);
  border-color: var(--color-border-hover);
}

.chart-container-box {
  position: relative;
  height: clamp(340px, 43vh, 560px);
  min-height: 340px;
  width: 100%;
}
.chart-outage-banner {
  position: absolute;
  left: 16px;
  top: 16px;
  right: 16px;
  display: none;
  z-index: 3;
  background: var(--color-surface-raised);
  color: var(--color-text-secondary);
  border: 1px solid var(--color-border);
  padding: 12px;
  border-radius: var(--radius-sm);
  font-size: 12px;
}
.chart-outage-banner.active { display: block; }
.outage-badge { color: var(--color-warning); }
.outage-time { color: var(--color-text-muted); margin-left: 8px; }

/* ── Order Ticket ── */
.order-ticket { padding: 16px; }
.ticket-input-group { margin-bottom: 16px; min-width: 0; }
.ticket-label {
  display: block;
  color: var(--color-text-muted);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .05em;
  margin-bottom: 6px;
  font-weight: 600;
}
.ticket-input { width: 100%; font-family: var(--font-mono); font-size: 13px; font-variant-numeric: tabular-nums; }
.ticket-input:focus { border-color: var(--color-accent); }

.side-toggle,
.chips-row { display: flex; gap: 8px; }
.side-toggle { margin: 16px 0; }
.btn-side { flex: 1; }
.btn-side.buy.active {
  color: var(--color-positive);
  background: var(--color-positive-subtle);
  border-color: var(--color-positive);
}
.btn-side.sell.active {
  color: var(--color-negative);
  background: var(--color-negative-subtle);
  border-color: var(--color-negative);
}
.chip-btn { flex: 1; padding: 6px 4px; min-width: 0; min-height: 30px; font-size: 10px; font-variant-numeric: tabular-nums; }

.btn-submit-order {
  width: 100%;
  min-height: 44px;
  background: var(--color-accent);
  color: var(--color-on-accent, var(--color-canvas));
  border-color: transparent;
  font-size: 13px;
  letter-spacing: .01em;
}
.btn-submit-order:hover:not(:disabled) {
  background: var(--color-text-primary);
  color: var(--color-canvas);
}
.btn-submit-order.sell,
.btn-submit-order.sell-mode {
  background: var(--color-negative);
  color: var(--color-on-negative, var(--color-canvas));
}
.btn-submit-order.sell:hover:not(:disabled),
.btn-submit-order.sell-mode:hover:not(:disabled) {
  background: var(--color-negative-subtle);
  color: var(--color-negative);
  border-color: var(--color-negative);
}

.btn-kill-switch,
.btn-kill {
  background: var(--color-negative-subtle);
  color: var(--color-negative);
  border-color: var(--color-negative);
}

/* ── Tables & Blotters ── */
.table-container {
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.pro-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.pro-table th {
  text-align: left;
  padding: 12px 16px;
  color: var(--color-text-muted);
  font-weight: 550;
  font-size: 10px;
  letter-spacing: .06em;
  border-bottom: 1px solid var(--color-border);
  background: var(--color-surface-raised);
}
.pro-table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--color-border-subtle);
  vertical-align: middle;
}
.pro-table tbody tr:hover { background: var(--color-surface-hover); }
.data-pending td,
.data-unknown { color: var(--color-text-muted); }
.data-pending td { padding: 28px 16px; text-align: center; }

.badge,
.trend-tag {
  display: inline-flex;
  align-items: center;
  font-size: 10px;
  font-weight: 600;
  padding: 3px 7px;
  border-radius: var(--badge-radius, var(--radius-xs));
  border: 1px solid var(--color-border);
  color: var(--color-text-secondary);
}
.badge.pos,
.trend-tag.buy,
.trend-tag.bull {
  color: var(--color-positive);
  background: var(--color-positive-subtle);
  border-color: color-mix(in srgb, var(--color-positive) 45%, transparent);
}
.badge.neg,
.trend-tag.sell,
.trend-tag.bear {
  color: var(--color-negative);
  background: var(--color-negative-subtle);
  border-color: color-mix(in srgb, var(--color-negative) 45%, transparent);
}

.blotter-tab-btn {
  padding: 12px 16px;
  border: 0;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}
.blotter-tab-btn.active { color: var(--color-accent); border-bottom-color: var(--color-accent); }

.metric-strip { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 20px; }
.metric-box-val { font-size: 22px; font-variant-numeric: tabular-nums; margin: 12px 0; }
.filter-strip { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.action-card-item {
  padding: 16px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
}
.activity-log-stream { padding: 16px; max-height: 400px; overflow: auto; font: 12px/1.8 var(--font-mono); }

/* ── Modals & Command Palette ── */
.modal-overlay,
.cmd-palette-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(8, 11, 15, .72);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal-overlay.open,
.modal-overlay.active,
.cmd-palette-overlay.open,
.cmd-palette-overlay.active { display: flex; }

body.auth-locked {
  overflow: hidden;
}
body.auth-locked .app-container,
body.auth-locked #execution_hud_dock {
  visibility: hidden;
  pointer-events: none;
}
body.auth-locked #login_modal_overlay {
  z-index: 130;
  background:
    radial-gradient(circle at 20% 20%, color-mix(in srgb, var(--color-accent) 18%, transparent), transparent 52%),
    radial-gradient(circle at 80% 80%, color-mix(in srgb, var(--color-positive) 12%, transparent), transparent 48%),
    var(--color-canvas);
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}
body.auth-locked #btn_close_login_modal {
  display: none;
}
.login-error-banner {
  margin: 0;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--color-negative);
  background: color-mix(in srgb, var(--color-negative) 12%, transparent);
  color: var(--color-negative);
  font-size: 12.5px;
  font-weight: 500;
}

.modal-card,
.cmd-palette-card {
  animation: dialog-arrive .2s var(--ease-out);
  box-shadow: var(--shadow-floating);
  width: 100%;
  max-width: 480px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  max-height: 90dvh;
  overflow: auto;
}
.modal-header,
.modal-footer,
.cmd-palette-header {
  padding: 18px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--color-border-subtle);
}
.modal-footer { border-top: 1px solid var(--color-border-subtle); border-bottom: 0; justify-content: flex-end; }
.modal-body { padding: 20px; }
.modal-title { margin: 0; font-size: 18px; font-weight: 600; }
.btn-close-modal,
.modal-close { border: 0; background: transparent; box-shadow: none; font-size: 20px; min-height: 36px; min-width: 36px; }
.cmd-palette-header svg { flex-shrink: 0; }
.cmd-palette-header input { flex: 1 1 auto; min-width: 0; width: auto; background: transparent; border: 0; }
.cmd-badge { font-size: 10px; color: var(--color-text-muted); font-family: var(--font-mono); white-space: nowrap; flex-shrink: 0; }
.cmd-item { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 20px; cursor: pointer; }
.cmd-item:hover,
.cmd-item.selected,
.cmd-item.active { background: var(--color-surface-hover); }
.cmd-item-title { font-size: 13px; }
.cmd-palette-results { max-height: 400px; overflow: auto; }
.cmd-palette-empty { padding: 18px 20px; font-size: 12.5px; color: var(--color-text-muted); text-align: center; }
.btn-confirm { background: var(--color-accent); color: var(--color-on-accent, var(--color-canvas)); border-color: transparent; }
.modal-card > p { margin: 16px 20px !important; }
.modal-card > div:not(.modal-header):not(.modal-footer):not(.modal-body):not(.quick-add-tabs):not(.quick-add-body) { padding: 20px; }

/* ── Toasts & Non-Overlapping Bottom-Right Floating Execution HUD ── */
.toast-container {
  position: fixed;
  right: 18px;
  bottom: 72px;
  z-index: 150;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: min(400px, calc(100vw - 32px));
}
.toast {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 16px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  color: var(--color-text-primary);
  background: var(--color-surface-raised);
  box-shadow: var(--shadow-elevated);
  font-size: 12px;
}
.toast > span:first-child {
  flex: 0 0 auto;
  font-weight: 700;
  line-height: 1.35;
}
.toast > span:last-child {
  flex: 1 1 auto;
  min-width: 0;
  line-height: 1.35;
}
.toast.error,
.toast-error { border-left: 3px solid var(--color-negative); }
.toast.success,
.toast-success { border-left: 3px solid var(--color-positive); }
.toast.warning,
.toast-warning { border-left: 3px solid var(--color-warning); }

.btn-side {
  min-height: 32px;
  font-size: 12px;
  font-weight: 600;
  border-radius: var(--radius-xs);
  border: 1px solid var(--color-border);
  background: var(--color-surface-active, var(--color-surface-raised));
  color: var(--color-text-secondary);
  cursor: pointer;
}
.btn-side.buy.active {
  background: var(--color-positive);
  color: var(--color-on-positive, var(--color-on-accent));
  border-color: transparent;
}
.btn-side.sell.active {
  background: var(--color-negative);
  color: var(--color-on-negative, var(--color-on-accent));
  border-color: transparent;
}

.execution-hud-dock,
#execution_hud_dock {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 40;
  width: 100%;
  height: var(--hud-height, 44px);
  min-height: var(--hud-height, 44px);
  box-sizing: border-box;
  background: color-mix(in srgb, var(--color-surface-raised) 95%, transparent);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 0;
  border-top: 1px solid var(--color-border);
  border-radius: 0;
  box-shadow: 0 -4px 16px rgba(10, 18, 28, .10);
  color: var(--color-text-primary);
  padding: 6px 20px;
  display: flex;
  align-items: center;
  transition: width .18s var(--ease-out), padding .18s var(--ease-out), border-radius .18s var(--ease-out), border-color .18s var(--ease-out);
}
.hud-inner {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: nowrap;
  min-width: 0;
}
.hud-inner > div:first-child { min-width: 0; overflow: hidden; }
.hud-inner > div:last-child { flex-shrink: 0; }
.hud-hotkey-btn {
  min-height: 28px;
  padding: 0 9px;
  font-size: 11px;
  font-weight: 600;
  border-radius: var(--radius-xs);
  white-space: nowrap;
}
.hud-toggle-btn {
  margin-left: auto;
  min-height: 28px;
  min-width: 28px;
  padding: 0 8px;
  border-radius: var(--radius-xs);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.execution-hud-dock.minimized,
.execution-hud-dock.hud-minimized,
#execution_hud_dock.minimized,
#execution_hud_dock.hud-minimized {
  left: auto;
  right: 16px;
  bottom: 12px;
  width: auto;
  min-height: 36px;
  padding: 4px 10px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-full);
  box-shadow: var(--shadow-floating);
}
.execution-hud-dock.minimized .hud-inner > :first-child,
.execution-hud-dock.hud-minimized .hud-inner > :first-child,
.execution-hud-dock.minimized .hud-hotkey-btn,
.execution-hud-dock.hud-minimized .hud-hotkey-btn,
.execution-hud-dock.minimized .hud-meta,
.execution-hud-dock.hud-minimized .hud-meta,
.execution-hud-dock.minimized .hud-shortcuts,
.execution-hud-dock.hud-minimized .hud-shortcuts {
  display: none !important;
}

/* ── Allocation Bar ── */
.allocation-panel {
  padding: 16px 20px;
  margin-bottom: 24px;
  border: 1px solid var(--color-border-subtle);
  border-radius: var(--radius-lg);
  background: var(--color-surface);
}
.allocation-heading {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
  font-size: 11px;
  color: var(--color-text-muted);
}
.eyebrow { color: var(--color-text-secondary); font-weight: 600; }
.allocation-bar,
.allocation-track {
  display: flex;
  width: 100%;
  height: 8px;
  border-radius: var(--radius-xs);
  overflow: hidden;
  gap: 3px;
  background: var(--color-border-subtle);
}
.allocation-segment { display: block; height: 100%; }
.allocation-color-0 { background: var(--alloc-color-0, #80d6bc); }
.allocation-color-1 { background: var(--alloc-color-1, #8abedb); }
.allocation-color-2 { background: var(--alloc-color-2, #c1b0db); }
.allocation-color-3 { background: var(--alloc-color-3, #e9bf75); }
.allocation-color-4 { background: var(--alloc-color-4, #a8b5b0); }
.allocation-legend {
  display: flex;
  gap: 20px;
  flex-wrap: wrap;
  margin: 12px 0 6px;
  font-size: 11px;
  color: var(--color-text-secondary);
}
.allocation-legend > span { display: inline-flex; align-items: center; gap: 7px; }
.allocation-legend i { width: 7px; height: 7px; border-radius: 2px; }
.allocation-legend strong { font: 11px var(--font-mono); color: var(--color-text-primary); margin-left: 4px; font-variant-numeric: tabular-nums; }
.allocation-caption,
.allocation-empty { color: var(--color-text-muted); font-size: 11px; }
.allocation-empty > span:last-child { display: block; margin-top: 10px; }
.allocation-track {
  background: repeating-linear-gradient(90deg, var(--color-border) 0, var(--color-border) calc(20% - 3px), transparent calc(20% - 3px), transparent 20%);
}

@keyframes view-arrive { from { opacity: .5; transform: translateY(5px); } to { opacity: 1; transform: translateY(0); } }
@keyframes dialog-arrive { from { opacity: 0; transform: translateY(8px) scale(.99); } to { opacity: 1; transform: translateY(0) scale(1); } }

/* ── Dashboard Widgets ── */
.dashboard-widgets { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 20px; }
.widget-body { padding: 20px; }
.widget-caption,
.widget-footnote { color: var(--color-text-muted); font-size: 11px; }
.widget-footnote { margin: 16px 0 0; }
.widget-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 150px;
  color: var(--color-text-muted);
  font-size: 12px;
  text-align: center;
}
.health-row {
  display: grid;
  grid-template-columns: 76px minmax(20px, 1fr) 76px 44px;
  gap: 12px;
  align-items: center;
  min-height: 34px;
  font-size: 11px;
}
.health-row > :last-child { text-align: right; color: var(--color-text-muted); }
.health-meter { height: 4px; background: var(--color-border-subtle); border-radius: 2px; overflow: hidden; }
.health-meter i { display: block; height: 100%; background: var(--color-positive); }
.widget-positive { color: var(--color-positive); }
.widget-negative { color: var(--color-negative); }
.widget-muted { color: var(--color-text-muted); }
.mix-layout { display: flex; gap: 28px; align-items: center; min-height: 136px; }
.mix-ring {
  flex-shrink: 0;
  position: relative;
  width: 128px;
  height: 128px;
  border-radius: 50%;
  background: conic-gradient(var(--color-positive) var(--buy-share, 50%), var(--color-negative) 0);
}
.mix-ring::before { content: ''; position: absolute; inset: 10px; background: var(--color-surface); border-radius: 50%; }
.mix-ring > span {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  font: 28px var(--font-mono);
  font-variant-numeric: tabular-nums;
}
.mix-ring small { font: 11px var(--font-sans); color: var(--color-text-muted); margin-top: 4px; }
.mix-details { flex: 1; }
.mix-details > div {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 6px 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--color-border-subtle);
  font-size: 12px;
}
.mix-details strong { font: 13px var(--font-mono); font-variant-numeric: tabular-nums; }
.mix-details > div > :last-child { color: var(--color-text-muted); font: 11px var(--font-mono); font-variant-numeric: tabular-nums; }
.dashboard-widgets .panel { transition: border-color .2s; }
.dashboard-widgets .panel:hover { border-color: var(--color-border-hover); }

/* ── Workstation Editorial Swiss-Desk Layer ── */
body { font-size: 15px; }
.app-sidebar {
  --color-text-primary: #f3f7fa;
  --color-text-secondary: #d6e1e9;
  --color-text-muted: #b7cad8;
  --color-text-dim: #a6bdce;
  --color-surface-hover: #23445e;
  --color-surface-raised: #1b3a53;
  --color-border: #456277;
  --color-accent: #d4e0ff;
  --color-accent-subtle: #294fb9;
  background: #142e45;
  padding-top: 24px;
}
.nav-category { font-size: 10px; letter-spacing: .12em; margin-top: 28px; }
.nav-item { font-size: 13px; min-height: 42px; margin-bottom: 5px; border-radius: var(--radius-sm); }
.nav-item.active { background: #294fb9; color: #fff; border-color: #5478d9; box-shadow: none; }
.nav-item.active .nav-icon { color: #fff; }
.brand-title { font-weight: 700; letter-spacing: .055em; font-size: 16px; }
.view-title-group h1 { font: 600 32px/1.15 var(--font-display); letter-spacing: -.035em; margin-bottom: 8px; }
.view-title-group p { font-size: 13px; }
#view_terminal .view-header { border: 0; padding-bottom: 4px; margin-bottom: 24px; }
.panel { border-radius: var(--radius-xl); box-shadow: var(--shadow-card); }
.panel-header { background: transparent; padding: 14px 20px; border-bottom-color: var(--color-border-subtle); }
.panel-title { font-size: 14.5px; font-weight: 600; }
.kpi-label,
.metric-box-title { text-transform: none; font-size: 12px; letter-spacing: .01em; }
.kpi-subtext,
.metric-box-sub { font-size: 12px; }

#view_terminal .kpi-grid {
  grid-template-columns: 1.35fr 1fr 1fr .8fr;
  gap: 0;
  padding: 0;
  overflow: hidden;
  border-radius: var(--radius-xl);
  border: 1px solid var(--color-border-subtle);
  background: var(--color-surface);
  box-shadow: var(--shadow-card);
  margin-bottom: 20px;
}
#view_terminal .kpi-card {
  border: 0;
  border-left: 1px solid var(--color-border-subtle);
  border-radius: 0;
  padding: 22px 24px;
  background: transparent;
  box-shadow: none;
}
#view_terminal .kpi-card:first-child { background: #142e45; color: #fff; border-left: 0; }
#view_terminal .kpi-card:first-child .kpi-label,
#view_terminal .kpi-card:first-child .kpi-subtext { color: #c7d8e5; }
#view_terminal .kpi-value {
  font: 500 34px/1.2 var(--font-sans);
  font-variant-numeric: tabular-nums;
  letter-spacing: -.045em;
  margin: 14px 0 10px;
}
#view_terminal .kpi-card:first-child .kpi-value { font-size: 42px; color: #fff; }
#view_terminal .allocation-panel {
  border: 0;
  border-radius: 0;
  background: transparent;
  padding: 4px 0 16px;
  border-bottom: 1px solid var(--color-border);
  margin-bottom: 24px;
}

button { font-size: 12px; border-radius: var(--radius-sm); }
input:not([type="checkbox"]):not([type="radio"]):not([type="file"]),
select,
textarea { border-radius: var(--radius-sm); }

#view_terminal .view-header { margin-bottom: 16px; padding-bottom: 10px; }
#view_terminal .kpi-grid { margin-bottom: 16px; }
#view_terminal .kpi-card { padding: 16px 20px; }
#view_terminal .kpi-value { margin: 8px 0; font-size: 28px; }
#view_terminal .allocation-panel {
  display: grid;
  grid-template-columns: 180px minmax(0, 1fr);
  align-items: center;
  gap: 24px;
  padding: 12px 20px;
  margin-bottom: 16px;
}
#view_terminal .allocation-heading { display: grid; gap: 4px; margin: 0; }
#view_terminal .allocation-caption { display: block; margin-top: 6px; }
#view_terminal .order-ticket { padding: 12px 16px 16px; }
#view_terminal .ticket-input-group { margin-bottom: 10px; }
#view_terminal .ticket-label { text-transform: none; font-size: 12px; letter-spacing: 0; margin-bottom: 6px; }
#view_terminal .side-toggle { margin: 8px 0; }
#view_terminal .order-type-btn { flex: 1; border-radius: var(--radius-sm); min-height: 36px; }
#view_terminal .order-type-btn.active { border-color: var(--color-accent); background: var(--color-accent-subtle); color: var(--color-accent); }
#view_terminal .ticket-input { border-radius: var(--radius-sm); }
#view_terminal .chart-controls {
  padding: 3px;
  border: 1px solid var(--color-border-subtle);
  border-radius: var(--radius-md);
  background: var(--color-canvas);
}
#view_terminal .tf-btn { border-color: transparent; background: transparent; }
#view_terminal .tf-btn.active { background: var(--color-surface-active); color: var(--color-accent); border-color: var(--color-border); }
#view_terminal #btn_term_kill { background: var(--color-negative-subtle); }
#view_terminal .btn-submit-order { background: var(--color-accent); color: var(--color-canvas); font-size: 13px; }
:root[data-theme="light"] #view_terminal .btn-submit-order { color: #fff; }
#view_terminal .btn-submit-order.sell-mode { background: var(--color-negative); color: var(--color-on-negative, var(--color-canvas)); }

.chart-outage-banner {
  top: 50%;
  transform: translateY(-50%);
  padding: 20px 28px;
  margin: auto;
  max-width: 440px;
  text-align: center;
  background: transparent;
  border: 0;
}
.chart-outage-banner p { margin: 16px auto; }
.outage-badge { font-size: 13px; font-weight: 500; }

.dashboard-widgets { grid-template-columns: 1fr 1.15fr 1.15fr; gap: 24px; }
.dashboard-widgets > .panel { border-radius: var(--radius-xl); }
.dashboard-widgets > .panel:first-child { border: 0; background: transparent; box-shadow: none; }
.dashboard-widgets > .panel:first-child .panel-header { padding-left: 0; padding-right: 0; }
.dashboard-widgets > .panel:first-child .widget-body { padding-left: 0; padding-right: 0; }
.dashboard-widgets > .panel:last-child {
  --color-surface: #142e45;
  --color-text-primary: #f3f7fa;
  --color-text-secondary: #d6e1e9;
  --color-text-muted: #b7cad8;
  --color-border-subtle: #37566c;
  --color-border-hover: #718fa3;
  --color-positive: #90dfc2;
  --color-negative: #ffb3be;
  background: #142e45;
  color: #f3f7fa;
  border-color: #37566c;
}
.dashboard-widgets .widget-body { padding: 20px; }
.widget-caption,
.widget-footnote { font-size: 11px; }
.health-row { grid-template-columns: 66px minmax(16px, 1fr) 66px 32px; gap: 8px; min-height: 36px; }
.mix-layout { gap: 20px; }
.mix-ring { width: 120px; height: 120px; }
.mix-ring > span { font: 400 40px var(--font-display); font-variant-numeric: tabular-nums; }
.mix-details > div { font-size: 12px; }

.pnl-row { padding: 12px 0 14px; }
.pnl-row > div:first-child { display: flex; justify-content: space-between; gap: 12px; margin-bottom: 12px; font-size: 13px; }
.pnl-track { position: relative; height: 8px; background: var(--color-border-subtle); border-radius: 2px; }
.pnl-track::before { content: ''; position: absolute; left: 50%; top: -3px; bottom: -3px; width: 1px; background: var(--color-border-hover); }
.pnl-track i { position: absolute; height: 100%; border-radius: 2px; }
.pnl-track .gain { left: 50%; background: var(--color-positive); }
.pnl-track .loss { right: 50%; background: var(--color-negative); }

#terminal_fleet_cards_row,
#fleet_page_cards_row {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 0;
  margin-bottom: 16px;
  background: var(--color-surface);
  border: 1px solid var(--color-border-subtle);
  border-radius: var(--radius-xl);
  padding: 8px;
  box-shadow: var(--shadow-card);
}
#terminal_fleet_cards_row > .panel,
#fleet_page_cards_row > .panel {
  min-width: 0;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  border: 0 !important;
  border-right: 1px solid var(--color-border-subtle) !important;
  border-radius: 0 !important;
  background: transparent !important;
  box-shadow: none;
}
#terminal_fleet_cards_row > .panel:last-child,
#fleet_page_cards_row > .panel:last-child { border-right: 0 !important; }

.pro-table { font-size: 13px; }
.pro-table th { font-size: 11px; text-transform: none; letter-spacing: .02em; }
.pro-table td { padding-top: 14px; padding-bottom: 14px; }
.pro-table th,
.pro-table td { padding-left: 12px; padding-right: 12px; }

.theme-controls { display: flex; gap: 8px; margin: 24px 4px 0; padding-top: 16px; border-top: 1px solid var(--color-border); }
.theme-controls button { flex: 1; min-width: 0; padding: 8px 6px; }
.theme-option-btn.active { background: var(--color-accent-subtle); color: var(--color-accent); }

.view-panel.active .dashboard-widgets > .panel { animation: summary-arrive .35s var(--ease-out) both; }
@keyframes summary-arrive { from { opacity: .5; transform: translateY(5px); } to { opacity: 1; transform: translateY(0); } }
#tab_btn_ticket.active,
.blotter-tab-btn.active { border-bottom-color: var(--color-accent) !important; }

/* ── Restored Chart Tools & Risk Form ── */
.restored-chart-tools { padding: 12px 20px; border-bottom: 1px solid var(--color-border-subtle); }
.restored-legend { display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: baseline; font-size: 11px; color: var(--color-text-muted); }
.restored-legend strong,
.restored-legend b { color: var(--color-text-primary); font-weight: 500; font-variant-numeric: tabular-nums; }
.restored-legend b { margin-left: 4px; }
.restored-overlays { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.overlay-control { min-height: 32px; padding: 4px 10px; font-size: 11px; background: transparent; box-shadow: none; }
.overlay-control.active { background: var(--color-accent-subtle); color: var(--color-accent); border-color: var(--color-border-hover); }

.restored-risk-panel { margin-bottom: 20px; }
.restored-risk-form { display: flex; align-items: end; flex-wrap: wrap; gap: 16px; padding: 20px; }
.restored-risk-form label { display: grid; gap: 8px; font-size: 12px; color: var(--color-text-secondary); }
.restored-risk-form output { flex-basis: 100%; font: 20px var(--font-mono); font-variant-numeric: tabular-nums; color: var(--color-text-primary); }

/* ── Dedicated Institutional Workstation Modules ── */

/* 1. Provenance Badges (Live Broker, Measured Snapshot, Derived, Imported, Hypothetical) */
.provenance-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 22px;
  padding: 3px 9px;
  border-radius: var(--radius-full);
  border: 1px solid var(--color-border);
  background: var(--color-surface-raised);
  color: var(--color-text-secondary);
  font: 600 10px/1.1 var(--font-sans);
  letter-spacing: .04em;
  text-transform: uppercase;
  white-space: nowrap;
  vertical-align: middle;
}
.provenance-pill::before {
  content: '';
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: currentColor;
  flex-shrink: 0;
}
.provenance-pill.live,
.provenance-pill.live-broker,
.provenance-pill[data-provenance="live"] {
  background: var(--color-positive-subtle);
  color: var(--color-positive);
  border-color: color-mix(in srgb, var(--color-positive) 45%, transparent);
}
.provenance-pill.snapshot,
.provenance-pill.measured,
.provenance-pill[data-provenance="snapshot"] {
  background: var(--color-cyan-subtle);
  color: var(--color-cyan);
  border-color: color-mix(in srgb, var(--color-cyan) 45%, transparent);
}
.provenance-pill.derived,
.provenance-pill[data-provenance="derived"] {
  background: var(--color-accent-subtle);
  color: var(--color-accent);
  border-color: color-mix(in srgb, var(--color-accent) 45%, transparent);
}
.provenance-pill.imported,
.provenance-pill[data-provenance="imported"] {
  background: var(--color-surface-raised);
  color: var(--color-text-secondary);
  border-color: var(--color-border);
}
.provenance-pill.hypothetical,
.provenance-pill[data-provenance="hypothetical"] {
  background: var(--color-warning-subtle);
  color: var(--color-warning);
  border-color: color-mix(in srgb, var(--color-warning) 45%, transparent);
}

/* 2. Global Session Clock & Order Flow Imbalance Bar */
.session-flow-bar {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(0, 1fr);
  gap: 16px;
  align-items: center;
  padding: 10px 16px;
  margin-bottom: 16px;
  background: var(--color-surface);
  border: 1px solid var(--color-border-subtle);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  font-variant-numeric: tabular-nums;
}
.session-clocks,
.session-clock-group {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.session-chip,
.session-pill,
.session-node {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 5px 10px;
  background: var(--color-surface-raised);
  border: 1px solid var(--color-border-subtle);
  border-radius: var(--radius-xs);
  color: var(--color-text-muted);
  font-size: 11px;
  font-family: var(--font-mono);
  white-space: nowrap;
}
.session-chip.is-open,
.session-chip.active,
.session-pill.is-open,
.session-pill.active,
.session-node[data-open="true"] {
  background: var(--color-positive-subtle);
  border-color: color-mix(in srgb, var(--color-positive) 45%, transparent);
  color: var(--color-positive);
}
.order-flow-bar,
.flow-imbalance-wrap {
  display: grid;
  gap: 6px;
  min-width: 0;
}
.flow-imbalance-meta,
.order-flow-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  font-size: 11px;
  color: var(--color-text-secondary);
}
.flow-imbalance-track,
.flow-meter {
  display: flex;
  height: 6px;
  width: 100%;
  border-radius: var(--radius-xs);
  overflow: hidden;
  gap: 2px;
  background: var(--color-border-subtle);
}
.flow-buy,
.buy-bar { height: 100%; background: var(--color-positive); transition: width .24s var(--ease-out); }
.flow-sell,
.sell-bar { height: 100%; background: var(--color-negative); transition: width .24s var(--ease-out); }

/* 3. Portfolio Equity Trajectory Card */
.equity-traj-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border-subtle);
  border-radius: var(--radius-xl);
  padding: 16px 20px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-card);
  min-width: 0;
  font-variant-numeric: tabular-nums;
}
.equity-traj-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 12px;
}
.equity-traj-svg-wrap,
.equity-traj-card svg {
  width: 100%;
  height: auto;
  display: block;
  overflow: visible;
}
.equity-traj-line { fill: none; stroke: var(--color-accent); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.equity-traj-area { fill: var(--color-accent); fill-opacity: .12; }
.equity-traj-grid { stroke: var(--color-border-subtle); stroke-dasharray: 2 3; stroke-width: 1; }
.equity-traj-card svg text { fill: var(--color-text-muted); font: 500 10px/1 var(--font-mono); font-variant-numeric: tabular-nums; }
.equity-traj-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 10px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--color-border-subtle);
  font-size: 11.5px;
}

/* 4. Extended Indicator Strip & Oscillator Subpane */
.ext-indicator-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px 12px;
  padding: 10px 16px;
  background: var(--color-surface-raised);
  border-bottom: 1px solid var(--color-border-subtle);
}
.ext-indicator-toggles { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.ext-indicator-selects { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.ext-indicator-strip button,
.ext-indicator-strip .indicator-toggle {
  min-height: 30px;
  padding: 4px 10px;
  font-size: 11px;
  font-weight: 600;
  border-radius: var(--radius-xs);
  background: var(--color-surface);
  color: var(--color-text-secondary);
  border: 1px solid var(--color-border);
  box-shadow: none;
}
.ext-indicator-strip button.active,
.ext-indicator-strip button[aria-pressed="true"] {
  background: var(--color-accent-subtle);
  color: var(--color-accent);
  border-color: var(--color-accent);
}
.ext-indicator-strip select {
  min-height: 30px;
  padding: 3px 10px;
  font-size: 11px;
  border-radius: var(--radius-xs);
  background: var(--color-canvas);
  color: var(--color-text-primary);
}

.oscillator-subpane {
  border-top: 1px solid var(--color-border-subtle);
  background: var(--color-surface);
  padding: 10px 16px 12px;
  min-height: 112px;
  position: relative;
  font-variant-numeric: tabular-nums;
}
.oscillator-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 6px;
  font-size: 11px;
  color: var(--color-text-muted);
}
.oscillator-subpane svg { width: 100%; height: 84px; display: block; overflow: visible; }
.osc-threshold { stroke: var(--color-border); stroke-dasharray: 3 3; stroke-width: 1; }
.osc-line-rsi { fill: none; stroke: var(--color-cyan); stroke-width: 1.75; }
.osc-line-macd { fill: none; stroke: var(--color-accent); stroke-width: 1.75; }
.osc-line-signal { fill: none; stroke: var(--color-warning); stroke-width: 1.4; }
.osc-hist-pos { fill: var(--color-positive); fill-opacity: .58; }
.osc-hist-neg { fill: var(--color-negative); fill-opacity: .58; }

/* 5. Level 2 DOM Depth Ladder */
.dom-ladder {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 10px 12px;
  font-family: var(--font-mono);
  font-size: 11.5px;
  font-variant-numeric: tabular-nums;
}
.dom-header {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
  padding: 4px 6px 6px;
  font-family: var(--font-sans);
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--color-text-muted);
  border-bottom: 1px solid var(--color-border-subtle);
}
.dom-row,
.dom-ask-row,
.dom-bid-row {
  position: relative;
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  align-items: center;
  gap: 8px;
  padding: 4px 6px;
  border-radius: var(--radius-xs);
  overflow: hidden;
  transition: background-color .14s var(--ease-out);
}
.dom-row:hover,
.dom-ask-row:hover,
.dom-bid-row:hover { background: var(--color-surface-hover); }
.dom-row > *,
.dom-ask-row > *,
.dom-bid-row > * { position: relative; z-index: 1; }
.dom-row > :nth-child(2),
.dom-row > :nth-child(3),
.dom-ask-row > :nth-child(2),
.dom-ask-row > :nth-child(3),
.dom-bid-row > :nth-child(2),
.dom-bid-row > :nth-child(3) { text-align: right; }
.dom-ask-row > :first-child { color: var(--color-negative); font-weight: 600; }
.dom-bid-row > :first-child { color: var(--color-positive); font-weight: 600; }
.dom-depth-bar,
.dom-bar {
  position: absolute;
  top: 1px;
  bottom: 1px;
  right: 0;
  z-index: 0 !important;
  pointer-events: none;
  border-radius: 2px;
}
.dom-ask-row .dom-depth-bar,
.dom-ask-row .dom-bar { background: color-mix(in srgb, var(--color-negative) 18%, transparent); }
.dom-bid-row .dom-depth-bar,
.dom-bid-row .dom-bar { background: color-mix(in srgb, var(--color-positive) 18%, transparent); }
.dom-spread-bar,
.dom-spread {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 10px;
  margin: 4px 0;
  background: var(--color-surface-raised);
  border: 1px solid var(--color-border-subtle);
  border-radius: var(--radius-xs);
  font-size: 11px;
  font-weight: 600;
  color: var(--color-text-primary);
}

/* 6. Multi-Timeframe Confluence Grid & Cross-Asset Correlation Heatmap */
.mtf-confluence-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 10px;
  padding: 16px;
}
.mtf-card,
.mtf-row {
  padding: 12px 14px;
  background: var(--color-surface-raised);
  border: 1px solid var(--color-border-subtle);
  border-radius: var(--radius-md);
  display: grid;
  gap: 10px;
  min-width: 0;
}
.mtf-cells {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 4px;
}
.mtf-cell,
.mtf-pill {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 6px 4px;
  border-radius: var(--radius-xs);
  border: 1px solid var(--color-border-subtle);
  background: var(--color-surface);
  color: var(--color-text-muted);
  font-size: 10px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  text-align: center;
}
.mtf-cell.bull,
.mtf-pill.bull,
.mtf-cell[data-bias="bull"] {
  background: var(--color-positive-subtle);
  color: var(--color-positive);
  border-color: color-mix(in srgb, var(--color-positive) 45%, transparent);
}
.mtf-cell.bear,
.mtf-pill.bear,
.mtf-cell[data-bias="bear"] {
  background: var(--color-negative-subtle);
  color: var(--color-negative);
  border-color: color-mix(in srgb, var(--color-negative) 45%, transparent);
}

.correlation-heatmap-wrap {
  padding: 16px 20px;
  background: var(--color-surface);
  border: 1px solid var(--color-border-subtle);
  border-radius: var(--radius-xl);
  margin-top: 16px;
  overflow-x: auto;
  box-shadow: var(--shadow-card);
  font-variant-numeric: tabular-nums;
}
.correlation-heatmap-wrap svg { width: 100%; max-width: 680px; height: auto; display: block; margin: 0 auto; }
.correlation-heatmap-wrap svg rect { rx: 4px; stroke: var(--color-surface); stroke-width: 2px; transition: opacity .15s; }
.correlation-heatmap-wrap svg rect:hover { stroke: var(--color-text-primary); stroke-width: 1.5px; }
.correlation-heatmap-wrap svg text { font: 600 11px/1 var(--font-mono); font-variant-numeric: tabular-nums; fill: var(--color-text-primary); }

/* 7. Strategy Radar & Parameter Drawer */
.strategy-radar-wrap {
  background: var(--color-surface);
  border: 1px solid var(--color-border-subtle);
  border-radius: var(--radius-xl);
  padding: 18px 20px;
  margin-bottom: 16px;
  display: grid;
  grid-template-columns: minmax(220px, 340px) minmax(0, 1fr);
  gap: 20px;
  align-items: center;
  box-shadow: var(--shadow-card);
}
.strategy-radar-wrap svg { width: 100%; max-width: 320px; height: auto; display: block; margin: 0 auto; }
.radar-grid { fill: none; stroke: var(--color-border-subtle); stroke-width: 1; }
.radar-axis { stroke: var(--color-border); stroke-width: 1; }
.radar-poly { fill: var(--color-accent); fill-opacity: .18; stroke: var(--color-accent); stroke-width: 2; }

.strategy-param-drawer {
  background: var(--color-surface-raised);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
  padding: 18px 20px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-elevated);
}
.strategy-param-drawer[data-drawer="false"] > :not(:first-child) {
  display: none;
}
.strategy-param-drawer[data-drawer="false"] > :first-child {
  margin-bottom: 0 !important;
}
.strategy-param-drawer.is-drawer,
.strategy-param-drawer[data-drawer="true"] {
  position: fixed;
  top: var(--effective-header-height, var(--header-height));
  right: 0;
  bottom: var(--hud-height, 44px);
  width: min(440px, 100vw);
  margin: 0;
  z-index: 60;
  border-radius: 0;
  border-right: 0;
  border-bottom: 0;
  overflow-y: auto;
  box-shadow: var(--shadow-floating);
}
.strategy-param-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 12px;
  margin: 14px 0;
}

/* 8. Risk Milestones & Drawdown Gauges */
.risk-milestone-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
  font-variant-numeric: tabular-nums;
}
.risk-milestone-grid > div,
.risk-milestone-card {
  padding: 14px 16px;
  background: var(--color-surface);
  border: 1px solid var(--color-border-subtle);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-card);
  display: grid;
  gap: 6px;
  min-width: 0;
}
.dd-gauge-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
  padding: 16px;
  font-variant-numeric: tabular-nums;
}
.dd-gauge-grid > div,
.dd-gauge-card {
  padding: 14px;
  background: var(--color-surface-raised);
  border: 1px solid var(--color-border-subtle);
  border-radius: var(--radius-md);
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 8px;
  min-width: 0;
}
.dd-gauge-ring {
  width: 84px;
  height: 84px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: conic-gradient(var(--dd-color, var(--color-positive)) var(--dd-pct, 0%), var(--color-border-subtle) 0);
}
.dd-gauge-ring > span {
  width: 66px;
  height: 66px;
  border-radius: 50%;
  background: var(--color-surface-raised);
  display: grid;
  place-items: center;
  font: 600 14px/1 var(--font-mono);
}

/* 9. Fleet Topology SVG & Onboarding Card */
.fleet-topology-svg {
  width: 100%;
  background: var(--color-surface);
  border: 1px solid var(--color-border-subtle);
  border-radius: var(--radius-xl);
  padding: 16px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-card);
  overflow-x: auto;
}
.fleet-topology-svg svg,
svg.fleet-topology-svg { width: 100%; height: auto; min-height: 170px; display: block; }
.topo-edge { stroke: var(--color-border-hover); stroke-width: 1.5; fill: none; }
.topo-edge.active { stroke: var(--color-positive); stroke-width: 2; }
.topo-node-box { fill: var(--color-surface-raised); stroke: var(--color-border); rx: 6; }
.topo-node-box.healthy { stroke: var(--color-positive); }
.topo-node-box.stale { stroke: var(--color-warning); }
.fleet-topology-svg text { fill: var(--color-text-primary); font: 500 11px/1.2 var(--font-mono); font-variant-numeric: tabular-nums; }

.fleet-onboard-card {
  background: var(--color-surface);
  border: 1px dashed var(--color-border-hover);
  border-radius: var(--radius-xl);
  padding: 18px 20px;
  margin-bottom: 16px;
  display: grid;
  gap: 14px;
}
.fleet-onboard-form {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(175px, 1fr));
  gap: 12px;
  align-items: end;
}

/* 10. 6-Tab Quick-Add Action Hub Modal */
.quick-add-modal {
  width: 100%;
  max-width: 720px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-floating);
  overflow: hidden;
  max-height: 90dvh;
  display: flex;
  flex-direction: column;
}
.quick-add-tabs {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 6px 16px 0;
  background: var(--color-surface-raised);
  border-bottom: 1px solid var(--color-border-subtle);
  overflow-x: auto;
  scrollbar-width: none;
  flex-shrink: 0;
}
.quick-add-tabs::-webkit-scrollbar { display: none; }
.quick-add-tab,
.quick-add-tabs button {
  min-height: 38px;
  padding: 8px 12px;
  border: 0;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  background: transparent;
  color: var(--color-text-muted);
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  flex-shrink: 0;
  box-shadow: none;
}
.quick-add-tab:hover,
.quick-add-tabs button:hover { color: var(--color-text-primary); background: transparent; }
.quick-add-tab.active,
.quick-add-tabs button.active,
.quick-add-tabs button[aria-selected="true"] {
  color: var(--color-accent);
  border-bottom-color: var(--color-accent);
  background: transparent;
}
.quick-add-body { padding: 20px; overflow-y: auto; display: grid; gap: 14px; }
.quick-add-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }

/* 11. Blotter Row Actions & SL/TP Edit Modal */
.row-action-group {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  flex-wrap: nowrap;
  white-space: nowrap;
}
.row-action-group button,
.row-action-btn {
  min-height: 28px;
  height: 28px;
  padding: 0 7px;
  font-size: 10.5px;
  font-weight: 600;
  line-height: 1;
  border-radius: var(--radius-xs);
  background: var(--color-surface-raised);
  color: var(--color-text-secondary);
  border: 1px solid var(--color-border);
  white-space: nowrap;
  box-shadow: none;
}
.row-action-group button:hover:not(:disabled) {
  background: var(--color-surface-hover);
  border-color: var(--color-border-hover);
  color: var(--color-text-primary);
}
.row-action-group .row-btn-close,
.row-action-group [data-action="close"] {
  color: var(--color-negative);
  border-color: color-mix(in srgb, var(--color-negative) 45%, transparent);
}
.row-action-group .row-btn-close:hover:not(:disabled),
.row-action-group [data-action="close"]:hover:not(:disabled) {
  background: var(--color-negative-subtle);
  border-color: var(--color-negative);
}
.row-action-group .row-btn-be,
.row-action-group [data-action="be"] {
  color: var(--color-positive);
  border-color: color-mix(in srgb, var(--color-positive) 45%, transparent);
}
.row-action-group .row-btn-be:hover:not(:disabled),
.row-action-group [data-action="be"]:hover:not(:disabled) {
  background: var(--color-positive-subtle);
  border-color: var(--color-positive);
}
.row-action-group .row-btn-edit,
.row-action-group [data-action="edit"] {
  color: var(--color-accent);
  border-color: color-mix(in srgb, var(--color-accent) 45%, transparent);
}
.row-action-group .row-btn-edit:hover:not(:disabled),
.row-action-group [data-action="edit"]:hover:not(:disabled) {
  background: var(--color-accent-subtle);
  border-color: var(--color-accent);
}
.row-action-group .row-btn-flip,
.row-action-group [data-action="flip"] {
  color: var(--color-warning);
  border-color: color-mix(in srgb, var(--color-warning) 45%, transparent);
}
.row-action-group .row-btn-flip:hover:not(:disabled),
.row-action-group [data-action="flip"]:hover:not(:disabled) {
  background: var(--color-warning-subtle);
  border-color: var(--color-warning);
}

#sltp_edit_modal .modal-card { max-width: 440px; }
#sltp_edit_modal .sltp-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* 12. Evaluation Stream, Telegram Health & Audit Hash Chain */
.eval-stream-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 14px 16px;
  max-height: 380px;
  overflow-y: auto;
  font-variant-numeric: tabular-nums;
}
.eval-stream-list > div,
.eval-stream-list > li,
.eval-stream-item {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 10px 12px;
  background: var(--color-surface-raised);
  border: 1px solid var(--color-border-subtle);
  border-radius: var(--radius-sm);
  font-size: 12px;
}
.eval-stream-item.is-pass { border-left: 3px solid var(--color-positive); }
.eval-stream-item.is-warn { border-left: 3px solid var(--color-warning); }
.eval-stream-item.is-error { border-left: 3px solid var(--color-negative); }

.telegram-health-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border-subtle);
  border-radius: var(--radius-xl);
  padding: 16px 20px;
  margin-bottom: 16px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
  box-shadow: var(--shadow-card);
  font-variant-numeric: tabular-nums;
}
.telegram-metrics { display: flex; flex-wrap: wrap; gap: 16px; font-size: 12px; color: var(--color-text-secondary); }

.audit-chain-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border-subtle);
  border-radius: var(--radius-xl);
  padding: 16px 20px;
  margin-bottom: 16px;
  display: grid;
  gap: 12px;
  box-shadow: var(--shadow-card);
  font-variant-numeric: tabular-nums;
}
.audit-chain-seq,
.chain-links { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.chain-badge,
.hash-seq-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  background: var(--color-canvas);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xs);
  font: 500 11px/1.2 var(--font-mono);
  font-variant-numeric: tabular-nums;
  color: var(--color-text-secondary);
}
.chain-badge.verified,
.hash-seq-badge.verified {
  border-color: var(--color-positive);
  background: var(--color-positive-subtle);
  color: var(--color-positive);
}
.chain-badge.unverified,
.hash-seq-badge.unverified {
  border-color: var(--color-warning);
  background: var(--color-warning-subtle);
  color: var(--color-warning);
}

/* ── Scrollbars ── */
* { scrollbar-width: thin; scrollbar-color: var(--color-border-hover) var(--color-canvas); }

/* ── Page-Wise Shell, Two-Tier Command Bar & Alignment Polish ── */
:root {
  --hud-height: 44px;
}
html,
body {
  height: 100%;
  overflow: hidden;
}
.app-container {
  height: calc(100dvh - var(--hud-height));
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
body:has(#execution_hud_dock.minimized) .app-container,
body:has(#execution_hud_dock.hud-minimized) .app-container {
  height: 100dvh;
}
.app-body {
  flex: 1 1 0%;
  min-height: 0;
  display: flex;
  overflow: hidden;
  position: relative;
}
.app-sidebar {
  height: 100%;
  overflow-y: auto;
  overflow-x: hidden;
  flex-shrink: 0;
  padding-bottom: calc(var(--hud-height, 44px) + 28px);
}
.main-content {
  flex: 1 1 0%;
  min-width: 0;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding-bottom: calc(var(--hud-height, 44px) + 28px);
}
.toast-container {
  bottom: calc(var(--hud-height, 44px) + 12px);
}

/* Two-Tier Non-Clipping Command Bar */
.header-bar,
.top-command-bar {
  height: auto;
  min-height: var(--header-height);
  padding: 8px 20px 6px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 14px;
  flex-shrink: 0;
}
.brand-section {
  flex: 0 1 auto;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 10px;
}
#global_scope_select {
  min-width: 170px;
  max-width: 268px;
  text-overflow: ellipsis;
}
.header-controls {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: nowrap;
}
.header-bar > .ticker-strip {
  order: 3;
  flex: 1 0 100%;
  width: 100%;
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 8px;
  padding: 6px 0 2px;
  margin: 0;
  border-top: 1px solid var(--color-border-subtle);
  overflow: visible;
}
.header-bar > .ticker-strip .ticker-chip {
  min-width: 0;
  min-height: 26px;
  padding: 3px 9px;
  justify-content: center;
  font-size: 11px;
  gap: 8px;
}
.header-bar > .ticker-strip .ticker-chip strong {
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Universal Text-Out-of-Box & Card/Control Containment */
.panel,
.panel-header,
.kpi-card,
.metric-box,
.desk-map-node,
.risk-milestone-card,
.dd-gauge-card,
.action-card-item,
.eval-stream-item,
.ticket-input-group {
  min-width: 0;
}
.panel-header {
  flex-wrap: wrap;
  gap: 8px 12px;
  min-height: 44px;
  height: auto !important;
}
.panel-title,
.metric-box-title,
.kpi-label,
.view-title-group h1,
.view-title-group p,
.action-card-item > div:first-child {
  min-width: 0;
  overflow-wrap: anywhere;
}
select,
.asset-select {
  max-width: 100%;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.fleet-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
  min-width: 0;
}
.fleet-card-title,
.fleet-card-role {
  min-width: 0;
  flex: 1 1 auto;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.fleet-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-width: 0;
  font-size: 11px;
  color: var(--color-text-dim);
  border-top: 1px solid var(--color-border-subtle);
  padding-top: 6px;
}
.strategy-cards-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 16px;
}
.strategy-card {
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 10px;
  min-width: 0;
}
.strategy-card-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
  min-width: 0;
  margin-bottom: 6px;
}
.strategy-card-head h3 {
  flex: 1 1 auto;
  min-width: 0;
  font-size: 13px;
  font-weight: 700;
  color: var(--color-text-primary);
  line-height: 1.3;
  overflow-wrap: anywhere;
  margin: 0;
}
.strategy-card-head .brand-badge {
  flex-shrink: 0;
  white-space: nowrap;
}
.market-metric-strip {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}
#view_market .metric-box {
  padding: 14px;
}
#view_market .metric-box-val {
  font-size: clamp(16px, 1.35vw, 21px);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
#view_market .metric-box-sub,
#view_risk .dd-gauge-card strong {
  overflow-wrap: anywhere;
}
#view_risk .dd-gauge-grid {
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
}
.orders-workspace-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 14px;
  margin-bottom: 16px;
}
.orders-select-row {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr);
  gap: 10px;
  margin-bottom: 10px;
}
.blotter-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--color-border-subtle);
  padding: 8px 16px;
}
.pro-table th,
.pro-table td {
  padding: 11px 10px;
}
:where(#view_orders, #view_audit) .pro-table th,
:where(#view_orders, #view_audit) .pro-table td {
  padding: 10px 8px;
  font-size: 12px;
}
.pro-table .cell-wrap {
  white-space: normal;
  overflow-wrap: anywhere;
  max-width: 240px;
}
#view_audit .metric-box-val {
  font-size: clamp(17px, 1.45vw, 22px);
  line-height: 1.25;
  overflow-wrap: anywhere;
}
/* audit panels must NOT clip wide tables — allow horizontal scroll */
#view_audit .panel { overflow: visible; }
#view_audit .table-container {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
:where(#view_audit) .pro-table { min-width: max-content; }
.eval-stream-item > div {
  min-width: 0;
  overflow-wrap: anywhere;
}
.strategy-radar-wrap svg {
  max-width: 352px;
  overflow: visible;
}
#telegram_health_card > div:last-child {
  flex-wrap: nowrap !important;
  justify-content: flex-end;
}
#telegram_health_card #inp_tg_test_msg {
  width: 240px !important;
  flex: 0 1 240px !important;
}
#telegram_health_card #btn_tg_test {
  white-space: nowrap;
  flex-shrink: 0;
}

/* ── Responsive Breakpoints (1440px -> 1024px -> 390px) ── */
@media (max-width: 1520px) {
  .brand-logo .brand-badge { display: none; }
  .brand-logo { min-width: 0; }
  .header-bar,
  .top-command-bar { padding: 8px 16px 6px; gap: 6px 10px; }
  .asset-select { min-width: 130px; max-width: 220px; }
  .topbar-icon-btn { min-width: 30px; padding: 0 8px; font-size: 11px; }
  .session-clock-pill { padding: 3px 8px; font-size: 10.5px; min-height: 28px; }
  .status-pill { font-size: 10.5px; gap: 5px; }
  #header_status_text { max-width: 150px; overflow: hidden; text-overflow: ellipsis; }
}

@media (max-width: 1350px) {
  .dashboard-widgets { grid-template-columns: 1fr 1fr; }
  .dashboard-widgets > :last-child { grid-column: 1 / -1; }
  #view_terminal .kpi-card { padding: 20px 16px; }
  #view_terminal .kpi-value { font-size: 29px; }
  #view_terminal .kpi-card:first-child .kpi-value { font-size: 36px; }
  .market-metric-strip { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  #view_market .market-metric-strip > .metric-box:last-child:nth-child(7) { grid-column: span 2; }
  .pro-table { font-size: 11.5px; }
  .pro-table th,
  .pro-table td { padding: 9px 7px; }
}

@media (max-width: 1200px) {
  :root { --sidebar-width: 184px; }
  .header-bar,
  .top-command-bar { padding: 8px 14px; gap: 6px 8px; }
  .header-controls { flex-wrap: wrap; gap: 6px; }
  #header_clock { display: none !important; }
  .brand-logo .brand-badge { display: none; }
  .asset-select { min-width: 120px; max-width: 186px; }
  #global_scope_select { min-width: 110px; max-width: 175px; }
  .orders-select-row > * { min-width: 0; }
  #exec_desk_select,
  #exec_sym_select { min-width: 0; width: 100%; max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
  .main-content { padding: 20px 18px calc(var(--hud-height, 44px) + 28px); }
  .view-panel { scroll-margin-top: 20px; }
  .workspace-grid { grid-template-columns: minmax(0, 1fr) 296px; }
  #terminal_fleet_cards_row,
  #fleet_page_cards_row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    padding: 12px;
  }
  #terminal_fleet_cards_row > .panel,
  #fleet_page_cards_row > .panel {
    border: 1px solid var(--color-border-subtle) !important;
    border-radius: var(--radius-md) !important;
    background: var(--color-surface-raised) !important;
  }
  #terminal_fleet_cards_row > .panel:last-child:nth-child(odd),
  #fleet_page_cards_row > .panel:last-child:nth-child(odd) {
    grid-column: 1 / -1;
  }
}

@media (max-width: 1100px) {
  .dashboard-widgets { grid-template-columns: 1fr; }
  .dashboard-widgets > :last-child { grid-column: auto; }
  .strategy-cards-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .strategy-cards-grid > :last-child:nth-child(odd) { grid-column: 1 / -1; }
}

@media (max-width: 1040px) {
  .table-container { overflow-x: visible; padding: 10px 12px; }
  .pro-table,
  .pro-table tbody { display: block; width: 100%; min-width: 0; max-width: 100%; }
  .pro-table thead {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
  }
  .pro-table tbody tr {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0 18px;
    margin: 0 0 10px;
    padding: 10px 14px;
    background: var(--color-surface-raised);
    border: 1px solid var(--color-border-subtle);
    border-radius: var(--radius-md);
    min-width: 0;
    max-width: 100%;
    box-sizing: border-box;
  }
  .pro-table tbody tr:last-child { margin-bottom: 0; }
  .pro-table tbody td:not([colspan]) {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 7px 0;
    border-bottom: 1px solid var(--color-border-subtle);
    text-align: right;
    min-width: 0;
    overflow-wrap: anywhere;
    white-space: normal;
  }
  .pro-table tbody td.cell-wrap { max-width: none; word-break: break-all; }
  .pro-table tbody td[data-label]::before {
    content: attr(data-label);
    font-size: 11px;
    font-weight: 600;
    color: var(--color-text-muted);
    text-align: left;
    flex: 0 0 auto;
    max-width: 46%;
  }
  .pro-table tbody td[colspan] {
    display: block;
    width: 100%;
    grid-column: 1 / -1;
    text-align: center;
    padding: 12px 4px;
    border-bottom: 0;
  }
  .pro-table tbody td:not([colspan]):last-child:nth-child(odd) {
    grid-column: 1 / -1;
    border-bottom: 0;
  }
  .pro-table tbody td:not([colspan]):last-child:nth-child(even),
  .pro-table tbody td:not([colspan]):nth-last-child(2):nth-child(odd) {
    border-bottom: 0;
  }
}

@media (max-width: 960px) {
  .kpi-grid,
  .metric-strip,
  #view_terminal .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .workspace-grid,
  .orders-workspace-grid { grid-template-columns: 1fr; }
  #view_terminal .allocation-panel { grid-template-columns: 1fr; gap: 12px; }
  #view_terminal .allocation-heading { display: flex; }
  .session-flow-bar,
  .strategy-radar-wrap,
  .telegram-health-card { grid-template-columns: 1fr; }
  .brand-logo { min-width: 0; }
  .status-pill,
  .header-bar > .ticker-strip { display: none !important; }
  .view-title-group h1 { font-size: 32px; }
  .main-content [style*="grid-template-columns:repeat(5"],
  .main-content [style*="grid-template-columns: repeat(5"],
  .main-content [style*="grid-template-columns:repeat(4"],
  .main-content [style*="grid-template-columns: repeat(4"] { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; }
}

@media (max-width: 640px) {
  :root { --hud-height: 48px; }
  .mobile-menu-toggle { display: inline-flex; align-items: center; justify-content: center; width: 40px; height: 40px; padding: 0; flex-shrink: 0; }
  .header-bar,
  .top-command-bar { gap: 6px; padding: 6px 10px; flex-wrap: nowrap; }
  .brand-section { gap: 6px; flex-wrap: nowrap; min-width: 0; flex: 1 1 0%; overflow: hidden; }
  .brand-logo,
  .brand-logo .brand-badge,
  .brand-title,
  #btn_audio_toggle,
  #btn_cmd_palette,
  #btn_refresh_workspace,
  .ticker-strip,
  .header-bar > .ticker-strip,
  .session-clock-pill { display: none !important; }
  .app-container #global_scope_select { min-width: 0; width: 100%; max-width: none; flex: 1 1 0%; height: 38px; min-height: 38px; padding: 0 22px 0 8px; line-height: 38px; font-size: 11px; text-overflow: ellipsis; }
  .header-controls { gap: 6px; flex: 0 0 auto; align-items: center; }
  .mobile-menu-toggle { width: 38px; height: 38px; min-height: 38px; }
  .btn-quick-add { min-height: 38px; height: 38px; padding: 0 9px; font-size: 11px; white-space: nowrap; display: inline-flex; align-items: center; }
  .auth-btn { min-height: 38px; height: 38px; padding: 0 9px; font-size: 11px; display: inline-flex; align-items: center; gap: 6px; }
  .app-sidebar {
    display: none;
    position: absolute;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 50;
    width: min(264px, 82vw);
    padding-top: 20px;
    box-shadow: var(--shadow-floating);
  }
  .app-sidebar.open { display: block; }
  .nav-item { min-height: 44px; }
  .main-content { padding: 16px 12px calc(var(--hud-height, 48px) + 28px); }
  .view-panel { scroll-margin-top: 16px; }
  .view-title-group h1 { font-size: 28px; }
  .view-header { margin-bottom: 20px; }
  .kpi-card,
  .metric-box { box-shadow: var(--shadow-card); padding: 14px; }
  .kpi-value { font-size: 24px; }
  .kpi-label { font-size: 11px; }
  .allocation-panel { padding: 16px; }
  .panel-header { padding: 12px; }
  .panel-header > div { flex-wrap: wrap; }
  .chart-controls { width: 100%; gap: 2px; }
  .chart-controls button { flex: 1; min-height: 44px; padding: 6px; }
  .chart-container-box,
  #pro_chart_container { height: 340px !important; }
  .main-content [style*="grid-template-columns"] { grid-template-columns: 1fr !important; }
  .strategy-cards-grid,
  .orders-select-row,
  #terminal_fleet_cards_row,
  #fleet_page_cards_row { grid-template-columns: 1fr; }
  .market-metric-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  #view_market .market-metric-strip > .metric-box:last-child { grid-column: 1 / -1; }
  .eval-stream-item { grid-template-columns: auto minmax(0, 1fr); }
  .eval-stream-item > span:last-child { grid-column: 1 / -1; }
  #telegram_health_card > div:last-child { flex-wrap: wrap !important; justify-content: stretch; }
  #telegram_health_card #inp_tg_test_msg { width: 100% !important; flex: 1 1 100% !important; }
  .widget-body { padding: 16px; }
  .mix-layout { gap: 16px; }
  .mix-ring { width: 128px; height: 128px; }
  .health-row { gap: 8px; grid-template-columns: 64px minmax(20px, 1fr) 72px 36px; }
  .dashboard-widgets { gap: 16px; }
  .execution-hud-dock,
  #execution_hud_dock { padding: 5px 10px; }
  .hud-inner { gap: 6px; font-size: 10px; }
  #execution_hud_dock .hud-inner > div:first-child > span:nth-child(2) { display: none; }
  .hud-hotkey-btn { min-height: 30px; }
  .toast-container { right: 12px; bottom: 56px; }
  #view_terminal .kpi-card { padding: 18px 14px; border-bottom: 1px solid var(--color-border-subtle); }
  #view_terminal .kpi-value,
  #view_terminal .kpi-card:first-child .kpi-value { font-size: 28px; }
  #view_terminal .allocation-panel { padding: 16px; }
  .restored-chart-tools { padding: 12px; }
  .overlay-control { min-height: 44px; }
  .quick-add-tabs { flex-wrap: wrap; padding: 8px 10px; gap: 4px; overflow-x: visible; }
  .quick-add-tab,
  .quick-add-tabs button { flex: 1 1 auto; min-height: 34px; padding: 5px 8px; font-size: 11px; text-align: center; }
  .quick-add-grid,
  #sltp_edit_modal .sltp-grid { grid-template-columns: 1fr; }
  .app-container button,
  .app-container input:not([type="checkbox"]):not([type="radio"]),
  .app-container select { min-height: 44px; }
  .app-container .row-action-group { flex-wrap: wrap; justify-content: flex-end; }
  .app-container .row-action-group button { min-height: 36px; height: 36px; padding: 0 8px; }
  .table-container { padding: 8px; }
  .pro-table tbody tr {
    grid-template-columns: minmax(0, 1fr);
    gap: 0;
    padding: 8px 12px;
  }
  .pro-table tbody td:not([colspan]) {
    gap: 12px;
    padding: 6px 0;
  }
  .pro-table tbody td:not([colspan]):nth-last-child(2):nth-child(odd) {
    border-bottom: 1px solid var(--color-border-subtle);
  }
  .pro-table tbody td:not([colspan]):last-child { border-bottom: 0; }
}

@media (max-width: 440px) {
  .kpi-grid,
  .metric-strip,
  #view_terminal .kpi-grid { grid-template-columns: 1fr; }
  .market-metric-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  #view_terminal .kpi-card { border-left: 0; }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
    scroll-behavior: auto !important;
  }
  .dashboard-widgets .panel { transition: none; }
}
