/* ── RESET & TOKENS ─────────────────────────────────────────── */
:root {
  /* ── Dark theme (default) ─────────────────────────────────── */
  --bg-page:        #0a0a0f;
  --bg-surface:     #111118;
  --bg-card:        #16161f;
  --bg-hover:       #1c1c28;
  --accent:         #d4a843;
  --accent-glow:    rgba(212, 168, 67, 0.12);
  --text-primary:   #e8e8f0;
  --text-secondary: #8888a0;
  --text-dim:       #4a4a60;
  --num-positive:   #5cb87a;
  --num-warn:       #e8854a;
  --num-danger:     #e85454;
  --color-res:      #4a9eff;
  --color-nonres:   #d4a843;
  --border:         rgba(255, 255, 255, 0.06);
  --border-accent:  rgba(212, 168, 67, 0.3);
  --radius:         8px;

  /* Backdrop / surface overlay colors */
  --bg-header:      rgba(10, 10, 15, 0.9);
  --bg-controls:    rgba(10, 10, 15, 0.7);
  --bg-back:        rgba(10, 10, 15, 0.85);
  --bg-footer:      rgba(10, 10, 15, 0.9);

  /* Misc component tokens */
  --bg-dropdown:    #16161f;
  --table-sep:      rgba(255, 255, 255, 0.03);
  --dot-color:      rgba(212, 168, 67, 0.055);

  /* Canvas chart */
  --chart-grid:     rgba(255, 255, 255, 0.04);
  --chart-label:    rgba(136, 136, 160, 0.5);

  /* Sparkline hover tooltip */
  --spark-tip-bg:     #1a1a24;
  --spark-tip-border: #2e2e42;
  --spark-tip-yr:     #5a5a78;
  --spark-tip-sep:    #1e1e30;
  --spark-tip-val:    #e8e8f0;

  /* Sparkline SVG internals */
  --svg-grid:       #1a1a28;
  --svg-yr-tick:    #3a3a55;
  --svg-legend:     #5a5a78;
  --svg-amt:        #3a3a55;
  --svg-dim:        #3a3a55;

  /* Trend popup */
  --popup-bg:       #1a1a24;
  --popup-border:   #333;
  --popup-color:    #a0a0b0;
  --popup-val:      #fff;

  /* Quota totals sub */
  --quota-sub-sep:  rgba(255, 255, 255, 0.1);

  /* Theme toggle */
  --toggle-bg:      rgba(255, 255, 255, 0.06);
  --toggle-hover:   rgba(255, 255, 255, 0.1);
  --toggle-icon:    #8888a0;
}

/* ── LIGHT THEME OVERRIDE — SLATE ────────────────────────────── */
/* Overcast alt: page #d0d2d7, surface #c4c7cd, card #b8bbc2, accent #3e6882 */
html[data-theme="light"] {
  --bg-page:        #d1d0d5;
  --bg-surface:     #c5c4cb;
  --bg-card:        #b9b8c0;
  --bg-hover:       #aeadb6;
  --accent:         #4872a0;
  --accent-glow:    rgba(72, 114, 160, 0.13);
  --text-primary:   #16181e;
  --text-secondary: #394150;
  --text-dim:       #555d6d;
  --num-positive:   #3a7a50;
  --num-warn:       #a06030;
  --num-danger:     #b83030;
  --color-res:      #4872a0;
  --color-nonres:   #8a6820;
  --border:         rgba(0, 0, 0, 0.09);
  --border-accent:  rgba(72, 114, 160, 0.32);

  /* Backdrop / surface overlay colors */
  --bg-header:      rgba(209, 208, 213, 0.93);
  --bg-controls:    #b9b8c0;
  --bg-back:        rgba(209, 208, 213, 0.96);
  --bg-footer:      rgba(209, 208, 213, 0.93);

  /* Misc component tokens */
  --bg-dropdown:    #c5c4cb;
  --table-sep:      rgba(0, 0, 0, 0.04);
  --dot-color:      rgba(0, 0, 0, 0.04);

  /* Canvas chart */
  --chart-grid:     rgba(0, 0, 0, 0.07);
  --chart-label:    rgba(74, 80, 96, 0.75);

  /* Sparkline hover tooltip — keep dark for legibility */
  --spark-tip-bg:     #1a1a24;
  --spark-tip-border: #2e2e42;
  --spark-tip-yr:     #5a5a78;
  --spark-tip-sep:    #1e1e30;
  --spark-tip-val:    #e8e8f0;

  /* Sparkline SVG internals */
  --svg-grid:       #b0b0be;
  --svg-yr-tick:    #8a8a9a;
  --svg-legend:     #8a8a9a;
  --svg-amt:        #8a8a9a;
  --svg-dim:        #8a8a9a;

  /* Trend popup */
  --popup-bg:       #c5c4cb;
  --popup-border:   rgba(0, 0, 0, 0.13);
  --popup-color:    #4a5060;
  --popup-val:      #16181e;

  /* Quota totals sub */
  --quota-sub-sep:  rgba(0, 0, 0, 0.09);

  /* Theme toggle */
  --toggle-bg:      rgba(0, 0, 0, 0.06);
  --toggle-hover:   rgba(0, 0, 0, 0.1);
  --toggle-icon:    #4a5060;
}

*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

/* Screen-reader only utility */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
}

html {
  overscroll-behavior-x: none;
}

body {
  background: var(--bg-page);
  color: var(--text-primary);
  font-family: 'Syne', sans-serif;
  min-height: 100vh;
  overflow-x: hidden;
  overscroll-behavior-x: none;
  transition: background 0.25s ease, color 0.25s ease;
}

/* Dot-grid texture */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image: radial-gradient(circle, var(--dot-color) 1px, transparent 1px);
  background-size: 28px 28px;
  pointer-events: none;
  z-index: 0;
}

/* ── FOCUS STATES ────────────────────────────────────────────── */
a:focus-visible,
button:focus-visible,
[tabindex]:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

/* Inputs use border-color + glow for focus — suppress default outline */
input:focus-visible,
select:focus-visible {
  outline: none;
  border-color: var(--accent) !important;
  box-shadow: 0 0 0 2px var(--accent-glow);
}

/* ── HEADER ──────────────────────────────────────────────────── */
header {
  position: relative;
  z-index: 10;
  padding: 20px 28px 18px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  background: var(--bg-header);
  backdrop-filter: blur(12px);
  transition: background 0.25s ease, border-color 0.25s ease;
}

.header-brand {
  color: var(--text-primary);
  display: inline-flex;
  flex-direction: column;
  align-items: flex-start;
  line-height: 1;
  margin-bottom: 4px;
}

.header-brand-main {
  font-family: 'Syne', sans-serif;
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--text-primary);
}

.header-brand-main span {
  color: var(--accent);
}

.header-brand-sub {
  margin-top: 5px;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.68rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--text-secondary);
  white-space: nowrap;
}

.header-left h1 {
  font-size: 17px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.header-left h1 span {
  color: var(--accent);
}

.header-subtitle {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 10px;
  color: var(--text-secondary);
  letter-spacing: 0.12em;
  margin-top: 4px;
  text-transform: uppercase;
}

.header-badge {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 12px;
  font-weight: 600;
  color: var(--accent);
  background: var(--accent-glow);
  border: 1px solid var(--border-accent);
  padding: 5px 14px;
  border-radius: 4px;
  letter-spacing: 0.12em;
  white-space: nowrap;
}

/* ── THEME TOGGLE BUTTON ─────────────────────────────────────── */
.theme-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--toggle-icon);
  background: var(--toggle-bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 6px 12px;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
  user-select: none;
}

.theme-toggle:hover {
  background: var(--toggle-hover);
  color: var(--text-secondary);
  border-color: var(--border-accent);
}

.dash-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 6px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-surface);
  position: relative;
  z-index: 10;
}

.dash-nav-links,
.dash-nav-utils {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.dash-nav-utils {
  gap: 10px;
}

.dash-nav-context {
  display: flex;
  align-items: center;
  padding: 4px 8px;
}

.dash-nav-context-title {
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-primary);
  line-height: 1.1;
  text-align: right;
}

.dash-nav-context-title span {
  color: var(--accent);
}

.dash-nav-link {
  font-size: 12px;
  padding: 11px 16px;
  border-radius: 6px;
  border-bottom: none;
}

.dash-nav-link:hover {
  background: var(--bg-hover);
}

.dash-nav-link.active {
  background: var(--accent-glow);
}

.theme-toggle svg {
  flex-shrink: 0;
  transition: transform 0.4s ease;
}

html[data-theme="light"] .theme-toggle svg {
  transform: rotate(180deg);
}

/* ── CONTROLS ────────────────────────────────────────────────── */
.controls {
  position: relative;
  z-index: 10;
  padding: 14px 28px;
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
  border-bottom: 1px solid var(--border);
  background: var(--bg-controls);
  transition: background 0.25s ease;
}

.search-wrap {
  position: relative;
  flex: 1;
  min-width: 160px;
  max-width: 320px;
}

.search-wrap::before {
  content: '⌕';
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-dim);
  font-size: 17px;
  pointer-events: none;
}

.search-input {
  width: 100%;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  color: var(--text-primary);
  font-family: 'IBM Plex Mono', monospace;
  font-size: 12px;
  padding: 9px 12px 9px 34px;
  border-radius: var(--radius);
  outline: none;
  transition: border-color 0.2s, background 0.25s;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.search-input:focus { border-color: var(--border-accent); }
.search-input::placeholder { color: var(--text-dim); text-transform: none; letter-spacing: 0; }

.filter-group {
  display: flex;
  gap: 6px;
  align-items: center;
}

.filter-label {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 10px;
  color: var(--text-secondary);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  white-space: nowrap;
}

.toggle-btn {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 12px;
  padding: 7px 14px;
  border-radius: 4px;
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--bg-surface);
  color: var(--text-secondary);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  transition: all 0.2s;
}

.toggle-btn.active-res    { border-color: var(--color-res);    color: var(--color-res);    background: rgba(74, 158, 255, 0.08); }
.toggle-btn.active-nonres { border-color: var(--color-nonres); color: var(--color-nonres); background: var(--accent-glow); }

.pref-filter { display: flex; align-items: center; gap: 8px; }

.pref-input {
  width: 68px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  color: var(--text-primary);
  font-family: 'IBM Plex Mono', monospace;
  font-size: 13px;
  padding: 7px 8px;
  border-radius: var(--radius);
  outline: none;
  text-align: center;
  transition: border-color 0.2s, background 0.25s;
}

.pref-input:focus { border-color: var(--border-accent); }

.results-count {
  margin-left: auto;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 10px;
  color: var(--text-dim);
  letter-spacing: 0.08em;
  white-space: nowrap;
}

/* ── MOBILE BACK ─────────────────────────────────────────────── */
.mobile-back {
  display: none;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 12px 24px;
  border: none;
  border-bottom: 1px solid var(--border);
  background: var(--bg-back);
  cursor: pointer;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  color: var(--accent);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  position: relative;
  z-index: 10;
  text-align: left;
  transition: background 0.25s ease;
}

/* ── MAIN LAYOUT ─────────────────────────────────────────────── */
.main-layout {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: 360px 1fr;
  height: calc(100dvh - 113px);
  min-height: 0;
  overflow: hidden;
}

/* ── LIST PANEL ──────────────────────────────────────────────── */
.list-panel {
  border-right: 1px solid var(--border);
  overflow-y: auto;
  min-height: 0;
  scrollbar-width: thin;
  scrollbar-color: var(--text-dim) transparent;
}

.hunt-item {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.15s;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 6px;
  align-items: start;
}

.hunt-item:hover { background: var(--bg-hover); }
.hunt-item.selected { background: var(--bg-hover); border-left: 2px solid var(--accent); }

.hunt-code-label {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
  letter-spacing: 0.06em;
}

.hunt-meta {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 10px;
  color: var(--text-secondary);
  letter-spacing: 0.06em;
  margin-top: 2px;
}

.hunt-quota {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 10px;
  color: var(--text-secondary);
  text-align: right;
}

.quota-num { font-size: 15px; font-weight: 500; color: var(--text-primary); display: block; }

.min-pref-badge {
  display: inline-block;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 10px;
  padding: 2px 5px;
  border-radius: 3px;
  margin-top: 4px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.badge-hard { background: rgba(232,84,84,0.15);  color: var(--num-danger);   border: 1px solid rgba(232,84,84,0.2); }
.badge-med  { background: rgba(232,133,74,0.15); color: var(--num-warn);     border: 1px solid rgba(232,133,74,0.2); }
.badge-easy { background: rgba(92,184,122,0.15); color: var(--num-positive); border: 1px solid rgba(92,184,122,0.2); }
/* ── DETAIL PANEL ────────────────────────────────────────────── */
.detail-panel {
  overflow-y: auto;
  padding: 28px 36px;
  min-height: 0;
  scrollbar-width: thin;
  scrollbar-color: var(--text-dim) transparent;
}

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--text-secondary);
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  gap: 12px;
}

.empty-icon { font-size: 36px; opacity: 0.7; }

/* ── DETAIL HEADER ───────────────────────────────────────────── */
.detail-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 28px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border);
}

.detail-code {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 26px;
  font-weight: 500;
  letter-spacing: 0.1em;
  color: var(--accent);
}

.detail-year {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  color: var(--text-secondary);
  letter-spacing: 0.15em;
  text-transform: uppercase;
  margin-top: 5px;
}

/* ── STAT CARDS ──────────────────────────────────────────────── */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 28px;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  min-height: 110px;
  transition: border-color 0.2s, background 0.25s;
}

.stat-card:hover { border-color: var(--border-accent); }

/* ── SPARKLINE ROW ─────────────────────────────────────────── */
.sparkline-card {
  padding: 14px 16px 12px;
  margin-bottom: 24px;
}

.sparkline-wrap {
  margin-top: 6px;
  width: 100%;
  overflow: hidden;
}

.stat-label {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 10px;
  color: var(--text-secondary);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  margin-bottom: 8px;
}

.stat-value {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 24px;
  font-weight: 500;
  line-height: 1;
}

.stat-sub {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 10px;
  color: var(--text-dim);
  margin-top: 5px;
  letter-spacing: 0.06em;
}
html[data-theme="light"] .stat-sub { color: var(--text-secondary); }

/* Value color utilities */
.val-res    { color: var(--color-res); }
.val-nonres { color: var(--color-nonres); }
.val-good   { color: var(--num-positive); }
.val-warn   { color: var(--num-warn); }
.val-bad    { color: var(--num-danger); }
.val-na     { color: var(--text-dim); font-size: 16px; }

/* ── SECTION TITLE ───────────────────────────────────────────── */
.section-title {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--text-secondary);
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.section-title::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* ── CHART ───────────────────────────────────────────────────── */
.chart-wrap {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 20px;
  transition: background 0.25s ease;
}

.chart-legend {
  display: flex;
  gap: 16px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 10px;
  color: var(--text-secondary);
  letter-spacing: 0.06em;
}

.legend-dot { width: 8px; height: 8px; border-radius: 2px; }

.chart-canvas-wrap { position: relative; width: 100%; height: 200px; }
canvas {
  display: block;
  width: 100%;
  max-width: 100%;
  height: auto;
}

/* ── PREFERENCE TABLE ────────────────────────────────────────── */
.pref-table {
  width: 100%;
  border-collapse: collapse;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 12px;
  margin-bottom: 32px;
}

.pref-table th {
  text-align: left;
  padding: 9px 12px;
  border-bottom: 1px solid var(--border);
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-dim);
  font-weight: 400;
}

.pref-table td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--table-sep);
}

.pref-table tr:hover td { background: var(--bg-hover); }
.pref-table tr.is-min-pref td { background: rgba(212, 168, 67, 0.06); }
.pref-table tr.is-min-pref td:first-child { border-left: 2px solid var(--accent); }

.draw-rate-bar { display: flex; align-items: center; gap: 8px; }
.bar-track { flex: 1; height: 4px; background: var(--border); border-radius: 2px; overflow: hidden; max-width: 80px; }
.bar-fill-res { height: 100%; background: var(--color-res); border-radius: 2px; transition: width 0.4s; }

.tag-drawn { color: var(--num-positive); }
.tag-zero  { color: var(--text-dim); }
.tag-min   { color: var(--accent); font-weight: 500; }

/* ── YOUR ODDS TOOL ──────────────────────────────────────────── */
.odds-tool {
  background: var(--bg-card);
  border: 1px solid var(--border-accent);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 28px;
  transition: background 0.25s ease;
}

.odds-tool-header {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 14px;
}

.odds-result {
  background: var(--bg-surface);
  border-radius: 6px;
  padding: 14px 18px;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}

.odds-stat { text-align: center; }

.odds-stat-val {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 22px;
  font-weight: 500;
}

.odds-stat-label {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 10px;
  color: var(--text-dim);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin-top: 4px;
}

/* ── SITE FOOTER ─────────────────────────────────────────────── */
.site-footer {
  position: relative;
  z-index: 10;
  padding: 14px 28px;
  border-top: 1px solid var(--border);
  background: var(--bg-footer);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  transition: background 0.25s ease;
}

.site-footer p {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 10px;
  color: var(--text-dim);
  letter-spacing: 0.06em;
}

.site-footer a {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 10px;
  color: var(--text-secondary);
  text-decoration: none;
  letter-spacing: 0.08em;
  white-space: nowrap;
  border-bottom: 1px solid var(--border);
  transition: color 0.2s;
}

.site-footer a:hover { color: var(--text-primary); }

.site-footer-link-button {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 10px;
  color: var(--text-secondary);
  text-decoration: none;
  letter-spacing: 0.08em;
  white-space: nowrap;
  border: none;
  border-bottom: 1px solid var(--border);
  background: none;
  padding: 0;
  cursor: pointer;
  transition: color 0.2s;
}

.site-footer-link-button:hover { color: var(--text-primary); }

/* ── SPARKLINE HOVER TOOLTIP ─────────────────────────────────── */
.spark-tip {
  display: none;
  position: fixed;
  background: var(--spark-tip-bg);
  color: var(--spark-tip-val);
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  letter-spacing: 0.05em;
  padding: 6px 10px;
  border-radius: 5px;
  border: 1px solid var(--spark-tip-border);
  pointer-events: none;
  z-index: 5000;
  white-space: nowrap;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5);
}

/* ── TREND POPUP ─────────────────────────────────────────────── */
.trend-popup {
  background-color: var(--popup-bg) !important;
  color: var(--popup-color) !important;
  border: 1px solid var(--popup-border) !important;
}

.trend-popup strong {
  color: var(--popup-val) !important;
}

/* ── QUOTA TOTALS ────────────────────────────────────────────── */
.quota-totals {
  display: flex;
  align-items: center;
  gap: 5px;
  margin-left: 6px;
}

.quota-stat {
  display: flex;
  align-items: center;
  gap: 4px;
}

.quota-stat-label {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 10px;
  color: var(--text-dim);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.quota-stat-val {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.04em;
}

.quota-divider {
  color: var(--text-dim);
  font-size: 10px;
  opacity: 0.3;
  margin: 0 2px;
}

.quota-total-sub {
  font-size: 0.75em;
  opacity: 0.5;
  margin-top: 4px;
  border-top: 1px solid var(--quota-sub-sep);
  padding-top: 2px;
}

/* ── FILTER SELECT ───────────────────────────────────────────── */
.filter-select {
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%234a4a60'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 28px;
  cursor: pointer;
  min-width: 180px;
}

.filter-select option,
.filter-select optgroup {
  background: var(--bg-dropdown);
  color: var(--text-primary);
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
}

/* ── FILTER INDICATOR ── */
.filter-active {
  border-color: var(--accent) !important;
  box-shadow: 0 0 0 2px var(--accent-glow);
}

/* Light mode: border alone disappears on mid-tone surfaces —
   add an amber background tint so the active state is unmissable */
html[data-theme="light"] .filter-active {
  background: rgba(184, 135, 44, 0.16) !important;
  border-color: #b8872c !important;
  box-shadow: 0 0 0 2px rgba(184, 135, 44, 0.22);
}

/* Light mode ✕ — pill background so it reads against the tan bar */
html[data-theme="light"] .filter-reset-btn-outer {
  background: rgba(192, 48, 48, 0.12);
  border-radius: 3px;
  padding: 1px 5px;
}

/* Hide browser native clear button on search inputs */
input[type="search"]::-webkit-search-cancel-button { display: none; }
input[type="search"]::-webkit-search-decoration     { display: none; }

/* ── SCROLLBARS ──────────────────────────────────────────────── */
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--text-dim); border-radius: 2px; }

/* ── ANIMATIONS ──────────────────────────────────────────────── */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.detail-panel > * { animation: fadeUp 0.22s ease forwards; }

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }
}

/* ── RESPONSIVE ──────────────────────────────────────────────── */
@media (max-width: 768px) {
  header { padding: 16px 16px 14px; }
  .header-brand-main { font-size: 1.7rem; }
  .header-brand-sub { font-size: 0.6rem; letter-spacing: 0.18em; }
  .header-left h1 { font-size: 15px; }

  .controls { padding: 10px 16px; gap: 8px; }
  .dash-nav { padding: 0 12px; }
  .dash-nav-context { align-items: flex-start; padding: 8px 0 4px; }
  .dash-nav-context-title { text-align: left; }
  .dash-nav-utils { gap: 8px; justify-content: flex-end; }
  .search-wrap { max-width: 100%; flex: 1 1 100%; }
  .results-count { display: none; }
  .header-coffee { display: none; }

  .main-layout {
    grid-template-columns: 1fr;
    height: auto;
    min-height: calc(100dvh - 105px);
  }

  .list-panel {
    border-right: none;
    min-height: calc(100dvh - 105px);
  }

  .list-panel.hidden { display: none; }

  .detail-panel {
    display: none;
    padding: 20px 16px;
    min-height: calc(100dvh - 105px);
    overflow-x: hidden;
    width: 100%;
    box-sizing: border-box;
  }

  .detail-panel.active { display: block; }

  .mobile-back { display: none; }

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

  .detail-code { font-size: 20px; }

  .quota-totals {
    display: flex;
    width: 100%;
    margin-left: 0;
    gap: 8px;
    flex-wrap: wrap;
    align-items: center;
  }
}

.col-short { display: none; }

@media (max-width: 480px) {
  .stat-value { font-size: 20px; }
  .filter-group .filter-label { display: none; }
  .odds-result { grid-template-columns: repeat(2, 1fr); gap: 6px; }
  .odds-stat-val { font-size: 18px; }
  .pref-table th,
  .pref-table td { padding: 6px 6px; font-size: 11px; }
  .bar-track { max-width: 40px; }
  .col-full { display: none; }
  .col-short { display: inline; }
}

/* ── FEEDBACK MODAL ──────────────────────────────────────────── */
#feedback-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.55);
  z-index: 9999;
  align-items: center;
  justify-content: center;
}

#feedback-overlay.visible { display: flex; }

#feedback-card {
  background: var(--bg-card);
  border: 1px solid rgba(74,158,255,0.25);
  border-radius: 10px;
  padding: 32px 36px;
  max-width: 460px;
  width: 90%;
  position: relative;
  box-shadow: 0 8px 40px rgba(0,0,0,0.4);
}

#feedback-close {
  position: absolute;
  top: 12px;
  right: 16px;
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 20px;
  cursor: pointer;
}

#feedback-close:hover { color: var(--text-primary); }

#feedback-heading {
  font-family: 'Syne', sans-serif;
  font-size: 17px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 6px;
}

#feedback-sub {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 10px;
  color: var(--text-secondary);
  letter-spacing: 0.08em;
  margin-bottom: 20px;
}

.fb-label {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 10px;
  color: var(--text-secondary);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  display: block;
  margin-bottom: 6px;
}

.fb-input,
.fb-select,
.fb-textarea {
  width: 100%;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  color: var(--text-primary);
  font-family: 'IBM Plex Mono', monospace;
  font-size: 12px;
  padding: 9px 12px;
  border-radius: 6px;
  outline: none;
  margin-bottom: 14px;
  transition: border-color 0.2s, background 0.25s;
  box-sizing: border-box;
}

.fb-input:focus,
.fb-select:focus,
.fb-textarea:focus { border-color: rgba(74,158,255,0.4); }

.fb-textarea { resize: vertical; min-height: 90px; }
.fb-select   { appearance: none; cursor: pointer; }

#fb-submit {
  width: 100%;
  background: #4a9eff;
  color: #0a0a0f;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.08em;
  padding: 11px;
  border-radius: 6px;
  border: none;
  cursor: pointer;
  transition: opacity 0.2s;
}

#fb-submit:hover { opacity: 0.85; }

#fb-success {
  display: none;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 12px;
  color: var(--num-positive);
  text-align: center;
  padding: 20px 0 8px;
  letter-spacing: 0.06em;
}

/* ── FILTER RESET ✕ BUTTON ───────────────────────────────────── */
.filter-reset-btn-outer {
  background: none;
  border: none;
  color: var(--num-danger);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  padding: 0 3px;
  line-height: 1;
  opacity: 0.82;
  flex-shrink: 0;
  margin-left: 2px;
  transition: opacity 0.15s;
}

.filter-reset-btn-outer:hover { opacity: 1; }

/* ── BY UNIT RESET ALL BUTTON ────────────────────────────────── */
.unit-reset-all {
  display: none;
  align-items: center;
  gap: 5px;
  background: rgba(200, 60, 60, 0.1);
  border: 1px solid rgba(200, 60, 60, 0.35);
  color: var(--num-danger);
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  padding: 5px 10px;
  border-radius: var(--radius);
  letter-spacing: 0.04em;
  transition: background 0.15s, opacity 0.15s;
  white-space: nowrap;
}
.unit-reset-all.visible { display: flex; }
.unit-reset-all:hover { background: rgba(200, 60, 60, 0.2); }

/* ── BY UNIT MODE FILTER WRAPPER ─────────────────────────────── */
/* display:none by default — JS adds .active to switch to
   display:contents so the three filter-groups join the flex row  */
#unitModeFilters { display: none; }
#unitModeFilters.active { display: contents; }

/* ── IDENTITY GATE ── */
#identity-gate {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  z-index: 9999;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(4px);
}
.gate-card {
  background: var(--bg-card);
  border: 1px solid var(--border-accent);
  border-radius: 14px;
  padding: 40px 36px;
  max-width: 420px;
  width: 90%;
  text-align: center;
  box-shadow: 0 24px 60px rgba(0,0,0,0.5);
}
.gate-logo {
  font-family: 'Syne', sans-serif;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.18em;
  color: var(--accent);
  margin-bottom: 18px;
}
.gate-title {
  font-family: 'Syne', sans-serif;
  font-size: 22px;
  font-weight: 800;
  line-height: 1.3;
  color: var(--text-primary);
  margin-bottom: 8px;
  letter-spacing: -0.01em;
}
.gate-sub {
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.7;
  margin-bottom: 28px;
  letter-spacing: 0.02em;
}
.gate-btn-primary {
  display: block;
  width: 100%;
  padding: 13px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-family: 'Syne', sans-serif;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.06em;
  cursor: pointer;
  margin-bottom: 10px;
  transition: opacity 0.15s;
}
.gate-btn-primary:hover { opacity: 0.88; }
.gate-btn-secondary {
  display: block;
  width: 100%;
  padding: 11px;
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  letter-spacing: 0.04em;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
}
.gate-btn-secondary:hover { border-color: var(--accent); color: var(--accent); }
.gate-input {
  display: block;
  width: 100%;
  box-sizing: border-box;
  padding: 11px 14px;
  margin-bottom: 10px;
  background: var(--bg-page);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 12px;
  letter-spacing: 0.04em;
  outline: none;
  transition: border-color 0.15s;
}
.gate-input:focus { border-color: var(--accent); }
.gate-input::placeholder { color: var(--text-dim); }
.gate-inline-actions {
  display: flex;
  justify-content: flex-end;
  margin: -2px 0 10px;
}
.gate-msg {
  margin-top: 12px;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  color: var(--text-secondary);
  letter-spacing: 0.04em;
  min-height: 16px;
  text-align: center;
}
.gate-toggle {
  margin-top: 16px;
  font-size: 12px;
  color: var(--text-dim);
  text-align: center;
}
.gate-link-btn {
  background: none;
  border: none;
  color: var(--accent);
  font-size: 12px;
  cursor: pointer;
  padding: 0 0 0 4px;
  text-decoration: underline;
}
