:root {
  color-scheme: dark;
  --bg: #0f1114;
  --surface: #171a1f;
  --surface-2: #20242b;
  --surface-3: #2a3038;
  --line: #333a44;
  --text: #edf1f5;
  --muted: #a6b0bc;
  --faint: #77818d;
  --teal: #30c0a2;
  --blue: #70a6ff;
  --amber: #d7a447;
  --red: #d65f5f;
  --violet: #a982ff;
  --green: #91c46c;
  --brown: #9b7d5d;
  --rail: #121519;
  --panel-alt: #13171b;
  --line-soft: #28313b;
  --track: #202833;
  --cell-bg: #141a20;
  --cell-bg-alt: #1a222a;
  --cell-border: #2b3540;
  --table-line: #28313b;
  --chart-grid: #28313b;
  --chart-label: #8b98a6;
  --selected-row: #1d2730;
  --tooltip-bg: #111a22;
  --accent-text: #061b18;
  --score-hole: #121519;
  --brand-border: #a98b52;
  --brand-bg: #211b13;
  --brand-text: #f0c877;
  --shadow: 0 18px 40px rgba(0, 0, 0, 0.28);
}

[data-theme="midnight"] {
  --bg: #081018;
  --surface: #101a24;
  --surface-2: #172331;
  --surface-3: #213245;
  --line: #2c4054;
  --text: #edf6ff;
  --muted: #9db1c6;
  --faint: #6e8195;
  --teal: #3ed6b3;
  --blue: #7bb7ff;
  --amber: #e4bb66;
  --rail: #0b141d;
  --panel-alt: #0d1720;
  --line-soft: #203346;
  --track: #172839;
  --cell-bg: #0d1822;
  --cell-bg-alt: #122130;
  --cell-border: #21384d;
  --table-line: #1f3346;
  --chart-grid: #1f3346;
  --chart-label: #8399ad;
  --selected-row: #13293c;
  --tooltip-bg: #0c1d2c;
  --score-hole: #0b141d;
}

[data-theme="paper"] {
  color-scheme: light;
  --bg: #e8e5dd;
  --surface: #f6f4ee;
  --surface-2: #ebe7dd;
  --surface-3: #ded8ca;
  --line: #c8c0af;
  --text: #1d2328;
  --muted: #66717c;
  --faint: #8a8275;
  --teal: #168f79;
  --blue: #246eb9;
  --amber: #a16d13;
  --red: #b84c4c;
  --violet: #7357c4;
  --green: #5e8f46;
  --rail: #efebe2;
  --panel-alt: #fffdf8;
  --line-soft: #d8d0c1;
  --track: #ddd5c6;
  --cell-bg: #fffaf0;
  --cell-bg-alt: #f3eee3;
  --cell-border: #d4cabb;
  --table-line: #ded5c6;
  --chart-grid: #d8d0c1;
  --chart-label: #776e62;
  --selected-row: #e7dfd0;
  --tooltip-bg: #fffaf0;
  --accent-text: #061b18;
  --score-hole: #efebe2;
  --shadow: 0 14px 28px rgba(64, 55, 40, 0.14);
}

* {
  box-sizing: border-box;
  letter-spacing: 0;
  scrollbar-color: var(--line) var(--rail);
  scrollbar-width: thin;
}

*::-webkit-scrollbar {
  width: 9px;
  height: 9px;
}

*::-webkit-scrollbar-track {
  background: var(--rail);
}

*::-webkit-scrollbar-thumb {
  border: 2px solid var(--rail);
  border-radius: 999px;
  background: var(--line);
}

*::-webkit-scrollbar-thumb:hover {
  background: var(--faint);
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Aptos, "Segoe UI", Inter, Arial, sans-serif;
  font-size: 12px;
}

body.is-auth-locked {
  min-height: 100vh;
  overflow: hidden;
}

body.is-auth-locked .app-shell {
  display: none;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.login-gateway {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    linear-gradient(180deg, rgba(8, 16, 24, 0.94), rgba(8, 16, 24, 0.98)),
    repeating-linear-gradient(90deg, rgba(237, 246, 255, 0.035) 0 1px, transparent 1px 76px);
}

body:not(.is-auth-locked) .login-gateway {
  display: none;
}

.login-panel {
  width: min(420px, 100%);
  display: grid;
  gap: 14px;
  padding: 26px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.login-kicker {
  margin: 0;
  color: var(--teal);
  font-size: 0.76rem;
  font-weight: 800;
  text-transform: uppercase;
}

.login-panel h1 {
  margin: 0 0 6px;
  color: var(--text);
  font-size: 1.55rem;
  line-height: 1.1;
}

.login-field {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

.login-field input {
  width: 100%;
  min-height: 42px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--rail);
  color: var(--text);
  font-size: 0.9rem;
  font-weight: 700;
  text-transform: none;
}

.login-field input:focus-visible {
  outline: 2px solid var(--teal);
  outline-offset: 2px;
}

.login-error {
  min-height: 1.2em;
  margin: 0;
  color: var(--red);
  font-size: 0.82rem;
  font-weight: 800;
}

.login-button {
  min-height: 44px;
  border: 1px solid var(--teal);
  border-radius: 4px;
  background: var(--teal);
  color: var(--accent-text);
  font-size: 0.86rem;
  font-weight: 900;
}

.login-link {
  width: fit-content;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
  text-decoration: none;
}

.login-link:hover,
.login-link:focus-visible {
  color: var(--text);
}

.top-bar {
  min-height: 56px;
  padding: 8px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  border-bottom: 1px solid var(--line);
  background: var(--rail);
}

.brand-block {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 10px;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 15px;
  line-height: 1.25;
  font-weight: 700;
}

h2 {
  font-size: 12px;
  line-height: 1.2;
  font-weight: 700;
}

.info-icon {
  width: 16px;
  height: 16px;
  margin-left: 6px;
  display: inline-grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  color: var(--muted);
  background: var(--surface-2);
  font-size: 10px;
  font-weight: 800;
  line-height: 1;
  vertical-align: middle;
  position: relative;
}

.info-icon:hover,
.info-icon:focus-visible {
  color: var(--text);
  border-color: var(--blue);
}

.info-icon:hover::after,
.info-icon:focus-visible::after {
  content: attr(data-help);
  position: absolute;
  z-index: 20;
  left: 50%;
  top: 20px;
  width: 220px;
  padding: 8px 9px;
  border: 1px solid var(--line);
  background: var(--tooltip-bg);
  color: var(--text);
  box-shadow: var(--shadow);
  transform: translateX(-50%);
  font-size: 11px;
  font-weight: 500;
  line-height: 1.35;
  text-align: left;
}

#ledgerStamp,
.panel-head span,
.metric-label {
  color: var(--muted);
  font-size: 12px;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.tool-button,
.reset-button,
.segment,
.signal-table th button,
.link-button {
  border: 1px solid var(--line);
  color: var(--text);
  background: var(--surface-2);
  border-radius: 6px;
  transition: border-color 140ms ease, background 140ms ease, color 140ms ease;
}

.tool-button {
  min-height: 32px;
  padding: 0 10px;
}

.status-pill {
  min-height: 28px;
  padding: 0 9px;
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  background: var(--surface);
  font-size: 11px;
  font-weight: 800;
  white-space: nowrap;
}

.tool-button:hover,
.reset-button:hover,
.segment:hover,
.signal-table th button:hover,
.link-button:hover {
  border-color: var(--faint);
  background: var(--surface-3);
}

.tool-button:disabled {
  color: var(--faint);
  cursor: wait;
}

.emphasis-button {
  border-color: var(--teal);
  color: var(--text);
  background: color-mix(in srgb, var(--teal) 18%, var(--surface-2));
}

.terminal-layout {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: 228px minmax(0, 1fr) 270px;
}

.control-rail,
.detail-rail {
  min-width: 0;
  padding: 10px;
  background: var(--rail);
}

.control-rail {
  border-right: 1px solid var(--line);
}

.detail-rail {
  border-left: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.workbench {
  min-width: 0;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow: auto;
}

.rail-section {
  padding-bottom: 8px;
  margin-bottom: 8px;
  border-bottom: 1px solid var(--line-soft);
}

.field-label {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.field-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.filter-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.filter-head .field-label {
  margin-bottom: 0;
}

.link-button {
  min-height: 22px;
  padding: 0 7px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
}

.text-field {
  width: 100%;
  height: 31px;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  outline: none;
}

.text-field:focus,
.range-field:focus-visible,
.segment:focus-visible,
.tool-button:focus-visible,
.reset-button:focus-visible,
.signal-table button:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 2px;
}

.range-field {
  width: 100%;
  accent-color: var(--teal);
}

.segmented-control {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}

.range-control {
  grid-template-columns: repeat(3, 1fr);
}

.window-control {
  grid-template-columns: repeat(4, 1fr);
}

.frequency-control {
  grid-template-columns: repeat(4, 1fr);
}

.horizon-control {
  grid-template-columns: repeat(4, 1fr);
}

.segment {
  min-height: 28px;
  padding: 0 7px;
  color: var(--muted);
}

.theme-control {
  grid-template-columns: repeat(3, 1fr);
}

.rating-control {
  grid-template-columns: repeat(5, 1fr);
}

.segment.is-active {
  color: var(--accent-text);
  background: var(--teal);
  border-color: var(--teal);
  font-weight: 800;
}

.checkbox-list {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.dense-list {
  max-height: 126px;
  overflow: auto;
  padding-right: 3px;
}

#sectorFilters {
  max-height: 108px;
}

#strategyFilters {
  max-height: 156px;
}

.check-row,
.toggle-row {
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--text);
}

.strategy-row span {
  min-width: 0;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: baseline;
  gap: 6px;
  flex: 1;
}

.strategy-row small {
  min-width: 0;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.strategy-row em {
  min-width: 22px;
  color: var(--faint);
  font-style: normal;
  text-align: right;
}

.strategy-row.is-muted {
  opacity: 0.62;
}

.check-row input,
.toggle-row input {
  width: 16px;
  height: 16px;
  accent-color: var(--teal);
}

.reset-button {
  width: 100%;
  min-height: 34px;
}

.regime-strip {
  display: grid;
  grid-template-columns: repeat(7, minmax(118px, 1fr));
  border: 1px solid var(--line);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.regime-cell {
  min-height: 50px;
  padding: 7px 8px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 4px;
  border-right: 1px solid var(--line);
}

.regime-cell:last-child {
  border-right: 0;
}

.regime-cell strong {
  font-size: 15px;
}

#dataVersion {
  font-size: 12px;
  line-height: 1.3;
}

.visual-grid {
  display: grid;
  grid-template-columns: minmax(360px, 1.35fr) minmax(230px, 0.7fr) minmax(230px, 0.7fr);
  gap: 8px;
}

.research-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(260px, 0.72fr) minmax(300px, 0.9fr);
  gap: 8px;
}

.analysis-panel,
.blotter-panel {
  min-width: 0;
  border: 1px solid var(--line);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.panel-wide {
  grid-column: span 2;
}

.panel-head {
  min-height: 32px;
  padding: 7px 9px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  border-bottom: 1px solid var(--line);
}

.panel-head > div:first-child {
  min-width: 0;
}

.inline-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.mini-button {
  min-height: 28px;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--muted);
  background: var(--surface-2);
}

.mini-button.is-active {
  color: var(--accent-text);
  border-color: var(--teal);
  background: var(--teal);
  font-weight: 800;
}

.surface-canvas {
  width: 100%;
  height: 214px;
  display: block;
}

.market-canvas {
  width: 100%;
  height: 254px;
  display: block;
}

.market-canvas.compact {
  height: 208px;
}

.price-panel,
.compare-panel {
  grid-column: span 2;
}

.correlation-panel,
.news-panel {
  grid-column: span 1;
}

.kpi-grid {
  padding: 9px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 7px;
}

.kpi-item {
  min-height: 50px;
  padding: 7px;
  border: 1px solid var(--cell-border);
  background: var(--cell-bg);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 8px;
}

.kpi-item span {
  color: var(--muted);
  font-size: 12px;
}

.kpi-item strong {
  font-size: 16px;
}

.legend-strip {
  min-height: 32px;
  padding: 0 10px 9px;
  display: flex;
  align-items: center;
  gap: 9px;
  flex-wrap: wrap;
}

.legend-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 24px;
  color: var(--muted);
  font-size: 12px;
}

.legend-chip.is-active {
  color: var(--text);
  font-weight: 800;
}

.legend-swatch {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.data-table-frame {
  overflow: auto;
  max-height: 300px;
}

.intel-table {
  width: 100%;
  border-collapse: collapse;
}

.intel-table th,
.intel-table td {
  padding: 6px 8px;
  border-bottom: 1px solid var(--table-line);
  text-align: left;
  vertical-align: top;
}

.intel-table th {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.intel-table td:last-child {
  text-align: right;
  font-weight: 800;
}

.peer-grid {
  padding: 9px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 7px;
  max-height: 330px;
  overflow: auto;
}

.peer-tile {
  min-width: 0;
  padding: 8px;
  border: 1px solid var(--cell-border);
  background: var(--cell-bg);
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
}

.peer-tile strong {
  display: block;
}

.peer-tile span {
  color: var(--muted);
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.peer-tile .peer-return {
  font-weight: 800;
}

.news-feed {
  max-height: 330px;
  overflow: auto;
  padding: 9px;
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.news-item {
  padding: 9px;
  border: 1px solid var(--cell-border);
  background: var(--cell-bg);
}

.news-item a {
  color: var(--text);
  text-decoration: none;
  font-weight: 800;
  line-height: 1.35;
}

.news-item a:hover {
  color: var(--blue);
}

.news-meta {
  margin-top: 7px;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 12px;
}

.sentiment-pill {
  min-height: 20px;
  padding: 0 7px;
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  color: var(--accent-text);
  font-weight: 800;
}

.sentiment-positive {
  background: var(--green);
}

.sentiment-negative {
  background: var(--red);
}

.sentiment-neutral {
  background: var(--muted);
}

.correlation-grid {
  padding: 9px;
  display: grid;
  gap: 5px;
  overflow: auto;
}

.corr-cell,
.corr-head {
  min-width: 52px;
  min-height: 32px;
  padding: 6px;
  display: grid;
  place-items: center;
  border: 1px solid var(--cell-border);
  font-size: 12px;
}

.corr-head {
  color: var(--muted);
  background: var(--cell-bg);
  font-weight: 800;
}

.corr-cell {
  color: var(--text);
  background: var(--cell-bg-alt);
}

.corr-empty {
  min-width: 52px;
  min-height: 32px;
  border: 1px solid transparent;
}

.bar-stack,
.risk-budget,
.allocation-list,
.sector-breadth,
.heatmap {
  padding: 9px;
}

.bar-stack {
  max-height: 238px;
  overflow: auto;
}

.bar-row,
.risk-row,
.allocation-row,
.sector-row {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr) 52px;
  align-items: center;
  gap: 8px;
  min-height: 26px;
}

.risk-row {
  grid-template-columns: 82px minmax(0, 1fr) 44px;
}

.allocation-row {
  grid-template-columns: 68px minmax(0, 1fr) 58px;
}

.sector-row {
  grid-template-columns: minmax(88px, 0.9fr) minmax(0, 1fr) 64px;
}

.sector-row strong,
.bar-row strong,
.risk-row strong,
.allocation-row strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bar-track {
  height: 8px;
  background: var(--track);
  overflow: hidden;
  border-radius: 999px;
}

.bar-fill {
  height: 100%;
  width: 0;
  background: var(--teal);
}

.heatmap {
  display: grid;
  grid-template-columns: 84px repeat(4, minmax(68px, 1fr));
  gap: 4px;
  max-height: 430px;
  overflow: auto;
}

.heat-cell {
  min-height: 42px;
  padding: 6px;
  border: 1px solid var(--cell-border);
  background: var(--cell-bg-alt);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.heat-head {
  min-height: 24px;
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 12px;
  border: 1px solid transparent;
}

.heat-cell strong {
  font-size: 15px;
}

.heat-cell span {
  color: var(--muted);
  font-size: 11px;
}

.table-frame {
  overflow: auto;
  max-height: 560px;
}

.signal-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 840px;
}

.signal-table th,
.signal-table td {
  padding: 5px 7px;
  border-bottom: 1px solid var(--table-line);
  text-align: left;
  white-space: nowrap;
}

.signal-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--cell-bg);
}

.signal-table th button {
  min-height: 24px;
  padding: 0 7px;
  color: var(--muted);
}

.signal-table tbody tr {
  transition: background 140ms ease;
}

.signal-table tbody tr:hover,
.signal-table tbody tr.is-selected {
  background: var(--selected-row);
}

.symbol-cell strong {
  display: block;
  font-size: 13px;
}

.symbol-cell span {
  display: block;
  max-width: 240px;
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  text-overflow: ellipsis;
}

.badge,
.risk-pill,
.rating-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 21px;
  padding: 0 7px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
}

.badge {
  color: var(--accent-text);
  background: var(--teal);
}

.risk-pill {
  color: var(--text);
  background: var(--surface-3);
}

.rating-pill {
  color: var(--accent-text);
  background: var(--amber);
}

.detail-head {
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line-soft);
}

.detail-head strong {
  display: block;
  margin: 6px 0;
  font-size: 26px;
  line-height: 1;
}

#detailName {
  color: var(--muted);
  line-height: 1.35;
}

.score-ring {
  --score-color: var(--teal);
  width: 112px;
  height: 112px;
  margin: 4px auto;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: conic-gradient(var(--score-color) var(--score-deg, 0deg), var(--track) 0);
  position: relative;
}

.score-ring::after {
  content: "";
  position: absolute;
  inset: 11px;
  border-radius: 50%;
  background: var(--score-hole);
}

.score-ring span {
  position: relative;
  z-index: 1;
  font-size: 28px;
  font-weight: 800;
}

.detail-stack {
  display: grid;
  grid-template-columns: 1fr;
  gap: 7px;
}

.detail-stack > div {
  padding: 8px;
  border: 1px solid var(--cell-border);
  background: var(--cell-bg);
}

.detail-stack strong {
  display: block;
  margin-top: 5px;
}

.spark-panel {
  border: 1px solid var(--cell-border);
  background: var(--cell-bg);
}

.spark-head {
  padding: 8px 9px 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.spark-label {
  margin: 0;
  padding: 0;
}

.spark-controls,
.spark-history {
  display: flex;
  align-items: center;
  gap: 4px;
}

.spark-controls .mini-button,
.spark-history .mini-button {
  min-height: 22px;
  padding: 0 6px;
  font-size: 10px;
}

.spark-history {
  padding: 5px 9px 0;
  color: var(--muted);
  font-size: 10px;
}

.spark-panel svg {
  width: 100%;
  height: 104px;
  display: block;
}

.metric-grid {
  margin: 0;
  display: grid;
  grid-template-columns: 1fr;
  gap: 6px;
}

.metric-grid div {
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 7px 8px;
  border: 1px solid var(--cell-border);
  background: var(--cell-bg);
}

.metric-grid dt {
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
}

.metric-grid dd {
  margin: 0;
  font-weight: 800;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  min-width: 240px;
  max-width: 420px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  background: var(--tooltip-bg);
  color: var(--text);
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(10px);
  pointer-events: none;
  transition: opacity 180ms ease, transform 180ms ease;
}

.toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

@media (max-width: 1220px) {
  .terminal-layout {
    grid-template-columns: 240px minmax(0, 1fr);
  }

  .detail-rail {
    grid-column: 1 / -1;
    border-left: 0;
    border-top: 1px solid var(--line);
    display: grid;
    grid-template-columns: minmax(220px, 0.8fr) 160px minmax(260px, 1fr) minmax(260px, 1fr);
    align-items: start;
  }

  .visual-grid {
    grid-template-columns: minmax(0, 1fr) minmax(280px, 0.8fr);
  }

  .research-grid {
    grid-template-columns: minmax(0, 1fr) minmax(280px, 0.8fr);
  }

  .price-panel,
  .compare-panel {
    grid-column: span 2;
  }
}

@media (max-width: 860px) {
  .top-bar {
    align-items: flex-start;
    flex-direction: column;
  }

  .terminal-layout {
    grid-template-columns: 1fr;
  }

  .control-rail {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .regime-strip,
  .visual-grid,
  .research-grid,
  .detail-rail {
    grid-template-columns: 1fr;
  }

  .panel-wide,
  .price-panel,
  .compare-panel {
    grid-column: auto;
  }

  .regime-cell {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .regime-cell:last-child {
    border-bottom: 0;
  }

  .heatmap {
    grid-template-columns: 78px repeat(4, minmax(66px, 1fr));
  }

  .peer-grid,
  .kpi-grid {
    grid-template-columns: 1fr;
  }
}
