/* ==========================================================
   Stats LoL — Design Tokens & Base
   Aesthetic: data-dense pro, dark, neon accent
   ========================================================== */

:root {
  /* surfaces — true black foundation, raised levels for hierarchy */
  --bg-0: #07080a;
  --bg-1: #0c0e12;
  --bg-2: #11141a;
  --bg-3: #161a22;
  --bg-4: #1d2230;
  --bg-hover: #1a1f2a;

  /* borders */
  --border-subtle: rgba(255,255,255,0.04);
  --border: rgba(255,255,255,0.07);
  --border-strong: rgba(255,255,255,0.12);
  --border-accent: color-mix(in oklch, var(--accent) 40%, transparent);

  /* text */
  --text-primary: #f4f6fa;
  --text-secondary: #a8aebd;
  --text-muted: #6b7180;
  --text-faint: #4a4f5c;

  /* accent — neon cyan default, tweakable */
  --accent: #22e2ff;
  --accent-soft: color-mix(in oklch, var(--accent) 16%, transparent);
  --accent-glow: color-mix(in oklch, var(--accent) 28%, transparent);
  --accent-fg: #021015;

  /* semantic */
  --positive: #4ade80;
  --positive-soft: rgba(74,222,128,0.12);
  --negative: #f97369;
  --negative-soft: rgba(249,115,105,0.12);
  --warning: #ffb547;
  --warning-soft: rgba(255,181,71,0.12);

  /* role / lane colors */
  --role-top: #c69b6d;
  --role-jgl: #82c69b;
  --role-mid: #c98ac9;
  --role-bot: #f97369;
  --role-sup: #6db1f9;

  /* shadows */
  --shadow-sm: 0 1px 0 rgba(255,255,255,0.03) inset, 0 1px 2px rgba(0,0,0,0.4);
  --shadow-card: 0 1px 0 rgba(255,255,255,0.04) inset, 0 8px 24px rgba(0,0,0,0.4);
  --shadow-pop: 0 24px 60px -20px rgba(0,0,0,0.7), 0 0 0 1px var(--border);

  /* typography */
  --font-sans: 'Geist', -apple-system, system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', 'Geist Mono', ui-monospace, monospace;
  --font-display: 'Geist', sans-serif;

  /* radii */
  --r-xs: 4px;
  --r-sm: 6px;
  --r: 8px;
  --r-md: 10px;
  --r-lg: 14px;
  --r-xl: 20px;

  /* spacing scale (multiples of 4) */
  --s-1: 4px;
  --s-2: 8px;
  --s-3: 12px;
  --s-4: 16px;
  --s-5: 20px;
  --s-6: 24px;
  --s-8: 32px;
  --s-10: 40px;
  --s-12: 48px;
  --s-16: 64px;

  /* layout */
  --sidebar-w: 232px;
  --topbar-h: 56px;
}

/* density variants set on <html data-density> */
html[data-density="compact"] { --row-h: 36px; --pad-card: 18px; }
html[data-density="cozy"] { --row-h: 44px; --pad-card: 22px; }
html[data-density="comfortable"] { --row-h: 52px; --pad-card: 28px; }

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html {
  background: var(--bg-0);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  font-feature-settings: "ss01", "cv11";
}

body {
  background:
    radial-gradient(1100px 600px at 90% -10%, color-mix(in oklch, var(--accent) 6%, transparent), transparent 60%),
    radial-gradient(900px 600px at -10% 110%, rgba(255,115,105,0.04), transparent 60%),
    var(--bg-0);
  min-height: 100vh;
}

a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; padding: 0; }
input, textarea, select { font: inherit; color: inherit; }

/* utility primitives */
.mono { font-family: var(--font-mono); font-feature-settings: "tnum"; letter-spacing: -0.01em; }
.tnum { font-variant-numeric: tabular-nums; font-feature-settings: "tnum"; }
.eyebrow {
  font-family: var(--font-mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--text-muted);
  font-weight: 500;
}
.dot { width: 6px; height: 6px; border-radius: 50%; display: inline-block; }

/* ===== Layout shell ===== */
.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 100vh;
}

.sidebar {
  border-right: 1px solid var(--border-subtle);
  background: linear-gradient(180deg, var(--bg-1), var(--bg-0));
  padding: var(--s-5) var(--s-3);
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: var(--s-5);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 8px;
}
.brand-mark {
  width: 28px; height: 28px;
  border-radius: 7px;
  background: linear-gradient(135deg, var(--accent), color-mix(in oklch, var(--accent) 60%, #000));
  display: grid; place-items: center;
  color: var(--accent-fg);
  font-weight: 700;
  font-family: var(--font-mono);
  font-size: 13px;
  box-shadow: 0 0 0 1px var(--border-strong), 0 4px 14px var(--accent-glow);
}
.brand-name {
  font-weight: 600;
  font-size: 14px;
  letter-spacing: -0.01em;
}
.brand-sub {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.team-switcher {
  border: 1px solid var(--border);
  border-radius: var(--r);
  background: var(--bg-2);
  padding: 8px 10px;
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  transition: border-color .15s, background .15s;
}
.team-switcher:hover { border-color: var(--border-strong); background: var(--bg-3); }
.team-switcher-wrap { position: relative; }
.team-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  left: 0; right: 0;
  background: var(--bg-2);
  border: 1px solid var(--border-strong);
  border-radius: var(--r);
  padding: 4px;
  z-index: 200;
  display: none;
  box-shadow: 0 8px 24px rgba(0,0,0,.4);
}
.team-dropdown.open { display: block; }
.team-drop-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
  transition: background .12s;
  text-decoration: none;
}
.team-drop-item:hover { background: var(--bg-3); }
.team-drop-item.active { background: rgba(141,215,227,0.08); color: var(--primary); }
.team-drop-sep { height: 1px; background: var(--border); margin: 4px 0; }
.team-drop-create {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  transition: background .12s, color .12s;
  text-decoration: none;
}
.team-drop-create:hover { background: var(--bg-3); color: var(--primary); }
.team-avatar {
  width: 26px; height: 26px;
  border-radius: 6px;
  background: linear-gradient(135deg, #2a3142, #161a22);
  display: grid; place-items: center;
  color: var(--text-primary);
  font-weight: 700;
  font-size: 11px;
  border: 1px solid var(--border);
}
.team-meta { flex: 1; min-width: 0; }
.team-name { font-size: 13px; font-weight: 500; line-height: 1.2; }
.team-tag { font-size: 11px; color: var(--text-muted); font-family: var(--font-mono); }

.nav-section { display: flex; flex-direction: column; gap: 1px; }
.nav-label {
  font-family: var(--font-mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-faint);
  padding: 6px 10px 4px;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 10px;
  border-radius: var(--r-sm);
  color: var(--text-secondary);
  font-size: 13px;
  cursor: pointer;
  position: relative;
  transition: background .12s, color .12s;
}
.nav-item:hover { background: var(--bg-2); color: var(--text-primary); }
.nav-item.active {
  background: var(--bg-2);
  color: var(--text-primary);
}
.nav-item.active::before {
  content: "";
  position: absolute;
  left: 0; top: 7px; bottom: 7px;
  width: 2px;
  background: var(--accent);
  border-radius: 2px;
  box-shadow: 0 0 12px var(--accent-glow);
}
.nav-item .ic { width: 16px; height: 16px; opacity: 0.85; flex: none; }
.nav-item .kbd {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-faint);
  background: var(--bg-3);
  border: 1px solid var(--border);
  padding: 1px 5px;
  border-radius: 4px;
}
.nav-item .badge-pill {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 10px;
  background: var(--accent-soft);
  color: var(--accent);
  padding: 1px 6px;
  border-radius: 999px;
}

.sidebar-foot { margin-top: auto; display: flex; flex-direction: column; gap: 6px; }
.sidebar-user {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px;
  border-radius: var(--r-sm);
  border: 1px solid var(--border);
  background: var(--bg-2);
  overflow: hidden;
}
.sidebar-user .av {
  width: 26px; height: 26px; min-width: 26px; border-radius: 50%;
  background: linear-gradient(135deg, #5a6378, #2a3142);
  display: grid; place-items: center;
  font-size: 11px; font-weight: 600;
  border: 1px solid var(--border);
  flex-shrink: 0;
  background-size: cover; background-position: center;
}
.sidebar-user .who { font-size: 12px; line-height: 1.2; min-width: 0; flex: 1; overflow: hidden; }
.sidebar-user .who > div { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user .who small { color: var(--text-muted); font-family: var(--font-mono); font-size: 10px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block; }
.sidebar-user > a { flex-shrink: 0; }

/* ===== Top bar ===== */
.main { min-width: 0; }
.topbar {
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  gap: var(--s-3);
  padding: 0 var(--s-6);
  border-bottom: 1px solid var(--border-subtle);
  background: color-mix(in oklch, var(--bg-0) 80%, transparent);
  backdrop-filter: blur(8px);
  position: sticky; top: 0; z-index: 50;
}
.crumbs {
  display: flex; align-items: center; gap: 8px;
  font-size: 13px; color: var(--text-secondary);
}
.crumbs .sep { color: var(--text-faint); }
.crumbs .now { color: var(--text-primary); font-weight: 500; }

.searchbar {
  display: flex; align-items: center; gap: 8px;
  margin-left: auto;
  width: 320px;
  padding: 7px 10px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--r);
  color: var(--text-muted);
  font-size: 13px;
  cursor: text;
}
.searchbar:hover { border-color: var(--border-strong); }
.searchbar .kbd {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 10px;
  background: var(--bg-3);
  border: 1px solid var(--border);
  padding: 1px 5px;
  border-radius: 4px;
}

.iconbtn {
  width: 32px; height: 32px;
  display: grid; place-items: center;
  border-radius: var(--r-sm);
  color: var(--text-secondary);
  border: 1px solid transparent;
  transition: background .12s, border-color .12s, color .12s;
}
.iconbtn:hover { background: var(--bg-2); color: var(--text-primary); border-color: var(--border); }

/* ===== Page container ===== */
.page {
  padding: var(--s-6) var(--s-6) var(--s-12);
  max-width: 1480px;
  margin: 0 auto;
}
.page-head {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: var(--s-6);
  flex-wrap: wrap;
  margin-bottom: var(--s-6);
}
.page-title {
  font-size: 26px;
  font-weight: 600;
  letter-spacing: -0.02em;
  margin: 4px 0 0;
}
.page-sub { color: var(--text-muted); font-size: 13px; max-width: 60ch; margin-top: 6px; }

/* ===== Card ===== */
.card {
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  position: relative;
}
.card.flat { background: transparent; }
.card-h {
  display: flex; align-items: center; gap: var(--s-3);
  padding: 14px var(--s-5);
  border-bottom: 1px solid var(--border-subtle);
}
.card-title { font-size: 13px; font-weight: 500; }
.card-sub { color: var(--text-muted); font-size: 12px; margin-left: auto; font-family: var(--font-mono); }
.card-body { padding: var(--s-5); }
.card-body.tight { padding: var(--s-3) var(--s-5); }
.card-body.flush { padding: 0; }

/* ===== Buttons ===== */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 12px;
  border-radius: var(--r-sm);
  font-size: 13px;
  font-weight: 500;
  border: 1px solid var(--border);
  background: var(--bg-2);
  color: var(--text-primary);
  transition: background .12s, border-color .12s, color .12s, transform .06s;
}
.btn:hover { background: var(--bg-3); border-color: var(--border-strong); }
.btn:active { transform: translateY(1px); }
.btn.primary {
  background: var(--accent);
  color: var(--accent-fg);
  border-color: color-mix(in oklch, var(--accent) 80%, #000);
  box-shadow: 0 0 0 1px var(--border-accent), 0 6px 20px var(--accent-glow);
}
.btn.primary:hover { background: color-mix(in oklch, var(--accent) 92%, #fff); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--text-secondary); }
.btn.ghost:hover { background: var(--bg-2); color: var(--text-primary); }
.btn.sm { padding: 4px 9px; font-size: 12px; }
.btn.icon { padding: 7px; }

/* ===== Pills / badges / chips ===== */
.pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-family: var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  background: var(--bg-2);
  color: var(--text-secondary);
  border: 1px solid var(--border);
}
.pill.accent { background: var(--accent-soft); color: var(--accent); border-color: var(--border-accent); }
.pill.pos { background: var(--positive-soft); color: var(--positive); border-color: rgba(74,222,128,0.2); }
.pill.neg { background: var(--negative-soft); color: var(--negative); border-color: rgba(249,115,105,0.2); }
.pill.warn { background: var(--warning-soft); color: var(--warning); border-color: rgba(255,181,71,0.2); }

.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 10px;
  border-radius: var(--r-sm);
  font-size: 12px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  cursor: pointer;
  transition: background .12s, border-color .12s, color .12s;
}
.chip:hover { background: var(--bg-3); color: var(--text-primary); }
.chip.active {
  background: color-mix(in oklch, var(--accent) 14%, var(--bg-2));
  color: var(--accent);
  border-color: var(--border-accent);
}

/* ===== KPI tile ===== */
.kpi {
  padding: 16px 18px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--bg-1);
  display: flex; flex-direction: column; gap: 6px;
  position: relative;
  overflow: hidden;
}
.kpi .label {
  font-family: var(--font-mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-muted);
}
.kpi .value {
  font-family: var(--font-mono);
  font-size: 26px;
  font-weight: 500;
  letter-spacing: -0.02em;
  color: var(--text-primary);
}
.kpi .delta {
  font-family: var(--font-mono);
  font-size: 11px;
  display: inline-flex; gap: 4px; align-items: center;
}
.kpi .delta.pos { color: var(--positive); }
.kpi .delta.neg { color: var(--negative); }
.kpi .accent-bar {
  position: absolute; left: 0; bottom: 0; right: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--accent), transparent);
  opacity: 0.8;
}

/* ===== Table ===== */
.table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 13px;
}
.table th {
  font-family: var(--font-mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  font-weight: 500;
  text-align: left;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border-subtle);
  background: var(--bg-1);
  position: sticky; top: 0;
}
.table td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--border-subtle);
  vertical-align: middle;
}
.table tr:hover td { background: var(--bg-hover); }
.table tr:last-child td { border-bottom: 0; }
.table .num { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.table .muted { color: var(--text-muted); }

/* ===== Sparkline / chart helpers ===== */
.spark { display: block; width: 100%; height: 32px; }
.bar-track {
  height: 6px; border-radius: 999px; background: var(--bg-3); overflow: hidden;
}
.bar-fill { height: 100%; border-radius: 999px; background: var(--accent); }
.bar-fill.pos { background: var(--positive); }
.bar-fill.neg { background: var(--negative); }

/* ===== Champion tile ===== */
.champ {
  display: flex; align-items: center; gap: 8px;
}
.champ-icon {
  width: 28px; height: 28px;
  border-radius: 6px;
  background: var(--bg-3);
  border: 1px solid var(--border);
  background-size: cover;
  background-position: center;
  flex: none;
  position: relative;
  overflow: hidden;
}
.champ-icon.lg { width: 40px; height: 40px; border-radius: 8px; }
.champ-icon.sm { width: 22px; height: 22px; border-radius: 5px; }
.champ-name { font-size: 13px; }

/* ===== Lane tag ===== */
.lane {
  display: inline-flex; align-items: center; justify-content: center;
  width: 22px; height: 22px;
  border-radius: 5px;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  background: var(--bg-3);
  border: 1px solid var(--border);
}
.lane.top { color: var(--role-top); }
.lane.jgl { color: var(--role-jgl); }
.lane.mid { color: var(--role-mid); }
.lane.bot { color: var(--role-bot); }
.lane.sup { color: var(--role-sup); }

/* ===== Result chip ===== */
.result {
  display: inline-grid; place-items: center;
  width: 26px; height: 26px;
  border-radius: 6px;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
}
.result.v { background: var(--positive-soft); color: var(--positive); border: 1px solid rgba(74,222,128,0.2); }
.result.d { background: var(--negative-soft); color: var(--negative); border: 1px solid rgba(249,115,105,0.2); }

/* ===== Inputs ===== */
.input {
  width: 100%;
  padding: 9px 12px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  color: var(--text-primary);
  font-size: 13px;
  outline: none;
  transition: border-color .12s, box-shadow .12s;
}
.input:focus {
  border-color: var(--border-accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.input::placeholder { color: var(--text-faint); }

.field { display: flex; flex-direction: column; gap: 6px; }
.field label {
  font-family: var(--font-mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
}

/* ===== Misc ===== */
.divider { height: 1px; background: var(--border-subtle); margin: var(--s-3) 0; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s-4); }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--s-4); }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--s-4); }
.grid-5 { display: grid; grid-template-columns: repeat(5, 1fr); gap: var(--s-4); }
.grid-6 { display: grid; grid-template-columns: repeat(6, 1fr); gap: var(--s-4); }

/* Allow grid items to actually shrink — prevents wide SVG/canvas content
   from forcing tracks past their 1fr share and overflowing the page */
.grid-2 > *, .grid-3 > *, .grid-4 > *, .grid-5 > *, .grid-6 > * { min-width: 0; }

.row { display: flex; align-items: center; gap: var(--s-3); }
.col { display: flex; flex-direction: column; gap: var(--s-3); }
.gap-2 { gap: var(--s-2); }
.gap-3 { gap: var(--s-3); }
.gap-4 { gap: var(--s-4); }
.gap-5 { gap: var(--s-5); }
.gap-6 { gap: var(--s-6); }
.flex-1 { flex: 1; }
.center { display: grid; place-items: center; }

/* tier colors for champool */
.tier-SSS { color: #ffd66e; }
.tier-S { color: #ff7a59; }
.tier-A { color: #4ade80; }
.tier-B { color: #6db1f9; }
.tier-C { color: #a8aebd; }
.tier-Refus, .tier-X { color: var(--negative); }

/* tier row */
.tier-row {
  display: grid;
  grid-template-columns: 70px 1fr;
  align-items: stretch;
  border: 1px solid var(--border);
  border-radius: var(--r);
  background: var(--bg-1);
}
.tier-row + .tier-row { margin-top: 8px; }
.tier-letter {
  display: grid; place-items: center;
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 18px;
  border-right: 1px solid var(--border-subtle);
  background: var(--bg-2);
  border-radius: var(--r) 0 0 var(--r);
}
.tier-list {
  display: flex; flex-wrap: wrap; gap: 8px;
  padding: 10px 14px;
}

/* radar wrapper */
.radar-card { aspect-ratio: 1.05/1; }

/* hover lift */
.lift { transition: transform .15s, border-color .15s; }
.lift:hover { transform: translateY(-1px); border-color: var(--border-strong); }

/* page transitions */
.page-enter {
  animation: fadeUp .24s ease both;
}
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* scrollbar */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--bg-3); border-radius: 999px; border: 2px solid var(--bg-0); }
::-webkit-scrollbar-thumb:hover { background: var(--bg-4); }

/* selection */
::selection { background: var(--accent-soft); color: var(--text-primary); }

/* ===== Mobile / responsive ===== */
.menu-btn { display: none; }
.mobile-only { display: none; }

@media (max-width: 1100px) {
  .grid-6 { grid-template-columns: repeat(3, 1fr); }
  .grid-5 { grid-template-columns: repeat(3, 1fr); }
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .page > div[style*="grid-template-columns: 1.6fr"] { grid-template-columns: 1fr !important; }
  .page > div[style*="grid-template-columns: 1.4fr"] { grid-template-columns: 1fr !important; }
  .page > div[style*="grid-template-columns: 220px"] { grid-template-columns: 1fr !important; }
  .radar-card { aspect-ratio: 1.2/1; }
}

@media (max-width: 760px) {
  :root { --sidebar-w: 0px; }
  .app { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; top: 0; left: 0; bottom: 0;
    width: 280px; height: 100vh; z-index: 200;
    transform: translateX(-100%);
    transition: transform .25s ease;
    box-shadow: 24px 0 60px rgba(0,0,0,.6);
  }
  body.nav-open .sidebar { transform: translateX(0); }
  body.nav-open::after {
    content: ""; position: fixed; inset: 0; z-index: 150;
    background: rgba(0,0,0,.6); backdrop-filter: blur(2px);
  }
  .menu-btn { display: grid; }
  .searchbar { display: none; }
  .topbar { padding: 0 14px; gap: 10px; }
  .crumbs { font-size: 12px; }
  .crumbs > :not(.now):not(.sep) { display: none; }
  .crumbs > .sep:first-of-type { display: none; }

  .page { padding: 18px 14px 60px; }
  .page-head { flex-direction: column; align-items: stretch; gap: 12px; }
  .page-title { font-size: 22px; }
  .page-sub { font-size: 12px; }

  .grid-6, .grid-5, .grid-4, .grid-3 { grid-template-columns: repeat(2, 1fr); }
  .grid-2 { grid-template-columns: 1fr; }

  /* Stat page filter chips wrap better */
  .row { flex-wrap: wrap; }

  /* Tables → horizontal scroll */
  .card-body.flush, .card { overflow-x: auto; }
  .table { min-width: 540px; }

  /* Match row in Parties */
  .page .col > div[style*="border: 1px solid var(--border)"] > .row:first-child {
    flex-wrap: wrap;
    gap: 8px !important;
  }

  /* Pricing — single column on mobile */
  .page .grid-3 { grid-template-columns: 1fr; }

  /* Settings rows stack */
  .page div[style*="grid-template-columns: 240px 1fr auto"] {
    grid-template-columns: 1fr !important;
  }

  /* KPIs slimmer */
  .kpi { padding: 12px 14px; }
  .kpi .value { font-size: 22px; }

  /* Tier list */
  .tier-row { grid-template-columns: 56px 1fr; }
  .tier-list { padding: 8px; gap: 6px; }

  /* Tweaks panel narrower */
  .tweaks-panel { width: calc(100vw - 32px) !important; max-width: 360px; }
}

@media (max-width: 480px) {
  .grid-6, .grid-5, .grid-4, .grid-3, .grid-2 { grid-template-columns: 1fr; }
  .page-title { font-size: 20px; }
  .nav-item .kbd { display: none; }
}

/* tweak: high contrast */
html[data-contrast="high"] {
  --text-primary: #ffffff;
  --text-secondary: #c8cdd9;
  --border: rgba(255,255,255,0.12);
  --border-strong: rgba(255,255,255,0.22);
}

/* ===== Auth / legacy compat ===== */
.auth-wrapper { max-width: 480px; margin: 80px auto; padding: 0 20px; }
.auth-card { background: var(--bg-1); border: 1px solid var(--border); border-radius: var(--r-lg); padding: 32px; }
.auth-hero { text-align: center; margin-bottom: 32px; }
.match-btn { display: inline-flex; align-items: center; gap: 6px; padding: 9px 16px; border-radius: var(--r-sm); border: 1px solid var(--border-accent); background: var(--accent-soft); color: var(--accent); font-size: 13px; font-weight: 500; cursor: pointer; transition: background .12s; text-decoration: none; }
.match-btn:hover { background: color-mix(in oklch, var(--accent) 22%, transparent); }
.form-group { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.form-group label { font-family: var(--font-mono); font-size: 10px; text-transform: uppercase; letter-spacing: .1em; color: var(--text-muted); }
.form-group input { padding: 9px 12px; background: var(--bg-2); border: 1px solid var(--border); border-radius: var(--r-sm); color: var(--text-primary); font-size: 13px; outline: none; transition: border-color .12s, box-shadow .12s; width: 100%; box-sizing: border-box; }
.form-group input:focus { border-color: var(--border-accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.btn-primary { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 9px 16px; border-radius: var(--r-sm); background: var(--accent); color: var(--accent-fg); font-size: 13px; font-weight: 600; border: none; cursor: pointer; width: 100%; transition: background .12s; }
.btn-primary:hover { background: color-mix(in oklch, var(--accent) 90%, #fff); }
.btn-ghost { display: inline-flex; align-items: center; gap: 6px; padding: 9px 16px; border-radius: var(--r-sm); background: transparent; border: 1px solid var(--border); color: var(--text-secondary); font-size: 13px; cursor: pointer; transition: background .12s; }
.btn-ghost:hover { background: var(--bg-2); color: var(--text-primary); }
.data-table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13px; }
.data-table th { font-family: var(--font-mono); font-size: 10px; text-transform: uppercase; letter-spacing: .1em; color: var(--text-muted); font-weight: 500; text-align: left; padding: 10px 14px; border-bottom: 1px solid var(--border-subtle); }
.data-table td { padding: 11px 14px; border-bottom: 1px solid var(--border-subtle); vertical-align: middle; }
.data-table tr:hover td { background: var(--bg-hover); }
.data-table tr:last-child td { border-bottom: 0; }
.muted { color: var(--text-muted); }
/* Legacy hero (pages non refaites) */
.hero { padding: 40px 24px 24px; max-width: 1200px; margin: 0 auto; display: flex; gap: 24px; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; }
.hero-content { flex: 1; min-width: 280px; }
.hero-content h1 { font-size: 26px; font-weight: 600; letter-spacing: -0.02em; margin: 4px 0 0; }
.hero-content .subtitle { color: var(--text-muted); font-size: 13px; margin-top: 6px; }
.hero-content .tag { font-family: var(--font-mono); font-size: 10px; text-transform: uppercase; letter-spacing: .14em; color: var(--text-muted); }
.hero-panel { background: var(--bg-1); border: 1px solid var(--border); border-radius: var(--r-lg); padding: 20px; min-width: 220px; }
.hero-panel-inner h2 { font-size: 14px; font-weight: 600; margin: 0 0 12px; }
.hero-panel-inner ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.hero-panel-inner li { display: flex; justify-content: space-between; align-items: center; font-size: 13px; }
.hero-panel-inner .label { color: var(--text-muted); font-size: 12px; }
.card { background: var(--bg-1); border: 1px solid var(--border); border-radius: var(--r-md); }
.card-header { display: flex; align-items: center; justify-content: space-between; padding: 14px 20px; border-bottom: 1px solid var(--border-subtle); font-size: 13px; font-weight: 500; }
/* Pricing legacy */
.btn-primary-pricing { display: inline-flex; align-items: center; justify-content: center; padding: 10px 20px; border-radius: var(--r-sm); background: var(--accent); color: var(--accent-fg); font-size: 13px; font-weight: 600; border: none; cursor: pointer; width: 100%; transition: background .12s; text-decoration: none; }
.btn-primary-pricing:hover { background: color-mix(in oklch, var(--accent) 90%, #fff); }
.btn-primary-pricing:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-ghost-pricing { display: inline-flex; align-items: center; justify-content: center; padding: 10px 20px; border-radius: var(--r-sm); background: transparent; border: 1px solid var(--border); color: var(--text-secondary); font-size: 13px; cursor: pointer; width: 100%; transition: background .12s; text-decoration: none; }
.btn-ghost-pricing:hover { background: var(--bg-2); }
.billing-toggle, .pricing-toggle { display: flex; gap: 4px; background: var(--bg-2); border: 1px solid var(--border); border-radius: var(--r-sm); padding: 4px; margin-bottom: 20px; }
.billing-toggle button, .pricing-toggle button { flex: 1; padding: 6px 12px; border-radius: 4px; font-size: 12px; font-weight: 500; color: var(--text-secondary); border: none; background: transparent; cursor: pointer; transition: all .12s; }
.billing-toggle button.active, .pricing-toggle button.active { background: var(--bg-3); color: var(--text-primary); border: 1px solid var(--border); }
.discount-badge { display: inline-flex; padding: 2px 6px; border-radius: 999px; font-size: 10px; font-family: var(--font-mono); background: var(--positive-soft); color: var(--positive); border: 1px solid rgba(74,222,128,.2); }
