:root {
  --bg: #f5f5f4;
  --surface: #ffffff;
  --text: #1c1c1c;
  --text-muted: #666666;
  --border: #ddd;
  --accent: #2f6f4f;
  --positive: #1a7a3c;
  --negative: #b3261e;
  --row-alt: #fafafa;
  --series-high: #2a78d6;
  --series-low: #eb6834;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #14171a;
    --surface: #1c2024;
    --text: #e8e8e6;
    --text-muted: #9a9a9a;
    --border: #33383d;
    --accent: #6fbf94;
    --positive: #4fbf7a;
    --negative: #e0685f;
    --row-alt: #1f2327;
    --series-high: #3987e5;
    --series-low: #d95926;
  }
}

:root[data-theme="dark"] {
  --bg: #14171a;
  --surface: #1c2024;
  --text: #e8e8e6;
  --text-muted: #9a9a9a;
  --border: #33383d;
  --accent: #6fbf94;
  --positive: #4fbf7a;
  --negative: #e0685f;
  --row-alt: #1f2327;
  --series-high: #3987e5;
  --series-low: #d95926;
}

* { box-sizing: border-box; }

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

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1.25rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
  gap: 0.5rem;
}

header h1 { font-size: 1.1rem; margin: 0; }

.meta { color: var(--text-muted); font-size: 0.85rem; }

.main-nav { position: relative; }

.nav-toggle {
  display: inline-block;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text);
  font-size: 1.1rem;
  padding: 0.25rem 0.6rem;
  cursor: pointer;
}

.nav-links {
  display: none;
  position: absolute;
  right: 0;
  top: calc(100% + 0.4rem);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.6rem;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.5rem;
  z-index: 10;
  min-width: 200px;
}

.nav-links.open { display: flex; }

.nav-links .link-btn { width: 100%; text-align: left; }

main { padding: 1rem 1.25rem 2rem; max-width: 1900px; margin: 0 auto; }

.bankroll-form {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.bankroll-form input {
  padding: 0.4rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--surface);
  color: var(--text);
  width: 160px;
}

.bankroll-form button, .link-btn {
  padding: 0.4rem 0.9rem;
  border: 1px solid var(--accent);
  border-radius: 4px;
  background: transparent;
  color: var(--accent);
  cursor: pointer;
  font-size: 0.9rem;
  text-decoration: none;
}

.text-link {
  color: var(--accent);
  text-decoration: none;
}
.text-link:hover { text-decoration: underline; }

.banner {
  background: var(--row-alt);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.6rem 0.9rem;
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-bottom: 1rem;
}

table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
  font-size: 0.82rem;
}

th, td {
  padding: 0.4rem 0.5rem;
  text-align: right;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

th:first-child, td:first-child { text-align: left; }

th {
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

tbody tr:nth-child(even) { background: var(--row-alt); }
tbody tr:hover { background: color-mix(in srgb, var(--accent) 10%, transparent); }

.score { font-weight: 700; }
.positive { color: var(--positive); }
.negative { color: var(--negative); }
.muted { color: var(--text-muted); font-size: 0.78rem; }

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

.login-box {
  max-width: 320px;
  margin: 4rem auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1.5rem;
}

.login-box input {
  display: block;
  width: 100%;
  margin-bottom: 0.75rem;
  padding: 0.5rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--bg);
  color: var(--text);
}

.error { color: var(--negative); font-size: 0.85rem; margin-bottom: 0.75rem; }

.chart-wrap { position: relative; width: 100%; max-width: 900px; }
.chart-svg { width: 100%; height: auto; display: block; }
.chart-grid { stroke: var(--border); stroke-width: 1; }
.chart-axis-label { fill: var(--text-muted); font-size: 11px; font-family: system-ui, sans-serif; }
.chart-bar { fill: var(--text-muted); opacity: 0.55; }
.chart-crosshair { stroke: var(--text-muted); stroke-width: 1; stroke-dasharray: 3 3; }
.chart-overlay { cursor: crosshair; }
.chart-empty { color: var(--text-muted); font-size: 0.85rem; padding: 1rem 0; }

.chart-legend { display: flex; gap: 1rem; margin-bottom: 0.5rem; font-size: 0.85rem; color: var(--text-muted); }
.chart-legend-item { display: flex; align-items: center; gap: 0.4rem; }
.chart-legend-dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }

.chart-tooltip {
  position: absolute;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.4rem 0.6rem;
  font-size: 0.78rem;
  color: var(--text);
  pointer-events: none;
  box-shadow: 0 2px 6px rgba(0,0,0,0.15);
  white-space: nowrap;
}

.trend-cell span { margin-right: 0.2rem; font-size: 0.82rem; cursor: default; }
.trend-cell span:last-child { margin-right: 0; }

.actions-cell { display: flex; gap: 0.4rem; flex-wrap: wrap; }

/* Below this width, data tables become a stack of labeled cards instead of a wide scrolling
   grid -- built for the guys checking this on their phones, not just resized desktop windows. */
@media (max-width: 700px) {
  main { padding: 0.75rem 0.75rem 1.5rem; }

  .responsive-table thead { display: none; }
  .responsive-table, .responsive-table tbody, .responsive-table tr, .responsive-table td {
    display: block;
    width: 100%;
  }
  .responsive-table {
    border: none;
    background: transparent;
  }
  .responsive-table tr {
    margin-bottom: 0.75rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
    padding: 0.5rem 0.75rem;
  }
  .responsive-table td {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.75rem;
    text-align: right;
    white-space: normal;
    border-bottom: 1px solid var(--border);
    padding: 0.45rem 0;
  }
  .responsive-table td:last-child { border-bottom: none; }
  .responsive-table td::before {
    content: attr(data-label);
    font-weight: 600;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--text-muted);
    text-align: left;
    flex-shrink: 0;
  }
  .responsive-table td.card-heading {
    display: block;
    text-align: left;
    font-size: 1rem;
    border-bottom: 1px solid var(--border);
    padding-bottom: 0.5rem;
    margin-bottom: 0.25rem;
  }
  .responsive-table td.card-heading::before { content: none; }
  .responsive-table .trend-cell { justify-content: flex-start; }
}
