/* public/inet-theme.css
 *
 * iNet design system — shared by every dashboard page and the login page.
 * Seven theme presets (theme.js: dark, light, midnight, emerald, amethyst,
 * nordic, sunset) — every colour is a token, see «Tokens» below. Soft
 * borders, one accent per theme, reserved for primary actions, active
 * states, focus and counters. Motion uses transform/opacity only and is switched off for
 * prefers-reduced-motion.
 *
 * settings.html / hub.html also use Tailwind (CDN) for layout utilities;
 * the component classes below (.glass, .btn-brand, .badge, …) keep their
 * historical names so markup generated by settings.js/hub.js stays valid.
 */

/* ---------- Tokens ----------
 *
 * Three layers, all on <html> (theme.js sets the attributes before paint):
 *   1. :root                     the default palette (dark «iNet» theme) and
 *                                everything theme-independent;
 *   2. [data-scheme='light']     structural values for light presets:
 *                                shadows, status text, alerts, chat bubbles;
 *   3. [data-theme='<preset>']   one palette per preset (after layer 2, so a
 *                                light preset can still adjust anything).
 * The accent is one channel: --accent-rgb ("r, g, b") feeds every tinted
 * glow, soft fill and border (rgba(var(--accent-rgb), a)), so a preset only
 * names its colours once. Public names for integrations and custom pages:
 * --bg-primary, --card-bg, --accent-color, --text-primary, --border-glow.
 * The iNet logo keeps its brand orange (--logo-grad) in every theme.
 */

:root {
  color-scheme: dark;

  /* Surfaces — a calm, low-glare dark for long shifts. Elevation is
     expressed with a lighter surface + soft shadow, not bright borders. */
  --bg: #0b1220;             /* page */
  --surface: #141d2f;        /* cards, panels, validated chart surface */
  --surface-raised: #19243a; /* menus, popovers, composer */
  --surface-sunken: #0f1828; /* wells inside cards, inputs */
  --surface-hover: #1c2840;
  --border: #22304a;
  --border-strong: #2f3f5c;
  --page-glow: none;         /* optional backdrop gradient behind pages */

  /* Text (WCAG on --bg / --surface: 15.8 / 7.5 / 4.8:1) */
  --text-primary: #e7ecf4;
  --text-secondary: #a0aec3;
  --text-muted: #7b8aa3;

  /* Accent. --brand is for marks, indicators and focus; filled controls
     with white text use --brand-solid (≥ 4.5:1 in every preset). */
  --accent-rgb: 255, 107, 0;
  --brand: #ff6b00;
  --brand-solid: #c24e00;
  --brand-solid-hi: #d55800;  /* top of the button gradient */
  --brand-hover: #ad4500;
  --brand-text: #ff8a3d;     /* accent text on the surfaces (7.2:1) */
  --brand-soft: rgba(var(--accent-rgb), 0.12);
  --brand-border: rgba(var(--accent-rgb), 0.4);
  --brand-grad: linear-gradient(135deg, #ff9a4d 0%, #ff6b00 52%, #e04f00 100%);
  --logo-grad: linear-gradient(135deg, #ff9a4d 0%, #ff6b00 52%, #e04f00 100%);
  --nav-active-bg: linear-gradient(90deg, rgba(var(--accent-rgb), 0.16), rgba(var(--accent-rgb), 0.04));
  --count-bg: var(--brand-solid);   /* unread counters */
  --count-text: #fff;

  /* Data series (validated on --surface) */
  --series-inbound: #ea6200;
  --series-outbound: #3987e5;
  --gauge-ok: var(--good);

  /* Status — always paired with an icon or label */
  --good: #22c55e;
  --warning: #f59e0b;
  --critical: #ef4444;
  --good-text: #4ade80;
  --warning-text: #fbbf24;
  --critical-text: #f87171;

  --radius: 12px;
  --radius-sm: 8px;
  --radius-xs: 6px;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 8px 24px -12px rgba(0, 0, 0, 0.55), 0 1px 2px rgba(0, 0, 0, 0.25);
  --shadow-lg: 0 24px 56px -20px rgba(0, 0, 0, 0.7);

  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);

  --avatar-grad: linear-gradient(145deg, #2c3d5c, #1d2940);
  --nav-bg: rgba(12, 19, 33, 0.82);
  --card-highlight: rgba(255, 255, 255, 0.035);
  --critical-soft: rgba(239, 68, 68, 0.12);
  --alert-lost-bg: #2a1215;
  --alert-lost-text: #fecaca;
  --alert-warn-bg: #2a2110;
  --alert-warn-text: #fde68a;
  --alert-strong: #fff;
  --backdrop: rgba(2, 6, 23, 0.62);

  /* Chat (style.css) and AI assistant (ai.css) */
  --bubble-in: #1a273c;
  --bubble-out-grad: linear-gradient(160deg, #2a5f9e 0%, #1f4b7f 100%);
  --bubble-note: rgba(245, 158, 11, 0.08);
  --note-text: #fde7b0;
  --note-composer-bg: #231f1a;
  --bubble-auto: #241c18;
  --thread-dots: rgba(148, 163, 184, 0.07);
  --ai: #8b7cf6;
  --ai-soft: rgba(139, 124, 246, 0.12);
  --ai-border: rgba(139, 124, 246, 0.4);
  --ai-text: #b4a9ff;
  --ai-escalation-text: #fecaca;

  /* Public aliases */
  --bg-primary: var(--bg);
  --card-bg: var(--surface);
  --accent-color: var(--brand);
  --border-glow: 0 0 0 1px rgba(var(--accent-rgb), 0.35), 0 0 22px -6px rgba(var(--accent-rgb), 0.55);
}

/* ---------- Light base (Светлая, Nordic Slate) ---------- */
:root[data-scheme='light'] {
  color-scheme: light;

  --bg: #f3f5fa;
  --surface: #ffffff;
  --surface-raised: #ffffff;
  --surface-sunken: #f1f4f9;
  --surface-hover: #eaeef6;
  --border: #e1e6ef;
  --border-strong: #c9d2e0;

  /* on #fff: 17.9 / 7.6 / 5.4:1; muted on --bg 4.9:1 */
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #5a6a80;

  --brand-soft: rgba(var(--accent-rgb), 0.1);
  --brand-border: rgba(var(--accent-rgb), 0.35);
  --brand-text: #c2410c;     /* 5.2:1 on white */
  --nav-active-bg: linear-gradient(90deg, rgba(var(--accent-rgb), 0.12), rgba(var(--accent-rgb), 0.03));

  --good-text: #15803d;
  --warning-text: #b45309;
  --critical-text: #b91c1c;

  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06), 0 1px 1px rgba(15, 23, 42, 0.04);
  --shadow-md: 0 10px 28px -14px rgba(15, 23, 42, 0.22), 0 1px 2px rgba(15, 23, 42, 0.06);
  --shadow-lg: 0 28px 60px -24px rgba(15, 23, 42, 0.32);

  --avatar-grad: linear-gradient(145deg, #e8edf6, #d6deeb);
  --nav-bg: rgba(255, 255, 255, 0.86);
  --card-highlight: rgba(255, 255, 255, 0.9);
  --critical-soft: rgba(239, 68, 68, 0.1);
  --alert-lost-bg: #fef2f2;
  --alert-lost-text: #991b1b;
  --alert-warn-bg: #fffbeb;
  --alert-warn-text: #92400e;
  --alert-strong: #450a0a;
  --backdrop: rgba(15, 23, 42, 0.38);

  --series-1: #2f6fd0;
  --series-2: #128a62;
  --series-neutral: #94a3b8;

  --bubble-in: #ffffff;
  --bubble-out-grad: linear-gradient(160deg, #2563eb 0%, #1d4ed8 100%);   /* white text ≥ 5.2:1 */
  --bubble-note: #fff8e6;
  --note-text: #7c4a03;
  --note-composer-bg: #fffaf0;
  --bubble-auto: #fff4ec;
  --thread-dots: rgba(15, 23, 42, 0.06);
  --ai: #6d5ce0;
  --ai-soft: rgba(109, 92, 224, 0.1);
  --ai-border: rgba(109, 92, 224, 0.35);
  --ai-text: #5b4bd0;          /* 6.3:1 on white */
  --ai-escalation-text: #991b1b;
}

/* ---------- Midnight Cyber: obsidian + neon cyan ---------- */
:root[data-theme='midnight'] {
  --bg: #05070d;
  --surface: #0b1020;
  --surface-raised: #0f1529;
  --surface-sunken: #070a15;
  --surface-hover: #121b35;
  --border: #18233f;
  --border-strong: #24345c;
  --page-glow: radial-gradient(900px 500px at 85% -10%, rgba(34, 211, 238, 0.08), transparent 70%), radial-gradient(700px 500px at 0% 110%, rgba(59, 130, 246, 0.07), transparent 70%);
  --text-primary: #e6f3ff;     /* 17:1 */
  --text-secondary: #9fb4d4;   /* 8.6:1 */
  --text-muted: #7489ad;       /* 5.2:1 on --surface */
  --accent-rgb: 34, 211, 238;
  --brand: #22d3ee;
  --brand-solid: #0e7490;      /* white 5.4:1 */
  --brand-solid-hi: #0891b2;
  --brand-hover: #155e75;
  --brand-text: #67e8f9;
  --brand-grad: linear-gradient(135deg, #a5f3fc 0%, #22d3ee 50%, #0891b2 100%);
  --brand-border: rgba(34, 211, 238, 0.45);
  --series-inbound: #22d3ee;
  --series-outbound: #818cf8;
  --gauge-ok: #22d3ee;
  --series-1: #22d3ee;
  --series-2: #818cf8;
  --avatar-grad: linear-gradient(145deg, #13213f, #0b1226);
  --nav-bg: rgba(6, 9, 18, 0.85);
  --card-highlight: rgba(34, 211, 238, 0.06);
  --bubble-in: #0f1a33;
  --bubble-out-grad: linear-gradient(160deg, #0e7490 0%, #155e75 100%);
  --thread-dots: rgba(34, 211, 238, 0.07);
  --border-glow: 0 0 0 1px rgba(34, 211, 238, 0.45), 0 0 26px -4px rgba(34, 211, 238, 0.6);
}

/* ---------- Emerald Forest: charcoal + emerald / mint ---------- */
:root[data-theme='emerald'] {
  --bg: #0c110f;
  --surface: #141b18;
  --surface-raised: #18211d;
  --surface-sunken: #0f1512;
  --surface-hover: #1c2722;
  --border: #22302a;
  --border-strong: #304239;
  --page-glow: radial-gradient(900px 480px at 100% -10%, rgba(16, 185, 129, 0.08), transparent 70%);
  --text-primary: #e7f3ed;
  --text-secondary: #a4bbaf;
  --text-muted: #7a9185;       /* 4.9:1 on --surface */
  --accent-rgb: 16, 185, 129;
  --brand: #10b981;
  --brand-solid: #047857;      /* white 5.5:1 */
  --brand-solid-hi: #059669;
  --brand-hover: #065f46;
  --brand-text: #6ee7b7;
  --brand-grad: linear-gradient(135deg, #a7f3d0 0%, #10b981 50%, #047857 100%);
  --series-inbound: #34d399;
  --series-outbound: #60a5fa;
  --gauge-ok: #34d399;
  --series-1: #34d399;
  --series-2: #60a5fa;
  --avatar-grad: linear-gradient(145deg, #213029, #151d19);
  --nav-bg: rgba(13, 18, 16, 0.85);
  --bubble-in: #19241f;
  --bubble-out-grad: linear-gradient(160deg, #047857 0%, #065f46 100%);
  --thread-dots: rgba(110, 231, 183, 0.06);
}

/* ---------- Amethyst Luxury: deep violet + lavender / gold ---------- */
:root[data-theme='amethyst'] {
  --bg: #110a22;
  --surface: #1a1132;
  --surface-raised: #20163c;
  --surface-sunken: #140c29;
  --surface-hover: #261a46;
  --border: #2e2150;
  --border-strong: #3f2d69;
  --page-glow: radial-gradient(900px 520px at 90% -10%, rgba(168, 85, 247, 0.12), transparent 70%), radial-gradient(700px 420px at 0% 110%, rgba(234, 179, 8, 0.05), transparent 70%);
  --text-primary: #f3edff;
  --text-secondary: #c2b3e3;
  --text-muted: #9584bb;       /* 5.0:1 on --surface */
  --accent-rgb: 168, 85, 247;
  --brand: #a855f7;
  --brand-solid: #7e22ce;      /* white 6.6:1 */
  --brand-solid-hi: #9333ea;
  --brand-hover: #6b21a8;
  --brand-text: #d8b4fe;
  --brand-grad: linear-gradient(135deg, #f0abfc 0%, #a855f7 50%, #6d28d9 100%);
  --count-bg: #e5b94e;         /* gold badges */
  --count-text: #1f1338;
  --series-inbound: #c084fc;
  --series-outbound: #f5c451;
  --gauge-ok: #c084fc;
  --series-1: #c084fc;
  --series-2: #f5c451;
  --avatar-grad: linear-gradient(145deg, #34245e, #1f1540);
  --nav-bg: rgba(17, 10, 34, 0.86);
  --card-highlight: rgba(216, 180, 254, 0.06);
  --bubble-in: #221840;
  --bubble-out-grad: linear-gradient(160deg, #7e22ce 0%, #5b21b6 100%);
  --thread-dots: rgba(216, 180, 254, 0.07);
  --ai: #f5c451;
  --ai-soft: rgba(245, 196, 81, 0.12);
  --ai-border: rgba(245, 196, 81, 0.4);
  --ai-text: #f8d785;
}

/* ---------- Nordic Slate: cool grey + crisp blue (light) ---------- */
:root[data-theme='nordic'] {
  --bg: #e6ebf1;
  --surface: rgba(248, 250, 252, 0.86);
  --surface-raised: #fbfcfd;
  --surface-sunken: #e0e6ee;
  --surface-hover: #dae1eb;
  --border: #cdd6e1;
  --border-strong: #b3c0cf;
  --page-glow: radial-gradient(1000px 520px at 100% -10%, rgba(37, 99, 235, 0.08), transparent 70%), radial-gradient(800px 500px at 0% 110%, rgba(100, 116, 139, 0.12), transparent 70%);
  --text-primary: #1b2533;
  --text-secondary: #475569;
  --text-muted: #56657a;       /* 5.0:1 on --surface */
  --accent-rgb: 37, 99, 235;
  --brand: #2563eb;
  --brand-solid: #1d4ed8;      /* white 6.7:1 */
  --brand-solid-hi: #2563eb;
  --brand-hover: #1e40af;
  --brand-text: #1d4ed8;
  --brand-grad: linear-gradient(135deg, #93c5fd 0%, #3b82f6 50%, #1d4ed8 100%);
  --series-inbound: #2563eb;
  --series-outbound: #0d9488;
  --gauge-ok: #2563eb;
  --series-1: #2563eb;
  --series-2: #0d9488;
  --avatar-grad: linear-gradient(145deg, #dfe6ef, #c9d4e2);
  --nav-bg: rgba(241, 244, 248, 0.72);
  --bubble-in: #fbfcfd;
  --bubble-out-grad: linear-gradient(160deg, #2563eb 0%, #1e40af 100%);
}

/* ---------- Warm Sunset: espresso + amber / coral / gold ---------- */
:root[data-theme='sunset'] {
  --bg: #16100d;
  --surface: #201814;
  --surface-raised: #271d18;
  --surface-sunken: #1a130f;
  --surface-hover: #2d221c;
  --border: #382a22;
  --border-strong: #4b392e;
  --page-glow: radial-gradient(900px 500px at 100% -10%, rgba(255, 111, 97, 0.09), transparent 70%), radial-gradient(700px 480px at 0% 110%, rgba(251, 191, 36, 0.06), transparent 70%);
  --text-primary: #f9ede5;
  --text-secondary: #d3baa9;
  --text-muted: #a68b79;       /* 5.0:1 on --surface */
  --accent-rgb: 255, 111, 97;
  --brand: #ff6f61;
  --brand-solid: #b5362b;      /* white 6.0:1 */
  --brand-solid-hi: #cf4436;
  --brand-hover: #962c23;
  --brand-text: #ffa596;
  --brand-grad: linear-gradient(135deg, #fde68a 0%, #fb923c 45%, #f43f5e 100%);
  --count-bg: #f5b942;
  --count-text: #2a1a0e;
  --series-inbound: #fb923c;
  --series-outbound: #fcd34d;
  --gauge-ok: #fbbf24;
  --series-1: #fb923c;
  --series-2: #fcd34d;
  --avatar-grad: linear-gradient(145deg, #3a2a21, #241914);
  --nav-bg: rgba(22, 16, 13, 0.86);
  --card-highlight: rgba(255, 210, 170, 0.05);
  --bubble-in: #2a201a;
  --bubble-out-grad: linear-gradient(160deg, #b5362b 0%, #8c2a20 100%);
  --thread-dots: rgba(253, 186, 116, 0.07);
}

*, *::before, *::after { box-sizing: border-box; }

html { background: var(--bg); }

body {
  background: transparent;   /* html paints --bg; body::before the preset's glow */
  color: var(--text-primary);
  font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  font-feature-settings: 'cv11', 'ss01', 'tnum' 0;
  text-rendering: optimizeLegibility;
  min-height: 100vh;
}

.font-mono, code, .mono { font-family: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace; }
.tabular { font-variant-numeric: tabular-nums; }

body::before { content: ''; position: fixed; inset: 0; z-index: -1; background: var(--page-glow); pointer-events: none; }

::selection { background: rgba(var(--accent-rgb), 0.3); }

/* Theme switches cross-fade instead of snapping (theme.js / nav.js add
   .theme-anim for 400 ms around the change). */
html.theme-anim, html.theme-anim *, html.theme-anim *::before, html.theme-anim *::after {
  transition: background-color 0.4s ease, border-color 0.4s ease, color 0.3s ease, fill 0.3s ease, box-shadow 0.4s ease !important;
}

h1, h2, h3 { letter-spacing: -0.015em; }
main h1 { font-weight: 700; }

/* ---------- Cards ---------- */

.glass {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  /* a hairline of light along the top edge reads as depth */
  box-shadow: 0 1px 0 var(--card-highlight) inset, var(--shadow-sm);
}

.glass-hover { transition: border-color 0.2s ease, transform 0.25s var(--ease), box-shadow 0.25s ease; }
.glass-hover:hover { border-color: var(--border-strong); transform: translateY(-2px); box-shadow: 0 1px 0 var(--card-highlight) inset, var(--shadow-md); }

/* Kept for markup compatibility; accents are now expressed with borders. */
.glow-brand { position: relative; }

.card-title {
  font-size: 0.95rem;
  font-weight: 650;
  color: var(--text-primary);
  letter-spacing: -0.005em;
}
.card-subtitle { font-size: 0.8rem; color: var(--text-secondary); }
.eyebrow {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}

/* ---------- Navigation: sidebar (desktop) / top bar + drawer (mobile) ----------
 *
 * Every staff page has the same <nav class="hub-nav"> markup; nav.js adds
 * icons, the collapse button, the mobile menu button, badges and the theme
 * toggle. ≥ 1024 px it is a fixed left sidebar (240 px, or a 72 px icon
 * rail when <html data-nav="collapsed">, restored early by theme.js); below
 * that a top bar whose links slide in as a drawer (<html class="nav-open">).
 * Layout uses transform/opacity/width only, so it stays cheap to animate.
 */

:root { --sidenav-w: 244px; --topbar-h: 56px; --topbar-offset: 57px; }
@media (min-width: 1024px) { :root { --topbar-offset: 0px; } }
:root[data-nav='collapsed'] { --sidenav-w: 72px; }

.hub-nav {
  position: sticky;
  top: 0;
  z-index: 35;
  border-bottom: 1px solid var(--border);
}
/* The frosted background sits on a pseudo-element: backdrop-filter on the
   nav itself would make it the containing block of the fixed mobile drawer
   (.nav-right) and trap the drawer inside the 56 px bar. */
.hub-nav::after {
  content: '';
  position: absolute;
  inset: 0;
  z-index: -1;
  background: var(--nav-bg);
  -webkit-backdrop-filter: saturate(160%) blur(14px);
  backdrop-filter: saturate(160%) blur(14px);
  pointer-events: none;
}
.hub-nav > .hub-nav-inner {
  height: var(--topbar-h);
  max-width: none;
  margin: 0;
  padding: 0 12px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.hub-logo {
  width: 32px;
  height: 32px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 15px;
  color: #fff;
  background: var(--logo-grad);
  box-shadow: 0 6px 18px -6px rgba(var(--accent-rgb), 0.65), 0 0 0 1px rgba(255, 255, 255, 0.18) inset;
  flex-shrink: 0;
}
.hub-brand {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  grid-template-rows: auto auto;
  column-gap: 10px;
  align-items: center;
  min-width: 0;
  color: var(--text-primary);
  text-decoration: none;
}
.hub-brand .hub-logo { grid-row: 1 / 3; }
.hub-brand-name { font-weight: 750; font-size: 1rem; letter-spacing: -0.02em; line-height: 1.15; }
.hub-brand-sub { font-size: 0.72rem; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; line-height: 1.2; }

.nav-icon-btn {
  width: 36px;
  height: 36px;
  flex: none;
  display: inline-grid;
  place-items: center;
  border: 1px solid transparent;
  border-radius: 10px;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  transition: background 0.18s ease, color 0.18s ease, border-color 0.18s ease, transform 0.12s ease;
}
.nav-icon-btn:hover { background: var(--surface-hover); color: var(--text-primary); }
.nav-icon-btn:active { transform: scale(0.94); }
.nav-icon-btn svg { width: 18px; height: 18px; }

.nav-right { display: flex; align-items: center; gap: 10px; min-width: 0; flex: 1 1 auto; }
.nav-links { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.nav-link {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  height: 40px;
  padding: 0 12px;
  border-radius: 11px;
  color: var(--text-secondary);
  font-size: 0.86rem;
  font-weight: 550;
  text-decoration: none;
  white-space: nowrap;
  transition: color 0.18s ease, background 0.18s ease, transform 0.12s ease;
}
.nav-link:hover { color: var(--text-primary); background: var(--surface-hover); }
.nav-link:active { transform: scale(0.98); }
.nav-ico { width: 20px; height: 20px; flex: none; display: grid; place-items: center; transition: transform 0.25s var(--ease); }
.nav-ico svg { width: 19px; height: 19px; }
.nav-link:hover .nav-ico { transform: translateX(1px) scale(1.06); }
.nav-label { min-width: 0; overflow: hidden; text-overflow: ellipsis; flex: 1; }
.nav-link[aria-current='page'] {
  color: var(--text-primary);
  background: var(--nav-active-bg);
  box-shadow: 0 0 0 1px var(--brand-border) inset, 0 8px 24px -14px rgba(var(--accent-rgb), 0.7);
}
.nav-link[aria-current='page'] .nav-ico { color: var(--brand); filter: drop-shadow(0 0 6px rgba(var(--accent-rgb), 0.55)); }
.nav-link[aria-current='page']::before {
  content: '';
  position: absolute;
  left: -12px;
  top: 9px;
  bottom: 9px;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: var(--brand-grad);
  box-shadow: 0 0 12px 1px rgba(var(--accent-rgb), 0.7);
}

/* Permission-gated links stay hidden until nav.js confirms the user may
   open them (it adds .is-allowed). */
.nav-link[data-perm]:not(.is-allowed) { display: none; }

/* Counters: solid orange = unread / waiting; red dot = an alert. */
.nav-count[hidden], .nav-badge[hidden] { display: none; }
.nav-count, .nav-badge {
  position: relative;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 10px;
  background: var(--count-bg);
  color: var(--count-text);
  font-size: 0.68rem;
  font-weight: 700;
  display: inline-grid;
  place-items: center;
  font-variant-numeric: tabular-nums;
  flex: none;
}
.nav-badge:not(.is-alert) { background: rgba(245, 158, 11, 0.12); color: var(--warning-text); box-shadow: 0 0 0 1.5px rgba(245, 158, 11, 0.55) inset; }
.nav-badge:not(.is-alert)::after { color: var(--warning); }
.nav-badge.is-alert { min-width: 10px; width: 10px; height: 10px; padding: 0; background: var(--critical); }
.nav-badge.is-alert.is-warn { background: var(--warning); }
.nav-count::after, .nav-badge::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  box-shadow: 0 0 0 0 currentColor;
  color: var(--brand);
  animation: badge-pulse 2.4s var(--ease) infinite;
  pointer-events: none;
}
.nav-badge.is-alert::after { color: var(--critical); }
.nav-badge.is-alert.is-warn::after { color: var(--warning); }
@keyframes badge-pulse {
  0% { box-shadow: 0 0 0 0 color-mix(in srgb, currentColor 55%, transparent); }
  70%, 100% { box-shadow: 0 0 0 7px color-mix(in srgb, currentColor 0%, transparent); }
}
.nav-count.bump, .nav-badge.bump { animation: badge-bump 0.4s var(--ease); }
@keyframes badge-bump { 40% { transform: scale(1.25); } }

/* Tools row: language, theme */
.nav-tools { display: flex; align-items: center; gap: 6px; }
/* Theme picker: the button (palette + the current accent as a dot) opens
   .theme-menu, a fixed popover built by theme.js. */
.theme-toggle { position: relative; }
.theme-toggle svg { transition: transform 0.45s var(--ease); }
.theme-toggle:hover svg { transform: rotate(-18deg) scale(1.05); }
.theme-toggle::after {
  content: '';
  position: absolute;
  right: 5px;
  bottom: 5px;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--brand);
  box-shadow: 0 0 0 2px var(--surface), 0 0 8px rgba(var(--accent-rgb), 0.8);
  transition: background 0.4s ease;
}
.theme-toggle[aria-expanded='true'] { background: var(--surface-hover); color: var(--text-primary); border-color: var(--border); }

.theme-menu {
  position: fixed;
  z-index: 90;
  width: 272px;
  max-height: calc(100vh - 16px);
  overflow-y: auto;
  padding: 6px;
  border-radius: 16px;
  background: var(--surface-raised);
  border: 1px solid var(--border-strong);
  box-shadow: var(--shadow-lg), 0 0 0 1px rgba(var(--accent-rgb), 0.08);
  animation: menu-in 0.22s var(--ease);
  transform-origin: top left;
}
.theme-menu[hidden] { display: none; }
@keyframes menu-in { from { opacity: 0; transform: translateY(6px) scale(0.97); } to { opacity: 1; transform: none; } }
.theme-menu-head { font-size: 0.66rem; font-weight: 650; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-muted); padding: 8px 10px 6px; }
.theme-menu-sep { height: 1px; background: var(--border); margin: 4px 6px; }
.theme-opt {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 8px 10px;
  border: 0;
  border-radius: 11px;
  background: transparent;
  color: var(--text-primary);
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.12s ease;
}
.theme-opt:hover, .theme-opt:focus-visible { background: var(--surface-hover); outline: none; }
.theme-opt:active { transform: scale(0.98); }
.theme-opt[aria-checked='true'] { background: var(--nav-active-bg); box-shadow: 0 0 0 1px var(--brand-border) inset; }
.theme-opt-text { display: flex; flex-direction: column; min-width: 0; flex: 1; line-height: 1.25; }
.theme-opt-name { font-size: 0.84rem; font-weight: 650; }
.theme-opt-note { font-size: 0.7rem; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.theme-check { width: 16px; height: 16px; flex: none; border-radius: 50%; }
.theme-opt[aria-checked='true'] .theme-check { background: var(--brand-solid); box-shadow: 0 0 10px rgba(var(--accent-rgb), 0.6); -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Ccircle cx='8' cy='8' r='8'/%3E%3C/svg%3E"); position: relative; }
.theme-opt[aria-checked='true'] .theme-check::after { content: ''; position: absolute; left: 5px; top: 3px; width: 5px; height: 8px; border: solid #fff; border-width: 0 2px 2px 0; transform: rotate(45deg); }
/* preview dot: the preset's background with its accent as a glowing core */
.theme-dot {
  position: relative;
  width: 26px;
  height: 26px;
  flex: none;
  border-radius: 50%;
  background: var(--dot-bg);
  box-shadow: 0 0 0 1px rgba(148, 163, 184, 0.35) inset, 0 2px 6px -2px rgba(0, 0, 0, 0.5);
}
.theme-dot::after {
  content: '';
  position: absolute;
  inset: 7px;
  border-radius: 50%;
  background: var(--dot-accent);
  box-shadow: 0 0 8px var(--dot-accent);
}
.theme-dot.is-system { display: flex; overflow: hidden; }
.theme-dot.is-system > span { flex: 1; }
.theme-dot.is-system::after { display: none; }

/* Signed-in user */
.nav-user { display: flex; align-items: center; gap: 8px; min-width: 0; }
.nav-user:empty { display: none; }
.nav-user-info { display: flex; align-items: center; gap: 10px; min-width: 0; flex: 1; color: inherit; text-decoration: none; border-radius: 10px; padding: 4px; transition: background 0.18s ease; }
.nav-user-info:hover { background: var(--surface-hover); }
.nav-user-info:hover .nav-user-name { color: var(--brand-text); }
.nav-user-avatar {
  position: relative;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--avatar-grad);
  display: grid;
  place-items: center;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text-primary);
  flex-shrink: 0;
  box-shadow: 0 0 0 2px var(--surface), 0 0 0 3px var(--border-strong);
}
.nav-user-avatar::after {
  content: '';
  position: absolute;
  right: -1px;
  bottom: -1px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--good);
  box-shadow: 0 0 0 2px var(--surface);
}
.nav-user-text { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.nav-user-name { font-size: 0.82rem; font-weight: 650; color: var(--text-primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; transition: color 0.18s ease; }
.nav-user-role { font-size: 0.7rem; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nav-logout { color: var(--text-muted); }
.nav-logout:hover { color: var(--critical-text); background: var(--critical-soft); }

.nav-backdrop { display: none; }

/* ----- Desktop: fixed sidebar ----- */
@media (min-width: 1024px) {
  body:has(> .hub-nav) { padding-left: var(--sidenav-w); transition: padding-left 0.28s var(--ease); }
  .hub-nav {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    width: var(--sidenav-w);
    border-bottom: 0;
    border-right: 1px solid var(--border);
    box-shadow: 1px 0 0 rgba(255, 255, 255, 0.02), 12px 0 40px -30px rgba(0, 0, 0, 0.6);
    transition: width 0.28s var(--ease);
    overflow: hidden;
  }
  .hub-nav::before {
    /* soft brand light at the top of the rail */
    content: '';
    position: absolute;
    inset: -80px -60px auto -60px;
    height: 220px;
    background: radial-gradient(closest-side, rgba(var(--accent-rgb), 0.16), transparent);
    pointer-events: none;
  }
  .hub-nav > .hub-nav-inner { position: relative; height: 100%; flex-direction: column; align-items: stretch; padding: 16px 12px 14px; gap: 14px; }
  .hub-brand { padding: 2px 4px 6px; }
  .nav-menu-btn { display: none; }
  .nav-collapse-btn { position: absolute; top: 18px; right: 10px; width: 30px; height: 30px; border-color: var(--border); background: var(--surface); }
  .nav-collapse-btn svg { transition: transform 0.28s var(--ease); }
  :root[data-nav='collapsed'] .nav-collapse-btn svg { transform: rotate(180deg); }
  .hub-brand { padding-right: 36px; }
  .nav-right { flex-direction: column; align-items: stretch; flex: 1; min-height: 0; gap: 12px; }
  .nav-links { flex: 1; min-height: 0; overflow-y: auto; overflow-x: hidden; padding: 2px 0 2px 12px; margin-left: -12px; }
  .nav-section-label { font-size: 0.66rem; font-weight: 650; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-muted); padding: 4px 12px 6px; }
  .nav-tools { justify-content: space-between; padding: 0 2px; }
  .nav-user { border-top: 1px solid var(--border); padding-top: 12px; }

  /* Collapsed: icon rail with tooltips */
  :root[data-nav='collapsed'] .hub-brand { grid-template-columns: auto; padding-right: 4px; justify-content: center; }
  :root[data-nav='collapsed'] .hub-brand-name,
  :root[data-nav='collapsed'] .hub-brand-sub,
  :root[data-nav='collapsed'] .nav-label,
  :root[data-nav='collapsed'] .nav-section-label,
  :root[data-nav='collapsed'] .nav-user-text { display: none; }
  :root[data-nav='collapsed'] .nav-collapse-btn { position: static; align-self: center; }
  :root[data-nav='collapsed'] .nav-link { justify-content: center; padding: 0; gap: 0; }
  :root[data-nav='collapsed'] .nav-link .nav-count,
  :root[data-nav='collapsed'] .nav-link .nav-badge { position: absolute; top: 2px; right: 4px; min-width: 16px; height: 16px; font-size: 0.6rem; padding: 0 4px; }
  :root[data-nav='collapsed'] .nav-link .nav-badge.is-alert { min-width: 9px; width: 9px; height: 9px; padding: 0; }
  :root[data-nav='collapsed'] .nav-tools { flex-direction: column; gap: 8px; }
  :root[data-nav='collapsed'] .nav-tools .lang-switch { flex-direction: column; }
  :root[data-nav='collapsed'] .nav-user { flex-direction: column; }
  :root[data-nav='collapsed'] .nav-user-info { justify-content: center; flex: none; }
  .nav-link[data-tip] { overflow: visible; }
}

/* ----- Below 1024 px: top bar + slide-in drawer ----- */
@media (max-width: 1023.98px) {
  .nav-collapse-btn { display: none; }
  .hub-brand { flex: 1; }
  .nav-right {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 70;
    width: min(300px, 86vw);
    flex-direction: column;
    align-items: stretch;
    gap: 14px;
    padding: 18px 12px 16px;
    background: var(--surface);
    border-right: 1px solid var(--border);
    box-shadow: var(--shadow-lg);
    transform: translateX(-105%);
    visibility: hidden;
    transition: transform 0.3s var(--ease), visibility 0s linear 0.3s;
    overflow-y: auto;
  }
  html.nav-open .nav-right { transform: none; visibility: visible; transition: transform 0.3s var(--ease), visibility 0s; }
  /* the drawer lives in the nav's stacking context: lift the nav above the backdrop */
  html.nav-open .hub-nav { z-index: 70; }
  .nav-links { flex: 1; padding-left: 12px; margin-left: -12px; }
  .nav-tools { justify-content: space-between; }
  .nav-user { border-top: 1px solid var(--border); padding-top: 12px; }
  .nav-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 65;
    background: rgba(2, 6, 23, 0.55);
    -webkit-backdrop-filter: blur(2px);
    backdrop-filter: blur(2px);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
  }
  html.nav-open .nav-backdrop { opacity: 1; pointer-events: auto; }
  html.nav-open, html.nav-open body { overflow: hidden; }
}
@media (max-width: 480px) { .hub-brand-sub { display: none; } }

/* Connection alert under the nav (nav.js) */
.conn-alert { border-bottom: 1px solid; position: relative; z-index: 25; animation: slide-down 0.35s var(--ease); }
.conn-alert[hidden] { display: none; }
.conn-alert.is-lost { background: var(--alert-lost-bg); border-color: rgba(239, 68, 68, 0.45); color: var(--alert-lost-text); }
.conn-alert.is-warning { background: var(--alert-warn-bg); border-color: rgba(245, 158, 11, 0.45); color: var(--alert-warn-text); }
.conn-alert-inner { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; padding: 10px 16px; max-width: 1280px; margin: 0 auto; flex-wrap: wrap; }
.conn-alert-text { font-size: 0.82rem; line-height: 1.45; min-width: 0; flex: 1 1 420px; }
.conn-alert-text strong { font-weight: 700; color: var(--alert-strong); }
.conn-alert-since { margin-left: 8px; opacity: 0.75; font-size: 0.75rem; }
.conn-alert-text ul { margin: 4px 0 0; padding-left: 18px; }
.conn-alert-text p { margin: 4px 0 0; }
.conn-alert-actions { display: flex; gap: 8px; flex-shrink: 0; align-items: center; }
.conn-alert-btn { font: inherit; font-size: 0.78rem; font-weight: 600; height: 30px; padding: 0 12px; border-radius: var(--radius-sm); border: 1px solid currentColor; background: transparent; color: inherit; cursor: pointer; display: inline-flex; align-items: center; text-decoration: none; white-space: nowrap; }
.conn-alert-btn.primary { background: var(--brand-solid); border-color: var(--brand-solid); color: #fff; }
.conn-alert-btn:disabled { opacity: 0.6; cursor: default; }
@keyframes slide-down { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: none; } }

/* ---------- Buttons ---------- */

.btn-brand,
.btn-ghost {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  font-weight: 600;
  font-size: 0.85rem;
  border-radius: var(--radius-sm);
  line-height: 1.2;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease, transform 0.1s ease, box-shadow 0.15s ease;
  text-decoration: none;
}
.btn-brand:active:not([disabled]), .btn-ghost:active:not([disabled]) { transform: scale(0.97); }
.btn-brand {
  position: relative;
  overflow: hidden;
  color: #fff;
  background: linear-gradient(180deg, var(--brand-solid-hi), var(--brand-solid));
  border: 1px solid var(--brand-solid);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.18) inset, 0 6px 18px -8px rgba(var(--accent-rgb), 0.65);
}
/* sheen sweeping across on hover */
.btn-brand::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(105deg, transparent 35%, rgba(255, 255, 255, 0.22) 50%, transparent 65%);
  transform: translateX(-120%);
  transition: transform 0.6s var(--ease);
  pointer-events: none;
}
.btn-brand:hover:not([disabled])::after { transform: translateX(120%); }
.btn-brand:hover { background: linear-gradient(180deg, var(--brand-solid), var(--brand-hover)); border-color: var(--brand-hover); box-shadow: 0 1px 0 rgba(255, 255, 255, 0.18) inset, 0 10px 24px -10px rgba(var(--accent-rgb), 0.75); }
.btn-brand[disabled] { opacity: 0.55; cursor: not-allowed; }

.btn-ghost {
  color: var(--text-primary);
  background: transparent;
  border: 1px solid var(--border-strong);
}
.btn-ghost:hover { background: var(--surface-hover); }
.btn-ghost[aria-pressed='true'] { background: var(--surface-hover); border-color: var(--text-muted); }

.btn-link {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--brand-text);
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
}
.btn-link:hover { text-decoration: underline; }

:where(button, a, input, select, textarea, [tabindex]):focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}

/* ---------- Form fields ---------- */

.field {
  width: 100%;
  background: var(--surface-sunken);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  padding: 0.5rem 0.7rem;
  font-size: 0.85rem;
  font-family: inherit;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.field::placeholder { color: var(--text-muted); }
.field:hover:not(:focus):not(:disabled) { border-color: var(--border-strong); }
.field:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 4px var(--brand-soft); background: var(--surface); }
select.field { cursor: pointer; }

/* ---------- Status dots ----------
   Healthy / warning / critical dots breathe with a soft ring (transform +
   opacity on a pseudo-element, so it costs nothing to repaint). */

.live-dot {
  position: relative;
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 9999px;
  background: var(--text-muted);
  flex-shrink: 0;
}
.live-dot.is-live { background: var(--good); box-shadow: 0 0 8px rgba(34, 197, 94, 0.6); }
.live-dot.is-warn { background: var(--warning); box-shadow: 0 0 8px rgba(245, 158, 11, 0.55); }
.live-dot.is-crit { background: var(--critical); box-shadow: 0 0 8px rgba(239, 68, 68, 0.6); }
.live-dot.is-live::after, .live-dot.is-warn::after, .live-dot.is-crit::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: inherit;
  animation: dot-ping 2s var(--ease) infinite;
}
.live-dot.is-crit::after { animation-duration: 1.2s; }
@keyframes dot-ping { 0% { transform: scale(1); opacity: 0.7; } 80%, 100% { transform: scale(2.6); opacity: 0; } }

/* ---------- Badges ---------- */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
  border: 1px solid var(--border-strong);
  background: transparent;
  color: var(--text-secondary);
  white-space: nowrap;
  line-height: 1.4;
}
.badge-live { color: var(--good-text); border-color: rgba(34, 197, 94, 0.35); background: rgba(34, 197, 94, 0.08); }
.badge-brand { color: var(--brand-text); border-color: var(--brand-border); }

/* ---------- Toasts / modal ---------- */

@keyframes toast-in { from { transform: translateY(10px) scale(0.96); opacity: 0; } to { transform: none; opacity: 1; } }
.toast { animation: toast-in 0.32s var(--ease-spring); box-shadow: var(--shadow-lg); border-radius: var(--radius-sm); }

@keyframes modal-in { from { transform: translateY(10px) scale(0.97); opacity: 0; } to { transform: none; opacity: 1; } }
.modal-panel.glass { background: var(--surface-raised); }
.modal-panel { animation: modal-in 0.28s var(--ease); box-shadow: var(--shadow-lg), 0 0 0 1px var(--border) !important; }
/* Modal backdrops (fixed full-screen wrappers toggled with .hidden/.flex) */
.fixed.inset-0:not(.hidden):has(> .modal-panel) {
  background: var(--backdrop) !important;
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
  animation: backdrop-in 0.25s ease both;
}
@keyframes backdrop-in { from { opacity: 0; } to { opacity: 1; } }

/* Dropdowns and popovers that open with [open]/hidden toggles */
details[open] > :not(summary) { animation: pop-in 0.22s var(--ease); }
@keyframes pop-in { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }

/* ---------- Page entrance ----------
   The page's main content fades and rises in once on load; direct
   children follow with a short stagger. Fill mode is `backwards`, never
   `both`: an animation still in effect after it ends counts as
   will-change: transform, which would make the animated element the
   containing block of fixed descendants (the AI panel lives in .app). */
@keyframes page-in { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
body:has(> .hub-nav) > main > *, body.inbox-page > .app, body.inbox-page > .channel-bar, main.ai-page {
  animation: page-in 0.5s var(--ease) backwards;
}
body:has(> .hub-nav) > main > *:nth-child(2) { animation-delay: 0.05s; }
body:has(> .hub-nav) > main > *:nth-child(3) { animation-delay: 0.1s; }
body:has(> .hub-nav) > main > *:nth-child(4) { animation-delay: 0.15s; }
body:has(> .hub-nav) > main > *:nth-child(n + 5) { animation-delay: 0.2s; }

.spinner {
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: #fff;
  border-radius: 9999px;
  width: 13px;
  height: 13px;
  animation: spin 0.6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

@keyframes fade-up { from { opacity: 0; } to { opacity: 1; } }
.fade-up { animation: fade-up 0.25s ease-out both; }

/* ---------- Data tables ---------- */

table.data { width: 100%; font-size: 0.82rem; border-collapse: collapse; }
table.data th { text-align: left; font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-muted); font-weight: 600; padding: 0.55rem 0.7rem; border-bottom: 1px solid var(--border); white-space: nowrap; }
table.data td { padding: 0.7rem 0.75rem; border-bottom: 1px solid rgba(148, 163, 184, 0.09); color: var(--text-secondary); }
table.data tbody tr { transition: background 0.15s ease; }
table.data tbody tr:hover { background: var(--surface-hover); }
table.data tbody tr:last-child td { border-bottom: none; }
table.data td.num, table.data th.num { text-align: right; font-variant-numeric: tabular-nums; }
table.data td:first-child { color: var(--text-primary); font-weight: 500; }

/* ---------- Scrollbars ---------- */

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

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; transition-duration: 0.001ms !important; }
}

/* ---------- Operator profile (public/user-stats.js) ---------- */
/* Categorical series validated on --surface (dark): blue / aqua, CVD ΔE 19.6. */
:root { --series-1: #3987e5; --series-2: #199e70; --series-neutral: #475672; }
.us-root { min-width: 0; }
.us-head { display: flex; align-items: center; gap: 14px; }
.us-avatar { width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; flex: none; font-weight: 700; font-size: 0.9rem; background: var(--avatar-grad); }
.us-name { font-size: 1.2rem; font-weight: 650; }
.us-sub { font-size: 0.78rem; color: var(--text-muted); margin-top: 2px; }
.us-badge { font-size: 0.68rem; font-weight: 600; color: var(--text-muted); border: 1px solid var(--border-strong); border-radius: 4px; padding: 0 5px; vertical-align: middle; }
.us-tiles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-top: 18px; }
@media (min-width: 720px) { .us-tiles { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (min-width: 1100px) { .us-tiles { grid-template-columns: repeat(6, minmax(0, 1fr)); } }
.us-tile { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px 12px; background: var(--surface); min-width: 0; }
.us-tile-label { font-size: 0.72rem; color: var(--text-secondary); }
.us-tile-value { font-size: 1.4rem; font-weight: 650; font-variant-numeric: tabular-nums; margin-top: 2px; }
.us-tile-hint { font-size: 0.7rem; color: var(--text-muted); margin-top: 2px; }
.us-warn { color: var(--warning-text); font-weight: 600; }
.us-card { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); padding: 16px 20px; margin-top: 14px; min-width: 0; }
.us-h { font-size: 0.95rem; font-weight: 650; }
.us-note { font-size: 0.75rem; color: var(--text-muted); margin-top: 3px; }
.us-sub-h { font-size: 0.7rem; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-muted); margin: 16px 0 8px; }
.us-two { display: grid; gap: 16px; grid-template-columns: minmax(0, 1fr); }
/* Two columns when the profile itself is wide enough (user-stats.js sets
   .is-split from the container width the charts are drawn for). */
.us-two.is-split { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.us-two-cards { gap: 14px; }
.us-two-cards .us-card { margin-top: 14px; }
.us-svg { display: block; overflow: visible; }
.us-grid { stroke: var(--border); stroke-width: 1; }
.us-tick { fill: var(--text-muted); font-size: 10px; font-variant-numeric: tabular-nums; }
.us-legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 0.75rem; color: var(--text-secondary); margin: 6px 0; }
.us-key { display: inline-flex; align-items: center; gap: 6px; }
.us-key i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.us-key b { color: var(--text-primary); font-weight: 600; }
.us-resp-grid { display: grid; gap: 12px; margin-top: 12px; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 640px) { .us-resp-grid { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); } }
.us-resp { border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-sunken); padding: 12px 14px; }
.us-resp-title { font-size: 0.78rem; font-weight: 600; color: var(--text-secondary); }
.us-resp-main { font-size: 1.6rem; font-weight: 650; font-variant-numeric: tabular-nums; margin: 4px 0 8px; }
.us-resp-main span { font-size: 0.75rem; font-weight: 500; color: var(--text-muted); margin-left: 8px; }
.us-dl > div, .us-facts > div { display: flex; justify-content: space-between; gap: 12px; padding: 5px 0; border-top: 1px solid var(--border); font-size: 0.8rem; }
.us-dl dt, .us-facts dt { color: var(--text-secondary); }
.us-dl dd, .us-facts dd { font-weight: 600; font-variant-numeric: tabular-nums; text-align: right; }
.us-facts { display: grid; gap: 0 24px; margin-top: 12px; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 760px) { .us-facts { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.us-facts-tight { grid-template-columns: minmax(0, 1fr) !important; }
.us-vs { font-size: 0.7rem; font-weight: 500; color: var(--text-muted); margin-left: 6px; white-space: nowrap; }
.us-vs.is-better::before { content: '▲ '; color: var(--good-text); }
.us-vs.is-worse::before { content: '▼ '; color: var(--warning-text); }
.us-insights { list-style: none; margin: 12px 0 0; padding: 0; display: grid; gap: 6px; }
.us-insight { display: flex; gap: 10px; align-items: flex-start; font-size: 0.85rem; line-height: 1.45; padding: 8px 10px; border-radius: var(--radius-xs); background: var(--surface-sunken); }
.us-insight-icon { width: 20px; height: 20px; flex: none; border-radius: 50%; display: grid; place-items: center; font-size: 0.75rem; font-weight: 700; color: var(--text-muted); border: 1px solid var(--border-strong); }
.us-insight.is-good .us-insight-icon { color: var(--good-text); border-color: rgba(34, 197, 94, 0.5); }
.us-insight.is-attention .us-insight-icon { color: var(--warning-text); border-color: rgba(245, 158, 11, 0.5); }
.us-heat { display: grid; grid-template-columns: 22px repeat(24, minmax(0, 1fr)); gap: 2px; }
.us-heat-h { font-size: 9px; color: var(--text-muted); text-align: center; }
.us-heat-d { font-size: 10px; color: var(--text-muted); line-height: 14px; }
.us-heat-c { height: 14px; border-radius: 3px; }
.us-heat-c:hover { outline: 1px solid var(--text-secondary); }
.us-heat-legend { display: flex; align-items: center; gap: 3px; justify-content: flex-end; font-size: 10px; color: var(--text-muted); margin-top: 6px; }
.us-heat-legend i { width: 12px; height: 10px; border-radius: 2px; display: inline-block; }
.us-heat-legend span { margin: 0 4px; }
.us-stack { display: flex; gap: 2px; height: 14px; margin-top: 12px; }
.us-stack-seg { border-radius: 3px; min-width: 3px; }
.us-csat { display: flex; gap: 24px; flex-wrap: wrap; align-items: center; margin-top: 12px; }
.us-csat-score { font-size: 2rem; font-weight: 650; font-variant-numeric: tabular-nums; }
.us-csat-score span { display: block; font-size: 0.75rem; font-weight: 500; color: var(--text-muted); }
.us-csat-bars { flex: 1; min-width: 220px; display: grid; gap: 8px; }
.us-csat-row { display: grid; grid-template-columns: 110px 1fr 32px; align-items: center; gap: 10px; font-size: 0.8rem; }
.us-csat-row b { text-align: right; font-variant-numeric: tabular-nums; }
.us-meter { height: 6px; border-radius: 3px; background: var(--surface-sunken); overflow: hidden; }
.us-meter div { height: 100%; background: var(--series-1); border-radius: 3px; }
.us-ratings { list-style: none; padding: 0; margin: 0; }
.us-ratings li { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 0.8rem; padding: 6px 0; border-top: 1px solid var(--border); }
.us-ratings a { color: var(--text-primary); font-weight: 600; text-decoration: none; }
.us-ratings a:hover { color: var(--brand-text); text-decoration: underline; }
.us-muted { color: var(--text-muted); }
.us-empty { font-size: 0.8rem; color: var(--text-muted); padding: 12px 0; }
.us-details { margin-top: 12px; font-size: 0.8rem; }
.us-details summary { cursor: pointer; color: var(--text-secondary); }
.us-table-wrap { max-height: 260px; overflow: auto; margin-top: 8px; }
.us-table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.us-table th, .us-table td { padding: 5px 8px; border-bottom: 1px solid var(--border); text-align: left; }
.us-table th { color: var(--text-muted); font-weight: 600; font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.05em; }
.us-table .num { text-align: right; }
.us-tooltip { position: fixed; left: 0; top: 0; z-index: 100; pointer-events: none; max-width: 280px; padding: 6px 9px; border-radius: 6px; font-size: 0.75rem; background: var(--surface-raised); color: var(--text-primary); border: 1px solid var(--border-strong); box-shadow: var(--shadow-md); }
