:root {
  --bg: #0a0c10; --bg-2: #0e1116; --card: #161a22; --card-2: #1d222c; --raised: #222834;
  --line: #262c38; --text: #eef1f7; --muted: #8b93a3; --faint: #5b6373;
  --accent: #f5c518; --accent-deep: #e0a800; --accent-ink: #1a1500; --danger: #ef5a6b; --warn: #ffd23f;
  --radius: 16px; --shadow: 0 8px 24px rgba(0,0,0,.35);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background:
    radial-gradient(900px 380px at 50% -120px, rgba(245,197,24,.10), transparent 70%),
    var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  display: flex; flex-direction: column; min-height: 100vh;
}

.app-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 18px; position: sticky; top: 0; z-index: 5;
  background: rgba(10,12,16,.82); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; }
/* FlashBox LED wordmark (built in app.js) — matches the shop. */
.brand .led-logo { height: 26px; width: auto; display: block;
  filter: drop-shadow(0 0 2px rgba(245,197,24,.45)); }
.env {
  font-size: 11px; color: var(--muted); border: 1px solid var(--line);
  padding: 4px 9px; border-radius: 999px; background: var(--bg-2);
}
.env.ok { color: var(--accent); border-color: rgba(245,197,24,.4); }
.env.bad { color: var(--danger); border-color: rgba(239,90,107,.4); }

.head-right { display: flex; align-items: center; gap: 8px; }
/* Signed-in identity, top-right beside sign-out (Home no longer carries it). */
.who { color: var(--muted); font-size: 13px; max-width: 22ch;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.app-header .signout {
  width: auto; margin: 0; padding: 4px 11px; font-size: 11px; font-weight: 700;
  border-radius: 999px; background: transparent; color: var(--muted);
  border: 1px solid var(--line); box-shadow: none; cursor: pointer;
}
.app-header .signout:hover { color: var(--danger); border-color: rgba(239,90,107,.4); }

.view { flex: 1; padding: 18px 16px 26px; max-width: 640px; width: 100%; margin: 0 auto; }
/* Admin is full-bleed (tables + fleet lists want the whole width). */
.view.view-wide { max-width: none; }

/* Desktop header navigation — hidden on phones (the tab bar serves there). */
.top-nav { display: none; flex: 1; margin: 0 18px; gap: 4px; }
.top-nav a {
  color: var(--muted); text-decoration: none; font-size: 13.5px; font-weight: 650;
  padding: 7px 13px; border-radius: 999px;
}
.top-nav a:hover { color: var(--text); background: var(--bg-2); }
.top-nav a.active { color: var(--accent); background: rgba(245,197,24,.10); }

.tabbar {
  display: flex; background: rgba(10,12,16,.9); backdrop-filter: blur(8px);
  border-top: 1px solid var(--line); position: sticky; bottom: 0;
}

/* ---- Desktop / laptop layout (the default styles above are mobile-first) ---- */
@media (min-width: 820px) {
  .top-nav { display: flex; }
  .tabbar { display: none; }
  .view { max-width: 1080px; padding: 26px 28px 40px; }
  .view.view-wide { max-width: none; padding: 26px 32px 40px; }
  /* Card collections flow into two columns; cards keep their own height. */
  .grid {
    display: grid; grid-template-columns: 1fr 1fr; gap: 14px; align-items: start;
  }
  .grid .card { margin-bottom: 0; }
  /* Forms shouldn't sprawl: the auth card stays a centred column. */
  .card.auth { max-width: 440px; margin: 24px auto 0; }
  h1 { font-size: 28px; }
}
.tabbar a {
  flex: 1; text-align: center; padding: 11px 0 13px; color: var(--muted);
  text-decoration: none; font-size: 11px; font-weight: 600;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
}
.tabbar a .ic { font-size: 17px; line-height: 1; }
.tabbar a.active { color: var(--accent); }

.card {
  background: linear-gradient(180deg, rgba(255,255,255,.02), transparent), var(--card);
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px; margin-bottom: 14px; box-shadow: var(--shadow);
}
h1 { font-size: 24px; font-weight: 760; letter-spacing: -.2px; margin: 6px 2px 16px; }
h2 { font-size: 15px; font-weight: 680; margin: 0 0 8px; }
p { line-height: 1.5; color: var(--text); margin: 0 0 4px; }
.muted { color: var(--muted); font-size: 14px; line-height: 1.5; }

label { display: block; margin: 14px 0 6px; font-size: 11px; font-weight: 700;
  letter-spacing: .7px; text-transform: uppercase; color: var(--faint); }
input, select, button, textarea {
  width: 100%; padding: 13px 14px; font-size: 16px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--bg-2); color: var(--text);
  outline: none; transition: border-color .15s, box-shadow .15s;
}
input::placeholder, textarea::placeholder { color: var(--faint); }
textarea { font-family: inherit; resize: vertical; line-height: 1.4; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(245,197,24,.18); }
button {
  border: 0; font-weight: 700; font-size: 15px; cursor: pointer; color: var(--accent-ink);
  background: linear-gradient(135deg, var(--accent), var(--accent-deep));
  box-shadow: 0 4px 14px rgba(245,197,24,.28); margin-top: 16px;
}
button.secondary {
  background: transparent; color: var(--text); border: 1px solid var(--line); box-shadow: none;
}
button:disabled { opacity: .55; cursor: default; box-shadow: none; }
button + button { margin-top: 10px; }

.row { display: flex; gap: 10px; align-items: stretch; }
.row > * { flex: 1; min-width: 0; }
/* A button sharing a row sizes to its label (not 100%), so the input fills. */
.row button { flex: 0 0 auto; width: auto; margin-top: 0; padding: 13px 20px; }

.steps { display: flex; gap: 6px; margin-bottom: 16px; }
.step { flex: 1; height: 4px; border-radius: 2px; background: #2b2e38; }
.step.done { background: var(--accent); }
.step.active { background: var(--accent-deep); }

.msg { margin-top: 12px; font-size: 14px; min-height: 18px; }
.msg.ok { color: var(--accent); }
.msg.bad { color: var(--danger); }
.msg.warn { color: var(--warn); }

.pill { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px;
  border-radius: 999px; font-size: 12px; font-weight: 700; }
.pill.active { background: rgba(245,197,24,.15); color: var(--accent); }
.pill.active::before { content: ""; width: 6px; height: 6px; border-radius: 50%;
  background: var(--accent); box-shadow: 0 0 8px var(--accent); }
.pill.inactive { background: rgba(239,90,107,.15); color: var(--danger); }

/* Box card */
.box-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.box-head .name { font-size: 17px; font-weight: 720; }
.box-head .spacer { flex: 1; }

.keychip { display: flex; align-items: center; gap: 8px; margin-top: 10px;
  background: var(--bg-2); border: 1px solid var(--line); border-radius: 10px; padding: 8px 11px; }
.keychip code { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12.5px;
  color: var(--muted); flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.keychip .copy { color: var(--faint); font-size: 13px; cursor: pointer; flex: 0 0 auto; }
.keychip .copy:hover { color: var(--accent); }
.box-actions { margin-top: 12px; display: flex; gap: 8px; justify-content: flex-end; }
.box-actions button { font-size: 13px; padding: 6px 12px; margin-top: 0; width: auto; }
.box-actions .remove-box:hover { border-color: var(--danger); color: var(--danger); }
/* The device key is support-only detail — folded away, not in the user's face. */
.box-details { margin-top: 10px; }
.box-details summary { cursor: pointer; font-size: 13px; }
.box-details .keychip { margin-top: 8px; }

/* News-ticker sport checkboxes. */
.checks { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.checks .check {
  display: inline-flex; align-items: center; gap: 7px; margin: 0;
  padding: 9px 13px; border: 1px solid var(--line); border-radius: 999px;
  background: var(--bg-2); font-size: 13.5px; font-weight: 600; color: var(--text);
  text-transform: none; letter-spacing: 0; cursor: pointer;
}
.checks .check:has(input:checked) { border-color: var(--accent); color: var(--accent); }
.checks input { width: auto; margin: 0; padding: 0; accent-color: var(--accent); }

/* Admin stats strip. */
.stats { display: flex; gap: 10px; }
.stats .stat { flex: 1; text-align: center; padding: 8px 4px; }
.stats .n { font-size: 19px; font-weight: 800; color: var(--accent); }
.stats .l { font-size: 11px; color: var(--muted); margin-top: 2px; }
/* Admin side-menu layout (GAMES-51). */
.admin-layout { display: block; }
.admin-side { display: flex; gap: 6px; overflow-x: auto; margin-bottom: 14px; }
.admin-side a { flex: 0 0 auto; cursor: pointer; color: var(--muted); text-decoration: none;
  font-size: 13.5px; font-weight: 650; padding: 8px 14px; border-radius: 999px;
  border: 1px solid var(--line); white-space: nowrap; }
.admin-side a:hover { color: var(--text); }
.admin-side a.active { color: var(--accent-ink); background: var(--accent); border-color: var(--accent); }
@media (min-width: 820px) {
  .admin-layout { display: grid; grid-template-columns: 190px 1fr; gap: 18px; align-items: start; }
  .admin-side { flex-direction: column; overflow: visible; margin-bottom: 0; position: sticky; top: 78px; }
  .admin-side a { text-align: left; }
}
.admin-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.admin-table th { text-align: left; color: var(--faint); font-weight: 700; text-transform: uppercase;
  font-size: 11px; letter-spacing: .5px; padding: 6px 10px; border-bottom: 1px solid var(--line); }
.admin-table td { padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.admin-table tr:last-child td { border-bottom: 0; }
.admin-table td.mono { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12px; color: var(--muted); }
.dot-status { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; vertical-align: middle; }
.dot-status.on { background: var(--accent); box-shadow: 0 0 6px var(--accent); }
.dot-status.off { background: var(--faint); }
/* Per-box extra-league grants (GAMES-53). */
.lg-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 12px; }
.lg-chip { display: inline-flex; align-items: center; gap: 6px; padding: 3px 6px 3px 10px;
  border-radius: 999px; font-size: 12.5px; background: rgba(245,197,24,.15); color: var(--accent); }
.lg-chip .lg-x { cursor: pointer; font-weight: 700; color: var(--muted); padding: 0 2px; }
.lg-chip .lg-x:hover { color: var(--danger); }
.lg-chip .lg-exp { font-size: 11px; color: var(--muted); padding-left: 2px; }
.lg-row .lg-add, .lg-row .lg-days { width: auto; margin: 0; padding: 6px 10px; font-size: 13px; }
.lg-grant .lg-days { color: var(--muted); }

/* Admin dashboard (GAMES-47): connected-boxes + upstream-usage sparklines. */
.dash-row { display: flex; gap: 20px; flex-wrap: wrap; }
.dash-metric { flex: 1; min-width: 240px; }
.dash-metric .l { font-size: 12px; color: var(--muted); }
.dash-metric .n { font-size: 26px; font-weight: 800; color: var(--accent); margin: 2px 0; }
.spark-svg { width: 100%; height: 60px; display: block; margin: 4px 0; }
.spark-line { fill: none; stroke: var(--accent); stroke-width: 1.5; vector-effect: non-scaling-stroke; }
.spark-dot { fill: var(--accent); }
.spark-budget { stroke: var(--warn); stroke-width: 1; stroke-dasharray: 4 3; vector-effect: non-scaling-stroke; }

/* Request topology "pyramid" (GAMES-56): external feed → our API → boxes,
   with the call count crossing each boundary. */
.funnel-card { margin-top: 16px; }
.topo { position: relative; display: flex; flex-direction: column; align-items: center; margin: 4px 0; }
.topo::before { content: ""; position: absolute; top: 6px; bottom: 6px; left: 50%;
  width: 2px; background: var(--line); transform: translateX(-50%); }
.topo-node { position: relative; z-index: 1; min-width: 210px; text-align: center;
  padding: 10px 20px; border-radius: 10px; border: 1px solid var(--accent);
  background: rgba(245, 197, 24, .1); }
.topo-node-api { border-width: 2px; background: rgba(245, 197, 24, .18); }
.topo-title { font-weight: 800; color: var(--accent); font-size: 15px; }
.topo-sub { font-size: 11px; color: var(--muted); margin-top: 1px; }
.topo-edge { position: relative; z-index: 1; margin: 7px 0; padding: 5px 12px;
  background: var(--card); border-radius: 999px; font-size: 12.5px; color: var(--muted); text-align: center; }
.topo-count { font-weight: 800; color: var(--accent); font-size: 15px; }
.funnel-cap { margin: 10px 0 2px; }
.funnel-cap b { color: var(--accent); }

/* Daily box-request bar chart + 7/30d toggle (GAMES-56). */
.bar-svg { width: 100%; height: 130px; display: block; }
.bar { fill: var(--accent); }
.bar:hover { fill: var(--accent-deep); }
.bar-axis { display: flex; justify-content: space-between; font-size: 11px; color: var(--faint); margin-top: 4px; }
.bar-legend { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 8px; font-size: 11.5px; color: var(--muted); }
.ax-key { display: inline-flex; align-items: center; gap: 5px; }
.ax-sw { width: 10px; height: 10px; border-radius: 2px; display: inline-block; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.seg button { width: auto; margin: 0; padding: 4px 12px; font-size: 12px; font-weight: 700;
  background: transparent; color: var(--muted); border: 0; border-radius: 0; box-shadow: none; }
.seg button.on { background: var(--accent); color: var(--accent-ink); }

/* Free-features page: a row per feed with a real on/off SWITCH (GAMES-85).
   A plain "On"/"Off" button read as an instruction ("click On to turn on")
   rather than a state, so it's a sliding switch now — position and colour both
   show the state at a glance. */
.free-row { display: flex; align-items: center; gap: 12px; }
/* Rows now live INSIDE one card per section rather than each being its own card
   (GAMES-124), so the switches line up in a single right-hand column instead of
   drifting with each row's text width. .free-label takes the slack. */
.free-row { padding: 12px 0; border-bottom: 1px solid var(--line); }
.free-row:last-child { border-bottom: 0; }
.free-label { flex: 1 1 auto; min-width: 0; }
.free-row .switch { margin-left: auto; }
/* A sub-option of the row above it (Show seconds belongs to Clock): indented,
   and disabled until its parent is on, so it can't be set to do nothing. */
.free-row.nested { padding-left: 22px; border-left: 2px solid var(--line); }
.switch[disabled] { opacity: .45; cursor: not-allowed; }
/* Settings that belong to a section but aren't switches (ticker speed, timezone)
   sit below its rows, separated rather than floating in their own card. */
.sub-setting { margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--line); }
.sub-setting label { display: block; font-weight: 600; margin-bottom: 2px; }
.sub-setting select { margin-top: 6px; }
.switch { position: relative; flex: 0 0 auto; width: 52px; height: 30px; padding: 0;
  margin: 0; border-radius: 999px; border: 1px solid var(--line);
  background: var(--bg-2); box-shadow: none; cursor: pointer; transition: background .15s; }
.switch .knob { position: absolute; top: 3px; left: 3px; width: 22px; height: 22px;
  border-radius: 50%; background: var(--muted); transition: left .15s, background .15s; }
.switch.on { background: var(--accent); border-color: var(--accent); }
.switch.on .knob { left: 25px; background: var(--accent-ink); }
.switch:disabled { opacity: .6; }

/* Section divider on the home page (Settings below your FlashBoxes). */
.section-head { margin: 28px 0 10px; padding-top: 18px; border-top: 1px solid var(--line);
  font-size: 15px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }

/* Clickable user rows (GAMES-56). */
.admin-table tr.rowlink { cursor: pointer; }
.admin-table tr.rowlink:hover td { background: rgba(245, 197, 24, .1); }
.admin-table td.row-chev { text-align: right; color: var(--faint); font-size: 18px; width: 1%; padding-right: 12px; }
.admin-table tr.rowlink:hover td.row-chev { color: var(--accent); }
.price { font-weight: 800; color: var(--accent); font-size: 15px; white-space: nowrap; }

/* Active subscription row on the current-plan card. */
.sub-row { display: flex; align-items: center; gap: 12px; padding: 11px 0 0; }
.sub-row > div:first-child { flex: 1; min-width: 0; }
.sub-row + .sub-row { border-top: 1px solid var(--line); margin-top: 11px; }
.sub-row button { flex: 0 0 auto; width: auto; margin-top: 0; padding: 9px 14px; font-size: 13px; }
.muted.small { font-size: 12px; margin-top: 2px; }

/* Plan-card header: name + description left, price right (no box around it). */
.plan-head { display: flex; align-items: center; gap: 12px; margin-bottom: 6px; }
.plan-head .ti { flex: 1; }
.plan-head .tn { font-weight: 700; font-size: 16px; }
.plan-head .td { color: var(--muted); font-size: 13px; margin-top: 2px; }
.plan-head .price { font-weight: 800; color: var(--accent); font-size: 15px; white-space: nowrap; }

/* Launch-offer highlight on an eligible plan card. */
.card.offer { border-color: rgba(231,169,74,.55); box-shadow: 0 0 0 1px rgba(231,169,74,.35), var(--shadow); }
.pill.offer-pill { background: rgba(231,169,74,.18); color: var(--warn); font-size: 11px; }
.offer-line { color: var(--warn); font-size: 12.5px; font-weight: 700; margin: 10px 0 2px; }

.tier { display: flex; align-items: center; gap: 12px; padding: 14px;
  border: 1px solid var(--line); border-radius: 13px; margin-bottom: 10px; background: var(--bg-2); }
.tier.sel { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset; }
.tier .name, .tier .ti { flex: 1; }
.tier .tn { font-weight: 700; font-size: 15px; }
.tier .td { color: var(--muted); font-size: 12.5px; margin-top: 2px; }
.tier .price { font-weight: 800; color: var(--accent); font-size: 15px; white-space: nowrap; }

.fixture { display: flex; align-items: center; gap: 10px; padding: 10px 12px;
  background: var(--bg-2); border: 1px solid var(--line); border-radius: 11px;
  margin-bottom: 8px; font-variant-numeric: tabular-nums; }
.fixture .teams { flex: 1; font-size: 14px; font-weight: 600; }
.fixture .score { font-weight: 800; }
.fixture .meta { color: var(--muted); font-size: 12px; }

.code { font-family: ui-monospace, Menlo, Consolas, monospace; background: var(--bg-2);
  padding: 2px 6px; border-radius: 6px; font-size: 13px; border: 1px solid var(--line); }
a.link { color: var(--accent); font-weight: 600; text-decoration: none; }
a.link:hover { text-decoration: underline; }
ul.tight { margin: 8px 0; padding-left: 20px; color: var(--muted); }
ul.tight li { margin: 4px 0; }

/* Date/time layout picker (GAMES-125). Each option carries a real render of the
   panel, so the choice is made by looking rather than by reading. */
.dt-choice { display: flex; align-items: center; gap: 12px; padding: 10px 12px;
  margin-bottom: 8px; border: 1px solid var(--line); border-radius: 10px;
  cursor: pointer; background: var(--bg-2); }
.dt-choice.on { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.dt-choice input { flex: 0 0 auto; margin: 0; width: auto; }
.dt-text { display: flex; flex-direction: column; gap: 2px; flex: 1 1 auto; }
.dt-preview, .panel-preview { flex: 0 0 auto; width: 168px; height: 42px; border-radius: 4px;
  background: #0b0b0e; image-rendering: pixelated; }
/* Font samples get a true 2x panel (128x32 -> 256x64). At the 168px used for the
   date/time previews the letterforms are barely above 1:1 and the fonts are
   genuinely indistinguishable — Andy: "you cant tell". Choosing a typeface needs
   to show the typeface. */
.panel-preview { width: 256px; height: 64px; }
@media (max-width: 560px) {
  .dt-choice { flex-wrap: wrap; }
  .dt-preview, .panel-preview { width: 100%; height: auto; aspect-ratio: 4 / 1; }
}

/* "These settings apply to" (GAMES-129). Only rendered once an account has more
   than one box - with a single box there is nothing to choose. */
.applies-card { border-color: var(--accent); }
.applies-card label { display: block; font-weight: 600; margin-bottom: 6px; }
.applies-card select { margin-bottom: 6px; }
/* A plan pinned to boxes that no longer exist: paid for, showing nowhere.
   Surfaced rather than silently corrected (GAMES-130). */
.plan-warn { color: var(--warn); font-weight: 600; }
.plan-boxes { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.plan-boxes label { display: flex; align-items: center; gap: 6px; font-size: 13px;
  padding: 6px 10px; border: 1px solid var(--line); border-radius: 999px;
  cursor: pointer; }
.plan-boxes input { width: auto; margin: 0; }
