/* ==========================================================================
   Corvus Hub design system v2
   One token set, two modes. Dark is the default (:root); light is switched
   on with html[data-theme="light"]. Every page on base_v2.html inherits this
   file; nothing in here depends on a runtime Tailwind compile.
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. Tokens
   -------------------------------------------------------------------------- */
:root {
    color-scheme: dark;

    /* Type */
    --font-sans: "Geist", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Helvetica, Arial, sans-serif;
    --t-xs: 11px;
    --t-sm: 12px;
    --t-base: 13.5px;
    --t-md: 15px;
    --t-lg: 18px;
    --t-xl: 22px;
    --t-2xl: 28px;
    --t-3xl: 36px;

    /* Surfaces: background -> panel -> raised -> overlay, each a distinct step */
    --bg: #0c0d10;
    --panel: #141518;
    --raised: #1c1e23;
    --overlay: #24272d;
    --hover: rgba(255, 255, 255, 0.045);
    --line: rgba(255, 255, 255, 0.06);
    --line-strong: rgba(255, 255, 255, 0.11);

    /* Ink */
    --ink: #eeeff1;
    --ink-2: #a4a8ae;
    --ink-3: #7e848d;
    --ink-inverse: #0c0d10;

    /* Semantic: growth, US%, male%. Meaning is fixed. */
    --good: #3ecf8e;
    --warn: #e6b04a;
    --bad: #f0626d;
    --good-bg: rgba(62, 207, 142, 0.12);
    --warn-bg: rgba(230, 176, 74, 0.13);
    --bad-bg: rgba(240, 98, 109, 0.13);

    /* Chart series: neutral ink steps. Platforms are not identities. */
    --chart-1: #c9ccd2;
    --chart-2: #6c727b;

    /* Audience percentage buckets. LOCKED scale: same boundaries as
       pctClass() / pct_cell in grid.html. 90+ bright green, 80s darker
       green, 70s-50s orange steps, 40s-30s red steps, below 30 bright red. */
    --pct-90: #3ecf8e;
    --pct-80: #23a468;
    --pct-70: #f2c46a;
    --pct-60: #eaa43a;
    --pct-50: #e3842a;
    --pct-40: #f07a6e;
    --pct-30: #ec5a53;
    --pct-0:  #ff4646;

    /* Creator identity colors: the only identity colors in the UI.
       Every color clears 4.5:1 on the panel; names always sit beside them. */
    --c-lucia: #5c9eff;
    --c-lexie: #f3b539;
    --c-romy: #d885d6;
    --c-kayla: #0bccb7;
    --c-cherry: #fc6568;
    --c-katherine: #7da200;
    --creator: var(--ink-3);

    /* Depth: one soft shadow scale, top highlight in dark */
    --shadow-1: inset 0 1px 0 rgba(255, 255, 255, 0.035), 0 1px 2px rgba(0, 0, 0, 0.35);
    --shadow-2: inset 0 1px 0 rgba(255, 255, 255, 0.045), 0 8px 20px -8px rgba(0, 0, 0, 0.6);
    --shadow-3: inset 0 1px 0 rgba(255, 255, 255, 0.06), 0 24px 48px -16px rgba(0, 0, 0, 0.75);

    /* Radius scale with hierarchy */
    --r-sm: 6px;
    --r-md: 10px;
    --r-lg: 14px;
    --r-pill: 999px;

    /* Spacing (dense dashboard scale) */
    --s-1: 4px;
    --s-2: 8px;
    --s-3: 12px;
    --s-4: 16px;
    --s-5: 20px;
    --s-6: 24px;
    --s-8: 32px;

    /* Motion */
    --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
    --ease-std: cubic-bezier(0.4, 0, 0.2, 1);
    --dur-1: 120ms;
    --dur-2: 200ms;
    --dur-3: 420ms;

    /* Layout */
    --sidebar-w: 248px;
    --sidebar-w-min: 64px;
    --content-max: 1440px;
    --focus: rgba(238, 239, 241, 0.55);
}

html[data-theme="light"] {
    color-scheme: light;

    --bg: #eceef1;
    --panel: #f7f8fa;
    --raised: #ffffff;
    --overlay: #ffffff;
    --hover: rgba(16, 20, 28, 0.045);
    --line: rgba(16, 20, 28, 0.075);
    --line-strong: rgba(16, 20, 28, 0.14);

    --ink: #15171b;
    --ink-2: #5a6069;
    --ink-3: #6a7079;
    --ink-inverse: #f7f8fa;

    --good: #1a8f5a;
    --warn: #a56f06;
    --bad: #cf2f3f;
    --good-bg: rgba(26, 143, 90, 0.11);
    --warn-bg: rgba(165, 111, 6, 0.12);
    --bad-bg: rgba(207, 47, 63, 0.10);

    --chart-1: #30343b;
    --chart-2: #9ba1a9;

    --pct-90: #178a55;
    --pct-80: #1e6b45;
    --pct-70: #b3830c;
    --pct-60: #b06d08;
    --pct-50: #b1540b;
    --pct-40: #cb4d46;
    --pct-30: #c73a35;
    --pct-0:  #d61b1b;

    --c-lucia: #176cdc;
    --c-lexie: #a85d11;
    --c-romy: #b23797;
    --c-kayla: #147d86;
    --c-cherry: #cc2538;
    --c-katherine: #467d10;

    --shadow-1: 0 1px 2px rgba(22, 28, 44, 0.06), 0 0 0 1px rgba(22, 28, 44, 0.035);
    --shadow-2: 0 1px 2px rgba(22, 28, 44, 0.05), 0 10px 24px -10px rgba(22, 28, 44, 0.16);
    --shadow-3: 0 2px 4px rgba(22, 28, 44, 0.06), 0 28px 56px -18px rgba(22, 28, 44, 0.28);

    --focus: rgba(21, 23, 27, 0.5);
}

/* Creator color binding: any element with data-creator gets --creator */
[data-creator="lucia"]     { --creator: var(--c-lucia); }
[data-creator="lexie"]     { --creator: var(--c-lexie); }
[data-creator="romy"]      { --creator: var(--c-romy); }
[data-creator="kayla"]     { --creator: var(--c-kayla); }
[data-creator="cherry"]    { --creator: var(--c-cherry); }
[data-creator="katherine"] { --creator: var(--c-katherine); }

/* --------------------------------------------------------------------------
   2. Base
   -------------------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }

html {
    background: var(--bg);
    overflow-x: hidden;
    -webkit-text-size-adjust: 100%;
}

body {
    margin: 0;
    min-height: 100dvh;
    background: var(--bg);
    color: var(--ink);
    font-family: var(--font-sans);
    font-size: var(--t-base);
    line-height: 1.45;
    font-variant-numeric: tabular-nums;
    font-feature-settings: "tnum" 1, "ss01" 0;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
    -webkit-tap-highlight-color: transparent;
    overflow-x: hidden;
}

a { color: inherit; text-decoration: none; }
a:hover { color: var(--ink); }

button {
    font: inherit;
    color: inherit;
    background: none;
    border: 0;
    padding: 0;
    cursor: pointer;
}

:focus-visible {
    outline: 2px solid var(--focus);
    outline-offset: 2px;
    border-radius: var(--r-sm);
}

h1, h2, h3, p { margin: 0; }
h1 { font-size: var(--t-xl); font-weight: 600; letter-spacing: -0.02em; line-height: 1.2; }
h2 { font-size: var(--t-base); font-weight: 600; letter-spacing: -0.005em; }
.sub { color: var(--ink-2); font-size: var(--t-sm); }
.muted { color: var(--ink-3); }
.num { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }

/* Big numbers: tight tracking, tabular */
.big {
    font-size: var(--t-2xl);
    font-weight: 600;
    letter-spacing: -0.03em;
    line-height: 1.05;
    font-variant-numeric: tabular-nums;
}

/* Icons (Lucide). Reserve the box before the script swaps them in. */
i[data-lucide] { display: inline-block; width: 16px; height: 16px; vertical-align: -3px; }
svg.lucide { width: 16px; height: 16px; stroke-width: 1.75; flex-shrink: 0; }
.mono-icon svg { color: inherit !important; width: 14px; height: 14px; }

/* Scrollbars, both modes */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 5px; border: 2px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-thumb:hover { background: var(--ink-3); border: 2px solid transparent; background-clip: padding-box; }

.skip-link {
    position: absolute; left: -9999px; top: 8px; z-index: 100;
    background: var(--overlay); color: var(--ink); padding: 8px 12px; border-radius: var(--r-sm);
    box-shadow: var(--shadow-3);
}
.skip-link:focus { left: 8px; }

/* --------------------------------------------------------------------------
   3. Shell
   -------------------------------------------------------------------------- */
.shell { display: block; min-height: 100dvh; }

.sidebar {
    position: fixed; top: 0; left: 0; bottom: 0; z-index: 40;
    width: var(--sidebar-w);
    display: flex; flex-direction: column;
    background: var(--panel);
    box-shadow: 1px 0 0 var(--line);
    transition: width var(--dur-2) var(--ease-std), transform var(--dur-2) var(--ease-std);
    overflow: hidden;
}
.sidebar-scroll { flex: 1 1 auto; min-height: 0; overflow-y: auto; overflow-x: hidden; padding: 0 var(--s-2) var(--s-3); overscroll-behavior: contain; }
.sidebar-foot { flex: none; }

.brand {
    display: flex; align-items: center; gap: var(--s-2);
    height: 56px; padding: 0 var(--s-3) 0 var(--s-4);
}
.wordmark {
    display: inline-flex; align-items: center; gap: 8px;
    font-size: 16px; font-weight: 600; letter-spacing: -0.03em; color: var(--ink);
}
.wordmark-mark { display: block; width: 33px; height: 28px; flex-shrink: 0; }

/* App switcher */
.switcher { position: relative; margin-left: auto; }
.switcher-btn {
    display: inline-flex; align-items: center; gap: 4px;
    height: 26px; padding: 0 6px 0 8px; border-radius: var(--r-sm);
    font-size: var(--t-sm); font-weight: 500; color: var(--ink-2);
    background: var(--raised); box-shadow: var(--shadow-1);
    transition: color var(--dur-1), background var(--dur-1);
}
.switcher-btn:hover, .switcher-btn[aria-expanded="true"] { color: var(--ink); }
.switcher-btn svg { width: 14px; height: 14px; }
.popover {
    position: absolute; top: calc(100% + 6px); right: 0; z-index: 60;
    min-width: 180px; padding: 6px;
    background: var(--overlay); border-radius: var(--r-lg); box-shadow: var(--shadow-3);
    transform-origin: top right;
    animation: pop var(--dur-2) var(--ease-out);
}
.popover[hidden] { display: none; }
@keyframes pop { from { opacity: 0; transform: translateY(-4px) scale(0.98); } to { opacity: 1; transform: none; } }
.pop-title { padding: 6px 10px 4px; font-size: var(--t-xs); color: var(--ink-3); }
.pop-item {
    display: flex; align-items: center; gap: 8px;
    padding: 7px 10px; border-radius: var(--r-sm); font-size: var(--t-base); color: var(--ink-2);
    transition: background var(--dur-1), color var(--dur-1);
}
.pop-item:hover { background: var(--hover); color: var(--ink); }
.pop-item[aria-current="true"] { color: var(--ink); }
.pop-item .ext { margin-left: auto; color: var(--ink-3); width: 14px; height: 14px; }
.pop-item[aria-current="true"] .ext { color: var(--good); }

/* Nav */
.nav-group { padding-top: var(--s-4); }
.nav-group:first-child { padding-top: var(--s-2); }
.nav-title {
    padding: 0 10px 6px;
    font-size: var(--t-xs); font-weight: 500; color: var(--ink-3);
    white-space: nowrap;
}
.nav-item {
    display: flex; align-items: center; gap: 10px;
    height: 32px; padding: 0 10px; border-radius: var(--r-sm);
    color: var(--ink-2); font-size: var(--t-base); font-weight: 500;
    white-space: nowrap;
    transition: background var(--dur-1), color var(--dur-1);
}
.nav-item:hover { background: var(--hover); color: var(--ink); }
.nav-item[aria-current="page"] { background: var(--raised); color: var(--ink); box-shadow: var(--shadow-1); }
.nav-item svg { color: var(--ink-3); transition: color var(--dur-1); }
.nav-item:hover svg, .nav-item[aria-current="page"] svg { color: var(--ink); }
.nav-label { flex: 1; overflow: hidden; text-overflow: ellipsis; }
.nav-badge {
    margin-left: auto; min-width: 18px; height: 18px; padding: 0 6px; border-radius: var(--r-pill);
    background: var(--warn-bg); color: var(--warn); font-size: var(--t-xs); font-weight: 600;
    display: inline-flex; align-items: center; justify-content: center;
}

/* Creator initials, shown only when the sidebar is collapsed */
.nav-ini { display: none; }
.shell[data-collapsed="true"] .nav-item[data-creator] .dot { display: none; }
.shell[data-collapsed="true"] .nav-item .nav-ini {
    display: inline-flex; align-items: center; justify-content: center;
    min-width: 30px; height: 20px; padding: 0 5px; border-radius: 5px;
    font-size: 11px; font-weight: 600; line-height: 1; letter-spacing: 0.01em;
    color: var(--creator); background: color-mix(in srgb, var(--creator) 16%, transparent);
}

/* Creator dot */
.dot {
    display: inline-block; width: 8px; height: 8px; border-radius: 50%;
    background: var(--creator); flex-shrink: 0;
}
.nav-item .dot { margin: 0 4px; }

/* Sidebar footer */
.sidebar-foot {
    padding: var(--s-3) var(--s-2);
    display: flex; flex-direction: column; gap: 6px;
    box-shadow: 0 -1px 0 var(--line);
}
.foot-row { display: flex; align-items: center; gap: 6px; }

/* Segmented control (theme, ranges, periods) */
.seg {
    display: inline-flex; align-items: center; gap: 2px;
    padding: 2px; border-radius: calc(var(--r-sm) + 2px);
    background: var(--bg);
    box-shadow: inset 0 0 0 1px var(--line);
}
.seg > * {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    height: 24px; padding: 0 9px; border-radius: var(--r-sm);
    font-size: var(--t-sm); font-weight: 500; color: var(--ink-2);
    white-space: nowrap;
    transition: background var(--dur-2) var(--ease-out), color var(--dur-1), box-shadow var(--dur-2);
}
.seg > *:hover { color: var(--ink); }
.seg > [aria-pressed="true"], .seg > [aria-current="true"] {
    background: var(--raised); color: var(--ink); box-shadow: var(--shadow-1);
}
.seg svg { width: 14px; height: 14px; }
.seg-grow { flex: 1; }
.seg-grow > * { flex: 1; }

.icon-btn {
    display: inline-flex; align-items: center; justify-content: center;
    width: 28px; height: 28px; border-radius: var(--r-sm); color: var(--ink-3);
    transition: background var(--dur-1), color var(--dur-1);
}
.icon-btn:hover { background: var(--hover); color: var(--ink); }

/* Collapsed sidebar */
.shell[data-collapsed="true"] .sidebar { width: var(--sidebar-w-min); }
.shell[data-collapsed="true"] .sidebar-scroll { padding-left: 10px; padding-right: 10px; }
.shell[data-collapsed="true"] .brand { padding: 0; justify-content: center; }
.shell[data-collapsed="true"] .wordmark-mark { width: 32px; height: 27px; }
.shell[data-collapsed="true"] .wordmark-text,
.shell[data-collapsed="true"] .switcher,
.shell[data-collapsed="true"] .nav-label,
.shell[data-collapsed="true"] .nav-badge,
.shell[data-collapsed="true"] .nav-title,
.shell[data-collapsed="true"] .theme-seg,
.shell[data-collapsed="true"] .foot-label { display: none; }
.shell[data-collapsed="true"] .nav-group { padding-top: var(--s-3); position: relative; }
.shell[data-collapsed="true"] .nav-group + .nav-group::before {
    content: ""; display: block; height: 1px; margin: 0 8px 8px; background: var(--line);
}
.shell[data-collapsed="true"] .nav-item { justify-content: center; padding: 0; width: 44px; }
.shell[data-collapsed="true"] .nav-item .dot { margin: 0; width: 10px; height: 10px; }
.shell[data-collapsed="true"] .sidebar-foot { align-items: center; }
.shell[data-collapsed="true"] .foot-row { flex-direction: column; }
.shell[data-collapsed="true"] .theme-mini { display: inline-flex; }
.theme-mini { display: none; }

/* Main */
.main {
    margin-left: var(--sidebar-w);
    padding: var(--s-5) var(--s-6) var(--s-8);
    transition: margin-left var(--dur-2) var(--ease-std);
    min-width: 0;
}
.shell[data-collapsed="true"] .main { margin-left: var(--sidebar-w-min); }
.content { max-width: var(--content-max); margin: 0 auto; }
.content.full { max-width: none; }

.topbar { display: none; }
.backdrop {
    position: fixed; inset: 0; z-index: 35; background: rgba(0, 0, 0, 0.5);
    opacity: 0; pointer-events: none; transition: opacity var(--dur-2);
}
.shell[data-drawer="open"] .backdrop { opacity: 1; pointer-events: auto; }

.page-head {
    display: flex; align-items: flex-end; justify-content: space-between; gap: var(--s-4);
    margin-bottom: var(--s-5);
}
.page-head .sub { margin-top: 4px; }
.page-head > div:first-child { flex: 1 1 auto; min-width: 0; }
.page-head > .inline { flex: 0 0 auto; flex-wrap: nowrap; }

/* --------------------------------------------------------------------------
   4. Surfaces and components
   -------------------------------------------------------------------------- */
.panel {
    background: var(--panel);
    border-radius: var(--r-md);
    box-shadow: var(--shadow-1);
    min-width: 0;
}
.panel-head {
    display: flex; align-items: center; justify-content: space-between; gap: var(--s-3);
    padding: var(--s-3) var(--s-4) var(--s-2);
}
.panel-head h2 { display: inline-flex; align-items: center; gap: 8px; }
.panel-body { padding: 0 var(--s-4) var(--s-4); }
.panel-foot {
    padding: var(--s-2) var(--s-4) var(--s-3);
    box-shadow: inset 0 1px 0 var(--line);
    color: var(--ink-2); font-size: var(--t-sm);
    display: flex; align-items: center; gap: var(--s-3);
}

.grid { display: grid; gap: var(--s-3); }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.stack { display: flex; flex-direction: column; gap: var(--s-3); }

/* KPI strip */
.kpis {
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
}
.kpi {
    padding: var(--s-4) var(--s-4) var(--s-3);
    display: flex; flex-direction: column; gap: 6px; min-width: 0;
}
.kpi + .kpi { box-shadow: inset 1px 0 0 var(--line); }
.kpi-label { font-size: var(--t-sm); color: var(--ink-2); display: inline-flex; align-items: center; gap: 6px; }
.kpi-delta { font-size: var(--t-sm); min-height: 17px; }

/* Deltas */
.delta { font-variant-numeric: tabular-nums; white-space: nowrap; }
.delta.up { color: var(--good); }
.delta.down { color: var(--bad); }
.delta.flat { color: var(--ink-3); }

/* Audience percentages: the locked eight-bucket scale (see _pct.html) */
.pct-90 { color: var(--pct-90); }
.pct-80 { color: var(--pct-80); }
.pct-70 { color: var(--pct-70); }
.pct-60 { color: var(--pct-60); }
.pct-50 { color: var(--pct-50); }
.pct-40 { color: var(--pct-40); }
.pct-30 { color: var(--pct-30); }
.pct-0  { color: var(--pct-0); }
.pct-na { color: var(--ink-3); }

/* Chips */
.chip {
    display: inline-flex; align-items: center; gap: 6px;
    height: 22px; padding: 0 8px 0 7px; border-radius: var(--r-pill);
    background: var(--raised); box-shadow: var(--shadow-1);
    font-size: var(--t-sm); font-weight: 500; color: var(--ink);
    white-space: nowrap;
}
.chip .dot { width: 7px; height: 7px; }

.st {
    display: inline-flex; align-items: center; gap: 6px;
    height: 22px; padding: 0 8px; border-radius: var(--r-sm);
    font-size: var(--t-sm); font-weight: 500; white-space: nowrap;
    font-variant-numeric: tabular-nums; color: var(--ink-2);
}
.st b { font-weight: 600; }
.st svg { width: 12px; height: 12px; stroke-width: 2.5; }
.st-ok   { background: var(--good-bg); } .st-ok b, .st-ok svg { color: var(--good); }
.st-warn { background: var(--warn-bg); } .st-warn b, .st-warn svg { color: var(--warn); }
.st-miss { background: var(--bad-bg); }  .st-miss b, .st-miss svg { color: var(--bad); }

/* Tables */
.tbl-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.tbl { width: 100%; border-collapse: separate; border-spacing: 0; }
.tbl th {
    padding: 6px 12px 8px;
    font-size: var(--t-xs); font-weight: 500; color: var(--ink-3);
    text-align: left; white-space: nowrap;
    box-shadow: inset 0 -1px 0 var(--line);
}
.tbl th.num { text-align: right; }
.tbl td {
    padding: 9px 12px; font-size: var(--t-base); vertical-align: middle;
    box-shadow: inset 0 -1px 0 var(--line);
    white-space: nowrap;
}
.tbl tbody tr:last-child td { box-shadow: none; }
.tbl tbody tr { transition: background var(--dur-1); }
.tbl tbody tr:hover td { background: var(--hover); }
.tbl td:first-child, .tbl th:first-child { padding-left: var(--s-4); }
.tbl td:last-child, .tbl th:last-child { padding-right: var(--s-4); }
.tbl .strong { font-weight: 600; color: var(--ink); }
.tbl a:hover { text-decoration: underline; text-underline-offset: 3px; }

.rank { color: var(--ink-3); font-size: var(--t-sm); width: 28px; }
.rank-top {
    display: inline-flex; align-items: center; justify-content: center;
    width: 20px; height: 20px; border-radius: 6px;
    background: var(--raised); box-shadow: var(--shadow-1);
    color: var(--ink); font-size: var(--t-xs); font-weight: 600;
}

.who { display: inline-flex; align-items: center; gap: 8px; }
.who .dot { width: 7px; height: 7px; }

/* Weekly comparison: the mobile card layout is hidden until the 699px block below */
.cmp-mobile { display: none; }

/* Leaderboard, narrow screens: rank, dot, worker, score, views stay; the
   rest lives in a detail row opened by tapping the row. */
.lb-more { display: none; width: 28px; padding-left: 0 !important; color: var(--ink-3); }
.lb-more svg { width: 14px; height: 14px; transition: transform var(--dur-2) var(--ease-out); }
.lb-row[aria-expanded="true"] .lb-more svg { transform: rotate(180deg); }
.lb-detail { display: none; }
.lb-detail td { padding: 2px var(--s-4) 12px; white-space: normal; }
.lb-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px 12px; }
.lb-grid .k { font-size: var(--t-xs); color: var(--ink-3); margin-bottom: 2px; }
.lb-grid .v { font-size: var(--t-md); font-weight: 500; font-variant-numeric: tabular-nums; }
@media (max-width: 699px) {
    .hide-sm { display: none !important; }
    .show-sm { display: block; margin-top: 4px; }
    .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .tiles > .kpi:last-child:nth-child(odd) { grid-column: 1 / -1; }
    .control-sm { width: 80px; }
    .control-search { width: 100%; }
    .tbl td.trunc { max-width: 160px; }
    .tbl td.trunc .who { display: inline-flex; max-width: 100%; }
    .tbl td.trunc .who > span:last-child, .tbl td.trunc .who > a:last-child { overflow: hidden; text-overflow: ellipsis; }
    .tbl td.wrap-cell { white-space: nowrap; max-width: none; }
    .cmp-desktop { display: none; }
    .cmp-mobile { display: flex; flex-direction: column; gap: var(--s-3); padding: 0 var(--s-4) var(--s-4); }
    .cmp-wide, .cmp-card { background: var(--raised); border-radius: var(--r-md); box-shadow: var(--shadow-1); padding: var(--s-3) var(--s-4); }
    .cmp-wide { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
    .cmp-wide .k, .cmp-grid .k { font-size: var(--t-xs); color: var(--ink-3); }
    .cmp-wide .big { font-size: var(--t-xl); }
    .cmp-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 16px; margin-top: 10px; }
    .cmp-grid .span2 { grid-column: 1 / -1; }
    .cmp-grid .k { margin-bottom: 2px; }
    .cmp-grid .mbar { max-width: 100%; }
    .lb-tbl th:nth-child(n+5):not(.lb-more), .lb-tbl td:nth-child(n+5):not(.lb-more) { display: none; }
    .lb-tbl .lb-more { display: table-cell; }
    .lb-tbl tr.lb-row { cursor: pointer; }
    .lb-tbl tr.lb-detail:not([hidden]) { display: table-row; }
    .lb-tbl tr.lb-row[aria-expanded="true"] td { box-shadow: none; }
}

/* Sticky leading columns for narrow screens */
.tbl-sticky td:nth-child(1), .tbl-sticky th:nth-child(1),
.tbl-sticky td:nth-child(2), .tbl-sticky th:nth-child(2) {
    position: sticky; z-index: 1; background: var(--panel);
}
.tbl-sticky td:nth-child(1), .tbl-sticky th:nth-child(1) { left: 0; }
.tbl-sticky td:nth-child(2), .tbl-sticky th:nth-child(2) { left: 44px; }
.tbl-sticky tbody tr:hover td:nth-child(1), .tbl-sticky tbody tr:hover td:nth-child(2) {
    background: var(--panel);
    background-image: linear-gradient(var(--hover), var(--hover));
}

/* Charts */
.chart-box { position: relative; height: 220px; }
/* Trend sparkline: inline SVG stretched to its column (non-scaling 2px stroke),
   capped at 200px and right-aligned so the line always ends at the column edge. */
.tbl th.trend, .tbl td.trend { width: 200px; min-width: 140px; }
.spark-wrap { width: 100%; max-width: 200px; margin-left: auto; }
.spark { width: 100%; height: 32px; display: block; overflow: visible; }
.spark-line { fill: none; stroke: var(--creator); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; vector-effect: non-scaling-stroke; }

/* Weekly comparison: five equal columns on desktop; under 700px one stacked
   card per platform with a 2x2 metric grid, and the 7-day figure on its own row. */
.cmp-tbl { table-layout: fixed; }
.cmp-tbl th, .cmp-tbl td { width: 20%; }
.cmp-tbl td + td, .cmp-tbl th + th { box-shadow: inset 1px 0 0 var(--line), inset 0 -1px 0 var(--line); }
.cmp-tbl td { padding-top: 12px; padding-bottom: 12px; vertical-align: top; }
.cmp-tbl td.span { vertical-align: middle; box-shadow: inset 1px 0 0 var(--line); }
.cmp-tbl tbody tr:hover td { background: transparent; }

/* Mini comparison bars (prev vs current) */
.mbar { display: grid; grid-template-columns: 34px 1fr; row-gap: 3px; column-gap: 8px; align-items: center; width: 100%; max-width: 180px; margin-top: 6px; }
.mbar span { font-size: var(--t-xs); color: var(--ink-3); }
.mbar i { display: block; height: 4px; border-radius: 2px; background: var(--ink-3); opacity: 0.45; }
.mbar i.cur { background: var(--ink); opacity: 1; }

/* Metric cells in the weekly comparison */
.metric { display: flex; flex-direction: column; gap: 2px; }
.metric .val { font-size: var(--t-lg); font-weight: 600; letter-spacing: -0.02em; line-height: 1.1; }
.metric .cmp { font-size: var(--t-sm); }

/* Posting report cards */
.reports { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--s-3); }
.report {
    background: var(--raised); border-radius: var(--r-md); box-shadow: var(--shadow-1);
    padding: var(--s-3) var(--s-4);
    display: flex; flex-direction: column; gap: 8px; min-width: 0;
}
.report .who { font-weight: 600; }
.report-row { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.report-row .plat { color: var(--ink-3); display: inline-flex; margin-right: 2px; }

.empty {
    padding: var(--s-6) var(--s-4); text-align: center; color: var(--ink-3); font-size: var(--t-base);
}

/* Buttons */
.btn {
    display: inline-flex; align-items: center; gap: 6px;
    height: 28px; padding: 0 10px; border-radius: var(--r-sm);
    font-size: var(--t-sm); font-weight: 500; color: var(--ink-2);
    background: var(--raised); box-shadow: var(--shadow-1);
    transition: color var(--dur-1), transform var(--dur-1);
}
.btn:hover { color: var(--ink); }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--ink); color: var(--ink-inverse); box-shadow: none; }
.btn-primary:hover { color: var(--ink-inverse); opacity: 0.92; }

/* --------------------------------------------------------------------------
   4b. Shared components: forms, alerts, tiles, cards, utilities
   (every page on base_v2 uses these; no page-specific CSS)
   -------------------------------------------------------------------------- */

/* Semantic text utilities */
.c-good { color: var(--good); }
.c-warn { color: var(--warn); }
.c-bad  { color: var(--bad); }
.link { color: var(--ink); text-decoration: underline; text-decoration-color: var(--line-strong); text-underline-offset: 3px; }
.link:hover { text-decoration-color: var(--ink); }
.narrow { max-width: 720px; }
/* Columns and elements that step aside on narrow screens (below 700px) */
.hide-sm { }
.show-sm { display: none; }
.tbl td.wrap-cell { white-space: normal; font-size: var(--t-sm); max-width: 320px; }
.wide { max-width: 960px; }
.section + .section { margin-top: var(--s-4); }

/* Form kit */
.form { display: flex; flex-direction: column; gap: var(--s-4); }
.form-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s-4); }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.label { font-size: var(--t-sm); font-weight: 500; color: var(--ink-2); }
.label b { color: var(--ink); font-weight: 600; }
.hint { font-size: var(--t-xs); color: var(--ink-3); }
.control {
    width: 100%; min-height: 34px; padding: 6px 10px;
    font: inherit; font-size: var(--t-base); color: var(--ink);
    background: var(--raised); border: 1px solid var(--line-strong); border-radius: var(--r-sm);
    box-shadow: var(--shadow-1);
    transition: border-color var(--dur-1), box-shadow var(--dur-1);
}
.control::placeholder { color: var(--ink-3); }
.control:hover { border-color: var(--ink-3); }
.control:focus { outline: none; border-color: var(--ink-2); box-shadow: 0 0 0 3px color-mix(in srgb, var(--ink) 12%, transparent); }
textarea.control { min-height: 120px; resize: vertical; line-height: 1.5; }
.control.mono { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: var(--t-sm); }
select.control {
    appearance: none; padding-right: 30px; cursor: pointer;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%237e848d' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><path d='m6 9 6 6 6-6'/></svg>");
    background-repeat: no-repeat; background-position: right 8px center;
}
input[type="date"].control { width: auto; min-width: 180px; }
input[type="file"].control { padding: 5px 8px; cursor: pointer; }
input[type="file"].control::file-selector-button {
    font: inherit; font-size: var(--t-sm); font-weight: 500; color: var(--ink);
    background: var(--overlay); border: 0; border-radius: 4px; padding: 4px 10px; margin-right: 10px; cursor: pointer;
    box-shadow: var(--shadow-1);
}
.check { display: flex; align-items: flex-start; gap: 10px; font-size: var(--t-base); color: var(--ink-2); cursor: pointer; }
.check input { width: 16px; height: 16px; margin: 2px 0 0; accent-color: var(--ink); cursor: pointer; flex: none; }
.check b { color: var(--ink); font-weight: 600; }
.form-actions { display: flex; align-items: center; gap: var(--s-3); padding-top: var(--s-1); flex-wrap: wrap; }
.btn { height: 32px; padding: 0 14px; font-size: var(--t-base); white-space: nowrap; flex: none; }
.btn svg { width: 15px; height: 15px; }
.inline { display: flex; align-items: center; gap: var(--s-3); flex-wrap: wrap; }

/* Alerts (server results and flashes) */
.alert {
    display: flex; align-items: flex-start; gap: 10px;
    padding: 10px 14px; border-radius: var(--r-md);
    background: var(--raised); box-shadow: var(--shadow-1);
    font-size: var(--t-base); color: var(--ink-2); line-height: 1.5;
}
.alert svg { flex: none; margin-top: 2px; width: 16px; height: 16px; }
.alert b { color: var(--ink); font-weight: 600; }
.alert-ok svg { color: var(--good); }
.alert-err { background: var(--bad-bg); }
.alert-err svg { color: var(--bad); }
.alert-warn { background: var(--warn-bg); }
.alert-warn svg { color: var(--warn); }
.alert ul { margin: 4px 0 0; padding-left: 18px; }
.alert li { font-size: var(--t-sm); }
.alert + .alert { margin-top: var(--s-2); }
.stack-alerts { display: flex; flex-direction: column; gap: var(--s-2); margin-bottom: var(--s-4); }

/* Stat tiles: any count, hairlines in every direction, wraps cleanly */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 1px; background: var(--line); border-radius: var(--r-md); overflow: hidden; box-shadow: var(--shadow-1); }
.tiles > .kpi { background: var(--panel); box-shadow: none; }
.tiles > .kpi + .kpi { box-shadow: none; }

/* Cards (entity lists) */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: var(--s-3); }
.card {
    display: flex; flex-direction: column; gap: 10px; min-width: 0;
    padding: var(--s-4); border-radius: var(--r-md);
    background: var(--panel); box-shadow: var(--shadow-1);
    transition: background var(--dur-1), transform var(--dur-2) var(--ease-out), box-shadow var(--dur-2);
}
a.card:hover { background: var(--raised); transform: translateY(-1px); box-shadow: var(--shadow-2); color: inherit; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); }
.card-head .who { font-size: var(--t-md); }
.card-meta { display: flex; gap: var(--s-3); font-size: var(--t-sm); color: var(--ink-3); }
.card-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--s-2); }
.card-stats .v { font-size: var(--t-lg); font-weight: 600; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.card-stats .k { font-size: var(--t-xs); color: var(--ink-3); }
.num-md { font-size: var(--t-md); font-weight: 600; letter-spacing: -0.01em; font-variant-numeric: tabular-nums; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.chip-quiet { background: var(--bg); box-shadow: inset 0 0 0 1px var(--line); color: var(--ink-2); font-weight: 500; }
.chip-quiet .mono-icon svg { width: 12px; height: 12px; }
.st-idle { background: var(--raised); box-shadow: inset 0 0 0 1px var(--line); }
.st-idle b { color: var(--ink-2); }

/* Code sample */
.code {
    margin: 0; padding: 10px 12px; border-radius: var(--r-sm);
    background: var(--bg); box-shadow: inset 0 0 0 1px var(--line);
    font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: var(--t-sm); line-height: 1.55; color: var(--ink-2);
    overflow-x: auto; white-space: pre;
}

/* Role tags (users page): neutral, weight by role */
.tag { display: inline-flex; align-items: center; height: 20px; padding: 0 7px; border-radius: 5px; font-size: var(--t-xs); font-weight: 600; letter-spacing: 0.01em; background: var(--raised); box-shadow: inset 0 0 0 1px var(--line); color: var(--ink-2); }
.tag-admin { color: var(--ink); background: var(--overlay); }
.tag-supervisor { color: var(--ink); }

/* Inline mini-forms inside table rows (users: set password, delete) */
.row-actions { display: flex; align-items: center; justify-content: flex-end; gap: 6px; }
.row-actions form { display: flex; align-items: center; gap: 6px; margin: 0; }
.control-sm { min-height: 28px; height: 28px; padding: 0 8px; font-size: var(--t-sm); width: 130px; }
.btn-sm { height: 28px; padding: 0 10px; font-size: var(--t-sm); }
.btn-danger { color: var(--ink-3); }
.btn-danger:hover { color: var(--bad); background: var(--bad-bg); }
.btn-icon { width: 28px; padding: 0; justify-content: center; }

/* Definition list (post info) */
.dl { display: grid; grid-template-columns: 96px 1fr; gap: 8px 12px; margin: 0; font-size: var(--t-base); }
.dl dt { color: var(--ink-3); font-size: var(--t-sm); padding-top: 1px; }
.dl dd { margin: 0; color: var(--ink); min-width: 0; overflow-wrap: anywhere; }

/* Back link in a page head */
.back { display: inline-flex; align-items: center; gap: 4px; color: var(--ink-3); font-size: var(--t-sm); margin-bottom: 6px; }
.back:hover { color: var(--ink); }
.back svg { width: 14px; height: 14px; }

/* Media grid (post slides) */
.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: var(--s-3); }
.media { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.media-frame { aspect-ratio: 3 / 4; border-radius: var(--r-sm); overflow: hidden; background: var(--raised); box-shadow: var(--shadow-1); display: flex; align-items: center; justify-content: center; color: var(--ink-3); font-size: var(--t-sm); }
.media-frame img { width: 100%; height: 100%; object-fit: cover; display: block; }
.media-frame img[hidden] { display: none; }
.ocr { font-size: var(--t-sm); color: var(--ink-2); line-height: 1.45; padding: 8px 10px; background: var(--raised); border-radius: var(--r-sm); box-shadow: var(--shadow-1); }
.ocr .k { font-size: var(--t-xs); color: var(--ink-3); margin-bottom: 2px; }
.prose { color: var(--ink); line-height: 1.55; white-space: pre-wrap; overflow-wrap: anywhere; }
.thumb { display: block; width: 100%; border-radius: var(--r-md); box-shadow: var(--shadow-1); }
.layout-main { display: grid; grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr); gap: var(--s-4); align-items: start; }
.tier { display: inline-flex; align-items: center; gap: 5px; }
.tier svg { width: 14px; height: 14px; color: var(--warn); }

/* Compact inline stat forms (my area: one row per account) */
.row-form { display: grid; grid-template-columns: minmax(150px, 1.3fr) repeat(auto-fit, minmax(112px, 0.7fr)); gap: var(--s-3); align-items: end; padding: var(--s-3) var(--s-4); background: var(--raised); border-radius: var(--r-md); box-shadow: var(--shadow-1); }
.row-form .field .label { font-size: var(--t-xs); white-space: nowrap; }
.row-form .check span { white-space: nowrap; }
.row-form .control { min-height: 30px; height: 30px; padding: 0 8px; font-size: var(--t-sm); }
.row-form .check { align-self: center; font-size: var(--t-sm); }
.row-form .btn { align-self: end; }
.row-form + .row-form { margin-top: var(--s-2); }
.row-form .ident { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.row-form .ident .h { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-form .ident .m { font-size: var(--t-xs); color: var(--ink-3); }

/* Sortable table headers: the active column carries the direction icon */
.sort { display: inline-flex; align-items: center; gap: 4px; color: var(--ink-3); font-weight: 500; }
.sort:hover { color: var(--ink); }
.sort.active { color: var(--ink); }
.sort svg { width: 12px; height: 12px; stroke-width: 2; }

/* Filter bar (GET forms) and active-filter chips */
.filter-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: var(--s-3); }
.filter-chips { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.filter-chips .k { font-size: var(--t-xs); color: var(--ink-3); margin-right: 2px; }
.chip a.x { display: inline-flex; color: var(--ink-3); margin-left: 2px; }
.chip a.x:hover { color: var(--bad); }
.chip a.x svg { width: 12px; height: 12px; }
.range { width: 100%; accent-color: var(--ink); cursor: pointer; margin: 8px 0 0; }
.control-auto { width: auto; }
.control-search { width: 240px; }
.tbl th.act, .tbl td.act { width: 36px; padding-left: 0; }
.tag-strong { color: var(--ink); background: var(--overlay); }

/* Pager */
.pager { display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); padding: var(--s-3) var(--s-4); font-size: var(--t-sm); color: var(--ink-2); box-shadow: inset 0 1px 0 var(--line); }
.pager-nav { display: inline-flex; align-items: center; gap: 6px; }

/* Watchlist panel: a warn rule marks it apart from cold storage */
.panel-warn { box-shadow: var(--shadow-1), inset 3px 0 0 var(--warn); }
.panel-warn .panel-head h2 svg { color: var(--warn); }
.thumb-sm { display: block; width: 54px; height: 96px; object-fit: cover; border-radius: 6px; background: var(--raised); box-shadow: var(--shadow-1); }
.thumb-sm.none { display: flex; align-items: center; justify-content: center; font-size: var(--t-xs); color: var(--ink-3); }
.tbl td.ocr-cell { white-space: normal; max-width: 380px; line-height: 1.4; }

/* Daily post grid: sticky header row and sticky row header inside a scroll box */
.grid-scroll { max-height: 70vh; overflow: auto; overscroll-behavior: contain; }
.post-grid { border-collapse: separate; border-spacing: 0; font-size: var(--t-sm); min-width: 100%; font-variant-numeric: tabular-nums; }
.post-grid th, .post-grid td { padding: 6px 10px; text-align: center; white-space: nowrap; box-shadow: inset 0 -1px 0 var(--line); }
.post-grid thead th { position: sticky; top: 0; z-index: 2; background: var(--panel); font-weight: 500; color: var(--ink-2); box-shadow: inset 0 -1px 0 var(--line-strong); }
.post-grid thead th .h { display: block; color: var(--ink); font-weight: 500; }
.post-grid thead th .mono-icon svg { width: 12px; height: 12px; }
.post-grid .row-head { position: sticky; left: 0; z-index: 1; background: var(--panel); text-align: left; font-weight: 500; color: var(--ink); box-shadow: inset -1px 0 0 var(--line), inset 0 -1px 0 var(--line); }
.post-grid thead .row-head { z-index: 3; box-shadow: inset -1px 0 0 var(--line), inset 0 -1px 0 var(--line-strong); }
.post-grid td.total { font-weight: 600; color: var(--ink); }
.cnt { display: inline-block; min-width: 26px; padding: 1px 6px; border-radius: 4px; font-weight: 500; }
.cnt-0 { background: var(--bad-bg); color: var(--bad); }
.cnt-low { background: var(--warn-bg); color: var(--warn); }
.cnt-ok { background: var(--good-bg); color: var(--good); }
.cnt-hi { background: var(--good); color: var(--ink-inverse); font-weight: 600; }

/* Meter (pool level): native progress on the tokens, color by level */
.meter-row { display: grid; grid-template-columns: 120px 1fr 90px; gap: var(--s-3); align-items: center; }
.meter-row + .meter-row { margin-top: 8px; }
.meter-row .v { font-size: var(--t-sm); color: var(--ink-2); text-align: right; font-variant-numeric: tabular-nums; }
progress.meter { width: 100%; height: 8px; appearance: none; -webkit-appearance: none; border: 0; border-radius: 4px; background: var(--bg); box-shadow: inset 0 0 0 1px var(--line); overflow: hidden; }
progress.meter::-webkit-progress-bar { background: transparent; }
progress.meter::-webkit-progress-value { border-radius: 4px; background: var(--good); }
progress.meter::-moz-progress-bar { border-radius: 4px; background: var(--good); }
progress.meter-warn::-webkit-progress-value, progress.meter-warn::-moz-progress-bar { background: var(--warn); }
progress.meter-bad::-webkit-progress-value, progress.meter-bad::-moz-progress-bar { background: var(--bad); }

/* Heatmap (7 x 24): neutral ink at nine intensity steps, no inline styles */
.heat { border-collapse: separate; border-spacing: 2px; font-size: var(--t-xs); color: var(--ink-3); }
.heat th { font-weight: 500; text-align: center; padding: 0 0 2px; color: var(--ink-3); }
.heat th.d { text-align: left; padding-right: 6px; }
.heat td { width: 16px; height: 16px; padding: 0; }
.heat td i { display: block; width: 16px; height: 16px; border-radius: 3px; background: color-mix(in srgb, var(--ink) var(--heat, 0%), var(--raised)); }
.heat td i.h0 { --heat: 0%; } .heat td i.h1 { --heat: 12%; } .heat td i.h2 { --heat: 24%; } .heat td i.h3 { --heat: 36%; } .heat td i.h4 { --heat: 48%; }
.heat td i.h5 { --heat: 60%; } .heat td i.h6 { --heat: 72%; } .heat td i.h7 { --heat: 84%; } .heat td i.h8 { --heat: 100%; }

/* List rows (top hooks, anomalies): hairline-separated entries */
.rows { display: flex; flex-direction: column; }
.rows > div { padding: 10px 0; box-shadow: inset 0 -1px 0 var(--line); }
.rows > div:last-child { box-shadow: none; }
.rows .t { color: var(--ink); white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.45; }
.rows .m { font-size: var(--t-sm); color: var(--ink-3); margin-top: 3px; }

/* Row-level emphasis and inline field errors */
.tbl tr.row-flag td { background: var(--bad-bg); }
.field-error { display: none; font-size: var(--t-xs); color: var(--bad); }
.field.invalid .control { border-color: var(--bad); box-shadow: 0 0 0 3px var(--bad-bg); }
.field.invalid .field-error { display: block; }
.setting-toggle { display: grid; grid-template-columns: 1fr auto auto; gap: var(--s-3); align-items: center; padding: var(--s-3) var(--s-4); background: var(--raised); border-radius: var(--r-md); box-shadow: var(--shadow-1); }
.setting-toggle .k { font-weight: 600; color: var(--ink); }
.setting-toggle .hint { margin-top: 2px; }
.settings-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s-3) var(--s-4); }
.settings-grid .span2 { grid-column: 1 / -1; }

/* Auth pages (login, change password): brand mark over one centred panel */
.auth-wrap { min-height: 100dvh; display: grid; place-items: center; padding: var(--s-6) var(--s-4); }
.auth { width: 100%; max-width: 384px; display: flex; flex-direction: column; align-items: center; gap: var(--s-5); }
.auth-brand { display: flex; flex-direction: column; align-items: center; gap: 10px; }
.auth-brand img { display: block; width: 66px; height: 56px; }
.auth-word { font-size: 20px; font-weight: 600; letter-spacing: -0.03em; color: var(--ink); }
.auth-word span { color: var(--ink-3); font-weight: 500; }
.auth-panel { width: 100%; padding: var(--s-6); box-shadow: var(--shadow-2); }
.auth-panel h1 { font-size: var(--t-lg); }
.auth-panel .sub { margin: 4px 0 var(--s-5); }
.auth-panel .form { gap: var(--s-3); }
.control-lg { min-height: 40px; font-size: var(--t-md); }
.btn-lg { height: 40px; font-size: var(--t-md); justify-content: center; width: 100%; margin-top: var(--s-1); }
.auth-foot { display: flex; align-items: center; gap: var(--s-3); color: var(--ink-3); font-size: var(--t-sm); }
@media (max-width: 480px) { .auth-panel { padding: var(--s-5) var(--s-4); } }

/* Full-page empty state (404) */
.empty-page { display: flex; flex-direction: column; align-items: center; text-align: center; gap: var(--s-3); padding: 12vh var(--s-4) var(--s-8); }
.empty-page svg { width: 36px; height: 36px; color: var(--ink-3); stroke-width: 1.5; }
.empty-page h1 { font-size: var(--t-xl); }

/* --------------------------------------------------------------------------
   5. Motion
   -------------------------------------------------------------------------- */
.reveal {
    opacity: 0;
    transform: translateY(6px);
    animation: rise var(--dur-3) var(--ease-out) forwards;
    animation-delay: calc(var(--i, 0) * 45ms);
}
@keyframes rise { to { opacity: 1; transform: none; } }

html.theming, html.theming *, html.theming *::before, html.theming *::after {
    transition: background-color var(--dur-2) var(--ease-std), color var(--dur-2) var(--ease-std),
                box-shadow var(--dur-2) var(--ease-std), fill var(--dur-2) var(--ease-std) !important;
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
    .reveal { opacity: 1; transform: none; animation: none; }
}

/* --------------------------------------------------------------------------
   6. Responsive
   -------------------------------------------------------------------------- */
@media (max-width: 1180px) {
    .kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .kpi:nth-child(4) { box-shadow: inset 0 1px 0 var(--line); }
    .kpi:nth-child(n+5) { box-shadow: inset 1px 0 0 var(--line), inset 0 1px 0 var(--line); }
    .reports { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 900px) {
    .sidebar { transform: translateX(-100%); width: var(--sidebar-w) !important; box-shadow: var(--shadow-3); }
    .shell[data-drawer="open"] .sidebar { transform: none; }
    .shell[data-collapsed="true"] .sidebar-scroll { padding: 0 var(--s-2) var(--s-3); }
    .shell[data-collapsed="true"] .brand { padding: 0 var(--s-3) 0 var(--s-4); justify-content: flex-start; }
    .shell[data-collapsed="true"] .wordmark-text,
    .shell[data-collapsed="true"] .switcher,
    .shell[data-collapsed="true"] .nav-label,
    .shell[data-collapsed="true"] .nav-badge,
    .shell[data-collapsed="true"] .nav-title,
    .shell[data-collapsed="true"] .theme-seg,
    .shell[data-collapsed="true"] .foot-label { display: revert; }
    .shell[data-collapsed="true"] .nav-item { justify-content: flex-start; padding: 0 10px; width: auto; }
    .shell[data-collapsed="true"] .nav-item .nav-ini { display: none; }
    .shell[data-collapsed="true"] .nav-item[data-creator] .dot { display: inline-block; }
    .shell[data-collapsed="true"] .theme-mini { display: none; }
    .shell[data-collapsed="true"] .foot-row { flex-direction: row; }
    .shell[data-collapsed="true"] .nav-group + .nav-group::before { display: none; }
    .collapse-btn { display: none; }

    .topbar {
        display: flex; align-items: center; gap: var(--s-2);
        position: sticky; top: 0; z-index: 30;
        height: 52px; padding: 0 var(--s-3);
        background: var(--panel); box-shadow: 0 1px 0 var(--line);
    }
    .main { margin-left: 0 !important; padding: var(--s-3) var(--s-3) var(--s-6); }
    .page-head { margin-bottom: var(--s-3); flex-wrap: wrap; align-items: flex-start; }
    .page-head > .inline, .page-head > form { width: 100%; }
    .page-head .seg { flex-wrap: wrap; }
    .grid-2, .grid-3 { grid-template-columns: 1fr; }
    .form-row { grid-template-columns: 1fr; }
    .cards { grid-template-columns: 1fr; }
    .layout-main { grid-template-columns: 1fr; }
    .filter-grid { grid-template-columns: 1fr 1fr; }
    .meter-row { grid-template-columns: 90px 1fr 70px; }
    .settings-grid { grid-template-columns: 1fr; }
    .setting-toggle { grid-template-columns: 1fr; }
    .tbl td.ocr-cell { max-width: 200px; }
    .grid-scroll { max-height: 60vh; }
    .panel-head { flex-wrap: wrap; align-items: baseline; }
    .panel-head h2 { white-space: nowrap; }
    .row-form { grid-template-columns: 1fr 1fr; }
    .row-form .ident, .row-form .btn, .row-form .check { grid-column: 1 / -1; }
    .row-actions { flex-wrap: nowrap; justify-content: flex-start; }
    .dl { grid-template-columns: 84px 1fr; }
    .narrow, .wide { max-width: none; }
    .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .kpi { padding: var(--s-3); }
    .kpi:nth-child(n) { box-shadow: none; }
    .kpi:nth-child(even) { box-shadow: inset 1px 0 0 var(--line); }
    .kpi:nth-child(n+3) { box-shadow: inset 0 1px 0 var(--line); }
    .kpi:nth-child(even):nth-child(n+3) { box-shadow: inset 1px 0 0 var(--line), inset 0 1px 0 var(--line); }
    .big { font-size: var(--t-xl); }
    .reports { grid-template-columns: 1fr; }
    .chart-box { height: 190px; }
    .tbl td, .tbl th { padding-left: 10px; padding-right: 10px; }
    .spark-wrap { max-width: 120px; }
}
