:root {
  color-scheme: light;
  --bg: #f4f6f2;
  --panel: #ffffff;
  --panel-soft: #eef3ec;
  --ink: #17201b;
  --muted: #627067;
  --line: #dce4dc;
  --live: #0f766e;
  --paper: #7c3aed;
  --paper-v2: #b7791f;
  --loss: #b42318;
  --gain: #087443;
  --warning: #b7791f;
  --shadow: 0 18px 45px rgba(25, 36, 28, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  line-height: 1.45;
}

button,
select {
  font: inherit;
}

.app-shell {
  display: grid;
  grid-template-columns: 248px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  border-right: 1px solid var(--line);
  background: #fbfcfa;
  padding: 22px 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 44px;
}

.brand-mark {
  display: inline-grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border-radius: 8px;
  background: var(--ink);
  color: #fff;
  font-weight: 800;
}

.brand strong,
.brand small {
  display: block;
}

.brand small {
  color: var(--muted);
  font-size: 12px;
}

.nav-list {
  display: grid;
  gap: 8px;
  margin-top: 28px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 42px;
  padding: 0 10px;
  border-radius: 8px;
  color: var(--ink);
  text-decoration: none;
  font-weight: 650;
}

.nav-item.active {
  background: var(--panel-soft);
}

.nav-icon {
  display: inline-grid;
  width: 28px;
  height: 28px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  font-size: 11px;
  font-weight: 800;
}

.workspace {
  display: grid;
  gap: 22px;
  align-content: start;
  padding: 28px;
}

.page-header,
.toolbar,
.section-heading,
.header-actions,
.legend,
.select-field {
  display: flex;
  align-items: center;
}

.page-header {
  justify-content: space-between;
  gap: 20px;
}

.page-header h1,
.section-heading h2 {
  margin: 0;
  letter-spacing: 0;
}

.page-header h1 {
  font-size: clamp(28px, 3vw, 42px);
  line-height: 1.05;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.header-actions {
  justify-content: flex-end;
  gap: 10px;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 38px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.status-dot {
  width: 9px;
  height: 9px;
  border-radius: 999px;
  background: var(--warning);
}

.status-pill.ok .status-dot {
  background: var(--gain);
}

.status-pill.demo .status-dot {
  background: var(--warning);
}

.status-pill.error .status-dot {
  background: var(--loss);
}

.icon-button {
  display: inline-grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--ink);
  cursor: pointer;
  font-weight: 800;
}

.icon-button:hover,
.segment:hover {
  border-color: #b8c7ba;
}

.toolbar {
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 14px;
  padding-bottom: 2px;
}

.segmented-control {
  display: inline-grid;
  grid-template-columns: repeat(4, minmax(78px, 1fr));
  min-height: 40px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.segment {
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 13px;
  font-weight: 800;
}

.segment.active {
  background: var(--ink);
  color: #fff;
}

.select-field {
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 750;
}

.select-field select {
  min-height: 38px;
  min-width: 92px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 0 28px 0 10px;
}

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

.metric-card,
.chart-section,
.data-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.metric-card {
  min-height: 128px;
  padding: 16px;
}

.metric-card small {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}

.metric-card strong {
  display: block;
  margin-top: 10px;
  font-size: 24px;
  line-height: 1.08;
  overflow-wrap: anywhere;
}

.metric-card span {
  display: block;
  margin-top: 8px;
  color: var(--muted);
  font-size: 12px;
}

.gain {
  color: var(--gain);
}

.loss {
  color: var(--loss);
}

.warning {
  color: var(--warning);
}

.edge-section {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
  padding: 18px;
}

.edge-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(120px, 1fr));
  gap: 12px;
  margin-top: 14px;
}

.edge-card {
  min-height: 116px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfa;
  padding: 14px;
}

.edge-card small {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.edge-card strong {
  display: block;
  margin-top: 9px;
  font-size: 22px;
  line-height: 1.1;
  overflow-wrap: anywhere;
}

.edge-card span {
  display: block;
  margin-top: 8px;
  color: var(--muted);
  font-size: 12px;
}

.edge-table-wrap {
  overflow-x: auto;
  margin-top: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.edge-table-wrap table {
  min-width: 820px;
}

.chart-section {
  padding: 18px;
}

.section-heading {
  justify-content: space-between;
  gap: 16px;
}

.section-heading h2 {
  font-size: 20px;
}

.section-heading.compact {
  padding: 16px 16px 8px;
}

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

.chart-frame {
  position: relative;
  min-height: 320px;
  margin-top: 14px;
}

#equity-chart {
  display: block;
  width: 100%;
  height: 320px;
}

.legend {
  gap: 18px;
  margin-top: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.legend span {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

.legend i {
  width: 22px;
  height: 3px;
  border-radius: 99px;
}

.legend-live {
  background: var(--live);
}

.legend-paper {
  background: var(--paper);
}

.legend-paper-v2 {
  background: var(--paper-v2);
}

.data-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 16px;
}

.data-panel {
  min-width: 0;
  overflow: hidden;
}

.table-wrap {
  overflow-x: auto;
}

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

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

th {
  color: var(--muted);
  font-size: 11px;
  font-weight: 850;
  text-transform: uppercase;
}

.num {
  text-align: right;
}

.badge {
  display: inline-flex;
  min-width: 50px;
  min-height: 24px;
  align-items: center;
  justify-content: center;
  border-radius: 7px;
  padding: 0 8px;
  font-size: 11px;
  font-weight: 850;
  text-transform: uppercase;
}

.badge.live {
  background: rgba(15, 118, 110, 0.12);
  color: var(--live);
}

.badge.paper {
  background: rgba(124, 58, 237, 0.12);
  color: var(--paper);
}

.badge.paper-v2 {
  background: rgba(183, 121, 31, 0.14);
  color: var(--paper-v2);
}

.empty-row {
  color: var(--muted);
  text-align: center;
}

.table-pager {
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  border-top: 1px solid var(--line);
  padding: 12px 16px;
  color: var(--muted);
  font-size: 13px;
}

.section-heading .table-pager {
  min-width: 280px;
  border-top: 0;
  padding: 0;
}

.table-pager.compact {
  justify-content: flex-end;
}

.table-pager.compact > span {
  white-space: nowrap;
}

.pager-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.pager-actions button {
  min-width: 62px;
  height: 30px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  color: var(--ink);
  font-weight: 750;
  cursor: pointer;
}

.pager-actions button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.pager-actions span {
  min-width: 78px;
  text-align: center;
  white-space: nowrap;
}

@media (max-width: 1180px) {
  .summary-grid {
    grid-template-columns: repeat(3, minmax(130px, 1fr));
  }

  .edge-grid {
    grid-template-columns: repeat(3, minmax(130px, 1fr));
  }

  .data-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 760px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
    padding: 14px;
  }

  .workspace {
    padding: 18px 14px;
  }

  .page-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .header-actions,
  .toolbar {
    width: 100%;
    justify-content: space-between;
  }

  .segmented-control {
    width: 100%;
  }

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

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

  .metric-card strong {
    font-size: 20px;
  }
}

@media (max-width: 460px) {
  .summary-grid {
    grid-template-columns: 1fr;
  }

  .edge-grid {
    grid-template-columns: 1fr;
  }
}
