:root {
  color-scheme: light;
  --bg: #f7f8fb;
  --ink: #111827;
  --muted: #5d6678;
  --line: #dbe1ea;
  --panel: #ffffff;
  --paper: #166534;
  --live: #b42318;
  --shadow: 0 18px 50px rgba(21, 31, 51, 0.10);
}

* {
  box-sizing: border-box;
}

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

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

a {
  color: inherit;
}

.home-page {
  display: grid;
  min-height: 100vh;
  place-items: center;
}

.home-shell {
  display: grid;
  grid-template-columns: repeat(2, minmax(180px, 280px));
  gap: 24px;
  width: min(640px, calc(100vw - 32px));
}

.mode-button {
  display: grid;
  min-height: 160px;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.48);
  border-radius: 8px;
  color: #ffffff;
  font-size: 44px;
  font-weight: 800;
  text-decoration: none;
  text-transform: lowercase;
  box-shadow: var(--shadow);
  transition: transform 160ms ease, filter 160ms ease;
}

.mode-button:hover,
.mode-button:focus-visible {
  filter: brightness(1.05);
  transform: translateY(-2px);
  outline: none;
}

.mode-button.paper {
  background: var(--paper);
}

.mode-button.live {
  background: var(--live);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 68px;
  padding: 0 28px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.86);
  backdrop-filter: blur(12px);
}

.back-link {
  font-weight: 800;
  text-decoration: none;
}

.mode-nav {
  display: flex;
  gap: 8px;
}

.mode-nav a {
  min-width: 76px;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  font-weight: 750;
  text-align: center;
  text-decoration: none;
}

.mode-nav a.active {
  border-color: #111827;
  background: #111827;
  color: #ffffff;
}

.results-shell {
  width: min(1180px, calc(100vw - 32px));
  margin: 36px auto 48px;
}

.chart-header {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 24px;
  min-height: 84px;
  margin-bottom: 18px;
}

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

h1 {
  margin: 0;
  font-size: 34px;
  line-height: 1.1;
}

.summary-text {
  max-width: 680px;
  min-height: 22px;
  margin: 0;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.45;
  text-align: right;
  white-space: nowrap;
}

.chart-actions {
  display: grid;
  justify-items: end;
  gap: 10px;
  min-width: min(680px, 100%);
}

.metric-toggle {
  display: inline-flex;
  gap: 6px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.metric-toggle button {
  min-width: 104px;
  padding: 9px 12px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font: inherit;
  font-size: 13px;
  font-weight: 800;
  text-transform: lowercase;
}

.metric-toggle button.active {
  background: #111827;
  color: #ffffff;
}

.metric-toggle button:focus-visible {
  outline: 2px solid #2563eb;
  outline-offset: 2px;
}

.chart-wrap {
  position: relative;
  min-height: 560px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

#pnl-chart {
  display: block;
  width: 100%;
  height: 560px;
}

.axis text,
.tick-label {
  fill: var(--muted);
  font-size: 12px;
}

.axis-line,
.grid-line {
  stroke: var(--line);
  stroke-width: 1;
}

.zero-line {
  stroke: #9aa4b2;
  stroke-dasharray: 4 5;
}

.bot-line {
  fill: none;
  stroke-width: 3;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.bot-dot {
  stroke: #ffffff;
  stroke-width: 2;
}

.total-line {
  stroke-width: 4;
}

.total-dot {
  stroke-width: 3;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 18px;
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--muted);
  font-size: 13px;
  font-weight: 750;
}

.total-item {
  border-color: #111827;
  color: #111827;
}

.legend-swatch {
  width: 12px;
  height: 12px;
  border-radius: 99px;
}

.empty-state {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: var(--muted);
  font-weight: 750;
}

.empty-state[hidden] {
  display: none;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

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

  .mode-button {
    min-height: 132px;
    font-size: 38px;
  }

  .topbar {
    padding: 0 16px;
  }

  .chart-header {
    display: block;
    min-height: 0;
  }

  .summary-text {
    margin-top: 10px;
    text-align: left;
    white-space: normal;
  }

  .chart-actions {
    justify-items: start;
    margin-top: 14px;
    min-width: 0;
  }

  .metric-toggle {
    width: 100%;
  }

  .metric-toggle button {
    flex: 1;
    min-width: 0;
  }

  #pnl-chart,
  .chart-wrap {
    min-height: 460px;
  }

  #pnl-chart {
    height: 460px;
  }
}
