/* =====================================================================
   FlashAPI Balance — Flash Terminal theme
   Mirrors the relay-proxy admin UI (tokens/base/layout/kit) in plain CSS.
   Dark is the default; html[data-theme='light'] switches to warm paper.
   ===================================================================== */

/* ---------- Fonts (self-hosted, latin + latin-ext) ---------- */
@font-face {
  font-family: 'Manrope Variable';
  font-style: normal;
  font-display: swap;
  font-weight: 200 800;
  src: url(assets/fonts/manrope-latin-ext-wght-normal.woff2) format('woff2-variations');
  unicode-range: U+0100-02BA,U+02BD-02C5,U+02C7-02CC,U+02CE-02D7,U+02DD-02FF,U+0304,U+0308,U+0329,U+1D00-1DBF,U+1E00-1E9F,U+1EF2-1EFF,U+2020,U+20A0-20AB,U+20AD-20C0,U+2113,U+2C60-2C7F,U+A720-A7FF;
}
@font-face {
  font-family: 'Manrope Variable';
  font-style: normal;
  font-display: swap;
  font-weight: 200 800;
  src: url(assets/fonts/manrope-latin-wght-normal.woff2) format('woff2-variations');
  unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD;
}
@font-face { font-family: 'IBM Plex Mono'; font-style: normal; font-display: swap; font-weight: 400; src: url(assets/fonts/ibm-plex-mono-latin-ext-400-normal.woff2) format('woff2'); unicode-range: U+0100-02BA,U+02BD-02C5,U+02C7-02CC,U+02CE-02D7,U+02DD-02FF,U+0304,U+0308,U+0329,U+1D00-1DBF,U+1E00-1E9F,U+1EF2-1EFF,U+2020,U+20A0-20AB,U+20AD-20C0,U+2113,U+2C60-2C7F,U+A720-A7FF; }
@font-face { font-family: 'IBM Plex Mono'; font-style: normal; font-display: swap; font-weight: 400; src: url(assets/fonts/ibm-plex-mono-latin-400-normal.woff2) format('woff2'); unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD; }
@font-face { font-family: 'IBM Plex Mono'; font-style: normal; font-display: swap; font-weight: 500; src: url(assets/fonts/ibm-plex-mono-latin-ext-500-normal.woff2) format('woff2'); unicode-range: U+0100-02BA,U+02BD-02C5,U+02C7-02CC,U+02CE-02D7,U+02DD-02FF,U+0304,U+0308,U+0329,U+1D00-1DBF,U+1E00-1E9F,U+1EF2-1EFF,U+2020,U+20A0-20AB,U+20AD-20C0,U+2113,U+2C60-2C7F,U+A720-A7FF; }
@font-face { font-family: 'IBM Plex Mono'; font-style: normal; font-display: swap; font-weight: 500; src: url(assets/fonts/ibm-plex-mono-latin-500-normal.woff2) format('woff2'); unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD; }
@font-face { font-family: 'IBM Plex Mono'; font-style: normal; font-display: swap; font-weight: 600; src: url(assets/fonts/ibm-plex-mono-latin-ext-600-normal.woff2) format('woff2'); unicode-range: U+0100-02BA,U+02BD-02C5,U+02C7-02CC,U+02CE-02D7,U+02DD-02FF,U+0304,U+0308,U+0329,U+1D00-1DBF,U+1E00-1E9F,U+1EF2-1EFF,U+2020,U+20A0-20AB,U+20AD-20C0,U+2113,U+2C60-2C7F,U+A720-A7FF; }
@font-face { font-family: 'IBM Plex Mono'; font-style: normal; font-display: swap; font-weight: 600; src: url(assets/fonts/ibm-plex-mono-latin-600-normal.woff2) format('woff2'); unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD; }

/* ---------- Tokens (shared with relay-proxy) ---------- */
:root {
  color-scheme: dark;
  --primary: #fcd535;
  --primary-hover: #f0b90b;
  --primary-text: #fcd535;
  --primary-ink: #181a20;
  --primary-soft: rgba(252, 213, 53, 0.12);
  --primary-line: rgba(252, 213, 53, 0.4);
  --success: #0ecb81;
  --success-text: #0ecb81;
  --success-soft: rgba(14, 203, 129, 0.12);
  --warning: #f0b90b;
  --warning-text: #f5c242;
  --warning-soft: rgba(240, 185, 11, 0.13);
  --danger: #f6465d;
  --danger-text: #ff6b7e;
  --danger-soft: rgba(246, 70, 93, 0.12);
  --info: #5b8ff9;
  --info-text: #7ea6ff;
  --info-soft: rgba(91, 143, 249, 0.13);
  --violet-text: #b79cff;

  --canvas: #0b0e11;
  --surface: #12161b;
  --surface-2: #1a1f26;
  --surface-3: #222831;
  --glass: rgba(18, 22, 27, 0.58);
  --glass-strong: rgba(18, 22, 27, 0.86);
  --glass-solid: rgba(18, 22, 27, 0.94);
  --line: rgba(255, 255, 255, 0.07);
  --line-strong: rgba(255, 255, 255, 0.13);
  --heading: #ffffff;
  --body: #e4e6ea;
  --muted: #8b94a1;
  --soft: #78818e; /* relay: #6e7784 — lifted for AA on canvas */
  --shadow: 0 30px 80px -40px rgba(0, 0, 0, 0.8);
  --shadow-sm: 0 12px 30px -14px rgba(0, 0, 0, 0.55);
  --shadow-pop: 0 24px 60px -20px rgba(0, 0, 0, 0.7);
  --overlay: rgba(5, 7, 9, 0.55);

  --glow-a: rgba(252, 213, 53, 0.16);
  --glow-b: rgba(14, 203, 129, 0.08);
  --glow-c: rgba(240, 120, 11, 0.1);
  --spot: rgba(252, 213, 53, 0.11);
  --rim: rgba(252, 213, 53, 0.7);
  --grain-opacity: 0.05;

  /* Chart palette (relay chartPalette) — switches with the theme via CSS. */
  --chart-primary: #fcd535;
  --chart-faint: rgba(252, 213, 53, 0.5);
  --chart-grid: rgba(255, 255, 255, 0.07);
  --chart-tick: #8b94a1;

  --font-copy: 'Manrope Variable', 'Manrope', 'PingFang SC', 'Microsoft YaHei', sans-serif;
  --font-mono: 'IBM Plex Mono', 'SFMono-Regular', Consolas, 'PingFang SC', 'Microsoft YaHei', monospace;
  --r-xl: 22px;
  --r-lg: 16px;
  --r-md: 12px;
  --r-sm: 8px;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --blur: blur(18px) saturate(1.25);
  --blur-strong: blur(24px) saturate(1.4);

  --sidebar-w: 248px;
  --topbar-h: 64px;
  --tabbar-h: 62px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

:root[data-theme='light'] {
  color-scheme: light;
  --primary-text: #8a6500;
  --primary-soft: rgba(252, 213, 53, 0.22);
  --primary-line: rgba(178, 128, 0, 0.35);
  --success-text: #067a4f;
  --success-soft: rgba(14, 203, 129, 0.13);
  --warning-text: #9a6700;
  --warning-soft: rgba(240, 185, 11, 0.16);
  --danger-text: #c0253c;
  --danger-soft: rgba(246, 70, 93, 0.1);
  --info: #2563eb;
  --info-text: #1d4ed8;
  --info-soft: rgba(37, 99, 235, 0.1);
  --violet-text: #6d28d9;

  --canvas: #f5f4ef;
  --surface: #ffffff;
  --surface-2: #efede6;
  --surface-3: #e6e3da;
  --glass: rgba(255, 255, 255, 0.62);
  --glass-strong: rgba(255, 255, 255, 0.86);
  --glass-solid: rgba(255, 255, 255, 0.95);
  --line: rgba(20, 22, 28, 0.08);
  --line-strong: rgba(20, 22, 28, 0.15);
  --heading: #14161b;
  --body: #2a2d33;
  --muted: #626973;
  --soft: #686e78; /* relay: #7a808a — darkened for AA on paper */
  --shadow: 0 30px 70px -45px rgba(40, 32, 0, 0.35);
  --shadow-sm: 0 12px 28px -16px rgba(40, 32, 0, 0.3);
  --shadow-pop: 0 24px 60px -24px rgba(40, 32, 0, 0.4);
  --overlay: rgba(60, 52, 20, 0.22);

  --glow-a: rgba(252, 213, 53, 0.32);
  --glow-b: rgba(14, 203, 129, 0.1);
  --glow-c: rgba(255, 159, 67, 0.13);
  --spot: rgba(252, 213, 53, 0.26);
  --rim: rgba(214, 160, 0, 0.75);
  --grain-opacity: 0.04;

  --chart-primary: #d9a800;
  --chart-faint: rgba(217, 168, 0, 0.45);
  --chart-grid: rgba(20, 22, 28, 0.08);
  --chart-tick: #626973;
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  color: var(--body);
  background: var(--canvas);
  font-family: var(--font-copy);
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  transition: background 400ms ease, color 400ms ease;
}
[hidden] { display: none !important; }
::selection { color: var(--primary-ink); background: var(--primary); }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
h1, h2, h3, h4, p { margin: 0; }
h1, h2, h3 { text-wrap: balance; }
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
pre, code { font-family: var(--font-mono); }
ul, ol { margin: 0; padding: 0; list-style: none; }

* { scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent; }
*::-webkit-scrollbar { width: 8px; height: 8px; }
*::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 8px; border: 2px solid transparent; background-clip: padding-box; }
*::-webkit-scrollbar-track { background: transparent; }

svg.lucide { width: 16px; height: 16px; flex: 0 0 auto; stroke-width: 2; }

.sr-only { position: absolute !important; width: 1px !important; height: 1px !important; overflow: hidden !important; clip: rect(0, 0, 0, 0) !important; white-space: nowrap !important; clip-path: inset(50%) !important; }
.mono, .num { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.kicker { color: var(--primary-text); font-family: var(--font-mono); font-size: 11px; font-weight: 500; letter-spacing: 0.04em; text-transform: uppercase; }
.tone-muted { color: var(--muted); }
.tone-soft { color: var(--soft); }
.tone-success { color: var(--success-text); }
.tone-danger { color: var(--danger-text); }
.tone-warning { color: var(--warning-text); }
b.tone-muted, b.tone-success, b.tone-danger, b.tone-warning { font-weight: 650; }
.rate-mark { margin-left: 4px; color: var(--soft); font-family: var(--font-mono); font-size: 10.5px; font-weight: 500; letter-spacing: 0.02em; }

/* ---------- Ambient backdrop ---------- */
.backdrop { position: fixed; inset: 0; z-index: 0; overflow: hidden; pointer-events: none; }
.backdrop i { position: absolute; border-radius: 50%; filter: blur(90px); will-change: transform; }
.backdrop .b1 { top: -18%; right: -8%; width: 58vw; height: 58vw; background: radial-gradient(circle, var(--glow-a), transparent 65%); animation: drift-a 24s ease-in-out infinite; }
.backdrop .b2 { bottom: -25%; left: -12%; width: 55vw; height: 55vw; background: radial-gradient(circle, var(--glow-b), transparent 65%); animation: drift-b 31s ease-in-out infinite; }
.backdrop .b3 { top: 38%; left: 38%; width: 36vw; height: 36vw; background: radial-gradient(circle, var(--glow-c), transparent 65%); animation: drift-c 27s ease-in-out infinite; }
.backdrop .grid { position: absolute; inset: 0; background-image: linear-gradient(var(--line) 1px, transparent 1px), linear-gradient(90deg, var(--line) 1px, transparent 1px); background-size: 72px 72px; mask-image: radial-gradient(ellipse 80% 50% at 50% 0%, #000 10%, transparent 70%); -webkit-mask-image: radial-gradient(ellipse 80% 50% at 50% 0%, #000 10%, transparent 70%); opacity: 0.55; }
.backdrop .grain { position: absolute; inset: -50%; opacity: var(--grain-opacity); background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E"); animation: grain 1.2s steps(6) infinite; }
@keyframes drift-a { 0%, 100% { transform: translate(0, 0) scale(1); } 50% { transform: translate(-12%, 14%) scale(1.12); } }
@keyframes drift-b { 0%, 100% { transform: translate(0, 0) scale(1); } 50% { transform: translate(16%, -10%) scale(0.9); } }
@keyframes drift-c { 0%, 100% { transform: translate(0, 0) scale(1); } 33% { transform: translate(-20%, -12%) scale(1.15); } 66% { transform: translate(12%, 10%) scale(0.92); } }
@keyframes grain { 0% { transform: translate(0, 0); } 20% { transform: translate(-3%, 2%); } 40% { transform: translate(2%, -3%); } 60% { transform: translate(-2%, -1%); } 80% { transform: translate(3%, 3%); } 100% { transform: translate(0, 0); } }

/* ---------- Motion primitives ---------- */
.blur-in { animation: blur-in 640ms var(--ease) both; animation-delay: var(--d, 0ms); }
@keyframes blur-in { from { opacity: 0; filter: blur(12px); transform: translateY(14px); } to { opacity: 1; filter: none; transform: none; } }
@keyframes fade-up { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes ping { 0% { opacity: 0.7; transform: scale(1); } 80%, 100% { opacity: 0; transform: scale(3.2); } }
@keyframes pop-in { from { opacity: 0; filter: blur(10px); transform: translateY(14px) scale(0.98); } to { opacity: 1; filter: none; transform: none; } }
@keyframes spin { to { transform: rotate(360deg); } }

/* =====================================================================
   Shell
   ===================================================================== */
.app-shell { position: relative; z-index: 1; min-height: 100vh; }
.app-main { min-width: 0; margin-left: var(--sidebar-w); transition: margin-left 300ms var(--ease); }
.app-content { width: min(100%, 1480px); margin: 0 auto; padding: 22px 28px 40px; }
body.auth-locked .app-shell,
body.auth-locked .tabbar,
body.auth-locked .more-sheet,
body.auth-locked .more-mask { display: none !important; }

/* ---------- Sidebar ---------- */
.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 60;
  display: flex;
  width: var(--sidebar-w);
  flex-direction: column;
  background: var(--glass);
  border-right: 1px solid var(--line);
  -webkit-backdrop-filter: var(--blur);
  backdrop-filter: var(--blur);
  transition: width 300ms var(--ease);
}
.sidebar-brand { display: flex; min-height: 76px; align-items: center; gap: 11px; padding: 18px 20px; color: var(--heading); text-decoration: none; }
.brand-lockup { display: inline-flex; min-width: 0; align-items: center; gap: 11px; color: var(--heading); }
.brand-mark { position: relative; display: grid; width: 36px; height: 36px; flex: 0 0 36px; place-items: center; background: var(--surface-2); border: 1px solid var(--line-strong); border-radius: 11px; box-shadow: 0 8px 22px -10px rgba(255, 172, 108, 0.55), inset 0 1px 0 rgba(255, 255, 255, 0.06); transition: transform 400ms var(--ease); }
.sidebar-brand:hover .brand-mark { transform: rotate(-8deg) scale(1.05); }
.brand-mark img { width: 22px; height: 22px; }
.brand-mark i { position: absolute; top: -2px; right: -2px; width: 9px; height: 9px; background: var(--success); border: 2px solid var(--canvas); border-radius: 50%; }
.brand-mark i::after { position: absolute; inset: -2px; content: ''; border-radius: 50%; background: var(--success); animation: ping 2.4s var(--ease) infinite; }
.brand-text { display: grid; min-width: 0; line-height: 1.15; }
.brand-text strong { overflow: hidden; font-size: 15px; font-weight: 800; letter-spacing: 0.01em; text-overflow: ellipsis; white-space: nowrap; }
.brand-text span { color: var(--soft); font-family: var(--font-mono); font-size: 10px; letter-spacing: 0.08em; white-space: nowrap; }

.sidebar-section { padding: 14px 8px 6px; color: var(--soft); font-family: var(--font-mono); font-size: 10px; letter-spacing: 0.08em; }
.sidebar-section:first-child { padding-top: 6px; }
.sidebar-nav { display: flex; flex: 1; flex-direction: column; gap: 3px; padding: 4px 12px; overflow-y: auto; }
.nav-item {
  position: relative;
  display: flex;
  min-height: 42px;
  flex: 0 0 auto;
  align-items: center;
  gap: 11px;
  padding: 0 13px;
  color: var(--muted);
  border: 1px solid transparent;
  border-radius: var(--r-md);
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
  transition: color 150ms ease, background 200ms ease, border-color 200ms ease;
}
.nav-item svg { width: 17px; height: 17px; color: var(--soft); transition: color 150ms ease, transform 300ms var(--ease); }
.nav-item:hover { color: var(--heading); background: var(--surface-2); }
.nav-item:hover svg { color: var(--heading); transform: translateX(1px); }
.nav-item.active { color: var(--heading); background: var(--primary-soft); border-color: var(--primary-line); }
.nav-item.active svg { color: var(--primary-text); }
.nav-item.active::before { position: absolute; top: 11px; bottom: 11px; left: -1px; width: 3px; content: ''; background: var(--primary); border-radius: 0 3px 3px 0; box-shadow: 0 0 12px var(--primary); }
.nav-label { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }

.sidebar-footer { display: grid; gap: 12px; padding: 14px 16px 18px; border-top: 1px solid var(--line); }
.sidebar-poll { display: flex; justify-content: space-between; gap: 10px; padding: 10px 12px; background: color-mix(in srgb, var(--surface-2) 65%, transparent); border: 1px solid var(--line); border-radius: var(--r-md); }
.sidebar-poll > div { display: grid; gap: 2px; min-width: 0; }
.sidebar-poll > div:last-child { text-align: right; }
.sidebar-poll span { color: var(--soft); font-family: var(--font-mono); font-size: 10px; letter-spacing: 0.06em; }
.sidebar-poll strong { color: var(--heading); font-size: 14px; font-weight: 600; }
.sidebar-poll strong span { color: inherit; font-size: inherit; letter-spacing: 0; }
.sidebar-status { display: flex; align-items: center; gap: 8px; color: var(--soft); font-family: var(--font-mono); font-size: 10.5px; letter-spacing: 0.04em; }
.sidebar-status i { position: relative; width: 6px; height: 6px; flex: 0 0 6px; background: var(--success); border-radius: 50%; }
.sidebar-status i::after { position: absolute; inset: 0; content: ''; border-radius: 50%; background: var(--success); animation: ping 2s var(--ease) infinite; }

/* Tablet: icon rail */
@media (min-width: 768px) and (max-width: 1099px) {
  :root { --sidebar-w: 76px; }
  .sidebar-brand { justify-content: center; padding: 18px 0; }
  .sidebar .brand-text, .sidebar .nav-label, .sidebar-status span, .sidebar-poll { display: none; }
  .sidebar-section { height: 1px; margin: 10px 8px; padding: 0; overflow: hidden; color: transparent; background: var(--line); }
  .sidebar-section:first-child { display: none; }
  .sidebar-nav { padding: 4px 14px; }
  .nav-item { justify-content: center; padding: 0; }
  .sidebar-footer { justify-items: center; }
}

/* ---------- Top bar ---------- */
.topbar { position: sticky; top: 0; z-index: 50; border-bottom: 1px solid transparent; transition: border-color 300ms ease; }
.topbar::before { position: absolute; inset: 0; z-index: -1; content: ''; background: color-mix(in srgb, var(--canvas) 70%, transparent); -webkit-backdrop-filter: var(--blur-strong); backdrop-filter: var(--blur-strong); opacity: 0; transition: opacity 300ms ease; pointer-events: none; }
.topbar.is-scrolled { border-bottom-color: var(--line); }
.topbar.is-scrolled::before { opacity: 1; }
.topbar-inner { display: flex; width: min(100%, 1480px); height: var(--topbar-h); align-items: center; justify-content: space-between; gap: 14px; margin: 0 auto; padding: 0 28px; }
.topbar-title { display: flex; min-width: 0; align-items: center; gap: 12px; }
.topbar-title .mobile-brand { display: none; }
.topbar-crumb { display: grid; min-width: 0; line-height: 1.2; }
.topbar-crumb span { color: var(--soft); font-family: var(--font-mono); font-size: 10.5px; letter-spacing: 0.06em; white-space: nowrap; }
.topbar-crumb strong { overflow: hidden; color: var(--heading); font-size: 17px; font-weight: 800; letter-spacing: -0.01em; text-overflow: ellipsis; white-space: nowrap; }
.topbar-tools { display: flex; flex: 0 0 auto; align-items: center; gap: 8px; }
.topbar-clock { display: flex; align-items: center; gap: 7px; height: 38px; padding: 0 14px; color: var(--muted); background: var(--glass); border: 1px solid var(--line); border-radius: 999px; font-size: 12.5px; -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px); }
.topbar-clock svg { width: 14px; height: 14px; color: var(--soft); }
.topbar-clock #clock { color: var(--heading); }
.topbar-clock .sep { color: var(--soft); }

.theme-toggle { display: flex; gap: 2px; padding: 3px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 999px; }
.icon-btn { display: grid; width: 32px; height: 32px; flex: 0 0 32px; place-items: center; padding: 0; color: var(--muted); background: transparent; border: 0; border-radius: 999px; cursor: pointer; transition: color 150ms ease, background 150ms ease, box-shadow 200ms ease, transform 200ms var(--ease), border-color 150ms ease; }
.icon-btn:hover { color: var(--heading); }
.icon-btn:active { transform: scale(0.92); }
.icon-btn:disabled { cursor: not-allowed; opacity: 0.4; }
.icon-btn.is-active { color: var(--heading); background: var(--surface); box-shadow: 0 1px 4px rgba(0, 0, 0, 0.18); }
.icon-btn svg { width: 15px; height: 15px; }
.icon-btn.is-outline { width: 38px; height: 38px; flex-basis: 38px; background: var(--glass); border: 1px solid var(--line-strong); -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px); }
.icon-btn.is-outline:hover { background: var(--surface-2); border-color: var(--muted); }

/* =====================================================================
   Login gate (mirrors relay /login)
   ===================================================================== */
.auth-gate { position: relative; z-index: 2; display: flex; min-height: 100vh; flex-direction: column; }
.login-top { position: relative; z-index: 2; display: flex; align-items: center; justify-content: space-between; width: min(100% - 32px, 1120px); margin: 0 auto; padding: 20px 0; }
.login-main { position: relative; z-index: 1; display: grid; flex: 1; grid-template-columns: minmax(0, 1.1fr) minmax(340px, 420px); align-items: center; gap: 56px; width: min(100% - 32px, 1120px); margin: 0 auto; padding: 24px 0 64px; }
.login-aside h1 { margin: 14px 0 0; color: var(--heading); font-size: clamp(40px, 6vw, 68px); font-weight: 800; letter-spacing: -0.05em; line-height: 0.98; }
.login-aside h1 span { color: var(--primary-text); }
.login-copy { max-width: 440px; margin: 22px 0 0; color: var(--muted); font-size: 15px; line-height: 1.8; }
.access-signal { display: inline-flex; align-items: center; gap: 10px; margin-top: 26px; padding: 7px 14px; color: var(--muted); background: var(--glass); border: 1px solid var(--line-strong); border-radius: 999px; font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.06em; -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px); }
.access-signal i { position: relative; width: 7px; height: 7px; background: var(--primary); border-radius: 50%; }
.access-signal i::after { position: absolute; inset: 0; content: ''; border-radius: 50%; background: var(--primary); animation: ping 2s var(--ease) infinite; }
.login-card { display: grid; gap: 0; padding: 34px 30px; border-radius: var(--r-xl); box-shadow: var(--shadow); }
.login-card.lit-card:hover { transform: none; }
.login-card h2 { margin: 10px 0 0; color: var(--heading); font-size: 28px; font-weight: 800; letter-spacing: -0.03em; }
.login-hint { margin: 8px 0 22px; color: var(--muted); font-size: 13.5px; }
.login-card .field input { height: 46px; font-size: 15px; }
.login-card .btn { margin-top: 18px; }
.auth-error { margin-top: 10px; padding: 8px 12px; color: var(--danger-text); background: var(--danger-soft); border: 1px solid color-mix(in srgb, var(--danger) 30%, transparent); border-radius: var(--r-sm); font-size: 13px; font-weight: 600; }

@media (max-width: 860px) {
  .login-main { grid-template-columns: 1fr; gap: 28px; padding-top: 8px; }
  .login-aside h1 { font-size: 40px; }
  .login-copy, .access-signal { display: none; }
  .login-card { padding: 26px 20px; }
}

/* =====================================================================
   Kit
   ===================================================================== */
/* ---------- Page header ---------- */
.page-header { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 14px 20px; }
.page-header-copy { min-width: 0; }
.page-header .kicker { display: inline-flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.page-header .kicker::before { width: 6px; height: 6px; content: ''; background: var(--primary); border-radius: 50%; box-shadow: 0 0 10px var(--primary); }
.page-header h1 { color: var(--heading); font-size: clamp(22px, 2.4vw, 28px); font-weight: 800; letter-spacing: -0.02em; line-height: 1.12; }
.page-header p { max-width: 620px; margin: 8px 0 0; color: var(--muted); font-size: 13.5px; line-height: 1.7; }
.page-header-extra { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.page-stack { display: flex; flex-direction: column; gap: 16px; }
.page-stack > * { animation: blur-in 560ms var(--ease) both; }
.page-stack > *:nth-child(2) { animation-delay: 60ms; }
.page-stack > *:nth-child(3) { animation-delay: 110ms; }
.page-stack > *:nth-child(4) { animation-delay: 160ms; }
.page-stack > *:nth-child(n + 5) { animation-delay: 200ms; }

.split { display: grid; gap: 16px; align-items: start; }
.split-3-2 { grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); }
@media (max-width: 1199px) { .split-3-2 { grid-template-columns: minmax(0, 1fr); } }

/* ---------- Glass surfaces ---------- */
.glass-panel,
.section-card {
  position: relative;
  min-width: 0;
  background: var(--glass);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-lg);
  -webkit-backdrop-filter: var(--blur);
  backdrop-filter: var(--blur);
}
.section-card.is-dense { background: var(--glass-strong); }
.section-card-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; padding: 16px 20px 0; }
.section-card-title { display: grid; min-width: 0; gap: 2px; }
.section-card-title strong { overflow: hidden; color: var(--heading); font-size: 15px; font-weight: 800; text-overflow: ellipsis; white-space: nowrap; }
.section-card-title span { overflow: hidden; color: var(--soft); font-family: var(--font-mono); font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.section-card-body { padding: 18px 20px 20px; }
.section-card-body.flush { padding: 10px 8px 8px; }

.link-sm { display: inline-flex; align-items: center; gap: 4px; color: var(--primary-text); font-family: var(--font-mono); font-size: 11.5px; font-weight: 500; letter-spacing: 0.02em; text-decoration: none; white-space: nowrap; transition: opacity 150ms ease, gap 200ms var(--ease); }
.link-sm svg { width: 13px; height: 13px; }
.link-sm:hover { gap: 7px; }

/* ---------- Lit card (spotlight + rim) ---------- */
.lit-card {
  --lx: -1000px;
  --ly: -1000px;
  --lit: 0;
  position: relative;
  isolation: isolate;
  overflow: hidden;
  background: var(--glass);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-lg);
  -webkit-backdrop-filter: var(--blur);
  backdrop-filter: var(--blur);
  transition: transform 350ms var(--ease), border-color 250ms ease, box-shadow 350ms ease;
}
.lit-card:hover { transform: translateY(-3px); box-shadow: var(--shadow); }
.lit-card .spot { position: absolute; inset: 0; z-index: -1; pointer-events: none; background: radial-gradient(300px circle at var(--lx) var(--ly), var(--spot), transparent 70%); opacity: var(--lit); transition: opacity 500ms ease; }
.lit-card .rim { position: absolute; inset: 0; z-index: 5; padding: 1px; border-radius: inherit; pointer-events: none; background: radial-gradient(200px circle at var(--lx) var(--ly), var(--rim), transparent 72%); opacity: var(--lit); transition: opacity 500ms ease; -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0); -webkit-mask-composite: xor; mask: linear-gradient(#000 0 0) content-box exclude, linear-gradient(#000 0 0); }

/* ---------- Metric card ---------- */
.metric-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
@media (max-width: 1099px) { .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.metric-card { display: flex; min-height: 128px; flex-direction: column; padding: 18px 18px 16px; }
.metric-card-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.metric-card-label { color: var(--muted); font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.03em; }
.metric-card-icon { display: grid; width: 32px; height: 32px; place-items: center; color: var(--tone, var(--primary-text)); background: color-mix(in srgb, var(--tone, var(--primary)) 13%, transparent); border: 1px solid color-mix(in srgb, var(--tone, var(--primary)) 24%, transparent); border-radius: 10px; transition: transform 400ms var(--ease), background 300ms ease, color 300ms ease; }
.metric-card-icon svg { width: 16px; height: 16px; }
.lit-card:hover .metric-card-icon { color: var(--primary-ink); background: var(--primary); transform: rotate(-6deg) scale(1.05); }
.metric-card-value { margin-top: 14px; overflow: hidden; color: var(--heading); font-family: var(--font-mono); font-size: clamp(22px, 2.3vw, 28px); font-weight: 600; letter-spacing: -0.02em; line-height: 1.1; font-variant-numeric: tabular-nums; text-overflow: ellipsis; white-space: nowrap; }
.metric-card-helper { margin-top: auto; padding-top: 8px; color: var(--muted); font-size: 12px; line-height: 1.45; }
.metric-card-helper b { font-weight: 650; }

/* ---------- Key/value tiles ---------- */
.kv-item { min-width: 0; padding: 12px 14px; background: color-mix(in srgb, var(--surface-2) 65%, transparent); border: 1px solid var(--line); border-radius: var(--r-md); }
.kv-item-label { display: block; margin-bottom: 5px; color: var(--soft); font-family: var(--font-mono); font-size: 11px; }

/* ---------- Toolbar / search ---------- */
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 10px; }
.toolbar > .grow { flex: 1 1 240px; min-width: 0; }
.search { position: relative; display: block; }
.search svg { position: absolute; top: 50%; left: 13px; width: 15px; height: 15px; color: var(--soft); transform: translateY(-50%); pointer-events: none; }
.search .input { width: 100%; padding-left: 38px; }

/* ---------- Buttons (pill) ---------- */
.btn {
  position: relative;
  display: inline-flex;
  height: 38px;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 0 16px;
  overflow: hidden;
  border: 1px solid transparent;
  border-radius: 999px;
  cursor: pointer;
  font-size: 13.5px;
  font-weight: 650;
  line-height: 1;
  white-space: nowrap;
  text-decoration: none;
  transition: transform 200ms var(--ease), background 200ms ease, border-color 200ms ease, box-shadow 200ms ease, color 200ms ease;
}
.btn svg { width: 15px; height: 15px; }
.btn:active:not(:disabled) { transform: scale(0.97); }
.btn:disabled { cursor: not-allowed; opacity: 0.55; }
.btn-sm { height: 34px; padding: 0 13px; font-size: 13px; }
.btn-lg { height: 46px; padding: 0 22px; font-size: 15px; }
.btn-block { width: 100%; }
.btn-primary { color: var(--primary-ink); background: var(--primary); box-shadow: 0 10px 30px -12px rgba(252, 213, 53, 0.65), inset 0 1px 0 rgba(255, 255, 255, 0.45); }
.btn-primary::after { position: absolute; inset: 0; content: ''; background: linear-gradient(105deg, transparent 30%, rgba(255, 255, 255, 0.55) 50%, transparent 70%); transform: translateX(-120%); pointer-events: none; }
.btn-primary:hover:not(:disabled) { background: var(--primary-hover); }
.btn-primary:hover:not(:disabled)::after { transition: transform 750ms var(--ease); transform: translateX(120%); }
.btn-ghost { color: var(--heading); background: var(--glass); border-color: var(--line-strong); -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px); }
.btn-ghost:hover:not(:disabled) { background: var(--surface-2); border-color: var(--muted); }
.btn-danger { color: #fff; background: var(--danger); box-shadow: 0 10px 28px -14px rgba(246, 70, 93, 0.7); }
.btn-danger:hover:not(:disabled) { background: color-mix(in srgb, var(--danger) 88%, #000); }
#btn-refresh.is-loading svg { animation: spin 900ms linear infinite; }

/* ---------- Segmented filter ---------- */
.seg { display: inline-flex; flex-wrap: wrap; gap: 2px; padding: 3px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 999px; }
.seg button { height: 30px; padding: 0 14px; color: var(--muted); background: transparent; border: 0; border-radius: 999px; cursor: pointer; font-size: 13px; font-weight: 650; white-space: nowrap; transition: color 150ms ease, background 150ms ease, box-shadow 200ms ease; }
.seg button:hover { color: var(--heading); }
.seg button.on { color: var(--heading); background: var(--surface); box-shadow: 0 1px 4px rgba(0, 0, 0, 0.18), inset 0 0 0 1px var(--primary-line); }

/* ---------- Inputs ---------- */
.input,
.field input:not([type='checkbox']),
.field textarea,
.field select {
  width: 100%;
  min-width: 0;
  height: 38px;
  padding: 0 12px;
  color: var(--heading);
  background: color-mix(in srgb, var(--surface-2) 72%, transparent);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-md);
  font-size: 13.5px;
  outline: none;
  transition: border-color 150ms ease, box-shadow 150ms ease, background 150ms ease;
}
.field textarea { height: auto; min-height: 72px; padding: 9px 12px; font-family: var(--font-mono); font-size: 12.5px; line-height: 1.55; resize: vertical; }
.input::placeholder, .field input::placeholder, .field textarea::placeholder { color: var(--soft); }
.input:hover, .field input:hover, .field textarea:hover, .field select:hover { background: var(--surface-2); border-color: var(--muted); }
.input:focus, .field input:focus, .field textarea:focus, .field select:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.field input:disabled, .field textarea:disabled, .field select:disabled { opacity: 0.5; }
select.input, .field select {
  padding-right: 34px;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%238b94a1' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-position: right 11px center;
  background-repeat: no-repeat;
  cursor: pointer;
}
select option { color: var(--heading); background: var(--surface); }
input[type='number'] { -moz-appearance: textfield; font-family: var(--font-mono); }
input[type='number']::-webkit-outer-spin-button, input[type='number']::-webkit-inner-spin-button { margin: 0; -webkit-appearance: none; }
.field { display: grid; min-width: 0; align-content: start; gap: 6px; }
.field-k { color: var(--body); font-size: 12.5px; font-weight: 600; }
.field-help { color: var(--muted); font-size: 12px; line-height: 1.5; }

.form-grid { display: grid; gap: 14px; }
.form-grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form-grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.form-grid.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.form-grid .span-2 { grid-column: span 2; }
.form-box { display: grid; gap: 12px; padding: 14px; background: color-mix(in srgb, var(--surface-2) 55%, transparent); border: 1px dashed var(--line-strong); border-radius: var(--r-md); }
.form-box-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.form-box-head svg { width: 14px; height: 14px; color: var(--primary-text); }
.form-box-head strong { color: var(--heading); font-size: 13px; font-weight: 750; }
.form-box-head span { color: var(--muted); font-size: 12px; }

/* ---------- Switch ---------- */
.switch-row { display: inline-flex; align-items: center; gap: 10px; color: var(--body); cursor: pointer; font-size: 13.5px; font-weight: 600; user-select: none; }
.switch-track { position: relative; width: 38px; height: 22px; flex: 0 0 38px; background: var(--surface-3); border: 1px solid var(--line-strong); border-radius: 999px; transition: background 200ms ease, border-color 200ms ease; }
.switch-track span { position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; background: #fff; border-radius: 50%; box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25); transition: transform 250ms var(--ease); }
.peer:checked + .switch-track { background: var(--primary); border-color: var(--primary); }
.peer:checked + .switch-track span { transform: translateX(16px); background: var(--primary-ink); }
.peer:focus-visible + .switch-track { outline: 2px solid var(--primary); outline-offset: 2px; }

/* ---------- Chips / pills / badges ---------- */
.chip, .pill, .type-badge, .sev {
  display: inline-flex;
  height: 22px;
  flex: 0 0 auto;
  align-items: center;
  gap: 5px;
  padding: 0 9px;
  color: var(--muted);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 999px;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  line-height: 1;
  white-space: nowrap;
}
.pill::before, .sev::before { width: 6px; height: 6px; flex: 0 0 6px; content: ''; background: currentColor; border-radius: 50%; }
.pill.on, .chip.success { color: var(--success-text); background: var(--success-soft); border-color: color-mix(in srgb, var(--success) 28%, transparent); }
.pill.on::before { box-shadow: 0 0 8px var(--success); }
.pill.warn, .chip.danger, .sev.critical { color: var(--danger-text); background: var(--danger-soft); border-color: color-mix(in srgb, var(--danger) 28%, transparent); }
.sev.warning, .chip.warning { color: var(--warning-text); background: var(--warning-soft); border-color: color-mix(in srgb, var(--warning) 30%, transparent); }
.sev.info, .chip.info { color: var(--info-text); background: var(--info-soft); border-color: color-mix(in srgb, var(--info) 28%, transparent); }
.pill.off { color: var(--muted); }
.type-badge.newapi { color: var(--info-text); background: var(--info-soft); border-color: color-mix(in srgb, var(--info) 28%, transparent); }
.type-badge.sub2api { color: var(--violet-text); background: color-mix(in srgb, var(--violet-text) 12%, transparent); border-color: color-mix(in srgb, var(--violet-text) 26%, transparent); }
.type-badge.zivv { color: var(--success-text); background: var(--success-soft); border-color: color-mix(in srgb, var(--success) 28%, transparent); }
.type-badge.derouter { color: var(--primary-text); background: var(--primary-soft); border-color: var(--primary-line); }
.type-badge.wokey { color: var(--warning-text); background: var(--warning-soft); border-color: color-mix(in srgb, var(--warning) 30%, transparent); }

/* ---------- Empty ---------- */
.empty { padding: 28px 16px; color: var(--muted); font-size: 13px; text-align: center; }
.empty.full { grid-column: 1 / -1; }
.glass-panel.empty { padding: 36px 20px; }

/* ---------- Tables ---------- */
.table-card { overflow: hidden; }
.table-scroll { overflow-x: auto; }
.table-scroll.tall { max-height: 70vh; overflow-y: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.data-table thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  padding: 11px 12px;
  color: var(--soft);
  background: color-mix(in srgb, var(--surface-2) 92%, transparent);
  border-bottom: 1px solid var(--line);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.02em;
  text-align: left;
  white-space: nowrap;
}
.data-table th.num, .data-table td.num { text-align: right; }
.data-table tbody td { padding: 11px 12px; color: var(--body); border-bottom: 1px solid var(--line); vertical-align: middle; white-space: nowrap; }
.data-table tbody tr:last-child td { border-bottom: 0; }
.data-table tbody tr { transition: background 150ms ease; }
.data-table tbody tr:hover td { background: color-mix(in srgb, var(--surface-2) 55%, transparent); }
.data-table td.empty { padding: 36px 16px; white-space: normal; }
.data-table .c-idx { color: var(--soft); font-family: var(--font-mono); font-size: 11.5px; }
.data-table .c-name { color: var(--heading); font-weight: 700; }
.data-table .c-mono { font-family: var(--font-mono); font-size: 12px; font-variant-numeric: tabular-nums; }
.data-table .c-dim { color: var(--muted); }
.data-table .c-url { max-width: 230px; overflow: hidden; text-overflow: ellipsis; }
.data-table td.is-danger { color: var(--danger-text); font-weight: 600; }

.row-actions { display: inline-flex; justify-content: flex-end; gap: 4px; }
.data-table .row-actions { display: flex; }
.row-actions button { display: inline-flex; height: 28px; align-items: center; gap: 4px; padding: 0 8px; color: var(--muted); background: transparent; border: 1px solid transparent; border-radius: 999px; cursor: pointer; font-size: 12px; font-weight: 650; transition: color 150ms ease, background 150ms ease, border-color 150ms ease; }
.row-actions button svg { width: 13px; height: 13px; }
.row-actions button:hover { color: var(--heading); background: var(--surface-2); border-color: var(--line); }
.row-actions button.del:hover { color: var(--danger-text); background: var(--danger-soft); border-color: color-mix(in srgb, var(--danger) 28%, transparent); }
@media (max-width: 1599px) {
  .data-table .ra-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  .data-table .row-actions button { width: 30px; justify-content: center; padding: 0; }
}

/* ---------- Modals (native <dialog>) ---------- */
.modal {
  width: min(560px, calc(100vw - 32px));
  max-width: none;
  max-height: calc(100vh - 48px);
  padding: 0;
  overflow: hidden;
  color: var(--body);
  background: var(--glass-solid);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-pop);
  -webkit-backdrop-filter: var(--blur-strong);
  backdrop-filter: var(--blur-strong);
}
.modal.modal-lg { width: min(720px, calc(100vw - 32px)); }
.modal.modal-sm { width: min(440px, calc(100vw - 32px)); }
.modal[open] { animation: pop-in 420ms var(--ease); }
.modal::backdrop { background: var(--overlay); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); }
.modal-inner { display: flex; max-height: calc(100vh - 48px); flex-direction: column; }
.modal-head { display: flex; flex: 0 0 auto; align-items: flex-start; justify-content: space-between; gap: 16px; padding: 20px 24px 16px; border-bottom: 1px solid var(--line); }
.modal-head h3 { margin-top: 6px; color: var(--heading); font-size: 19px; font-weight: 800; letter-spacing: -0.01em; }
.modal-body { display: grid; gap: 16px; padding: 20px 24px 22px; overflow-y: auto; }
.modal-foot { display: flex; flex: 0 0 auto; justify-content: flex-end; gap: 8px; padding: 14px 24px calc(14px + var(--safe-bottom)); background: color-mix(in srgb, var(--surface) 70%, transparent); border-top: 1px solid var(--line); }
.confirm-head { display: flex; align-items: flex-start; gap: 14px; padding: 24px 24px 20px; }
.confirm-icon { display: grid; width: 42px; height: 42px; flex: 0 0 42px; place-items: center; color: var(--danger-text); background: var(--danger-soft); border: 1px solid color-mix(in srgb, var(--danger) 28%, transparent); border-radius: 12px; }
.confirm-icon svg { width: 19px; height: 19px; }
.confirm-head h3 { color: var(--heading); font-size: 16px; font-weight: 800; }
.confirm-head p { margin-top: 6px; color: var(--muted); font-size: 13.5px; }
.confirm-head b { color: var(--heading); }

/* ---------- Toasts ---------- */
#toast-host { position: fixed; right: 24px; bottom: 24px; z-index: 200; display: flex; flex-direction: column; align-items: flex-end; gap: 8px; pointer-events: none; }
.toast { display: inline-flex; max-width: min(420px, calc(100vw - 32px)); align-items: center; gap: 9px; padding: 10px 16px 10px 12px; color: var(--heading); background: var(--glass-solid); border: 1px solid var(--line-strong); border-radius: 999px; box-shadow: var(--shadow-sm); font-size: 13px; font-weight: 600; -webkit-backdrop-filter: var(--blur-strong); backdrop-filter: var(--blur-strong); animation: toast-in 320ms var(--ease) both; transition: opacity 200ms ease, transform 200ms ease; }
.toast::before { width: 8px; height: 8px; flex: 0 0 8px; content: ''; background: var(--tone, var(--info)); border-radius: 50%; box-shadow: 0 0 10px var(--tone, var(--info)); }
.toast.ok { --tone: var(--success); }
.toast.err { --tone: var(--danger); }
.toast.info { --tone: var(--primary); }
.toast.is-leaving { opacity: 0; transform: translateY(6px); }
@keyframes toast-in { from { opacity: 0; filter: blur(6px); transform: translateY(10px); } to { opacity: 1; filter: none; transform: none; } }

/* =====================================================================
   Pages
   ===================================================================== */
/* ---------- Overview: 7-day bar chart ---------- */
.chart-head-extra { display: flex; align-items: flex-end; gap: 18px; }
.chart-sum { display: grid; text-align: right; line-height: 1.2; }
.chart-sum span { color: var(--soft); font-family: var(--font-mono); font-size: 10.5px; }
.chart-sum strong { color: var(--heading); font-size: 18px; font-weight: 600; letter-spacing: -0.02em; }
.bar-chart {
  display: grid;
  height: 224px;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  align-items: end;
  gap: 14px;
  padding: 24px 6px 0;
  background-image: linear-gradient(var(--chart-grid) 1px, transparent 1px);
  background-position: 0 24px;
  background-size: 100% 25%;
  border-bottom: 1px solid var(--line-strong);
}
.bar-col { position: relative; display: flex; height: 100%; min-width: 0; flex-direction: column; align-items: center; justify-content: flex-end; gap: 6px; }
.bar-val { color: var(--chart-tick); font-family: var(--font-mono); font-size: 10.5px; font-variant-numeric: tabular-nums; white-space: nowrap; transition: color 200ms ease; }
.bar-fill { display: block; width: min(100%, 44px); min-height: 3px; background: linear-gradient(180deg, var(--chart-faint), color-mix(in srgb, var(--chart-faint) 55%, transparent)); border-radius: 8px 8px 3px 3px; transition: height 900ms var(--ease), background 200ms ease, box-shadow 200ms ease; }
.bar-col.peak .bar-fill { background: linear-gradient(180deg, var(--chart-primary), color-mix(in srgb, var(--chart-primary) 70%, transparent)); box-shadow: 0 0 24px -4px color-mix(in srgb, var(--chart-primary) 60%, transparent); }
.bar-col.peak .bar-val { color: var(--primary-text); font-weight: 600; }
@media (hover: hover) { .bar-col:hover .bar-fill { background: var(--chart-primary); } }
@media (hover: hover) { .bar-col:hover .bar-val { color: var(--heading); } }
.bar-axis { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 14px; padding: 10px 6px 0; }
.axis-cell { display: grid; color: var(--chart-tick); font-family: var(--font-mono); font-size: 10.5px; line-height: 1.35; text-align: center; }
.axis-cell b { color: var(--body); font-size: 11.5px; font-weight: 600; }
.axis-cell.today b { color: var(--primary-text); }

/* ---------- Overview: health list ---------- */
.health-list { display: grid; gap: 4px; max-height: 330px; margin: -6px -8px; padding: 0 8px; overflow-y: auto; }
.health-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 5px 12px; padding: 9px 8px; border-radius: var(--r-sm); transition: background 150ms ease; }
.health-row:hover { background: color-mix(in srgb, var(--surface-2) 55%, transparent); }
.health-row .h-name { overflow: hidden; color: var(--heading); font-size: 13px; font-weight: 700; text-overflow: ellipsis; white-space: nowrap; }
.health-row .h-bal { color: var(--heading); font-family: var(--font-mono); font-size: 12.5px; font-weight: 500; font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.health-row.warn .h-bal { color: var(--danger-text); }
.health-row .h-bar { grid-column: 1 / -1; height: 5px; overflow: hidden; background: var(--surface-3); border-radius: 5px; }
.health-row .h-bar i { display: block; height: 100%; background: var(--success); border-radius: inherit; transition: width 800ms var(--ease); }
.health-row.warn .h-bar i { background: var(--danger); }
.health-row .h-meta { display: flex; grid-column: 1 / -1; justify-content: space-between; color: var(--muted); font-family: var(--font-mono); font-size: 10.5px; }
.health-row .h-meta span:last-child { color: var(--success-text); }
.health-row.warn .h-meta span:last-child { color: var(--danger-text); }

/* ---------- Overview: mini feed ---------- */
.feed-list { display: grid; }
.feed-row { display: grid; grid-template-columns: 72px minmax(80px, 160px) minmax(0, 1fr) auto; align-items: center; gap: 14px; padding: 11px 12px; border-radius: var(--r-sm); transition: background 150ms ease; }
.feed-row + .feed-row { border-top: 1px solid var(--line); }
.feed-row:hover { background: color-mix(in srgb, var(--surface-2) 55%, transparent); }
.feed-row .t { color: var(--muted); font-family: var(--font-mono); font-size: 11.5px; white-space: nowrap; }
.feed-row .who { overflow: hidden; color: var(--heading); font-size: 13px; font-weight: 700; text-overflow: ellipsis; white-space: nowrap; }
.feed-row .msg { overflow: hidden; color: var(--body); font-size: 13px; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- Platforms: cards ---------- */
.platform-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 14px; align-items: stretch; }
.pcard { display: flex; width: 100%; min-width: 0; flex-direction: column; padding: 18px; color: var(--body); text-align: left; cursor: pointer; animation: fade-up 480ms var(--ease) both; }
.pcard:hover { border-color: var(--primary-line); }
.pcard.warn { background: color-mix(in srgb, var(--danger) 6%, var(--glass)); border-color: color-mix(in srgb, var(--danger) 32%, transparent); }
.pcard.is-paused { opacity: 0.78; }
.pcard-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.pcard-id { min-width: 0; }
.pcard-eyebrow { display: flex; min-width: 0; align-items: center; gap: 8px; }
.pcard-url { min-width: 0; overflow: hidden; color: var(--soft); font-family: var(--font-mono); font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.pcard-name { margin-top: 8px; overflow: hidden; color: var(--heading); font-size: 17px; font-weight: 800; line-height: 1.3; text-overflow: ellipsis; white-space: nowrap; }
.pcard-balance { display: flex; align-items: baseline; gap: 8px; margin-top: 16px; }
.pcard-balance strong { color: var(--heading); font-family: var(--font-mono); font-size: 26px; font-weight: 600; letter-spacing: -0.02em; line-height: 1.1; font-variant-numeric: tabular-nums; }
.pcard.warn .pcard-balance strong { color: var(--danger-text); }
.pcard-balance span { color: var(--muted); font-size: 12px; font-weight: 600; }
.meter { height: 5px; margin-top: 12px; overflow: hidden; background: var(--surface-3); border-radius: 5px; }
.meter i { display: block; height: 100%; background: var(--success); border-radius: inherit; transition: width 800ms var(--ease); }
.pcard.warn .meter i { background: var(--danger); }
.pcard-scale { display: flex; justify-content: space-between; margin-top: 6px; color: var(--muted); font-family: var(--font-mono); font-size: 10.5px; }
.cell-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); margin: 16px 0 14px; overflow: hidden; background: color-mix(in srgb, var(--surface-2) 60%, transparent); border: 1px solid var(--line); border-radius: var(--r-md); }
.cell-grid > div { min-width: 0; padding: 10px 12px; border-bottom: 1px solid var(--line); }
.cell-grid > div:nth-child(odd) { border-right: 1px solid var(--line); }
.cell-grid > div:nth-last-child(-n + 2):nth-child(odd), .cell-grid > div:last-child { border-bottom: 0; }
.cell-grid > div:last-child:nth-child(odd) { grid-column: 1 / -1; border-right: 0; }
.cell-k { color: var(--soft); font-family: var(--font-mono); font-size: 10.5px; }
.cell-v { margin-top: 3px; overflow: hidden; color: var(--heading); font-family: var(--font-mono); font-size: 13px; font-weight: 500; font-variant-numeric: tabular-nums; text-overflow: ellipsis; white-space: nowrap; }
.cell-v.danger { color: var(--danger-text); }
.cell-v.success { color: var(--success-text); }
.spark { display: flex; height: 40px; flex: 0 0 auto; align-items: flex-end; gap: 4px; margin-top: auto; padding-top: 6px; border-top: 1px dashed var(--line); }
.spark span { flex: 1; min-height: 3px; background: var(--chart-faint); border-radius: 3px 3px 1px 1px; transition: background 200ms ease; }
.spark span:last-child { background: var(--chart-primary); }
@media (hover: hover) { .pcard:hover .spark span { background: var(--chart-primary); } }
.pcard.warn .spark span { background: color-mix(in srgb, var(--danger) 45%, transparent); }
.pcard.warn .spark span:last-child { background: var(--danger); }

/* ---------- Groups ---------- */
.groups-list { display: grid; gap: 14px; }
.group-platform.is-error { border-color: color-mix(in srgb, var(--danger) 32%, transparent); }
.group-head-main { display: flex; min-width: 0; align-items: center; gap: 8px; }
.group-head-main strong { overflow: hidden; color: var(--heading); font-size: 15px; font-weight: 800; text-overflow: ellipsis; white-space: nowrap; }
.group-head-side { display: grid; flex: 0 0 auto; text-align: right; line-height: 1.35; }
.group-head-side span { color: var(--muted); font-size: 12px; font-weight: 600; }
.group-head-side small { color: var(--soft); font-family: var(--font-mono); font-size: 11px; }
.group-sub { margin-top: 3px; overflow: hidden; color: var(--soft); font-family: var(--font-mono); font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.group-error-banner { margin: 14px 20px 0; padding: 10px 12px; color: var(--danger-text); background: var(--danger-soft); border: 1px solid color-mix(in srgb, var(--danger) 28%, transparent); border-radius: var(--r-md); font-family: var(--font-mono); font-size: 12px; word-break: break-word; }
.group-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 10px; }
.group-card { min-width: 0; padding: 12px 14px; background: color-mix(in srgb, var(--surface-2) 60%, transparent); border: 1px solid var(--line); border-radius: var(--r-md); transition: border-color 200ms ease, transform 250ms var(--ease), background 200ms ease; }
.group-card:hover { border-color: var(--line-strong); transform: translateY(-1px); background: var(--surface-2); }
.group-card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.group-card-id { min-width: 0; }
.group-name { overflow: hidden; color: var(--heading); font-size: 13.5px; font-weight: 700; text-overflow: ellipsis; white-space: nowrap; }
.group-meta { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.group-meta:empty { display: none; }
.group-channel { display: inline-flex; height: 20px; align-items: center; padding: 0 7px; color: var(--muted); background: var(--surface-3); border-radius: 999px; font-family: var(--font-mono); font-size: 10.5px; }
.group-ratio { flex: 0 0 auto; padding: 3px 9px; color: var(--primary-text); background: var(--primary-soft); border: 1px solid var(--primary-line); border-radius: 999px; font-family: var(--font-mono); font-size: 12.5px; font-weight: 600; font-variant-numeric: tabular-nums; }
.group-card.tone-cheap .group-ratio { color: var(--success-text); background: var(--success-soft); border-color: color-mix(in srgb, var(--success) 28%, transparent); }
.group-card.tone-premium .group-ratio { color: var(--danger-text); background: var(--danger-soft); border-color: color-mix(in srgb, var(--danger) 28%, transparent); }
.group-desc { display: -webkit-box; margin-top: 8px; overflow: hidden; color: var(--muted); font-size: 12px; line-height: 1.55; -webkit-box-orient: vertical; -webkit-line-clamp: 3; word-break: break-word; }
.group-desc.muted { color: var(--soft); font-style: italic; }

/* ---------- History ---------- */
.month-nav { display: inline-flex; align-items: center; gap: 4px; padding: 3px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 999px; }
.month-nav strong { min-width: 104px; color: var(--heading); font-size: 13.5px; font-weight: 600; text-align: center; }
.month-nav .icon-btn:hover:not(:disabled) { background: var(--surface); }
.history-summary { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 10px; }
.history-summary .kv-item { background: var(--glass); border-color: var(--line-strong); -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur); }
.history-summary strong { display: block; overflow: hidden; color: var(--heading); font-size: 16px; font-weight: 600; letter-spacing: -0.01em; text-overflow: ellipsis; white-space: nowrap; }
.history-summary .is-primary { background: color-mix(in srgb, var(--primary) 9%, var(--glass)); border-color: var(--primary-line); }
.history-summary .is-primary strong { color: var(--primary-text); font-size: 20px; }
.history-legend { display: inline-flex; align-items: center; gap: 4px; color: var(--soft); font-family: var(--font-mono); font-size: 10.5px; }
.history-legend span { margin: 0 3px; }
.history-legend i { width: 12px; height: 12px; border: 1px solid var(--line); border-radius: 3px; }
.history-calendar { container-type: inline-size; display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; }
.history-weekday { padding-bottom: 4px; color: var(--soft); font-family: var(--font-mono); font-size: 11px; text-align: center; }
.history-day {
  --lvl: 0%;
  position: relative;
  display: flex;
  min-width: 0;
  min-height: 64px;
  flex-direction: column;
  justify-content: space-between;
  padding: 8px 9px;
  color: var(--body);
  background: color-mix(in srgb, var(--chart-primary) var(--lvl), color-mix(in srgb, var(--surface-2) 70%, transparent));
  border: 1px solid var(--line);
  border-radius: 10px;
  cursor: pointer;
  text-align: left;
  transition: transform 200ms var(--ease), border-color 150ms ease, box-shadow 200ms ease;
}
.history-legend i { background: color-mix(in srgb, var(--chart-primary) var(--lvl, 0%), var(--surface-2)); }
.history-legend .level-1, .history-day[data-level="1"] { --lvl: 10%; }
.history-legend .level-2, .history-day[data-level="2"] { --lvl: 18%; }
.history-legend .level-3, .history-day[data-level="3"] { --lvl: 28%; }
.history-legend .level-4, .history-day[data-level="4"] { --lvl: 40%; }
.history-legend .level-5, .history-day[data-level="5"] { --lvl: 55%; }
.history-legend .level-6, .history-day[data-level="6"] { --lvl: 74%; }
.history-legend .level-7, .history-day[data-level="7"] { --lvl: 92%; }
.history-day[data-level="6"], .history-day[data-level="7"] { color: var(--primary-ink); }
.history-day[data-level="6"] .history-day-number, .history-day[data-level="7"] .history-day-number { color: color-mix(in srgb, var(--primary-ink) 70%, transparent); }
.history-day[data-level="6"] strong, .history-day[data-level="7"] strong { color: var(--primary-ink); }
.history-day:hover { border-color: var(--primary-line); transform: translateY(-1px); }
.history-day.selected { border-color: var(--primary); box-shadow: 0 0 0 2px var(--primary-soft), 0 8px 22px -12px var(--primary); }
.history-day.today::after { position: absolute; top: 8px; right: 8px; width: 6px; height: 6px; content: ''; background: var(--success); border-radius: 50%; box-shadow: 0 0 8px var(--success); }
.history-day-number { color: var(--muted); font-family: var(--font-mono); font-size: 11px; }
.history-day strong { overflow: hidden; color: var(--heading); font-family: var(--font-mono); font-size: 11.5px; font-weight: 600; font-variant-numeric: tabular-nums; text-overflow: ellipsis; white-space: nowrap; }
.history-day .amt-short { display: none; }
@container (max-width: 520px) { .history-day .amt-full { display: none; } .history-day .amt-short { display: inline; } }
.history-day[data-level="3"] .history-day-number, .history-day[data-level="4"] .history-day-number, .history-day[data-level="5"] .history-day-number { color: var(--body); }
.history-day[data-level="0"] strong { color: var(--soft); font-weight: 400; }
.history-day.empty-day { background: transparent; border-color: transparent; cursor: default; }
.history-day.empty-day:hover { transform: none; }
.history-loading { grid-column: 1 / -1; padding: 40px 0; color: var(--muted); text-align: center; }
.history-platform-list, .history-rank-list { display: grid; gap: 4px; }
.history-platform-list { max-height: 460px; overflow-y: auto; }
.history-platform-row { display: grid; grid-template-columns: 26px minmax(0, 1fr) auto; align-items: center; gap: 12px; padding: 10px 6px; border-bottom: 1px solid var(--line); }
.history-platform-row:last-child { border-bottom: 0; }
.history-rank-number, .history-rank-row > span:first-child { display: grid; width: 24px; height: 24px; place-items: center; color: var(--muted); background: var(--surface-2); border-radius: 7px; font-family: var(--font-mono); font-size: 11px; }
.history-platform-row:first-child .history-rank-number, .history-rank-row:first-child > span:first-child { color: var(--primary-ink); background: var(--primary); }
.history-platform-main { display: grid; min-width: 0; gap: 6px; }
.history-platform-main strong { overflow: hidden; color: var(--heading); font-size: 13px; font-weight: 700; text-overflow: ellipsis; white-space: nowrap; }
.history-share-track { height: 4px; overflow: hidden; background: var(--surface-3); border-radius: 4px; }
.history-share-track i { display: block; height: 100%; background: var(--chart-primary); border-radius: inherit; }
.history-platform-metrics { display: grid; justify-items: end; gap: 1px; font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.history-platform-metrics b { color: var(--heading); font-size: 13px; font-weight: 600; }
.history-platform-metrics span { color: var(--muted); font-size: 10.5px; }
.history-rank-list { grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 6px 20px; }
.history-rank-row { display: grid; grid-template-columns: 24px minmax(0, 1fr) auto auto; align-items: center; gap: 12px; padding: 9px 4px; border-bottom: 1px solid var(--line); }
.history-rank-row strong { overflow: hidden; color: var(--heading); font-size: 13px; font-weight: 700; text-overflow: ellipsis; white-space: nowrap; }
.history-rank-row > span:nth-child(3) { color: var(--muted); font-family: var(--font-mono); font-size: 11px; white-space: nowrap; }
.history-rank-row b { color: var(--heading); font-family: var(--font-mono); font-size: 13px; font-weight: 600; font-variant-numeric: tabular-nums; }

/* ---------- Important notifications ---------- */
.important-summary { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.important-summary > span { display: inline-flex; height: 30px; align-items: center; gap: 7px; padding: 0 13px; color: var(--muted); background: var(--glass); border: 1px solid var(--line-strong); border-radius: 999px; font-family: var(--font-mono); font-size: 12px; -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px); }
.important-summary > span b { color: var(--heading); font-weight: 600; }
.important-channel-state svg { width: 14px; height: 14px; }
.important-summary .important-channel-state.on { color: var(--success-text); background: var(--success-soft); border-color: color-mix(in srgb, var(--success) 28%, transparent); }
.important-summary .important-channel-state.off { color: var(--muted); }
.important-settings-foot { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--line); }
.voice-template { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-size: 13px; }
.voice-template > span { margin-right: 4px; color: var(--soft); font-family: var(--font-mono); font-size: 11px; }
.voice-template b, .voice-template em { padding: 3px 9px; border-radius: 7px; font-style: normal; font-weight: 650; }
.voice-template b { color: var(--body); background: var(--surface-2); border: 1px solid var(--line); }
.voice-template em { color: var(--primary-text); background: var(--primary-soft); border: 1px dashed var(--primary-line); }
.subsection-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 10px; padding: 4px 2px 0; }
.subsection-head strong { color: var(--heading); font-size: 16px; font-weight: 800; }
.subsection-head span { color: var(--soft); font-family: var(--font-mono); font-size: 11px; }
.important-rule-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 14px; }
.important-rule-card { display: grid; gap: 14px; padding: 16px 18px; --tone: var(--primary); }
.important-rule-card.sent { --tone: var(--danger); }
.important-rule-card.off { --tone: var(--muted); opacity: 0.78; }
.important-rule-card > header { display: flex; align-items: center; gap: 12px; }
.important-rule-icon { display: grid; width: 36px; height: 36px; flex: 0 0 36px; place-items: center; color: var(--tone); background: color-mix(in srgb, var(--tone) 13%, transparent); border: 1px solid color-mix(in srgb, var(--tone) 26%, transparent); border-radius: 11px; }
.important-rule-card.armed .important-rule-icon { color: var(--primary-text); }
.important-rule-card.sent .important-rule-icon { color: var(--danger-text); }
.important-rule-title { display: grid; flex: 1; min-width: 0; gap: 4px; }
.important-rule-title h4 { overflow: hidden; color: var(--heading); font-size: 15px; font-weight: 800; text-overflow: ellipsis; white-space: nowrap; }
.important-status { justify-self: start; }
.important-status.armed { color: var(--primary-text); background: var(--primary-soft); border-color: var(--primary-line); }
.important-status.sent { color: var(--danger-text); background: var(--danger-soft); border-color: color-mix(in srgb, var(--danger) 28%, transparent); }
.important-actions button { width: 30px; padding: 0; justify-content: center; }
.important-threshold { display: flex; flex-wrap: wrap; align-items: baseline; gap: 8px; padding: 12px 14px; background: color-mix(in srgb, var(--surface-2) 60%, transparent); border: 1px solid var(--line); border-radius: var(--r-md); }
.important-threshold span { color: var(--soft); font-family: var(--font-mono); font-size: 11px; }
.important-threshold strong { color: var(--heading); font-family: var(--font-mono); font-size: 22px; font-weight: 600; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.important-threshold small { margin-left: auto; color: var(--muted); font-family: var(--font-mono); font-size: 11.5px; }
.important-message { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; color: var(--muted); font-size: 12.5px; }
.important-message svg { width: 14px; height: 14px; color: var(--primary-text); }
.important-message b { padding: 1px 8px; color: var(--primary-text); background: var(--primary-soft); border-radius: 6px; font-weight: 650; }
.important-rule-card > footer { padding-top: 10px; color: var(--soft); border-top: 1px dashed var(--line); font-family: var(--font-mono); font-size: 11px; }
.important-empty { display: grid; grid-column: 1 / -1; justify-items: center; gap: 10px; padding: 40px 20px; color: var(--muted); background: var(--glass); border: 1px dashed var(--line-strong); border-radius: var(--r-lg); }
.important-empty svg { width: 26px; height: 26px; color: var(--soft); }
.important-empty b { color: var(--body); }
.voice-preview { display: grid; gap: 4px; padding: 12px 14px; background: var(--primary-soft); border: 1px solid var(--primary-line); border-radius: var(--r-md); }
.voice-preview span { color: var(--primary-text); font-family: var(--font-mono); font-size: 11px; }
.voice-preview strong { color: var(--heading); font-size: 15px; font-weight: 750; }

/* ---------- Alerts timeline ---------- */
.timeline { display: grid; gap: 10px; }
.tl-card { --tone: var(--info); position: relative; padding: 14px 18px 14px 22px; overflow: hidden; background: var(--glass); border: 1px solid var(--line-strong); border-radius: var(--r-lg); -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur); animation: fade-up 420ms var(--ease) both; transition: border-color 200ms ease; }
.tl-card::before { position: absolute; top: 14px; bottom: 14px; left: 0; width: 3px; content: ''; background: var(--tone); border-radius: 0 3px 3px 0; box-shadow: 0 0 12px var(--tone); }
.tl-card:hover { border-color: color-mix(in srgb, var(--tone) 40%, transparent); }
.tl-card.critical { --tone: var(--danger); }
.tl-card.warning { --tone: var(--warning); }
.tl-head { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; color: var(--muted); font-size: 12px; }
.tl-time { color: var(--muted); font-family: var(--font-mono); font-size: 11.5px; }
.tl-platform { color: var(--heading); font-weight: 700; }
.tl-channel { display: inline-flex; align-items: center; gap: 5px; margin-left: auto; color: var(--soft); font-family: var(--font-mono); font-size: 11px; }
.tl-channel svg { width: 13px; height: 13px; }
.tl-msg { margin-top: 8px; color: var(--body); font-size: 13.5px; line-height: 1.65; white-space: pre-wrap; word-break: break-word; }
.tl-meta { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.tl-meta span { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; color: var(--heading); background: color-mix(in srgb, var(--surface-2) 70%, transparent); border: 1px solid var(--line); border-radius: 999px; font-family: var(--font-mono); font-size: 11.5px; }
.tl-meta b { color: var(--soft); font-weight: 500; }

/* ---------- Requests ---------- */
.req-row .ts { color: var(--muted); font-family: var(--font-mono); font-size: 11.5px; }
.req-row .method { display: inline-flex; height: 20px; align-items: center; padding: 0 7px; color: var(--info-text); background: var(--info-soft); border-radius: 6px; font-family: var(--font-mono); font-size: 10.5px; font-weight: 600; }
.req-row .status { display: inline-flex; height: 22px; align-items: center; padding: 0 8px; border-radius: 999px; font-family: var(--font-mono); font-size: 11.5px; font-weight: 600; }
.req-row .status.ok { color: var(--success-text); background: var(--success-soft); }
.req-row .status.err { color: var(--danger-text); background: var(--danger-soft); }
.req-row .url { max-width: 520px; overflow: hidden; font-family: var(--font-mono); font-size: 12px; text-overflow: ellipsis; }
.req-row .url .qs { color: var(--soft); }
.req-row .lat { font-family: var(--font-mono); font-size: 12px; font-variant-numeric: tabular-nums; }

/* =====================================================================
   Mobile: bottom tab bar + more sheet
   ===================================================================== */
.tabbar, .more-sheet, .more-mask { display: none; }

@media (max-width: 1099px) {
  .topbar-clock { display: none; }
}

@media (max-width: 767px) {
  :root { --topbar-h: 56px; --blur: blur(14px) saturate(1.2); --blur-strong: blur(18px) saturate(1.3); }
  .backdrop .grain { display: none; }
  .backdrop i { filter: blur(60px); }
  .sidebar { display: none; }
  .app-main { margin-left: 0; }
  .app-content { padding: 14px 14px calc(var(--tabbar-h) + var(--safe-bottom) + 26px); }
  .topbar-inner { padding: 0 14px; }
  .topbar-title .mobile-brand { display: grid; }
  .topbar-title .mobile-brand .brand-mark { width: 32px; height: 32px; flex-basis: 32px; border-radius: 10px; }
  .topbar-crumb strong { font-size: 16px; }
  .hide-sm { display: none !important; }
  #btn-refresh { width: 38px; padding: 0; }

  .tabbar {
    position: fixed;
    right: 10px;
    bottom: calc(10px + var(--safe-bottom));
    left: 10px;
    z-index: 70;
    display: grid;
    height: var(--tabbar-h);
    grid-template-columns: repeat(5, minmax(0, 1fr));
    padding: 5px;
    background: var(--glass-strong);
    border: 1px solid var(--line-strong);
    border-radius: 22px;
    box-shadow: var(--shadow-pop);
    -webkit-backdrop-filter: var(--blur-strong);
    backdrop-filter: var(--blur-strong);
  }
  .tab-item { position: relative; display: flex; min-width: 0; flex-direction: column; align-items: center; justify-content: center; gap: 2px; padding: 0; color: var(--soft); background: transparent; border: 0; border-radius: 16px; font: inherit; font-size: 10.5px; font-weight: 650; text-decoration: none; cursor: pointer; transition: color 150ms ease, background 200ms ease; }
  .tab-item svg { width: 19px; height: 19px; transition: transform 300ms var(--ease); }
  .tab-item.active { color: var(--heading); background: var(--primary-soft); }
  .tab-item.active svg { color: var(--primary-text); transform: translateY(-1px); }
  .tab-item:active svg { transform: scale(0.9); }

  .more-mask { position: fixed; inset: 0; z-index: 80; display: block; background: var(--overlay); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); opacity: 0; pointer-events: none; transition: opacity 250ms ease; }
  body.nav-open .more-mask { opacity: 1; pointer-events: auto; }
  .more-sheet {
    position: fixed;
    right: 10px;
    bottom: calc(10px + var(--safe-bottom));
    left: 10px;
    z-index: 90;
    display: grid;
    gap: 6px;
    padding: 12px;
    background: var(--glass-solid);
    border: 1px solid var(--line-strong);
    border-radius: 24px;
    box-shadow: var(--shadow-pop);
    -webkit-backdrop-filter: var(--blur-strong);
    backdrop-filter: var(--blur-strong);
    opacity: 0;
    filter: blur(8px);
    transform: translateY(24px) scale(0.98);
    visibility: hidden;
    pointer-events: none;
    transition: opacity 250ms ease, filter 300ms var(--ease), transform 380ms var(--ease), visibility 0s linear 380ms;
  }
  body.nav-open .more-sheet { opacity: 1; filter: none; transform: none; visibility: visible; pointer-events: auto; transition: opacity 250ms ease, filter 300ms var(--ease), transform 380ms var(--ease); }
  .more-sheet-handle { justify-self: center; width: 38px; height: 4px; margin-bottom: 6px; background: var(--line-strong); border-radius: 4px; }
  .more-item { display: flex; min-height: 50px; align-items: center; gap: 12px; padding: 0 14px; color: var(--body); background: transparent; border: 1px solid transparent; border-radius: 14px; font: inherit; font-size: 15px; font-weight: 650; text-align: left; text-decoration: none; cursor: pointer; }
  .more-item svg { width: 18px; height: 18px; color: var(--soft); }
  .more-item.active { color: var(--heading); background: var(--primary-soft); border-color: var(--primary-line); }
  .more-item.active svg { color: var(--primary-text); }
  .more-item.danger, .more-item.danger svg { color: var(--danger-text); }
  .more-divider { height: 1px; margin: 4px 6px; background: var(--line); }
  .more-theme { display: flex; min-height: 50px; align-items: center; justify-content: space-between; padding: 0 8px 0 14px; color: var(--body); font-size: 15px; font-weight: 650; }

  #toast-host { right: 12px; bottom: calc(var(--tabbar-h) + var(--safe-bottom) + 22px); left: 12px; align-items: center; }

  .page-header { align-items: stretch; }
  .page-header-extra { width: 100%; }
  .page-header-extra .seg { width: 100%; }
  .page-header-extra .seg button { flex: 1; padding: 0 8px; }
  .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .metric-card { min-height: 112px; padding: 14px; }
  .metric-card-icon { width: 28px; height: 28px; }
  .metric-card-value { margin-top: 10px; font-size: 19px; }
  .section-card-head { padding: 14px 14px 0; }
  .section-card-body { padding: 14px; }
  .lit-card:hover { transform: none; box-shadow: none; }
  .bar-chart, .bar-axis { gap: 6px; }
  .bar-chart { height: 190px; }
  .bar-val { font-size: 9px; }
  .bar-col:not(.peak):not(:last-child) .bar-val { visibility: hidden; }
  .chart-head-extra .link-sm { display: none; }
  .feed-row { grid-template-columns: minmax(0, 1fr) auto; gap: 4px 10px; }
  .feed-row .t { order: 3; }
  .feed-row .msg { grid-column: 1 / -1; order: 4; white-space: normal; }
  .platform-grid { grid-template-columns: minmax(0, 1fr); }
  .history-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .history-summary .is-primary { grid-column: 1 / -1; }
  .history-calendar { gap: 4px; }
  .history-day { min-height: 50px; padding: 6px; }
  .history-day strong { font-size: 10px; }
  .history-day .amt-full { display: none; }
  .history-day .amt-short { display: inline; }
  .history-rank-list { grid-template-columns: minmax(0, 1fr); }
  .tl-channel { margin-left: 0; }
  .form-grid.cols-2, .form-grid.cols-3, .form-grid.cols-4 { grid-template-columns: minmax(0, 1fr); }
  .form-grid .span-2 { grid-column: auto; }

  /* Dialogs become bottom sheets on phones. */
  .modal, .modal.modal-lg, .modal.modal-sm { width: 100vw; max-width: 100vw; max-height: calc(100vh - 40px); margin: auto 0 0; border-radius: 22px 22px 0 0; border-bottom: 0; }
  .modal-inner { max-height: calc(100vh - 40px); }
  .modal-head, .modal-body { padding-right: 18px; padding-left: 18px; }
}

@media (min-width: 768px) and (max-width: 1199px) {
  .form-grid.cols-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .history-summary { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .history-summary .is-primary { grid-column: span 3; }
}

/* =====================================================================
   Accessibility / fallbacks
   ===================================================================== */
@media (hover: none) {
  .lit-card:hover { transform: none; box-shadow: none; }
}

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

@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  :root { --glass: var(--glass-solid); --glass-strong: var(--glass-solid); }
}
