/* ============================================================
   Admin panel — dark navy dashboard with neon gradients.
   Motion follows Emil Kowalski's rules: transform/opacity/clip-path only, strong ease-out,
   UI transitions under 300 ms, no hover-driven movement, a gentler path for reduced motion.
   ============================================================ */
:root {
  --bg: #12142a;
  --bg-2: #171a33;
  --sidebar: #161931;
  --panel: #1c2038;
  --panel-2: #222744;
  --panel-3: #2a3052;
  --hover: rgba(255, 255, 255, 0.045);
  --line: rgba(255, 255, 255, 0.07);
  --line-strong: rgba(255, 255, 255, 0.13);
  /* text: every level clears 4.5:1 on --panel-2 */
  --text: #eceefb;
  --muted: #a7acce;
  --faint: #8a90b8;
  /* accents on dark surfaces (lines, bars, icons) */
  --pink: #e86ee8;
  --violet: #9d6cf6;
  --violet-l: #c2a3ff;
  --cyan: #2ee6d6;
  --blue: #4b8ff7;
  --indigo: #5b6cf0;
  --green: #34d399;
  --orange: #fbbf6b;
  --red: #ff6b8b;
  --accent: var(--cyan);
  --accent-soft: rgba(46, 230, 214, 0.12);
  /* surfaces that carry white text: deep enough for 4.5:1 across the whole gradient */
  --g-pink: linear-gradient(135deg, #a63fc9 0%, #6f4fe0 100%);
  --g-cyan: linear-gradient(135deg, #0b7a8a 0%, #2c5fd0 100%);
  /* data fills (no text on them) */
  --g-fill: linear-gradient(90deg, #2ee6d6, #4b8ff7);
  --g-fill-pink: linear-gradient(90deg, #e86ee8, #9d6cf6);
  --g-bar: linear-gradient(180deg, #2ee6d6 0%, #7c5cf5 100%);
  --g-nav: linear-gradient(90deg, rgba(157, 108, 246, 0.4), rgba(157, 108, 246, 0.06));
  --blue-soft: rgba(75, 143, 247, 0.15);
  --violet-soft: rgba(157, 108, 246, 0.16);
  --green-soft: rgba(52, 211, 153, 0.14);
  --orange-soft: rgba(251, 191, 107, 0.14);
  --red-soft: rgba(255, 107, 139, 0.15);
  /* type roles: caption, label, small, body, title, page, metric, hero */
  --t-caption: 11px;
  --t-label: 12px;
  --t-small: 13px;
  --t-body: 14px;
  --t-title: 16px;
  --t-page-sm: 18px;
  --t-page: 20px;
  --t-metric-sm: 22px;
  --t-metric: 26px;
  --t-hero-sm: 32px;
  --t-hero: 36px;
  /* spacing: 4px base */
  --s-1: 4px; --s-2: 8px; --s-3: 12px; --s-4: 16px; --s-5: 20px; --s-6: 24px; --s-8: 32px;
  --radius: 16px;
  --radius-sm: 11px;
  --shadow: 0 14px 28px -18px rgba(0, 0, 0, 0.75);
  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
  --ease-in-out: cubic-bezier(0.77, 0, 0.175, 1);
  --ease-drawer: cubic-bezier(0.32, 0.72, 0, 1);
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
  --sans: "Inter", "Roboto", system-ui, -apple-system, "Segoe UI", sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body { background: var(--bg); color: var(--text); font: var(--t-body)/1.55 var(--sans); -webkit-font-smoothing: antialiased; overflow-x: hidden; caret-color: var(--pink); }
/* Large soft circles behind the layout, as in the reference. Static: painted once. */
body::before {
  content: ""; position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background:
    radial-gradient(42vmax 42vmax at -6% 4%, rgba(157, 108, 246, 0.15), transparent 62%),
    radial-gradient(36vmax 36vmax at 104% 100%, rgba(46, 230, 214, 0.07), transparent 62%),
    radial-gradient(30vmax 30vmax at 70% -10%, rgba(232, 110, 232, 0.06), transparent 60%),
    var(--bg);
}

a { color: var(--cyan); text-decoration: none; text-underline-offset: 3px; transition: color 150ms ease; }
::selection { background: rgba(157, 108, 246, 0.45); color: #fff; }
:focus-visible { outline: 2px solid var(--violet-l); outline-offset: 2px; border-radius: 6px; }
.hidden { display: none !important; }
h1, h2, h3, .hero-label { text-wrap: balance; }
p, .hint, .sub, .help { text-wrap: pretty; }
.mono { font-family: var(--mono); font-size: var(--t-label); }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.num { font-variant-numeric: tabular-nums; }
.spacer { flex: 1; }
svg { flex-shrink: 0; }
html { scrollbar-color: rgba(255, 255, 255, 0.14) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.1); border-radius: 10px; border: 2px solid transparent; background-clip: padding-box; }

/* Elevation is declared once: a filled surface with an offset shadow, no outline. */
.panel, .kpi-card, .mini, .toast, .modal, .palette { background: var(--panel); box-shadow: var(--shadow); }
.panel, .kpi-card { position: relative; }

/* ---------- layout ---------- */
.layout { display: grid; grid-template-columns: 236px minmax(0, 1fr); min-height: 100vh; }
.sidebar { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; background: var(--sidebar); border-right: 1px solid var(--line); z-index: 30; }
.brand { display: flex; align-items: center; gap: 11px; padding: 22px 20px 16px; }
.brand-logo { width: 34px; height: 34px; border-radius: 11px; flex-shrink: 0; display: grid; place-items: center; background: var(--g-pink); color: #fff; position: relative; }
.brand-logo svg { width: 15px; height: 15px; margin-left: 2px; }
.brand-logo::after { content: ""; position: absolute; right: -2px; bottom: -2px; width: 9px; height: 9px; border-radius: 50%; background: var(--green); border: 2px solid var(--sidebar); }
.brand-name { font-weight: 700; font-size: var(--t-title); letter-spacing: -0.01em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.brand-sub { font-size: var(--t-caption); color: var(--faint); }
.nav { padding: 2px 0 12px; overflow-y: auto; flex: 1; }
.nav-group { display: flex; align-items: center; gap: 9px; font-size: var(--t-caption); font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--pink); padding: 18px 22px 8px; }
.nav-group svg { width: 15px; height: 15px; }
.nav a { display: flex; align-items: center; gap: 10px; height: 36px; padding: 0 22px 0 48px; color: #c9cce8; font-weight: 500; font-size: var(--t-small); position: relative; transition: background-color 150ms ease, color 150ms ease; }
.nav a:focus-visible { outline-offset: -2px; border-radius: 0; }
.nav a.active { color: #fff; background: var(--g-nav); }
.nav a.active::before { content: ""; position: absolute; left: 0; top: 50%; width: 0; height: 0; transform: translateY(-50%); border-top: 9px solid transparent; border-bottom: 9px solid transparent; border-left: 9px solid var(--violet); }
.nav .icon { display: none; }
.nav .count { margin-left: auto; font-size: var(--t-caption); color: var(--faint); font-variant-numeric: tabular-nums; }
.nav .count.hot { color: #fff; background: var(--g-pink); padding: 0 8px; border-radius: 99px; line-height: 18px; font-weight: 600; }
.sidebar-cta { margin: 6px 18px 12px; }
.sidebar-cta .label { font-size: var(--t-label); font-weight: 600; margin-bottom: 2px; }
.sidebar-cta .sub { font-size: var(--t-caption); color: var(--faint); margin-bottom: 10px; }
.sidebar-cta .btn { width: 100%; justify-content: space-between; }
.sidebar-clock { padding: 0 22px 10px; display: flex; justify-content: space-between; font-size: var(--t-caption); color: var(--faint); font-variant-numeric: tabular-nums; }
.sidebar-foot { padding: 12px 18px; border-top: 1px solid var(--line); display: flex; align-items: center; gap: 10px; }
.sidebar-foot .who { flex: 1; min-width: 0; }
.sidebar-foot .who b { display: block; font-size: var(--t-small); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-foot .who span { font-size: var(--t-caption); color: var(--faint); }
.sidebar-backdrop { display: none; }

.main { min-width: 0; display: flex; flex-direction: column; }
/* Solid, not blurred: a backdrop-filter under a sticky bar repaints on every scroll frame. */
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: var(--s-4); padding: var(--s-4) var(--s-8); background: rgba(18, 20, 42, 0.97); border-bottom: 1px solid var(--line); }
.topbar h1 { margin: 0; font-size: var(--t-page); font-weight: 700; letter-spacing: -0.015em; text-wrap: balance; }
.topbar p { margin: 1px 0 0; color: var(--faint); font-size: var(--t-label); }
.topbar-tools { display: flex; align-items: center; gap: 8px; }
.btn.menu-toggle { display: none; }
.content { padding: var(--s-6) var(--s-8) 48px; }
/* Route change: one quick crossfade, no staggered choreography. */
.content > * { animation: fade 160ms var(--ease-out) both; }
@keyframes fade { from { opacity: 0; } }
#page-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }

/* ---------- panels & grids ---------- */
.panel { border-radius: var(--radius); }
.content > * + *, .grid + .grid, .grid + .panel, .panel + .panel, .panel + .grid, .dash + .grid { margin-top: var(--s-5); }
.panel-head { display: flex; align-items: baseline; gap: var(--s-2) var(--s-3); padding: var(--s-5) var(--s-5) var(--s-1); flex-wrap: wrap; }
.panel-head h2 { margin: 0; font-size: var(--t-title); font-weight: 650; letter-spacing: -0.01em; text-wrap: balance; }
.panel-head .sub { font-size: var(--t-label); color: var(--faint); }
.panel-head + .table-wrap, .panel-head + .empty { border-top: 1px solid var(--line); margin-top: 12px; }
.panel-body { padding: var(--s-3) var(--s-5) var(--s-5); }
.panel-note { font-size: var(--t-label); color: var(--faint); margin-left: auto; }
.grid { display: grid; gap: var(--s-5); }
.grid.kpi { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.grid.two { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
.grid.half { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.four { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid.top { align-items: start; }

.kpi-card { border-radius: var(--radius); padding: var(--s-5) var(--s-5) var(--s-4); overflow: hidden; --c: var(--cyan); }
/* A row of metrics reads as one summary: a single surface, metrics split by hairlines. Hairlines on
   the strip's outer edges are clipped away, so wrapping rows never show a stray line. */
.grid.kpi { gap: 0; background: var(--panel); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.grid.kpi > .kpi-card { background: none; box-shadow: -1px 0 0 var(--line), 0 -1px 0 var(--line); border-radius: 0; }
.kpi-card .mark { width: 24px; height: 4px; border-radius: 4px; background: var(--c); margin-bottom: 14px; }
.kpi-card .label { font-size: var(--t-label); color: var(--muted); }
.kpi-card .value { font-size: var(--t-metric); font-weight: 700; letter-spacing: -0.02em; margin-top: 2px; font-variant-numeric: tabular-nums; line-height: 1.2; }
.kpi-card .value small { font-size: var(--t-body); color: var(--muted); font-weight: 600; margin: 0 3px; }
.kpi-card .hint { font-size: var(--t-label); color: var(--faint); margin-top: 4px; }
.kpi-card .hint b { color: var(--muted); font-weight: 600; }
.kpi-card.c-blue { --c: var(--blue); } .kpi-card.c-violet { --c: var(--violet); } .kpi-card.c-green { --c: var(--green); }
.kpi-card.c-orange, .kpi-card.c-amber { --c: var(--orange); } .kpi-card.c-red { --c: var(--red); } .kpi-card.c-pink { --c: var(--pink); } .kpi-card.c-cyan { --c: var(--cyan); }

/* ---------- dashboard ---------- */
.dash { display: grid; grid-template-columns: minmax(0, 1fr) minmax(300px, 30%); gap: var(--s-5); align-items: stretch; }
.dash-main, .dash-side { display: flex; flex-direction: column; gap: var(--s-5); min-width: 0; }
.dash-main > .grid { margin-top: 0; }
.dash-side .grow { flex: 1; display: flex; flex-direction: column; }
.dash-side .grow .panel-body { flex: 1; display: flex; }
.dash-side .grow .vb { flex: 1; }
.dash-top { display: grid; grid-template-columns: 1fr 1fr minmax(200px, 0.95fr); gap: var(--s-5); }
.hero { position: relative; overflow: hidden; border-radius: var(--radius); padding: 22px 24px; color: #fff; min-height: 128px; display: flex; flex-direction: column; box-shadow: 0 18px 32px -20px var(--glow); }
.hero.pink { background: var(--g-pink); --glow: rgba(166, 63, 201, 0.9); }
.hero.cyan { background: var(--g-cyan); --glow: rgba(11, 122, 138, 0.9); }
.hero-orb { position: absolute; width: 140px; height: 140px; border-radius: 50%; right: -38px; bottom: -58px; background: rgba(255, 255, 255, 0.1); }
.hero-orb.two { width: 90px; height: 90px; right: 54px; bottom: -48px; background: rgba(255, 255, 255, 0.07); }
.hero-label { font-size: var(--t-small); font-weight: 500; position: relative; }
.hero-value { font-size: var(--t-hero); font-weight: 700; letter-spacing: -0.02em; line-height: 1.1; margin-top: 12px; font-variant-numeric: tabular-nums; position: relative; }
.hero-value small { font-size: var(--t-title); font-weight: 500; opacity: 0.85; margin-left: 6px; }
.hero-foot { margin-top: auto; padding-top: 10px; font-size: var(--t-label); display: flex; align-items: center; gap: 8px; position: relative; flex-wrap: wrap; }
.hero .trend { background: rgba(255, 255, 255, 0.2); color: #fff; }
.mini-stack { display: flex; flex-direction: column; gap: var(--s-4); }
.mini { flex: 1; display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: var(--radius); min-width: 0; }
.mini-ico { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; background: var(--c); color: #fff; flex-shrink: 0; }
.mini-ico svg { width: 17px; height: 17px; }
.mini-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.mini-text span { font-size: var(--t-label); color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mini-text b { font-size: var(--t-page); line-height: 1.25; font-variant-numeric: tabular-nums; }
.trend { font-size: var(--t-caption); font-weight: 700; padding: 3px 9px; border-radius: 8px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.trend.up { color: #5ff2c0; background: var(--green-soft); }
.trend.down { color: #ff9db3; background: var(--red-soft); }
.side-foot { display: flex; justify-content: space-between; gap: 10px; margin-top: 14px; padding: 11px 14px; border-radius: 12px; background: var(--panel-2); font-size: var(--t-label); color: var(--muted); }
.side-foot b { color: var(--text); font-weight: 600; }
.donut-row { display: flex; align-items: center; gap: 22px; }
.legend { display: flex; gap: 16px; font-size: var(--t-label); color: var(--muted); flex-wrap: wrap; }
.legend i { display: inline-block; width: 18px; height: 2px; border-radius: 2px; margin-right: 7px; vertical-align: middle; background: var(--c); }
.legend .dashed i { background: repeating-linear-gradient(90deg, var(--c) 0 3px, transparent 3px 6px); }

/* line / area chart */
.lc { position: relative; display: grid; grid-template-columns: auto minmax(0, 1fr); grid-template-rows: var(--h) auto; column-gap: 10px; }
.lc:not(.with-axis) { grid-template-columns: minmax(0, 1fr); }
.lc-y { display: flex; flex-direction: column; justify-content: space-between; font-size: var(--t-caption); color: var(--faint); text-align: right; font-variant-numeric: tabular-nums; }
.lc-y span { transform: translateY(-50%); }
.lc-y span:last-child { transform: none; }
.lc-plot { position: relative; height: var(--h); min-width: 0; touch-action: pan-y; cursor: crosshair; }
.lc-plot svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.lc-grid { stroke: rgba(255, 255, 255, 0.06); stroke-width: 1; vector-effect: non-scaling-stroke; }
/* New data morphs the curve in place: on-screen movement, so ease-in-out. */
.lc-line { fill: none; stroke-width: 2.4; stroke-linecap: round; vector-effect: non-scaling-stroke; transition: d 500ms var(--ease-in-out); }
.lc-line.dashed { stroke-dasharray: 3 5; stroke-width: 2; }
.lc-area { transition: d 500ms var(--ease-in-out); }
/* The dashboard's one authored moment: the curves draw in once, on first paint. */
.lc-reveal { transform-origin: left center; animation: reveal 700ms var(--ease-out) both; }
@keyframes reveal { from { transform: scaleX(0); } }
.lc-x { grid-column: 2; position: relative; height: 22px; font-size: var(--t-caption); color: var(--faint); }
.lc:not(.with-axis) .lc-x { grid-column: 1; }
.lc-x span { position: absolute; top: 6px; transform: translateX(-50%); white-space: nowrap; font-variant-numeric: tabular-nums; }
.lc-x span:first-child { transform: none; }
.lc-x span:last-child { transform: translateX(-100%); }
.lc-x span.skip { display: none; }
.lc-dot { position: absolute; width: 12px; height: 12px; margin: -6px 0 0 -6px; border-radius: 50%; background: var(--c); border: 3px solid rgba(255, 255, 255, 0.85); }
.lc-pill { position: absolute; transform: translate(-50%, calc(-100% - 14px)); background: var(--g-pink); color: #fff; font-size: var(--t-label); font-weight: 600; padding: 5px 10px; border-radius: 7px; white-space: nowrap; pointer-events: none; animation: fade 200ms 500ms var(--ease-out) both; }
.lc-pill::after { content: ""; position: absolute; left: 50%; bottom: -5px; margin-left: -5px; border: 5px solid transparent; border-bottom: 0; border-top-color: #8a47d5; }
.lc-guide { position: absolute; top: 0; bottom: 0; width: 1px; background: rgba(255, 255, 255, 0.28); opacity: 0; transition: opacity 120ms ease; pointer-events: none; }
.lc-tip { position: absolute; top: 6px; transform: translateX(-50%); min-width: 140px; padding: 9px 11px; border-radius: 10px; background: #14172e; border: 1px solid var(--line-strong); font-size: var(--t-label); opacity: 0; transition: opacity 120ms ease; pointer-events: none; z-index: 3; }
.lc-tip b { display: block; margin-bottom: 4px; }
.lc-tip div { display: flex; align-items: center; gap: 7px; color: var(--muted); }
.lc-tip div span { margin-left: auto; color: var(--text); font-weight: 600; font-variant-numeric: tabular-nums; }
.lc-tip i { width: 8px; height: 8px; border-radius: 50%; background: var(--c); }
.lc.hover .lc-guide, .lc.hover .lc-tip { opacity: 1; }

/* donut: segments re-proportion smoothly when the data changes */
.dn { position: relative; width: var(--size); height: var(--size); flex-shrink: 0; }
.dn svg { width: 100%; height: 100%; }
.dn-track { fill: none; stroke: rgba(255, 255, 255, 0.05); }
.dn-seg { fill: none; transition: stroke-dasharray 500ms var(--ease-in-out), stroke-dashoffset 500ms var(--ease-in-out); }
.dn-center { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; }
.dn-center b { font-size: var(--t-page); font-weight: 700; font-variant-numeric: tabular-nums; }
.dn-center span { font-size: var(--t-caption); color: var(--faint); }
.lg { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 9px; }
.lg-row { display: grid; grid-template-columns: auto minmax(0, 1fr) auto auto; align-items: center; gap: 9px; font-size: var(--t-small); }
.lg-row i { width: 14px; height: 14px; border-radius: 50%; border: 3px solid var(--c); }
.lg-row span { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lg-row b { font-variant-numeric: tabular-nums; font-weight: 600; }
.lg-row em { font-style: normal; font-size: var(--t-caption); color: var(--faint); min-width: 32px; text-align: right; }

/* vertical bars: full-height gradient revealed by clip-path, so height changes stay off layout */
.vb { position: relative; display: flex; align-items: stretch; gap: 10px; min-height: var(--h); padding-bottom: 22px; }
.vb-grid { position: absolute; inset: 0 0 22px; display: flex; flex-direction: column; justify-content: space-between; pointer-events: none; }
.vb-grid i { height: 1px; background: rgba(255, 255, 255, 0.05); }
.vb-col { flex: 1; display: flex; flex-direction: column; align-items: center; position: relative; min-width: 0; }
.vb-track { flex: 1; width: 100%; position: relative; }
.vb-bar { position: absolute; left: 50%; bottom: 0; width: min(26px, 70%); height: 100%; transform: translateX(-50%); background: var(--g-bar); clip-path: inset(var(--top) 0 0 0 round 6px 6px 3px 3px); transition: clip-path 500ms var(--ease-in-out); }
.vb-tip { position: absolute; left: 50%; bottom: calc(100% - var(--top) + 6px); transform: translate(-50%, 4px); background: #14172e; border: 1px solid var(--line-strong); padding: 3px 8px; border-radius: 7px; font-size: var(--t-caption); font-weight: 600; opacity: 0; transition: opacity 150ms ease, transform 150ms var(--ease-out); white-space: nowrap; pointer-events: none; }
.vb-label { position: absolute; bottom: -20px; font-size: var(--t-caption); color: var(--faint); }

/* ---------- forms ---------- */
.filters { display: grid; grid-template-columns: 2fr repeat(3, 1fr) auto; gap: 12px; align-items: end; padding: 16px 20px; }
.field label, .label-sm { display: block; font-size: var(--t-label); color: var(--muted); margin-bottom: 6px; font-weight: 500; }
input, select, textarea { width: 100%; background: var(--panel-2); color: var(--text); border: 1px solid var(--line-strong); border-radius: var(--radius-sm); padding: 9px 12px; font: inherit; outline: none; transition: border-color 150ms ease, box-shadow 150ms ease; }
input::placeholder, textarea::placeholder { color: var(--faint); }
input:focus, select:focus, textarea:focus { border-color: rgba(194, 163, 255, 0.75); box-shadow: 0 0 0 3px rgba(157, 108, 246, 0.22); }
input:focus-visible, select:focus-visible, textarea:focus-visible { outline: none; }
select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23a7acce' stroke-width='2.4' stroke-linecap='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 34px; }
select option, select optgroup { background: var(--panel-2); }
textarea { resize: vertical; min-height: 120px; line-height: 1.55; }
input[type="checkbox"], input[type="radio"] { width: 16px; height: 16px; accent-color: var(--violet); margin: 0; flex-shrink: 0; }
input:disabled, select:disabled, textarea:disabled { opacity: 0.5; cursor: not-allowed; }
.total { color: var(--faint); font-size: var(--t-label); white-space: nowrap; padding-bottom: 10px; }
.total b { color: var(--text); font-variant-numeric: tabular-nums; }
.check { display: flex; align-items: center; gap: 9px; font-size: var(--t-small); cursor: pointer; user-select: none; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 14px; align-items: end; }
.recipients { display: flex; flex-wrap: wrap; gap: 8px 16px; }
.toggle { position: relative; display: inline-flex; align-items: center; gap: 10px; cursor: pointer; user-select: none; }
.toggle input { position: absolute; opacity: 0; pointer-events: none; }
.toggle .track { width: 38px; height: 22px; border-radius: 99px; background: var(--panel-3); box-shadow: inset 0 0 0 1px var(--line-strong); position: relative; transition: background-color 200ms ease; flex-shrink: 0; }
.toggle .track::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #c9cce6; transition: transform 200ms var(--ease-out), background-color 200ms ease; }
.toggle input:checked + .track { background: #7c4ce8; }
.toggle input:checked + .track::after { transform: translateX(16px); background: #fff; }
.toggle input:focus-visible + .track { outline: 2px solid var(--violet-l); outline-offset: 2px; }

/* ---------- buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; height: 36px; padding: 0 16px; border-radius: var(--radius-sm); border: 1px solid var(--line-strong); background: var(--panel-2); color: var(--text); font: inherit; font-weight: 600; cursor: pointer; white-space: nowrap; transition: transform 160ms var(--ease-out), background-color 150ms ease, border-color 150ms ease, opacity 150ms ease; -webkit-tap-highlight-color: transparent; }
.btn svg { width: 15px; height: 15px; }
/* Press feedback: the label and icon go down with the button. */
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }
.btn.primary { background: var(--g-pink); border-color: transparent; color: #fff; }
.btn.danger { color: #ff9db3; border-color: rgba(255, 107, 139, 0.32); background: rgba(255, 107, 139, 0.07); }
.btn.small { height: 30px; padding: 0 12px; font-size: var(--t-label); border-radius: 9px; }
.btn.icon-only { width: 36px; padding: 0; }
.btn.small.icon-only { width: 30px; }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.loading { color: transparent !important; pointer-events: none; position: relative; }
.btn.loading::before { content: ""; position: absolute; inset: 0; margin: auto; width: 15px; height: 15px; border-radius: 50%; border: 2px solid rgba(255, 255, 255, 0.3); border-top-color: #fff; animation: spin 700ms linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.seg { display: inline-flex; padding: 3px; border-radius: 12px; background: var(--panel-2); border: 1px solid var(--line); gap: 2px; }
.seg button { height: 28px; padding: 0 12px; border: 0; border-radius: 9px; background: transparent; color: var(--muted); font: inherit; font-size: var(--t-label); font-weight: 600; cursor: pointer; transition: background-color 150ms ease, color 150ms ease, transform 160ms var(--ease-out); }
.seg button:active { transform: scale(0.97); }
.seg button.on { background: var(--g-pink); color: #fff; }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: var(--t-caption); color: var(--faint); font-weight: 600; padding: 12px 20px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 12px 20px; border-bottom: 1px solid var(--line); vertical-align: middle; font-variant-numeric: tabular-nums; }
tbody tr { transition: background-color 120ms ease; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr.clickable { cursor: pointer; }
tbody tr.clickable:focus-visible { outline-offset: -2px; border-radius: 0; }
.empty { padding: 36px 20px; text-align: center; color: var(--muted); }
.empty .big { display: grid; place-items: center; width: 44px; height: 44px; margin: 0 auto 10px; border-radius: 50%; background: var(--panel-2); color: var(--violet-l); }
.empty .big svg { width: 20px; height: 20px; }
.empty .btn { margin-top: 14px; }
.empty p { margin: var(--s-1) auto 0; max-width: 52ch; color: var(--faint); font-size: var(--t-small); text-wrap: pretty; }
.pager { display: flex; align-items: center; gap: 8px; padding: 12px 20px; border-top: 1px solid var(--line); color: var(--faint); font-size: var(--t-label); flex-wrap: wrap; }
.pager .chip { border: 1px solid var(--line); border-radius: 99px; padding: 2px 10px; }
.user-cell { display: flex; align-items: center; gap: 11px; min-width: 180px; }
.avatar { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: var(--t-label); flex-shrink: 0; color: #12142a; overflow: hidden; }
.user-cell b { display: block; font-size: var(--t-small); font-weight: 600; }
.user-cell .sub { font-size: var(--t-caption); color: var(--faint); line-height: 1.35; }
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px; border-radius: 99px; font-size: var(--t-caption); font-weight: 600; color: var(--muted); white-space: nowrap; background: rgba(255, 255, 255, 0.06); }
.badge.green { color: #5ff2c0; background: var(--green-soft); }
.badge.orange { color: var(--orange); background: var(--orange-soft); }
.badge.red { color: #ff9db3; background: var(--red-soft); }
.badge.blue { color: #8fbaff; background: var(--blue-soft); }
.badge.violet { color: var(--violet-l); background: var(--violet-soft); }
.badge.accent { color: var(--cyan); background: var(--accent-soft); }
.badge .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.pulse .dot { animation: blink 1.4s ease-in-out infinite; }
@keyframes blink { 50% { opacity: 0.3; } }
.pill-num { color: #5ff2c0; background: var(--green-soft); padding: 2px 9px; border-radius: 99px; font-size: var(--t-label); font-weight: 650; white-space: nowrap; font-variant-numeric: tabular-nums; }
code, .code { font-family: var(--mono); font-size: var(--t-label); background: var(--panel-2); border: 1px solid var(--line); padding: 1px 6px; border-radius: 6px; color: var(--cyan); }
.details { font-family: var(--mono); font-size: var(--t-caption); color: var(--faint); max-width: 520px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.inline-icon { display: inline-flex; align-items: center; gap: 5px; }
.inline-icon svg { width: 13px; height: 13px; opacity: 0.85; }

/* ---------- live / progress ---------- */
.live { display: inline-flex; align-items: center; gap: 7px; font-size: var(--t-label); color: var(--muted); padding: 6px 12px; border-radius: 99px; border: 1px solid var(--line); background: var(--panel); white-space: nowrap; }
.live-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--faint); display: inline-block; flex-shrink: 0; }
.live-dot.on { background: var(--green); }
.live-dot.warn { background: var(--orange); }
.live-dot.bad { background: var(--red); }
/* Progress fill: full-width gradient revealed by clip-path — no layout work while it moves. */
.bar { height: 6px; border-radius: 99px; background: rgba(255, 255, 255, 0.07); overflow: hidden; position: relative; }
.bar > i { display: block; height: 100%; background: var(--g-fill); clip-path: inset(0 var(--rest) 0 0 round 99px); transition: clip-path 400ms var(--ease-out); }
/* Live progress ticks about once a second: constant motion, linear, matched to the update rate. */
.bar.active > i { transition: clip-path 900ms linear; }
.bar.upload > i { background: var(--g-fill-pink); }
.bar.thin { height: 4px; }
.bar.c-blue > i { background: linear-gradient(90deg, #4b7bf5, #8fbaff); } .bar.c-violet > i { background: linear-gradient(90deg, #7c5cf5, #c2a3ff); }
.bar.c-pink > i { background: var(--g-fill-pink); } .bar.c-orange > i { background: linear-gradient(90deg, #f59e0b, #fbbf6b); }
.bar.c-green > i { background: linear-gradient(90deg, #10b981, #5ff2c0); } .bar.c-red > i { background: linear-gradient(90deg, #f43f5e, #ff9db3); }
.workers { display: flex; gap: 5px; flex-wrap: wrap; margin-top: 10px; }
.worker { width: 24px; height: 6px; border-radius: 99px; background: rgba(255, 255, 255, 0.1); transition: background-color 200ms ease; }
.worker.busy { background: var(--cyan); }
.run-list { display: flex; flex-direction: column; gap: 10px; }
.run-card { border: 1px solid var(--line); border-radius: 14px; padding: 13px 14px; background: var(--panel-2); }
.run-card.enter { animation: fade 200ms var(--ease-out) both; }
.run-top { display: flex; gap: 11px; align-items: flex-start; }
.run-title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.run-meta { font-size: var(--t-label); color: var(--faint); margin-top: 5px; display: flex; gap: 6px 14px; flex-wrap: wrap; align-items: center; }
.run-card .bar { margin-top: 12px; }
.run-pct { font-size: var(--t-small); font-weight: 700; font-variant-numeric: tabular-nums; min-width: 42px; text-align: right; }
.dist { display: flex; flex-direction: column; gap: 12px; }
.dist-row .top { display: flex; justify-content: space-between; gap: 10px; font-size: var(--t-small); margin-bottom: 6px; }
.dist-row .top span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); }
.dist-row .top b { font-variant-numeric: tabular-nums; font-weight: 650; }
.list-row { display: flex; justify-content: space-between; gap: 12px; padding: 9px 0; border-bottom: 1px solid var(--line); font-size: var(--t-small); }
.list-row:last-child { border-bottom: 0; }
.list-row > span { color: var(--muted); }
.list-row b { font-weight: 600; text-align: right; font-variant-numeric: tabular-nums; }
.panel-body > .bar { margin: 0 0 4px; }

/* ---------- drawer & modal ---------- */
.overlay { position: fixed; inset: 0; background: rgba(8, 9, 22, 0.7); z-index: 40; transition: opacity 250ms var(--ease-out); }
@starting-style { .overlay { opacity: 0; } }
#modal-root .overlay { z-index: 44; }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(760px, 100%); z-index: 41; overflow-y: auto; background: var(--bg-2); border-left: 1px solid var(--line); border-radius: 20px 0 0 20px; box-shadow: -24px 0 48px -12px rgba(0, 0, 0, 0.55); transition: transform 400ms var(--ease-drawer); }
@starting-style { .drawer { transform: translateX(100%); } }
.drawer-head { display: flex; align-items: center; gap: 12px; padding: 18px 24px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--bg-2); z-index: 2; }
.drawer-body { padding: 20px 24px 40px; }
.drawer .grid .panel + .panel { margin-top: 0; }
.kv { display: grid; grid-template-columns: 170px 1fr; gap: 9px 14px; font-size: var(--t-small); }
.kv dt { color: var(--faint); }
.kv dd { margin: 0; }
.actions { display: grid; grid-template-columns: 1fr 1fr 1fr auto; gap: 10px; align-items: end; }
.actions.two { grid-template-columns: 1fr auto; }
.modal-wrap { position: fixed; inset: 0; z-index: 45; display: grid; place-items: center; padding: 24px; overflow-y: auto; }
.modal { width: min(900px, 100%); max-height: calc(100vh - 48px); display: flex; flex-direction: column; border-radius: 20px; background: var(--bg-2); border: 1px solid var(--line); transition: opacity 250ms var(--ease-out), transform 250ms var(--ease-out); }
@starting-style { .modal { opacity: 0; transform: scale(0.96); } }
.modal-head { display: flex; align-items: center; gap: 12px; padding: 20px 24px 12px; }
.modal-head h2 { margin: 0; font-size: 16px; font-weight: 700; }
.modal-body { padding: 4px 24px 18px; overflow-y: auto; flex: 1; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 14px 24px 20px; border-top: 1px solid var(--line); }
.section { border-radius: 14px; padding: 16px; background: var(--panel); }
.section + .section { margin-top: 12px; }
.section h3 { margin: 0 0 var(--s-1); font-size: var(--t-body); font-weight: 650; }
.section .sub { font-size: var(--t-label); color: var(--faint); margin-bottom: 12px; }
.effect { display: grid; grid-template-columns: auto 1fr minmax(200px, 280px); gap: 14px; align-items: center; padding: 14px; border: 1px solid var(--line); border-radius: 14px; cursor: pointer; transition: border-color 150ms ease, background-color 150ms ease; }
.effect + .effect { margin-top: 10px; }
.effect.on { border-color: rgba(157, 108, 246, 0.6); background: var(--violet-soft); }
.effect b { display: block; font-size: var(--t-small); }
.effect .desc { font-size: var(--t-label); color: var(--faint); margin-top: 2px; max-width: 70ch; text-wrap: pretty; }
.effect .inputs { display: flex; gap: 8px; }
.effect:not(.on) .inputs { opacity: 0.5; }
.code-head { display: flex; align-items: center; gap: 12px; padding: 14px 16px; border-radius: 14px; margin-bottom: 12px; background: var(--g-pink); color: #fff; }
.code-head .label-sm { color: #fff; margin: 0; }
.code-head .code-value { font-family: var(--mono); font-size: var(--t-page); font-weight: 700; letter-spacing: 0.06em; }
.code-head .faint { color: #fff; opacity: 0.9; }

/* ---------- broadcast composer ---------- */
.tiles { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr) minmax(0, 1.1fr); gap: 12px; }
.tile { border-radius: 14px; padding: 12px 14px; background: var(--panel-2); }
.tile .label-sm { margin-bottom: 8px; }
.tile .big-num { font-size: var(--t-metric-sm); font-weight: 700; font-variant-numeric: tabular-nums; }
.toolbar { display: flex; gap: 5px; flex-wrap: wrap; margin-bottom: 8px; }
.toolbar .btn { height: 30px; min-width: 32px; padding: 0 9px; font-size: var(--t-label); border-radius: 9px; }
.toolbar .btn svg { width: 14px; height: 14px; }
.toolbar .sep { width: 1px; background: var(--line); margin: 4px 3px; }
.menu { position: absolute; z-index: 46; min-width: 190px; padding: 5px; border-radius: 12px; background: var(--panel-2); border: 1px solid var(--line-strong); box-shadow: 0 16px 32px -12px rgba(0, 0, 0, 0.75); transform-origin: top left; transition: opacity 180ms var(--ease-out), transform 180ms var(--ease-out); }
@starting-style { .menu { opacity: 0; transform: scale(0.95); } }
.menu button { display: flex; width: 100%; justify-content: space-between; gap: 12px; padding: 7px 10px; border: 0; background: transparent; color: var(--text); font: inherit; font-size: var(--t-small); border-radius: 8px; cursor: pointer; text-align: left; }
.menu button:focus-visible { background: var(--hover); outline: none; }
.dropzone { border: 1.5px dashed var(--line-strong); border-radius: 14px; padding: 22px; text-align: center; color: var(--muted); cursor: pointer; transition: border-color 150ms ease, background-color 150ms ease; font-size: var(--t-small); }
.dropzone.drag { border-color: rgba(157, 108, 246, 0.75); background: var(--violet-soft); }
.dropzone .icon { display: block; margin: 0 auto 6px; width: 22px; height: 22px; color: var(--pink); }
.dropzone .icon svg { width: 22px; height: 22px; }
.dropzone small { display: block; color: var(--faint); margin-top: 3px; }
.image-chip { display: flex; align-items: center; gap: 12px; padding: 10px; border: 1px solid var(--line); border-radius: 14px; }
.image-chip img { width: 64px; height: 64px; object-fit: cover; border-radius: 10px; }
.btn-row { display: grid; grid-template-columns: 140px 1fr 1.4fr auto; gap: 8px; align-items: center; }
.btn-row + .btn-row { margin-top: 8px; }
.composer { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(300px, 1fr); gap: 18px; align-items: start; }
.composer-side { position: sticky; top: 88px; }
.form-block + .form-block { margin-top: 18px; }
.form-block > .label-row { display: flex; align-items: baseline; gap: 10px; margin-bottom: 8px; }
.form-block > .label-row b { font-size: var(--t-small); font-weight: 650; }
.form-block > .label-row span { font-size: var(--t-label); color: var(--faint); }
.counter { font-size: var(--t-caption); color: var(--faint); font-variant-numeric: tabular-nums; }
.counter.over { color: #ff9db3; }
.tg { border-radius: 16px; padding: 16px; min-height: 140px; background: linear-gradient(160deg, #20264a, #171b36); }
.tg-msg { max-width: 360px; background: #2a3158; border-radius: 16px 16px 16px 5px; overflow: hidden; }
.tg-msg img { display: block; width: 100%; max-height: 320px; object-fit: cover; }
.tg-text { padding: 8px 12px 6px; white-space: pre-wrap; overflow-wrap: anywhere; font-size: var(--t-body); line-height: 1.45; }
.tg-text a { color: #8bc4ff; }
.tg-text code { color: #a8d8ff; background: rgba(0, 0, 0, 0.25); border: 0; }
.tg-text pre { background: rgba(0, 0, 0, 0.25); padding: 8px; border-radius: 8px; overflow-x: auto; margin: 4px 0; font-family: var(--mono); font-size: var(--t-label); }
.tg-text blockquote { margin: 4px 0; padding: 2px 10px; background: rgba(139, 196, 255, 0.1); border-radius: 6px; }
.tg-text .spoiler { background: rgba(255, 255, 255, 0.25); color: transparent; border-radius: 4px; cursor: pointer; transition: color 150ms ease, background-color 150ms ease; }
.tg-text .spoiler.shown { color: inherit; background: rgba(255, 255, 255, 0.08); }
.tg-time { text-align: right; font-size: var(--t-caption); color: #a3aed4; padding: 0 10px 6px; }
.tg-buttons { max-width: 360px; display: flex; flex-direction: column; gap: 4px; margin-top: 4px; }
.tg-buttons span { display: block; text-align: center; padding: 8px; border-radius: 10px; background: rgba(42, 49, 88, 0.9); font-size: var(--t-small); font-weight: 550; }
.tg-empty { color: var(--faint); font-size: var(--t-small); text-align: center; padding: 30px 0; }

/* ---------- command palette: opened from the keyboard many times a day, so it never animates ---------- */
.palette-wrap { position: fixed; inset: 0; z-index: 46; display: flex; justify-content: center; align-items: flex-start; padding: 12vh 16px 16px; }
.palette { width: min(560px, 100%); border-radius: 16px; overflow: hidden; background: var(--bg-2); border: 1px solid var(--line-strong); }
.palette input { border: 0; border-bottom: 1px solid var(--line); border-radius: 0; background: transparent; padding: 16px 18px; font-size: var(--t-title); box-shadow: none !important; }
.palette-list { max-height: 50vh; overflow-y: auto; padding: 6px; }
.palette-item { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 10px; cursor: pointer; color: var(--muted); }
.palette-item.on { background: var(--g-nav); color: var(--text); }
.palette-item .icon svg { width: 16px; height: 16px; }
.palette-item kbd, .kbd { margin-left: auto; font-family: var(--mono); font-size: var(--t-caption); color: var(--faint); border: 1px solid var(--line); border-radius: 5px; padding: 0 5px; }
.overlay.instant { transition: none; }

/* ---------- toasts: transitions, not keyframes — several can fire in a second ---------- */
.toast-box { position: fixed; right: 20px; bottom: 20px; z-index: 60; display: flex; flex-direction: column; gap: 8px; align-items: flex-end; }
.toast { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-radius: 14px; min-width: 240px; max-width: 400px; background: var(--panel-2); border: 1px solid var(--line-strong); font-size: var(--t-small); transition: opacity 250ms var(--ease-out), transform 250ms var(--ease-out); }
@starting-style { .toast { opacity: 0; transform: translateY(100%); } }
.toast.out { opacity: 0; transform: translateY(100%); transition-duration: 180ms; }
.toast::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--cyan); flex-shrink: 0; }
.toast.error::before { background: var(--red); }
.toast.ok::before { background: var(--green); }
.loading { padding: 40px; text-align: center; color: var(--faint); }
.skeleton { border-radius: var(--radius); background: linear-gradient(100deg, var(--panel) 20%, var(--panel-2) 40%, var(--panel) 60%); background-size: 200% 100%; animation: skel 1.3s linear infinite; }
@keyframes skel { to { background-position: -200% 0; } }
.skeleton-grid { display: grid; gap: 18px; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); }
.skeleton-grid .skeleton { height: 120px; }
.skeleton.block { height: 260px; margin-top: 18px; }
td.video-cell { min-width: 240px; }
td.video-cell a { font-weight: 600; }
.inline-field { display: flex; align-items: center; gap: 8px; font-size: var(--t-small); color: var(--muted); white-space: nowrap; }
.inline-field input { width: 64px; height: 30px; padding: 0 8px; }
.row-actions { display: flex; gap: 6px; justify-content: flex-end; }

/* ---------- hover: only where a precise pointer exists (touch would leave hovers stuck) ---------- */
@media (hover: hover) and (pointer: fine) {
  a:hover { color: #8ff5ea; }
  .nav a:hover { background: var(--hover); color: #fff; }
  .nav a.active:hover { background: var(--g-nav); }
  .btn:hover { background: var(--panel-3); border-color: rgba(255, 255, 255, 0.22); }
  .btn.primary:hover { background: var(--g-pink); filter: brightness(1.1); }
  .btn.danger:hover { background: var(--red-soft); border-color: rgba(255, 107, 139, 0.55); }
  .btn.ghost:hover { background: var(--hover); border-color: var(--line); }
  .seg button:hover { color: var(--text); }
  input:hover, select:hover, textarea:hover { border-color: rgba(255, 255, 255, 0.22); }
  tbody tr:hover td { background: var(--hover); }
  .effect:hover { border-color: var(--line-strong); }
  .menu button:hover { background: var(--hover); }
  .palette-item:hover { background: var(--hover); color: var(--text); }
  .dropzone:hover { border-color: rgba(157, 108, 246, 0.75); background: var(--violet-soft); }
  .run-card:hover { border-color: var(--line-strong); }
  .vb-col:hover .vb-bar { filter: brightness(1.2); }
  .vb-col:hover .vb-tip { opacity: 1; transform: translate(-50%, 0); }
}

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 1300px) {
  .dash { grid-template-columns: minmax(0, 1fr); }
  .dash-side { flex-direction: row; }
  .dash-side > .panel { flex: 1; min-width: 0; }
  .composer { grid-template-columns: minmax(0, 1fr); }
  .composer-side { position: static; }
  .grid.four { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 1080px) {
  .grid.two, .grid.three { grid-template-columns: minmax(0, 1fr); }
  .dash-top { grid-template-columns: 1fr 1fr; }
  .mini-stack { grid-column: 1 / -1; flex-direction: row; }
  .filters { grid-template-columns: 1fr 1fr; }
  .filters .field:first-child { grid-column: 1 / -1; }
  .tiles { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 820px) {
  body { font-size: var(--t-body); }
  .layout { grid-template-columns: minmax(0, 1fr); }
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; width: 280px; height: auto; transform: translateX(-105%); transition: transform 400ms var(--ease-drawer); border-radius: 0 20px 20px 0; z-index: 50; }
  .sidebar.open { transform: none; box-shadow: 24px 0 48px -12px rgba(0, 0, 0, 0.55); }
  .sidebar-backdrop { display: block; position: fixed; inset: 0; z-index: 49; background: rgba(8, 9, 22, 0.66); opacity: 0; pointer-events: none; transition: opacity 250ms var(--ease-out); }
  .sidebar.open + .sidebar-backdrop { opacity: 1; pointer-events: auto; }
  .nav a { height: 44px; font-size: var(--t-body); }
  .btn.menu-toggle { display: inline-flex; }
  .topbar { padding: 10px 14px; gap: 10px; flex-wrap: wrap; }
  .topbar h1 { font-size: var(--t-page-sm); }
  .topbar p { display: none; }
  .topbar-tools .kbd, .topbar-tools .label { display: none; }
  #page-actions { width: 100%; justify-content: flex-start; order: 5; }
  #page-actions:empty { display: none; }
  .content { padding: 14px 12px 90px; }
  .content > * + *, .grid + .grid, .grid + .panel, .panel + .panel, .panel + .grid, .dash + .grid { margin-top: 12px; }
  .grid, .dash, .dash-main, .dash-side, .dash-top { gap: var(--s-3); }
  .grid.kpi { gap: 0; }
  .panel-head { padding: 16px 16px 4px; }
  .panel-body { padding: 12px 16px 16px; }
  .dash-side { flex-direction: column; }
  .dash-top { grid-template-columns: minmax(0, 1fr); }
  .mini-stack { flex-direction: column; }
  .hero { min-height: 112px; padding: 18px 20px; }
  .hero-value { font-size: var(--t-hero-sm); }
  .grid.half, .grid.four { grid-template-columns: minmax(0, 1fr); }
  .grid.kpi { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpi-card { padding: 14px 15px 13px; }
  .kpi-card .value { font-size: var(--t-metric-sm); }
  .donut-row { flex-direction: column; align-items: stretch; }
  .donut-row .dn { margin: 0 auto; }
  .lc-x span.skip-m { display: none; }
  .vb { gap: 6px; }
  .filters { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; padding: 12px 14px; gap: 10px; }
  .filters > .field:first-child, .filters > .total { grid-column: 1 / -1; }
  .filters > div:empty { display: none; }
  .filters .total { padding-bottom: 0; }
  .actions, .actions.two, .tiles { grid-template-columns: minmax(0, 1fr); }
  .kv { grid-template-columns: minmax(96px, 38%) minmax(0, 1fr); gap: 8px 12px; }
  .btn { height: 40px; }
  .btn.small { height: 36px; padding: 0 12px; }
  .btn.small.icon-only, .btn.icon-only { width: 40px; }
  input, select, textarea { font-size: 16px; padding: 10px 12px; } /* 16px stops iOS from zooming into fields */
  .inline-field input { height: 36px; font-size: var(--t-body); }

  /* Tables become cards: every cell gets its column name from data-label (set by app.js). */
  .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 16px; border-bottom: 1px solid var(--line); }
  .table-wrap tbody tr:last-child { border-bottom: 0; }
  .table-wrap td { border: 0; padding: 4px 0; display: flex; justify-content: space-between; align-items: center; gap: 12px; text-align: right; min-height: 26px; }
  .table-wrap td::before { content: attr(data-label); color: var(--faint); font-size: var(--t-label); text-align: left; flex-shrink: 0; }
  .table-wrap td:not([data-label])::before, .table-wrap td[data-label=""]::before { display: none; }
  .table-wrap td:first-child { justify-content: flex-start; text-align: left; padding-bottom: 6px; }
  .table-wrap td:first-child::before { display: none; }
  .table-wrap td.video-cell, .table-wrap td.stack-cell { min-width: 0; max-width: none; flex-direction: column; align-items: stretch; text-align: left; }
  .table-wrap td.stack-cell > * { width: 100%; }
  .table-wrap td.right, .table-wrap td:last-child { justify-content: flex-end; }
  .table-wrap tr.clickable:active { background: var(--hover); }
  .user-cell { min-width: 0; }
  .details { max-width: 60vw; }
  .row-actions { flex-wrap: wrap; }

  .drawer { width: 100%; border-radius: 0; border-left: 0; }
  @starting-style { .drawer { transform: translateY(40px); opacity: 0; } }
  .drawer { transition: transform 400ms var(--ease-drawer), opacity 250ms var(--ease-out); }
  .drawer-head, .drawer-body { padding-left: 14px; padding-right: 14px; }
  .modal-wrap { padding: 0; place-items: end stretch; }
  .modal { width: 100% !important; max-height: 94vh; border-radius: 20px 20px 0 0; transition: transform 400ms var(--ease-drawer); }
  @starting-style { .modal { opacity: 1; transform: translateY(100%); } }
  .modal-head, .modal-body, .modal-foot { padding-left: 14px; padding-right: 14px; }
  .modal-foot .btn { flex: 1; }
  .effect { grid-template-columns: auto 1fr; }
  .effect .inputs { grid-column: 1 / -1; }
  .btn-row { grid-template-columns: 1fr auto; padding: 10px; border: 1px solid var(--line); border-radius: 12px; }
  .btn-row > :nth-child(2), .btn-row > :nth-child(3) { grid-column: 1 / -1; }
  .toast-box { left: 12px; right: 12px; bottom: 12px; align-items: stretch; }
  .toast { max-width: none; }
  .palette-wrap { padding-top: 8vh; }
  .pager { justify-content: center; }
  .pager .spacer { display: none; }
}

/* Reduced motion: fewer and gentler, not none. Movement goes; fades and colour changes that confirm a state stay. */
@media (prefers-reduced-motion: reduce) {
  .lc-reveal { animation: none; }
  .lc-line, .lc-area { transition: none; }
  .btn:active, .seg button:active { transform: none; }
  .drawer, .sidebar { transition: opacity 200ms ease; }
  @starting-style { .drawer { transform: none; opacity: 0; } }
  .modal { transition: opacity 200ms ease; }
  @starting-style { .modal { transform: none; opacity: 0; } }
  .toast { transition: opacity 200ms ease; }
  @starting-style { .toast { transform: none; opacity: 0; } }
  .toast.out { transform: none; }
  .menu { transition: opacity 150ms ease; }
  @starting-style { .menu { transform: none; } }
  .toggle .track::after { transition: background-color 150ms ease; }
  .bar.active > i, .bar > i, .vb-bar, .dn-seg { transition-duration: 150ms; transition-timing-function: ease; }
  .skeleton, .badge.pulse .dot { animation: none; }
}
