:root {
  color-scheme: dark;
  --bg: #0a0b0d;
  --surface: #131417;
  --surface-2: #171a1e;
  --surface-3: #0f1114;
  --border: #2b2f36;
  --text: #eef1f5;
  --muted: #9ca3ad;
  --red: #ef5350;
  --green: #22c55e;
  --yellow: #f2c94c;
  --blue: #60a5fa;
  --cyan: #35d0ba;
  --violet: #c084fc;
}

* {
  box-sizing: border-box;
}

html {
  background: var(--bg);
  overflow-x: hidden;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  overflow-x: hidden;
}

button,
input {
  font: inherit;
}

button {
  min-height: 38px;
}

.app {
  min-height: 100vh;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  min-height: 76px;
  padding: 12px 22px;
  border-bottom: 1px solid var(--border);
  background: rgba(10, 11, 13, 0.96);
  backdrop-filter: blur(12px);
}

.topbar-main {
  display: flex;
  align-items: center;
  gap: 24px;
  min-width: 0;
}

.brand {
  font-size: 24px;
  line-height: 1;
  font-weight: 800;
}

.subtitle {
  margin-top: 6px;
  color: var(--muted);
  font-size: 13px;
}

.desktop-tabs,
.toolbar,
.chart-actions,
.home-actions,
.report-detail-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.nav-tab,
.toolbar button,
.chart-actions button,
.panel-button,
.home-actions button,
.table-link {
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 7px;
  cursor: pointer;
  font-weight: 700;
}

.nav-tab {
  min-width: 62px;
  padding: 8px 12px;
}

.nav-tab.active,
.chart-actions button.active,
.toolbar button,
.panel-button,
.home-actions button:first-child {
  color: #03110f;
  background: var(--cyan);
  border-color: var(--cyan);
}

.toolbar input {
  width: 132px;
  padding: 9px 10px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 7px;
}

.toolbar button {
  padding: 9px 14px;
}

.toolbar button.secondary,
.home-actions button:last-child {
  color: var(--text);
  background: var(--surface-2);
  border-color: var(--border);
}

.layout {
  display: grid;
  grid-template-columns: 268px minmax(0, 1fr);
  min-height: calc(100vh - 76px);
}

body:not([data-view="intraday"]) .layout {
  grid-template-columns: 1fr;
}

body:not([data-view="intraday"]) .sidebar {
  display: none;
}

.sidebar {
  border-right: 1px solid var(--border);
  background: var(--surface-3);
  padding: 16px;
}

.side-title {
  margin-bottom: 12px;
  color: var(--muted);
  font-size: 13px;
}

.date-list {
  display: grid;
  gap: 8px;
  max-height: calc(100vh - 132px);
  overflow: auto;
  padding-right: 2px;
}

.date-btn,
.date-chip {
  color: var(--text);
  background: var(--surface);
  border: 1px solid transparent;
  border-radius: 7px;
  cursor: pointer;
}

.date-btn {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 10px;
  text-align: left;
}

.date-chip {
  flex: 0 0 auto;
  display: grid;
  gap: 3px;
  min-width: 86px;
  padding: 9px 10px;
  text-align: center;
}

.date-btn.active,
.date-chip.active {
  border-color: var(--cyan);
  background: #10211f;
}

.date-meta {
  color: var(--muted);
  font-size: 12px;
}

.date-strip {
  display: none;
  gap: 8px;
  margin-top: 12px;
  overflow-x: auto;
  padding-bottom: 2px;
}

.workspace {
  width: min(100%, 1320px);
  min-width: 0;
  margin: 0 auto;
  padding: 18px;
}

.view {
  display: grid;
  gap: 16px;
  min-width: 0;
}

.view.hidden {
  display: none;
}

.dashboard-head,
.chart-head,
.panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: 24px;
  line-height: 1.15;
  overflow-wrap: anywhere;
}

h2 {
  font-size: 17px;
}

#homeSub,
#chartSub,
#backtestSub,
#accuracySummary,
.panel-head p {
  margin-top: 5px;
  color: var(--muted);
  font-size: 13px;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.summary-grid.compact {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.metric,
.dashboard-card,
.chart-panel,
.reports-panel,
.backtest-panel,
.backtest-summary article {
  min-width: 0;
  max-width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.metric {
  min-height: 86px;
  padding: 14px;
}

.metric-label,
.card-kicker,
.backtest-summary span {
  color: var(--muted);
  font-size: 12px;
}

.metric-value {
  margin-top: 8px;
  font-size: 22px;
  line-height: 1.1;
  font-weight: 780;
}

.home-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.trade-plan {
  display: grid;
  grid-template-columns: 1fr 2.8fr;
  gap: 12px;
}

.plan-hero,
.plan-tile {
  min-width: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.plan-hero {
  display: grid;
  align-content: center;
  gap: 8px;
  min-height: 126px;
  padding: 16px;
  border-color: rgba(242, 85, 85, 0.52);
  background: #211314;
}

.plan-headline {
  color: var(--text);
  font-size: 34px;
  font-weight: 850;
  line-height: 1.05;
  overflow-wrap: anywhere;
}

.plan-headline.bad {
  color: var(--red);
}

.plan-headline.good {
  color: var(--green);
}

.plan-headline.neutral {
  color: var(--yellow);
}

.plan-meta {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.38;
}

.plan-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.plan-tile {
  display: grid;
  grid-template-rows: auto auto 1fr;
  gap: 8px;
  min-height: 126px;
  padding: 14px;
  border-top-width: 3px;
}

.plan-tile.bad {
  border-top-color: var(--red);
}

.plan-tile.good {
  border-top-color: var(--green);
}

.plan-tile.neutral {
  border-top-color: var(--yellow);
}

.plan-label {
  color: var(--muted);
  font-size: 12px;
}

.plan-level {
  color: var(--text);
  font-size: 24px;
  font-weight: 820;
  line-height: 1.1;
  overflow-wrap: anywhere;
}

.plan-action {
  align-self: end;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.3;
  overflow-wrap: anywhere;
}

.daily-discipline {
  display: grid;
  min-width: 0;
  padding: 16px;
  background: linear-gradient(135deg, rgba(245, 197, 66, 0.14), rgba(239, 83, 80, 0.12));
  border: 1px solid rgba(245, 197, 66, 0.32);
  border-radius: 8px;
}

.discipline-head {
  min-width: 0;
}

.discipline-head h2 {
  margin-top: 6px;
  color: var(--yellow);
  font-size: 32px;
  font-weight: 860;
  line-height: 1.08;
  overflow-wrap: anywhere;
}

.model-chart-card {
  display: grid;
  gap: 10px;
  min-width: 0;
  padding: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.model-chart-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.model-chart-title {
  margin-top: 4px;
  font-size: 16px;
  font-weight: 760;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.model-chart-link {
  flex: 0 0 auto;
  padding: 8px 10px;
  color: #03110f;
  background: var(--cyan);
  border-radius: 7px;
  text-decoration: none;
  font-size: 13px;
  font-weight: 760;
}

.model-chart-frame {
  min-width: 0;
  overflow: hidden;
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 7px;
}

.model-chart-frame.html {
  height: 520px;
}

.model-chart-frame.image {
  overflow: auto;
}

.model-chart-frame.component {
  display: grid;
  gap: 8px;
  padding: 8px;
  background: #07090d;
}

.model-chart-frame iframe,
.model-chart-frame img {
  display: block;
  width: 100%;
  border: 0;
}

.model-chart-frame iframe {
  height: 100%;
}

.model-chart-frame img {
  height: auto;
  object-fit: contain;
  background: #f8fafc;
}

.component-chart-canvas {
  display: block;
  width: 100%;
  margin: 0;
  background: #07090d;
  border-radius: 7px;
}

.component-chart-canvas.forecast-path {
  height: 420px;
  min-height: 420px;
}

.component-chart-canvas.neighbor-model {
  height: 680px;
  min-height: 680px;
}

.component-chart-note {
  color: #9aa7b8;
  font-size: 12px;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.decision-layout,
.forecast-summary {
  display: grid;
  grid-template-columns: 1.6fr 0.9fr 0.9fr;
  gap: 12px;
}

.home-split {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.dashboard-card {
  display: grid;
  gap: 10px;
  min-height: 154px;
  padding: 16px;
}

.dashboard-card.wide {
  grid-column: span 1;
}

.card-title {
  font-size: 19px;
  font-weight: 780;
  line-height: 1.25;
}

.card-body,
.report-summary {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.58;
}

.decision-card {
  align-content: start;
}

.decision-main {
  display: flex;
  align-items: center;
  gap: 12px;
}

.decision-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 74px;
  min-height: 38px;
  padding: 8px 12px;
  border-radius: 999px;
  color: #061016;
  background: var(--muted);
  font-weight: 800;
}

.decision-chip.good {
  background: var(--green);
}

.decision-chip.neutral {
  background: var(--yellow);
}

.decision-chip.bad {
  background: var(--red);
}

.decision-sub {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
}

.decision-sub.good {
  color: var(--green);
}

.decision-sub.neutral {
  color: var(--yellow);
}

.decision-sub.bad {
  color: var(--red);
}

.insight-list {
  display: grid;
  gap: 7px;
  margin: 0;
  padding-left: 18px;
  color: var(--text);
  font-size: 13px;
  line-height: 1.55;
}

.level-list,
.context-list,
.market-stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.level-list span,
.context-list span,
.market-stats span {
  display: grid;
  gap: 3px;
  min-height: 42px;
  padding: 8px;
  color: var(--muted);
  background: var(--surface-3);
  border: 1px solid var(--border);
  border-radius: 7px;
  font-size: 12px;
}

.level-list span {
  place-items: center;
  color: var(--text);
  font-size: 15px;
  font-weight: 760;
}

.context-list strong,
.market-stats strong {
  color: var(--text);
  font-size: 14px;
}

.list-card {
  align-content: start;
  min-height: 286px;
}

.mini-list {
  display: grid;
  gap: 8px;
}

.mini-list-row {
  display: grid;
  grid-template-columns: minmax(110px, 0.8fr) minmax(78px, auto) minmax(0, 1.6fr);
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 46px;
  padding: 9px 10px;
  color: var(--text);
  background: var(--surface-3);
  border: 1px solid var(--border);
  border-radius: 7px;
  cursor: pointer;
  text-align: left;
}

.mini-list-row strong {
  font-size: 13px;
}

.mini-list-row strong.good {
  color: var(--green);
}

.mini-list-row strong.neutral {
  color: var(--yellow);
}

.mini-list-row strong.bad {
  color: var(--red);
}

.mini-list-row em,
.mini-list-empty {
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  font-style: normal;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.card-metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.card-metrics span {
  display: grid;
  gap: 3px;
  min-height: 46px;
  padding: 8px;
  background: var(--surface-3);
  border: 1px solid var(--border);
  border-radius: 7px;
  color: var(--muted);
  font-size: 12px;
}

.card-metrics strong {
  color: var(--text);
  font-size: 15px;
}

.chart-panel,
.reports-panel,
.backtest-panel {
  padding: 16px;
}

.chart-panel {
  overflow: hidden;
}

.dashboard-head > *,
.chart-head > *,
.panel-head > * {
  min-width: 0;
}

.chart-actions {
  flex-wrap: wrap;
  justify-content: flex-end;
}

.chart-actions button,
.panel-button,
.home-actions button {
  padding: 7px 10px;
}

.ohlc {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
  color: var(--muted);
  font-size: 13px;
}

.ohlc strong {
  color: var(--text);
  font-weight: 650;
}

canvas {
  display: block;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  height: min(62vh, 540px);
  min-height: 420px;
  margin-top: 12px;
  border-radius: 7px;
  background: #07090d;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  align-items: center;
  margin-top: 10px;
  color: var(--muted);
  font-size: 12px;
}

.line,
.bar {
  display: inline-block;
  width: 18px;
  height: 3px;
  margin-right: 6px;
  vertical-align: middle;
}

.line.price {
  background: var(--yellow);
}

.line.vwap {
  background: var(--blue);
}

.line.prev {
  background: var(--muted);
}

.line.day-separator {
  background: repeating-linear-gradient(90deg, #64748b 0 5px, transparent 5px 9px);
}

.bar {
  height: 8px;
  background: #394150;
}

.backtest-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.backtest-summary article {
  display: grid;
  gap: 7px;
  padding: 14px;
}

.backtest-summary strong {
  font-size: 15px;
  line-height: 1.35;
}

.backtest-table-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.backtest-table-scroll-hint {
  color: var(--muted);
  font-size: 12px;
}

.backtest-table-wrapper {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
}

.backtest-table {
  width: 100%;
  min-width: 720px;
  border-collapse: collapse;
  font-size: 13px;
}

.backtest-table th,
.backtest-table td {
  padding: 11px 12px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  white-space: nowrap;
}

.backtest-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 12px;
}

.backtest-table tr:last-child td {
  border-bottom: 0;
}

.backtest-table td > span:not(.backtest-status-chip) {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
  white-space: normal;
}

.backtest-table td > strong {
  font-size: 14px;
  line-height: 1.35;
}

.backtest-status-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 42px;
  height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 760;
}

.backtest-status-chip.good {
  color: #052015;
  background: var(--green);
}

.backtest-status-chip.neutral {
  color: #241a00;
  background: var(--yellow);
}

.backtest-status-chip.bad {
  color: #290504;
  background: var(--red);
}

.table-link {
  min-height: 30px;
  padding: 5px 8px;
  color: var(--cyan);
  background: transparent;
}

.backtest-empty-state {
  margin-top: 12px;
  color: var(--muted);
  font-size: 13px;
}

.backtest-empty-state.hidden {
  display: none;
}

.reports {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.report {
  display: grid;
  gap: 6px;
  padding: 12px;
  background: var(--surface-3);
  border: 1px solid var(--border);
  border-radius: 7px;
  cursor: pointer;
}

.report.active {
  border-color: var(--cyan);
}

.report-title {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-weight: 700;
}

.report a {
  color: var(--cyan);
  text-decoration: none;
}

.report-detail {
  margin-top: 14px;
  padding: 14px;
  background: var(--surface-3);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.report-detail.hidden {
  display: none;
}

.report-detail h3 {
  margin: 0;
  font-size: 18px;
}

.report-detail-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 8px;
  color: var(--muted);
  font-size: 12px;
}

.report-detail-actions {
  flex-wrap: wrap;
  margin-top: 12px;
}

.report-detail-actions a {
  padding: 7px 10px;
  color: #03110f;
  background: var(--cyan);
  border-radius: 7px;
  text-decoration: none;
  font-weight: 700;
  font-size: 13px;
}

.report-chart-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 14px;
}

.report-preview-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin: 10px 0;
}

.report-preview-grid img {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #07090d;
}

.report-chart-figure {
  margin: 0;
  overflow: hidden;
  background: #07090d;
  border: 1px solid var(--border);
  border-radius: 8px;
}

.report-chart-figure figcaption {
  padding: 10px 12px;
  color: var(--text);
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  font-weight: 760;
}

.report-chart-figure a {
  display: block;
}

.report-chart-figure img {
  display: block;
  width: 100%;
  height: auto;
}

.report-markdown {
  margin-top: 14px;
  max-height: 520px;
  overflow: auto;
  color: #dde5ee;
  background: #07090d;
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 14px;
  white-space: pre-wrap;
  line-height: 1.62;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-size: 13px;
}

.up {
  color: var(--red) !important;
}

.down {
  color: var(--green) !important;
}

.mobile-tabbar {
  display: none;
}

.login-body {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background: var(--bg);
}

.login-shell {
  width: min(380px, calc(100vw - 32px));
}

.login-box {
  display: grid;
  gap: 14px;
  padding: 24px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.login-label {
  color: var(--muted);
  font-size: 13px;
}

.login-input {
  width: 100%;
  padding: 11px 12px;
  color: var(--text);
  background: var(--surface-3);
  border: 1px solid var(--border);
  border-radius: 7px;
}

.login-submit {
  padding: 11px 14px;
  color: #03110f;
  background: var(--cyan);
  border: 0;
  border-radius: 7px;
  font-weight: 750;
  cursor: pointer;
}

.login-submit:disabled {
  cursor: wait;
  opacity: 0.7;
}

.login-error {
  min-height: 18px;
  color: #ff8a80;
  font-size: 13px;
}

@media (max-width: 980px) {
  .trade-plan {
    grid-template-columns: 1fr;
  }

  .plan-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .summary-grid,
  .summary-grid.compact,
  .home-grid,
  .decision-layout,
  .forecast-summary,
  .home-split {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .dashboard-card.wide {
    grid-column: span 2;
  }
}

@media (max-width: 760px) {
  body {
    padding-bottom: 72px;
  }

  .topbar {
    align-items: stretch;
    flex-direction: column;
    gap: 8px;
    min-height: auto;
    padding: 8px 12px;
  }

  .topbar-main {
    justify-content: space-between;
    gap: 12px;
  }

  .brand {
    font-size: 20px;
  }

  .subtitle {
    display: none;
  }

  .desktop-tabs {
    display: none;
  }

  .toolbar {
    width: 100%;
  }

  .toolbar input {
    flex: 1 1 auto;
    min-width: 0;
    padding: 7px 8px;
  }

  .toolbar button {
    flex: 0 0 auto;
    padding-inline: 12px;
    min-height: 34px;
    padding-block: 7px;
  }

  .layout,
  body:not([data-view="intraday"]) .layout {
    display: block;
    min-height: 0;
  }

  .sidebar {
    display: none;
  }

  .workspace {
    padding: 10px 12px 12px;
  }

  h1 {
    font-size: 20px;
  }

  .dashboard-head,
  .chart-head,
  .panel-head {
    display: grid;
    gap: 12px;
  }

  .home-actions,
  .chart-actions {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    width: 100%;
  }

  .home-actions {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  body[data-view="home"] .home-actions {
    display: none;
  }

  .chart-actions button,
  .home-actions button {
    width: 100%;
    padding-inline: 6px;
  }

  .plan-hero {
    min-height: 92px;
    padding: 14px;
  }

  .plan-headline {
    font-size: 28px;
  }

  .plan-tile {
    min-height: 106px;
    padding: 12px;
  }

  .plan-level {
    font-size: 20px;
  }

  .model-chart-head {
    align-items: flex-start;
  }

  .model-chart-frame.html {
    height: 320px;
  }

  .component-chart-canvas.forecast-path {
    height: 340px;
    min-height: 340px;
  }

  .component-chart-canvas.neighbor-model {
    height: 620px;
    min-height: 620px;
  }

  .summary-grid,
  .summary-grid.compact,
  .home-grid,
  .decision-layout,
  .forecast-summary,
  .home-split,
  .backtest-summary {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }

  .dashboard-card.wide {
    grid-column: span 2;
  }

  .metric {
    min-height: 76px;
    padding: 12px;
  }

  .metric-value {
    font-size: 19px;
  }

  .card-metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .decision-card {
    grid-column: span 2;
  }

  .mini-list-row {
    grid-template-columns: 1fr auto;
  }

  .mini-list-row em {
    grid-column: 1 / -1;
  }

  .chart-panel,
  .reports-panel,
  .backtest-panel {
    padding: 12px;
  }

  .report-chart-grid {
    grid-template-columns: 1fr;
  }

  .backtest-table-wrapper {
    overflow-x: visible;
  }

  .backtest-table {
    min-width: 0;
  }

  .backtest-table thead {
    display: none;
  }

  .backtest-table,
  .backtest-table tbody,
  .backtest-table tr,
  .backtest-table td {
    display: block;
    width: 100%;
  }

  .backtest-table tr {
    padding: 12px;
    border-bottom: 1px solid var(--border);
  }

  .backtest-table tr:last-child {
    border-bottom: 0;
  }

  .backtest-table td {
    display: grid;
    grid-template-columns: 78px minmax(0, 1fr);
    gap: 10px;
    padding: 7px 0;
    border-bottom: 0;
    white-space: normal;
  }

  .backtest-table td::before {
    content: attr(data-label);
    grid-column: 1;
    grid-row: 1 / span 2;
    color: var(--muted);
    font-size: 12px;
    line-height: 1.35;
  }

  .backtest-table td > strong,
  .backtest-table td > .backtest-status-chip,
  .backtest-table td > .table-link {
    grid-column: 2;
    justify-self: start;
  }

  .backtest-table td > span:not(.backtest-status-chip) {
    grid-column: 2;
    margin-top: 0;
  }

  .date-strip {
    display: flex;
  }

  .ohlc {
    justify-content: flex-start;
  }

  canvas {
    height: 360px;
    min-height: 360px;
  }

  .legend {
    gap: 10px;
  }

  .backtest-table-toolbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .report-title {
    display: grid;
  }

  .report-markdown {
    max-height: 60vh;
    font-size: 12px;
  }

  .mobile-tabbar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 30;
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 6px;
    padding: 8px 10px calc(8px + env(safe-area-inset-bottom));
    border-top: 1px solid var(--border);
    background: rgba(10, 11, 13, 0.97);
    backdrop-filter: blur(12px);
  }

  .mobile-tabbar .nav-tab {
    min-width: 0;
    width: 100%;
    padding: 8px 4px;
    font-size: 13px;
  }
}

@media (max-width: 420px) {
  .trade-plan {
    gap: 10px;
  }

  .plan-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }

  .daily-discipline {
    padding: 14px;
  }

  .discipline-head h2 {
    font-size: 24px;
  }

  .plan-tile {
    min-height: 102px;
    padding: 10px;
  }

  .plan-level {
    font-size: 18px;
  }

  .plan-action {
    font-size: 12px;
  }

  .model-chart-card {
    padding: 10px;
  }

  .model-chart-head {
    display: grid;
  }

  .model-chart-link {
    width: max-content;
  }

  .summary-grid,
  .summary-grid.compact,
  .home-grid,
  .decision-layout,
  .home-split,
  .backtest-summary {
    grid-template-columns: 1fr;
  }

  .dashboard-card.wide {
    grid-column: span 1;
  }

  .decision-card {
    grid-column: span 1;
  }

  .home-actions,
  .chart-actions {
    grid-template-columns: 1fr;
  }
}
