/**
 * Phase 15 Step 4b (AB2): admin's own layout/component classes, themed
 * ENTIRELY through packages/ui's `--cb-*` tokens (loaded first, via
 * `/static/ui/ui.css` - see Layout.tsx's <head>) - no color, radius, or
 * font value is ever hardcoded here. This file owns STRUCTURE (the
 * sidebar/topbar/tabbar shell, card/table/form layout) - what a value
 * actually IS comes from tokens.css, so a future palette change there
 * propagates here for free.
 *
 * AB1: every value that's genuinely per-request (a progress-bar fill
 * width, a cohort-heatmap cell's retention intensity) is expressed as
 * one of a bounded, pre-generated set of classes below (rounded to the
 * nearest 5% for bars, nearest 10% for heatmap cells) - never an inline
 * `style=""` attribute. This is what lets the CSP drop 'unsafe-inline'
 * from style-src entirely (see app.ts / ADMIN-SECURITY.md's Step 4b
 * section) while still rendering a value that's different on every
 * request.
 */

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--cb-bg-gradient) var(--cb-bg);
  color: var(--cb-text);
  font-family: var(--cb-font, 'Manrope', system-ui, sans-serif);
  font-size: 14px;
  font-variant-numeric: tabular-nums;
}

a { color: var(--cb-cyan); text-decoration: none; }
a:hover { color: var(--cb-cyan-hi); }
button, input, textarea, select { font-family: inherit; }
input::placeholder, textarea::placeholder { color: var(--cb-text-label); }
::-webkit-scrollbar { width: 0; height: 0; }
* { scrollbar-width: none; }

h1 { font-size: 22px; font-weight: 800; letter-spacing: -0.01em; margin: 0; }
h2 { font-size: 14px; font-weight: 800; margin: 0; }
h3 { font-size: 13px; font-weight: 700; margin: 0; color: var(--cb-text-secondary); }

/* ---------------------------------------------------------------- */
/* Shell: sidebar (desktop) / topbar + tabbar (mobile)               */
/* ---------------------------------------------------------------- */

.shell { display: flex; min-height: 100vh; }

.sidebar {
  width: 232px;
  flex: none;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 22px 14px 18px;
  border-right: 1px solid var(--cb-border-weak);
  background: var(--cb-bg);
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}
.sidebar__logo { height: 24px; width: auto; align-self: flex-start; margin: 0 8px; display: block; }
.sidebar__kicker { font-size: 10px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--cb-text-label); font-weight: 700; margin: 8px 8px 16px; }
.sidebar__nav { display: flex; flex-direction: column; gap: 4px; }
.sidebar__nav--secondary { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--cb-border-weak); }
.sidebar__foot { margin-top: auto; display: flex; flex-direction: column; gap: 10px; }

.nav-item {
  display: flex; align-items: center; gap: 10px;
  min-height: var(--cb-tap-min); padding: 0 12px;
  border-radius: var(--cb-r-md);
  border: 1px solid transparent;
  background: transparent;
  color: var(--cb-text-secondary);
  font-size: 14px; font-weight: 700;
  cursor: pointer; text-align: left;
}
.nav-item svg { flex: none; }
.nav-item.active {
  background: rgba(var(--cb-cyan-rgb), 0.12);
  border-color: rgba(var(--cb-cyan-rgb), 0.45);
  color: var(--cb-cyan);
  box-shadow: 0 0 18px rgba(var(--cb-cyan-rgb), 0.25);
}
.nav-item:hover:not(.active) { color: var(--cb-text); }

.status-pill { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-radius: var(--cb-r-md); background: var(--cb-surface-2); border: 1px solid var(--cb-border-weak); font-size: 12px; color: var(--cb-text-secondary); }
.dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.dot--ok { background: var(--cb-green); box-shadow: 0 0 8px rgba(var(--cb-green-rgb), 0.8); }
.dot--warn { background: var(--cb-orange); box-shadow: 0 0 8px rgba(var(--cb-orange-rgb), 0.6); }
.dot--bad { background: var(--cb-red); box-shadow: 0 0 8px rgba(var(--cb-red-rgb), 0.7); }
.dot--sm { width: 6px; height: 6px; }

.avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--cb-cyan-gradient); display: grid; place-items: center; font-size: 12px; font-weight: 800; color: #062330; flex: none; }
.who-row { display: flex; align-items: center; gap: 10px; padding: 0 4px; }
.who-row__name { flex: 1; min-width: 0; line-height: 1.2; }
.who-row__name .name { font-size: 13px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.who-row__name .role { font-size: 11px; color: var(--cb-text-secondary); }
.icon-btn { width: 32px; height: 32px; border: 0; background: transparent; color: var(--cb-text-secondary); display: grid; place-items: center; cursor: pointer; border-radius: var(--cb-r-sm); }
.icon-btn:hover { color: var(--cb-text); }

.topbar {
  display: none;
  align-items: center; justify-content: space-between;
  padding: 14px 16px 8px;
}
.topbar__logo { height: 22px; width: auto; display: block; }
.topbar__who { display: flex; align-items: center; gap: 8px; }
.topbar__kicker { font-size: 10px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--cb-text-label); font-weight: 700; }

.main-col { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.content { flex: 1; padding: 20px 24px 40px; }
.content__inner { max-width: 1120px; display: flex; flex-direction: column; gap: 16px; }

.tabbar {
  display: none;
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  padding: 8px 12px 14px;
  background: rgba(11, 22, 34, 0.96);
  border-top: 1px solid var(--cb-border-weak);
}
.tabbar__track { display: flex; gap: 4px; padding: 5px; border-radius: var(--cb-r-xl); background: var(--cb-surface-2); border: 1px solid var(--cb-border-weak); }
.tabbar .nav-item { flex: 1; min-height: 50px; border-radius: var(--cb-r-md); flex-direction: column; justify-content: center; gap: 3px; font-size: 10px; }

/* ---------------------------------------------------------------- */
/* Page header + stat grid                                          */
/* ---------------------------------------------------------------- */

.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.page-head__sub { font-size: 12px; color: var(--cb-text-secondary); margin-top: 2px; }
.live-badge { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--cb-text-secondary); }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 10px; }
.stat-card { padding: 14px 16px; border-radius: var(--cb-r-xl); background: var(--cb-surface-1); border: 1px solid var(--cb-border-weak); box-shadow: inset 0 1px 0 var(--cb-border-top-highlight); }
.stat-card__label { font-size: 11px; color: var(--cb-text-secondary); display: flex; align-items: center; gap: 6px; }
.stat-card__value { font-size: 28px; font-weight: 800; letter-spacing: -0.02em; line-height: 1.1; margin-top: 4px; }
.stat-card__value--cyan { color: var(--cb-cyan); text-shadow: 0 0 14px rgba(var(--cb-cyan-rgb), 0.4); }
.stat-card__note { font-size: 12px; color: var(--cb-text-secondary); margin-top: 4px; }
.stat-card__note--up { color: var(--cb-green); font-weight: 700; }

/* ---------------------------------------------------------------- */
/* Cards / tiles / sections                                         */
/* ---------------------------------------------------------------- */

.card { padding: 16px; border-radius: var(--cb-r-xl); background: var(--cb-surface-1); border: 1px solid var(--cb-border-weak); box-shadow: inset 0 1px 0 var(--cb-border-top-highlight); }
.card--pad-sm { padding: 12px 14px; }
.card__head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 10px; flex-wrap: wrap; }
.card__head-note { font-size: 11px; color: var(--cb-text-secondary); }
.card-link { font-size: 12px; font-weight: 700; }
.card-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(360px, 1fr)); gap: 12px; }
.card-grid--sm { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }

.tile { padding: 10px 12px; border-radius: var(--cb-r-md); background: var(--cb-surface-2); border: 1px solid var(--cb-border-weak); }
.tile-grid { display: grid; gap: 8px; }
.tile-grid--2 { grid-template-columns: 1fr 1fr; }
.tile-grid--3 { grid-template-columns: repeat(3, 1fr); }
.tile__label { font-size: 11px; color: var(--cb-text-secondary); display: flex; align-items: center; gap: 6px; }
.tile__value { font-size: 20px; font-weight: 800; margin-top: 2px; }
.tile__value--md { font-size: 15px; }
.tile__value--lg { font-size: 24px; }
.tile__sub { font-size: 11px; color: var(--cb-text-secondary); margin-top: 2px; }

.section { display: flex; flex-direction: column; gap: 16px; }
.section--mt { margin-top: 6px; }
.stack-col { display: flex; flex-direction: column; gap: 12px; }

/* Small structural utility classes - named, not inline `style=` (AB1) -
   for one-off layout tweaks that don't warrant a whole new component. */
.identity-row { display: flex; flex-wrap: wrap; align-items: center; gap: 14px; }
.avatar--lg { width: 52px; height: 52px; font-size: 18px; }
.identity-name-block { flex: 1; min-width: 180px; }
.identity-worth { text-align: right; min-width: 150px; }
.mt-4 { margin-top: 4px; }
.mt-8 { margin-top: 8px; }
.mt-12 { margin-top: 12px; }
.mb-12 { margin-bottom: 12px; }
.row__key { flex: 2; }
.row__progress { width: 70px; }
.actions-head-title { font-size: 16px; font-weight: 800; }
.field--wide { min-width: 220px; }

/* ---------------------------------------------------------------- */
/* Rows (audit log, activity, orders, challenges)                   */
/* ---------------------------------------------------------------- */

.row-list { display: flex; flex-direction: column; }
.row { display: flex; align-items: center; gap: 12px; min-height: 40px; border-top: 1px solid var(--cb-border-weak); font-size: 13px; }
.row-list > .row:first-child { border-top: 0; }
.row--tall { min-height: 44px; }
.row__time { width: 54px; flex: none; font-size: 12px; color: var(--cb-text-secondary); }
.row__time--wide { width: 88px; }
.row__who { width: 26px; height: 26px; flex: none; border-radius: 50%; background: var(--cb-surface-2); border: 1px solid var(--cb-border-weak); display: grid; place-items: center; font-size: 11px; font-weight: 800; color: var(--cb-text-secondary); }
.row__text { flex: 1; min-width: 0; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row__amount { font-size: 12px; font-weight: 700; flex: none; }
.row__icon { width: 30px; height: 30px; flex: none; border-radius: var(--cb-r-sm); display: grid; place-items: center; font-size: 13px; font-weight: 800; }
.row__icon--round { width: 26px; height: 26px; border-radius: 50%; }

/* ---------------------------------------------------------------- */
/* Badges / pills / chips                                           */
/* ---------------------------------------------------------------- */

.badge { min-width: 44px; text-align: center; padding: 3px 8px; border-radius: var(--cb-r-pill); font-size: 11px; font-weight: 700; display: inline-block; }
.badge--ok { background: rgba(var(--cb-green-rgb), 0.14); color: var(--cb-green); }
.badge--bad { background: rgba(var(--cb-red-rgb), 0.14); color: var(--cb-red-text); }
.badge--warn { background: rgba(var(--cb-orange-rgb), 0.14); color: var(--cb-orange); }
.badge--neutral { background: rgba(255, 255, 255, 0.06); color: var(--cb-text-secondary); }
.badge--cyan { background: rgba(var(--cb-cyan-rgb), 0.12); color: var(--cb-cyan); }

.chip-row { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  min-height: 32px; padding: 0 12px; border-radius: var(--cb-r-pill);
  border: 1px solid var(--cb-border); background: transparent; color: var(--cb-text-secondary);
  font-size: 12px; font-weight: 700; cursor: pointer; display: inline-flex; align-items: center; gap: 8px;
}
.chip.active { border-color: rgba(var(--cb-cyan-rgb), 0.45); background: rgba(var(--cb-cyan-rgb), 0.12); color: var(--cb-cyan); }
.chip--stat { background: var(--cb-surface-2); border-color: var(--cb-border); cursor: default; }
.chip--stat b { color: var(--cb-text); }
.chip--stat span:last-child { color: var(--cb-text-label); }

/* ---------------------------------------------------------------- */
/* Buttons                                                          */
/* ---------------------------------------------------------------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 0 16px; border-radius: var(--cb-r-md);
  border: 1px solid var(--cb-border); background: var(--cb-surface-1); color: var(--cb-text);
  font-size: 14px; font-weight: 700; cursor: pointer; text-decoration: none;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { border: 0; color: #fff; background: var(--cb-cyan-gradient); box-shadow: 0 0 22px rgba(var(--cb-cyan-rgb), 0.45); }
.btn-danger { border: 0; color: #fff; background: linear-gradient(180deg, #ff6b6b, var(--cb-red) 60%, #c62828); box-shadow: 0 0 22px rgba(var(--cb-red-rgb), 0.35); }
.btn-secondary { background: var(--cb-surface-1); border-color: var(--cb-border); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--cb-text-secondary); }
.btn-block { width: 100%; }

/* Segmented control - a real link/radio group styled as tabs, never a
   JS-driven toggle. `n` (option count) is always a small, fixed value
   at each call site (2 or 3), so it's one of these two fixed classes -
   never an inline style, unlike packages/ui's own Segmented component. */
.segmented { display: grid; gap: 4px; padding: 4px; border-radius: var(--cb-r-lg); background: var(--cb-surface-2); border: 1px solid var(--cb-border-weak); }
.segmented--2 { grid-template-columns: 1fr 1fr; }
.segmented--3 { grid-template-columns: repeat(3, 1fr); }
.segmented--scroll { display: flex; overflow-x: auto; }
.segmented--scroll .segmented__option { flex: none; padding: 0 14px; }
.segmented__option {
  min-height: 38px; border: 0; border-radius: 11px; font-size: 13px; font-weight: 700; cursor: pointer;
  background: transparent; color: var(--cb-text-secondary); text-decoration: none;
  display: flex; align-items: center; justify-content: center;
}
.segmented__option.active { background: rgba(var(--cb-cyan-rgb), 0.14); color: var(--cb-cyan); }
.segmented__option--danger.active { background: rgba(var(--cb-red-rgb), 0.14); color: var(--cb-red-text); }

/* A form-submitted segmented pair (radio-hack, e.g. the action form's
   Add/Remove direction) - zero JS, the checked radio is what a real
   submit sends. */
.segmented-radio { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 4px; border-radius: var(--cb-r-lg); background: var(--cb-surface-2); border: 1px solid var(--cb-border-weak); }
.segmented-radio input { position: absolute; opacity: 0; pointer-events: none; }
.segmented-radio label { min-height: 38px; border-radius: 11px; font-size: 13px; font-weight: 700; cursor: pointer; display: flex; align-items: center; justify-content: center; color: var(--cb-text-secondary); }
.segmented-radio input:checked + label { background: rgba(var(--cb-cyan-rgb), 0.14); color: var(--cb-cyan); }
.segmented-radio input:focus-visible + label { outline: 2px solid var(--cb-cyan); outline-offset: 2px; }

/* ---------------------------------------------------------------- */
/* Forms                                                            */
/* ---------------------------------------------------------------- */

.field { display: flex; flex-direction: column; gap: 6px; }
.field__label { font-size: 11px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--cb-text-secondary); display: flex; justify-content: space-between; }
.field__label .required { color: var(--cb-red-text); text-transform: none; letter-spacing: normal; font-weight: 600; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

/* A blanket base style for every native form control, not just ones
   explicitly given the .input/.select/.textarea class - a handful of
   lower-traffic pages (blocklist, launch-reset, some analytics forms)
   use bare <input>/<select> elements, and those must never fall back to
   the browser's default (light-themed) chrome against this dark shell. */
input[type='text'], input[type='number'], input[type='date'], input[type='password'], input[type='email'], input:not([type]), textarea, select {
  box-sizing: border-box; min-height: 44px; padding: 0 12px;
  border-radius: var(--cb-r-md); border: 1px solid var(--cb-border); background: var(--cb-surface-2);
  color: var(--cb-text); font-size: 14px; font-weight: 600; outline: none;
}
textarea { padding: 10px 12px; line-height: 1.4; }
label { color: var(--cb-text-secondary); font-size: 13px; }
button:not(.nav-item):not(.icon-btn):not(.chip):not(.segmented__option):not(.link-button) {
  min-height: 44px; padding: 0 16px; border-radius: var(--cb-r-md);
  border: 1px solid var(--cb-border); background: var(--cb-surface-1); color: var(--cb-text);
  font-size: 14px; font-weight: 700; cursor: pointer;
}

.input, .textarea, .select {
  width: 100%; box-sizing: border-box; min-height: 46px; padding: 0 12px;
  border-radius: var(--cb-r-md); border: 1px solid var(--cb-border); background: var(--cb-surface-2);
  color: var(--cb-text); font-size: 15px; font-weight: 600; outline: none;
}
.textarea { min-height: 78px; padding: 12px; line-height: 1.4; resize: vertical; font-size: 14px; }
.input-group { display: flex; align-items: center; gap: 8px; min-height: 46px; padding: 0 12px; border-radius: var(--cb-r-md); border: 1px solid var(--cb-border); background: var(--cb-surface-2); }
.input-group .input { border: 0; background: transparent; min-height: auto; padding: 0; flex: 1; min-width: 0; }
.input-group__icon { width: 18px; height: 18px; flex: none; border-radius: 50%; display: grid; place-items: center; font-weight: 800; font-size: 11px; }
.input-group__icon--cash { background: var(--cb-orange); color: var(--cb-orange-fg); }
.input-group__icon--btc { background: var(--cb-btc-icon-mid); color: #fff; transform: rotate(-12deg); }

.search-bar { display: flex; align-items: center; gap: 10px; min-height: 46px; padding: 0 14px; border-radius: var(--cb-r-md); background: var(--cb-surface-2); border: 1px solid var(--cb-border); }
.search-bar input { flex: 1; min-width: 0; border: 0; background: transparent; color: var(--cb-text); font-size: 14px; font-weight: 600; outline: none; }
.search-bar svg { flex: none; color: var(--cb-text-secondary); }

.hint { color: var(--cb-text-secondary); font-size: 13px; }
.hint--warn { padding: 8px 12px; border-radius: var(--cb-r-md); background: rgba(var(--cb-orange-rgb), 0.1); border: 1px solid rgba(var(--cb-orange-rgb), 0.3); }
.cache-note { color: var(--cb-text-label); font-size: 12px; margin: 0; }
.note-box { padding: 14px 16px; border-radius: var(--cb-r-lg); background: var(--cb-surface-2); border: 1px solid var(--cb-border-weak); font-size: 13px; line-height: 1.5; color: var(--cb-text-secondary); }

.filter-bar, .range-form { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; }
.filter-bar .field, .range-form .field { min-width: 140px; }
.field--grow { flex: 2; min-width: 220px; }
.net-worth-line { display: flex; justify-content: space-between; }
.player-card__body { flex: 1; min-width: 0; }
.csv-link { font-size: 13px; }
.pager { display: flex; gap: 16px; margin-top: 8px; font-size: 13px; }
.filter-bar .actions, .range-form .actions { display: flex; gap: 8px; margin-left: auto; align-items: center; }
.action-form { display: flex; flex-wrap: wrap; gap: 8px; align-items: flex-end; padding: 10px 0; border-top: 1px solid var(--cb-border-weak); }
.action-form:first-of-type { border-top: none; }
.action-form .field { min-width: 140px; }
.action-form label.checkbox { flex-direction: row; align-items: center; gap: 8px; min-height: 44px; font-size: 13px; color: var(--cb-text-secondary); }

/* ---------------------------------------------------------------- */
/* Explanations (ZZ4/AB3 - copy.ts's content, this container)       */
/* ---------------------------------------------------------------- */

.action-explanation { display: flex; flex-direction: column; gap: 6px; padding: 14px 16px; border-radius: var(--cb-r-lg); background: var(--cb-surface-2); border: 1px solid var(--cb-border-weak); font-size: 13px; line-height: 1.5; color: var(--cb-text); }
.action-explanation p { margin: 0; }
.action-explanation__example, .action-explanation__does-not { color: var(--cb-text-secondary); font-size: 12px; }
.action-explanation strong { color: var(--cb-text); }

/* ---------------------------------------------------------------- */
/* Tables -> card lists on mobile (kv-table / audit-table /          */
/* player-table share one visual language)                          */
/* ---------------------------------------------------------------- */

.kv-table, .audit-table, .player-table { width: 100%; border-collapse: collapse; }
.kv-table th, .kv-table td, .audit-table th, .audit-table td, .player-table th, .player-table td {
  border-bottom: 1px solid var(--cb-border-weak); padding: 8px 12px; text-align: left; font-size: 13px;
}
.kv-table th { color: var(--cb-text-secondary); font-weight: 500; width: 220px; }
.audit-table th, .player-table th { color: var(--cb-text-secondary); font-weight: 700; font-size: 11px; letter-spacing: 0.06em; text-transform: uppercase; background: transparent; }
.player-table th a { color: inherit; text-decoration: none; }
.player-table th a:hover { text-decoration: underline; }
.player-table tr:hover td { background: rgba(255, 255, 255, 0.03); }
.table-scroll { overflow-x: auto; border-radius: var(--cb-r-xl); background: var(--cb-surface-1); border: 1px solid var(--cb-border-weak); }
.table-scroll table { border-radius: inherit; }
.nowrap { white-space: nowrap; }
.mobile-only { display: none; }
.desktop-only { display: block; }
.empty { text-align: center; color: var(--cb-text-secondary); padding: 24px; }
.cond-yes { color: var(--cb-green); font-weight: 600; }
.cond-no { color: var(--cb-text-secondary); }
.json-cell { margin: 0; white-space: pre-wrap; word-break: break-word; font-size: 12px; max-width: 220px; color: var(--cb-text-secondary); }

/* Player-card list (mobile players screen - the design's own card
   shape, distinct from the generic kv-table->card fallback below). */
.player-card-list { display: flex; flex-direction: column; gap: 8px; }
.player-card { padding: 12px 14px; border-radius: var(--cb-r-xl); background: var(--cb-surface-1); border: 1px solid var(--cb-border-weak); box-shadow: inset 0 1px 0 var(--cb-border-top-highlight); cursor: pointer; display: block; color: inherit; }
.player-card__top { display: flex; align-items: center; gap: 10px; }
.player-card__name { font-size: 15px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; min-width: 0; }
.player-card__meta { font-size: 11px; color: var(--cb-text-secondary); }
.player-card__worth-row { display: flex; justify-content: space-between; align-items: baseline; margin-top: 10px; }
.player-card__worth { font-size: 17px; font-weight: 800; }

/* ---------------------------------------------------------------- */
/* Bars (AB1: bucketed classes, never inline style)                 */
/* ---------------------------------------------------------------- */

.bar-track { height: 4px; display: flex; border-radius: var(--cb-r-pill); overflow: hidden; background: var(--cb-bg); }
.bar-track--lg { height: 8px; border-radius: var(--cb-r-pill); }
.bar-cash { background: var(--cb-cyan); }
.bar-btc { flex: 1; background: var(--cb-btc-icon-mid); }
.bar-progress { height: 100%; border-radius: var(--cb-r-pill); background: var(--cb-cyan-gradient); box-shadow: 0 0 12px rgba(var(--cb-cyan-rgb), 0.8); }

/* Generated: 21 width buckets, 0/5/10/.../100 - every percentage this
   app ever renders is rounded to the nearest one server-side (see
   render/bars.ts's `pctBucket`). */
.bar-w-0 { width: 0%; } .bar-w-5 { width: 5%; } .bar-w-10 { width: 10%; }
.bar-w-15 { width: 15%; } .bar-w-20 { width: 20%; } .bar-w-25 { width: 25%; }
.bar-w-30 { width: 30%; } .bar-w-35 { width: 35%; } .bar-w-40 { width: 40%; }
.bar-w-45 { width: 45%; } .bar-w-50 { width: 50%; } .bar-w-55 { width: 55%; }
.bar-w-60 { width: 60%; } .bar-w-65 { width: 65%; } .bar-w-70 { width: 70%; }
.bar-w-75 { width: 75%; } .bar-w-80 { width: 80%; } .bar-w-85 { width: 85%; }
.bar-w-90 { width: 90%; } .bar-w-95 { width: 95%; } .bar-w-100 { width: 100%; }

/* ---------------------------------------------------------------- */
/* Retention cohort heatmap (AB4) - 11 intensity buckets, 0/10/.../100,  */
/* a cyan-alpha ramp matching the design's own legend gradient. Cells    */
/* past 50% swap to dark text - the fill gets bright enough that white   */
/* text loses contrast (see render/analyticsRetention.ts's own bucketing). */
/* ---------------------------------------------------------------- */

.heat-cell { min-height: 40px; min-width: 0; border-radius: var(--cb-r-sm); display: grid; place-items: center; font-size: 12px; font-weight: 800; color: #fff; }
.heat-cell--na { background: transparent; border: 1px dashed var(--cb-border); color: var(--cb-text-label); }
.heat-0 { background: rgba(var(--cb-cyan-rgb), 0.06); }
.heat-10 { background: rgba(var(--cb-cyan-rgb), 0.15); }
.heat-20 { background: rgba(var(--cb-cyan-rgb), 0.24); }
.heat-30 { background: rgba(var(--cb-cyan-rgb), 0.33); }
.heat-40 { background: rgba(var(--cb-cyan-rgb), 0.42); }
.heat-50 { background: rgba(var(--cb-cyan-rgb), 0.51); color: var(--cb-bg); }
.heat-60 { background: rgba(var(--cb-cyan-rgb), 0.60); color: var(--cb-bg); }
.heat-70 { background: rgba(var(--cb-cyan-rgb), 0.69); color: var(--cb-bg); }
.heat-80 { background: rgba(var(--cb-cyan-rgb), 0.78); color: var(--cb-bg); }
.heat-90 { background: rgba(var(--cb-cyan-rgb), 0.87); color: var(--cb-bg); }
.heat-100 { background: rgba(var(--cb-cyan-rgb), 0.95); color: var(--cb-bg); }
.heat-legend { display: flex; align-items: center; gap: 8px; margin-top: 12px; font-size: 11px; color: var(--cb-text-secondary); }
.heat-legend__bar { flex: 1; max-width: 200px; height: 8px; border-radius: var(--cb-r-pill); background: linear-gradient(90deg, rgba(var(--cb-cyan-rgb), 0.06), rgba(var(--cb-cyan-rgb), 0.95)); }
.heat-legend__note { margin-left: auto; }

.cohort-grid { display: flex; flex-direction: column; gap: 4px; margin-top: 8px; }
.cohort-row { display: grid; grid-template-columns: 160px repeat(5, 1fr); gap: 4px; align-items: center; }
.cohort-row--head { font-size: 11px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--cb-text-secondary); }
.cohort-head { text-align: center; }
.cohort-label { min-width: 0; line-height: 1.2; }
.cohort-label__name { display: block; font-size: 13px; font-weight: 600; white-space: nowrap; }
.cohort-label__size { display: block; font-size: 11px; color: var(--cb-text-secondary); }

/* ---------------------------------------------------------------- */
/* Charts (line/area/bar - server-rendered SVG, colors as real SVG   */
/* attributes, never `style=`, so CSP's style-src never applies to   */
/* chart geometry at all)                                            */
/* ---------------------------------------------------------------- */

.chart-card { position: relative; margin-top: 14px; }
.chart-svg { width: 100%; height: 180px; display: block; border-radius: var(--cb-r-md); background: var(--cb-surface-2); }
.chart-bar { fill: var(--cb-cyan); }
.chart-line { stroke: var(--cb-cyan); }
.chart-area { fill: url(#adm-area); }
.chart-avg-line { stroke: var(--cb-text-secondary); }
.chart-dot { fill: var(--cb-cyan); }
.chart-tag { position: absolute; display: flex; align-items: center; gap: 6px; transform: translate(0, -50%); }
.chart-tag__value { padding: 3px 8px; border-radius: 6px; background: #fff; color: var(--cb-bg); font-size: 11px; font-weight: 800; }
.chart-tag__dot { width: 10px; height: 10px; border-radius: 50%; background: #fff; border: 2.5px solid var(--cb-cyan); box-sizing: border-box; }
.chart-axis { display: flex; justify-content: space-between; font-size: 11px; color: var(--cb-text-label); margin-top: 6px; }
.chart-legend { display: flex; gap: 14px; font-size: 11px; color: var(--cb-text-secondary); align-items: center; flex-wrap: wrap; }
.chart-legend__swatch { width: 14px; height: 3px; border-radius: 2px; background: var(--cb-cyan); display: inline-block; }
.chart-legend__dash { width: 14px; height: 0; border-top: 2px dashed var(--cb-text-secondary); display: inline-block; }

.headline { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.headline__value { font-size: 34px; font-weight: 800; letter-spacing: -0.02em; line-height: 1.1; margin-top: 4px; }
.headline__change { font-size: 14px; font-weight: 800; }
.headline__change--up { color: var(--cb-green); }
.headline__change--down { color: var(--cb-red-text); }
.headline__prior { font-size: 12px; color: var(--cb-text-secondary); }

/* ---------------------------------------------------------------- */
/* Login / unlock                                                    */
/* ---------------------------------------------------------------- */

.auth-screen { flex: 1; display: grid; place-items: center; padding: 24px; min-height: 100vh; }
.auth-card { width: 100%; max-width: 360px; display: flex; flex-direction: column; gap: 22px; }
.auth-brand { display: flex; flex-direction: column; align-items: center; gap: 12px; text-align: center; }
.auth-brand__logo { height: 30px; width: auto; display: block; }
.auth-brand__kicker { font-size: 11px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--cb-cyan); font-weight: 700; }
.auth-panel { padding: 20px; border-radius: var(--cb-r-xl); background: var(--cb-surface-1); border: 1px solid var(--cb-border-weak); box-shadow: inset 0 1px 0 var(--cb-border-top-highlight); display: flex; flex-direction: column; gap: 12px; }
.auth-panel h1 { font-size: 20px; }
.auth-panel .input { min-height: 48px; font-size: 15px; }
.auth-panel form { display: flex; flex-direction: column; gap: 6px; }
.auth-panel form .input, .auth-panel form .code-input { margin-bottom: 6px; }
.auth-cta { min-height: 50px; border: 0; border-radius: var(--cb-r-md); font-size: 16px; font-weight: 800; color: #fff; background: var(--cb-cyan-gradient); box-shadow: 0 0 22px rgba(var(--cb-cyan-rgb), 0.45); cursor: pointer; margin-top: 4px; }
.auth-note { font-size: 12px; color: var(--cb-text-secondary); text-align: center; line-height: 1.5; }
.auth-footnote { font-size: 11px; color: var(--cb-text-label); text-align: center; line-height: 1.5; }
.code-input { width: 100%; box-sizing: border-box; min-height: 64px; padding: 0 16px; border-radius: var(--cb-r-md); border: 1px solid var(--cb-border); background: var(--cb-surface-2); color: var(--cb-text); font-size: 28px; font-weight: 800; letter-spacing: 0.35em; text-align: center; outline: none; text-transform: uppercase; }
.auth-row { display: flex; justify-content: space-between; font-size: 12px; color: var(--cb-text-secondary); align-items: center; }
.link-button { background: none; border: none; color: var(--cb-cyan); cursor: pointer; font: inherit; font-weight: 700; padding: 0; }

/* ---------------------------------------------------------------- */
/* Action form: two-column form + live-preview, then confirm panel   */
/* ---------------------------------------------------------------- */

.action-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.action-head__icon { width: 40px; height: 40px; flex: none; border-radius: var(--cb-r-md); display: grid; place-items: center; background: rgba(var(--cb-cyan-rgb), 0.12); color: var(--cb-cyan); }
.action-head__title { font-size: 22px; font-weight: 800; letter-spacing: -0.01em; }
.action-head__for { font-size: 12px; color: var(--cb-text-secondary); }
.back-link { align-self: flex-start; display: inline-flex; align-items: center; gap: 6px; border: 0; background: transparent; color: var(--cb-text-secondary); font-size: 13px; font-weight: 700; cursor: pointer; padding: 0; min-height: 32px; }
.back-link:hover { color: var(--cb-text); }

.step-track { margin-left: auto; display: flex; gap: 6px; align-items: center; font-size: 11px; font-weight: 700; color: var(--cb-text-secondary); }
.step-dot { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; background: var(--cb-surface-2); color: var(--cb-text-secondary); }
.step-dot.active { background: rgba(var(--cb-cyan-rgb), 0.16); color: var(--cb-cyan); }
.step-sep { width: 18px; height: 1px; background: var(--cb-border-strong); }

.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 12px; align-items: start; }
.form-panel { display: flex; flex-direction: column; gap: 14px; }
.preview-panel {
  border: 1px solid rgba(var(--cb-cyan-rgb), 0.35);
  box-shadow: 0 0 24px rgba(var(--cb-cyan-rgb), 0.12), inset 0 1px 0 var(--cb-border-top-highlight);
  display: flex; flex-direction: column; gap: 12px;
}
.preview-panel__head { display: flex; justify-content: space-between; align-items: center; }
.preview-panel__kicker { font-size: 11px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--cb-cyan); }
.preview-row { padding: 12px 14px; border-radius: var(--cb-r-md); background: var(--cb-surface-2); border: 1px solid var(--cb-border-weak); }
.preview-row__label { font-size: 11px; color: var(--cb-text-secondary); }
.preview-row__values { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px; margin-top: 4px; font-size: 17px; font-weight: 800; }
.preview-row__before { color: var(--cb-text-secondary); }
.preview-row__arrow { color: var(--cb-text-label); }
.preview-row__delta { font-size: 13px; }
.preview-row__delta--up { color: var(--cb-green); }
.preview-row__delta--down { color: var(--cb-red-text); }
.preview-empty { padding: 14px; border-radius: var(--cb-r-md); border: 1px dashed var(--cb-border-strong); font-size: 13px; color: var(--cb-text-secondary); text-align: center; }
.preview-warning { padding: 10px 14px; border-radius: var(--cb-r-md); background: rgba(var(--cb-red-rgb), 0.1); border: 1px solid rgba(var(--cb-red-rgb), 0.3); color: var(--cb-red-text); font-size: 13px; font-weight: 600; }
.preview-total { display: flex; justify-content: space-between; font-size: 13px; padding-top: 4px; border-top: 1px solid var(--cb-border-weak); }
.preview-total b { font-weight: 800; }
.preview-ledger-note { font-size: 12px; color: var(--cb-text-secondary); }

.confirm-panel {
  border: 1px solid rgba(var(--cb-orange-rgb), 0.4);
  box-shadow: 0 0 24px rgba(var(--cb-orange-rgb), 0.1), inset 0 1px 0 var(--cb-border-top-highlight);
  display: flex; flex-direction: column; gap: 14px; max-width: 560px;
}
.confirm-panel--danger { border-color: rgba(var(--cb-red-rgb), 0.4); box-shadow: 0 0 24px rgba(var(--cb-red-rgb), 0.12), inset 0 1px 0 var(--cb-border-top-highlight); }
.confirm-panel__head { display: flex; align-items: center; gap: 10px; }
.confirm-panel__icon { width: 32px; height: 32px; flex: none; border-radius: 50%; background: rgba(var(--cb-orange-rgb), 0.16); color: var(--cb-orange); display: grid; place-items: center; font-weight: 800; font-size: 16px; }
.confirm-panel__title { font-size: 16px; font-weight: 800; }
.confirm-panel__reason { font-size: 13px; color: var(--cb-text-secondary); line-height: 1.5; padding: 0 2px; }
.confirm-panel__typed-label { font-size: 13px; color: var(--cb-text-secondary); margin-bottom: 8px; }
.confirm-actions { display: flex; gap: 10px; }
.confirm-actions .btn { flex: 1; }
.confirm-actions .btn-primary, .confirm-actions .btn-danger { flex: 1.4; }

.done-banner { padding: 18px; border-radius: var(--cb-r-xl); background: rgba(14, 36, 26, 0.96); border: 1px solid rgba(var(--cb-green-rgb), 0.5); box-shadow: 0 0 24px rgba(var(--cb-green-rgb), 0.25); display: flex; align-items: center; gap: 12px; max-width: 560px; }
.done-banner__icon { width: 32px; height: 32px; border-radius: 50%; background: var(--cb-green); color: #04210f; display: grid; place-items: center; font-weight: 800; flex: none; }
.done-banner__title { font-size: 15px; font-weight: 800; }
.done-banner__sub { font-size: 12px; color: #c9f5db; }
.done-banner .btn { margin-left: auto; }

.action-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 10px; }
.action-card {
  text-align: left; padding: 14px; border-radius: var(--cb-r-xl); background: var(--cb-surface-1);
  border: 1px solid var(--cb-border-weak); box-shadow: inset 0 1px 0 var(--cb-border-top-highlight);
  color: var(--cb-text); cursor: pointer; display: flex; gap: 12px; align-items: flex-start; min-height: 76px;
  text-decoration: none;
}
.action-card--danger { border-color: rgba(var(--cb-red-rgb), 0.35); }
.action-card__icon { width: 36px; height: 36px; flex: none; border-radius: var(--cb-r-md); display: grid; place-items: center; background: rgba(var(--cb-cyan-rgb), 0.12); color: var(--cb-cyan); }
.action-card--danger .action-card__icon { background: rgba(var(--cb-red-rgb), 0.14); color: var(--cb-red-text); }
.action-card__body { flex: 1; min-width: 0; line-height: 1.3; }
.action-card__title-row { display: flex; justify-content: space-between; gap: 8px; align-items: center; }
.action-card__name { font-size: 14px; font-weight: 800; }
.action-card__desc { display: block; font-size: 12px; color: var(--cb-text-secondary); margin-top: 3px; }
.action-card__flag { padding: 2px 7px; border-radius: var(--cb-r-pill); font-size: 10px; font-weight: 700; background: rgba(var(--cb-red-rgb), 0.14); color: var(--cb-red-text); }

/* ---------------------------------------------------------------- */
/* Mobile (AB2/AB5): sidebar -> topbar + bottom tabbar, per the       */
/* prototype's own breakpoint (its ResizeObserver checks               */
/* `width < 760`) - matched here exactly so the CSS switch lands at    */
/* the same width the design was built against.                       */
/* ---------------------------------------------------------------- */

@media (max-width: 759px) {
  .sidebar { display: none; }
  .topbar { display: flex; }
  .tabbar { display: block; }
  .content { padding: 16px 14px calc(90px + env(safe-area-inset-bottom, 0px)); }
  .mobile-only { display: block; }
  .desktop-only { display: none; }

  .form-grid, .card-grid, .card-grid--sm { grid-template-columns: 1fr; }
  .field-row { grid-template-columns: 1fr 1fr; }
  .tile-grid--3 { grid-template-columns: repeat(3, 1fr); }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }

  .input, .textarea, .select, .input-group, .search-bar { font-size: 16px; } /* stops iOS auto-zoom on focus */

  /* Tables become card lists - a kv-table row that's already <th>
     (label) + <td> (value) needs no extra markup; a wider data table's
     <td data-label="..."> supplies the label a hidden <thead> can no
     longer show. */
  .kv-table, .audit-table, .player-table { display: block; width: 100%; }
  .kv-table thead, .audit-table thead, .player-table thead { display: none; }
  .kv-table tbody, .audit-table tbody, .player-table tbody { display: block; }
  .kv-table tr, .audit-table tr, .player-table tr {
    display: block; border: 1px solid var(--cb-border-weak); border-radius: var(--cb-r-xl);
    margin-bottom: 10px; padding: 4px 12px; background: var(--cb-surface-1);
  }
  .kv-table th, .kv-table td, .audit-table th, .audit-table td, .player-table th, .player-table td {
    display: block; width: auto; border-bottom: none; padding: 6px 0; white-space: normal;
  }
  .kv-table td[data-label]::before, .audit-table td[data-label]::before, .player-table td[data-label]::before {
    content: attr(data-label) ": "; font-weight: 600; color: var(--cb-text-secondary);
  }
  .json-cell { max-width: 100%; }

  .filter-bar, .range-form, .action-form { flex-direction: column; align-items: stretch; }
  .filter-bar .field, .range-form .field, .action-form .field { width: 100%; min-width: 0; }
  .filter-bar .actions, .range-form .actions { margin-left: 0; width: 100%; flex-direction: column; }
  .filter-bar .actions .btn, .range-form .actions .btn { width: 100%; }

  .action-form .btn { width: 100%; }
  .confirm-actions { flex-direction: column; }
  .auth-card { max-width: 100%; }

  .step-track { display: none; }
}

