/* Tagio admin. Tokens first; dark mode is its own set of steps, not an inversion. */
/* Tagio's palette (web/app/globals.css, app/src/theme.ts). Dark mode is its own set of steps. */
:root {
  --brand: #2563eb;
  --brand-strong: #1d4ed8;
  --brand-sky: #60a5fa;
  --brand-soft: #dbeafe;
  --brand-subtle: #eff6ff;
  --bar: #2563eb;
  --hero: linear-gradient(135deg, #3b82f6 0%, #2563eb 48%, #1d4ed8 100%);
  --deep: linear-gradient(150deg, #1d4ed8 0%, #1e3a8a 100%);
  --night: #0f2a6b;          /* tooltips and toasts */
  --night-ink: #ffffff;
  --night-soft: rgba(255, 255, 255, .78);
  --page: #e9eef7;           /* behind the frame */
  --bg: #f8f9fa;             /* Tagio paper */
  --side: #ffffff;
  --surface: #ffffff;
  --surface-2: #f2f4f7;
  --line: #e3e6ea;
  --grid: #edf0f3;
  --ink: #0b0d12;
  --body: #353a42;
  --soft: #5e6470;
  --good: #15803d; --good-bg: #e8f7ee;
  --warn: #92400e; --warn-bg: #fdf3dc;
  --bad: #b91c1c; --bad-bg: #fdecec;
  /* Subscriber groups (validated: light surface) */
  --c-solo: #2563eb; --c-share: #0d9488; --c-off: #d97706; --c-ended: #8b5cf6;
  --shadow: 0 1px 2px rgba(15, 23, 42, .04), 0 6px 20px -14px rgba(37, 99, 235, .25);
  --radius: 18px;
  color-scheme: light;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --brand: #3b82f6; --brand-strong: #60a5fa; --brand-sky: #93c5fd; --brand-soft: #1c2d52; --brand-subtle: #131d33; --bar: #3b82f6;
    --hero: linear-gradient(135deg, #2563eb 0%, #1d4ed8 50%, #1e3a8a 100%);
    --deep: linear-gradient(150deg, #1e3a8a 0%, #172554 100%);
    --night: #1e3a8a;
    --page: #06080c; --bg: #0c0f14; --side: #10141b; --surface: #141820; --surface-2: #1a1f29; --line: #252b36; --grid: #1e232d;
    --ink: #f3f5f8; --body: #cbd2dc; --soft: #8b95a7;
    --good: #4ade80; --good-bg: #0e2a1b; --warn: #fbbf24; --warn-bg: #2b2210; --bad: #f87171; --bad-bg: #2d1414;
    /* Subscriber groups (validated: dark surface) */
    --c-solo: #3b82f6; --c-share: #0f9f8f; --c-off: #d4820c; --c-ended: #9b7af7;
    --shadow: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--page); color: var(--body); font-size: 14px; line-height: 1.45; -webkit-font-smoothing: antialiased; }
[hidden] { display: none !important; }
h1, h2, h3 { color: var(--ink); margin: 0; letter-spacing: -0.015em; }
code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .9em; background: var(--surface-2); padding: 1px 5px; border-radius: 5px; }
a { color: var(--brand); }
.muted { color: var(--soft); }
.small { font-size: 12.5px; }
.num { font-variant-numeric: tabular-nums; }
.error { color: var(--bad); background: var(--bad-bg); padding: 8px 10px; border-radius: 10px; margin: 0; }

/* Icons */
.i { display: inline-grid; place-items: center; width: 18px; height: 18px; flex: none; }
.i svg { width: 100%; height: 100%; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }

/* Brand */
.brand { display: flex; align-items: center; gap: 10px; color: var(--ink); }
.brand-name { font-size: 15.5px; font-weight: 650; letter-spacing: -0.01em; }
.brand-name b { font-weight: 500; color: var(--soft); }
.mark { width: 30px; height: 30px; border-radius: 9px; background: url("icon.svg") center / cover; flex: none; }

/* Buttons and inputs */
.btn { appearance: none; display: inline-flex; align-items: center; justify-content: center; gap: 7px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); font: inherit; font-weight: 550; padding: 8px 14px; border-radius: 11px; cursor: pointer; white-space: nowrap; text-decoration: none; }
.btn:hover { border-color: var(--soft); }
.btn:focus-visible, input:focus-visible, select:focus-visible, a:focus-visible, .icon-btn:focus-visible, button:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-strong); border-color: var(--brand-strong); }
.btn.danger { color: var(--bad); }
.btn.danger:hover { border-color: var(--bad); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--soft); }
.btn.ghost:hover { color: var(--ink); }
.btn.small { padding: 6px 11px; font-size: 13px; border-radius: 10px; }
.btn.wide { width: 100%; }
.btn[disabled] { opacity: .5; cursor: default; }
.icon-btn { appearance: none; position: relative; display: grid; place-items: center; width: 40px; height: 40px; border-radius: 50%; border: 1px solid var(--line); background: var(--surface); color: var(--ink); cursor: pointer; }
.icon-btn:hover { border-color: var(--soft); }
.icon-btn[aria-pressed=true] { background: var(--ink); color: var(--surface); border-color: var(--ink); }
input[type=text], input[type=password], input[type=search], select {
  font: inherit; color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: 11px; padding: 8px 11px; min-width: 0;
}
label { display: block; font-weight: 550; color: var(--ink); margin: 14px 0 6px; }
label.check { display: flex; align-items: center; gap: 8px; font-weight: 450; color: var(--body); margin: 12px 0; cursor: pointer; }

/* Sign in */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card { width: 100%; max-width: 400px; background: var(--surface); border: 1px solid var(--line); border-radius: 22px; padding: 30px; box-shadow: 0 30px 60px -30px rgba(15, 23, 42, .35); }
.login-card h1 { font-size: 24px; margin: 28px 0 6px; }
.login-card input[type=password] { width: 100%; }
.login-card .btn { margin-top: 12px; padding: 11px; }
.login-foot { margin: 16px 0 0; }

/* Frame and shell: the sidebar and the top bar never scroll; only .content does. */
.frame { height: 100vh; height: 100dvh; padding: 18px; overflow: hidden; }
.shell { display: grid; grid-template-columns: 252px minmax(0, 1fr); height: 100%; margin: 0 auto; border-radius: 28px; overflow: hidden; border: 1px solid var(--line); background: var(--bg); }
.side { display: flex; flex-direction: column; gap: 16px; padding: 22px 16px; background: var(--side); border-right: 1px solid var(--line); min-height: 0; overflow: hidden; }
.side .brand { padding: 0 8px 6px; }
#nav { display: flex; flex-direction: column; }
.nav-group { font-size: 11px; font-weight: 650; letter-spacing: .08em; text-transform: uppercase; color: var(--soft); padding: 14px 10px 6px; }
.nav-group:first-child { padding-top: 0; }
#nav a, #nav button, #more-nav a { display: flex; align-items: center; gap: 11px; color: var(--body); text-decoration: none; padding: 10px 12px; border-radius: 12px; font: inherit; font-weight: 520; border: 0; background: none; text-align: left; cursor: pointer; }
#nav a .i, #nav button .i, #more-nav a .i { color: var(--soft); }
#nav a:hover, #nav button:hover, #more-nav a:hover { background: var(--surface-2); color: var(--ink); }
#nav a[aria-current=page], #more-nav a[aria-current=page] { background: var(--brand); color: #fff; box-shadow: 0 8px 18px -10px rgba(37, 99, 235, .8); }
#nav a[aria-current=page] .i, #more-nav a[aria-current=page] .i { color: #fff; }
#nav .short, #nav #more-btn { display: none; }
#nav .count, #more-nav .count { margin-left: auto; font-size: 11.5px; font-weight: 650; min-width: 20px; padding: 1px 7px; border-radius: 99px; background: var(--brand-soft); color: var(--brand); text-align: center; }
#nav a[aria-current=page] .count { background: rgba(255, 255, 255, .14); color: #fff; }
.side-card { margin-top: auto; background: var(--surface-2); border: 1px solid var(--line); border-radius: 16px; padding: 14px; }
.side-card-head { display: flex; align-items: center; gap: 8px; color: var(--ink); }
.side-card .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--c-share); box-shadow: 0 0 0 3px color-mix(in srgb, var(--c-share) 20%, transparent); }
.side-card p { margin: 6px 0 10px; font-size: 12.5px; color: var(--soft); }
.toggle { position: relative; display: flex; align-items: center; gap: 10px; margin: 0; font-weight: 550; cursor: pointer; }
.toggle input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.toggle .track { width: 36px; height: 21px; border-radius: 99px; background: var(--line); position: relative; transition: background .15s; flex: none; }
.toggle .track::after { content: ""; position: absolute; top: 2.5px; left: 2.5px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0, 0, 0, .25); transition: transform .15s; }
.toggle input:checked + .track { background: var(--brand); }
.toggle input:checked + .track::after { transform: translateX(15px); }
.toggle input:focus-visible + .track { outline: 2px solid var(--brand); outline-offset: 2px; }

.main { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.top { flex: none; display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 20px 26px 16px; }
.content { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 4px 26px 26px; }
.hello { display: flex; align-items: center; gap: 12px; min-width: 0; }
.hello > div { min-width: 0; }
.avatar { width: 44px; height: 44px; border-radius: 13px; background: url("icon.svg") center / cover; flex: none; box-shadow: 0 8px 18px -10px rgba(37, 99, 235, .8); }
.top h1 { font-size: 21px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top p { margin: 1px 0 0; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top-right { display: flex; align-items: center; gap: 8px; flex: none; }
.search { position: relative; }
.search .i { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); color: var(--soft); }
.search input { width: 250px; padding: 10px 14px 10px 38px; border-radius: 99px; }
#search-btn { display: none; }
.bell-wrap { position: relative; }
.bell-dot { position: absolute; top: 8px; right: 9px; width: 8px; height: 8px; border-radius: 50%; background: var(--bad); box-shadow: 0 0 0 2px var(--surface); }
.notes { position: absolute; right: 0; top: calc(100% + 8px); width: 340px; max-width: calc(100vw - 32px); max-height: 70vh; overflow-y: auto; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; box-shadow: 0 24px 50px -20px rgba(15, 23, 42, .35); padding: 8px; z-index: 5; }
.notes h3 { font-size: 13px; padding: 8px 10px; }
.note { display: flex; gap: 10px; padding: 10px; border-radius: 12px; color: var(--body); text-decoration: none; }
.note:hover { background: var(--surface-2); }
.note b { color: var(--ink); display: block; font-weight: 600; }
.note .chip { width: 32px; height: 32px; }
.updated { margin: 22px 0 0; text-align: right; }

/* Phone "More" sheet */
.sheet { position: fixed; inset: 0; z-index: 12; }
.sheet-back { position: absolute; inset: 0; background: rgba(2, 6, 23, .5); }
.sheet-panel { position: absolute; left: 0; right: 0; bottom: 0; background: var(--surface); border-radius: 22px 22px 0 0; padding: 10px 16px calc(18px + env(safe-area-inset-bottom)); display: grid; gap: 12px; box-shadow: 0 -20px 50px rgba(0, 0, 0, .25); }
.sheet-grip { width: 40px; height: 4px; border-radius: 99px; background: var(--line); margin: 0 auto 4px; }
#more-nav { display: grid; gap: 2px; }
.sheet-toggle { padding: 10px 12px; background: var(--surface-2); border-radius: 12px; }

/* Desktop on a short screen: tighten the sidebar so it never needs to scroll. */
@media (min-width: 1101px) and (max-height: 800px) {
  .side { gap: 10px; padding: 16px 14px; }
  .nav-group { padding-top: 10px; }
  #nav a, #nav button { padding: 8px 12px; }
  .side-card p { display: none; }
  .side-card { padding: 10px 12px; }
}
@media (min-width: 1101px) and (max-height: 640px) { .side-card { display: none; } }

/* Tablet and small laptop: an icon rail. */
@media (max-width: 1100px) {
  .frame { padding: 12px; }
  .shell { grid-template-columns: 76px minmax(0, 1fr); border-radius: 22px; }
  .side { padding: 16px 10px; align-items: center; gap: 10px; }
  .side .brand { padding: 0 0 8px; }
  .brand-name, .nav-group, #nav .label, .side-card p, .side-card-head, .side-card .toggle > span:last-child { display: none; }
  #nav { align-items: center; gap: 4px; }
  #nav a, #nav button { position: relative; width: 48px; height: 44px; justify-content: center; padding: 0; }
  #nav .count { position: absolute; top: 3px; right: 2px; min-width: 16px; padding: 0 4px; font-size: 10px; line-height: 16px; }
  .side-card { padding: 6px; background: none; border: 0; }
  .top { padding: 16px 20px 12px; }
  .content { padding: 4px 20px 20px; }
  .search input { width: 190px; }
}
@media (max-width: 1100px) and (max-height: 560px) { .side-card { display: none; } }

/* Phone: content on top, a tab bar at the bottom, a compact header. */
@media (max-width: 700px) {
  .frame { padding: 0; }
  .shell { display: flex; flex-direction: column; border-radius: 0; border: 0; }
  .main { order: 1; flex: 1; }
  .side { order: 2; flex: none; flex-direction: row; align-items: stretch; gap: 0; padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); border-right: 0; border-top: 1px solid var(--line); }
  .side .brand, .side-card { display: none; }
  #nav { flex: 1; flex-direction: row; justify-content: space-around; gap: 0; }
  #nav [data-phone=hide] { display: none; }
  #nav a, #nav button { flex: 1; flex-direction: column; gap: 3px; width: auto; height: auto; padding: 6px 2px; font-size: 10.5px; font-weight: 600; border-radius: 12px; }
  #nav .short, #nav #more-btn { display: flex; }
  #nav a[aria-current=page] { background: none; color: var(--brand); }
  #nav a[aria-current=page] .i { color: var(--brand); }
  #nav .count { top: 1px; right: calc(50% - 20px); }
  .top { padding: 12px 16px 10px; gap: 10px; }
  .hello { flex: 1; gap: 10px; }
  .avatar { width: 36px; height: 36px; font-size: 14px; }
  .top h1 { font-size: 18px; }
  .top p { font-size: 12px; }
  .top-right { gap: 6px; }
  .icon-btn { width: 36px; height: 36px; }
  .bell-dot { top: 6px; right: 7px; }
  .search { display: none; }
  #search-btn { display: grid; }
  .top.searching .hello, .top.searching .top-right > :not(.search):not(#search-btn) { display: none; }
  .top.searching .top-right { flex: 1; }
  .top.searching .search { display: block; flex: 1; }
  .top.searching .search input { width: 100%; }
  .content { padding: 4px 16px 18px; }
  .notes { position: fixed; top: 60px; left: 12px; right: 12px; width: auto; max-width: none; }
}

/* Cards */
.grid { display: grid; gap: 16px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); min-width: 0; }
.card h2 { font-size: 15px; font-weight: 650; display: flex; align-items: center; gap: 8px; }
.card h2 .i { color: var(--soft); }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; }
.section { margin-top: 16px; }
.row-stats { grid-template-columns: minmax(0, 1.45fr) repeat(3, minmax(0, 1fr)); }
.row-main { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
.stack { display: grid; gap: 16px; align-content: start; }
@media (max-width: 1280px) { .row-stats { grid-template-columns: repeat(3, minmax(0, 1fr)); } .row-stats .hero { grid-column: 1 / -1; } }
@media (max-width: 900px) { .row-stats { grid-template-columns: 1fr 1fr; } .row-stats > .stat:last-child:nth-child(even) { grid-column: 1 / -1; } }
@media (max-width: 1060px) { .row-main { grid-template-columns: 1fr; } }
@media (max-width: 640px) { .row-stats { grid-template-columns: 1fr 1fr; } .row-stats > .stat:last-child:nth-child(even) { grid-column: 1 / -1; } }

/* Stat cards */
.stat { display: flex; flex-direction: column; }
.stat .foot { margin-top: auto; padding-top: 14px; }
.spark { display: block; width: 100%; height: 40px; overflow: visible; margin-bottom: 4px; }
.spark .line { fill: none; stroke: var(--brand); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.spark .area { fill: var(--brand); opacity: .08; }
.split { display: flex; gap: 2px; height: 8px; border-radius: 99px; overflow: hidden; background: var(--surface-2); }
.split span { display: block; height: 100%; }
.split-legend { display: flex; gap: 14px; margin-top: 8px; font-size: 12.5px; color: var(--soft); }
.split-legend b { color: var(--ink); font-weight: 650; }
.flex-card { display: flex; flex-direction: column; }
.flex-card > .donut-wrap { flex: 1; }
.chip { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; flex: none; background: var(--brand-subtle); color: var(--brand); }
.chip .i { width: 16px; height: 16px; }
.chip.good { background: var(--good-bg); color: var(--good); }
.chip.warn { background: var(--warn-bg); color: var(--warn); }
.chip.bad { background: var(--bad-bg); color: var(--bad); }
.stat .label { display: flex; align-items: center; gap: 9px; color: var(--ink); font-weight: 550; font-size: 13.5px; }
.stat .value { color: var(--ink); font-size: 30px; font-weight: 700; letter-spacing: -0.025em; margin: 16px 0 12px; font-variant-numeric: tabular-nums; line-height: 1.1; white-space: nowrap; }
.stat .value small { font-size: .55em; font-weight: 600; color: var(--soft); letter-spacing: 0; }
.trend-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 12.5px; color: var(--soft); }
.trend { display: inline-flex; align-items: center; gap: 4px; font-weight: 650; font-size: 12.5px; padding: 3px 8px; border-radius: 8px; background: var(--surface-2); color: var(--body); font-variant-numeric: tabular-nums; }
.trend .i { width: 13px; height: 13px; }
.trend.up { background: var(--good-bg); color: var(--good); }
.trend.down { background: var(--bad-bg); color: var(--bad); }
.hero { background: var(--hero); border-color: transparent; color: var(--night-soft); position: relative; overflow: hidden; }
.hero::before { content: ""; position: absolute; inset: 0; background: radial-gradient(60% 80% at 100% 0%, rgba(255, 255, 255, .18), transparent 60%); pointer-events: none; }
.hero::after { content: ""; position: absolute; right: -50px; bottom: -70px; width: 220px; height: 220px; border-radius: 50%; border: 28px solid rgba(255, 255, 255, .07); pointer-events: none; }
.hero > * { position: relative; z-index: 1; }
.hero .label { color: #fff; }
.hero .label .i { color: rgba(255, 255, 255, .8); }
.hero .value { color: #fff; font-size: 40px; }
.hero .value small { color: rgba(255, 255, 255, .72); }
.hero .trend-row { color: var(--night-soft); }
.hero .trend { background: rgba(255, 255, 255, .16); color: #fff; }
.hero .trend.up { background: rgba(255, 255, 255, .2); color: #fff; }
.hero .trend.down { background: rgba(15, 23, 42, .22); color: #fff; }
.hero .mini { display: flex; flex-wrap: wrap; gap: 8px 22px; margin-top: 16px; padding-top: 14px; border-top: 1px solid rgba(255, 255, 255, .18); font-size: 12.5px; }
.hero .mini b { display: block; color: #fff; font-size: 15px; font-variant-numeric: tabular-nums; }
.hero .badge { background: rgba(255, 255, 255, .2); color: #fff; }
.progress.on-hero { background: rgba(255, 255, 255, .2); margin: 14px 0 10px; }
.progress.on-hero span { background: #fff; }
.chip.sky { background: var(--brand-subtle); color: var(--brand-strong); }
@media (max-width: 640px) {
  .stat .value { font-size: 23px; }
  .hero .value { font-size: 32px; }
  .card { padding: 16px; }
}
body.masked .amt { filter: blur(7px); user-select: none; }

/* Insight card */
.insight { background: var(--deep); color: var(--night-soft); border-color: transparent; position: relative; overflow: hidden; display: flex; flex-direction: column; }
.insight h2 { color: var(--night-ink); font-size: 13.5px; }
.insight h2 .i { color: #93c5fd; }
.insight .msg { color: #fff; font-size: 18px; font-weight: 600; line-height: 1.35; margin: 14px 0 8px; letter-spacing: -0.01em; max-width: 30ch; }
.insight .why { font-size: 13px; margin: 0 0 16px; max-width: 40ch; }
.insight .btn.primary { background: #fff; border-color: #fff; color: #1d4ed8; align-self: flex-start; margin-top: auto; }
.insight .btn.primary:hover { background: #eff6ff; }
.insight .pager { display: flex; align-items: center; gap: 6px; }
.insight .pager button { appearance: none; border: 0; padding: 0; width: 7px; height: 7px; border-radius: 50%; background: rgba(255, 255, 255, .25); cursor: pointer; }
.insight .pager button[aria-current=true] { background: #fff; width: 18px; border-radius: 99px; }
.insight .glow { position: absolute; right: 18px; bottom: 18px; width: 64px; height: 64px; color: rgba(147, 197, 253, .35); }
.insight .glow svg { width: 100%; height: 100%; fill: none; stroke: currentColor; stroke-width: 1.2; }

/* Quick actions */
.actions-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.qa { appearance: none; display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 14px 6px 12px; border-radius: 14px; border: 1px solid var(--line); background: var(--surface-2); color: var(--ink); font: inherit; font-size: 12px; font-weight: 550; text-align: center; cursor: pointer; text-decoration: none; line-height: 1.25; }
.qa:hover { border-color: var(--brand); background: var(--brand-subtle); }
.qa .chip { width: 34px; height: 34px; background: var(--surface); border: 1px solid var(--line); }

/* Donut */
.donut-wrap { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 28px; align-items: center; }
@media (max-width: 640px) { .donut-wrap { grid-template-columns: 1fr; justify-items: center; } }
.donut { position: relative; width: 220px; height: 220px; }
.donut svg { width: 100%; height: 100%; display: block; }
.donut .seg { fill: none; stroke-width: 30; cursor: pointer; transition: opacity .15s; }
.donut .track { fill: none; stroke: var(--surface-2); stroke-width: 30; }
.donut.focus .seg:not(.on) { opacity: .28; }
.donut-center { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; pointer-events: none; }
.donut-center .k { font-size: 11.5px; color: var(--soft); }
.donut-center .v { font-size: 26px; font-weight: 700; color: var(--ink); font-variant-numeric: tabular-nums; line-height: 1.15; }
.donut-center .s { font-size: 12.5px; font-weight: 600; color: var(--ink); }
.legend-table { width: 100%; border-collapse: collapse; }
.legend-table td { padding: 11px 6px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.legend-table tr:last-child td { border-bottom: 0; }
.legend-table tr { cursor: default; }
.legend-table tr.on td { background: var(--surface-2); }
.legend-table .sw { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 10px; vertical-align: -1px; }
.legend-table .name { color: var(--ink); font-weight: 550; }
.legend-table .r { text-align: right; font-variant-numeric: tabular-nums; }
.sw.solo { background: var(--c-solo); } .sw.share { background: var(--c-share); } .sw.off { background: var(--c-off); } .sw.ended { background: var(--c-ended); }

/* Recent list */
.list { display: flex; flex-direction: column; }
.list-item { display: flex; align-items: center; gap: 12px; padding: 11px 0; border-bottom: 1px solid var(--line); min-width: 0; }
.list-item:last-child { border-bottom: 0; }
.list-item .chip { width: 38px; height: 38px; border-radius: 12px; }
.list-item .who { min-width: 0; flex: 1; }
.list-item .who b { display: block; color: var(--ink); font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-item .who span { font-size: 12px; color: var(--soft); }
.list-item .amount { font-weight: 650; font-variant-numeric: tabular-nums; white-space: nowrap; }
.amount.plus { color: var(--good); }
.amount.minus { color: var(--bad); }

/* Progress */
.progress { height: 10px; border-radius: 99px; background: var(--surface-2); overflow: hidden; margin: 14px 0 8px; }
.progress span { display: block; height: 100%; border-radius: 99px; background: linear-gradient(90deg, var(--brand-sky), var(--brand)); width: 0; }
.big { font-size: 30px; font-weight: 700; color: var(--ink); letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.big small { font-size: 15px; color: var(--soft); font-weight: 550; }

/* Notices */
.notice { display: flex; gap: 10px; align-items: center; background: var(--warn-bg); color: var(--warn); border-radius: 14px; padding: 12px 14px; margin-bottom: 16px; }
.notice.info { background: var(--brand-subtle); color: var(--brand); }
.notice b { color: inherit; }
.notice a { color: inherit; font-weight: 650; }

/* Bar chart */
.chart { position: relative; }
.chart svg { display: block; max-width: 100%; height: auto; overflow: visible; }
.chart .gridline { stroke: var(--grid); stroke-width: 1; }
.chart .axis-text { fill: var(--soft); font-size: 11px; font-variant-numeric: tabular-nums; }
.chart .bar { fill: var(--bar); }
.chart .bar.dim { opacity: .3; }
.chart .hit { fill: transparent; }
.chart .value-label { fill: var(--ink); font-size: 11.5px; font-weight: 650; font-variant-numeric: tabular-nums; }
.tip { position: absolute; pointer-events: none; background: var(--night); color: #f8fafc; border-radius: 11px; padding: 9px 11px; font-size: 12.5px; line-height: 1.55; white-space: nowrap; transform: translate(-50%, calc(-100% - 10px)); box-shadow: 0 12px 30px -10px rgba(0, 0, 0, .4); z-index: 2; }
.tip b { display: block; }
.tip .row { display: flex; justify-content: space-between; gap: 18px; font-variant-numeric: tabular-nums; }
.seg-ctl { display: inline-flex; background: var(--surface-2); border-radius: 11px; padding: 3px; gap: 2px; }
.seg-ctl button { appearance: none; border: 0; background: transparent; color: var(--soft); font: inherit; font-weight: 550; font-size: 12.5px; padding: 5px 11px; border-radius: 9px; cursor: pointer; }
.seg-ctl button[aria-pressed=true] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgba(0, 0, 0, .08); }

/* Key-value */
.kv { display: grid; grid-template-columns: auto 1fr; gap: 9px 16px; margin: 0; }
.kv dt { color: var(--soft); }
.kv dd { margin: 0; color: var(--ink); text-align: right; font-variant-numeric: tabular-nums; }

/* Tables */
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 14px; }
.toolbar input[type=search] { flex: 1 1 220px; }
.toolbar .spacer { flex: 1; }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); }
.card .table-wrap { box-shadow: none; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 12px 16px; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { font-size: 11.5px; font-weight: 650; color: var(--soft); text-transform: uppercase; letter-spacing: .05em; background: var(--surface-2); }
tbody tr:last-child td { border-bottom: 0; }
tbody tr.clickable { cursor: pointer; }
tbody tr.clickable:hover td { background: var(--surface-2); }
td.right, th.right { text-align: right; }
td.wrap { white-space: normal; }
.cell-who { display: flex; align-items: center; gap: 11px; }
.initial { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; font-weight: 650; font-size: 13px; background: var(--brand-subtle); color: var(--brand); flex: none; }
.initial.share { background: color-mix(in srgb, var(--c-share) 14%, transparent); color: var(--c-share); }
.empty { padding: 40px 16px; text-align: center; color: var(--soft); }
.more { display: flex; justify-content: center; padding: 12px; }

/* Badges: always text, never colour alone */
.badge { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 600; padding: 3px 9px; border-radius: 99px; background: var(--surface-2); color: var(--body); }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.good { background: var(--good-bg); color: var(--good); }
.badge.warn { background: var(--warn-bg); color: var(--warn); }
.badge.bad { background: var(--bad-bg); color: var(--bad); }
.badge.brand { background: var(--brand-subtle); color: var(--brand); }
.badge.plain::before { display: none; }

/* Setup checklist */
.checklist { list-style: none; margin: 0; padding: 0; }
.checklist li { display: grid; grid-template-columns: 30px 1fr; gap: 12px; padding: 16px 0; border-bottom: 1px solid var(--line); }
.checklist li:first-child { padding-top: 0; }
.checklist li:last-child { border-bottom: 0; padding-bottom: 0; }
.checklist .chip { width: 30px; height: 30px; }
.checklist b { color: var(--ink); }
.checklist p { margin: 4px 0 0; }

/* Drawer */
.drawer { position: fixed; inset: 0; z-index: 10; }
.drawer-back { position: absolute; inset: 0; background: rgba(2, 6, 23, .5); }
.drawer-panel { position: absolute; right: 0; top: 0; bottom: 0; width: min(580px, 100%); background: var(--bg); overflow-y: auto; padding: 20px; box-shadow: -20px 0 50px rgba(0, 0, 0, .25); }
.drawer-panel > header { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 16px; }
.drawer-panel h2 { font-size: 18px; overflow: hidden; text-overflow: ellipsis; }
.drawer-panel .card + .card { margin-top: 14px; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; }
.slot { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.slot:last-of-type { border-bottom: 0; }

.toast { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); background: var(--night); color: #f8fafc; padding: 11px 16px; border-radius: 12px; z-index: 20; box-shadow: 0 12px 30px -10px rgba(0, 0, 0, .4); max-width: calc(100% - 32px); }
.skeleton { height: 130px; border-radius: var(--radius); background: linear-gradient(90deg, var(--surface) 0%, var(--surface-2) 50%, var(--surface) 100%); background-size: 200% 100%; animation: shimmer 1.2s infinite linear; border: 1px solid var(--line); }
@keyframes shimmer { to { background-position: -200% 0; } }
@media (prefers-reduced-motion: reduce) { .skeleton { animation: none; } .toggle .track, .toggle .track::after { transition: none; } }

.legend-dot { display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-right: 6px; }
.health { grid-template-columns: 1fr 1fr; gap: 28px; }
@media (max-width: 640px) { .health { grid-template-columns: 1fr; gap: 9px; } }

/* Phone: tables become cards; each cell shows its column name (set by admin.js). */
@media (max-width: 700px) {
  .table-wrap { overflow: visible; }
  .table-wrap table, .table-wrap tbody, .table-wrap tr, .table-wrap td { display: block; width: 100%; }
  .table-wrap thead { display: none; }
  .table-wrap tr { padding: 12px 14px; border-bottom: 1px solid var(--line); }
  .table-wrap tbody tr:last-child { border-bottom: 0; }
  .table-wrap td { display: flex; justify-content: space-between; align-items: center; gap: 14px; padding: 4px 0; border: 0; white-space: normal; text-align: right; }
  .table-wrap td::before { content: attr(data-label); color: var(--soft); font-size: 12px; text-align: left; flex: none; }
  .table-wrap td:first-child { justify-content: flex-start; text-align: left; padding-bottom: 8px; }
  .table-wrap td:first-child::before, .table-wrap td[data-label=""]::before { display: none; }
  .table-wrap td.right { justify-content: space-between; }
  tbody tr.clickable:hover td { background: none; }
  .toolbar > * { flex: 1 1 auto; }
  .toolbar .spacer { display: none; }
  .donut { width: 200px; height: 200px; }
  .actions-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
  .qa { padding: 12px 4px 10px; font-size: 11.5px; }
}

/* Website page */
.period { margin-bottom: 14px; display: flex; justify-content: flex-end; }
.vitals { display: grid; gap: 4px; }
.vital { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 6px 12px; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--line); }
.vital:last-child { border-bottom: 0; }
.vital .name b { color: var(--ink); display: block; }
.vital .name span { font-size: 12px; color: var(--soft); }
.vital .val { text-align: right; font-weight: 700; color: var(--ink); font-variant-numeric: tabular-nums; }
.vital .dist { grid-column: 1 / -1; display: flex; gap: 2px; height: 8px; border-radius: 99px; overflow: hidden; background: var(--surface-2); }
.vital .dist span { display: block; height: 100%; }
.vital .dist .g { background: var(--good); } .vital .dist .n { background: var(--c-off); } .vital .dist .p { background: var(--bad); }
.vital .legend { grid-column: 1 / -1; display: flex; gap: 14px; font-size: 12px; color: var(--soft); }
.strip { display: grid; grid-template-columns: repeat(48, 1fr); gap: 2px; height: 34px; margin: 14px 0 6px; }
.strip span { border-radius: 3px; background: var(--surface-2); }
.strip .up { background: var(--good); opacity: .75; }
.strip .down { background: var(--bad); }
.strip-axis { display: flex; justify-content: space-between; font-size: 12px; color: var(--soft); }
.rank { display: grid; gap: 10px; }
.rank-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 12px; font-size: 13.5px; }
.rank-row .n { color: var(--ink); font-weight: 600; font-variant-numeric: tabular-nums; }
.rank-row .bar { grid-column: 1 / -1; height: 6px; border-radius: 99px; background: var(--surface-2); overflow: hidden; }
.rank-row .bar span { display: block; height: 100%; background: var(--bar); border-radius: 99px; }
.rank-row .k { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--body); }
#more-btn[data-current], #more-btn[data-current] .i { color: var(--brand); }

/* One-screen overview on desktop */
.content { display: flex; flex-direction: column; }
#view { flex: 1 0 auto; display: flex; flex-direction: column; }
.fill { display: flex; flex-direction: column; gap: 16px; }
.fill > .notice { margin: 0; }
.row-half { grid-template-columns: 1fr 1fr; }
@media (max-width: 900px) { .row-half { grid-template-columns: 1fr; } }
@media (min-width: 1101px) and (min-height: 760px) {
  .fill { flex: 1; min-height: 0; }
  .fill > .grow { flex: 1; min-height: 0; }
  .grow .stack { grid-template-rows: minmax(0, 1fr) auto; }
  .grow .flex-card .donut-wrap { align-content: center; }
  .updated { margin-top: 12px; }
}
/* Very wide screens: bigger donut and a little more air. */
@media (min-width: 1800px) {
  .donut { width: 260px; height: 260px; }
  .donut-wrap { grid-template-columns: 260px minmax(0, 1fr); gap: 48px; }
  .content { padding-left: 32px; padding-right: 32px; }
  .top { padding-left: 32px; padding-right: 32px; }
}

/* Large, high screens: draw everything bigger (like zooming the page) so the layout keeps the
   proportions it has on a normal desktop instead of stretching into empty space. */
/* Viewport heights are zoomed too, so the frame divides them back to fit the screen exactly. */
@media (min-width: 1900px) and (min-height: 1000px) { html { zoom: 1.2; } .frame { height: calc(100vh / 1.2); height: calc(100dvh / 1.2); } }
@media (min-width: 2300px) and (min-height: 1200px) { html { zoom: 1.33; } .frame { height: calc(100vh / 1.33); height: calc(100dvh / 1.33); } }

/* KPI cards: change badge top right, charts drawn at their real width, gentle entrance motion. */
.kpi-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.kpi-head .label { min-width: 0; }
.kpi-head .label > span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kpi-head .trend, .kpi-head .badge { flex: none; }
.kpi .label > span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kpi-value { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 14px 0 6px; }
.kpi-value .value { margin: 0; min-width: 0; }
.kpi-value .trend, .kpi-value .badge { flex: none; }
.kpi .trend-row b { color: var(--ink); font-weight: 650; }
.kchart { color: var(--brand); min-height: 56px; display: flex; align-items: flex-end; }
.kchart.tone-good { color: var(--c-share); }
.kchart.tone-sky { color: #0ea5e9; }
.kchart.tone-bad { color: var(--bad); }
.ksvg { display: block; overflow: visible; }
.ksvg .kghost { fill: none; stroke: currentColor; stroke-opacity: .22; stroke-width: 2.2; }
.ksvg .kline { fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.ksvg .kdot { fill: currentColor; stroke: var(--surface); stroke-width: 2; filter: drop-shadow(0 0 5px currentColor); }
.ksvg .kbar { fill: currentColor; opacity: .35; transform-box: fill-box; transform-origin: bottom; }
.ksvg .kbar.last { opacity: 1; }
.ksvg .ktarget { stroke: currentColor; stroke-opacity: .45; stroke-width: 1.3; stroke-dasharray: 5 4; }
.ksvg .ktarget-label { fill: var(--soft); font-size: 10px; font-weight: 600; letter-spacing: .02em; }
.ksvg.anim .kline { stroke-dasharray: 1; stroke-dashoffset: 1; animation: kdraw 1s cubic-bezier(.33, 0, .2, 1) forwards; }
.ksvg.anim .karea, .ksvg.anim .kdot { opacity: 0; animation: kfade .5s ease-out .7s forwards; }
.ksvg.anim .kbar { animation: kgrow .5s cubic-bezier(.22, 1, .36, 1) both; }
@keyframes kdraw { to { stroke-dashoffset: 0; } }
@keyframes kfade { to { opacity: 1; } }
@keyframes kgrow { from { transform: scaleY(.15); } to { transform: scaleY(1); } }
.ksvg.anim .kbar:nth-of-type(2) { animation-delay: 0.025s; }
.ksvg.anim .kbar:nth-of-type(3) { animation-delay: 0.050s; }
.ksvg.anim .kbar:nth-of-type(4) { animation-delay: 0.075s; }
.ksvg.anim .kbar:nth-of-type(5) { animation-delay: 0.100s; }
.ksvg.anim .kbar:nth-of-type(6) { animation-delay: 0.125s; }
.ksvg.anim .kbar:nth-of-type(7) { animation-delay: 0.150s; }
.ksvg.anim .kbar:nth-of-type(8) { animation-delay: 0.175s; }
.ksvg.anim .kbar:nth-of-type(9) { animation-delay: 0.200s; }
.ksvg.anim .kbar:nth-of-type(10) { animation-delay: 0.225s; }
.ksvg.anim .kbar:nth-of-type(11) { animation-delay: 0.250s; }
.ksvg.anim .kbar:nth-of-type(12) { animation-delay: 0.275s; }
.ksvg.anim .kbar:nth-of-type(13) { animation-delay: 0.300s; }
.ksvg.anim .kbar:nth-of-type(14) { animation-delay: 0.325s; }
.ksvg.anim .kbar:nth-of-type(15) { animation-delay: 0.350s; }
.ksvg.anim .kbar:nth-of-type(16) { animation-delay: 0.375s; }
.ksvg.anim .kbar:nth-of-type(17) { animation-delay: 0.400s; }
.ksvg.anim .kbar:nth-of-type(18) { animation-delay: 0.425s; }
.ksvg.anim .kbar:nth-of-type(19) { animation-delay: 0.450s; }
.ksvg.anim .kbar:nth-of-type(20) { animation-delay: 0.475s; }
.ksvg.anim .kbar:nth-of-type(21) { animation-delay: 0.500s; }
.ksvg.anim .kbar:nth-of-type(22) { animation-delay: 0.525s; }
.ksvg.anim .kbar:nth-of-type(23) { animation-delay: 0.550s; }
.ksvg.anim .kbar:nth-of-type(24) { animation-delay: 0.575s; }
.ksvg.anim .kbar:nth-of-type(25) { animation-delay: 0.600s; }
.ksvg.anim .kbar:nth-of-type(26) { animation-delay: 0.625s; }
.ksvg.anim .kbar:nth-of-type(27) { animation-delay: 0.650s; }
.ksvg.anim .kbar:nth-of-type(28) { animation-delay: 0.675s; }
.ksvg.anim .kbar:nth-of-type(29) { animation-delay: 0.700s; }
.ksvg.anim .kbar:nth-of-type(30) { animation-delay: 0.725s; }
.ksvg.anim .kbar:nth-of-type(31) { animation-delay: 0.750s; }
@media (prefers-reduced-motion: reduce) { .ksvg.anim .kline, .ksvg.anim .karea, .ksvg.anim .kdot, .ksvg.anim .kbar { animation: none; stroke-dashoffset: 0; } .ksvg.anim .karea, .ksvg.anim .kdot { opacity: 1; } } }
textarea { font: inherit; color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: 11px; padding: 10px 12px; width: 100%; resize: vertical; min-height: 140px; }
textarea:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
#tester-add { margin-top: 10px; }
