/* Burn Battle admin back office: shared look for admin.html, admin-devices.html,
   admin-reports.html, admin-flags.html (dashboard redesign 2026-11-22).
   Layout follows the owner's reference video (soft rounded cards, left sidebar,
   dark round icon buttons, Light/Dark toggle); colours come from the Burn Battle
   logo palette already used in css/site.css (violet podium, pink heart, teal base).
   Behaviour (theme, drawer, intro, count-up, skeletons, mini charts) lives in
   js/admin-shell.js; data and Firebase calls stay in js/admin-*.js. System fonts only. */

:root {
  color-scheme: light;
  --bg: #FAF9FE;
  --card: #F1EFFA;
  --card-2: #E9E6F7;
  --surface: #FFFFFF;
  --surface-2: #F7F6FC;
  --ink: #17152B;
  --ink-2: #47445F;
  --ink-3: #625F7C;
  --line: #E4E1F0;
  --line-strong: #CDC9E1;
  --accent: #6B4FE0;
  --accent-hover: #5A3DD2;
  --accent-ink: #FFFFFF;
  --accent-soft: #E7E1FD;
  --accent-text: #5236C9;
  --pink: #C72E5A;
  --pink-soft: #FCE8EF;
  --teal: #0F7462;
  --teal-soft: #DFF3EC;
  --amber: #7E5200;
  --amber-soft: #FFF0D3;
  --dot: #17152B;
  --dot-ink: #FFFFFF;
  --s1: #6B4FE0; --s2: #D63A66; --s3: #13806B; --s4: #3D7BC4; --s5: #C98A0B; --s6: #8E8AA8; --s-rest: #CDC9E1;
  --shadow: 0 1px 2px rgba(23, 21, 43, .04), 0 14px 34px -24px rgba(42, 38, 96, .35);
  --glow: 0 10px 26px -10px rgba(107, 79, 224, .65);
  --focus: #6B4FE0;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans", Roboto, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --r: 24px;
  --r-sm: 16px;
  --pad: 16px;
  --side-w: 252px;
  --ease: cubic-bezier(.2, .7, .2, 1);
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0C0B16;
  --card: #16142A;
  --card-2: #1D1A36;
  --surface: #201D3B;
  --surface-2: #1A1831;
  --ink: #EEEDF6;
  --ink-2: #CBC9DC;
  --ink-3: #A6A4BC;
  --line: rgba(255, 255, 255, .09);
  --line-strong: rgba(255, 255, 255, .2);
  --accent: #9B7DFF;
  --accent-hover: #B9A8FF;
  --accent-ink: #0C0B16;
  --accent-soft: rgba(155, 125, 255, .16);
  --accent-text: #B9A8FF;
  --pink: #FF6B91;
  --pink-soft: rgba(255, 107, 145, .14);
  --teal: #2CC4A4;
  --teal-soft: rgba(44, 196, 164, .14);
  --amber: #F2B84B;
  --amber-soft: rgba(242, 184, 75, .14);
  --dot: #EEEDF6;
  --dot-ink: #0C0B16;
  --s1: #9B7DFF; --s2: #FF6B91; --s3: #2CC4A4; --s4: #6AA8F0; --s5: #F2B84B; --s6: #8D8AA6; --s-rest: #3A3658;
  --shadow: 0 1px 0 rgba(255, 255, 255, .03) inset, 0 18px 40px -28px rgba(0, 0, 0, .9);
  --glow: 0 10px 28px -10px rgba(155, 125, 255, .55);
  --focus: #FFDF9E;
}
@media (min-width: 720px) { :root { --pad: 28px; } }
@media (min-width: 1100px) { :root { --pad: 36px; } }

/* ---------- Base ---------- */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; background: var(--bg); }
body { margin: 0; min-height: 100vh; background: var(--bg); color: var(--ink); font: 15px/1.55 var(--font);
  overflow-wrap: anywhere; -webkit-font-smoothing: antialiased; }
[hidden] { display: none !important; }
::selection { background: var(--accent-soft); color: var(--ink); }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 3px; border-radius: 8px; }
h1, h2, h3, h4 { margin: 0; line-height: 1.2; text-wrap: balance; }
p { margin: 0; }
small { font-size: max(12px, .78em); font-weight: 400; color: var(--ink-3); }
a { color: var(--accent-text); }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.muted { color: var(--ink-3); }
.error { color: var(--pink) !important; }
.mono { font-family: var(--mono); font-size: .86em; }
.ico { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.skip { position: absolute; left: 8px; top: -60px; z-index: 200; padding: 10px 14px; border-radius: 10px; background: var(--ink); color: var(--bg); font-weight: 700; }
.skip:focus { top: 8px; }

/* Cross-page fade (Chrome/Edge/Safari 18 cross-document view transitions; others ignore it). */
@view-transition { navigation: auto; }
.side { view-transition-name: bb-side; }

/* ---------- App frame ---------- */
.app { display: grid; grid-template-columns: var(--side-w) minmax(0, 1fr); min-height: 100vh; }
.main-col { min-width: 0; display: flex; flex-direction: column; }

/* Sidebar */
.side { position: sticky; top: 0; height: 100vh; height: 100dvh; overflow-y: auto; display: flex; flex-direction: column; gap: 22px;
  padding: 24px 16px 18px; background: var(--bg); border-right: 1px solid var(--line); z-index: 40; }
.side-brand { display: flex; align-items: center; gap: 11px; padding: 2px 8px; color: var(--ink); text-decoration: none; min-width: 0; }
.side-brand img { flex: none; border-radius: 10px; }
.side-brand-txt { font-weight: 750; font-size: 19px; letter-spacing: -.02em; line-height: 1.1; white-space: nowrap; }
.side-brand-txt small { display: block; margin-top: 2px; font-size: 12px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-3); }
.side-nav { display: grid; gap: 6px; }
.nav-item { position: relative; display: flex; align-items: center; gap: 12px; min-height: 50px; padding: 0 14px; border-radius: 999px;
  color: var(--ink-2); text-decoration: none; font-weight: 600; font-size: 15px; transition: background-color .18s ease-out, color .18s ease-out; }
.nav-item:hover { background: var(--card); color: var(--ink); }
.nav-lbl { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nav-item .chev { width: 16px; height: 16px; flex: none; opacity: 0; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.nav-item[aria-current="page"] { background: var(--accent); color: var(--accent-ink); box-shadow: var(--glow); }
.nav-item[aria-current="page"] .chev { opacity: 1; }
.badge { display: inline-grid; place-items: center; min-width: 22px; height: 22px; padding: 0 6px; border-radius: 999px; background: var(--accent);
  color: var(--accent-ink); font-size: 12px; font-weight: 700; font-style: normal; font-variant-numeric: tabular-nums; }
.nav-item[aria-current="page"] .badge { background: var(--accent-ink); color: var(--accent); }
body:not(.is-authed) .badge { display: none; }

.side-foot { margin-top: auto; display: grid; gap: 12px; }
.me { display: flex; align-items: center; gap: 11px; padding: 6px 8px; min-width: 0; }
.me-av { position: relative; flex: none; width: 42px; height: 42px; border-radius: 50%; display: grid; place-items: center;
  background: linear-gradient(135deg, #7A55FF, #FF6B91); color: #fff; font-weight: 700; font-size: 15px; letter-spacing: .02em; }
body.is-authed .me-av::after { content: ""; position: absolute; right: -1px; top: 0; width: 11px; height: 11px; border-radius: 50%;
  background: #2CC4A4; border: 2px solid var(--bg); }
.me-txt { display: grid; min-width: 0; line-height: 1.25; }
.me-name { font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.who { font-size: 12.5px; color: var(--ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.who:empty { display: none; }
.side-btn { appearance: none; display: flex; align-items: center; gap: 12px; min-height: 44px; padding: 0 14px; border: 1px solid var(--line-strong);
  border-radius: 999px; background: transparent; color: var(--ink-2); font: inherit; font-weight: 600; cursor: pointer; }
.side-btn .nav-lbl { text-align: left; }
.side-btn:hover { background: var(--card); color: var(--ink); }
.theme-seg { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 4px; border-radius: 999px; background: var(--card); }
.theme-seg button { appearance: none; display: inline-flex; align-items: center; justify-content: center; gap: 7px; min-height: 40px; border: 0;
  border-radius: 999px; background: transparent; color: var(--ink-2); font: inherit; font-weight: 600; font-size: 14px; cursor: pointer;
  transition: background-color .2s ease-out, color .2s ease-out; }
.theme-seg button .ico { width: 16px; height: 16px; }
.theme-seg button[aria-pressed="true"] { background: var(--dot); color: var(--dot-ink); }
.side-warn { padding: 0 8px; font-size: 12px; font-weight: 600; color: var(--pink); }

.scrim { position: fixed; inset: 0; z-index: 35; background: rgba(8, 7, 16, .45); }
.menu-btn { display: none !important; }

/* Rail: tablets (iPad portrait) */
@media (min-width: 720px) and (max-width: 1099px) {
  :root { --side-w: 84px; }
  .side { padding: 22px 12px 16px; align-items: center; }
  .side-brand { padding: 0; }
  .side-brand-txt, .nav-item .nav-lbl, .nav-item .chev, .me-txt, .theme-seg, .side-warn, .side-btn .nav-lbl { position: absolute; width: 1px; height: 1px;
    overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .side-nav { justify-items: center; }
  .nav-item { width: 52px; min-height: 52px; padding: 0; justify-content: center; }
  .badge { position: absolute; top: 2px; right: 0; min-width: 19px; height: 19px; font-size: 11px; padding: 0 5px; box-shadow: 0 0 0 2px var(--bg); }
  .me { padding: 0; justify-content: center; }
  .side-btn { width: 48px; padding: 0; justify-content: center; }
}
/* Drawer: phones */
@media (max-width: 719px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .side { position: fixed; left: 0; top: 0; bottom: 0; width: min(300px, 86vw); transform: translateX(-104%); visibility: hidden;
    transition: transform .28s var(--ease), visibility 0s linear .28s; box-shadow: 20px 0 50px -20px rgba(0, 0, 0, .35); border-right: 0; }
  body.nav-open .side { transform: none; visibility: visible; transition: transform .28s var(--ease), visibility 0s; }
  body.nav-open { overflow: hidden; }
  .menu-btn { display: inline-grid !important; }
}

/* ---------- Header ---------- */
.top { display: flex; align-items: center; gap: 14px; padding: 26px var(--pad) 6px; }
.top-title { flex: 1; min-width: 0; }
.top-title h1 { font-size: clamp(22px, 2.6vw, 30px); font-weight: 750; letter-spacing: -.025em; }
.top-sub { margin-top: 4px; color: var(--ink-3); font-size: 14px; }
.top-sub:empty { display: none; }
.top-actions { display: flex; align-items: center; gap: 10px; flex: none; }
.icon-btn { appearance: none; position: relative; display: inline-grid; place-items: center; width: 46px; height: 46px; border: 0; border-radius: 50%;
  background: var(--dot); color: var(--dot-ink); cursor: pointer; transition: transform .2s var(--ease), opacity .2s; }
.icon-btn:hover { transform: translateY(-1px); }
.icon-btn:active { transform: scale(.94); }
.icon-btn:disabled { opacity: .55; cursor: progress; }
.icon-btn:disabled .ico { animation: bb-spin 1s linear infinite; }
.menu-btn { background: var(--card); color: var(--ink); }
.ico-sun { display: none; }
:root[data-theme="dark"] .ico-sun { display: block; }
:root[data-theme="dark"] .ico-moon { display: none; }
.pill-btn { display: inline-flex; align-items: center; gap: 8px; min-height: 46px; padding: 0 22px; border-radius: 999px; background: var(--accent);
  color: var(--accent-ink); font-weight: 650; text-decoration: none; white-space: nowrap; box-shadow: var(--glow); transition: background-color .18s, transform .2s var(--ease); }
.pill-btn:hover { background: var(--accent-hover); transform: translateY(-1px); }
.pill-btn .ico { width: 18px; height: 18px; }
body:not(.is-authed) .authed-only { display: none !important; }
@media (max-width: 719px) {
  .top { flex-wrap: wrap; padding-top: 16px; gap: 10px 12px; }
  .top-actions { margin-left: auto; }
  .top-title { order: 3; flex-basis: 100%; }
}
@media (max-width: 479px) { .pill-btn { display: none !important; } }

/* ---------- Page ---------- */
.page { flex: 1; width: 100%; max-width: 1360px; padding: 18px var(--pad) 48px; }
#status { margin: 0 0 14px; color: var(--ink-3); font-size: 15px; }
#status.error { color: var(--pink); font-weight: 600; }
#status:empty { display: none; }
.stack { display: grid; gap: 18px; }

/* Skeleton while a page is loading (js/admin-shell.js toggles body.is-loading) */
.skeleton { display: none; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr)); margin-bottom: 18px; }
body.is-loading .skeleton { display: grid; }
.skeleton span { height: 132px; border-radius: var(--r); }
.skeleton .wide { grid-column: 1 / -1; height: 260px; }
.skeleton span, .is-loading .card-num, .is-loading .mini, .is-loading .ring-wrap {
  background: linear-gradient(100deg, var(--card) 30%, var(--card-2) 50%, var(--card) 70%); background-size: 300% 100%;
  animation: bb-shimmer 1.3s ease-in-out infinite; }

/* ---------- Buttons / inputs ---------- */
button, input, select, textarea { font: inherit; color: inherit; }
.btn { appearance: none; display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 0; border-radius: 999px;
  padding: 0 22px; min-height: 46px; background: var(--accent); color: var(--accent-ink); font-weight: 650; cursor: pointer;
  transition: background-color .15s ease-out, transform .2s var(--ease); }
.btn:hover { background: var(--accent-hover); }
.btn:active { transform: scale(.97); }
.btn:disabled { background: var(--line-strong); color: var(--ink-3); cursor: progress; }
.btn-ghost { appearance: none; display: inline-flex; align-items: center; justify-content: center; min-height: 42px; padding: 0 16px;
  border: 1px solid var(--line-strong); border-radius: 999px; background: transparent; color: var(--ink-2); font-weight: 600; cursor: pointer; }
.btn-ghost:hover { background: var(--surface); color: var(--ink); }
.btn-ghost:disabled { opacity: .55; cursor: progress; }
/* Plain buttons the data scripts create inside tables / cards */
.page button:not([class]), dialog button:not([class]) { appearance: none; min-height: 36px; padding: 0 14px; margin: 2px 6px 2px 0;
  border: 1px solid var(--line-strong); border-radius: 999px; background: var(--surface); color: var(--ink); font-size: 13.5px; font-weight: 600; cursor: pointer;
  white-space: nowrap; transition: background-color .15s, border-color .15s; }
.page button:not([class]):hover { border-color: var(--accent); background: var(--accent-soft); }
.page button:not([class]):disabled { opacity: .55; cursor: progress; }
button.danger { appearance: none; min-height: 36px; padding: 0 14px; margin: 2px 6px 2px 0; border: 1px solid var(--pink); border-radius: 999px;
  background: var(--pink); color: #fff; font-size: 13.5px; font-weight: 650; cursor: pointer; }
:root[data-theme="dark"] button.danger { color: #0C0B16; }
button.danger:disabled { opacity: .5; cursor: not-allowed; }
input[type=email], input[type=password], input[type=search], input[type=date], input:not([type]), select, textarea {
  width: 100%; min-height: 46px; padding: 10px 14px; border: 1px solid var(--line-strong); border-radius: 14px; background: var(--surface);
  color: var(--ink); caret-color: var(--accent); }
input[type=checkbox] { width: 18px; height: 18px; accent-color: var(--accent); vertical-align: -3px; }
input::placeholder, textarea::placeholder { color: var(--ink-3); }
input:focus, select:focus, textarea:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px var(--accent-soft); }

/* ---------- Sign-in ---------- */
.login { max-width: 440px; margin: 16px auto; padding: 32px 28px 28px; background: var(--card); border-radius: 28px; box-shadow: var(--shadow); }
.login-mark { display: block; margin-bottom: 16px; border-radius: 14px; }
.login h2 { font-size: 24px; letter-spacing: -.02em; margin-bottom: 18px; }
.login-form { display: grid; gap: 14px; }
.login-form label { display: grid; gap: 6px; font-weight: 600; font-size: 14px; color: var(--ink-2); }
.login-form .btn { margin-top: 4px; }
.login-form .error:empty, .login .error:empty { display: none; }
.login-note { margin: -6px 0 18px; color: var(--ink-2); font-size: 14.5px; line-height: 1.5; }
/* Google "G" sits on its own white disc so its brand colours read on any theme. */
.btn-google .g-logo { flex: 0 0 auto; width: 26px; height: 26px; padding: 4px; margin-left: -8px; border-radius: 50%; background: #fff; }
.noaccess { margin: 0 0 18px; padding: 12px 14px; border-radius: 14px; background: var(--pink-soft); color: var(--pink); font-weight: 600; }

/* Separate login page (admin-login.html, 2026-11-23): one centred card, no sidebar. Desktop. */
body.login-page { display: grid; grid-template-columns: minmax(0, 440px); place-content: center; padding: 32px 20px; }
.login-page .login { width: 100%; margin: 0; text-align: left; }
.login-page .login-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 22px; font-weight: 800; font-size: 17px; letter-spacing: -.01em; }
.login-page .login-brand .login-mark { margin: 0; }
.login-page .login-brand small { display: block; font-size: 12.5px; font-weight: 600; color: var(--ink-3); letter-spacing: 0; }
.login-page .login-title { margin: 0 0 14px; font-size: 26px; letter-spacing: -.02em; }
.login-page .btn-google { width: 100%; }
.login-page .login-status { margin: 0; font-size: 14px; color: var(--ink-3); }
.login-page .login-status:empty { display: none; }
.login-page .login-foot { margin: 18px 0 0; text-align: center; font-size: 12px; font-weight: 600; color: var(--pink); }
.login-page .login[data-state="checking"] .btn-google { display: none; }

/* ---------- Cards ---------- */
.card { position: relative; display: flex; flex-direction: column; gap: 8px; min-width: 0; padding: 22px 24px; background: var(--card);
  border-radius: var(--r); color: var(--ink); text-decoration: none; box-shadow: var(--shadow); }
a.card { transition: background-color .2s ease-out, transform .25s var(--ease); }
a.card:hover { background: var(--card-2); transform: translateY(-2px); }
a.card:focus-visible { outline-offset: 3px; border-radius: var(--r); }
.card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 4px; }
.card-title { font-size: 20px; font-weight: 700; letter-spacing: -.015em; }
.card-title small { display: block; margin-top: 3px; font-size: 13px; letter-spacing: 0; }
.card-more { font-size: 13.5px; color: var(--ink-3); white-space: nowrap; display: inline-flex; align-items: center; gap: 4px; }
.card-more::after, .card-go::after { content: ""; width: 6px; height: 6px; border-top: 1.8px solid currentColor; border-right: 1.8px solid currentColor; transform: rotate(45deg); }

/* Stat cards */
.stats { display: grid; gap: 18px; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 560px) { .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); } .stats > :last-child { grid-column: 1 / -1; } }
@media (min-width: 1100px) { .stats { grid-template-columns: repeat(3, minmax(0, 1fr)); } .stats > :last-child { grid-column: auto; } }
.stat { gap: 10px; }
.card-label { font-weight: 600; font-size: 15px; color: var(--ink); }
.stat-row { display: flex; align-items: center; gap: 12px; min-width: 0; }
.stat-ico { flex: none; width: 46px; height: 46px; border-radius: 50%; display: grid; place-items: center; background: var(--dot); color: var(--dot-ink); }
.card-num { font-size: clamp(32px, 4vw, 40px); font-weight: 750; line-height: 1.05; letter-spacing: -.03em; font-variant-numeric: tabular-nums;
  border-radius: 10px; min-width: 1.2ch; }
.is-loading .card-num { color: transparent; min-width: 2.4ch; }
.mini { margin-left: auto; flex: none; width: 96px; height: 50px; border-radius: 10px; }
.mini svg { display: block; width: 100%; height: 100%; overflow: visible; }
.mini text { font: 600 9px var(--font); fill: var(--ink-3); }
.card-note { font-size: 13.5px; color: var(--ink-3); }
.card-note:empty { display: none; }
.card-go { margin-top: auto; padding-top: 4px; font-size: 14px; font-weight: 650; color: var(--accent-text); display: inline-flex; align-items: center; gap: 7px; }
.card.is-alert .card-label::before { content: ""; display: inline-block; width: 8px; height: 8px; margin-right: 8px; border-radius: 50%; background: var(--pink);
  vertical-align: .1em; box-shadow: 0 0 0 4px var(--pink-soft); }
.card.is-alert .stat-ico { background: var(--pink); color: #fff; }

/* Lower grid */
.grid-lower { display: grid; gap: 18px; margin-top: 18px; grid-template-columns: minmax(0, 1fr); align-items: start; }
@media (min-width: 1180px) { .grid-lower { grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); } }

/* Brands card: donut + bars */
.card-brands { display: grid; grid-template-columns: auto minmax(0, 1fr); grid-template-areas: "head head" "ring list" "note note"; gap: 14px 22px; align-items: center; }
.card-brands .card-head { grid-area: head; }
.card-brands .card-note { grid-area: note; }
.ring-wrap { grid-area: ring; width: 148px; height: 148px; border-radius: 50%; }
.ring-wrap:empty { display: none; }
.ring-wrap svg { display: block; width: 100%; height: 100%; }
.ring-num { font: 750 26px var(--font); fill: var(--ink); letter-spacing: -.02em; }
.ring-sub { font: 600 9.5px var(--font); fill: var(--ink-3); }
.brand-list { grid-area: list; display: grid; gap: 10px; min-width: 0; }
.brand-list:empty { display: none; }
.brand-row { display: grid; grid-template-columns: minmax(70px, 8.5em) 1fr minmax(2.5em, auto); align-items: center; gap: 12px; font-size: 14px; }
.brand-name { font-weight: 600; min-width: 0; overflow-wrap: anywhere; display: flex; align-items: center; gap: 8px; }
.brand-name::before { content: ""; flex: none; width: 9px; height: 9px; border-radius: 50%; background: var(--sw, var(--s1)); }
.brand-track { height: 8px; border-radius: 999px; background: var(--surface); overflow: hidden; }
.brand-fill { display: block; height: 100%; border-radius: 999px; background: var(--sw, var(--s1)); }
.brand-row:nth-child(1) { --sw: var(--s1); } .brand-row:nth-child(2) { --sw: var(--s2); } .brand-row:nth-child(3) { --sw: var(--s3); }
.brand-row:nth-child(4) { --sw: var(--s4); } .brand-row:nth-child(5) { --sw: var(--s5); } .brand-row:nth-child(6) { --sw: var(--s6); }
.brand-count { text-align: right; font-variant-numeric: tabular-nums; font-weight: 700; }
@media (max-width: 559px) {
  .card-brands { grid-template-columns: minmax(0, 1fr); grid-template-areas: "head" "ring" "list" "note"; justify-items: stretch; }
  .ring-wrap { justify-self: center; }
}

.aside { margin: 18px 4px 0; font-size: 13.5px; color: var(--ink-3); max-width: 75ch; }

/* Lookup */
.lookup { gap: 10px; }
.search { display: flex; gap: 10px; flex-wrap: wrap; }
.search-field { position: relative; flex: 1 1 220px; display: flex; align-items: center; }
.search-field .ico { position: absolute; left: 14px; color: var(--ink-3); pointer-events: none; }
.search-field input { padding-left: 42px; border-radius: 999px; }
.search .btn { flex: 0 0 auto; }
.hint { font-size: 13.5px; color: var(--ink-3); }
.lookup .status { margin: 0; font-size: 14px; color: var(--ink-3); }
.lookup .status:empty { display: none; }
.matches { display: grid; gap: 8px; }
.match { appearance: none; text-align: left; display: grid; gap: 2px; padding: 12px 16px; border: 1px solid transparent; border-radius: var(--r-sm);
  background: var(--surface); cursor: pointer; color: var(--ink); }
.match:hover { border-color: var(--accent); }
.match-name { font-weight: 650; }
.match-sub { font-size: 13.5px; color: var(--ink-3); }
.profile { margin-top: 6px; padding: 20px; background: var(--surface); border-radius: 20px; animation: bb-rise .45s var(--ease) both; }
.profile-top { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.avatar { flex: none; width: 52px; height: 52px; border-radius: 50%; display: grid; place-items: center;
  background: linear-gradient(135deg, #7A55FF, #FF6B91); color: #fff; font-weight: 700; font-size: 21px; }
.profile-id { min-width: 0; flex: 1; }
.profile-id h3 { font-size: 19px; }
.profile-user { color: var(--ink-3); font-size: 14px; }
.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; margin: 18px 0 4px; }
.facts dt { font-size: 12.5px; color: var(--ink-3); }
.facts dd { margin: 2px 0 0; font-weight: 650; font-variant-numeric: tabular-nums; }
.sub { margin-top: 18px; }
.sub h4 { font-size: 14px; color: var(--ink-2); margin-bottom: 8px; }
.profile .chip { display: inline-flex; gap: 4px; flex-wrap: wrap; padding: 6px 12px; margin: 0 8px 8px 0; border-radius: 999px; background: var(--teal-soft);
  color: var(--teal); font-size: 13.5px; }
.flag-list { list-style: none; margin: 0 0 10px; padding: 0; display: grid; gap: 6px; }
.flag-list li { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 9px 12px; border-radius: 12px; background: var(--surface-2); font-size: 14px; }
.flag-day { font-weight: 650; font-variant-numeric: tabular-nums; min-width: 7.5em; }
.flag-why { color: var(--ink-2); flex: 1 1 12em; }
.pill { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 12.5px; font-weight: 650; white-space: nowrap; }
.pill-warn { background: var(--amber-soft); color: var(--amber); }
.pill-bad { background: var(--pink-soft); color: var(--pink); }
.pill-ok { background: var(--teal-soft); color: var(--teal); }
.link { color: var(--accent-text); font-weight: 650; font-size: 14px; text-underline-offset: 3px; }

/* ---------- Segmented tabs (devices / reports) ---------- */
.seg { display: inline-flex; flex-wrap: wrap; gap: 4px; padding: 5px; margin-bottom: 18px; border-radius: 999px; background: var(--card); }
.page .seg button { margin: 0; border: 0; background: transparent; font-size: inherit; }
.seg button { appearance: none; min-height: 40px; padding: 0 18px; border: 0; border-radius: 999px; background: transparent; color: var(--ink-2);
  font-weight: 650; cursor: pointer; transition: background-color .2s ease-out, color .2s ease-out; }
.page .seg button:hover { color: var(--ink); background: transparent; }
.page .seg button[aria-selected="true"] { background: var(--dot); color: var(--dot-ink); }
.seg button span { font-variant-numeric: tabular-nums; opacity: .75; }

/* ---------- Tables inside cards ---------- */
.table-wrap { max-height: min(72vh, 960px); overflow: auto; border-radius: var(--r-sm); background: var(--surface); margin-top: 8px;
  -webkit-overflow-scrolling: touch; overscroll-behavior: contain; }
.table-wrap:has(table:empty) { display: none; }
table { border-collapse: separate; border-spacing: 0; width: 100%; font-size: 13.5px; }
th, td { padding: 10px 12px; text-align: left; vertical-align: top; border-bottom: 1px solid var(--line); }
th { position: sticky; top: 0; z-index: 1; background: var(--surface-2); color: var(--ink-3); font-size: 12px; font-weight: 650;
  letter-spacing: .03em; white-space: nowrap; }
tbody tr:last-child td, table > tr:last-child td { border-bottom: 0; }
tbody tr:hover td, table > tr:hover td { background: color-mix(in srgb, var(--accent) 5%, transparent); }
td.num { text-align: right; font-variant-numeric: tabular-nums; }
td.nowrap { white-space: nowrap; }
body[data-page="devices"] td, body[data-page="flags"] td { white-space: nowrap; }
tr.brand-start td { border-top: 2px solid var(--line-strong); }
tbody tr.brand-start:first-child td { border-top: 0; }
.legend { margin-top: 10px; font-size: 12.5px; color: var(--ink-3); line-height: 1.6; }
.legend:empty { display: none; }
.toolbar { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px 12px; }
.field { display: grid; gap: 4px; font-size: 13px; font-weight: 600; color: var(--ink-2); }
.field input { width: auto; min-width: 170px; }
#userMeta:empty, #brandMeta:empty, #watchMeta:empty { display: none; }

/* Devices: delivery-pattern chips */
body[data-page="devices"] .chip { display: inline-block; min-width: 78px; text-align: center; padding: 3px 10px; border-radius: 999px; font-weight: 700;
  font-size: 11.5px; letter-spacing: .04em; }
.chip.periodic { background: var(--teal-soft); color: var(--teal); }
.chip.mixed { background: var(--amber-soft); color: var(--amber); }
.chip.lump { background: var(--pink-soft); color: var(--pink); }
.chip.session { background: var(--accent-soft); color: var(--accent-text); }
.split { font-size: 11.5px; color: var(--ink-3); margin-left: 8px; }

/* Reports */
.uid { font-family: var(--mono); font-size: 12px; color: var(--ink-3); }
.snippet { font-family: var(--mono); font-size: 12px; background: var(--surface-2); border-radius: 10px; padding: 8px 10px; white-space: pre-wrap;
  word-break: break-word; max-width: 420px; }
.count { display: inline-block; margin-top: 4px; padding: 1px 8px; border-radius: 999px; background: var(--pink-soft); color: var(--pink); font-size: 12px; font-weight: 700; white-space: nowrap; }
img.evidence { max-width: 160px; max-height: 160px; display: block; margin-top: 6px; border-radius: 10px; }
.reports-table td { min-width: 90px; }
.flagged { margin-bottom: 18px; background: linear-gradient(180deg, var(--pink-soft), var(--card) 140px); }
.flagged .card-title { color: var(--pink); }
.flagged-list { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 320px), 1fr)); }
.fuser { display: grid; gap: 8px; align-content: start; padding: 16px; border-radius: 20px; background: var(--surface); font-size: 14px; }
.fuser > div:first-child > div:first-child { font-weight: 700; font-size: 15px; }
.fuser ul { margin: 0; padding-left: 18px; color: var(--ink-2); font-size: 13px; }
.fuser li + li { margin-top: 4px; }
.actions { display: flex; flex-wrap: wrap; gap: 6px; }
.actions button { margin: 0 !important; }
dialog { max-width: 540px; width: 92vw; padding: 26px; border: 0; border-radius: 26px; background: var(--card); color: var(--ink); box-shadow: 0 30px 80px -20px rgba(0, 0, 0, .45); }
dialog::backdrop { background: rgba(8, 7, 16, .5); backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px); }
dialog[open] { animation: bb-pop .28s var(--ease) both; }
dialog h3 { font-size: 20px; margin-bottom: 8px; }
dialog p { margin: 8px 0; }
dialog label { display: block; margin: 14px 0 6px; font-weight: 600; font-size: 14px; }
dialog textarea, dialog select, dialog input { width: 100%; }
dialog .error:empty { display: none; }
.dialog-actions { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 8px; margin-top: 18px; }
.dialog-actions button.danger { min-height: 42px; margin: 0; }

/* ---------- Motion ---------- */
.rise { animation: bb-rise .6s var(--ease) both; animation-delay: calc(var(--i, 0) * 75ms + 60ms); }
html.intro-on .rise { animation-play-state: paused; }
@keyframes bb-rise { from { opacity: 0; transform: translateY(14px) scale(.985); } to { opacity: 1; transform: none; } }
@keyframes bb-pop { from { opacity: 0; transform: translateY(10px) scale(.97); } to { opacity: 1; transform: none; } }
@keyframes bb-shimmer { from { background-position: 100% 0; } to { background-position: 0 0; } }
@keyframes bb-spin { to { transform: rotate(360deg); } }
@keyframes bb-unhide { to { opacity: 1; } }

/* Intro (first page of a session; built by js/admin-shell.js) */
html.intro-on, html.intro-on body { background: #07060D; }
html.intro-on .app { opacity: 0; animation: bb-unhide .01s 4s forwards; } /* safety net if the script fails */
.app.app-enter { animation: bb-app-in .6s var(--ease) both; }
@keyframes bb-app-in { from { opacity: 0; transform: scale(.985); } to { opacity: 1; transform: none; } }
.intro { position: fixed; inset: 0; z-index: 150; display: grid; place-items: center; align-content: center; gap: 26px;
  background: radial-gradient(60% 55% at 50% 44%, #1B1836 0%, #0B0A15 62%, #07060D 100%); color: #EEEDF6; cursor: pointer; }
.intro-dial { position: relative; width: min(48vmin, 250px); aspect-ratio: 1; }
.intro-dial svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.intro-logo { position: absolute; left: 50%; top: 50%; width: 30%; height: 30%; margin: -15% 0 0 -15%; border-radius: 22%;
  box-shadow: 0 0 40px rgba(155, 125, 255, .55); }
.intro-hi { font-size: 16px; letter-spacing: .02em; color: #CFCBE8; min-height: 1.5em; text-align: center; padding: 0 20px; }
.intro-skip { position: absolute; bottom: max(24px, env(safe-area-inset-bottom)); left: 50%; transform: translateX(-50%); appearance: none; border: 1px solid rgba(255, 255, 255, .22);
  background: transparent; color: #CFCBE8; border-radius: 999px; min-height: 40px; padding: 0 18px; font: 600 13px var(--font); cursor: pointer; }
.intro-skip:focus-visible { outline-color: #FFDF9E; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-delay: 0s !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
  @view-transition { navigation: none; }
}

/* Very narrow (320 px phones at 150-200 % zoom) */
@media (max-width: 420px) {
  .card { padding: 18px 16px; }
  .fuser { padding: 12px; }
  .actions button, .page button:not([class]), button.danger { white-space: normal; text-align: center; }
}
@media (max-width: 340px) {
  .mini { display: none; }
  .stat-row { flex-wrap: wrap; }
  .top-actions { gap: 6px; }
}

/* ---------- Devices: brand-first layout (owner feedback 2026-11-22, desktop) ---------- */
.sec-title { font-size: 20px; font-weight: 700; letter-spacing: -.015em; margin: 6px 0 2px; }
.overview-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px 24px; flex-wrap: wrap; }
.overview-hint { max-width: 40ch; text-align: right; }
.bgrid { display: grid; gap: 18px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr)); }
.bcard { cursor: pointer; gap: 14px; transition: background-color .2s ease-out, transform .25s var(--ease); }
.bcard:hover { background: var(--card-2); transform: translateY(-2px); }
.bcard-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.bcard-name { display: grid; gap: 6px; min-width: 0; }
.bcard-name h3 { font-size: 21px; letter-spacing: -.02em; }
.kind { justify-self: start; display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 11.5px; font-weight: 700; letter-spacing: .04em;
  text-transform: uppercase; background: var(--surface); color: var(--ink-2); }
.kind.phone { background: var(--dot); color: var(--dot-ink); }
.bstats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.bstat { display: grid; gap: 2px; padding: 10px 12px; border-radius: 14px; background: var(--surface); min-width: 0; }
.bstat-v { font-size: 22px; font-weight: 750; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.bstat-l { font-size: 12px; color: var(--ink-3); line-height: 1.3; }
.btypes { display: flex; flex-wrap: wrap; gap: 6px; }
.tchip { padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 650; background: var(--surface); color: var(--ink-2); }
.tchip::before { content: ""; display: inline-block; width: 7px; height: 7px; margin-right: 6px; border-radius: 50%; background: var(--s-rest); vertical-align: .05em; }
.tchip.periodic::before { background: var(--teal); } .tchip.mixed::before { background: var(--amber); }
.tchip.lump::before { background: var(--pink); } .tchip.session::before { background: var(--accent); }
.bcard-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: auto; flex-wrap: wrap; }
.nat { display: inline-flex; align-items: center; gap: 8px; padding: 6px 12px 6px 8px; border-radius: 999px; background: var(--surface); font-size: 13px;
  font-weight: 600; color: var(--ink-2); cursor: pointer; }
.nat.on { background: var(--accent-soft); color: var(--accent-text); }
/* Country board per metric (2026-11-22) */
.natpick { display: grid; gap: 8px; padding: 12px; border-radius: 14px; background: var(--surface); cursor: default; }
.natpick-title { font-size: 12px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--ink-3); }
.natpick-row { display: flex; flex-wrap: wrap; gap: 6px; }
.natpick .nat { padding: 5px 11px 5px 7px; gap: 6px; background: var(--card); border: 1px solid var(--line); }
.natpick .nat.on { background: var(--accent-soft); border-color: transparent; }
.natpick .nat.nofx { opacity: .55; }
.natpick .nat input { width: 16px; height: 16px; min-height: 0; margin: 0; padding: 0; accent-color: var(--accent); }
.natpick-hint { font-size: 12px; color: var(--ink-3); }
.bhero .natpick { justify-self: start; max-width: 620px; }
.nat-info { gap: 8px; }
.nat-info p { max-width: 95ch; line-height: 1.5; }
.nat-now { font-weight: 650; color: var(--ink-2); }
.chip.none { background: var(--surface); color: var(--ink-3); }
body[data-page="devices"] .chip { white-space: nowrap; }
.legend-box { padding: 14px 18px; border-radius: var(--r-sm); background: var(--card); }
.legend-box summary { cursor: pointer; font-weight: 650; color: var(--ink-2); }
.back { justify-self: start; gap: 6px; }
.back::before { content: ""; width: 7px; height: 7px; border-left: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: rotate(45deg); }
.bhero { gap: 14px; }
.bhero-title { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.bhero-title h2 { font-size: 28px; letter-spacing: -.025em; }
.bhero .bstats { max-width: 620px; }
.bhero .nat { justify-self: start; align-self: flex-start; }
.tgrid { display: grid; gap: 18px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 320px), 1fr)); }
.tcard { gap: 10px; }
.tcard-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.tcard-head h4 { font-size: 17px; }
.pbar { display: flex; height: 8px; border-radius: 999px; overflow: hidden; background: var(--surface); }
.pseg.periodic { background: var(--teal); } .pseg.mixed { background: var(--amber); } .pseg.lump { background: var(--pink); } .pseg.session { background: var(--accent); }
.tcard .split { margin: 0; }
.tfacts { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px 12px; margin: 4px 0 0; padding: 12px; border-radius: 14px; background: var(--surface); }
.tfacts dt { font-size: 11.5px; color: var(--ink-3); line-height: 1.3; }
.tfacts dd { margin: 2px 0 0; font-weight: 700; font-variant-numeric: tabular-nums; }
.note-box { padding: 12px 14px; border-radius: 14px; background: var(--surface); }
.users-table tr.click { cursor: pointer; }
.uwho { display: grid; }
.uname { font-weight: 650; }
.ulink { font-weight: 650; }
