/*
 * ETC HQ — premium interface (approved in the ETC HQ).
 *
 * Loaded after app.css, whose rules sit in the lowest cascade layer
 * (legacy): every layer here wins over it, so existing pages keep their
 * markup and take the navy glass look through the shared tokens and the
 * bridge rules at the end of the components layer. The ETC HQ
 * keeps its own copy as the visual reference; nothing here depends on it.
 */

@layer tokens, base, layout, components, materials, motion;

/* ------------------------------------------------------------------ */
/* Tokens                                                              */
/* ------------------------------------------------------------------ */

@layer tokens {
  /* ================================================================ */
  /* Midnight & Pearl (V3). One palette, defined once:                 */
  /*   60 % Midnight Navy  #0B1420  canvas, shell, satin-metal cards   */
  /*   30 % Satin Pearl    #E4E8EC  pearl cards, key figures, menus    */
  /*   10 % accents: Electric Green #00D896 (results, done),           */
  /*        Electric Blue #438BFF (navigation, data, selection),       */
  /*        Neon Orange #FF6600 (TESLA, priority, attention).          */
  /* Every colour below is also exposed as RGB channels (--x-rgb) so   */
  /* tints are written rgb(var(--x-rgb) / alpha) and follow the token. */
  /* Red stays only for errors and money owed (semantic, never decor). */
  /* ================================================================ */
  :root {
    /* Channels */
    --navy-rgb: 11 20 32;            /* #0B1420 */
    --navy-hi-rgb: 22 36 54;
    --pearl-rgb: 228 232 236;        /* #E4E8EC, Satin Pearl */
    --green-rgb: 0 216 150;          /* #00D896 */
    --blue-rgb: 67 139 255;          /* #438BFF */
    --blue-hi-rgb: 150 192 255;
    --orange-rgb: 255 102 0;         /* #FF6600 */
    --orange-hi-rgb: 255 178 122;
    --warn-rgb: 255 122 31;          /* attention: Neon Orange family, never amber */
    --red-rgb: 255 77 87;
    --fg-rgb: 255 255 255;           /* the surface's own foreground tint */

    /* Midnight Navy scale */
    --navy-950: #060c15;
    --navy-900: #0b1420;
    --navy-850: #0f1a29;
    --navy-800: #132134;
    --navy-700: #1a2b42;
    --navy-600: #253a56;
    --glow-primary: rgb(var(--blue-rgb) / 0.20);
    --glow-secondary: rgb(var(--blue-rgb) / 0.08);

    /* Electric Blue scale */
    --blue-300: #9ec2ff;
    --blue-400: #6aa5ff;
    --blue-500: #438bff;
    --blue-600: #2c6fe6;
    --blue-700: #1d55bd;
    --blue-900: #0c2a5e;

    /* Electric Green and Neon Orange */
    --green: #00d896;
    --green-300: #5cf0c0;
    --green-700: #007a55;
    --orange: #ff6600;
    --orange-400: #ff8433;
    --orange-300: #ffa766;

    /* Text on navy */
    --text: #f4f5f2;
    --text-muted: #aab6c6;
    --text-subtle: #8090a6;
    --text-on-light: #0b1420;

    /* Lines */
    --line-soft: rgb(var(--fg-rgb) / 0.06);
    --line: rgb(var(--fg-rgb) / 0.10);
    --line-strong: rgb(var(--fg-rgb) / 0.16);
    --highlight: rgba(255, 255, 255, 0.08);
    --focus-ring: 0 0 0 2px var(--navy-900), 0 0 0 4px var(--blue-500);

    /* Functional states */
    --ok: #00b47d;
    --ok-text: var(--green);
    --error: #e5242d;
    --error-text: #ff6b73;
    --warn: #ff7a1f;

    /* TESLA: Neon Orange is TESLA's signature */
    --tesla: var(--orange);
    --tesla-text: #ff7a24;
    --tesla-soft: rgb(var(--orange-rgb) / 0.16);
    --tesla-glow: rgb(var(--orange-rgb) / 0.22);

    /* Satin Pearl: a softened, cool-neutral pearl with a satin finish.
       No glossy hotspot: a broad, low key light, a faint pearlescent
       sweep and a gentle top-to-bottom falloff. Contrast ratios below are
       measured against the darkest point of the surface (--pearl-bottom). */
    --pearl: #e4e8ec;
    --pearl-hi: #edf0f3;
    --pearl-top: #e9ecf0;
    --pearl-bottom: #d9dee4;
    --pearl-edge: rgba(255, 255, 255, 0.42);
    --pearl-edge-hi: rgba(255, 255, 255, 0.62);   /* the lit top rim */
    --pearl-sheen: rgba(255, 255, 255, 0.30);     /* the pointer's soft light */
    --pearl-well: rgba(243, 245, 248, 0.78);      /* inputs and keys set into pearl */
    --pearl-solid: #e1e5ea;                       /* opaque pearl, where glass cannot be used */
    --pearl-ink: #0b1420;            /* 13:1 on pearl */
    --pearl-ink-muted: #3a4555;      /* 7.4:1 */
    --pearl-ink-subtle: #525d6c;     /* 4.9:1 */
    --pearl-ink-blue: #1a56c4;       /* 4.9:1 */
    --pearl-ink-green: #006647;      /* 5.1:1 */
    --pearl-ink-error: #b0121b;      /* 5.2:1 */
    --pearl-ink-warn: #9a3700;       /* 5.3:1 */
    --pearl-ink-orange: #a33b00;     /* 4.9:1 */
    --pearl-surface:
      radial-gradient(150% 100% at 0% 0%, rgba(255, 255, 255, 0.34), rgba(255, 255, 255, 0) 62%),
      linear-gradient(115deg, rgba(196, 216, 242, 0) 26%, rgba(196, 216, 242, 0.16) 50%, rgba(236, 222, 214, 0.12) 68%, rgba(255, 255, 255, 0) 88%),
      linear-gradient(180deg, var(--pearl-top), var(--pearl-bottom));
    --pearl-grain: 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='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.7 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
    --pearl-grain-faint: 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='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.035 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
    --pearl-rim: inset 0 1px 0 var(--pearl-edge-hi), inset 0 -1px 0 rgb(var(--navy-rgb) / 0.10), inset 0 0 0 1px var(--pearl-edge);
    --pearl-shadow:
      var(--pearl-rim),
      0 1px 1px rgba(0, 0, 0, 0.35),
      0 6px 14px -6px rgba(0, 0, 0, 0.55),
      0 34px 70px -34px rgba(0, 0, 0, 0.9);

    /* Satin anodized navy: brushed hairlines, directional light, grain */
    --brush: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='600' height='120'%3E%3Cfilter id='b'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.002 0.75' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0.05 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23b)'/%3E%3C/svg%3E");
    --grain: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0.045 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
    --satin:
      radial-gradient(140% 90% at 0% 0%, rgba(255, 255, 255, 0.055), rgba(255, 255, 255, 0) 48%),
      linear-gradient(180deg, rgba(255, 255, 255, 0.035), rgba(255, 255, 255, 0) 30%, rgba(0, 0, 0, 0.10) 100%);

    /* Glass levels (smoked glass over the canvas) */
    --glass-0: rgb(var(--fg-rgb) / 0.03);
    --glass-1: rgb(var(--navy-hi-rgb) / 0.62);
    --glass-2: rgb(25 42 64 / 0.72);
    --glass-3: rgb(var(--navy-rgb) / 0.88);
    --sheen: linear-gradient(180deg, rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0) 38%);
    /* Illuminated edge: light falls from the top left. */
    --edge-top: rgba(255, 255, 255, 0.20);
    --edge-mid: rgba(255, 255, 255, 0.05);
    --edge-bottom: rgba(255, 255, 255, 0.07);
    --edge-angle: 160deg;
    /* Layered shadows: contact, body and ambient. */
    --shadow-1: 0 1px 1px rgba(0, 0, 0, 0.4), 0 4px 10px -4px rgba(0, 0, 0, 0.45), 0 26px 52px -26px rgba(0, 0, 0, 0.75);
    --shadow-2: 0 1px 1px rgba(0, 0, 0, 0.45), 0 8px 18px -6px rgba(0, 0, 0, 0.5), 0 40px 80px -34px rgba(0, 0, 0, 0.85), 0 0 90px -40px rgb(var(--blue-rgb) / 0.45);
    --shadow-3: 0 2px 4px rgba(0, 0, 0, 0.3), 0 28px 70px rgba(0, 0, 0, 0.55);
    --blur: 20px;

    /* Data series (redefined on pearl so charts stay readable there) */
    --series-1: var(--blue-500);
    --series-2: var(--pearl);
    --series-3: var(--green);
    --series-4: var(--blue-300);
    --series-5: var(--text-subtle);
    --series-6: #3d5577;

    /* Receivables by age: blue while not due, then red by severity. */
    --age-0: #438bff;   /* not yet due */
    --age-1: #fda4af;   /* 1-30 days late */
    --age-2: #f43f5e;   /* 31-60 days late */
    --age-3: #dc2626;   /* over 60 (61-90 where split further) */
    --age-4: #b91c1c;   /* over 90 days late */
    --age-glow: 0 0 8px rgb(220 38 38 / 0.45);
    --chart-dot-fill: var(--navy-900);
    --surface-solid: var(--navy-850);   /* opaque fill for sticky headers */

    /* Shape */
    --radius-xs: 6px;
    --radius-sm: 10px;
    --radius: 14px;
    --radius-card: 22px;
    --radius-sheet: 26px;

    /* Spacing */
    --space-xs: 4px;
    --space-s: 8px;
    --space-m: 16px;
    --space-l: 24px;
    --space-xl: 32px;

    /* Type */
    --font-sans: "Manrope", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    --font-display: "Sora", "Manrope", -apple-system, BlinkMacSystemFont, sans-serif;

    /* Motion */
    --dur-instant: 120ms;
    --dur-fast: 180ms;
    --dur: 260ms;
    --dur-slow: 420ms;
    --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
    --ease-in-out: cubic-bezier(0.65, 0, 0.35, 1);
    --ease-in: cubic-bezier(0.55, 0, 1, 0.45);
    --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
    --stagger: 70ms;
    --dur-enter: 820ms;

    /* Interactive states */
    --hover-tint: rgb(var(--fg-rgb) / 0.05);
    --press-scale: 0.975;
    --lift: translateY(-3px);

    /* Layout */
    --sidebar: 284px;
    --rail: 76px;
    --topbar: 64px;
    --tabbar: 64px;
    --gutter: 32px;
    --gap: 24px;
  }

  @media (max-width: 1023px) {
    :root { --blur: 16px; --gutter: 20px; --gap: 20px; }
  }
  @media (max-width: 639px) {
    :root { --gutter: 14px; --gap: 14px; --radius-card: 20px; --tabbar: 66px; }
  }
  @media (prefers-reduced-transparency: reduce) {
    :root {
      --glass-1: var(--navy-850);
      --glass-2: var(--navy-800);
      --glass-3: var(--navy-950);
    }
  }
}

/* ------------------------------------------------------------------ */
/* Base                                                                */
/* ------------------------------------------------------------------ */

@layer base {
  *, *::before, *::after { box-sizing: border-box; }
  html {
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
    color-scheme: dark;
    /* A stable gutter keeps card widths (and their container queries) from
       changing when the scrollbar appears. */
    scrollbar-gutter: stable;
    scrollbar-color: var(--navy-600) transparent;
    background: var(--navy-900);
  }
  body {
    margin: 0;
    min-height: 100dvh;
    font-family: var(--font-sans);
    font-size: 15px;
    line-height: 1.5;
    font-weight: 500;
    color: var(--text);
    background: var(--navy-900);
    -webkit-font-smoothing: antialiased;
    caret-color: var(--blue-400);
  }
  /* Ambient light: one fixed layer, painted once (3.1). */
  body::before {
    content: "";
    position: fixed;
    inset: 0;
    z-index: -1;
    pointer-events: none;
    background:
      radial-gradient(55% 45% at 22% -6%, rgb(var(--blue-rgb) / 0.30), transparent 70%),
      radial-gradient(38% 34% at 98% 18%, rgb(var(--blue-rgb) / 0.14), transparent 72%),
      radial-gradient(60% 50% at 70% 115%, rgb(var(--blue-rgb) / 0.14), transparent 70%),
      radial-gradient(120% 90% at 50% 40%, transparent 55%, rgba(3, 7, 14, 0.55) 100%),
      var(--navy-900);
  }
  /* A barely visible grain keeps large dark areas from banding. */
  body::after {
    content: "";
    position: fixed;
    inset: 0;
    z-index: -1;
    pointer-events: none;
    opacity: 0.05;
    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='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0.6 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  }
  ::selection { background: rgb(var(--blue-rgb) / 0.35); color: #fff; }
  ::-webkit-scrollbar { width: 10px; height: 10px; }
  ::-webkit-scrollbar-thumb { background: var(--navy-600); border-radius: 10px; border: 2px solid var(--navy-900); }
  ::-webkit-scrollbar-track { background: transparent; }
  /* Headings and paragraphs: app.css resets their margins; element rules
     here would outrank its classes, so the rest is scoped to this interface. */
  :where(ul, ol, dl, dd, figure, h4)[class*="hq-"], :where([class*="hq-"]) > :where(dd, div > dd) { margin: 0; }
  :where(ul, ol)[class*="hq-"] { padding: 0; list-style: none; }
  /* app.css already makes links and buttons inherit their colour; repeating
     it here (a higher layer) would override its button and link classes. */
  a:where([class*="hq-"]) { color: inherit; text-decoration: none; }
  a, button, summary, [tabindex] { -webkit-tap-highlight-color: transparent; }
  :focus-visible { outline: none; box-shadow: var(--focus-ring); border-radius: var(--radius-sm); }
  button:where([class*="hq-"]) { font: inherit; color: inherit; }
  :where([class*="hq-"]) img, img:where([class*="hq-"]) { display: block; }
  :where([class*="hq-"]) small { font-size: 0.75em; }
  .hq-text-error { color: var(--error-text); }
  .hq-text-warn { color: var(--warn); }
}

/* ------------------------------------------------------------------ */
/* Layout: shell                                                       */
/* ------------------------------------------------------------------ */

@layer layout {
  .hq-app { min-height: 100dvh; }

  /* Sidebar: L3 glass over the ambient light (desktop only). */
  .hq-sidebar { display: none; }

  .hq-main { min-width: 0; }
  /* While the navigation collapses or expands (hq.js), the content slides
     into place without widening the page. */
  .hq-rail-sliding .hq-main { overflow-x: clip; }

  .hq-topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    gap: 12px;
    height: calc(var(--topbar) + env(safe-area-inset-top));
    padding: env(safe-area-inset-top) var(--gutter) 0;
    border-bottom: 1px solid transparent;
    transition: background-color var(--dur) var(--ease-out), border-color var(--dur) var(--ease-out);
  }
  /* The bar turns to glass only once content scrolls underneath it. */
  .hq-scrolled .hq-topbar {
    background: rgb(var(--navy-rgb) / 0.72);
    border-bottom-color: var(--line-soft);
    -webkit-backdrop-filter: blur(var(--blur)) saturate(150%);
    backdrop-filter: blur(var(--blur)) saturate(150%);
  }
  .hq-topbar__brand { display: flex; align-items: center; gap: 10px; }
  .hq-topbar__actions { margin-left: auto; display: flex; align-items: center; gap: 10px; }

  .hq-content {
    max-width: 1520px;
    margin: 0 auto;
    padding: 20px var(--gutter) calc(var(--tabbar) + 48px + env(safe-area-inset-bottom));
    outline: none;
  }

  @media (min-width: 1024px) {
    .hq-app {
      display: grid;
      grid-template-columns: var(--sidebar) minmax(0, 1fr);
    }
    .hq-rail .hq-app { grid-template-columns: var(--rail) minmax(0, 1fr); }
    /* The sidebar floats as one glass panel beside the content. */
    .hq-sidebar {
      position: sticky;
      top: 14px;
      height: calc(100dvh - 28px);
      margin: 14px 0 14px 14px;
      display: flex;
      flex-direction: column;
      gap: 8px;
      padding: 18px 12px 14px;
      border-radius: 26px;
      background: var(--sheen), rgb(var(--navy-rgb) / 0.62);
      box-shadow: var(--shadow-1), inset 0 1px 0 rgba(255, 255, 255, 0.07);
      -webkit-backdrop-filter: blur(var(--blur)) saturate(150%);
      backdrop-filter: blur(var(--blur)) saturate(150%);
      overflow: hidden;
    }
    .hq-sidebar::after {
      content: "";
      position: absolute;
      inset: 0;
      border-radius: inherit;
      padding: 1px;
      background: linear-gradient(180deg, var(--edge-top), var(--edge-mid) 30%, var(--edge-bottom));
      -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);
      pointer-events: none;
    }
    .hq-topbar__brand { display: none; }
    .hq-content { padding-bottom: 48px; }
    .hq-tabbar { display: none !important; }
  }

  /* Dashboard grid (10.2) */
  .hq-grid {
    display: grid;
    grid-template-columns: repeat(12, minmax(0, 1fr));
    gap: var(--gap);
  }
  .hq-grid > * { grid-column: span 12; min-width: 0; }
  @media (min-width: 720px) {
    .hq-span-7, .hq-span-5 { grid-column: span 6; }
  }
  @media (min-width: 1200px) {
    .hq-span-8 { grid-column: span 8; }
    .hq-span-7 { grid-column: span 7; }
    .hq-span-5 { grid-column: span 5; }
    .hq-span-4 { grid-column: span 4; }
  }
}

/* ------------------------------------------------------------------ */
/* Components                                                          */
/* ------------------------------------------------------------------ */

@layer components {
  /* Brand: the official logo, unmodified and matte (no glow, no edge
     light), on a compact pearl satin-glass backing like the welcome
     screen's pane. The logo file is square with empty space above and
     below the mark (the artwork fills about 87 % of its width and 61 % of
     its height), so the image is larger than the backing and centred: the
     backing hugs the mark itself. */
  .hq-brand { display: flex; align-items: center; gap: 12px; padding: 2px 6px 14px; }
  .hq-brand__mark {
    --mark: 52px;
    position: relative;
    display: block;
    flex: none;
    width: 64px;
    height: 46px;
    border-radius: 12px;
    background: var(--pearl-surface);
    box-shadow: var(--pearl-rim), 0 1px 2px rgba(0, 0, 0, 0.35), 0 10px 22px -12px rgba(0, 0, 0, 0.7);
    overflow: hidden;
  }
  .hq-brand__mark::after {
    content: "";
    position: absolute;
    inset: 0;
    opacity: 0.05;
    background-image: var(--pearl-grain);
    pointer-events: none;
  }
  .hq-brand__mark img { position: absolute; left: 50%; top: 50%; width: var(--mark); height: var(--mark); max-width: none; transform: translate(-50%, -50%); }
  .hq-brand__mark--small { --mark: 40px; width: 50px; height: 36px; border-radius: 10px; }
  .hq-rail .hq-sidebar .hq-brand__mark { --mark: 40px; width: 50px; height: 36px; border-radius: 10px; }
  .hq-brand__text { display: grid; line-height: 1.15; }
  .hq-brand__name { font-family: var(--font-display); font-weight: 650; font-size: 17px; letter-spacing: -0.01em; white-space: nowrap; }
  .hq-brand__tag { font-size: 12px; color: var(--text-subtle); }

  /* Navigation */
  .hq-nav { display: grid; gap: 2px; overflow-y: auto; scrollbar-width: none; flex: 1; align-content: start; }
  .hq-nav__heading {
    margin: 16px 12px 6px;
    font-size: 11.5px;
    font-weight: 650;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text-subtle);
    white-space: nowrap;
  }
  .hq-nav__heading:first-child { margin-top: 4px; }
  .hq-nav__list { display: grid; gap: 2px; }
  .hq-nav__link {
    position: relative;
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 42px;
    padding: 0 12px;
    border-radius: 12px;
    color: var(--text-muted);
    font-weight: 600;
    font-size: 14.5px;
    white-space: nowrap;
    transition: background-color var(--dur-fast) var(--ease-out), color var(--dur-fast) var(--ease-out);
  }
  /* One icon slot for every item: 20px outline icons (TESLA's portrait fills the same slot). */
  .hq-nav__link > .icon { width: 20px; height: 20px; stroke-width: 1.75; }
  .hq-nav__link .icon { color: var(--text-subtle); transition: color var(--dur-fast) var(--ease-out); }
  .hq-nav__label { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
  .hq-nav__link:hover { background: rgb(var(--fg-rgb) / 0.045); color: var(--text); }
  .hq-nav__link:hover .icon { color: var(--text-muted); }
  .hq-nav__link[aria-current="page"] {
    color: var(--text);
    background: rgb(var(--blue-rgb) / 0.22);
    box-shadow: inset 0 0 0 1px rgb(var(--blue-rgb) / 0.22), inset 0 1px 0 var(--highlight);
  }
  .hq-nav__link[aria-current="page"] .icon { color: var(--blue-300); }
  /* A slim pearl mark on the active item: the secondary accent, quietly. */
  .hq-nav__link[aria-current="page"]::before {
    content: "";
    position: absolute;
    left: 4px;
    top: 50%;
    width: 3px;
    height: 18px;
    margin-top: -9px;
    border-radius: 3px;
    background: linear-gradient(180deg, var(--pearl-hi), var(--pearl));
  }
  .hq-sidebar .hq-nav__link[aria-current="page"] { view-transition-name: hq-active; }
  .hq-nav__tesla-dot {
    width: 7px;
    height: 7px;
    margin-left: auto;
    border-radius: 50%;
    background: var(--tesla);
    box-shadow: 0 0 0 3px var(--tesla-soft);
  }
  /* A module the user may not open: listed, muted, with one small lock. */
  .hq-nav__link.is-locked { color: var(--text-subtle); }
  .hq-nav__link.is-locked .icon { color: var(--text-subtle); opacity: 0.7; }
  .hq-nav__lock { display: inline-flex; margin-left: auto; }
  .hq-nav__lock .icon { width: 13px; height: 13px; opacity: 0.6; }
  .hq-nav__link.is-locked[aria-current="page"] { color: var(--text-muted); }

  .hq-sidebar__foot {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 4px 0;
    border-top: 1px solid var(--line-soft);
  }
  .hq-user { display: flex; align-items: center; gap: 10px; min-width: 0; flex: 1; }
  .hq-user__text { display: grid; line-height: 1.2; min-width: 0; }
  .hq-user__name { font-size: 13.5px; font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .hq-user__role { font-size: 12px; color: var(--text-subtle); }
  .hq-avatar {
    display: grid;
    place-items: center;
    flex: none;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--navy-700);
    box-shadow: inset 0 0 0 1px var(--line-strong);
    font-family: var(--font-display);
    font-size: 12.5px;
    font-weight: 600;
    color: var(--text-muted);
  }
  .hq-rail-toggle {
    display: grid;
    place-items: center;
    width: 40px;
    height: 40px;
    border: 0;
    border-radius: 12px;
    background: transparent;
    color: var(--text-subtle);
    cursor: pointer;
    transition: background-color var(--dur-fast) var(--ease-out), color var(--dur-fast) var(--ease-out);
  }
  .hq-rail-toggle:hover { background: rgb(var(--fg-rgb) / 0.05); color: var(--text); }

  /* Collapsed rail */
  .hq-rail .hq-sidebar .hq-brand__text,
  .hq-rail .hq-sidebar .hq-nav__label,
  .hq-rail .hq-sidebar .hq-user__text,
  .hq-rail .hq-sidebar .hq-nav__tesla-dot,
  .hq-rail .hq-sidebar .hq-nav__lock { display: none; }
  .hq-rail .hq-sidebar .hq-brand { justify-content: center; padding-inline: 0; }
  .hq-rail .hq-sidebar .hq-nav__heading { height: 1px; margin: 12px 10px; overflow: hidden; color: transparent; background: var(--line-soft); }
  .hq-rail .hq-sidebar .hq-nav__link { justify-content: center; padding: 0; }
  .hq-rail .hq-sidebar .hq-sidebar__foot { flex-direction: column; }
  .hq-rail .hq-sidebar .hq-user { justify-content: center; }
  .hq-rail .hq-rail-toggle:not(.hq-sidebar__welcome) { transform: scaleX(-1); }

  /* Sync status pill (9) */
  .hq-sync {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    height: 36px;
    padding: 0 4px 0 12px;
    border-radius: 999px;
    background: var(--glass-0);
    box-shadow: inset 0 0 0 1px var(--line);
    font-size: 13px;
    color: var(--text-muted);
    white-space: nowrap;
  }
  .hq-sync__icon { position: relative; display: grid; place-items: center; width: 16px; height: 16px; }
  .hq-sync__check { width: 16px; height: 16px; color: var(--ok-text); stroke-width: 2.25; }
  .hq-sync__spinner {
    position: absolute;
    inset: 1px;
    border-radius: 50%;
    border: 2px solid rgb(var(--blue-rgb) / 0.25);
    border-top-color: var(--blue-400);
    opacity: 0;
  }
  .hq-sync[data-state="syncing"] .hq-sync__check { opacity: 0; }
  .hq-sync[data-state="syncing"] .hq-sync__spinner { opacity: 1; animation: hq-spin 0.8s linear infinite; }
  .hq-sync__button {
    display: grid;
    place-items: center;
    width: 30px;
    height: 30px;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: var(--text-subtle);
    cursor: pointer;
    transition: background-color var(--dur-fast) var(--ease-out), color var(--dur-fast) var(--ease-out);
  }
  .hq-sync__button .icon { width: 16px; height: 16px; }
  .hq-sync__button:hover { background: rgb(var(--fg-rgb) / 0.06); color: var(--text); }
  .hq-sync__button:disabled { cursor: default; opacity: 0.5; }
  /* Page header */
  .hq-header {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    justify-content: space-between;
    gap: 16px 24px;
    margin-bottom: 24px;
  }
  .hq-title {
    font-family: var(--font-display);
    font-size: clamp(26px, 2.4vw + 12px, 36px);
    font-weight: 600;
    line-height: 1.1;
    letter-spacing: -0.035em;
    text-wrap: balance;
  }
  .hq-title--icon { display: flex; align-items: center; gap: 14px; }
  .hq-title--icon .icon { width: 30px; height: 30px; color: var(--blue-400); stroke-width: 1.5; }
  .hq-title--tesla .icon { color: var(--tesla); }
  .hq-subtitle { margin-top: 6px; color: var(--text-muted); font-size: 14.5px; max-width: 70ch; }
  .hq-header__controls { display: flex; flex-wrap: wrap; gap: 10px; }
  @media (max-width: 639px) {
    .hq-header__controls { width: 100%; flex-wrap: nowrap; }
    .hq-select { flex: 1 1 0; min-width: 0; }
    .hq-select__button { width: 100%; padding-inline: 12px 10px; }
    .hq-select__button > span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    .hq-menu { min-width: 100%; }
  }

  /* Select (month, site) */
  .hq-select { position: relative; }
  .hq-select__button {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    height: 42px;
    padding: 0 12px 0 14px;
    border-radius: 12px;
    list-style: none;
    cursor: pointer;
    font-weight: 650;
    font-size: 14px;
    background: var(--glass-1);
    box-shadow: inset 0 0 0 1px var(--line), inset 0 1px 0 var(--highlight);
    transition: box-shadow var(--dur-fast) var(--ease-out), background-color var(--dur-fast) var(--ease-out);
    user-select: none;
  }
  .hq-select__button::-webkit-details-marker { display: none; }
  .hq-select__button > .icon:first-child { color: var(--blue-400); width: 18px; height: 18px; }
  .hq-select__button:hover { box-shadow: inset 0 0 0 1px var(--line-strong), inset 0 1px 0 var(--highlight); }
  .hq-select__chevron { width: 16px; height: 16px; color: var(--text-subtle); transition: transform var(--dur) var(--ease-out); }
  .hq-select[open] .hq-select__chevron { transform: rotate(180deg); }
  .hq-select[open] .hq-select__button { box-shadow: inset 0 0 0 1px rgb(var(--blue-rgb) / 0.45), inset 0 1px 0 var(--highlight); }
  .hq-menu {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    z-index: 30;
    min-width: 220px;
    padding: 6px;
    border-radius: var(--radius);
    background: var(--glass-3);
    box-shadow: var(--shadow-3), inset 0 0 0 1px var(--line-strong);
    -webkit-backdrop-filter: blur(var(--blur)) saturate(140%);
    backdrop-filter: blur(var(--blur)) saturate(140%);
    transform-origin: top left;
  }
  .hq-menu--end { left: auto; right: 0; transform-origin: top right; }
  .hq-menu__item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    min-height: 40px;
    padding: 0 12px;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-muted);
  }
  .hq-menu__item:hover { background: rgb(var(--fg-rgb) / 0.06); color: var(--text); }
  .hq-menu__item[aria-current] { color: var(--text); }
  .hq-menu__item .icon { width: 16px; height: 16px; color: var(--blue-400); }

  /* Glass cards (4) */
  /* A glass card is three layers: the tinted fill with a top sheen, a
     1 px light edge that is brightest on top (::after), and a soft
     spotlight that follows the pointer (::before). */
  .hq-card, .hq-pulse {
    position: relative;
    isolation: isolate;
    border-radius: var(--radius-card);
    background: var(--sheen), var(--glass-1);
    box-shadow: var(--shadow-1), inset 0 1px 0 rgba(255, 255, 255, 0.06);
    transition: box-shadow var(--dur) var(--ease-out), transform var(--dur) var(--ease-out);
  }
  .hq-card { container-type: inline-size; padding: 26px 26px 24px; }
  .hq-card::after, .hq-pulse::after {
    content: "";
    position: absolute;
    inset: 0;
    z-index: 2;
    border-radius: inherit;
    padding: 1px;
    background: linear-gradient(180deg, var(--edge-top), var(--edge-mid) 34%, var(--edge-bottom));
    -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);
    pointer-events: none;
  }
  .hq-card::before, .hq-pulse::before {
    content: "";
    position: absolute;
    inset: 0;
    z-index: -1;
    border-radius: inherit;
    background: radial-gradient(520px circle at var(--mx, 50%) var(--my, -30%), rgb(var(--blue-rgb) / 0.075), transparent 62%);
    opacity: 0;
    transition: opacity var(--dur-slow) var(--ease-out);
    pointer-events: none;
  }
  .hq-card.is-lit::before, .hq-pulse.is-lit::before { opacity: 1; }
  .hq-card--hero {
    background:
      radial-gradient(70% 90% at 0% 0%, rgb(var(--blue-rgb) / 0.26), transparent 62%),
      radial-gradient(60% 70% at 100% 100%, rgb(var(--blue-rgb) / 0.08), transparent 70%),
      var(--sheen),
      var(--glass-2);
    box-shadow: var(--shadow-2), inset 0 1px 0 rgba(255, 255, 255, 0.09);
    --edge-top: rgb(var(--blue-hi-rgb) / 0.34);
  }
  .hq-card--tesla { --edge-top: rgb(var(--orange-rgb) / 0.42); }
  @media (max-width: 639px) { .hq-card { padding: 20px 18px 18px; } }
  .hq-card__head { display: flex; align-items: center; gap: 12px; margin-bottom: 20px; min-height: 28px; }
  .hq-card__title { font-family: var(--font-display); font-size: 15.5px; font-weight: 600; letter-spacing: -0.01em; }
  .hq-card__link, .hq-card__meta {
    margin-left: auto;
    display: inline-flex;
    align-items: center;
    gap: 2px;
    font-size: 13px;
    font-weight: 650;
    color: var(--text-subtle);
    white-space: nowrap;
  }
  .hq-card__link { color: var(--blue-400); padding: 4px 4px 4px 8px; border-radius: 8px; transition: color var(--dur-fast) var(--ease-out); }
  .hq-card__link .icon { width: 16px; height: 16px; transition: transform var(--dur-fast) var(--ease-out); }
  .hq-card__link:hover { color: var(--blue-300); }
  .hq-card__link:hover .icon { transform: translateX(2px); }
  .hq-subhead {
    margin: 22px 0 10px;
    font-size: 12px;
    font-weight: 650;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--text-subtle);
  }

  /* Ledger: revenue − costs = result */
  .hq-ledger {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr) auto minmax(0, 1.25fr);
    align-items: start;
    gap: 8px 20px;
    margin-bottom: 18px;
  }
  .hq-ledger__op {
    align-self: center;
    margin-top: 6px;
    font-family: var(--font-display);
    font-size: 24px;
    font-weight: 300;
    color: var(--text-subtle);
  }
  .hq-ledger__label { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 650; color: var(--text-muted); }
  .hq-ledger__value {
    margin-top: 6px;
    font-family: var(--font-display);
    font-size: clamp(26px, 1.7vw + 10px, 34px);
    font-weight: 600;
    letter-spacing: -0.03em;
    line-height: 1.05;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
  }
  /* The month's key figure sits on pearl satin glass: the one light
     surface in the hero, so the eye lands on the result first. */
  .hq-ledger__item--result {
    position: relative;
    isolation: isolate;
    margin: -12px -14px -12px 0;
    padding: 12px 16px 14px;
    border-radius: 18px;
    color: var(--pearl-ink);
    background: var(--pearl-surface);
    box-shadow: var(--pearl-rim), 0 1px 2px rgba(0, 0, 0, 0.3), 0 22px 44px -24px rgba(0, 0, 0, 0.8);
    overflow: hidden;
  }
  .hq-ledger__item--result::after {
    content: "";
    position: absolute;
    inset: 0;
    z-index: -1;
    opacity: 0.05;
    background-image: var(--pearl-grain);
    pointer-events: none;
  }
  .hq-ledger__item--result .hq-ledger__label { color: var(--pearl-ink-muted); }
  .hq-ledger__value--result { font-size: clamp(32px, 2.6vw + 10px, 46px); }
  .hq-ledger__value--result.is-negative { color: var(--pearl-ink-error); }
  .hq-ledger__margin { margin-top: 6px; font-size: 13px; color: var(--pearl-ink-muted); }
  .hq-ledger__margin strong { color: var(--pearl-ink); font-variant-numeric: tabular-nums; }
  .hq-change { display: flex; align-items: center; gap: 6px; margin-top: 6px; font-size: 12.5px; font-weight: 650; color: var(--text-subtle); white-space: nowrap; }
  .hq-change .icon { width: 15px; height: 15px; }
  .hq-change.is-good { color: var(--ok-text); }
  .hq-change.is-bad { color: var(--error-text); }
  .hq-change__vs { font-weight: 500; color: var(--text-subtle); }
  @media (max-width: 719px) {
    .hq-ledger { grid-template-columns: 1fr 1fr; gap: 16px; }
    .hq-ledger__op { display: none; }
    .hq-ledger__item--result { grid-column: 1 / -1; margin: 0; padding: 14px 16px; }
  }

  /* Swatches */
  .hq-swatch { display: inline-block; width: 10px; height: 10px; border-radius: 3px; flex: none; }
  .hq-swatch--revenue { background: var(--blue-400); }
  .hq-swatch--expenses { background: var(--pearl); }

  /* Line chart (8) */
  .hq-chart { position: relative; margin: 0 -6px; }
  .hq-chart--compact, .hq-chart--medium { display: none; }
  @media (max-width: 1199px) {
    .hq-chart--wide { display: none; }
    .hq-chart--medium { display: block; }
  }
  @media (max-width: 639px) {
    .hq-chart--medium { display: none; }
    .hq-chart--compact { display: block; }
  }
  .hq-chart__svg { display: block; width: 100%; height: auto; overflow: visible; }
  .hq-chart__grid line { stroke: var(--line-soft); stroke-width: 1; }
  .hq-chart__grid text, .hq-chart__label { fill: var(--text-subtle); font-size: 12px; font-weight: 500; font-variant-numeric: tabular-nums; }
  .hq-chart__label.is-current { fill: var(--text); font-weight: 700; }
  .hq-chart__line { fill: none; stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round; }
  .hq-chart__line--revenue { stroke: var(--blue-400); filter: drop-shadow(0 4px 10px rgb(var(--blue-rgb) / 0.35)); }
  .hq-chart__line--expenses { stroke: var(--pearl); stroke-width: 2; stroke-dasharray: 0.012 0.008; opacity: 0.85; }
  .hq-chart__dot { opacity: 0; stroke-width: 2.5; transition: opacity var(--dur-fast) var(--ease-out); }
  .hq-chart__dot--revenue { fill: var(--chart-dot-fill); stroke: var(--blue-400); }
  .hq-chart__dot--expenses { fill: var(--chart-dot-fill); stroke: var(--pearl); }
  .hq-chart__dot.is-current, .hq-chart__dot.is-hover { opacity: 1; }
  .hq-chart__guide { stroke: var(--line-strong); stroke-width: 1; opacity: 0; transition: opacity var(--dur-fast) var(--ease-out); }
  .hq-chart.is-hovering .hq-chart__guide { opacity: 1; }
  .hq-chart__hit { fill: transparent; cursor: crosshair; outline: none; }
  .hq-chart__hit:focus-visible { fill: rgb(var(--blue-rgb) / 0.06); }
  .hq-tooltip {
    position: absolute;
    top: 0;
    left: 0;
    z-index: 5;
    min-width: 172px;
    padding: 10px 12px;
    border-radius: 12px;
    color: var(--pearl-ink);
    background: var(--pearl-surface);
    box-shadow: var(--pearl-rim), var(--shadow-3);
    -webkit-backdrop-filter: blur(16px);
    backdrop-filter: blur(16px);
    pointer-events: none;
    font-size: 13px;
    transition: transform var(--dur-fast) var(--ease-out), opacity var(--dur-fast) var(--ease-out);
  }
  .hq-tooltip[hidden] { display: block; opacity: 0; visibility: hidden; }
  .hq-tooltip__title { font-weight: 700; margin-bottom: 4px; text-transform: capitalize; }
  .hq-tooltip__row { display: flex; align-items: center; gap: 8px; color: var(--pearl-ink-muted); }
  .hq-tooltip__row strong { margin-left: auto; padding-left: 12px; color: var(--pearl-ink); font-variant-numeric: tabular-nums; }
  .hq-tooltip__source { margin-top: 6px; font-size: 11.5px; color: var(--pearl-ink-muted); }
  /* On pearl the swatches need their deeper tones to stay distinct. */
  .hq-tooltip .hq-swatch--revenue { background: var(--blue-600); }
  .hq-tooltip .hq-swatch--expenses { background: var(--pearl-ink-subtle); }
  .hq-chart__table { margin: 4px 6px 0; }
  .hq-chart__table summary {
    display: inline-block;
    cursor: pointer;
    font-size: 12.5px;
    font-weight: 600;
    color: var(--text-subtle);
    border-radius: 6px;
  }
  .hq-chart__table summary:hover { color: var(--text-muted); }
  .hq-chart__table[open] summary { margin-bottom: 8px; }

  /* Count badge */
  .hq-count-badge {
    display: grid;
    place-items: center;
    min-width: 24px;
    height: 24px;
    padding: 0 7px;
    border-radius: 999px;
    font-size: 12.5px;
    font-weight: 700;
    color: var(--navy-900);
    background: var(--warn);
    font-variant-numeric: tabular-nums;
  }

  /* Requires attention */
  /* Sized to its own content: a short list should not stretch to its neighbour. */
  .hq-attention { align-self: start; }
  /* Flagged: pearl satin glass, with TESLA's warning pose in its own grid
     column at the top right, beside the title and his note. The list spans
     the full width beneath him, so he never covers a message. */
  .hq-attention--flagged {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-rows: auto 1fr;
    column-gap: 12px;
    color: var(--pearl-ink);
    background: var(--pearl-grain-faint), var(--pearl-surface);
    box-shadow: var(--pearl-shadow);
    --edge-top: rgba(255, 255, 255, 0.95);
    --edge-mid: rgba(255, 255, 255, 0.45);
    --edge-bottom: rgba(255, 255, 255, 0.3);
  }
  .hq-attention--flagged::before { background: radial-gradient(520px circle at var(--mx, 50%) var(--my, -30%), rgba(255, 255, 255, 0.45), transparent 62%); }
  .hq-attention--flagged .hq-attention__head { grid-column: 1; grid-row: 1; margin-bottom: 0; }
  .hq-attention--flagged .hq-count-badge { box-shadow: inset 0 0 0 1px rgb(var(--orange-rgb) / 0.4); }
  .hq-attention__lead {
    grid-column: 1;
    grid-row: 2;
    align-self: end;
    max-width: 30ch;
    margin-bottom: 18px;
    font-size: 13.5px;
    line-height: 1.5;
    color: var(--pearl-ink-muted);
    text-wrap: pretty;
  }
  .hq-attention__lead strong { font-family: var(--font-display); font-size: 12.5px; letter-spacing: 0.06em; color: var(--pearl-ink); }
  /* The whole bust: face, raised hand and the exclamation sign. Its own
     soft fade at the bottom lets him rise out of the list's edge. */
  .hq-attention__tesla {
    grid-column: 2;
    grid-row: 1 / 3;
    align-self: end;
    width: clamp(112px, 44cqi, 180px);
    height: auto;
    margin: -14px -10px 0 0;
  }
  .hq-attention--flagged .hq-attention__list { grid-column: 1 / -1; margin-top: 0; padding-top: 8px; border-top: 1px solid rgb(var(--navy-rgb) / 0.10); }
  @container (max-width: 400px) {
    .hq-attention__tesla { margin: -10px -6px 0 0; }
    .hq-attention__lead { margin-bottom: 14px; font-size: 13px; }
  }
  /* Very narrow: the note moves under TESLA rather than squeeze beside him. */
  @container (max-width: 290px) {
    .hq-attention__lead { grid-column: 1 / -1; grid-row: 3; max-width: none; margin-top: 10px; }
    .hq-attention--flagged .hq-attention__list { grid-row: 4; }
  }
  .hq-attention__list { display: grid; gap: 4px; margin: -6px -10px; }
  .hq-attention__item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 12px 10px;
    border-radius: 14px;
    transition: background-color var(--dur-fast) var(--ease-out);
  }
  .hq-attention__item:hover { background: rgb(var(--fg-rgb) / 0.045); }
  .hq-attention__icon {
    display: grid;
    place-items: center;
    flex: none;
    width: 34px;
    height: 34px;
    border-radius: 10px;
  }
  .hq-attention__icon .icon { width: 18px; height: 18px; }
  .hq-attention__item--error .hq-attention__icon { color: var(--error-text); background: rgb(var(--red-rgb) / 0.14); }
  .hq-attention__item--warn .hq-attention__icon { color: var(--warn); background: rgb(var(--warn-rgb) / 0.12); }
  .hq-attention__body { display: grid; gap: 2px; min-width: 0; flex: 1; }
  .hq-attention__title { font-size: 14px; font-weight: 650; line-height: 1.35; }
  .hq-attention__detail { font-size: 13px; color: var(--text-muted); }
  .hq-attention__detail strong { color: var(--text); font-variant-numeric: tabular-nums; }
  .hq-attention__action { margin-top: 4px; font-size: 12.5px; font-weight: 650; color: var(--blue-300); }
  .hq-attention__chevron { align-self: center; width: 16px; height: 16px; color: var(--text-subtle); transition: transform var(--dur-fast) var(--ease-out), color var(--dur-fast) var(--ease-out); }
  .hq-attention__item:hover .hq-attention__chevron { transform: translateX(3px); color: var(--text-muted); }
  /* On pearl the same states in their deeper, readable tones. */
  .hq-attention--flagged .hq-attention__item:hover { background: rgb(var(--navy-rgb) / 0.05); }
  .hq-attention--flagged .hq-attention__item--error .hq-attention__icon { color: var(--pearl-ink-error); background: rgb(var(--red-rgb) / 0.12); }
  .hq-attention--flagged .hq-attention__item--warn .hq-attention__icon { color: var(--pearl-ink-warn); background: rgb(var(--warn-rgb) / 0.32); }
  .hq-attention--flagged .hq-attention__detail { color: var(--pearl-ink-muted); }
  .hq-attention--flagged .hq-attention__detail strong { color: var(--pearl-ink); }
  .hq-attention--flagged .hq-attention__action { color: var(--pearl-ink-blue); }
  .hq-attention--flagged .hq-attention__chevron,
  .hq-attention--flagged .hq-attention__item:hover .hq-attention__chevron { color: var(--pearl-ink-muted); }

  /* Pulse: one glass strip, four linked figures */
  .hq-pulse {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
  .hq-pulse__item {
    position: relative;
    display: grid;
    gap: 4px;
    padding: 20px 24px;
    border-radius: inherit;
    transition: background-color var(--dur-fast) var(--ease-out);
  }
  .hq-pulse__item + .hq-pulse__item::before {
    content: "";
    position: absolute;
    left: 0;
    top: 18px;
    bottom: 18px;
    width: 1px;
    background: var(--line);
  }
  .hq-pulse__item:hover { background: rgb(var(--fg-rgb) / 0.035); }
  .hq-pulse__label { font-size: 13px; font-weight: 650; color: var(--text-muted); }
  .hq-pulse__value {
    font-family: var(--font-display);
    font-size: 28px;
    font-weight: 600;
    letter-spacing: -0.03em;
    line-height: 1.15;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
  }
  .hq-pulse__value small { font-family: var(--font-sans); font-size: 14px; font-weight: 600; color: var(--text-muted); letter-spacing: 0; }
  .hq-pulse__note { font-size: 12.5px; color: var(--text-subtle); }
  @media (max-width: 899px) {
    .hq-pulse { grid-template-columns: 1fr 1fr; }
    .hq-pulse__item:nth-child(3)::before { display: none; }
    .hq-pulse__item:nth-child(n + 3) { border-top: 1px solid var(--line-soft); }
  }
  @media (max-width: 639px) {
    .hq-pulse__item { padding: 14px 16px; }
    .hq-pulse__value { font-size: 21px; }
  }

  /* Pills */
  .hq-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 26px;
    padding: 0 10px;
    border-radius: 999px;
    font-size: 12.5px;
    font-weight: 650;
    white-space: nowrap;
  }
  .hq-pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
  .hq-pill--active { color: var(--ok-text); background: rgb(var(--green-rgb) / 0.14); }
  .hq-pill--delayed { color: var(--error-text); background: rgb(var(--red-rgb) / 0.14); }
  .hq-pill--closing { color: var(--blue-300); background: rgb(var(--blue-rgb) / 0.14); }
  .hq-pill--prio-high { color: var(--blue-300); background: rgb(var(--blue-rgb) / 0.16); box-shadow: inset 0 0 0 1px rgb(var(--blue-rgb) / 0.3); }
  .hq-pill--prio-medium { color: var(--text-muted); background: rgb(var(--fg-rgb) / 0.05); box-shadow: inset 0 0 0 1px var(--line); }

  /* Sites: recorded figures only (no completion percentages) */
  .hq-sites { display: grid; }
  .hq-site {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto auto;
    align-items: center;
    gap: 10px 22px;
    padding: 16px 0;
    border-top: 1px solid var(--line-soft);
  }
  .hq-site:first-child { border-top: 0; padding-top: 2px; }
  .hq-site__name { font-weight: 700; font-size: 15px; }
  .hq-site__meta { margin-top: 2px; font-size: 12.5px; color: var(--text-subtle); }
  .hq-site__stats { display: flex; gap: 22px; }
  .hq-site__stats div { display: grid; min-width: 3.5rem; text-align: right; }
  .hq-site__stats dt { font-size: 11.5px; font-weight: 600; color: var(--text-subtle); }
  .hq-site__stats dd { font-family: var(--font-display); font-size: 17px; font-weight: 600; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; white-space: nowrap; }
  .hq-site__stats dd small { font-family: var(--font-sans); font-size: 12px; font-weight: 600; color: var(--text-subtle); }
  @container (max-width: 560px) {
    .hq-site { grid-template-columns: minmax(0, 1fr) auto; }
    .hq-site__stats { grid-column: 1 / -1; justify-content: space-between; padding: 10px 12px; border-radius: 12px; background: var(--glass-0); }
    .hq-site__stats div { text-align: left; }
  }

  /* Stats */
  .hq-stat__label { font-size: 13px; font-weight: 650; color: var(--text-muted); }
  .hq-stat__value {
    margin-top: 4px;
    font-family: var(--font-display);
    font-size: 26px;
    font-weight: 600;
    letter-spacing: -0.02em;
    line-height: 1.15;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
  }
  .hq-stat__note { margin-top: 2px; font-size: 12.5px; color: var(--text-subtle); }
  .hq-summary-line { margin: -6px 0 18px; font-size: 13px; color: var(--text-muted); }

  /* Receivables donut: the shares of what is still owed */
  .hq-receivables { display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: center; gap: 20px; }
  @container (max-width: 360px) {
    .hq-receivables { grid-template-columns: 1fr; justify-items: center; }
    .hq-receivables__side { width: 100%; }
  }
  .hq-donut { position: relative; width: clamp(140px, 38cqi, 176px); aspect-ratio: 1; }
  @container (max-width: 360px) { .hq-donut { width: 180px; } }
  .hq-donut__svg { width: 100%; height: 100%; transform: rotate(-90deg); overflow: visible; }
  .hq-donut__track { fill: none; stroke: rgb(var(--fg-rgb) / 0.05); stroke-width: 11; }
  .hq-donut__arc { fill: none; stroke-width: 11; transition: stroke-width var(--dur) var(--ease-out); }
  .hq-donut__arc--1 { stroke: var(--age-0); }
  .hq-donut__arc--2 { stroke: var(--age-1); }
  .hq-donut__arc--3 { stroke: var(--age-2); filter: drop-shadow(0 0 6px rgb(244 63 94 / 0.35)); }
  .hq-donut__arc--4 { stroke: var(--age-3); filter: drop-shadow(0 0 6px rgb(220 38 38 / 0.5)); }
  .hq-donut:hover .hq-donut__arc { stroke-width: 12.5; }
  .hq-donut__center {
    position: absolute;
    inset: 18%;
    display: grid;
    place-content: center;
    justify-items: center;
    border-radius: 50%;
    background: radial-gradient(circle at 50% 30%, rgb(var(--blue-rgb) / 0.14), transparent 70%);
    text-align: center;
  }
  .hq-donut__label { font-size: 12px; font-weight: 650; color: var(--text-muted); }
  .hq-donut__value { font-family: var(--font-display); font-size: 21px; font-weight: 600; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; white-space: nowrap; }
  .hq-donut__note { font-size: 11.5px; color: var(--text-subtle); }
  .hq-overdue { padding: 12px 14px; margin-bottom: 14px; border-radius: 14px; background: rgb(var(--red-rgb) / 0.07); box-shadow: inset 0 0 0 1px rgb(var(--red-rgb) / 0.16); }
  .hq-overdue .hq-stat__value { font-size: 24px; }
  .hq-aging-swatch--1 { background: var(--age-0); }
  .hq-aging-swatch--2 { background: var(--age-1); }
  .hq-aging-swatch--3 { background: var(--age-2); }
  .hq-aging-swatch--4 { background: var(--age-3); }
  .hq-legend { display: grid; gap: 8px; font-size: 13px; color: var(--text-muted); }
  .hq-legend li { display: flex; align-items: center; gap: 10px; }
  .hq-legend__label { flex: 1; }
  .hq-legend strong { color: var(--text); font-variant-numeric: tabular-nums; }

  .hq-debtors { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 28px; margin-top: 6px; }
  @container (max-width: 560px) { .hq-debtors { grid-template-columns: 1fr; } }
  .hq-debtor { align-items: flex-start; }
  .hq-debtor__dot { flex: none; width: 9px; height: 9px; margin-top: 6px; border-radius: 3px; }
  .hq-debtor__age { font-weight: 650; }
  .hq-debtor__age--2 { color: var(--age-1); }
  .hq-debtor__age--3 { color: var(--age-2); }
  .hq-debtor__age--4 { color: var(--error-text); }

  /* Rows */
  .hq-rows { display: grid; }
  .hq-row { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-top: 1px solid var(--line-soft); }
  .hq-row:first-child { border-top: 0; padding-top: 0; }
  .hq-row__main { display: grid; min-width: 0; }
  .hq-row__title { font-weight: 650; font-size: 14px; }
  .hq-row__meta { font-size: 12.5px; color: var(--text-subtle); }
  .hq-row__value { margin-left: auto; font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }

  /* Meters: label and value on one line, the bar beneath */
  .hq-meters { display: grid; gap: 16px; }
  .hq-meter { display: grid; gap: 7px; }
  .hq-meter__line { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
  .hq-meter__label { min-width: 0; font-size: 13.5px; font-weight: 600; color: var(--text-muted); }
  .hq-meter__label strong { color: var(--text); font-weight: 700; }
  .hq-meter__value { flex: none; font-weight: 700; font-size: 14px; font-variant-numeric: tabular-nums; white-space: nowrap; }
  .hq-meter__value small { margin-left: 8px; font-size: 12px; font-weight: 600; color: var(--text-subtle); }
  .hq-meter__track { display: block; height: 8px; border-radius: 8px; background: rgb(var(--fg-rgb) / 0.06); overflow: hidden; }
  .hq-meter__bar {
    display: block;
    width: var(--value);
    height: 100%;
    border-radius: inherit;
    background: var(--blue-500);
    box-shadow: 0 0 12px rgb(var(--blue-rgb) / 0.35);
    transform-origin: left;
  }
  .hq-meter__meta { font-size: 12.5px; color: var(--text-subtle); }
  .hq-meter__meta strong { color: var(--text-muted); }
  .hq-meter--team + .hq-meter--team { padding-top: 14px; border-top: 1px solid var(--line-soft); }

  /* Table */
  .hq-table-wrap { margin: 0 -6px; }
  .hq-table { width: 100%; border-collapse: collapse; font-size: 14px; }
  .hq-table th, .hq-table td { padding: 12px 6px; text-align: left; border-top: 1px solid var(--line-soft); vertical-align: middle; }
  .hq-table thead th {
    padding-top: 0;
    border-top: 0;
    font-size: 12px;
    font-weight: 650;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--text-subtle);
  }
  .hq-table tbody th { font-weight: 600; }
  .hq-table .is-num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
  .hq-table tbody td.is-num { font-weight: 650; }
  .hq-table__name { display: block; font-weight: 700; }
  .hq-table__sub { display: block; font-size: 12.5px; font-weight: 500; color: var(--text-subtle); }
  .hq-table--compact th, .hq-table--compact td { padding: 6px; font-size: 13px; }
  @media (max-width: 639px) {
    .hq-table thead { display: none; }
    .hq-table tbody tr { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 12px; padding: 12px 0; border-top: 1px solid var(--line-soft); }
    .hq-table tbody tr:first-child { border-top: 0; padding-top: 0; }
    .hq-table tbody th, .hq-table tbody td { padding: 0; border: 0; }
    .hq-table tbody th { grid-column: 1 / -1; }
    .hq-table tbody td, .hq-table tbody td.is-num { display: grid; text-align: left; }
    .hq-table tbody td::before { content: attr(data-label); font-size: 11.5px; font-weight: 600; color: var(--text-subtle); }
    .hq-table--compact tbody tr { display: table-row; }
  }

  .hq-opp__company { font-size: 13px; color: var(--text); }
  .hq-opp__company span { color: var(--text-subtle); }
  .hq-opp__next {
    display: flex;
    gap: 8px;
    margin-top: 8px;
    padding: 8px 10px;
    border-radius: 10px;
    font-size: 13px;
    color: var(--text-muted);
    background: rgb(var(--blue-rgb) / 0.08);
  }
  .hq-opp__next .icon { flex: none; width: 16px; height: 16px; margin-top: 2px; color: var(--blue-300); }
  .hq-opp__next strong { color: var(--text); }

  /* TESLA marks shared by several components */
  .hq-tesla__dot { flex: none; width: 7px; height: 7px; border-radius: 50%; background: var(--tesla); box-shadow: 0 0 0 3px var(--tesla-soft); transform: translateY(-1px); }
  .hq-tesla__note { margin-top: 14px; font-size: 12px; color: var(--text-subtle); }

  .hq-opps { display: grid; gap: 8px; }
  .hq-opp {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    align-items: start;
    gap: 14px;
    padding: 14px;
    border-radius: 16px;
    background: var(--glass-0);
    box-shadow: inset 0 0 0 1px var(--line-soft);
    transition: background-color var(--dur-fast) var(--ease-out), box-shadow var(--dur-fast) var(--ease-out), transform var(--dur-fast) var(--ease-out);
  }
  .hq-opp__score {
    display: grid;
    place-items: center;
    width: 44px;
    height: 44px;
    border-radius: 12px;
    font-family: var(--font-display);
    font-weight: 650;
    font-size: 17px;
    color: var(--blue-300);
    background: rgb(var(--blue-rgb) / 0.16);
    box-shadow: inset 0 0 0 1px rgb(var(--blue-rgb) / 0.25);
    font-variant-numeric: tabular-nums;
  }
  .hq-opp__body { display: grid; gap: 2px; min-width: 0; }
  .hq-opp__title { font-weight: 700; font-size: 14.5px; line-height: 1.35; }
  .hq-opp__meta { font-size: 12.5px; color: var(--text-subtle); }
  .hq-opp__why { margin-top: 4px; font-size: 13px; color: var(--text-muted); }
  .hq-opp__head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
  .hq-opp .hq-pill { flex: none; margin-top: -1px; }
  @container (max-width: 520px) { .hq-opp__head { flex-direction: column; gap: 6px; } }

  /* Buttons */
  .hq-button {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    height: 44px;
    padding: 0 18px;
    border-radius: 12px;
    font-weight: 700;
    font-size: 14px;
    transition: transform var(--dur-fast) var(--ease-out), box-shadow var(--dur-fast) var(--ease-out), filter var(--dur-fast) var(--ease-out);
  }
  .hq-button .icon { width: 18px; height: 18px; }
  .hq-button--primary { background: var(--text); color: var(--text-on-light); box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3); }
  .hq-button--primary:active { transform: scale(0.98); }

  /* States: empty, missing, running, error (components/state.html). Calm,
     never alarming unless it is an error, and never a made-up figure. */
  .hq-state { display: flex; align-items: flex-start; gap: 16px; padding: 8px 0 4px; }
  .hq-state__icon {
    display: grid;
    place-items: center;
    flex: none;
    width: 44px;
    height: 44px;
    border-radius: 14px;
    color: var(--text-muted);
    background: var(--glass-0);
    box-shadow: inset 0 0 0 1px var(--line), inset 0 1px 0 var(--highlight);
  }
  .hq-state__icon .icon { width: 20px; height: 20px; }
  .hq-state--info .hq-state__icon { color: var(--blue-300); background: rgb(var(--blue-rgb) / 0.14); box-shadow: inset 0 0 0 1px rgb(var(--blue-rgb) / 0.24); }
  .hq-state--error .hq-state__icon { color: var(--error-text); background: rgb(var(--red-rgb) / 0.12); box-shadow: inset 0 0 0 1px rgb(var(--red-rgb) / 0.22); }
  .hq-state__tesla { flex: none; width: 104px; height: auto; margin: -10px -4px -4px -6px; }
  .hq-state__body { display: grid; justify-items: start; gap: 4px; min-width: 0; padding-top: 2px; }
  .hq-state__title { font-family: var(--font-display); font-size: 15.5px; font-weight: 600; letter-spacing: -0.01em; line-height: 1.35; }
  .hq-state__text { max-width: 52ch; font-size: 13.5px; line-height: 1.55; color: var(--text-muted); text-wrap: pretty; }
  .hq-state__action { margin-top: 10px; }
  /* The restricted-access screen and restricted cards: a lock, no data. */
  .hq-restricted { max-width: 680px; }
  .hq-card--restricted .hq-state__icon { opacity: 0.75; }
  .hq-pulse__item.is-locked .hq-pulse__label,
  .hq-pulse__item.is-locked .hq-pulse__note { color: var(--text-subtle); }
  .hq-pulse__item.is-locked .icon { width: 20px; height: 20px; color: var(--text-subtle); opacity: 0.6; }
  /* Work in progress: a quiet, indeterminate bar. No percentage is shown,
     because none is known. */
  .hq-state__progress { position: relative; display: block; width: min(220px, 100%); height: 3px; margin-top: 10px; border-radius: 3px; background: rgb(var(--fg-rgb) / 0.08); overflow: hidden; }
  .hq-state__progress > span { position: absolute; inset: 0 auto 0 0; width: 38%; border-radius: inherit; background: linear-gradient(90deg, transparent, var(--tesla), transparent); }
  @container (max-width: 380px) {
    .hq-state__tesla { width: 84px; }
    .hq-state__icon { width: 40px; height: 40px; }
  }

  /* Loading: the card's shape in quiet placeholders (components/skeleton.html). */
  .hq-skeleton { display: grid; gap: 18px; }
  .hq-skeleton__figure { display: grid; gap: 10px; }
  .hq-skeleton__bar, .hq-skeleton__chart {
    position: relative;
    display: block;
    height: 12px;
    border-radius: 6px;
    background: rgb(var(--fg-rgb) / 0.06);
    overflow: hidden;
  }
  .hq-skeleton__bar--label { width: 30%; height: 11px; }
  .hq-skeleton__bar--value { width: 52%; height: 30px; border-radius: 9px; }
  .hq-skeleton__chart { height: 150px; border-radius: 14px; background: linear-gradient(180deg, rgb(var(--fg-rgb) / 0.05), rgb(var(--fg-rgb) / 0.02)); }
  .hq-skeleton__rows { display: grid; gap: 10px; }
  .hq-skeleton__rows .hq-skeleton__bar:nth-child(2) { width: 86%; }
  .hq-skeleton__rows .hq-skeleton__bar:nth-child(3) { width: 64%; }
  /* The shimmer is a moving highlight on a pseudo-element: transform only. */
  .hq-skeleton__bar::after, .hq-skeleton__chart::after {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(100deg, transparent 20%, rgb(var(--fg-rgb) / 0.07) 50%, transparent 80%);
    transform: translateX(-100%);
  }

  /* Missing chart data: a faint empty frame, never a line. */
  .hq-chart-empty { position: relative; display: grid; align-items: center; min-height: 210px; padding: 18px; border-radius: 16px; background: rgb(var(--navy-rgb) / 0.28); box-shadow: inset 0 0 0 1px var(--line-soft); overflow: hidden; }
  .hq-chart-empty__grid {
    position: absolute;
    inset: 18px;
    background: repeating-linear-gradient(180deg, transparent 0 39px, rgb(var(--fg-rgb) / 0.05) 39px 40px);
    -webkit-mask: linear-gradient(90deg, #000, rgba(0, 0, 0, 0.3));
    mask: linear-gradient(90deg, #000, rgba(0, 0, 0, 0.3));
  }
  .hq-chart-empty .hq-state { position: relative; }

  /* Account menu (components/account_menu.html) */
  .hq-account { position: relative; }
  .hq-account__button {
    display: grid;
    place-items: center;
    width: 42px;
    height: 42px;
    border-radius: 50%;
    list-style: none;
    cursor: pointer;
  }
  .hq-account__button::-webkit-details-marker { display: none; }
  .hq-account__button .hq-avatar { transition: box-shadow var(--dur-fast) var(--ease-out), transform var(--dur) var(--ease-out), color var(--dur-fast) var(--ease-out); }
  .hq-account__button:hover .hq-avatar { color: var(--text); box-shadow: inset 0 0 0 1px rgb(var(--pearl-rgb) / 0.45); }
  .hq-account[open] .hq-account__button .hq-avatar { color: var(--text); box-shadow: inset 0 0 0 1px rgb(var(--pearl-rgb) / 0.6), 0 0 0 3px rgb(var(--pearl-rgb) / 0.10); }
  .hq-account__panel {
    position: absolute;
    top: calc(100% + 10px);
    right: 0;
    z-index: 35;
    width: min(300px, calc(100vw - 24px));
    padding: 8px;
    border-radius: 20px;
    background: var(--sheen), rgb(var(--navy-rgb) / 0.94);
    box-shadow: var(--shadow-3), inset 0 0 0 1px var(--line-strong), inset 0 1px 0 rgba(255, 255, 255, 0.08);
    -webkit-backdrop-filter: blur(var(--blur)) saturate(140%);
    backdrop-filter: blur(var(--blur)) saturate(140%);
    transform-origin: top right;
  }
  .hq-account__who { display: flex; align-items: center; gap: 12px; padding: 10px 10px 12px; }
  .hq-avatar--lg { width: 44px; height: 44px; font-size: 14px; color: var(--pearl-ink); background: var(--pearl-surface); box-shadow: var(--pearl-rim); }
  .hq-account__id { min-width: 0; }
  .hq-account__name { font-family: var(--font-display); font-size: 15px; font-weight: 600; letter-spacing: -0.01em; }
  .hq-account__role { display: flex; align-items: center; gap: 5px; margin-top: 2px; font-size: 12.5px; font-weight: 650; color: var(--blue-300); }
  .hq-account__role .icon { width: 14px; height: 14px; }
  .hq-account__signed { margin: 0 10px 8px; padding: 8px 10px; border-radius: 10px; font-size: 12.5px; color: var(--text-muted); background: var(--glass-0); box-shadow: inset 0 0 0 1px var(--line-soft); overflow-wrap: anywhere; }
  .hq-account__signed strong { color: var(--text); font-weight: 650; }
  .hq-account__list { padding: 2px 0 6px; border-bottom: 1px solid var(--line-soft); }
  .hq-account__row { display: flex; align-items: center; gap: 10px; min-height: 42px; padding: 0 10px; font-size: 13.5px; font-weight: 600; color: var(--text-muted); }
  .hq-account__row .icon { width: 17px; height: 17px; color: var(--text-subtle); }
  .hq-account__value { margin-left: auto; font-size: 12.5px; color: var(--text-subtle); }
  .hq-account__item {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 44px;
    margin-top: 6px;
    padding: 0 10px;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 650;
    color: var(--text);
    transition: background-color var(--dur-fast) var(--ease-out), transform var(--dur-fast) var(--ease-out);
  }
  .hq-account__item .icon { width: 18px; height: 18px; color: var(--blue-300); }
  .hq-account__item:hover { background: rgb(var(--fg-rgb) / 0.06); }
  .hq-account__item:active { transform: scale(0.985); }
  .hq-account__logout { margin-top: 2px; }
  .hq-account__out {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    min-height: 44px;
    padding: 0 10px;
    border: 0;
    border-radius: 12px;
    background: transparent;
    color: var(--error-text);
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    transition: background-color var(--dur-fast) var(--ease-out), transform var(--dur-fast) var(--ease-out);
  }
  .hq-account__out .icon { width: 18px; height: 18px; }
  .hq-account__out:hover { background: rgb(var(--red-rgb) / 0.10); }
  .hq-account__out:active { transform: scale(0.985); }
  .hq-account__out:disabled { cursor: default; opacity: 0.7; }
  .hq-account__note { padding: 2px 10px 6px; font-size: 11.5px; color: var(--text-subtle); }

  .hq-footnote a { color: var(--blue-400); border-radius: 4px; }
  .hq-footnote a:hover { color: var(--blue-300); }

  /* Mobile tab bar and sheet */
  /* Floating glass tab bar, clear of the home indicator. */
  .hq-tabbar {
    position: fixed;
    left: 10px;
    right: 10px;
    bottom: calc(8px + env(safe-area-inset-bottom));
    z-index: 40;
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    height: var(--tabbar);
    padding: 0 6px;
    border-radius: 24px;
    box-shadow: 0 18px 40px -12px rgba(0, 0, 0, 0.7);
  }
  /* The glass lives on a pseudo-element: a backdrop filter on the bar itself
     would become the containing block of the fixed sheet and its backdrop. */
  .hq-tabbar::before {
    content: "";
    position: absolute;
    inset: 0;
    z-index: -1;
    border-radius: inherit;
    background: var(--sheen), rgb(var(--navy-rgb) / 0.78);
    box-shadow: inset 0 0 0 1px rgb(var(--fg-rgb) / 0.10), inset 0 1px 0 rgba(255, 255, 255, 0.12);
    -webkit-backdrop-filter: blur(var(--blur)) saturate(160%);
    backdrop-filter: blur(var(--blur)) saturate(160%);
  }
  .hq-tabbar__item {
    position: relative;
    display: grid;
    justify-items: center;
    align-content: center;
    gap: 3px;
    min-height: 44px;
    font-size: 11px;
    font-weight: 650;
    color: var(--text-subtle);
    list-style: none;
    cursor: pointer;
    transition: color var(--dur-fast) var(--ease-out);
  }
  .hq-tabbar__item::-webkit-details-marker { display: none; }
  .hq-tabbar__item .icon { width: 22px; height: 22px; }
  .hq-tabbar__item[aria-current="page"] { color: var(--text); }
  .hq-tabbar__item[aria-current="page"] .icon { color: var(--blue-400); }
  .hq-tabbar__item[aria-current="page"]::before {
    content: "";
    position: absolute;
    top: 3px;
    left: 50%;
    width: 18px;
    height: 3px;
    margin-left: -9px;
    border-radius: 3px;
    background: linear-gradient(90deg, var(--pearl-hi), var(--pearl));
  }
  /* The active tab sits in a soft glass bubble that glides between tabs. */
  .hq-tabbar__item { isolation: isolate; }
  .hq-tabbar__item[aria-current="page"]::after {
    content: "";
    position: absolute;
    inset: 7px 4px;
    z-index: -1;
    border-radius: 16px;
    background: rgb(var(--blue-rgb) / 0.24);
    box-shadow: inset 0 0 0 1px rgb(var(--blue-rgb) / 0.26), inset 0 1px 0 rgba(255, 255, 255, 0.10);
  }
  .hq-tabbar__item--tesla .icon { color: var(--tesla); }
  .hq-tabbar__item.is-locked { opacity: 0.55; }
  .hq-tabbar__more { display: grid; }
  .hq-tabbar__more > summary { height: var(--tabbar); }
  .hq-tabbar__more[open] > summary { color: var(--text); }
  .hq-tabbar__more[open] > summary::before {
    content: "";
    position: fixed;
    inset: 0;
    z-index: -1;
    background: rgb(var(--navy-rgb) / 0.6);
  }
  .hq-sheet {
    position: fixed;
    left: 8px;
    right: 8px;
    bottom: calc(var(--tabbar) + env(safe-area-inset-bottom) + 18px);
    max-height: min(72dvh, 640px);
    overflow-y: auto;
    padding: 8px 10px 14px;
    border-radius: var(--radius-sheet);
    /* Dense navigation text: nearly opaque, so it stays readable even where
       the blur is unavailable. */
    background: rgb(var(--navy-rgb) / 0.94);
    box-shadow: var(--shadow-3), inset 0 0 0 1px var(--line-strong);
    -webkit-backdrop-filter: blur(var(--blur)) saturate(140%);
    backdrop-filter: blur(var(--blur)) saturate(140%);
  }
  .hq-sheet__grip { display: block; width: 40px; height: 4px; margin: 4px auto 8px; border-radius: 4px; background: var(--line-strong); }
  .hq-sheet .hq-nav { overflow: visible; }
}

/* ------------------------------------------------------------------ */
/* Motion (6). Everything is visible without JavaScript; animations    */
/* only run when motion is allowed. One authored moment on load: the   */
/* page settles into focus, figures count up, charts draw.             */
/* ------------------------------------------------------------------ */

@layer motion {
  @keyframes hq-spin { to { transform: rotate(360deg); } }
  /* One motion language: things rise a little and come into focus. */
  @keyframes hq-enter {
    from { opacity: 0; transform: translateY(20px); filter: blur(4px); }
    70% { filter: blur(0); }
  }
  @keyframes hq-enter-light { from { opacity: 0; transform: translateY(22px); } }
  @keyframes hq-rise { from { opacity: 0; transform: translateY(14px); } }
  @keyframes hq-grow-x { from { transform: scaleX(0); } }
  @keyframes hq-draw { from { stroke-dashoffset: 1; } to { stroke-dashoffset: 0; } }
  @keyframes hq-reveal { from { clip-path: inset(0 100% 0 0); } to { clip-path: inset(0 0 0 0); } }
  @keyframes hq-arc { from { stroke-dasharray: 0 100; } }
  @keyframes hq-dot {
    from { opacity: 0; transform: scale(0); }
    70% { transform: scale(1.25); }
    to { opacity: 1; transform: scale(1); }
  }
  @keyframes hq-fade { from { opacity: 0; } }
  @keyframes hq-pop { from { opacity: 0; transform: translateY(-6px) scale(0.97); } }
  @keyframes hq-sheet-up { from { opacity: 0; transform: translateY(28px) scale(0.98); } }
  /* An updated value briefly takes the accent colour: no glow. */
  @keyframes hq-flash { 30% { color: var(--flash, var(--blue-300)); } }
  @keyframes hq-check { from { stroke-dasharray: 24; stroke-dashoffset: 24; } to { stroke-dasharray: 24; stroke-dashoffset: 0; } }
  @keyframes hq-vt-out { to { opacity: 0; } }
  @keyframes hq-vt-in { from { opacity: 0; } }
  @keyframes hq-breathe { 0%, 100% { opacity: 0.55; } 50% { opacity: 0.9; } }
  @keyframes hq-shimmer { to { transform: translateX(100%); } }
  @keyframes hq-progress { from { transform: translateX(-100%); } to { transform: translateX(270%); } }

  @media (prefers-reduced-motion: no-preference) {
    /* Page transitions (View Transitions, where supported): a short
       cross-fade of the content while the shell stays put and the active
       navigation marks glide; the cards then reveal as on any load.
       Elsewhere, including older Safari, navigation is simply instant.
       The content keeps a layer of its own, above the light stream's layer
       (V3.1 audit, step 5: fading it as part of the root picture was cheaper
       but put the stream over the old page's cards). */
    @view-transition { navigation: auto; }
    .hq-content { view-transition-name: hq-content; }
    .hq-tabbar__item[aria-current="page"] { view-transition-name: hq-tab-active; }
    ::view-transition-group(hq-active),
    ::view-transition-group(hq-tab-active) {
      animation-duration: 380ms;
      animation-timing-function: var(--ease-out);
    }
    ::view-transition-old(hq-content) { animation: hq-vt-out 140ms var(--ease-in) both; }
    ::view-transition-new(hq-content) { animation: hq-vt-in 280ms var(--ease-out) both; }
    ::view-transition-old(root), ::view-transition-new(root) { animation: none; }
    /* The light stream (energy-flow.js) holds its old picture until the new
       page's stream is drawn; then the two cross-fade (the canvas fades in as
       .hq-energy-live is set, the old picture fades out with it). The new
       stream continues the old one's motion, so the light never blinks. */
    .hq-energy-track:not(.is-page) { view-transition-name: hq-energy; }
    ::view-transition-old(hq-energy), ::view-transition-new(hq-energy) { animation: none; mix-blend-mode: normal; }
    html.hq-energy-live::view-transition-old(hq-energy) { animation: hq-vt-out 360ms var(--ease-out) both; }
    /* The shell stays above the light and in place: it changes at once, as
       it did when it was part of the page's root picture. */
    .hq-sidebar { view-transition-name: hq-shell-nav; }
    .hq-topbar { view-transition-name: hq-shell-bar; }
    .hq-tabbar { view-transition-name: hq-shell-tabs; }
    ::view-transition-group(hq-shell-nav), ::view-transition-group(hq-shell-bar), ::view-transition-group(hq-shell-tabs) { animation: none; }
    ::view-transition-old(hq-shell-nav), ::view-transition-old(hq-shell-bar), ::view-transition-old(hq-shell-tabs) { display: none; }
    ::view-transition-new(hq-shell-nav), ::view-transition-new(hq-shell-bar), ::view-transition-new(hq-shell-tabs) { animation: none; }


    /* Scroll reveal, once per load (playground.js, IntersectionObserver).
       A card waits invisible only while .hq-motion is set, which happens
       only on a visible page, with motion allowed and the script running. */
    .hq-motion [data-enter]:not(.is-revealed) { opacity: 0; }
    .hq-motion [data-enter].is-revealed {
      animation: hq-enter var(--dur-enter) var(--ease-out) both;
      animation-delay: calc(var(--i, 0) * var(--stagger));
    }
    /* Cards that arrive while scrolling take the light entrance (no blur):
       the full entrance is the page's opening only. */
    .hq-motion [data-enter].is-revealed.is-scrolled-in { animation-name: hq-enter-light; }
    @media (max-width: 1023px), (pointer: coarse) {
      /* Phones and tablets: no blur, the costliest part of the reveal. */
      .hq-motion [data-enter].is-revealed { animation-name: hq-enter-light; animation-duration: 900ms; }
    }

    /* Charts animate when their card is revealed: the line draws while its
       area opens behind it, donut segments sweep in one after another,
       bars grow to their values. The values themselves never change. */
    .hq-motion .is-revealed .hq-chart__line { stroke-dasharray: 1; stroke-dashoffset: 1; animation: hq-draw 1900ms var(--ease-out) 360ms forwards; }
    .hq-motion .is-revealed .hq-chart__line--expenses { animation-delay: 540ms; }
    .hq-motion .is-revealed .hq-chart__area { animation: hq-reveal 1900ms var(--ease-out) 360ms both; }
    .hq-chart__dot { transform-box: fill-box; transform-origin: center; }
    .hq-motion .is-revealed .hq-chart__dot.is-current { animation: hq-dot 600ms var(--ease-out) 1900ms both; }
    .hq-motion .is-revealed .hq-chart__label { animation: hq-fade 700ms var(--ease-out) 520ms both; }
    .hq-motion .is-revealed .hq-donut__arc { animation: hq-arc 1500ms var(--ease-out) both; animation-delay: calc(460ms + var(--i, 0) * 200ms); }
    .hq-motion .is-revealed .hq-meter__bar {
      animation: hq-grow-x 1400ms var(--ease-out) both;
      animation-delay: calc(380ms + var(--i, 0) * 100ms);
    }

    /* TESLA steps in a moment after his card: searching in the report,
       raising his hand over what needs attention, at his laptop over his
       latest research. Once, then still. */
    .hq-motion .is-revealed .hq-report__figure img,
    .hq-motion .is-revealed .hq-attention__tesla,
    .hq-motion .is-revealed .hq-research__tesla,
    .hq-motion .is-revealed .hq-state__tesla { animation: hq-rise 850ms var(--ease-out) 340ms both; }

    /* Loading and work in progress */
    .hq-skeleton__bar::after, .hq-skeleton__chart::after { animation: hq-shimmer 1.6s var(--ease-in-out) infinite; }
    .hq-state__progress > span { animation: hq-progress 1.8s var(--ease-in-out) infinite; }

    /* Menus, sheets and the tooltip open from where they are anchored. */
    .hq-select[open] .hq-menu { animation: hq-pop 260ms var(--ease-out); }
    .hq-account[open] .hq-account__panel { animation: hq-pop 260ms var(--ease-out); }
    .hq-tabbar__more[open] .hq-sheet { animation: hq-sheet-up 420ms var(--ease-out); }
    .hq-tabbar__more[open] > summary::before { animation: hq-fade var(--dur) var(--ease-out); }
    .hq-tooltip { transition: transform 240ms var(--ease-out), opacity var(--dur-fast) var(--ease-out); }

    /* Press feedback: short and soft, the same everywhere. */
    .hq-attention__item, .hq-opp, .hq-pulse__item, .hq-tabbar__item, .hq-select__button,
    .hq-button, .hq-nav__link, .hq-sync__button, .hq-menu__item, .hq-card__link {
      transition-property: background-color, color, box-shadow, transform;
      transition-duration: var(--dur);
      transition-timing-function: var(--ease-out);
    }
    .hq-attention__item:active, .hq-opp:active, .hq-pulse__item:active,
    .hq-select__button:active, .hq-nav__link:active, .hq-menu__item:active { transform: scale(0.985); transition-duration: 90ms; }
    .hq-tabbar__item:active, .hq-button:active, .hq-sync__button:active, .hq-card__link:active { transform: scale(0.96); transition-duration: 90ms; }
    .hq-presence__button:active .hq-portrait, .hq-account__button:active .hq-avatar { transform: scale(0.92); transition-duration: 90ms; }

    /* Pointer devices: surfaces answer hover with light and a small lift. */
    @media (hover: hover) and (pointer: fine) {
      .hq-card:hover { box-shadow: var(--shadow-2), inset 0 1px 0 rgba(255, 255, 255, 0.08); }
      .hq-attention--flagged:hover { box-shadow: var(--pearl-shadow); }
      .hq-opp:hover {
        transform: translateY(-3px);
        background: rgb(var(--fg-rgb) / 0.045);
        box-shadow: inset 0 0 0 1px var(--line-strong), 0 16px 32px -12px rgba(0, 0, 0, 0.55);
      }
      .hq-pulse__value { transition: transform var(--dur) var(--ease-out); }
      .hq-pulse__item:hover .hq-pulse__value { transform: translateY(-2px); }
      .hq-attention__item:hover { transform: translateX(2px); }
      .hq-nav__link .icon { transition: color var(--dur-fast) var(--ease-out), transform var(--dur) var(--ease-out); }
      .hq-nav__link:hover .icon { transform: translateX(1px) scale(1.06); }
      .hq-menu__item:hover { transform: translateX(2px); }
      .hq-select__button:hover { transform: translateY(-1px); }
      .hq-account__button:hover .hq-avatar { transform: scale(1.05); }
      .hq-button--primary:hover {
        transform: translateY(-2px);
        box-shadow: 0 14px 30px -10px rgba(0, 0, 0, 0.55), 0 0 0 4px rgb(var(--fg-rgb) / 0.06);
      }
    }

    /* Updated values change colour once (sync and filter feedback). */
    .is-updated { animation: hq-flash 1200ms var(--ease-out); }
    .hq-ledger__item--result .is-updated { --flash: var(--blue-600); }
    .hq-sync[data-state="done"] .hq-sync__check { animation: hq-check 420ms var(--ease-out); }
  }

  /* Printing shows everything, whatever the motion state. */
  @media print {
    .hq-motion [data-enter] { opacity: 1 !important; animation: none !important; }
  }
}

/* ------------------------------------------------------------------ */
/* Welcome experience, TESLA AGENT (portrait, presence, report, page)  */
/* ------------------------------------------------------------------ */

@layer components {
  /* Small buttons */
  .hq-button--small { height: 36px; padding: 0 14px; border-radius: 10px; font-size: 13px; }
  .hq-button--ghost { background: var(--glass-0); color: var(--text-muted); box-shadow: inset 0 0 0 1px var(--line); border: 0; cursor: pointer; }
  .hq-button--ghost:hover { color: var(--text); box-shadow: inset 0 0 0 1px var(--line-strong); }

  /* Phones: TESLA's presence and the account menu share the right edge. */
  @media (max-width: 639px) {
    .hq-topbar { gap: 8px; }
    .hq-topbar__actions { gap: 4px; }
    .hq-account__button, .hq-presence__button { width: 40px; height: 40px; }
  }
  /* ---------- TESLA portrait: the approved head, in a soft round frame -- */
  .hq-portrait {
    position: relative;
    display: inline-grid;
    flex: none;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--navy-800);
    box-shadow: 0 0 0 1.5px rgb(var(--orange-rgb) / 0.55), 0 4px 10px -2px rgba(0, 0, 0, 0.5);
    overflow: hidden;
    transition: box-shadow var(--dur) var(--ease-out), transform var(--dur) var(--ease-out);
  }
  .hq-portrait img { width: 100%; height: 100%; object-fit: cover; }
  /* In the navigation: the 20px icon slot (22px, overlapping it by 1px each
     side), a thin blue-grey frame, clear of the active-item mark. */
  .hq-portrait--nav { width: 22px; height: 22px; margin-inline: -1px; }
  .hq-portrait--nav, .hq-portrait--tab { box-shadow: 0 0 0 1px rgba(148, 163, 184, 0.38); }
  .hq-portrait--tab { width: 24px; height: 24px; }
  .hq-portrait--presence { width: 34px; height: 34px; }
  .hq-portrait--chat { width: 38px; height: 38px; }
  .hq-nav__link--tesla:hover .hq-portrait { box-shadow: 0 0 0 1px rgba(148, 163, 184, 0.62); }
  /* Active: the same blue item as every module, with a quiet blue frame. */
  .hq-nav__link--tesla[aria-current="page"] .hq-portrait,
  .hq-tabbar__item--tesla[aria-current="page"] .hq-portrait { box-shadow: 0 0 0 1px rgb(var(--blue-rgb) / 0.75); }
  .hq-nav__link.is-locked .hq-portrait { opacity: 0.7; }
  /* The collapsed rail's narrow items: the portrait takes the icon slot exactly
     and the active mark moves out, so the two never touch. */
  .hq-rail .hq-sidebar .hq-portrait--nav { width: 20px; height: 20px; margin: 0; }
  .hq-rail .hq-sidebar .hq-nav__link[aria-current="page"]::before { left: 2px; }

  /* ---------- TESLA presence in the top bar (optional, dismissible) ----- */
  .hq-presence { position: relative; }
  .hq-presence__button {
    position: relative;
    display: grid;
    place-items: center;
    width: 42px;
    height: 42px;
    border-radius: 50%;
    list-style: none;
    cursor: pointer;
  }
  .hq-presence__button::-webkit-details-marker { display: none; }
  .hq-presence__button:hover .hq-portrait { transform: scale(1.06); box-shadow: 0 0 0 1.5px var(--tesla), 0 0 16px rgb(var(--orange-rgb) / 0.40); }
  .hq-presence__dot {
    position: absolute;
    right: 3px;
    bottom: 4px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--ok-text);
    box-shadow: 0 0 0 2px var(--navy-900);
  }
  .hq-presence__panel {
    position: absolute;
    top: calc(100% + 10px);
    right: 0;
    z-index: 35;
    width: min(320px, calc(100vw - 24px));
    padding: 16px;
    border-radius: 18px;
    background: rgb(var(--navy-rgb) / 0.94);
    box-shadow: var(--shadow-3), inset 0 0 0 1px rgb(var(--orange-rgb) / 0.22), inset 0 1px 0 rgba(255, 255, 255, 0.08);
    -webkit-backdrop-filter: blur(var(--blur));
    backdrop-filter: blur(var(--blur));
    transform-origin: top right;
  }
  .hq-presence__head { display: flex; align-items: center; gap: 12px; }
  .hq-presence__name { font-family: var(--font-display); font-weight: 650; font-size: 14px; letter-spacing: 0.04em; }
  .hq-presence__state { display: flex; align-items: baseline; gap: 8px; font-size: 12px; color: var(--text-subtle); }
  .hq-presence__text { margin: 12px 0 14px; font-size: 14.5px; line-height: 1.5; }
  .hq-presence__actions { display: flex; flex-wrap: wrap; gap: 8px; }
  .hq-presence__note { margin-top: 12px; font-size: 11.5px; color: var(--text-subtle); }
  .hq-presence-off .hq-presence { display: none; }

  /* ---------- TESLA's report on Home ------------------------------------ */
  .hq-report { display: grid; grid-template-columns: 132px minmax(0, 1fr); align-items: end; gap: 6px; margin: -6px 0 18px; }
  .hq-report__figure { position: relative; display: block; align-self: end; }
  .hq-report__figure::before {
    content: "";
    position: absolute;
    inset: 20% -10% -6% -10%;
    z-index: -1;
    border-radius: 50%;
    background: radial-gradient(closest-side, rgb(var(--orange-rgb) / 0.18), rgb(var(--blue-rgb) / 0.10) 55%, transparent);
  }
  .hq-report__figure img { display: block; width: 100%; height: auto; }
  .hq-report__bubble {
    position: relative;
    align-self: center;
    padding: 16px 18px;
    border-radius: 18px;
    background: radial-gradient(120% 140% at 0% 0%, rgb(var(--orange-rgb) / 0.10), transparent 60%), rgb(var(--navy-rgb) / 0.45);
    box-shadow: inset 0 0 0 1px rgb(var(--orange-rgb) / 0.22), inset 0 1px 0 rgba(255, 255, 255, 0.07);
  }
  .hq-report__bubble::before {
    content: "";
    position: absolute;
    left: -7px;
    top: 34px;
    width: 14px;
    height: 14px;
    transform: rotate(45deg);
    background: rgb(var(--navy-hi-rgb) / 0.95);
    box-shadow: -1px 1px 0 rgb(var(--orange-rgb) / 0.22);
  }
  .hq-report__from { display: flex; gap: 10px; align-items: baseline; font-size: 12px; color: var(--text-subtle); }
  .hq-report__from strong { font-family: var(--font-display); font-size: 12.5px; letter-spacing: 0.06em; color: var(--tesla); }
  .hq-report__headline { margin-top: 6px; font-family: var(--font-display); font-size: 18px; font-weight: 600; line-height: 1.3; letter-spacing: -0.015em; text-wrap: balance; }
  .hq-report__text { margin-top: 6px; font-size: 13.5px; line-height: 1.55; color: var(--text-muted); }
  .hq-report__meta { display: flex; align-items: baseline; gap: 8px; margin-top: 10px; font-size: 12px; color: var(--text-subtle); }
  @container (max-width: 480px) {
    .hq-report { grid-template-columns: 92px minmax(0, 1fr); }
    .hq-report__headline { font-size: 16px; }
    .hq-report__bubble { padding: 14px; }
  }

  /* ---------- TESLA poses: small round avatars ------------------------- */
  .hq-pose-avatar {
    position: relative;
    display: inline-block;
    flex: none;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    overflow: hidden;
    background: radial-gradient(circle at 50% 30%, rgb(var(--blue-rgb) / 0.28), rgb(var(--navy-rgb) / 0.95) 70%);
    box-shadow: 0 0 0 1.5px rgb(var(--orange-rgb) / 0.5), 0 4px 12px -4px rgba(0, 0, 0, 0.6);
  }
  .hq-pose-avatar img { position: absolute; left: 50%; top: 0; width: 210%; max-width: none; height: auto; transform: translateX(-50%); }
  /* Each pose framed on the face and its gesture. */
  .hq-pose-avatar--greeting img { width: 190%; left: 54%; }
  .hq-pose-avatar--search img { width: 200%; left: 50%; }
  .hq-pose-avatar--md { width: 48px; height: 48px; }

  /* ---------- Welcome experience ----------------------------------------
     Calm and expensive: a dark navy frosted-glass surface, the logo large
     in the centre on a pearl satin-glass pane (approved), and a pearl
     button in the same finish low on the screen. */
  .hq-welcome-page { overflow: hidden; }
  .hq-welcome {
    position: fixed;
    inset: 0;
    display: grid;
    grid-template-rows: 1fr auto;
    justify-items: center;
    padding: calc(64px + env(safe-area-inset-top)) 24px calc(40px + env(safe-area-inset-bottom));
    background:
      radial-gradient(90% 60% at 50% 0%, rgb(var(--blue-rgb) / 0.16), transparent 70%),
      radial-gradient(140% 100% at 50% 50%, transparent 55%, rgba(3, 7, 14, 0.7) 100%),
      linear-gradient(180deg, var(--navy-850) 0%, var(--navy-900) 50%, var(--navy-950) 100%);
  }
  /* Frosted glass: a large pane with a faint top highlight, two soft
     diagonal reflections and a fine grain. Nothing round, nothing bright. */
  .hq-welcome__glass {
    position: absolute;
    inset: 0;
    pointer-events: none;
    background:
      linear-gradient(118deg, transparent 30%, rgb(var(--fg-rgb) / 0.028) 42%, rgb(var(--fg-rgb) / 0.008) 50%, transparent 58%),
      linear-gradient(118deg, transparent 62%, rgb(var(--fg-rgb) / 0.018) 70%, transparent 78%),
      linear-gradient(180deg, rgb(var(--fg-rgb) / 0.03), rgb(var(--fg-rgb) / 0) 28%, rgb(var(--fg-rgb) / 0) 80%, rgb(var(--fg-rgb) / 0.015));
  }
  .hq-welcome__glass::before {
    content: "";
    position: absolute;
    left: 8%;
    right: 8%;
    top: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgb(var(--blue-hi-rgb) / 0.22), transparent);
  }
  .hq-welcome__glass::after {
    content: "";
    position: absolute;
    inset: 0;
    opacity: 0.05;
    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='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0.6 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  }
  @media (max-width: 639px) {
    .hq-welcome { padding: calc(72px + env(safe-area-inset-top)) 20px calc(58px + env(safe-area-inset-bottom)); }
  }
  .hq-welcome__center { position: relative; display: grid; align-content: center; justify-items: center; text-align: center; }
  /* The logo sits on one light frosted satin-glass pane. The logo stays
     matte and unmodified; the pane alone gives it contrast. */
  .hq-welcome__stage {
    position: relative;
    display: grid;
    place-items: center;
    padding: clamp(26px, 3.4vw, 46px) clamp(34px, 4.6vw, 64px);
  }
  .hq-welcome__pane {
    position: absolute;
    inset: 0;
    border-radius: clamp(22px, 2.4vw, 32px);
    background: var(--pearl-surface);
    box-shadow: var(--pearl-shadow);
    overflow: hidden;
  }
  .hq-welcome__pane::after {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: inherit;
    opacity: 0.05;
    background-image: var(--pearl-grain);
  }
  /* The logo file is square with empty space above and below the mark;
     negative margins let the pane hug the mark itself. */
  .hq-welcome__logo { position: relative; width: clamp(240px, min(32vw, 42vh), 400px); margin: -19% 0 -18%; }
  @media (max-width: 639px) {
    .hq-welcome__stage { padding: 30px 28px 28px; }
    .hq-welcome__logo { width: min(66vw, 270px); }
  }
  .hq-welcome__logo img { display: block; width: 100%; height: auto; }

  .hq-welcome__title {
    margin-top: clamp(24px, 3.6vh, 40px);
    margin-right: -0.6em;
    font-family: var(--font-display);
    font-size: clamp(12px, 0.8vw + 8px, 16px);
    font-weight: 500;
    letter-spacing: 0.6em;
    text-transform: uppercase;
    color: rgba(169, 184, 204, 0.85);
  }
  .hq-welcome__bottom { position: relative; display: grid; justify-items: center; gap: 12px; }
  .hq-welcome__enter {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 14px;
    height: 58px;
    padding: 0 28px 0 34px;
    border-radius: 999px;
    font-family: var(--font-display);
    font-size: 15.5px;
    font-weight: 600;
    letter-spacing: 0.03em;
    color: var(--pearl-ink);
    /* The same pearl satin as the logo pane, so the screen reads as one. */
    background: var(--pearl-surface);
    box-shadow: var(--pearl-rim), 0 1px 2px rgba(0, 0, 0, 0.4), 0 18px 40px -16px rgba(0, 0, 0, 0.8);
    overflow: hidden;
    transition: translate var(--dur) var(--ease-out), scale var(--dur-instant) var(--ease-out), box-shadow var(--dur) var(--ease-out), filter var(--dur) var(--ease-out);
  }
  .hq-welcome__enter::before {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: inherit;
    opacity: 0.05;
    background-image: var(--pearl-grain);
    pointer-events: none;
  }
  .hq-welcome__enter > * { position: relative; }
  .hq-welcome__enter .icon { width: 18px; height: 18px; color: var(--pearl-ink-blue); stroke-width: 2; transition: transform var(--dur) var(--ease-out); }
  /* Hover: the satin brightens and the button lifts; press settles it. */
  .hq-welcome__enter:hover {
    filter: brightness(1.05);
    translate: 0 -2px;
    box-shadow: var(--pearl-rim), 0 2px 4px rgba(0, 0, 0, 0.35), 0 26px 52px -18px rgba(0, 0, 0, 0.85), 0 0 0 4px rgb(var(--pearl-rgb) / 0.10);
  }
  .hq-welcome__enter:active { scale: 0.98; filter: brightness(0.98); }
  .hq-welcome__enter:hover .icon { transform: translateX(3px); }
  .hq-welcome__enter:focus-visible { box-shadow: var(--pearl-rim), var(--focus-ring); }
  .hq-welcome__hint { font-size: 12px; color: var(--text-subtle); }
  @media (hover: none) { .hq-welcome__hint { display: none; } }
  .hq-welcome__skip {
    position: absolute;
    top: calc(18px + env(safe-area-inset-top));
    right: 18px;
    z-index: 1;
    display: inline-flex;
    align-items: center;
    gap: 2px;
    padding: 8px 10px 8px 14px;
    border-radius: 999px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-subtle);
    transition: color var(--dur-fast) var(--ease-out), background-color var(--dur-fast) var(--ease-out);
  }
  .hq-welcome__skip .icon { width: 16px; height: 16px; }
  .hq-welcome__skip:hover { color: var(--text); background: rgb(var(--fg-rgb) / 0.05); }
  .hq-welcome__note { position: absolute; left: 0; right: 0; bottom: calc(12px + env(safe-area-inset-bottom)); padding: 0 20px; text-align: center; font-size: 11px; color: var(--text-subtle); opacity: 0.55; }
  /* The logo travels to its place in the navigation (View Transitions). */
  [data-logo] { view-transition-name: hq-logo; }
  @media (max-width: 1023px) { .hq-sidebar [data-logo] { view-transition-name: none; } }
  @media (min-width: 1024px) { .hq-topbar [data-logo] { view-transition-name: none; } }
}

@layer motion {
  @keyframes hq-w-logo {
    from { opacity: 0; transform: scale(0.86); filter: blur(14px); }
    60% { filter: blur(0); }
  }
  @keyframes hq-w-disc { from { opacity: 0; transform: scale(0.6); } }
  @keyframes hq-w-pane { from { opacity: 0; transform: translateY(10px) scale(0.98); } }
  @keyframes hq-w-up { from { opacity: 0; transform: translateY(14px); } }
  @keyframes hq-w-sweep { from { transform: translateX(-120%) skewX(-18deg); } to { transform: translateX(260%) skewX(-18deg); } }
  @keyframes hq-idle { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-5px); } }
  @keyframes hq-ring-breathe { 0%, 100% { box-shadow: 0 0 0 1.5px rgb(var(--orange-rgb) / 0.45); } 50% { box-shadow: 0 0 0 1.5px rgb(var(--orange-rgb) / 0.85), 0 0 12px rgb(var(--orange-rgb) / 0.30); } }
  @keyframes hq-leave { to { opacity: 0; transform: translateY(8px); } }

  @media (prefers-reduced-motion: no-preference) {
    /* Welcome: the glow opens, the logo comes into focus, then the title
       and the button rise. About 1.5 s in all; any key or tap completes it.
       The entrance plays only on a visible page (an inline script adds
       hq-intro before first paint), so nothing can stay hidden. */
    .hq-intro .hq-welcome .hq-welcome__pane { animation: hq-w-pane 1100ms var(--ease-out) both; }
    .hq-intro .hq-welcome .hq-welcome__logo img { animation: hq-w-logo 1200ms var(--ease-out) 150ms both; }
    .hq-intro .hq-welcome .hq-welcome__title { animation: hq-w-up 800ms var(--ease-out) 700ms both; }
    .hq-intro .hq-welcome .hq-welcome__enter { animation: hq-w-up 800ms var(--ease-out) 950ms both; }
    .hq-intro .hq-welcome :is(.hq-welcome__hint, .hq-welcome__skip, .hq-welcome__note) { animation: hq-fade 700ms var(--ease-out) 1250ms both; }
    .hq-intro .hq-welcome .hq-welcome__enter::after {
      content: "";
      position: absolute;
      inset: 0 auto 0 0;
      width: 40%;
      background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.55), transparent);
      animation: hq-w-sweep 1300ms var(--ease-out) 1500ms both;
      pointer-events: none;
    }
    .hq-welcome.is-instant *, .hq-welcome.is-instant *::after { animation: none !important; }
    /* Leaving: everything but the logo on its pearl pane fades, and the
       two glide into the navigation as the dashboard appears. */
    .hq-welcome.is-leaving .hq-welcome__center > :not(.hq-welcome__stage),
    .hq-welcome.is-leaving .hq-welcome__bottom,
    .hq-welcome.is-leaving .hq-welcome__skip,
    .hq-welcome.is-leaving .hq-welcome__note { animation: hq-leave 220ms var(--ease-in) both; }
    ::view-transition-group(hq-logo) { animation-duration: 720ms; animation-timing-function: cubic-bezier(0.65, 0, 0.35, 1); }
    ::view-transition-old(hq-logo) { animation: hq-fade 720ms var(--ease-in-out) reverse both; }
    ::view-transition-new(hq-logo) { animation: hq-fade 720ms var(--ease-in-out) both; }

    /* TESLA: a gentle idle presence (pointer-free, low amplitude). */
    .hq-presence__button .hq-portrait { animation: hq-ring-breathe 4.5s ease-in-out 3; }
    .hq-presence[open] .hq-presence__panel { animation: hq-pop 320ms var(--ease-out); }
    .hq-report__figure img { transition: translate var(--dur-slow) var(--ease-out); }
    @media (hover: hover) and (pointer: fine) {
      .hq-report__figure:hover img { translate: 0 -4px; }
    }
  }
}

/* ------------------------------------------------------------------ */
/* Existing pages (app.css classes) in the premium look                */
/* ------------------------------------------------------------------ */

@layer tokens {
  /* app.css tokens, set to the premium values: panels, tables, forms,
     tags and buttons on every existing page follow them. */
  :root {
    --bg: var(--navy-900);
    --surface: var(--glass-1);
    --surface-muted: rgb(var(--fg-rgb) / 0.045);
    --border: var(--line);
    --border-strong: var(--line-strong);
    --primary: var(--pearl-hi);
    --primary-hover: #ffffff;
    --on-primary: var(--navy-900);
    --link: var(--blue-400);
    --focus: var(--blue-400);
    --selected-soft: rgb(var(--blue-rgb) / 0.16);
    --shadow: var(--shadow-1);
    --shadow-pop: var(--shadow-3);
    --radius-lg: var(--radius-card);
    --status-neutral: var(--text-subtle);
    --status-info: var(--blue-400);
    --status-active: var(--tesla);
    --status-ok: var(--ok-text);
    --status-error: var(--error-text);
  }
}

@layer components {
  /* Panels and cards become glass: tinted fill, top sheen, a light top edge. */
  .panel, .kpi, .opp-card, .tesla, .auth--single .auth-card {
    background: var(--sheen), var(--glass-1);
    border: 1px solid rgb(var(--fg-rgb) / 0.07);
    border-top-color: rgba(255, 255, 255, 0.15);
    box-shadow: var(--shadow-1), inset 0 1px 0 rgba(255, 255, 255, 0.05);
  }
  .panel { border-radius: var(--radius-card); }
  .kpi, .opp-card { border-radius: 18px; }
  .opp-card { background: rgb(var(--navy-rgb) / 0.32); }
  .tesla { --edge-top: rgb(var(--orange-rgb) / 0.42); border-top-color: rgb(var(--orange-rgb) / 0.38); }
  .page-title { font-weight: 600; letter-spacing: -0.035em; font-size: clamp(26px, 2.4vw + 12px, 34px); }
  .kpi__value { font-family: var(--font-display); letter-spacing: -0.03em; }
  .btn { border-radius: 12px; font-weight: 700; text-decoration: none; }
  .btn--primary { box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3); }
  input[type="text"], input[type="password"], input[type="email"], input[type="search"], input[type="number"], select, textarea {
    background: rgb(var(--navy-rgb) / 0.55);
    border-color: var(--line-strong);
    border-radius: 12px;
    color: var(--text);
  }
  .table th { color: var(--text-subtle); }
  .flash__item { border-radius: 14px; }
}

@layer motion {
  @media (prefers-reduced-motion: no-preference) {
    /* Existing pages reveal their header, KPI rows and panels the same way. */
    .hq-motion .hq-content :is(.page-header, .kpis, .panel):not(.is-revealed) { opacity: 0; }
    .hq-motion .hq-content :is(.page-header, .kpis, .panel).is-revealed {
      animation: hq-enter var(--dur-enter) var(--ease-out) both;
      animation-delay: calc(var(--i, 0) * var(--stagger));
    }
    .hq-motion .hq-content :is(.page-header, .kpis, .panel).is-revealed.is-scrolled-in { animation-name: hq-enter-light; }
    @media (max-width: 1023px), (pointer: coarse) {
      .hq-motion .hq-content :is(.page-header, .kpis, .panel).is-revealed { animation-name: hq-enter-light; animation-duration: 900ms; }
    }
  }
  @media print {
    .hq-motion .hq-content :is(.page-header, .kpis, .panel) { opacity: 1 !important; animation: none !important; }
  }
}

/* ------------------------------------------------------------------ */
/* Production additions: real data, sign-in and account                */
/* ------------------------------------------------------------------ */

@layer components {
  /* Sign-in: the pearl logo pane above one glass card. */
  .hq-auth {
    min-height: 100dvh;
    display: grid;
    align-content: center;
    justify-items: center;
    gap: 28px;
    padding: calc(40px + env(safe-area-inset-top)) 20px calc(40px + env(safe-area-inset-bottom));
  }
  .hq-auth__brand { display: grid; justify-items: center; gap: 16px; text-align: center; }
  .hq-auth__pane {
    position: relative;
    display: block;
    width: 220px;
    height: 150px;
    border-radius: 24px;
    background: var(--pearl-surface);
    box-shadow: var(--pearl-shadow);
    overflow: hidden;
  }
  .hq-auth__pane img { position: absolute; left: 50%; top: 50%; width: 200px; height: 200px; max-width: none; transform: translate(-50%, -50%); }
  .hq-auth__name { font-family: var(--font-display); font-size: 17px; font-weight: 650; }
  .hq-auth__name span { margin-left: 6px; font-weight: 400; letter-spacing: 0.32em; text-transform: uppercase; font-size: 12px; color: var(--text-muted); }
  .hq-auth__card {
    width: min(400px, 100%);
    display: grid;
    gap: 14px;
    padding: 28px 26px 26px;
    border-radius: var(--radius-card);
    background: var(--sheen), var(--glass-1);
    box-shadow: var(--shadow-2), inset 0 1px 0 rgba(255, 255, 255, 0.08), inset 0 0 0 1px rgb(var(--fg-rgb) / 0.06);
  }
  .hq-auth__title { font-family: var(--font-display); font-size: 24px; font-weight: 600; letter-spacing: -0.02em; }
  .hq-auth__text { margin-top: -8px; font-size: 14px; color: var(--text-muted); }
  .hq-auth__submit { width: 100%; justify-content: center; height: 52px; border: 0; cursor: pointer; }
  .hq-auth__agent { font-size: 11.5px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--text-subtle); }
  .hq-auth__agent strong { font-family: var(--font-display); color: var(--tesla); }

  /* SEC-02.1: two-step verification, recovery codes and re-authentication on the
     same card; the Security page reuses cards, facts and tables. */
  .hq-auth__card--wide { width: min(460px, 100%); }
  .hq-auth__notice { padding: 10px 12px; border-radius: 12px; font-size: 14px; line-height: 1.45; background: rgb(var(--blue-rgb) / 0.1); box-shadow: inset 0 0 0 1px rgb(var(--blue-rgb) / 0.25); }
  .hq-auth__alt { font-size: 13.5px; text-align: center; }
  .hq-auth__alt a { color: var(--blue-500); }
  .hq-auth__steps { display: grid; gap: 6px; padding-left: 20px; list-style: decimal; font-size: 14px; line-height: 1.45; }
  .hq-auth__qr { justify-self: center; margin: 4px 0; padding: 10px; border-radius: 16px; background: #fff; box-shadow: inset 0 0 0 1px rgb(var(--navy-rgb) / 0.12); }
  .hq-auth__qr img { display: block; width: 225px; height: 225px; image-rendering: pixelated; }
  .hq-auth__keybox { display: grid; gap: 4px; text-align: center; }
  .hq-auth__keylabel { font-size: 12.5px; opacity: 0.75; }
  .hq-auth__key, .hq-auth__codes { font-family: ui-monospace, "SFMono-Regular", Consolas, monospace; letter-spacing: 0.06em; user-select: all; }
  .hq-auth__key { font-size: 15px; word-break: break-all; }
  .hq-auth__codes { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px 16px; padding: 12px 16px 12px 36px; border-radius: 12px; font-size: 15px; background: rgb(var(--navy-rgb) / 0.06); }
  .hq-sec-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 14px; }
  .hq-sec-actions--row { margin-top: 0; gap: 6px; }

  /* Account menu: the language setting of the signed-in user. */
  .hq-account__language { padding: 4px 0 8px; border-bottom: 1px solid var(--line-soft); }
  .hq-account__choose { display: flex; gap: 8px; padding: 0 10px; }
  .hq-account__choose select { min-height: 40px; font-size: 14px; }
  .hq-account__choose .btn { min-height: 40px; flex: none; }
  .hq-account__row { cursor: default; }

  /* TESLA running: his dot breathes in orange (motion layer); ready is green. */
  .hq-presence__dot.is-running { background: var(--tesla); }
  .hq-tesla__dot:not(.is-running) { background: var(--ok-text); box-shadow: 0 0 0 3px rgb(var(--green-rgb) / 0.18); }

  /* Navigation items without a page yet. */
  .hq-nav__link.is-disabled { opacity: 0.55; cursor: default; }
  .hq-nav__soon { margin-left: auto; font-size: 11px; font-weight: 650; color: var(--text-subtle); }

  /* Top bar: the last import (desktop and tablet; on phones it is in the header). */
  .hq-sync { padding-right: 14px; }
  @media (max-width: 639px) { .hq-sync { display: none; } }

  /* Figures with their source cell. */
  .hq-ledger__source, .hq-pulse__source { display: block; margin-top: 6px; }
  .hq-ledger__cell { font-size: 12px; letter-spacing: 0.02em; color: var(--pearl-ink-muted); }
  .hq-ledger__item--result .source-ref { color: var(--pearl-ink-muted); }
  .hq-figure-empty { color: var(--text-subtle); }
  .hq-count-badge--neutral { color: var(--text); background: rgb(var(--fg-rgb) / 0.08); box-shadow: inset 0 0 0 1px var(--line); }
  .hq-card__note { margin-top: 14px; font-size: 12.5px; line-height: 1.5; color: var(--text-subtle); }
  .hq-pill--idle { color: var(--text-muted); background: rgb(var(--fg-rgb) / 0.05); box-shadow: inset 0 0 0 1px var(--line); }
  .hq-text-ok { color: var(--ok-text); }

  /* Label / value grids */
  .hq-facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; margin-bottom: 18px; }
  .hq-facts div { padding: 10px 12px; border-radius: 12px; background: var(--glass-0); box-shadow: inset 0 0 0 1px var(--line-soft); }
  .hq-facts dt { font-size: 12px; font-weight: 600; color: var(--text-subtle); }
  .hq-facts dd { margin: 2px 0 0; font-weight: 700; font-variant-numeric: tabular-nums; }
  .hq-facts dd small { color: var(--text-subtle); font-weight: 600; }
  .hq-facts--compact { grid-template-columns: 1fr 1fr; margin: 0 0 14px; }

  .hq-indicators { display: grid; }
  .hq-indicators__row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 16px; padding: 12px 0; border-top: 1px solid var(--line-soft); }
  .hq-indicators__row:first-child { border-top: 0; padding-top: 0; }
  .hq-indicators dt { font-size: 14px; font-weight: 600; color: var(--text-muted); }
  .hq-indicators dd { margin: 0; display: flex; flex-wrap: wrap; justify-content: flex-end; align-items: baseline; gap: 6px 10px; text-align: right; }
  .hq-indicators__value { font-family: var(--font-display); font-weight: 600; font-variant-numeric: tabular-nums; }
  .hq-indicators__note { flex-basis: 100%; font-size: 12px; color: var(--text-subtle); }
  @container (max-width: 480px) {
    .hq-indicators__row { grid-template-columns: 1fr; }
    .hq-indicators dd { justify-content: flex-start; text-align: left; }
  }
  .hq-notes { display: grid; gap: 10px; font-size: 13px; line-height: 1.55; color: var(--text-muted); }

  /* Receivables by age: not yet due (blue), then warning and error tones */
  .hq-donut__arc--pearl { stroke: var(--pearl); }
  .hq-donut-swatch--1 { background: var(--age-0); }
  .hq-donut-swatch--2 { background: var(--age-1); }
  .hq-donut-swatch--3 { background: var(--age-2); }
  .hq-donut-swatch--4 { background: var(--age-3); box-shadow: var(--age-glow); }
  .hq-donut-swatch--pearl { background: var(--pearl); }
  .hq-donut-swatch--error { background: var(--error-text); }


  /* Pose selector under TESLA's stage. */
  .hq-poses {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-top: 18px;
    padding: 6px;
    border-radius: 18px;
    background: rgb(var(--navy-rgb) / 0.45);
    box-shadow: inset 0 0 0 1px var(--line-soft);
    max-width: 100%;
    overflow-x: auto;
    scrollbar-width: none;
  }
  .hq-poses__btn {
    display: grid;
    justify-items: center;
    gap: 6px;
    min-width: 62px;
    padding: 8px 6px 6px;
    border: 0;
    border-radius: 14px;
    background: transparent;
    color: var(--text-subtle);
    font: inherit;
    font-size: 11.5px;
    font-weight: 650;
    cursor: pointer;
    transition: background-color var(--dur-fast) var(--ease-out), color var(--dur-fast) var(--ease-out);
  }
  .hq-poses__btn:hover { color: var(--text); background: rgb(var(--fg-rgb) / 0.04); }
  .hq-poses__btn[aria-pressed="true"] { color: var(--text); background: rgb(var(--orange-rgb) / 0.12); box-shadow: inset 0 0 0 1px rgb(var(--orange-rgb) / 0.3); }
  .hq-poses__thumb {
    position: relative;
    display: block;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    overflow: hidden;
    background: radial-gradient(circle at 50% 30%, rgb(var(--blue-rgb) / 0.26), rgb(var(--navy-rgb) / 0.95) 70%);
    box-shadow: 0 0 0 1px var(--line);
  }
  .hq-poses__btn[aria-pressed="true"] .hq-poses__thumb { box-shadow: 0 0 0 2px var(--tesla); }
  .hq-poses__thumb img { position: absolute; left: 50%; top: 0; width: 200%; max-width: none; height: auto; transform: translateX(-50%); }
  @media (max-width: 639px) {
    .hq-poses { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 2px; width: 100%; padding: 4px; }
    .hq-poses__btn { min-width: 0; padding: 8px 2px 6px; font-size: 10.5px; letter-spacing: -0.01em; }
    .hq-poses__thumb { width: 38px; height: 38px; }
  }
  .hq-agent__caption { margin-top: 8px; font-size: 12.5px; color: var(--text-subtle); min-height: 1.5em; }
  .hq-agent__figure { transition: opacity 260ms var(--ease-out), transform 420ms var(--ease-out); }
  .hq-agent__figure.is-swapping { opacity: 0; transform: translateY(8px) scale(0.985); }

  /* ---------- TESLA AGENT page ------------------------------------------ */
  .hq-agent { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); gap: var(--gap); align-items: start; }
  .hq-agent__actions { grid-column: 1 / -1; }
  .hq-agent__side { display: grid; gap: var(--gap); }
  @media (max-width: 1099px) { .hq-agent { grid-template-columns: 1fr; } }

  .hq-agent__stage {
    position: relative;
    isolation: isolate;
    display: grid;
    justify-items: center;
    padding: 28px 24px 24px;
    border-radius: var(--radius-card);
    background:
      radial-gradient(70% 55% at 50% 38%, rgb(var(--blue-rgb) / 0.22), transparent 70%),
      radial-gradient(60% 30% at 50% 92%, rgb(var(--orange-rgb) / 0.14), transparent 70%),
      var(--sheen), rgb(var(--navy-rgb) / 0.72);
    box-shadow: var(--shadow-2), inset 0 0 0 1px rgb(var(--orange-rgb) / 0.20), inset 0 1px 0 rgba(255, 255, 255, 0.08);
    overflow: hidden;
  }
  /* A soft floor light right under TESLA's feet. */
  .hq-agent__light {
    width: 62%;
    height: 30px;
    margin-top: -22px;
    border-radius: 50%;
    background: radial-gradient(closest-side, rgb(var(--orange-rgb) / 0.28), transparent);
    filter: blur(6px);
    pointer-events: none;
  }
  .hq-agent__figure { display: block; width: auto; height: min(62vh, 560px); max-width: 100%; object-fit: contain; filter: drop-shadow(0 24px 30px rgba(0, 0, 0, 0.55)); }
  @media (max-width: 639px) { .hq-agent__figure { height: 420px; } }
  .hq-agent__plate { margin-top: 16px; text-align: center; }
  .hq-agent__name { font-family: var(--font-display); font-size: 30px; font-weight: 700; letter-spacing: 0.04em; }
  .hq-agent__name span { color: var(--tesla); font-weight: 400; letter-spacing: 0.18em; }
  .hq-agent__role { margin-top: 4px; font-size: 13.5px; color: var(--text-muted); }
  .hq-agent__state { display: inline-flex; align-items: center; gap: 8px; margin-top: 12px; padding: 6px 12px; border-radius: 999px; font-size: 12.5px; font-weight: 650; color: var(--ok-text); background: rgb(var(--green-rgb) / 0.14); }
  .hq-agent__pulse { width: 8px; height: 8px; border-radius: 50%; background: currentColor; }

  .hq-agent__status { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
  .hq-agent__status div { padding: 12px 14px; border-radius: 14px; background: var(--glass-0); box-shadow: inset 0 0 0 1px var(--line-soft); }
  .hq-agent__status dt { font-size: 12px; font-weight: 600; color: var(--text-subtle); }
  .hq-agent__status dd { margin-top: 4px; font-weight: 700; font-size: 15px; }
  .hq-agent__status--ok { color: var(--ok-text); }
  .hq-agent__summary { font-size: 14.5px; line-height: 1.6; color: var(--text); max-width: 70ch; }
  /* Latest research: TESLA at his laptop in his own column beside the
     title and summary; the discoveries span the full width beneath him. */
  .hq-research {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-rows: auto 1fr;
    column-gap: 16px;
  }
  .hq-research__head { grid-column: 1; grid-row: 1; margin-bottom: 12px; }
  .hq-research__summary { grid-column: 1; grid-row: 2; align-self: start; margin-bottom: 18px; }
  .hq-research__tesla {
    grid-column: 2;
    grid-row: 1 / 3;
    align-self: end;
    width: clamp(132px, 36cqi, 212px);
    height: auto;
    margin: -14px -12px 0 0;
  }
  .hq-research__found { grid-column: 1 / -1; border-top: 1px solid var(--line-soft); }
  .hq-research__found .hq-subhead { margin-top: 16px; }
  /* Narrow cards: the summary moves under TESLA, keeping its full width. */
  @container (max-width: 520px) {
    .hq-research__head { flex-wrap: wrap; gap: 4px 12px; align-self: start; padding-top: 4px; }
    .hq-research__head .hq-card__meta { margin-left: 0; width: 100%; }
    .hq-research__summary { grid-column: 1 / -1; grid-row: 3; margin: 14px 0 18px; }
    .hq-research__found { grid-row: 4; }
    .hq-research__tesla { margin: -8px -6px 0 0; }
  }
  .hq-agent__kind {
    flex: none;
    min-width: 5.5rem;
    padding: 3px 8px;
    border-radius: 8px;
    font-size: 11.5px;
    font-weight: 700;
    text-align: center;
    color: var(--blue-300);
    background: rgb(var(--blue-rgb) / 0.12);
  }

  /* Conversation (concept) */
  .hq-chat { display: grid; gap: 12px; margin-bottom: 16px; }
  .hq-chat__msg { display: flex; align-items: flex-end; gap: 10px; }
  .hq-chat__msg--user { justify-content: flex-end; }
  .hq-chat__bubble { max-width: min(70ch, 78%); padding: 12px 14px; border-radius: 16px; font-size: 14px; line-height: 1.5; }
  .hq-chat__msg--tesla .hq-chat__bubble { border-bottom-left-radius: 6px; background: rgb(var(--fg-rgb) / 0.05); box-shadow: inset 0 0 0 1px var(--line); }
  .hq-chat__msg--user .hq-chat__bubble { border-bottom-right-radius: 6px; background: rgb(var(--blue-rgb) / 0.32); box-shadow: inset 0 0 0 1px rgb(var(--blue-rgb) / 0.32); }
  .hq-quick { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
  .hq-quick__action {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 40px;
    padding: 0 14px;
    border: 0;
    border-radius: 999px;
    font-size: 13px;
    font-weight: 650;
    color: var(--text-muted);
    background: var(--glass-0);
    box-shadow: inset 0 0 0 1px var(--line);
    cursor: pointer;
  }
  .hq-quick__action .hq-icon { width: 16px; height: 16px; color: var(--blue-300); }
  .hq-quick__action:hover { color: var(--text); box-shadow: inset 0 0 0 1px rgb(var(--blue-rgb) / 0.4); }

  /* Real states and actions on the TESLA AGENT page */
  .hq-agent__state--active { color: var(--tesla); background: rgb(var(--orange-rgb) / 0.14); }
  .hq-agent__state--error { color: var(--error-text); background: rgb(var(--red-rgb) / 0.14); }
  .hq-agent__status--active { color: var(--tesla); }
  .hq-agent__status--error { color: var(--error-text); }
  .hq-agent__status-wide { grid-column: 1 / -1; }
  .hq-agent__status-text { font-weight: 500 !important; font-size: 13.5px !important; line-height: 1.5; color: var(--text-muted); }
  .hq-agent__status dd small { display: block; margin-top: 2px; font-size: 12px; font-weight: 500; color: var(--text-subtle); }
  .hq-agent__more { margin-top: var(--gap); }
  .hq-quick form { display: contents; }
  .hq-quick__action { text-decoration: none; }
  .hq-quick__action--primary { color: var(--text-on-light); background: var(--text); box-shadow: none; }
  .hq-quick__action--primary .icon, .hq-quick__action--primary:hover { color: var(--text-on-light); }
  .hq-quick__action:disabled { opacity: 0.5; cursor: not-allowed; }
  .hq-quick__action .icon { width: 16px; height: 16px; color: var(--blue-300); }
  .hq-research__found .prio { flex: none; }
  @media (prefers-reduced-motion: no-preference) {
    .hq-agent__figure { animation: hq-idle 6s ease-in-out infinite; }
    @media (hover: hover) and (pointer: fine) { .hq-quick__action:hover { transform: translateY(-1px); } }
  }

  /* Requires attention: the import's tones (warning, info) */
  .hq-attention__item { list-style: none; }
  .hq-attention__item--warning .hq-attention__icon { color: var(--warn); background: rgb(var(--warn-rgb) / 0.12); }
  .hq-attention__item--info .hq-attention__icon { color: var(--blue-300); background: rgb(var(--blue-rgb) / 0.14); }
  .hq-attention--flagged .hq-attention__item--warning .hq-attention__icon { color: var(--pearl-ink-warn); background: rgb(var(--warn-rgb) / 0.32); }
  .hq-attention--flagged .hq-attention__item--info .hq-attention__icon { color: var(--pearl-ink-blue); background: rgb(var(--blue-rgb) / 0.12); }
  .hq-attention--flagged .source-ref { color: var(--pearl-ink-muted); }
  .hq-attention--flagged .hq-attention__lead a, .hq-attention__action { color: var(--pearl-ink-blue); font-weight: 650; }
  .hq-attention:not(.hq-attention--flagged) .hq-attention__action { color: var(--blue-300); }
}

@layer motion {
  @media (prefers-reduced-motion: no-preference) {
    .hq-presence__dot.is-running, .hq-tesla__dot.is-running { animation: hq-breathe 2.4s ease-in-out infinite; }
  }
}

/* ------------------------------------------------------------------ */
/* Home: details on request, single-month view, tiles                  */
/* ------------------------------------------------------------------ */

@layer components {
  /* Info: sources, definitions and calculation notes, shown on request so
     the dashboard itself stays free of technical detail. */
  .hq-info { position: relative; display: inline-block; }
  .hq-info__button {
    display: inline-grid;
    place-items: center;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    list-style: none;
    cursor: pointer;
    color: var(--text-subtle);
    transition: color var(--dur-fast) var(--ease-out), background-color var(--dur-fast) var(--ease-out);
  }
  .hq-info__button::-webkit-details-marker { display: none; }
  .hq-info__button .icon { width: 17px; height: 17px; }
  .hq-info__button:hover, .hq-info[open] .hq-info__button { color: var(--text); background: rgb(var(--fg-rgb) / 0.07); }
  .hq-info__button--labelled {
    width: auto;
    height: 42px;
    gap: 6px;
    grid-auto-flow: column;
    padding: 0 14px 0 12px;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 650;
    color: var(--text-muted);
    background: var(--glass-1);
    box-shadow: inset 0 0 0 1px var(--line), inset 0 1px 0 var(--highlight);
  }
  .hq-info__button--labelled .icon { width: 18px; height: 18px; color: var(--blue-400); }
  .hq-info__panel {
    position: absolute;
    top: calc(100% + 8px);
    right: -6px;
    z-index: 30;
    display: grid;
    gap: 8px;
    width: min(320px, calc(100vw - 32px));
    padding: 14px 16px;
    border-radius: var(--radius);
    background: var(--glass-3);
    box-shadow: var(--shadow-3), inset 0 0 0 1px var(--line-strong);
    -webkit-backdrop-filter: blur(var(--blur)) saturate(140%);
    backdrop-filter: blur(var(--blur)) saturate(140%);
    font-size: 13px;
    font-weight: 500;
    line-height: 1.5;
    letter-spacing: 0;
    text-transform: none;
    color: var(--text-muted);
    text-align: left;
    white-space: normal;
  }
  .hq-info--inline .hq-info__panel { left: -10px; right: auto; }
  .hq-info__panel--wide { width: min(440px, calc(100vw - 32px)); max-height: min(70vh, 560px); overflow-y: auto; }
  .hq-info__title { font-family: var(--font-display); font-size: 15px; font-weight: 600; color: var(--text); }
  .hq-info__subtitle { margin-top: 6px; font-size: 12px; font-weight: 650; letter-spacing: 0.05em; text-transform: uppercase; color: var(--text-subtle); }
  .hq-info__text { display: block; }
  .hq-info__list { display: grid; gap: 4px; margin: 0; }
  .hq-info__list div { display: flex; justify-content: space-between; gap: 12px; padding: 4px 0; border-top: 1px solid var(--line-soft); }
  .hq-info__list div:first-child { border-top: 0; }
  .hq-info__list dt { color: var(--text-muted); }
  .hq-info__list dd { margin: 0; white-space: nowrap; }
  .hq-info__notes { display: grid; gap: 8px; margin: 0; padding: 0; list-style: none; }
  /* Open menus and panels stay above the cards that follow them. */
  .hq-header { position: relative; z-index: 6; }
  :is(.hq-card, .hq-pulse):has(details[open]) { z-index: 7; }

  /* Page header: the import line with the sources panel beside it. */
  .hq-header__meta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; margin-top: 6px; }
  .hq-header__meta .hq-subtitle { margin-top: 0; }
  .hq-info--header .hq-info__button--labelled { height: 28px; padding: 0 10px 0 8px; border-radius: 999px; font-size: 12.5px; }
  .hq-info--header .hq-info__button--labelled .icon { width: 15px; height: 15px; }

  /* One imported month: its revenue against its total costs. */
  .hq-monthbars { display: grid; gap: 18px; margin-top: 6px; padding: 20px 20px 16px; border-radius: 18px; background: rgb(var(--navy-rgb) / 0.28); box-shadow: inset 0 0 0 1px var(--line-soft); }
  .hq-monthbars__rows { display: grid; gap: 14px; margin: 0; padding: 0; list-style: none; }
  .hq-monthbars__row { display: grid; grid-template-columns: 170px minmax(0, 1fr) auto; align-items: center; gap: 16px; }
  .hq-monthbars__label { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 650; color: var(--text-muted); }
  .hq-monthbars__track { display: block; height: 12px; border-radius: 12px; background: rgb(var(--fg-rgb) / 0.05); overflow: hidden; }
  .hq-monthbars__bar { display: block; width: var(--value); height: 100%; border-radius: inherit; transform-origin: left; }
  .hq-monthbars__row--revenue .hq-monthbars__bar { background: var(--blue-400); box-shadow: 0 0 14px rgb(var(--blue-rgb) / 0.3); }
  .hq-monthbars__row--expenses .hq-monthbars__bar { background: var(--pearl); }
  .hq-monthbars__value { font-family: var(--font-display); font-size: 15px; font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
  .hq-monthbars__note { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--text-subtle); }
  .hq-monthbars__note .icon { width: 16px; height: 16px; flex: none; }
  @container (max-width: 560px) {
    .hq-monthbars { padding: 16px 14px 14px; }
    .hq-monthbars__row { grid-template-columns: 1fr auto; gap: 6px 12px; }
    .hq-monthbars__track { grid-column: 1 / -1; grid-row: 2; }
    .hq-monthbars__note { align-items: flex-start; }
  }

  /* Projects: a dash where the workbook records nothing for the project. */
  .hq-site__none { color: var(--text-subtle); font-weight: 600; }

  /* Receivables without a donut (nothing invoiced or collected yet). */
  .hq-receivables--single { grid-template-columns: 1fr; }
  .hq-stat__label .hq-info { vertical-align: middle; }

  /* Performance indicators: tiles in the key-indicator style. */
  .hq-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; margin: 0; padding: 0; list-style: none; }
  .hq-tile { display: grid; gap: 4px; align-content: start; padding: 16px 18px; border-radius: 16px; background: var(--glass-0); box-shadow: inset 0 0 0 1px var(--line-soft), inset 0 1px 0 var(--highlight); }
  .hq-tile__label { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 13px; font-weight: 650; color: var(--text-muted); }
  .hq-tile__label .hq-info__button { width: 24px; height: 24px; margin: -4px -6px -4px 0; }
  .hq-tile__value { font-family: var(--font-display); font-size: 24px; font-weight: 600; letter-spacing: -0.03em; line-height: 1.15; font-variant-numeric: tabular-nums; }
  .hq-tile__note { font-size: 12px; color: var(--text-subtle); }
  .hq-tile .hq-info--inline .hq-info__panel { left: auto; right: -8px; }
  @media (max-width: 639px) { .hq-tiles { grid-template-columns: 1fr 1fr; } .hq-tile { padding: 14px; } .hq-tile__value { font-size: 20px; } }

  /* TESLA's opportunities: compact, as approved; the full text and the
     evidence are on each opportunity page. */
  .hq-opp__why { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
  .hq-opp__next > span { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
  .hq-opp__estimate { font-size: 11.5px; font-weight: 600; color: var(--text-subtle); white-space: nowrap; }
  .hq-opp__estimate::before { content: "· "; }
  .hq-opp__evidence { display: inline-flex; align-items: center; gap: 2px; margin-top: 2px; font-size: 12.5px; font-weight: 650; color: var(--blue-400); }
  .hq-opp__evidence .icon { width: 14px; height: 14px; }
}

@layer motion {
  @media (prefers-reduced-motion: no-preference) {
    .hq-info[open] .hq-info__panel { animation: hq-pop 240ms var(--ease-out); }
    .hq-motion .is-revealed .hq-monthbars__bar {
      animation: hq-grow-x 1400ms var(--ease-out) both;
      animation-delay: calc(380ms + var(--i, 0) * 140ms);
    }
  }
}

/* ------------------------------------------------------------------ */
/* TESLA AGENT chat: answers from stored records (section 7.4)         */
/* ------------------------------------------------------------------ */

@layer components {
  .hq-ask__log { max-height: min(60vh, 520px); margin: 4px 0 14px; padding-right: 4px; overflow-y: auto; overscroll-behavior: contain; }
  .hq-ask__log .hq-chat__msg--tesla { align-items: flex-start; }
  .hq-ask__log .hq-pose-avatar { flex: none; }
  .hq-ask__log .hq-chat__bubble { min-width: 0; overflow-wrap: anywhere; }
  .hq-ask__answer, .hq-ask__block { display: grid; grid-template-columns: minmax(0, 1fr); }
  .hq-ask__answer { gap: 10px; }
  .hq-ask__block { gap: 6px; }
  .hq-ask__block + .hq-ask__block { padding-top: 10px; border-top: 1px solid var(--line-soft); }
  .hq-ask__kind { justify-self: start; padding: 2px 8px; border-radius: 8px; font-size: 11px; font-weight: 700; letter-spacing: 0.01em; color: var(--blue-300); background: rgb(var(--blue-rgb) / 0.12); }
  .hq-ask__kind--estimate, .hq-ask__kind--recommendation, .hq-ask__kind--clarification { color: var(--tesla); background: rgb(var(--orange-rgb) / 0.12); }
  .hq-ask__kind--calculated { box-shadow: inset 0 0 0 1px rgb(var(--blue-rgb) / 0.35); }
  .hq-ask__kind--not_found, .hq-ask__kind--unverified { color: var(--text-subtle); background: rgb(var(--fg-rgb) / 0.06); }
  .hq-ask__kind--incomplete { color: var(--text); background: rgb(var(--fg-rgb) / 0.06); box-shadow: inset 0 0 0 1px var(--line); }
  .hq-ask__links { display: flex; flex-wrap: wrap; gap: 6px; }
  .hq-ask__links a { display: inline-flex; max-width: 100%; padding: 3px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; color: var(--blue-300); text-decoration: none; background: rgb(var(--fg-rgb) / 0.04); box-shadow: inset 0 0 0 1px var(--line); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .hq-ask__links a:hover { box-shadow: inset 0 0 0 1px rgb(var(--blue-rgb) / 0.45); }
  /* TESLA Chat v2: natural answers. Text first; a tag only where a statement is
     not a checked record; sources once, collapsed; drafts apart and unsaved. */
  .hq-ask__text { display: grid; gap: 8px; }
  .hq-ask__para { margin: 0; white-space: pre-line; line-height: 1.55; }
  .hq-ask__tag { display: inline-block; margin-right: 2px; padding: 1px 7px; border-radius: 7px; font-size: 11px; font-weight: 700; vertical-align: 1px; color: var(--text-muted); background: rgb(var(--fg-rgb) / 0.06); box-shadow: inset 0 0 0 1px var(--line); }
  .hq-ask__tag--estimate, .hq-ask__tag--recommendation { color: var(--tesla); background: rgb(var(--orange-rgb) / 0.12); box-shadow: none; }
  .hq-ask__tag--owner_info { color: var(--blue-300); background: rgb(var(--blue-rgb) / 0.12); box-shadow: none; }
  .hq-ask__check { margin: 0; padding-left: 18px; font-size: 12.5px; color: var(--text-subtle); }
  .hq-ask__draft { display: grid; gap: 6px; padding: 12px 14px; border-radius: 12px; background: var(--glass-0); box-shadow: inset 3px 0 0 var(--blue-300), inset 0 0 0 1px var(--line-soft); }
  .hq-ask__draft p { margin: 0; }
  .hq-ask__draft-title { font-size: 12px; font-weight: 700; color: var(--blue-300); }
  .hq-ask__draft-text { white-space: pre-line; line-height: 1.55; }
  /* TESLA Chat v2.1: a draft's fields, label beside value; stacked on a phone. */
  .hq-ask__draft-fields { display: grid; grid-template-columns: minmax(110px, max-content) minmax(0, 1fr); gap: 6px 14px; margin: 0; }
  .hq-ask__draft-fields dt { font-size: 12.5px; font-weight: 700; color: var(--text-muted); padding-top: 1px; }
  .hq-ask__draft-fields dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
  @media (max-width: 560px) {
    .hq-ask__draft-fields { grid-template-columns: minmax(0, 1fr); gap: 2px; }
    .hq-ask__draft-fields dd { margin-bottom: 6px; }
  }
  .hq-ask__notices { display: grid; gap: 4px; }
  .hq-ask__notice { margin: 0; padding-left: 10px; font-size: 12.5px; color: var(--text-subtle); box-shadow: inset 2px 0 0 var(--line); }
  .hq-ask__notice--caution, .hq-ask__notice--action { box-shadow: inset 2px 0 0 var(--tesla); }
  .hq-ask__notice a { color: var(--blue-300); }
  .hq-ask__sources { font-size: 12.5px; color: var(--text-subtle); }
  .hq-ask__sources summary { width: fit-content; cursor: pointer; border-radius: 6px; }
  .hq-ask__sources summary:focus-visible { outline: 2px solid var(--blue-300); outline-offset: 2px; }
  .hq-ask__sources[open] summary { margin-bottom: 6px; }
  .hq-ask__calc { margin: 6px 0 0; overflow-wrap: anywhere; }
  .hq-ask__error { color: var(--error-text); }
  .hq-ask__pending { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 10px; }
  .hq-ask__progress { font-size: 13px; color: var(--text-muted); }
  .hq-ask__progress:empty { display: none; }
  .hq-ask__dots { display: inline-flex; gap: 4px; padding: 4px 0; }
  .hq-ask__dots span { width: 6px; height: 6px; border-radius: 50%; background: var(--tesla); opacity: 0.4; }
  .hq-ask__form { display: flex; align-items: flex-end; gap: 8px; }
  .hq-ask__form textarea { flex: 1; min-width: 0; min-height: 48px; max-height: 160px; padding: 12px 14px; font: inherit; font-size: 16px; line-height: 1.4; resize: vertical; }
  .hq-ask__form .hq-quick__action { flex: none; min-height: 48px; }
  .hq-ask__form textarea:disabled { opacity: 0.5; }
  @media (max-width: 639px) {
    .hq-ask__log .hq-chat__bubble { max-width: calc(100% - 46px); }
    .hq-ask__log .hq-chat__msg--user .hq-chat__bubble { max-width: 88%; }
    .hq-ask__form .hq-quick__action span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
    .hq-ask__tools .hq-quick__action span, .hq-ask__tools .hq-select__button > span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  }
  /* Saved conversations (TESLA Core): a menu and "New conversation". */
  .hq-ask__tools { display: flex; align-items: center; gap: 8px; margin-left: auto; }
  .hq-ask__tools[hidden] { display: none; }
  .hq-ask__tools .hq-menu { width: min(320px, calc(100vw - 48px)); max-height: 320px; overflow-y: auto; }
  .hq-ask__tools button.hq-menu__item { width: 100%; border: 0; background: none; font: inherit; font-size: 14px; font-weight: 600; text-align: left; cursor: pointer; }
  .hq-ask__tools button.hq-menu__item { display: block; padding-block: 10px; line-height: 1.35; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .hq-ask__tools button.hq-menu__item:hover { background: rgb(var(--fg-rgb) / 0.06); }
  .hq-ask__tools li.hq-menu__item { cursor: default; }
}

@layer motion {
  @media (prefers-reduced-motion: no-preference) {
    .hq-ask__dots span { animation: hq-breathe 1.2s ease-in-out infinite; }
    .hq-ask__dots span:nth-child(2) { animation-delay: 160ms; }
    .hq-ask__dots span:nth-child(3) { animation-delay: 320ms; }
  }
}

/* ------------------------------------------------------------------ */
/* Construction sites (ARCHITECTURE.md, section 16)                    */
/* ------------------------------------------------------------------ */

@layer components {
  .hq-muted { color: var(--text-subtle); }

  /* Status pills of a site and of an invoice */
  .hq-pill--site-active { color: var(--ok-text); background: rgb(var(--green-rgb) / 0.14); }
  .hq-pill--site-paused { color: var(--warn); background: rgb(var(--warn-rgb) / 0.13); }
  .hq-pill--site-completed { color: var(--blue-300); background: rgb(var(--blue-rgb) / 0.14); }
  .hq-pill--site-unrecorded { color: var(--text-muted); background: rgb(var(--fg-rgb) / 0.05); box-shadow: inset 0 0 0 1px var(--line); }
  .hq-pay {
    display: inline-flex;
    align-items: center;
    flex: none;
    height: 24px;
    padding: 0 9px;
    border-radius: 999px;
    font-size: 11.5px;
    font-weight: 700;
    white-space: nowrap;
  }
  .hq-pay--paid { color: var(--ok-text); background: rgb(var(--green-rgb) / 0.14); }
  .hq-pay--partial { color: var(--blue-300); background: rgb(var(--blue-rgb) / 0.14); }
  .hq-pay--unpaid { color: var(--text-muted); background: rgb(var(--fg-rgb) / 0.06); box-shadow: inset 0 0 0 1px var(--line); }
  .hq-pay--overdue { color: var(--error-text); background: rgb(var(--red-rgb) / 0.15); box-shadow: inset 0 0 0 1px rgb(var(--red-rgb) / 0.25); }
  .hq-pay--unknown { color: var(--text-subtle); background: transparent; box-shadow: inset 0 0 0 1px var(--line); }

  /* Summary by status: the pulse strip, each item a filter */
  .hq-sites-summary { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); margin-bottom: var(--gap); }
  .hq-sites-summary__item { text-decoration: none; color: inherit; }
  .hq-sites-summary__item[aria-current="true"] { background: rgb(var(--blue-rgb) / 0.08); box-shadow: inset 0 -2px 0 var(--blue-400); }
  .hq-sites-summary__item:is(.hq-sites-summary__item--active, .hq-sites-summary__item--paused, .hq-sites-summary__item--completed) .hq-pulse__label::before {
    content: "";
    display: inline-block;
    width: 7px;
    height: 7px;
    margin-right: 7px;
    border-radius: 50%;
    vertical-align: 1px;
  }
  .hq-sites-summary__item--active .hq-pulse__label::before { background: var(--ok-text); }
  .hq-sites-summary__item--paused .hq-pulse__label::before { background: var(--warn); }
  .hq-sites-summary__item--completed .hq-pulse__label::before { background: var(--blue-400); }
  @media (max-width: 899px) {
    .hq-sites-summary { grid-template-columns: 1fr 1fr; }
  }

  /* Filter bar: status segments and search */
  .hq-sites-filter { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin-bottom: 18px; }
  .hq-segmented {
    display: inline-flex;
    flex-wrap: wrap;
    gap: 2px;
    padding: 4px;
    border-radius: 14px;
    background: var(--glass-0);
    box-shadow: inset 0 0 0 1px var(--line);
  }
  .hq-segmented__item {
    display: inline-flex;
    align-items: center;
    min-height: 34px;
    padding: 0 14px;
    border: 0;
    border-radius: 10px;
    font: inherit;
    font-size: 13px;
    font-weight: 650;
    color: var(--text-muted);
    background: transparent;
    text-decoration: none;
    cursor: pointer;
    transition: color var(--dur-fast) var(--ease-out), background var(--dur-fast) var(--ease-out);
  }
  .hq-segmented__item:hover { color: var(--text); }
  .hq-segmented__item:is([aria-current="true"], [aria-selected="true"]) {
    color: var(--text);
    background: rgb(var(--fg-rgb) / 0.09);
    box-shadow: inset 0 0 0 1px var(--line-strong);
  }
  .hq-search {
    position: relative;
    display: flex;
    flex: 1 1 260px;
    align-items: center;
    max-width: 440px;
  }
  .hq-search .icon { position: absolute; left: 13px; width: 17px; height: 17px; color: var(--text-subtle); pointer-events: none; }
  .hq-search input[type="search"] {
    width: 100%;
    min-height: 42px;
    padding: 0 14px 0 40px;
    border: 1px solid var(--line-strong);
    border-radius: 12px;
    font-size: 16px;
    color: var(--text);
    background: rgb(var(--navy-rgb) / 0.55);
  }
  @media (min-width: 640px) { .hq-search input[type="search"] { font-size: 14px; } }
  .hq-sites-hint {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin-bottom: 18px;
    padding: 12px 14px;
    border-radius: 14px;
    font-size: 13.5px;
    color: var(--text-muted);
    background: rgb(var(--blue-rgb) / 0.07);
    box-shadow: inset 0 0 0 1px rgb(var(--blue-rgb) / 0.18);
  }
  .hq-sites-hint .icon { flex: none; width: 18px; height: 18px; margin-top: 1px; color: var(--blue-300); }
  .hq-sites-pages { margin-top: var(--gap); }

  /* Site cards */
  .hq-sitecards { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 360px), 1fr)); gap: var(--gap); align-items: start; }
  .hq-sitecard { display: grid; gap: 16px; padding: 22px 22px 18px; }
  .hq-sitecard--paused { --edge-top: rgb(var(--warn-rgb) / 0.30); }
  .hq-sitecard__head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
  .hq-sitecard__title { min-width: 0; }
  .hq-sitecard__name { font-family: var(--font-display); font-size: 19px; font-weight: 600; letter-spacing: -0.02em; line-height: 1.25; overflow-wrap: anywhere; }
  .hq-sitecard__name a { color: inherit; text-decoration: none; }
  .hq-sitecard__name a:hover { color: var(--blue-300); }
  .hq-sitecard__phase { display: flex; align-items: center; gap: 6px; margin-top: 4px; font-size: 13px; color: var(--text-muted); }
  .hq-sitecard__phase .icon { flex: none; width: 15px; height: 15px; color: var(--text-subtle); }
  .hq-sitecard__dates { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin: 0; }
  .hq-sitecard__dates dt, .hq-sitecard__stats dt, .hq-sitecard__ledger dt { font-size: 11.5px; font-weight: 600; color: var(--text-subtle); }
  .hq-sitecard__dates dd { margin: 2px 0 0; font-size: 13.5px; font-weight: 650; font-variant-numeric: tabular-nums; }
  .hq-sitecard__stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(80px, 1fr));
    gap: 8px;
    margin: 0;
    padding: 12px 14px;
    border-radius: 14px;
    background: var(--glass-0);
    box-shadow: inset 0 0 0 1px var(--line-soft);
  }
  .hq-sitecard__stats dd { margin: 2px 0 0; font-family: var(--font-display); font-size: 19px; font-weight: 600; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; white-space: nowrap; }
  .hq-sitecard__stats--pairs { grid-template-columns: repeat(2, minmax(0, 1fr)); row-gap: 12px; }
  .hq-sitecard__code {
    display: inline-block;
    margin-right: 8px;
    padding: 1px 7px;
    border-radius: 6px;
    font-family: var(--font-sans);
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.02em;
    vertical-align: 3px;
    color: var(--blue-300);
    background: rgb(var(--blue-rgb) / 0.12);
  }
  .hq-sitecard__meta { margin-top: 4px; font-size: 13px; color: var(--text-muted); overflow-wrap: anywhere; }
  .hq-sitecard__flag { display: flex; align-items: flex-start; gap: 8px; font-size: 12.5px; color: var(--warn); }
  .hq-sitecard__flag .icon { flex: none; width: 16px; height: 16px; }
  .hq-chip__source { font-size: 10.5px; font-weight: 700; letter-spacing: 0.04em; color: var(--text-subtle); }
  .hq-conflicts { display: grid; gap: 8px; margin: 0 0 12px; padding: 0; list-style: none; }
  .hq-conflict { display: grid; gap: 8px; padding: 10px 12px; border-radius: 12px; font-size: 13px; background: rgb(var(--warn-rgb) / 0.08); box-shadow: inset 0 0 0 1px rgb(var(--warn-rgb) / 0.25); }
  .hq-conflict__actions { display: flex; flex-wrap: wrap; gap: 6px; }
  .hq-conflict__actions form { display: contents; }
  .hq-kb-related { display: grid; gap: 6px; margin-top: 12px; font-size: 13px; }
  .hq-kb-related p { margin: 0; }
  .hq-sitecard__stats dd small { font-family: var(--font-sans); font-size: 12px; font-weight: 600; color: var(--text-subtle); letter-spacing: 0; }
  .hq-sitecard__money { display: grid; gap: 10px; padding-top: 14px; border-top: 1px solid var(--line-soft); }
  .hq-sitecard__ledger { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin: 0; }
  .hq-sitecard__ledger dd { margin: 2px 0 0; font-size: 14.5px; font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .hq-sitecard__subhead {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 4px;
    font-size: 12px;
    font-weight: 650;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--text-subtle);
  }
  .hq-sitecard__subhead .hq-card__link { font-size: 12.5px; letter-spacing: 0; text-transform: none; }
  .hq-sitecard__empty { font-size: 13px; color: var(--text-subtle); }
  .hq-sitecard__note {
    padding-left: 12px;
    border-left: 2px solid var(--line-strong);
    font-size: 13px;
    line-height: 1.5;
    color: var(--text-muted);
  }
  .hq-sitecard__foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-top: 4px; }
  .hq-sitecard__idle { font-size: 12.5px; color: var(--text-subtle); }
  .hq-sitecard__foot .hq-button .icon { width: 16px; height: 16px; }

  /* Invoices: the latest three on a card, the full history on the site */
  .hq-invoices { display: grid; gap: 6px; margin: 0; padding: 0; list-style: none; }
  .hq-invoice {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto auto;
    align-items: center;
    gap: 10px;
    padding: 9px 10px 9px 12px;
    border-radius: 12px;
    background: rgb(var(--fg-rgb) / 0.03);
    box-shadow: inset 0 0 0 1px var(--line-soft);
  }
  .hq-invoice__main { display: grid; min-width: 0; color: inherit; text-decoration: none; }
  a.hq-invoice__main:hover .hq-invoice__number { color: var(--blue-300); }
  .hq-invoice__number { font-size: 13.5px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .hq-invoice__meta { font-size: 12px; color: var(--text-subtle); font-variant-numeric: tabular-nums; }
  .hq-invoice__amount { font-family: var(--font-display); font-size: 14.5px; font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
  .hq-invoices--full .hq-invoice { grid-template-columns: minmax(0, 1fr) auto auto 18px; cursor: pointer; list-style: none; }
  .hq-invoices--full .hq-invoice::-webkit-details-marker { display: none; }
  .hq-invoice__chevron { width: 18px; height: 18px; color: var(--text-subtle); transition: transform var(--dur-fast) var(--ease-out); }
  :is(.hq-invoice-detail, .hq-report-detail)[open] .hq-invoice__chevron { transform: rotate(180deg); }
  .hq-invoice-detail[open] .hq-invoice { box-shadow: inset 0 0 0 1px rgb(var(--blue-rgb) / 0.35); }
  .hq-invoice-detail__list { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px 16px; margin: 8px 0 6px; padding: 12px 14px; border-radius: 12px; background: rgb(var(--navy-rgb) / 0.32); }
  .hq-invoice-detail__list dt { font-size: 11.5px; font-weight: 600; color: var(--text-subtle); }
  .hq-invoice-detail__list dd { margin: 2px 0 0; font-size: 13.5px; font-weight: 600; font-variant-numeric: tabular-nums; }
  .hq-invoice-detail__wide { grid-column: 1 / -1; }
  .hq-invoice-item:target .hq-invoice { box-shadow: inset 0 0 0 1px var(--blue-400); }
  @media (max-width: 479px) {
    .hq-invoice { grid-template-columns: minmax(0, 1fr) auto; }
    .hq-invoice .hq-pay { grid-column: 1; justify-self: start; }
    .hq-invoices--full .hq-invoice { grid-template-columns: minmax(0, 1fr) auto 18px; }
    .hq-invoices--full .hq-invoice .hq-pay { grid-row: 2; }
    .hq-sitecard__ledger, .hq-sitecard__dates { grid-template-columns: 1fr 1fr; }
  }

  /* Site page */
  .hq-back {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    margin-bottom: 8px;
    font-size: 13px;
    font-weight: 650;
    color: var(--text-muted);
    text-decoration: none;
  }
  .hq-back:hover { color: var(--text); }
  .hq-back__icon { width: 16px; height: 16px; transform: rotate(180deg); }
  .hq-site-header__title { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; }
  .hq-header__controls form { display: contents; }
  .hq-site-facts { grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); }
  .hq-site-facts dd small { font-weight: 600; }
  .hq-site-stats { margin-bottom: 4px; }
  .hq-site-note { margin-top: 14px; }
  .hq-site-note p { font-size: 14px; line-height: 1.55; color: var(--text-muted); }
  .hq-site-indicators { margin-top: 18px; }
  .hq-site-indicators .hq-tile__note { font-size: 12px; line-height: 1.45; color: var(--text-subtle); }
  .hq-site-ledger { grid-template-columns: repeat(4, minmax(0, 1fr)); margin-bottom: 16px; }
  @media (max-width: 639px) { .hq-site-ledger { grid-template-columns: 1fr 1fr; } }

  /* Linked projects and teams */
  .hq-site-links .hq-subhead:first-of-type { margin-top: 4px; }
  .hq-chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 10px; padding: 0; list-style: none; }
  .hq-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    min-height: 30px;
    padding: 0 6px 0 12px;
    border-radius: 999px;
    font-size: 13px;
    font-weight: 650;
    background: rgb(var(--blue-rgb) / 0.12);
    box-shadow: inset 0 0 0 1px rgb(var(--blue-rgb) / 0.25);
  }
  .hq-chip--team { background: rgb(var(--fg-rgb) / 0.05); box-shadow: inset 0 0 0 1px var(--line); }
  .hq-chip form { display: contents; }
  .hq-chip__remove {
    display: inline-grid;
    place-items: center;
    width: 22px;
    height: 22px;
    border: 0;
    border-radius: 50%;
    font-size: 15px;
    line-height: 1;
    color: var(--text-subtle);
    background: transparent;
    cursor: pointer;
  }
  .hq-chip__remove:hover { color: var(--error-text); background: rgb(var(--red-rgb) / 0.14); }
  .hq-chips__empty { font-size: 13px; color: var(--text-subtle); }
  .hq-inline-form { display: flex; gap: 8px; margin-bottom: 6px; }
  .hq-inline-form select { flex: 1; min-width: 0; min-height: 36px; font-size: 14px; }

  /* Forms */
  .hq-form-card { max-width: 860px; }
  .hq-form { display: grid; gap: 18px; }
  .hq-form__grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px 18px; }
  @media (max-width: 639px) { .hq-form__grid { grid-template-columns: 1fr; } }
  .hq-field { display: grid; gap: 6px; align-content: start; }
  .hq-field--wide { grid-column: 1 / -1; }
  .hq-field > label, .hq-field > span { font-size: 13px; font-weight: 650; color: var(--text-muted); }
  .hq-field__optional { font-weight: 500; color: var(--text-subtle); }
  :is(.hq-form, .hq-describe) :is(input[type="text"], input[type="date"], input[type="number"], select, textarea) {
    width: 100%;
    min-height: 44px;
    padding: 10px 12px;
    border: 1px solid var(--line-strong);
    border-radius: 12px;
    font: inherit;
    font-size: 16px;
    color: var(--text);
    background: rgb(var(--navy-rgb) / 0.55);
    color-scheme: dark;
  }
  :is(.hq-form, .hq-describe) textarea { line-height: 1.5; resize: vertical; }
  @media (min-width: 640px) {
    :is(.hq-form, .hq-describe) :is(input, select, textarea) { font-size: 14.5px; }
  }
  :is(.hq-form, .hq-describe) :is(input, select, textarea):focus-visible {
    outline: none;
    border-color: var(--blue-400);
    box-shadow: 0 0 0 3px rgb(var(--blue-rgb) / 0.22);
  }
  .hq-field.has-error :is(input, select, textarea) { border-color: rgb(var(--red-rgb) / 0.6); }
  .hq-field__help { font-size: 12px; color: var(--text-subtle); }
  .hq-field__error { font-size: 12.5px; font-weight: 600; color: var(--error-text); }
  .hq-form__actions { display: flex; flex-wrap: wrap; gap: 10px; }
  .hq-check { display: flex; align-items: center; gap: 10px; font-size: 13.5px; color: var(--text-muted); }
  .hq-check input { width: 18px; height: 18px; accent-color: var(--blue-500); }

  /* TESLA on a site */
  .hq-site-tesla { display: grid; gap: 16px; }
  .hq-site-tesla__head { align-items: center; gap: 14px; margin-bottom: 0; }
  .hq-site-tesla__lead { margin-top: 2px; font-size: 13px; color: var(--text-subtle); }
  .hq-site-tesla__tabs { justify-self: start; }
  .hq-site-tesla__panel { display: grid; gap: 14px; }
  .hq-site-tesla__panel[hidden] { display: none; }
  .hq-steps { display: flex; flex-wrap: wrap; gap: 6px 18px; margin: 0; padding: 0; list-style: none; }
  .hq-steps__item { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 650; color: var(--text-subtle); }
  .hq-steps__item span {
    display: inline-grid;
    place-items: center;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    font-size: 11.5px;
    box-shadow: inset 0 0 0 1px var(--line-strong);
  }
  .hq-steps__item.is-current { color: var(--text); }
  .hq-steps__item.is-current span { color: var(--navy-900); background: var(--tesla); box-shadow: none; }
  .hq-describe { display: grid; gap: 10px; }
  .hq-describe__row { display: flex; gap: 12px; }
  .hq-describe__date { width: min(100%, 200px); }
  .hq-describe__box { position: relative; }
  .hq-describe__box textarea { min-height: 120px; padding-bottom: 52px; }
  .hq-mic {
    position: absolute;
    right: 10px;
    bottom: 10px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 34px;
    padding: 0 12px;
    border: 0;
    border-radius: 999px;
    font: inherit;
    font-size: 12.5px;
    font-weight: 700;
    color: var(--text-muted);
    background: rgb(var(--fg-rgb) / 0.06);
    box-shadow: inset 0 0 0 1px var(--line);
    cursor: pointer;
  }
  .hq-mic[hidden] { display: none; }
  .hq-mic .icon { width: 16px; height: 16px; }
  .hq-mic.is-listening { color: var(--navy-900); background: var(--tesla); box-shadow: 0 0 0 4px var(--tesla-soft); }
  .hq-describe__status { min-height: 1.2em; font-size: 13px; color: var(--text-muted); }
  .hq-describe__status.is-busy { color: var(--tesla); }
  .hq-describe__actions { display: flex; flex-wrap: wrap; gap: 8px; }
  .no-js .hq-describe { display: none; }
  .js .hq-report-form[data-collapsed] { display: none; }
  .hq-report-form { scroll-margin-top: 96px; padding: 18px; border-radius: 18px; background: rgb(var(--navy-rgb) / 0.32); box-shadow: inset 0 0 0 1px var(--line-soft); }
  .hq-report-form__site { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; }
  .hq-report-form__label { font-size: 12px; font-weight: 650; letter-spacing: 0.05em; text-transform: uppercase; color: var(--text-subtle); }
  .hq-report-form__notice {
    padding: 10px 12px;
    border-radius: 12px;
    font-size: 13.5px;
    line-height: 1.5;
    color: var(--text);
    background: var(--tesla-soft);
    box-shadow: inset 0 0 0 1px rgb(var(--orange-rgb) / 0.3);
  }
  .hq-report-form__notice[hidden] { display: none; }

  /* Daily reports */
  .hq-reports { display: grid; gap: 8px; margin: 0; padding: 0; list-style: none; }
  .hq-report-item.is-superseded { opacity: 0.7; }
  .hq-report-item:target .hq-report-item__head { box-shadow: inset 0 0 0 1px var(--blue-400); }
  .hq-report-item__head {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto 18px;
    align-items: center;
    gap: 12px;
    padding: 11px 12px;
    border-radius: 12px;
    background: rgb(var(--fg-rgb) / 0.03);
    box-shadow: inset 0 0 0 1px var(--line-soft);
    cursor: pointer;
    list-style: none;
  }
  .hq-report-item__head::-webkit-details-marker { display: none; }
  .hq-report-item__date { font-size: 13px; font-weight: 700; white-space: nowrap; }
  .hq-report-item__work { overflow: hidden; font-size: 13px; color: var(--text-muted); text-overflow: ellipsis; white-space: nowrap; }
  .hq-report-item__tags { display: inline-flex; gap: 6px; }
  .hq-tesla-tag { padding: 2px 7px; border-radius: 6px; font-size: 10.5px; font-weight: 800; letter-spacing: 0.06em; color: var(--tesla); background: var(--tesla-soft); }
  .hq-report-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 18px; margin: 10px 0 8px; padding: 14px; border-radius: 12px; background: rgb(var(--navy-rgb) / 0.32); }
  .hq-report-fields dt { font-size: 11.5px; font-weight: 650; color: var(--text-subtle); }
  .hq-report-fields dd { margin: 3px 0 0; font-size: 13.5px; line-height: 1.5; }
  .hq-report-fields__wide { grid-column: 1 / -1; }
  .hq-report-fields__source { color: var(--text-muted); font-style: italic; }
  .hq-report-item__by { margin-bottom: 6px; font-size: 12px; color: var(--text-subtle); }
  @media (max-width: 639px) {
    .hq-report-item__head { grid-template-columns: minmax(0, 1fr) auto 18px; }
    .hq-report-item__work { grid-column: 1 / -1; grid-row: 2; white-space: normal; }
    .hq-report-fields { grid-template-columns: 1fr; }
  }

  /* History of changes */
  .hq-history { display: grid; margin: 0; padding: 0; list-style: none; }
  .hq-history__item { padding: 10px 0; border-top: 1px solid var(--line-soft); }
  .hq-history__item:first-child { border-top: 0; padding-top: 0; }
  .hq-history__what { font-size: 13.5px; line-height: 1.45; overflow-wrap: anywhere; }
  .hq-history__old { color: var(--text-subtle); text-decoration: line-through; }
  .hq-history__when { margin-top: 2px; font-size: 12px; color: var(--text-subtle); }

  /* Employees (ZAPOSLENI) */
  .hq-emp-kpis .hq-pulse__item { text-decoration: none; color: inherit; }
  .hq-emp-month select, .hq-emp-filter select { min-height: 38px; max-width: 100%; font-size: 14px; }
  .hq-emp-filter__field { display: flex; flex: 0 1 180px; min-width: 0; }
  .hq-emp-filter__field select { width: 100%; }
  .hq-emp-name { display: block; color: inherit; text-decoration: none; }
  .hq-emp-name:hover .hq-table__name { color: var(--blue-300); }
  .hq-emp-table td a { color: var(--blue-300); }
  .hq-pill--emp-active { color: var(--ok-text); background: rgb(var(--green-rgb) / 0.14); }
  .hq-pill--emp-inactive { color: var(--text-muted); background: rgb(var(--fg-rgb) / 0.05); }
  .hq-pill--emp-unrecorded { color: var(--text-muted); background: rgb(var(--fg-rgb) / 0.05); box-shadow: inset 0 0 0 1px var(--line); }
  .hq-pill--emp-not_listed { color: var(--text-muted); background: transparent; box-shadow: inset 0 0 0 1px var(--line); }
  .hq-emp-filter__field:has(select[name="status"]) { flex-basis: 260px; }
  .hq-emp-cost__parts { display: grid; gap: 1px; font-size: 11.5px; }
  .hq-emp-cost__parts > span { white-space: nowrap; }
  .hq-emp-register-note { display: grid; grid-template-columns: 18px minmax(0, 1fr); gap: 10px; align-items: start; margin: 0 0 var(--gap); padding: 12px 14px; border-radius: 14px; font-size: 13.5px; line-height: 1.5; background: rgb(var(--warn-rgb) / 0.07); box-shadow: inset 0 0 0 1px rgb(var(--warn-rgb) / 0.22); }
  .hq-emp-review { margin-top: var(--gap); }
  .hq-emp-review__list, .hq-emp-flags { display: grid; gap: 8px; margin: 0; padding: 0; list-style: none; }
  .hq-emp-review__list li, .hq-emp-flags li { display: grid; grid-template-columns: 18px minmax(0, 1fr); gap: 10px; align-items: start; font-size: 13.5px; line-height: 1.5; }
  .hq-emp-review__list .icon, .hq-emp-flags .icon { width: 18px; height: 18px; margin-top: 1px; color: var(--warn); }
  .hq-emp-review__list a { color: var(--blue-300); font-weight: 650; }
  .hq-emp-flags { margin-bottom: var(--gap); padding: 12px 14px; border-radius: 14px; background: rgb(var(--warn-rgb) / 0.07); box-shadow: inset 0 0 0 1px rgb(var(--warn-rgb) / 0.22); }
  .hq-emp-flags--inline { margin: 12px 0; }
  .hq-emp-sync { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; margin-top: 14px; font-size: 12.5px; color: var(--text-subtle); }
  .hq-emp-facts .hq-emp-facts__wide, .hq-emp-assign .hq-emp-facts__wide { grid-column: 1 / -1; }
  .hq-emp-facts dd, .hq-emp-assign dd { overflow-wrap: anywhere; }
  .hq-emp-facts a, .hq-emp-assign a, .hq-emp-team a { color: var(--blue-300); }
  .hq-emp-assign .hq-chip { margin: 2px 4px 2px 0; text-decoration: none; }
  .hq-emp-edit { margin-top: 4px; }
  .hq-emp-edit > summary { list-style: none; cursor: pointer; }
  .hq-emp-edit > summary::-webkit-details-marker { display: none; }
  .hq-emp-edit__form { display: grid; gap: 12px; max-width: 520px; margin-top: 12px; }
  .hq-emp-edit__form label { display: grid; gap: 4px; font-size: 13px; font-weight: 600; color: var(--text-muted); }
  .hq-emp-edit__form input, .hq-emp-edit__form textarea { width: 100%; font-size: 16px; }
  .hq-emp-edit__form button { justify-self: start; }
  .hq-emp-conflict { margin-bottom: 12px; }
  .hq-emp-move { margin-top: 4px; }
  .hq-emp-stats { margin-bottom: 10px; }

  .hq-cal { display: grid; gap: 6px; margin-top: 14px; }
  .hq-cal__head, .hq-cal__week { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; }
  .hq-cal__head span { font-size: 11.5px; font-weight: 650; letter-spacing: 0.04em; text-align: center; text-transform: uppercase; color: var(--text-subtle); }
  .hq-cal__day {
    position: relative;
    display: grid;
    align-content: space-between;
    min-height: 62px;
    padding: 7px 8px;
    border-radius: 10px;
    background: var(--glass-0);
    box-shadow: inset 0 0 0 1px var(--line-soft);
  }
  .hq-cal__num { font-size: 12px; font-weight: 650; color: var(--text-subtle); }
  .hq-cal__value { font-family: var(--font-display); font-size: 15px; font-weight: 600; font-variant-numeric: tabular-nums; }
  .hq-cal__day--worked { background: rgb(var(--blue-rgb) / 0.16); box-shadow: inset 0 0 0 1px rgb(var(--blue-rgb) / 0.35); }
  .hq-cal__day--worked .hq-cal__num { color: var(--blue-300); }
  .hq-cal__day--not_working .hq-cal__value { color: var(--text-subtle); }
  .hq-cal__day--no_record { background: transparent; box-shadow: inset 0 0 0 1px var(--line-soft); border: 1px dashed var(--line); }
  .hq-cal__day--no_record .hq-cal__value { color: var(--text-subtle); font-weight: 500; }
  .hq-cal__day--other { box-shadow: inset 0 0 0 1px rgb(var(--warn-rgb) / 0.45); }
  .hq-cal__day--other .hq-cal__value { color: var(--warn); font-size: 13px; }
  .hq-cal__day--weekend .hq-cal__num { opacity: 0.75; }
  .hq-cal__day--pad { background: none; box-shadow: none; }
  .hq-cal__both, .hq-cal__sheet, .hq-cal__tag {
    position: absolute;
    top: 6px;
    right: 6px;
    padding: 1px 5px;
    border-radius: 5px;
    font-size: 9.5px;
    font-weight: 800;
    letter-spacing: 0.04em;
    color: var(--text-muted);
    background: rgb(var(--fg-rgb) / 0.07);
  }
  .hq-cal__both { color: var(--warn); background: rgb(var(--warn-rgb) / 0.14); }
  .hq-cal__legend { display: flex; flex-wrap: wrap; gap: 8px 18px; margin: 12px 0 0; padding: 0; list-style: none; font-size: 12.5px; color: var(--text-muted); }
  .hq-cal__legend li { display: inline-flex; align-items: center; gap: 7px; }
  .hq-cal__swatch { width: 14px; height: 14px; border-radius: 4px; background: var(--glass-0); box-shadow: inset 0 0 0 1px var(--line-soft); }
  .hq-cal__swatch--worked { background: rgb(var(--blue-rgb) / 0.3); box-shadow: inset 0 0 0 1px rgb(var(--blue-rgb) / 0.5); }
  .hq-cal__swatch--no_record { background: transparent; border: 1px dashed var(--line); box-shadow: none; }
  .hq-cal__legend .hq-cal__tag { position: static; }
  @media (max-width: 639px) {
    .hq-cal, .hq-cal__head, .hq-cal__week { gap: 3px; }
    .hq-cal__day { min-height: 46px; padding: 4px 5px; border-radius: 7px; }
    .hq-cal__value { font-size: 11.5px; }
    .hq-cal__num { font-size: 10.5px; }
    .hq-cal__both, .hq-cal__sheet { top: 3px; right: 3px; padding: 0 3px; font-size: 8px; }
    .hq-emp-filter__field { flex: 1 1 140px; }
    .hq-emp-table tbody td, .hq-emp-table tbody td.is-num { display: block; }
    .hq-emp-table tbody td::before { display: block; }
  }

  .hq-emp-teams { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: var(--gap); }
  .hq-emp-team { display: grid; align-content: start; gap: 4px; }
  .hq-emp-team__facts { grid-template-columns: 1fr 1fr; }
  .hq-emp-members { display: grid; margin: 0 0 12px; padding: 0; list-style: none; }
  .hq-emp-members li { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 9px 0; border-top: 1px solid var(--line-soft); }
  .hq-emp-members li:first-child { border-top: 0; }
  .hq-emp-members a { display: grid; min-width: 0; color: inherit; text-decoration: none; }
  .hq-emp-members a:hover .hq-emp-members__name { color: var(--blue-300); }
  .hq-emp-members__name { font-weight: 700; }
  .hq-emp-members__meta { font-size: 12.5px; color: var(--text-subtle); }
  @media (max-width: 639px) { .hq-emp-teams { grid-template-columns: 1fr; } }

  .hq-site-members { margin: -2px 0 10px; font-size: 13px; color: var(--text-muted); }
  .hq-site-members a { color: var(--blue-300); }
}

/* ------------------------------------------------------------------ */
/* Market intelligence (modules/radar): tabs reuse .hq-fin-tabs       */
/* ------------------------------------------------------------------ */

@layer components {
  /* Four counts: two by two, one row from desktop width; never 3 + 1. */
  .kpis.hq-mi-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  @media (min-width: 1100px) { .kpis.hq-mi-kpis { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
}

/* ------------------------------------------------------------------ */
/* Finance (modules/finance)                                           */
/* ------------------------------------------------------------------ */

@layer components {
  .hq-fin-tabs { margin-bottom: var(--gap); overflow-x: auto; scrollbar-width: none; }
  .hq-fin-tabs .hq-segmented { flex-wrap: nowrap; }
  .hq-fin-tabs .hq-segmented__item { white-space: nowrap; text-decoration: none; }
  .hq-fin-tabs .hq-segmented__item[aria-current="page"] {
    color: var(--text);
    background: rgb(var(--fg-rgb) / 0.09);
    box-shadow: inset 0 0 0 1px var(--line-strong);
  }
  .hq-fin-back { margin: 0 0 4px; }

  /* KPI strips inside a card: no glass of their own */
  .hq-fin-kpis { background: none; box-shadow: none; margin: 0 -24px; }
  .hq-fin-kpis::after, .hq-fin-kpis::before { display: none; }
  .hq-fin-kpis a.hq-pulse__item { color: inherit; text-decoration: none; }
  .hq-fin-kpis a.hq-pulse__item:hover { background: var(--glass-0); }
  .hq-fin-kpis--six { grid-template-columns: repeat(6, minmax(0, 1fr)); }
  @media (max-width: 1199px) { .hq-fin-kpis--six { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
  @media (max-width: 899px) { .hq-fin-kpis--six { grid-template-columns: 1fr 1fr; } }
  @media (max-width: 639px) { .hq-fin-kpis { margin: 0 -16px; } }
  .hq-fin-lead { margin-top: -6px; margin-bottom: 14px; }

  .hq-fin-notes { display: grid; gap: 6px; margin: 16px 0 0; padding: 0; list-style: none; }
  .hq-fin-notes li { display: grid; grid-template-columns: 16px minmax(0, 1fr); gap: 8px; font-size: 13px; line-height: 1.5; color: var(--text-muted); }
  .hq-fin-notes .icon { width: 16px; height: 16px; margin-top: 2px; color: var(--blue-300); }

  /* Charts: grouped bars */
  .hq-fin-chart__legend { display: flex; flex-wrap: wrap; gap: 6px 18px; margin: 0 0 10px; }
  .hq-fin-bar--invoiced, .hq-fin-swatch--invoiced { fill: var(--blue-500); background: var(--blue-500); }
  .hq-fin-bar--collected, .hq-fin-swatch--collected { fill: var(--blue-300); background: var(--blue-300); }
  .hq-fin-bar--costs, .hq-fin-swatch--costs { fill: var(--pearl); background: var(--pearl); }
  .hq-fin-bar--revenue, .hq-fin-swatch--revenue { fill: var(--blue-600); background: var(--blue-600); }
  .hq-fin-bar { opacity: 0.92; }
  .hq-fin-bar:hover { opacity: 1; }

  /* Aging */
  .hq-fin-age--not_due { background: var(--age-0); }
  .hq-fin-age--1_30 { background: var(--age-1); }
  .hq-fin-age--31_60 { background: var(--age-2); }
  .hq-fin-age--61_90 { background: var(--age-3); }
  .hq-fin-age--over_90 { background: var(--age-4); box-shadow: var(--age-glow); }
  .hq-fin-age--no_due_date { background: var(--text-subtle); }
  .hq-fin-aging .hq-meter__bar { box-shadow: none; }
  .hq-fin-aging .hq-meter__label { display: inline-flex; align-items: center; gap: 8px; }
  .hq-fin-link { color: inherit; text-decoration: none; }
  .hq-fin-link:hover { color: var(--blue-300); }

  /* Payment and due status side by side */
  .hq-fin-status { display: inline-flex; flex-direction: column; align-items: flex-start; gap: 4px; }
  .hq-pay--not_due { color: var(--blue-300); background: rgb(var(--blue-rgb) / 0.10); }
  .hq-pay--no_due_date { color: var(--text-muted); background: rgb(var(--fg-rgb) / 0.05); box-shadow: inset 0 0 0 1px var(--line-strong); }
  /* An overdue pill takes its invoice's age: lighter red first, deeper later. */
  .hq-pay--overdue.hq-pay--age-1_30 { color: var(--age-1); background: rgb(253 164 175 / 0.12); box-shadow: inset 0 0 0 1px rgb(253 164 175 / 0.3); }
  .hq-pay--overdue.hq-pay--age-31_60 { color: #fb7185; background: rgb(244 63 94 / 0.16); box-shadow: inset 0 0 0 1px rgb(244 63 94 / 0.4); }
  .hq-pay--overdue.hq-pay--age-61_90 { color: #fca5a5; background: rgb(220 38 38 / 0.28); box-shadow: inset 0 0 0 1px rgb(220 38 38 / 0.55); }
  .hq-pay--overdue.hq-pay--age-over_90 { color: #fff; background: var(--age-4); box-shadow: inset 0 0 0 1px rgb(255 255 255 / 0.12), var(--age-glow); }

  /* Invoice table: the invoice opens to its details */
  .hq-fin-table td a { color: var(--blue-300); }
  .hq-table-wrap:has(> .hq-fin-table) { overflow-x: auto; }
  @media (min-width: 640px) {
    .hq-fin-table { font-size: 13.5px; }
    .hq-fin-table th, .hq-fin-table td { padding: 11px 6px; }
    .hq-fin-table tbody th { width: 22%; }
  }
  .hq-fin-invoice summary { display: grid; cursor: pointer; list-style: none; }
  .hq-fin-invoice summary::-webkit-details-marker { display: none; }
  .hq-fin-invoice summary .hq-table__sub { color: var(--blue-300); }
  .hq-fin-invoice[open] summary .hq-table__sub { color: var(--text-subtle); }
  .hq-fin-invoice .hq-invoice-detail__list { grid-template-columns: minmax(0, 1fr); gap: 6px; margin-top: 10px; font-size: 12.5px; font-weight: 500; }
  .hq-fin-invoice .hq-invoice-detail__list dd { overflow-wrap: anywhere; }
  @media (max-width: 639px) {
    .hq-fin-table tbody tr { grid-template-columns: 1fr 1fr; }
  }
  .hq-fin-more > summary { cursor: pointer; margin-bottom: 10px; font-size: 13.5px; font-weight: 650; color: var(--blue-300); }

  /* What the register does not record */
  .hq-fin-gaps { display: grid; gap: 8px; margin: 0 0 12px; padding: 0; list-style: none; }
  .hq-fin-gaps summary { display: grid; grid-template-columns: 18px minmax(0, 1fr) auto; gap: 10px; align-items: start; cursor: pointer; font-size: 13.5px; line-height: 1.5; list-style: none; }
  .hq-fin-gaps summary::-webkit-details-marker { display: none; }
  .hq-fin-gaps summary .icon { width: 18px; height: 18px; margin-top: 1px; color: var(--warn); }
  .hq-fin-gaps__list { display: grid; gap: 4px; margin: 6px 0 4px 28px; padding: 0; list-style: none; font-size: 13px; }
  .hq-fin-gaps__list a { color: var(--blue-300); }

  /* Cost groups */
  .hq-fin-groups { display: grid; margin: 0 0 12px; padding: 0; list-style: none; }
  .hq-fin-groups > li { border-top: 1px solid var(--line-soft); }
  .hq-fin-groups > li:first-child { border-top: 0; }
  .hq-fin-groups summary { display: grid; grid-template-columns: minmax(0, 1fr) auto 18px; gap: 12px; align-items: center; padding: 12px 0; cursor: pointer; list-style: none; }
  .hq-fin-groups summary::-webkit-details-marker { display: none; }
  .hq-fin-groups details[open] .hq-invoice__chevron { transform: rotate(180deg); }
  .hq-fin-groups__label { font-weight: 700; }
  .hq-fin-groups__value { font-weight: 700; font-variant-numeric: tabular-nums; }
  .hq-fin-groups__lines { display: grid; gap: 6px; margin: 0 0 12px; padding: 0; list-style: none; font-size: 13px; }
  .hq-fin-groups__lines li { display: flex; justify-content: space-between; gap: 12px; }
  .hq-fin-groups__category { font-weight: 650; }
  .hq-fin-groups__line { padding-left: 14px; color: var(--text-muted); }
  .hq-fin-groups__lines span:last-child, .hq-fin-groups__lines strong { font-variant-numeric: tabular-nums; white-space: nowrap; }

  /* Result: revenue − costs = result */
  .hq-fin-result { display: grid; margin: 0 0 12px; }
  .hq-fin-result > div { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 4px 12px; padding: 10px 0; border-top: 1px solid var(--line-soft); }
  .hq-fin-result > div:first-child { border-top: 0; }
  .hq-fin-result dt { color: var(--text-muted); font-weight: 600; }
  .hq-fin-result dd { margin: 0; font-weight: 700; font-variant-numeric: tabular-nums; }
  .hq-fin-result .source-ref { margin-left: 6px; }
  .hq-fin-result__total { border-top: 1px solid var(--line-strong) !important; }
  .hq-fin-result__total dt, .hq-fin-result__total dd { color: var(--text); font-size: 16px; }
}

@layer components {
  /* Home UPDATE: beside the import date, in the header's meta row. */
  .hq-update { display: inline-flex; align-items: center; gap: 8px; margin: 0; }
  .hq-update__button {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 28px;
    padding: 0 12px 0 9px;
    border: 0;
    border-radius: 999px;
    background: var(--glass-0);
    box-shadow: inset 0 0 0 1px var(--line);
    color: var(--text);
    font: inherit;
    font-size: 12.5px;
    font-weight: 650;
    white-space: nowrap;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    transition: background-color var(--dur-fast) var(--ease-out), box-shadow var(--dur-fast) var(--ease-out);
  }
  /* A finger-sized target on touch screens without a larger pill. */
  .hq-update__button::after { content: ""; position: absolute; inset: -8px -4px; }
  .hq-update__button .icon { width: 15px; height: 15px; color: var(--blue-400); }
  .hq-update__button:hover { background: rgb(var(--fg-rgb) / 0.07); box-shadow: inset 0 0 0 1px var(--line-strong); }
  .hq-update__button:focus-visible { outline: 2px solid var(--blue-400); outline-offset: 2px; }
  .hq-update__button:disabled { cursor: progress; opacity: 0.7; }
  .hq-update[aria-busy="true"] .hq-update__button .icon { animation: hq-spin 0.8s linear infinite; }
  .hq-update__status { display: inline-flex; align-items: center; gap: 5px; font-size: 12.5px; color: var(--text-subtle); white-space: nowrap; }
  .hq-update__status .icon { width: 14px; height: 14px; color: var(--ok-text); }
  .hq-update__status--pending { color: var(--blue-400); font-weight: 650; text-decoration: none; }
  .hq-update__status--pending:hover { text-decoration: underline; }
  .hq-update__status--failed { color: var(--text-muted); }
}

/* ------------------------------------------------------------------ */
/* TESLA Control Center (modules/radar/tesla, ?tab=…)                  */
/* Navy glass with pearl text; TESLA's orange only around TESLA       */
/* himself, his marks and his real activity.                          */
/* ------------------------------------------------------------------ */

@layer components {
  /* Header and tabs */
  .hq-tc__head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 14px 24px; margin-bottom: 22px; }
  .hq-tc__title { display: flex; align-items: center; gap: 12px; font-family: var(--font-display); font-size: 21px; font-weight: 700; letter-spacing: 0.06em; }
  .hq-tc__title span:last-child { font-weight: 400; letter-spacing: -0.01em; color: var(--text-muted); }
  .hq-tc__mark { width: 9px; height: 9px; border-radius: 50%; background: var(--tesla); box-shadow: 0 0 0 4px var(--tesla-soft), 0 0 18px rgb(var(--orange-rgb) / 0.45); }
  .hq-tc-tabs { min-width: 0; max-width: 100%; }
  .hq-tc-tabs__list {
    display: flex;
    gap: 2px;
    padding: 4px;
    border-radius: 16px;
    background: rgb(var(--navy-rgb) / 0.5);
    box-shadow: inset 0 0 0 1px var(--line), inset 0 1px 0 rgba(255, 255, 255, 0.04);
    overflow-x: auto;
    scrollbar-width: none;
    scroll-snap-type: x proximity;
    overscroll-behavior-x: contain;
  }
  .hq-tc-tabs__list::-webkit-scrollbar { display: none; }
  .hq-tc-tabs__item {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 40px;
    padding: 0 15px;
    border-radius: 12px;
    font-size: 13.5px;
    font-weight: 650;
    color: var(--text-muted);
    text-decoration: none;
    white-space: nowrap;
    scroll-snap-align: start;
    transition: color var(--dur-fast) var(--ease-out), background-color var(--dur-fast) var(--ease-out), box-shadow var(--dur-fast) var(--ease-out);
  }
  .hq-tc-tabs__item .icon { width: 16px; height: 16px; color: var(--text-subtle); transition: color var(--dur-fast) var(--ease-out); }
  .hq-tc-tabs__item:hover { color: var(--text); background: rgb(var(--fg-rgb) / 0.04); }
  .hq-tc-tabs__item:focus-visible { outline: none; box-shadow: var(--focus-ring); }
  .hq-tc-tabs__item[aria-current="page"] {
    color: var(--text);
    background: rgb(var(--fg-rgb) / 0.085);
    box-shadow: inset 0 0 0 1px var(--line-strong), 0 6px 18px -10px rgba(0, 0, 0, 0.6);
  }
  .hq-tc-tabs__item[aria-current="page"] .icon { color: var(--tesla); }
  @media (max-width: 899px) {
    .hq-tc__head { margin-bottom: 18px; }
    .hq-tc-tabs { width: calc(100% + 2 * var(--gutter)); max-width: none; margin-inline: calc(-1 * var(--gutter)); }
    .hq-tc-tabs__list {
      padding-inline: var(--gutter);
      border-radius: 0;
      background: none;
      box-shadow: none;
      scroll-padding-inline: var(--gutter);
      -webkit-mask: linear-gradient(90deg, transparent, #000 var(--gutter), #000 calc(100% - var(--gutter)), transparent);
      mask: linear-gradient(90deg, transparent, #000 var(--gutter), #000 calc(100% - var(--gutter)), transparent);
    }
    .hq-tc-tabs__item { min-height: 44px; background: var(--glass-0); box-shadow: inset 0 0 0 1px var(--line-soft); }
  }

  .hq-tc__body { display: grid; gap: var(--gap); }
  .hq-tc__body > * { min-width: 0; }

  /* Hero: TESLA on the left, quick actions on the right */
  /* Stage and actions share the row 7 : 5. The stage never gets narrower
     than TESLA's frame plus room for the greeting: when the row (which
     changes with the sidebar) is too narrow for that, the actions wrap
     under the stage instead of TESLA shrinking. */
  .hq-tc-hero { display: flex; flex-wrap: wrap; gap: var(--gap); }
  .hq-tc-hero > .hq-tc-stage { flex: 7 1 0; min-width: min(100%, calc(var(--tc-figure-w) + 320px)); }
  .hq-tc-hero > .hq-tc-actions { flex: 5 1 0; min-width: min(100%, 380px); }

  /* TESLA's figure has its own fixed frame: its size follows the viewport
     only, never the card, so expanding or collapsing the sidebar changes
     the space beside him and not TESLA himself. The frame keeps the
     artwork's ratio (420 x 462). */
  .hq-tc-stage {
    --tc-figure-h: clamp(300px, 22vw, 360px);
    --tc-figure-w: calc(var(--tc-figure-h) * 420 / 462);
    position: relative;
    isolation: isolate;
    display: grid;
    grid-template-columns: var(--tc-figure-w) minmax(0, 1fr);
    column-gap: 8px;
    align-items: center;
    min-height: 420px;
    padding-right: 40px;
    border-radius: var(--radius-card);
    overflow: hidden;
    background:
      radial-gradient(90% 80% at 100% 0%, rgb(var(--blue-rgb) / 0.20), transparent 60%),
      var(--sheen),
      var(--glass-2);
    box-shadow: var(--shadow-2), inset 0 1px 0 rgba(255, 255, 255, 0.09), inset 0 0 0 1px rgb(var(--fg-rgb) / 0.06);
  }
  .hq-tc-stage::after {
    content: "";
    position: absolute;
    inset: 0;
    z-index: 3;
    border-radius: inherit;
    padding: 1px;
    background: linear-gradient(160deg, rgb(var(--blue-hi-rgb) / 0.30), rgb(var(--fg-rgb) / 0.04) 40%, rgb(var(--orange-rgb) / 0.22));
    -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);
    pointer-events: none;
  }
  /* The warm light behind TESLA: soft, low and never the page's colour. */
  .hq-tc-stage__glow {
    position: absolute;
    z-index: -1;
    /* Centred on TESLA's frame and sized by it, so it moves with him. */
    left: calc(var(--tc-figure-w) / 2);
    bottom: -14%;
    width: calc(var(--tc-figure-w) * 1.65);
    aspect-ratio: 1;
    margin-left: calc(var(--tc-figure-w) * -0.825);
    border-radius: 50%;
    background: radial-gradient(closest-side, rgb(var(--orange-rgb) / 0.40), rgb(var(--orange-rgb) / 0.17) 46%, rgb(var(--orange-rgb) / 0.05) 70%, transparent);
    pointer-events: none;
  }
  .hq-tc-stage__figure {
    position: relative;
    align-self: end;
    justify-self: start;
    width: var(--tc-figure-w);
    height: var(--tc-figure-h);
    line-height: 0;
  }
  .hq-tc-stage__figure img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
    object-position: left bottom;
    filter: drop-shadow(0 22px 28px rgba(0, 0, 0, 0.5));
  }
  /* The light sweep is masked to TESLA's own outline: the masked layer
     stays still and only the light inside it moves. */
  .hq-tc-stage__figure::after {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(100deg, transparent 42%, rgb(var(--orange-hi-rgb) / 0.5) 50%, transparent 58%) 100% 0 / 300% 100% no-repeat;
    -webkit-mask: var(--figure) center / 100% 100% no-repeat;
    mask: var(--figure) center / 100% 100% no-repeat;
    opacity: 0;
    pointer-events: none;
  }
  .hq-tc-stage__text { position: relative; z-index: 1; padding: 40px 0; }
  .hq-tc-stage__eyebrow { font-size: 11.5px; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase; color: var(--text-subtle); }
  .hq-tc-stage__greeting {
    margin-top: 12px;
    font-family: var(--font-display);
    font-size: clamp(28px, 1.6vw + 18px, 42px);
    font-weight: 600;
    line-height: 1.08;
    letter-spacing: -0.035em;
    color: var(--text);
    text-wrap: balance;
  }
  /* Whom TESLA works for: a quiet line in pearl with TESLA's orange mark. */
  .hq-tc-stage__for {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    margin-top: 14px;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.16em;
    color: var(--pearl);
  }
  .hq-tc-stage__for::before { content: ""; flex: none; width: 18px; height: 2px; border-radius: 2px; background: var(--tesla); box-shadow: 0 0 10px rgb(var(--orange-rgb) / 0.5); }

  /* Private notice for everyone except TESLA's owner */
  .hq-tc-private {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    align-items: start;
    gap: 14px;
    max-width: 46ch;
    margin-top: 24px;
    padding: 16px 18px;
    border-radius: 16px;
    text-align: left;
    background: rgb(var(--navy-rgb) / 0.45);
    box-shadow: inset 0 0 0 1px var(--line), inset 0 1px 0 rgba(255, 255, 255, 0.05);
  }
  .hq-tc-private__lock {
    display: grid;
    place-items: center;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    color: var(--pearl);
    background: rgb(var(--fg-rgb) / 0.05);
    box-shadow: inset 0 0 0 1px var(--line-strong), 0 0 0 4px rgb(var(--orange-rgb) / 0.07);
  }
  .hq-tc-private__lock .icon { width: 16px; height: 16px; }
  .hq-tc-private__title { font-size: 11.5px; font-weight: 700; letter-spacing: 0.14em; color: var(--text); }
  .hq-tc-private__text { margin-top: 5px; font-size: 13.5px; line-height: 1.55; color: var(--text-muted); }
  .hq-tc-private__text + .hq-tc-private__text { margin-top: 8px; }

  /* Locked placeholders: empty shapes behind frosted glass, never content. */
  .hq-tc-locked {
    position: relative;
    overflow: hidden;
    padding: 24px;
    border-radius: var(--radius-card);
    background: var(--sheen), var(--glass-1);
    box-shadow: var(--shadow-1), inset 0 0 0 1px var(--line-soft), inset 0 1px 0 rgba(255, 255, 255, 0.05);
    pointer-events: none;
    user-select: none;
  }
  .hq-tc-locked__ghost { display: grid; gap: 12px; filter: blur(5px); opacity: 0.6; }
  .hq-tc-locked--action { display: grid; align-items: center; min-height: 96px; }
  .hq-tc-locked--action .hq-tc-locked__ghost { grid-template-columns: auto minmax(0, 1fr); align-items: center; gap: 18px; }
  .hq-tc-locked__tile { width: 52px; height: 52px; border-radius: 16px; background: rgb(var(--blue-rgb) / 0.22); }
  .hq-tc-locked__lines { display: grid; gap: 9px; }
  .hq-tc-locked__bar { display: block; height: 9px; width: 82%; border-radius: 6px; background: rgba(255, 255, 255, 0.16); }
  .hq-tc-locked__bar--title { height: 13px; width: 52%; background: rgba(255, 255, 255, 0.24); }
  .hq-tc-locked__bar--short { width: 38%; }
  .hq-tc-locked__bar--figure { height: 22px; width: 46%; background: rgba(255, 255, 255, 0.22); }
  .hq-tc-locked__row { display: grid; grid-template-columns: 10px 1fr 22%; align-items: center; gap: 14px; padding-top: 6px; }
  .hq-tc-locked__row .hq-tc-locked__bar { width: 100%; }
  .hq-tc-locked__dot { width: 10px; height: 10px; border-radius: 50%; background: rgba(255, 255, 255, 0.2); }
  .hq-tc-locked__lock {
    position: absolute;
    top: 14px;
    right: 14px;
    display: grid;
    place-items: center;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    color: var(--text-subtle);
    background: rgb(var(--navy-rgb) / 0.55);
    box-shadow: inset 0 0 0 1px var(--line);
  }
  .hq-tc-locked__lock .icon { width: 13px; height: 13px; }
  .hq-tc-locked-row { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--gap); }
  .hq-tc-locked--wide { min-height: 190px; }
  .hq-tc-locked--wide .hq-tc-locked__ghost { gap: 16px; }
  @media (max-width: 899px) { .hq-tc-locked-row { grid-template-columns: 1fr 1fr; } }
  @media (max-width: 639px) {
    .hq-tc-locked { padding: 18px; }
    .hq-tc-locked--action { min-height: 84px; }
    .hq-tc-locked__tile { width: 44px; height: 44px; border-radius: 14px; }
    .hq-tc-private { margin-inline: auto; margin-top: 20px; }
    .hq-tc-stage__for { justify-content: center; }
  }

  .hq-tc-state {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-top: 20px;
    padding: 6px 12px 6px 10px;
    border-radius: 999px;
    font-size: 12.5px;
    font-weight: 650;
    color: var(--ok-text);
    background: rgb(var(--green-rgb) / 0.14);
  }
  .hq-tc-state__dot { position: relative; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
  .hq-tc-state--active { color: var(--tesla); background: var(--tesla-soft); }
  .hq-tc-state--error { color: var(--error-text); background: rgb(var(--red-rgb) / 0.14); }
  .hq-tc-state--off { color: var(--text-muted); background: rgb(var(--fg-rgb) / 0.05); box-shadow: inset 0 0 0 1px var(--line); }
  /* Under the greeting the state always starts its own line, however wide
     the text column is. */
  .hq-tc-stage__text > .hq-tc-state { display: flex; width: fit-content; }

  @media (max-width: 639px) {
    .hq-tc-stage { --tc-figure-h: 224px; grid-template-columns: 1fr; min-height: 0; padding: 0; text-align: center; }
    .hq-tc-stage__glow { left: 50%; bottom: auto; top: -22%; width: 118%; margin-left: -59%; }
    .hq-tc-stage { padding-top: 18px; }
    .hq-tc-stage__figure { justify-self: center; }
    .hq-tc-stage__text { margin-top: -4px; padding: 0 20px 24px; }
    .hq-tc-state { margin-top: 16px; }
    .hq-tc-stage__text > .hq-tc-state { margin-inline: auto; }
  }

  /* Quick actions: two glass cards with a clear primary affordance */
  .hq-tc-actions { display: grid; grid-auto-rows: 1fr; gap: var(--gap); }
  /* Under the stage the actions have the full width: two side by side. */
  .hq-tc-hero > .hq-tc-actions { grid-template-columns: repeat(auto-fit, minmax(min(100%, 340px), 1fr)); }
  @media (max-width: 639px) { .hq-tc-actions { grid-template-columns: 1fr; gap: 12px; } }
  .hq-tc-action {
    position: relative;
    isolation: isolate;
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
    gap: 18px;
    min-height: 96px;
    padding: 24px;
    border-radius: var(--radius-card);
    overflow: hidden;
    color: var(--text);
    text-decoration: none;
    background: var(--sheen), var(--glass-1);
    box-shadow: var(--shadow-1), inset 0 0 0 1px var(--line), inset 0 1px 0 rgba(255, 255, 255, 0.07);
    transition: transform var(--dur) var(--ease-out), box-shadow var(--dur) var(--ease-out), background-color var(--dur) var(--ease-out);
  }
  /* Edge light along the top of an interactive card (4.3). */
  .hq-tc-action::before {
    content: "";
    position: absolute;
    left: 12%;
    right: 12%;
    top: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgb(var(--blue-hi-rgb) / 0.55), transparent);
    opacity: 0;
    transition: opacity var(--dur) var(--ease-out);
  }
  /* A soft sheen that crosses the card once on hover. */
  .hq-tc-action::after {
    content: "";
    position: absolute;
    inset: 0;
    z-index: -1;
    background: linear-gradient(105deg, transparent 30%, rgb(var(--blue-hi-rgb) / 0.08) 50%, transparent 70%);
    transform: translateX(-100%);
    pointer-events: none;
  }
  .hq-tc-action:focus-visible { outline: none; box-shadow: var(--focus-ring), var(--shadow-1); }
  .hq-tc-action__icon {
    display: grid;
    place-items: center;
    width: 52px;
    height: 52px;
    border-radius: 16px;
    color: var(--blue-300);
    background: radial-gradient(circle at 30% 20%, rgb(var(--blue-rgb) / 0.30), rgb(var(--blue-rgb) / 0.12) 70%);
    box-shadow: inset 0 0 0 1px rgb(var(--blue-rgb) / 0.28), inset 0 1px 0 rgba(255, 255, 255, 0.12);
  }
  .hq-tc-action__icon .icon { width: 24px; height: 24px; }
  .hq-tc-action__icon--telegram .icon { translate: -1px 1px; }
  .hq-tc-action__body { display: grid; gap: 5px; min-width: 0; }
  .hq-tc-action__title { font-family: var(--font-display); font-size: 17px; font-weight: 600; letter-spacing: -0.015em; }
  .hq-tc-action__text { font-size: 13.5px; line-height: 1.5; color: var(--text-muted); }
  .hq-tc-action__meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; margin-top: 6px; font-size: 12.5px; color: var(--text-subtle); }
  .hq-tc-action__go {
    display: grid;
    place-items: center;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    color: var(--text-on-light);
    background: var(--text);
    box-shadow: 0 8px 20px -8px rgba(0, 0, 0, 0.6);
    transition: transform var(--dur) var(--ease-out);
  }
  .hq-tc-action__go .icon { width: 18px; height: 18px; }
  .hq-tc-action--soon { cursor: default; grid-template-columns: auto minmax(0, 1fr); }
  .hq-tc-action--soon .hq-tc-action__title { color: var(--text-muted); }
  .hq-tc-action--soon .hq-tc-action__icon { color: var(--text-muted); background: rgb(var(--fg-rgb) / 0.04); box-shadow: inset 0 0 0 1px var(--line); }
  @media (max-width: 639px) {
    .hq-tc-action { gap: 14px; padding: 18px; min-height: 0; }
    .hq-tc-action__icon { width: 44px; height: 44px; border-radius: 14px; }
    .hq-tc-action__title { font-size: 16px; }
    .hq-tc-action__go { width: 36px; height: 36px; }
  }

  /* Pills for real states: planned, in progress, done, unknown, server */
  .hq-tc-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 24px;
    padding: 0 9px;
    border-radius: 999px;
    font-size: 11.5px;
    font-weight: 700;
    letter-spacing: 0.01em;
    white-space: nowrap;
    color: var(--text-muted);
    background: rgb(var(--fg-rgb) / 0.05);
    box-shadow: inset 0 0 0 1px var(--line);
  }
  .hq-tc-pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
  .hq-tc-pill--planned::before { background: none; box-shadow: inset 0 0 0 1.5px currentColor; }
  .hq-tc-pill--active { color: var(--tesla); background: var(--tesla-soft); box-shadow: none; }
  .hq-tc-pill--ok { color: var(--ok-text); background: rgb(var(--green-rgb) / 0.14); box-shadow: none; }
  .hq-tc-pill--unknown { color: var(--warn); background: rgb(var(--warn-rgb) / 0.12); box-shadow: none; }
  .hq-tc-pill--server { color: var(--blue-300); background: rgb(var(--blue-rgb) / 0.13); box-shadow: none; }

  /* At a glance: the Home pulse strip with three or four figures */
  .hq-tc-pulse { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .hq-tc-pulse--4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .hq-tc-pulse .hq-pulse__item { align-content: start; color: inherit; text-decoration: none; }
  .hq-tc-pulse__value--text { font-size: 17px; letter-spacing: -0.015em; line-height: 1.3; white-space: normal; }
  .hq-tc-pulse__value--text.is-empty { color: var(--text-muted); }
  .hq-tc-meter { display: block; height: 4px; margin: 4px 0 2px; border-radius: 4px; background: rgb(var(--fg-rgb) / 0.08); overflow: hidden; }
  .hq-tc-meter > span { display: block; height: 100%; min-width: 2px; border-radius: inherit; background: var(--blue-500); }
  @media (max-width: 899px) {
    .hq-tc-pulse { grid-template-columns: 1fr 1fr; }
    .hq-tc-pulse:not(.hq-tc-pulse--4) .hq-pulse__item:last-child { grid-column: 1 / -1; }
  }

  /* Requires attention */
  .hq-tc-alerts__list { display: grid; gap: 10px; }
  .hq-tc-alert { display: flex; align-items: flex-start; gap: 12px; padding: 12px 14px; border-radius: 14px; font-size: 14px; line-height: 1.5; background: var(--glass-0); box-shadow: inset 0 0 0 1px var(--line-soft); }
  .hq-tc-alert > .icon { flex: none; width: 18px; height: 18px; margin-top: 2px; }
  .hq-tc-alert--active > .icon { color: var(--tesla); }
  .hq-tc-alert--error > .icon { color: var(--error-text); }
  .hq-tc-alert--warn > .icon { color: var(--warn); }

  /* Section heads inside tabs */
  .hq-tc-section { display: grid; gap: var(--gap); }
  .hq-tc-section > * { min-width: 0; }
  .hq-tc-section__title { font-family: var(--font-display); font-size: 22px; font-weight: 600; letter-spacing: -0.025em; }
  .hq-tc-section__text { margin-top: 6px; max-width: 72ch; font-size: 14.5px; line-height: 1.6; color: var(--text-muted); }
  .hq-tc-filters { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 16px; }
  .hq-tc-filter { flex-wrap: nowrap; max-width: 100%; overflow-x: auto; scrollbar-width: none; }
  .hq-tc-section__head > .hq-tc-filter { margin-top: 16px; }
  .hq-tc-filter .hq-segmented__item { white-space: nowrap; gap: 6px; }
  .hq-tc-filter .hq-segmented__item:disabled { opacity: 0.45; cursor: default; }
  .hq-tc-filter .hq-segmented__item[aria-pressed="true"] { color: var(--text); background: rgb(var(--fg-rgb) / 0.09); box-shadow: inset 0 0 0 1px var(--line-strong); }
  .hq-tc-count { font-size: 11.5px; font-variant-numeric: tabular-nums; color: var(--text-subtle); }

  /* Facts: small labelled values in wells */
  .hq-tc-facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(128px, 1fr)); gap: 10px; }
  .hq-tc-facts > div { padding: 10px 12px; border-radius: 12px; background: var(--glass-0); box-shadow: inset 0 0 0 1px var(--line-soft); }
  .hq-tc-facts dt { font-size: 11.5px; font-weight: 650; color: var(--text-subtle); }
  .hq-tc-facts dd { margin: 3px 0 0; font-size: 13.5px; font-weight: 650; line-height: 1.4; overflow-wrap: anywhere; }
  .hq-tc-facts code { font-size: 12.5px; color: var(--blue-300); }
  .hq-tc-empty { font-size: 13.5px; line-height: 1.55; color: var(--text-muted); }
  .hq-tc-empty strong { color: var(--text); font-weight: 650; }

  /* Automations */
  .hq-tc-autos { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 320px), 1fr)); gap: var(--gap); }
  .hq-tc-auto { display: flex; flex-direction: column; gap: 14px; }
  .hq-tc-auto--server { --edge-top: rgb(var(--orange-rgb) / 0.38); }
  .hq-tc-auto__top { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 10px; }
  .hq-tc-auto__time { font-family: var(--font-display); font-size: 22px; font-weight: 600; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; color: var(--text); }
  .hq-tc-auto__title { display: flex; align-items: center; gap: 10px; font-size: 15.5px; font-weight: 700; letter-spacing: -0.01em; }
  .hq-tc-auto__icon { flex: none; display: grid; place-items: center; width: 32px; height: 32px; border-radius: 10px; color: var(--blue-300); background: rgb(var(--blue-rgb) / 0.12); box-shadow: inset 0 0 0 1px rgb(var(--blue-rgb) / 0.2); }
  .hq-tc-auto__icon .icon { width: 17px; height: 17px; }
  .hq-tc-auto--server .hq-tc-auto__icon { color: var(--tesla); background: var(--tesla-soft); box-shadow: inset 0 0 0 1px rgb(var(--orange-rgb) / 0.25); }
  .hq-tc-auto__text { font-size: 13.5px; line-height: 1.55; color: var(--text-muted); }
  .hq-tc-auto__foot { display: flex; align-items: center; gap: 8px; margin-top: auto; padding-top: 12px; border-top: 1px solid var(--line-soft); font-size: 12.5px; font-weight: 600; color: var(--text-subtle); }
  .hq-tc-auto__foot .icon { width: 15px; height: 15px; }

  /* Research tab */
  .hq-tc-research { display: grid; gap: var(--gap); }
  .hq-tc-research > * { min-width: 0; }
  .hq-tc-run { display: grid; grid-template-columns: minmax(0, 1fr) auto; column-gap: 24px; }
  .hq-tc-run .hq-tc-section__title { margin-top: 8px; }
  .hq-tc-run .hq-agent__status { margin: 20px 0 18px; }
  .hq-tc-run .hq-agent__status dd { margin-left: 0; }
  .hq-tc-run__tesla { align-self: end; width: clamp(160px, 24cqi, 250px); height: auto; margin: 0 -10px -24px 0; filter: drop-shadow(0 18px 24px rgba(0, 0, 0, 0.45)); }
  @container (max-width: 560px) {
    .hq-tc-run { grid-template-columns: 1fr; }
    .hq-tc-run__tesla { display: none; }
  }

  /* Reports archive */
  .hq-tc-archive { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 380px), 1fr)); gap: var(--gap); align-items: start; }
  .hq-tc-archive__group .hq-card__head { margin-bottom: 14px; }
  .hq-tc-archive__group.is-planned { background: var(--glass-0); box-shadow: inset 0 0 0 1px var(--line-soft); }
  .hq-tc-archive__group.is-planned::after { display: none; }
  .hq-tc-rows { display: grid; }
  .hq-tc-row { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-top: 1px solid var(--line-soft); }
  .hq-tc-row__main { display: grid; gap: 2px; flex: 1; min-width: 0; }
  .hq-tc-row__title { font-size: 14px; font-weight: 650; color: var(--text); text-decoration: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .hq-tc-row__title:hover { color: var(--blue-300); }
  .hq-tc-row__meta { font-size: 12.5px; color: var(--text-subtle); }
  .hq-tc-row__open { flex: none; display: grid; place-items: center; width: 36px; height: 36px; border-radius: 50%; color: var(--text-subtle); transition: color var(--dur-fast) var(--ease-out), background-color var(--dur-fast) var(--ease-out); }
  .hq-tc-row__open:hover { color: var(--text); background: rgb(var(--fg-rgb) / 0.06); }
  .hq-tc-row__open .icon { width: 18px; height: 18px; }
  .hq-tc [data-filtered="out"] { display: none; }

  /* Activity timeline */
  .hq-tc-timeline { display: grid; }
  .hq-tc-event { position: relative; display: grid; grid-template-columns: 18px minmax(0, 1fr) auto; column-gap: 14px; align-items: start; padding: 14px 0; }
  .hq-tc-event + .hq-tc-event { border-top: 1px solid var(--line-soft); }
  .hq-tc-event__dot { width: 10px; height: 10px; margin: 6px 0 0 4px; border-radius: 50%; background: var(--ok-text); box-shadow: 0 0 0 4px rgb(var(--green-rgb) / 0.14); }
  .hq-tc-event--error .hq-tc-event__dot { background: var(--error-text); box-shadow: 0 0 0 4px rgb(var(--red-rgb) / 0.14); }
  .hq-tc-event--running .hq-tc-event__dot { background: var(--tesla); box-shadow: 0 0 0 4px var(--tesla-soft); }
  .hq-tc-event__title { font-size: 14.5px; font-weight: 650; }
  .hq-tc-event__title a { color: var(--text); text-decoration: none; }
  .hq-tc-event__title a:hover { color: var(--blue-300); }
  .hq-tc-event__meta { margin-top: 2px; font-size: 12.5px; line-height: 1.5; color: var(--text-subtle); }
  .hq-tc-event__time { font-size: 12.5px; font-variant-numeric: tabular-nums; color: var(--text-subtle); white-space: nowrap; padding-top: 2px; }
  @media (max-width: 639px) {
    .hq-tc-event { grid-template-columns: 18px minmax(0, 1fr); }
    .hq-tc-event__time { grid-column: 2; padding-top: 4px; }
  }
  .hq-tc-blank { display: grid; justify-items: center; gap: 8px; padding: 44px 16px; text-align: center; }
  .hq-tc-blank__title { font-family: var(--font-display); font-size: 17px; font-weight: 600; }
  .hq-tc-blank__text { max-width: 54ch; font-size: 14px; line-height: 1.6; color: var(--text-muted); }

  /* Settings */
  .hq-tc-settings { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 340px), 1fr)); gap: var(--gap); }
  .hq-tc-set .hq-card__head { margin-bottom: 16px; }
  .hq-tc-set--wide { grid-column: 1 / -1; }
  .hq-tc-set .hq-tc-facts + .hq-tc-empty { margin-top: 14px; }
}

@layer motion {
  @keyframes hq-tc-in { from { opacity: 0; transform: translateY(10px) scale(0.99); } }
  @keyframes hq-tc-glow { from { opacity: 0; transform: scale(0.82); } }
  @keyframes hq-tc-glow-idle { 0%, 100% { opacity: 1; } 50% { opacity: 0.78; } }
  @keyframes hq-tc-arrive { from { opacity: 0; transform: translateY(28px) scale(0.975); } }
  @keyframes hq-tc-float { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-5px); } }
  @keyframes hq-tc-sweep {
    0% { opacity: 0; background-position: 100% 0; }
    30% { opacity: 1; }
    100% { opacity: 0; background-position: 0% 0; }
  }
  @keyframes hq-tc-up { from { opacity: 0; transform: translateY(12px); } }
  @keyframes hq-tc-sheen { to { transform: translateX(100%); } }
  @keyframes hq-tc-pulse-dot { 0% { box-shadow: 0 0 0 0 rgb(var(--orange-rgb) / 0.5); } 100% { box-shadow: 0 0 0 8px rgb(var(--orange-rgb) / 0); } }

  @media (prefers-reduced-motion: no-preference) {
    /* TESLA's arrival: the stage settles, the warm light rises behind him,
       he steps in, a light passes over him once and his greeting follows.
       All within about 1.6 s; the page is usable from the first frame. */
    .hq-motion .hq-tc-stage { animation: hq-tc-in 700ms var(--ease-out) both; }
    .hq-motion .hq-tc-stage__glow { animation: hq-tc-glow 1300ms var(--ease-out) 120ms both, hq-tc-glow-idle 7s var(--ease-in-out) 1.6s infinite; }
    .hq-motion .hq-tc-stage__figure img { animation: hq-tc-arrive 1000ms var(--ease-out) 260ms both, hq-tc-float 8s var(--ease-in-out) 1.8s infinite; }
    .hq-motion .hq-tc-stage__figure::after { animation: hq-tc-sweep 1300ms var(--ease-in-out) 820ms both; }
    .hq-motion .hq-tc-stage__eyebrow { animation: hq-tc-up 700ms var(--ease-out) 420ms both; }
    .hq-motion .hq-tc-stage__greeting { animation: hq-tc-up 800ms var(--ease-out) 520ms both; }
    .hq-motion .hq-tc-stage__for { animation: hq-tc-up 800ms var(--ease-out) 640ms both; }
    .hq-motion .hq-tc-private { animation: hq-tc-up 800ms var(--ease-out) 760ms both; }
    .hq-motion .hq-tc-locked--action { animation: hq-tc-up 700ms var(--ease-out) 160ms both; }
    .hq-motion .hq-tc-locked--action + .hq-tc-locked--action { animation-delay: 260ms; }
    .hq-motion .hq-tc-state { animation: hq-tc-up 800ms var(--ease-out) 840ms both; }
    .hq-motion .hq-tc-action { animation: hq-tc-up 700ms var(--ease-out) 160ms both; }
    .hq-motion .hq-tc-action + .hq-tc-action { animation-delay: 260ms; }
    /* The status dot breathes only while TESLA is really researching. */
    .hq-tc-state--active .hq-tc-state__dot { animation: hq-tc-pulse-dot 1.6s var(--ease-out) infinite; }

    a.hq-tc-action:active { transform: scale(0.985); transition-duration: 90ms; }
    @media (hover: hover) and (pointer: fine) {
      a.hq-tc-action:hover { transform: translateY(-3px); }
      a.hq-tc-action:hover::after { animation: hq-tc-sheen 900ms var(--ease-out) both; }
      a.hq-tc-action:hover .hq-tc-action__go { transform: translateX(3px); }
      a.hq-tc-action:hover:active { transform: translateY(-1px); }
    }
  }
  /* The hover answers with light even when motion is reduced. */
  @media (hover: hover) and (pointer: fine) {
    a.hq-tc-action:hover { box-shadow: var(--shadow-2), inset 0 0 0 1px var(--line-strong), inset 0 1px 0 rgba(255, 255, 255, 0.1); }
    a.hq-tc-action:hover::before { opacity: 1; }
  }
}

/* ------------------------------------------------------------------ */
/* Reports (modules/reports): tabs reuse .hq-fin-tabs, counts the      */
/* Finance KPI strip; the report document is shared with the PDF.      */
/* ------------------------------------------------------------------ */

@layer components {
  .hq-rep-filter__field { display: flex; flex: 0 1 190px; min-width: 0; }
  .hq-rep-filter__field select, .hq-rep-filter__field input { width: 100%; min-height: 38px; max-width: 100%; font-size: 14px; }
  .hq-rep-filter__date { flex: 0 1 170px; align-items: center; gap: 8px; }
  .hq-rep-filter__label { flex: none; font-size: 12.5px; font-weight: 650; color: var(--text-subtle); }
  .hq-rep-filter input[type="date"] { color-scheme: dark; }

  .hq-rep-name { display: grid; color: inherit; text-decoration: none; }
  .hq-rep-name:hover .hq-table__name { color: var(--blue-300); }
  .hq-rep-tesla { font-weight: 750; letter-spacing: 0.04em; color: var(--tesla); }
  .hq-rep-cat { color: var(--blue-300); text-decoration: none; }
  .hq-rep-open { width: 1%; text-align: right; white-space: nowrap; }
  .hq-rep-open .hq-button { text-decoration: none; }

  .hq-rep-cats { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; margin: 0; padding: 0; list-style: none; }
  .hq-rep-cats__item {
    display: grid;
    grid-template-columns: 36px minmax(0, 1fr);
    gap: 12px;
    height: 100%;
    padding: 16px;
    border-radius: 14px;
    color: inherit;
    text-decoration: none;
    background: var(--glass-0);
    box-shadow: inset 0 0 0 1px var(--line-soft);
    transition: box-shadow var(--dur-fast) var(--ease-out), background var(--dur-fast) var(--ease-out);
  }
  .hq-rep-cats__item:hover { background: rgb(var(--fg-rgb) / 0.045); box-shadow: inset 0 0 0 1px var(--line-strong); }
  .hq-rep-cats__icon { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 10px; color: var(--blue-300); background: rgb(var(--blue-rgb) / 0.10); }
  .hq-rep-cats__icon .icon { width: 18px; height: 18px; }
  .hq-rep-cats__body { display: grid; gap: 4px; min-width: 0; }
  .hq-rep-cats__name { display: flex; align-items: center; gap: 8px; font-weight: 750; }
  .hq-rep-cats__text { font-size: 13px; line-height: 1.5; color: var(--text-muted); }
  .hq-rep-cats__source { font-size: 12px; font-weight: 650; color: var(--ok-text); }
  .hq-rep-cats__source.is-pending { color: var(--text-subtle); }

  .hq-rep-side { display: grid; align-content: start; gap: var(--gap); }
  .hq-rep-meta { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 16px; margin: 0 0 14px; }
  .hq-rep-meta dt { font-size: 12px; font-weight: 600; color: var(--text-subtle); }
  .hq-rep-meta dd { margin: 2px 0 0; font-size: 14px; font-weight: 650; overflow-wrap: anywhere; }
  .hq-rep-meta a { color: var(--blue-300); }
  .hq-rep-meta__wide { grid-column: 1 / -1; }
  .hq-rep-meta code { font-size: 12px; font-weight: 500; color: var(--text-muted); }
  .hq-pill--rep-completed { color: var(--ok-text); background: rgb(var(--green-rgb) / 0.14); }
  .hq-pill--rep-draft { color: var(--warn); background: rgb(var(--warn-rgb) / 0.13); }
  .hq-pill--rep-failed { color: var(--error-text); background: rgb(var(--red-rgb) / 0.14); }

  .hq-rep-versions { display: grid; margin: 0; padding: 0; list-style: none; }
  .hq-rep-versions__item { display: grid; padding: 9px 0; border-top: 1px solid var(--line-soft); color: inherit; font-weight: 650; text-decoration: none; }
  .hq-rep-versions li:first-child .hq-rep-versions__item { border-top: 0; padding-top: 0; }
  a.hq-rep-versions__item:hover { color: var(--blue-300); }
  .hq-rep-versions__item[aria-current] { color: var(--text-muted); }

  /* The report document */
  .rep-doc { display: grid; gap: 26px; }
  .rep-doc__summary { margin: 0; font-size: 15px; line-height: 1.6; color: var(--text-muted); }
  .rep-doc__figures { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin: 0; }
  .rep-doc__figure { padding: 14px 16px; border-radius: 14px; background: var(--glass-0); box-shadow: inset 0 0 0 1px var(--line-soft); }
  .rep-doc__figure dt { font-size: 12.5px; font-weight: 650; color: var(--text-muted); }
  .rep-doc__figure dd { margin: 4px 0 0; font-family: var(--font-display); font-size: 22px; font-weight: 600; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
  .rep-doc__section { display: grid; gap: 10px; }
  .rep-doc__heading { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 0; font-family: var(--font-display); font-size: 17px; font-weight: 600; letter-spacing: -0.01em; }
  .rep-doc__text { margin: 0; line-height: 1.65; color: var(--text); white-space: pre-line; }
  .rep-doc__items { display: grid; gap: 8px; margin: 0; padding-left: 20px; line-height: 1.55; }
  .rep-doc__items li::marker { color: var(--blue-400); }
  .rep-doc__facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 10px; margin: 0; }
  .rep-doc__facts dt { font-size: 12px; font-weight: 600; color: var(--text-subtle); }
  .rep-doc__facts dd { margin: 2px 0 0; font-weight: 700; }
  .rep-doc__table-wrap { overflow-x: auto; margin: 0 -6px; }
  .rep-doc__empty { margin: 0; font-size: 14px; color: var(--text-subtle); }
  .rep-doc__notes { display: grid; gap: 6px; margin: 0; padding: 14px 16px; list-style: none; border-radius: 12px; font-size: 13px; line-height: 1.5; color: var(--text-muted); background: var(--glass-0); box-shadow: inset 3px 0 0 var(--blue-500), inset 0 0 0 1px var(--line-soft); }
  @media (max-width: 639px) {
    .hq-rep-filter__field, .hq-rep-filter__date { flex: 1 1 140px; }
    .hq-rep-open { width: auto; text-align: left; }
    .rep-doc__table-wrap { margin: 0; }
    .rep-doc__figures { grid-template-columns: 1fr 1fr; }
    .rep-doc__figure dd { font-size: 19px; }
  }
}

/* ------------------------------------------------------------------ */
/* System (modules/hq, templatetags/system.py): tabs reuse            */
/* .hq-fin-tabs, the overview the .hq-facts tiles.                     */
/* ------------------------------------------------------------------ */

@layer components {
  .hq-sys-overview .hq-facts { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
  .hq-sys-overview .hq-facts dd { overflow-wrap: anywhere; }
  @media (max-width: 639px) {
    .hq-sys-overview .hq-facts { grid-template-columns: 1fr; gap: 6px; }
    .hq-sys-overview .hq-facts div { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; padding: 8px 12px; }
    .hq-sys-overview .hq-facts dd { margin: 0; text-align: right; }
  }
}

/* ------------------------------------------------------------------ */
/* Company knowledge (modules/knowledge, TESLA M5.2) and knowledge in  */
/* TESLA's answers. Green and red only for verified and disputed or    */
/* rejected; orange only for TESLA's AI summaries and proposals.       */
/* ------------------------------------------------------------------ */

@layer components {
  .hq-pill--kb-verified { color: var(--ok-text); background: rgb(var(--green-rgb) / 0.14); }
  .hq-pill--kb-user_note, .hq-pill--kb-document { color: var(--text-muted); background: rgb(var(--fg-rgb) / 0.05); box-shadow: inset 0 0 0 1px var(--line); }
  .hq-pill--kb-ai_summary, .hq-pill--kb-proposal { color: var(--tesla); background: rgb(var(--orange-rgb) / 0.12); }
  .hq-pill--kb-disputed, .hq-pill--kb-rejected { color: var(--error-text); background: rgb(var(--red-rgb) / 0.14); }
  .hq-pill--kb-outdated { color: var(--text-subtle); background: rgb(var(--fg-rgb) / 0.04); }
  .hq-kb-kpis { margin-bottom: 18px; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
  .hq-kb-filter select { max-width: 220px; }
  .hq-kb-check { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text-muted); }
  .hq-kb-list { display: grid; margin: 0; padding: 0; list-style: none; }
  .hq-kb-item { display: grid; gap: 6px; padding: 14px 0; border-top: 1px solid var(--line-soft); }
  .hq-kb-item:first-child { border-top: 0; padding-top: 2px; }
  .hq-kb-item.is-outdated { opacity: 0.72; }
  .hq-kb-item__head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 12px; }
  .hq-kb-item__title { font-weight: 700; font-size: 15px; color: var(--text); text-decoration: none; }
  a.hq-kb-item__title:hover { color: var(--blue-300); }
  .hq-kb-item__meta { margin: 0; font-size: 12.5px; color: var(--text-subtle); }
  .hq-kb-item__snippet { margin: 0; font-size: 14px; line-height: 1.5; color: var(--text-muted); }
  .hq-kb-ref { font-variant-numeric: tabular-nums; font-weight: 650; color: var(--text-muted); }
  .hq-kb-warnings { margin: 0; }
  .hq-kb-pages { display: flex; align-items: center; justify-content: center; gap: 12px; padding-top: 14px; }
  .hq-kb-side { display: grid; grid-template-columns: minmax(0, 1fr); gap: 18px; align-content: start; }
  .hq-kb-cats { display: grid; gap: 2px; margin: 0; padding: 0; list-style: none; }
  .hq-kb-cats a { display: flex; justify-content: space-between; gap: 12px; padding: 7px 10px; border-radius: 10px; font-size: 14px; color: var(--text-muted); text-decoration: none; }
  .hq-kb-cats a:hover, .hq-kb-cats a[aria-current="true"] { color: var(--text); background: var(--glass-0); box-shadow: inset 0 0 0 1px var(--line-soft); }
  .hq-kb-rules { margin: 0; }
  .hq-segmented__item .hq-count-badge { margin-left: 6px; }
  .hq-kb-status + .hq-kb-warnings { margin-bottom: 14px; }
  .hq-kb-links__note { margin: 0 0 10px; }
  .hq-kb-status { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin-bottom: 12px; }
  .hq-kb-body { font-size: 15px; line-height: 1.6; overflow-wrap: anywhere; }
  .hq-kb-body p { margin: 0 0 10px; }
  .hq-kb-inline-list { margin: 8px 0 0; padding-left: 18px; }
  .hq-kb-actions { display: grid; gap: 12px; margin-top: 16px; }
  .hq-kb-links { display: grid; gap: 8px; margin: 0 0 12px; padding: 0; list-style: none; }
  .hq-kb-links li { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; font-size: 14px; }
  .hq-kb-links__end { display: inline; margin-left: auto; }
  .hq-kb-subtitle { margin: 18px 0 8px; font-size: 13px; font-weight: 700; color: var(--text-subtle); }
  .hq-kb-proposal__quote { margin: 0; font-size: 14px; color: var(--text-muted); }
  .hq-kb-proposal__form { margin-top: 6px; }
  .hq-kb-form-narrow { grid-template-columns: minmax(0, 1fr); }

  /* Knowledge in TESLA's answers */
  .hq-ask__kind--note { color: var(--text-muted); background: rgb(var(--fg-rgb) / 0.06); box-shadow: inset 0 0 0 1px var(--line); }
  .hq-ask__kind--caution { color: var(--text); background: rgb(var(--fg-rgb) / 0.06); box-shadow: inset 3px 0 0 var(--tesla), inset 0 0 0 1px var(--line); }
  .hq-ask__proposal { display: grid; gap: 8px; margin-top: 10px; padding: 12px 14px; border-radius: 12px; background: var(--glass-0); box-shadow: inset 3px 0 0 var(--tesla), inset 0 0 0 1px var(--line-soft); }
  .hq-ask__proposal p { margin: 0; }
  .hq-ask__proposal-title { font-size: 12px; font-weight: 700; color: var(--tesla); }
  .hq-ask__proposal-note { font-size: 12.5px; color: var(--text-subtle); }
  .hq-ask__proposal-actions { display: flex; flex-wrap: wrap; gap: 8px; }
  .hq-ask__proposal-form { display: grid; gap: 8px; width: 100%; }
  .hq-ask__proposal-form label { display: grid; gap: 4px; font-size: 12.5px; color: var(--text-subtle); }
  .hq-ask__proposal-form input[type="text"], .hq-ask__proposal-form textarea, .hq-ask__proposal-form select { width: 100%; min-width: 0; padding: 8px 10px; font: inherit; font-size: 14px; color: var(--text); background: var(--surface, #fff); border: 1px solid var(--border, #E2E8F0); border-radius: 8px; }
  .hq-ask__proposal-form .hq-kb-check { display: flex; align-items: center; gap: 6px; }
  .hq-ask__action { display: grid; gap: 8px; min-width: 0; margin-top: 10px; padding: 12px 14px; border-radius: 12px; background: var(--glass-0); box-shadow: inset 3px 0 0 var(--tesla), inset 0 0 0 1px var(--line-soft); }
  .hq-ask__action p { margin: 0; }
  .hq-ask__action-summary { font-weight: 600; overflow-wrap: anywhere; }
  .hq-ask__action-records { margin: 0; padding: 0; list-style: none; font-size: 13px; overflow-wrap: anywhere; }
  .hq-ask__action-scroll { min-width: 0; overflow-x: auto; }
  .hq-ask__action-table { width: 100%; border-collapse: collapse; font-size: 13px; }
  .hq-ask__action-table th { padding: 4px 8px 4px 0; font-size: 12px; font-weight: 600; text-align: left; color: var(--text-subtle); border-bottom: 1px solid var(--line-soft); }
  .hq-ask__action-table td { padding: 5px 8px 5px 0; vertical-align: top; overflow-wrap: anywhere; border-bottom: 1px solid var(--line-soft); }
  .hq-ask__action-table td:first-child { overflow-wrap: normal; }
  .hq-ask__action-old { color: var(--text-subtle); }
  .hq-ask__action-new { font-weight: 600; }
  @media (max-width: 640px) {
    .hq-ask__action-table thead { display: none; }
    .hq-ask__action-table, .hq-ask__action-table tbody, .hq-ask__action-table tr, .hq-ask__action-table td { display: block; width: 100%; }
    .hq-ask__action-table tr { padding: 8px 0; border-bottom: 1px solid var(--line-soft); }
    .hq-ask__action-table td { padding: 1px 0; border-bottom: 0; overflow-wrap: break-word; }
    .hq-ask__action-table td:first-child { font-weight: 700; }
    .hq-ask__action-table td[data-label]::before { content: attr(data-label) ": "; font-weight: 500; color: var(--text-subtle); }
  }
  .hq-ask__action-warning { font-size: 13px; font-weight: 600; color: var(--tesla); }
  .hq-ask__action-visible { font-size: 13px; font-weight: 600; overflow-wrap: anywhere; }
  .hq-ask__action-state { font-size: 13px; font-weight: 700; }
  .hq-ask__action-state--succeeded, .hq-ask__action-result { color: var(--ok-text); }
  .hq-ask__action-state--failed, .hq-ask__action-state--conflict, .hq-ask__action-state--interrupted, .hq-ask__action-problem { color: var(--error-text); }
  .hq-ask__action-result, .hq-ask__action-problem { font-size: 13.5px; }
  .hq-kb-proposal__links { display: grid; gap: 8px; margin: 0; padding: 0; border: 0; }
  .hq-kb-proposal__links legend { padding: 0; margin-bottom: 4px; font-size: 13px; color: var(--text-subtle); }
  .hq-kb-revision { margin-top: 6px; font-size: 13.5px; }
  .hq-kb-revision summary { cursor: pointer; color: var(--text-subtle); }
  .hq-kb-compare { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
  .hq-kb-profile__form { display: grid; gap: 10px; }
  .hq-kb-profile__source { display: grid; gap: 4px; font-size: 13px; color: var(--text-subtle); }
  .hq-kb-profile__form textarea, .hq-kb-profile__form input[type="text"] { width: 100%; min-width: 0; }
  @media (max-width: 760px) { .hq-kb-compare { grid-template-columns: minmax(0, 1fr); } }

  @media (max-width: 639px) {
    .hq-kb-filter select { max-width: none; flex: 1 1 140px; }
  }
}

/* Tasks (modules/tasks) */
@layer components {
  .hq-tasklist { display: grid; margin: 0; padding: 0; list-style: none; }
  .hq-task { border-top: 1px solid var(--line-soft); }
  .hq-task:first-child { border-top: 0; }
  .hq-task__main { display: grid; gap: 8px; padding: 12px 0; color: inherit; text-decoration: none; }
  .hq-task__main:hover .hq-task__title { color: var(--blue-300); }
  .hq-task__head { display: flex; align-items: baseline; gap: 8px; min-width: 0; }
  .hq-task__head .hq-sitecard__code { flex: none; }
  .hq-task__title { font-size: 14.5px; font-weight: 650; line-height: 1.35; overflow-wrap: anywhere; }
  .hq-task__meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; }
  .hq-task__fact { display: inline-flex; align-items: center; gap: 5px; font-size: 12.5px; color: var(--text-muted); overflow-wrap: anywhere; }
  .hq-task__fact .icon { flex: none; width: 14px; height: 14px; color: var(--text-subtle); }
  .hq-task-title { overflow-wrap: anywhere; }
  .hq-task-filter__field { min-width: 0; max-width: 100%; }
  .hq-task-filter__field select { min-height: 36px; max-width: 100%; padding: 6px 10px; border: 1px solid var(--line-strong); border-radius: 10px; font: inherit; font-size: 14px; color: var(--text); background: rgb(var(--navy-rgb) / 0.55); color-scheme: dark; }
  .hq-task-warning { margin-bottom: 12px; }
  .hq-task-warning .icon { color: var(--warn); }
  .hq-task-update { margin-bottom: 18px; }
  .hq-task-update:last-child { margin-bottom: 0; }
  .hq-task-update .hq-button { justify-self: start; }
  .hq-task-note { margin-top: 4px; font-size: 13.5px; line-height: 1.5; color: var(--text-muted); overflow-wrap: anywhere; }
  .hq-pill--task-open { color: var(--blue-300); background: rgb(var(--blue-rgb) / 0.14); }
  .hq-pill--task-in_progress { color: var(--ok-text); background: rgb(var(--green-rgb) / 0.14); }
  .hq-pill--task-waiting { color: var(--warn); background: rgb(var(--warn-rgb) / 0.13); }
  .hq-pill--task-done { color: var(--text-muted); background: rgb(var(--fg-rgb) / 0.05); box-shadow: inset 0 0 0 1px var(--line); }
  .hq-pill--task-cancelled { color: var(--text-subtle); background: rgb(var(--fg-rgb) / 0.03); box-shadow: inset 0 0 0 1px var(--line); }
  .hq-pill--task-high { color: var(--warn); background: rgb(var(--warn-rgb) / 0.13); }
  .hq-pill--task-urgent { color: var(--error-text); background: rgb(var(--red-rgb) / 0.14); }
  .hq-pill--remind-error { color: var(--error-text); background: rgb(var(--red-rgb) / 0.14); }
  .hq-pill--remind-warn { color: var(--warn); background: rgb(var(--warn-rgb) / 0.13); }
  .hq-pill--remind-info { color: var(--blue-300); background: rgb(var(--blue-rgb) / 0.14); }
}

/* AI usage and costs (System tab, owner only; hq/ai_costs.html) */
.ai-costs__budgets {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: var(--space-4);
}
.ai-costs__budget-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  margin: 0;
  font-weight: 600;
}
.ai-costs__budget-value {
  margin: var(--space-1) 0 0;
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.ai-costs__budget[data-level="80"] .meter span,
.ai-costs__budget[data-level="95"] .meter span { background: var(--warn); }
.ai-costs__budget[data-level="stopped"] .meter span { background: var(--status-error); }
.ai-costs__chart {
  display: block;
  width: 100%;
  height: 140px;
}
.ai-costs__bar { fill: var(--link); }
.ai-costs__bar--estimate { fill: color-mix(in srgb, var(--link) 35%, transparent); }
.ai-costs__events {
  display: grid;
  gap: var(--space-2);
  margin: 0;
  padding: 0;
  list-style: none;
}
.ai-costs__ledger details { min-width: 0; }
.ai-costs__ledger .facts { margin-top: var(--space-2); }
.ai-costs .panel { min-width: 0; }
.ai-costs .panel__header { flex-wrap: wrap; }
/* Four System tabs (AI costs for the owner) scroll on narrow screens. */
.hq-sys-tabs { max-width: 100%; }
.hq-sys-tabs .hq-segmented { max-width: 100%; overflow-x: auto; scrollbar-width: none; }
.ai-costs tbody th[scope="row"] { min-width: 11rem; }

/* ------------------------------------------------------------------ */
/* W4: workbook months (freshness, checks, histories)                  */
/* ------------------------------------------------------------------ */
@layer components {
  /* Freshness of the shown month */
  .hq-fresh {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px 14px;
    margin: 0 0 18px;
    padding: 9px 14px;
    border-radius: var(--radius-sm);
    background: var(--glass-0);
    box-shadow: inset 0 0 0 1px var(--line-soft);
    font-size: 13px;
    color: var(--text-muted);
  }
  .hq-header .hq-fresh { margin: 2px 0 0; }
  .hq-fresh__icon { width: 15px; height: 15px; color: var(--blue-400); flex: none; }
  .hq-fresh__month strong { color: var(--text); font-weight: 700; margin-right: 6px; }
  .hq-fresh--in_progress .hq-fresh__state { color: var(--blue-300); }
  .hq-fresh__source { color: var(--text-subtle); }
  .hq-fresh__warn { display: inline-flex; align-items: center; gap: 6px; color: var(--warn); }
  .hq-fresh__warn .icon { width: 14px; height: 14px; }
  .hq-fresh.is-stale { box-shadow: inset 0 0 0 1px rgb(var(--warn-rgb) / 0.35); }
  .hq-fresh__note { color: var(--text-subtle); font-style: italic; }

  /* Workbook check */
  .hq-pill--quality-ok { color: var(--ok-text); background: rgb(var(--green-rgb) / 0.14); }
  .hq-pill--quality-warning { color: var(--warn); background: rgb(var(--warn-rgb) / 0.13); }
  .hq-pill--quality-error { color: var(--error-text); background: rgb(var(--red-rgb) / 0.14); }
  .hq-quality .hq-card__head .hq-pill { margin-left: auto; }
  .hq-checks { display: grid; gap: 14px; margin: 0; padding: 0; list-style: none; }
  .hq-check { display: grid; grid-template-columns: 22px 1fr; gap: 10px; }
  .hq-check + .hq-check { padding-top: 14px; border-top: 1px solid var(--line-soft); }
  .hq-check__icon .icon { width: 18px; height: 18px; margin-top: 1px; }
  .hq-check.is-ok .hq-check__icon { color: var(--ok-text); }
  .hq-check.is-warn .hq-check__icon { color: var(--warn); }
  .hq-check.is-error .hq-check__icon { color: var(--error-text); }
  .hq-check.is-none .hq-check__icon { color: var(--text-subtle); }
  .hq-check__body { display: grid; gap: 3px; min-width: 0; }
  .hq-check__title { font-weight: 650; color: var(--text); }
  .hq-check__text { font-size: 13.5px; color: var(--text-muted); }
  .hq-check__list { display: grid; gap: 4px; margin: 6px 0 0; padding: 0; list-style: none; font-size: 13px; color: var(--text-muted); }
  .hq-check__list li { overflow-wrap: anywhere; }
  .hq-check__list strong { color: var(--text); font-variant-numeric: tabular-nums; }
  .hq-check__link { display: inline-flex; align-items: center; gap: 4px; margin-top: 4px; font-size: 13px; font-weight: 600; color: var(--blue-300); }
  .hq-check__link .icon { width: 14px; height: 14px; }

  /* Revenue structure */
  .hq-structure__facts { margin: 18px 0 0; }
  .hq-structure .hq-subhead { margin-top: 22px; }
  .hq-matrix tbody th { white-space: nowrap; }

  /* Year table and month tables: wide, scroll on their own */
  .hq-year-wrap { overflow-x: auto; }
  .hq-year { min-width: 640px; }
  .hq-year th[scope="row"] { white-space: nowrap; }
  .hq-year__total { background: rgb(var(--blue-rgb) / 0.06); }
  .hq-year__sub { display: block; font-weight: 500; }
  .hq-year-switch { margin-left: auto; }
  @media (max-width: 639px) {
    .hq-year tbody tr { display: table-row; }
    .hq-year tbody th, .hq-year tbody td { display: table-cell; padding: 6px; border-top: 1px solid var(--line-soft); }
    .hq-year tbody td::before { content: none; }
    .hq-year thead { display: table-header-group; }
  }
  .hq-months-table tfoot th, .hq-months-table tfoot td { border-top: 1px solid var(--line); font-weight: 650; }
  @media (max-width: 639px) {
    .hq-months-table tfoot tr { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 12px; padding-top: 12px; }
    .hq-months-table tfoot th { grid-column: 1 / -1; }
    .hq-months-table tfoot td { display: grid; padding: 0; border: 0; text-align: left; }
    .hq-months-table tfoot td:empty { display: none; }
    .hq-months-table tfoot td::before { content: attr(data-label); font-size: 11.5px; font-weight: 600; color: var(--text-subtle); }
  }

  /* Price list */
  .hq-pricelist { display: grid; gap: 10px; margin: 0 0 6px; padding: 0; list-style: none; }
  .hq-pricelist__item { display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; }
  .hq-pricelist__name { font-weight: 650; }
  .hq-pricelist__price { text-align: right; font-variant-numeric: tabular-nums; }
  .hq-pricelist__meta { grid-column: 1 / -1; font-size: 12.5px; color: var(--text-subtle); }

  /* Apartments by building */
  .hq-units { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; margin: 0 0 18px; padding: 0; list-style: none; }
  .hq-unit { display: grid; gap: 6px; padding: 10px 12px; border-radius: var(--radius-sm); background: var(--glass-0); box-shadow: inset 0 0 0 1px var(--line-soft); }
  .hq-unit__name { font-weight: 700; font-variant-numeric: tabular-nums; }
  .hq-unit__phases { display: flex; flex-wrap: wrap; gap: 4px; }
  .hq-unit__phase { display: inline-flex; align-items: center; gap: 3px; padding: 1px 7px; border-radius: 999px; font-size: 11.5px; font-weight: 650; }
  .hq-unit__phase .icon { width: 11px; height: 11px; }
  .hq-unit__phase.is-done { color: var(--ok-text); background: rgb(var(--green-rgb) / 0.14); }
  .hq-unit__phase.is-open { color: var(--text-muted); box-shadow: inset 0 0 0 1px var(--line); }

  /* Employees: payroll strip, projects, project of a calendar day */
  .hq-emp-payroll, .hq-team-output { margin-bottom: 18px; }
  .hq-emp-payroll .hq-facts { margin-bottom: 8px; }
  .hq-emp-projects { margin-bottom: 14px; }
  .hq-cal__project {
    overflow: hidden;
    font-size: 10px;
    font-weight: 600;
    line-height: 1.2;
    color: var(--blue-300);
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  @media (max-width: 639px) { .hq-cal__project { display: none; } }
}

@layer components {
  /* W4 tables on a phone: each row a small card of label/value pairs. */
  @media (max-width: 639px) {
    .hq-table.hq-stack tbody tr, .hq-table.hq-stack tfoot tr {
      display: grid;
      grid-template-columns: 1fr 1fr;
      gap: 8px 12px;
      padding: 12px 0;
      border-top: 1px solid var(--line-soft);
    }
    .hq-table.hq-stack tbody tr:first-child { border-top: 0; padding-top: 0; }
    .hq-table.hq-stack tbody th, .hq-table.hq-stack tfoot th { grid-column: 1 / -1; padding: 0; border: 0; }
    .hq-table.hq-stack tbody td, .hq-table.hq-stack tfoot td { display: block; padding: 0; border: 0; text-align: left; }
    .hq-table.hq-stack td:empty { display: none; }
    .hq-table.hq-stack td::before { display: block; content: attr(data-label); font-size: 11.5px; font-weight: 600; color: var(--text-subtle); }
  }
}
@layer components {
  /* The year table keeps its columns on a phone and scrolls in its card. */
  @media (max-width: 639px) {
    .hq-table.hq-year thead { display: table-header-group; }
    .hq-table.hq-year tbody tr { display: table-row; padding: 0; }
    .hq-table.hq-year tbody th, .hq-table.hq-year tbody td, .hq-table.hq-year tbody td.is-num {
      display: table-cell;
      padding: 6px;
      border-top: 1px solid var(--line-soft);
    }
    .hq-table.hq-year tbody td.is-num { text-align: right; }
  }
  /* Seven Finance tabs scroll on narrow screens instead of widening the page. */
  .hq-fin-tabs { max-width: 100%; }
  .hq-fin-tabs .hq-segmented { max-width: 100%; overflow-x: auto; scrollbar-width: none; }
}
@layer components {
  /* A card header with a long note wraps on a phone instead of widening the page. */
  @media (max-width: 639px) {
    .hq-card__head { flex-wrap: wrap; }
    .hq-card__meta { min-width: 0; overflow-wrap: anywhere; }
  }
}

/* ------------------------------------------------------------------ */
/* Home V2 (2026-11-18): the compact executive dashboard               */
/* ------------------------------------------------------------------ */

@layer components {
  /* Denser Home: one padding and header rhythm for every card. */
  .hq-home { --gap: 20px; }
  .hq-home > .hq-card { padding: 22px 22px 20px; }
  .hq-home .hq-card__head { margin-bottom: 14px; min-height: 26px; }
  .hq-home .hq-pulse__item { padding: 16px 22px; }
  .hq-home .hq-pulse__value { font-size: 26px; }
  .hq-card__eyebrow { margin-left: 6px; font-family: var(--font-sans); font-size: 11px; font-weight: 700; letter-spacing: 0.08em; color: var(--text-subtle); }
  .icon.is-flipped { transform: rotate(180deg); }
  @media (max-width: 639px) { .hq-home > .hq-card { padding: 18px 16px 16px; } }

  /* Beside the projects: revenue by type of work on top, TESLA's daily
     message below it filling the rest of the row. */
  .hq-home-side { display: flex; flex-direction: column; gap: var(--gap); min-width: 0; }
  .hq-home-side > .hq-card { padding: 22px 22px 20px; }
  .hq-home-side > .hq-tesla-daily { flex: 1 1 auto; }
  @media (max-width: 639px) { .hq-home-side > .hq-card { padding: 18px 16px 16px; } }

  /* Beside the receivables: Requires attention keeps its own height, the
     ideas notebook fills the rest of the column. */
  .hq-home-side > .hq-attention { align-self: stretch; }
  .hq-home-side > .hq-ideas { flex: 1 1 auto; }

  /* Ideas and suggestions about ETC HQ (hq/ideas.py): on Home a title, one
     line and the writing box, which grows to fill the column; the notes are
     read in System. Blue accents only: no orange (TESLA and priority) and no
     red (errors). */
  .hq-ideas { display: flex; flex-direction: column; min-height: 0; }
  .hq-ideas__head { display: grid; gap: 4px; margin-bottom: 14px; }
  .hq-ideas__lead { margin: 0; font-size: 13px; line-height: 1.45; color: var(--text-subtle); }
  .hq-ideas__form { display: flex; flex-direction: column; flex: 1 1 auto; }
  .hq-ideas__box { position: relative; display: flex; flex: 1 1 auto; }
  .hq-ideas__box textarea {
    display: block; flex: 1 1 auto; width: 100%; min-height: 84px; padding: 11px 54px 11px 13px;
    border: 1px solid var(--line-strong); border-radius: 14px; font: inherit; font-size: 16px; line-height: 1.45;
    color: var(--text); background: rgb(var(--navy-rgb) / 0.55); color-scheme: dark; resize: none;
  }
  @media (min-width: 640px) { .hq-ideas__box textarea { font-size: 14px; } }
  @media (max-width: 639px) { .hq-ideas__box textarea { min-height: 100px; } }
  .hq-ideas__box textarea::placeholder { color: var(--text-subtle); }
  .hq-ideas__box textarea:focus-visible { outline: none; border-color: var(--blue-400); box-shadow: 0 0 0 3px rgb(var(--blue-rgb) / 0.22); }
  .hq-ideas__send {
    position: absolute; right: 8px; bottom: 8px; display: grid; place-items: center; width: 38px; height: 38px;
    border: 0; border-radius: 11px; color: #fff; background: var(--blue-500); cursor: pointer;
    box-shadow: 0 6px 16px -6px rgb(var(--blue-rgb) / 0.7);
    -webkit-tap-highlight-color: transparent; touch-action: manipulation;
    transition: transform var(--dur-fast) var(--ease-out), box-shadow var(--dur-fast) var(--ease-out);
  }
  .hq-ideas__send .icon { width: 17px; height: 17px; }
  .hq-ideas__send:hover { box-shadow: 0 0 0 3px rgb(var(--blue-rgb) / 0.22), 0 8px 18px -6px rgb(var(--blue-rgb) / 0.8); }
  .hq-ideas__send:active { transform: scale(var(--press-scale, 0.97)); }
  .hq-ideas__send:focus-visible { outline: 2px solid var(--blue-400); outline-offset: 2px; }

  /* System, "Ideas and suggestions": the notes by status. */
  .hq-ideas-review__head { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 12px; }
  .hq-ideas-review__head .hq-segmented { margin-left: auto; }
  @media (max-width: 639px) {
    .hq-ideas-review__head .hq-segmented { flex: 1 1 100%; flex-wrap: nowrap; margin-left: 0; }
    .hq-ideas-review__head .hq-segmented__item { flex: 1 1 0; justify-content: center; min-width: 0; padding-inline: 8px; }
  }
  .hq-ideas__list { display: grid; gap: 10px; margin: 16px 0 0; padding: 0; list-style: none; }
  .hq-ideas__item {
    display: grid; grid-template-columns: 1fr auto; grid-template-areas: "text actions" "meta actions";
    gap: 6px 12px; padding: 14px 14px 13px 16px; border-radius: 14px;
    background: rgb(var(--fg-rgb) / 0.035); box-shadow: inset 0 0 0 1px var(--line);
  }
  .hq-ideas__text { grid-area: text; margin: 0; font-size: 14.5px; line-height: 1.5; color: var(--text); white-space: pre-line; overflow-wrap: anywhere; }
  .hq-ideas__meta { grid-area: meta; margin: 0; font-size: 12.5px; color: var(--text-subtle); }
  .hq-ideas__actions { grid-area: actions; align-self: start; display: flex; gap: 4px; margin: -4px -4px 0 0; }
  .hq-ideas__act {
    display: grid; place-items: center; width: 34px; height: 34px; border: 0; border-radius: 10px;
    color: var(--text-subtle); background: transparent; cursor: pointer; -webkit-tap-highlight-color: transparent;
    transition: color var(--dur-fast) var(--ease-out), background var(--dur-fast) var(--ease-out);
  }
  .hq-ideas__act .icon { width: 16px; height: 16px; }
  .hq-ideas__act:hover { color: var(--text); background: rgb(var(--fg-rgb) / 0.08); }
  .hq-ideas__act--done:hover { color: var(--green); background: rgb(var(--green-rgb) / 0.12); }
  .hq-ideas__act:focus-visible { outline: 2px solid var(--blue-400); outline-offset: 1px; }

  /* TESLA's daily message: his greeting pose at the edge, the message and
     an orange key to his page. */
  .hq-tesla-daily { position: relative; display: flex; align-items: stretch; overflow: hidden; isolation: isolate; min-height: 210px; }
  .hq-tesla-daily__figure {
    position: absolute;
    right: 14px;
    bottom: -8px;
    z-index: 0;
    width: auto;
    height: min(92%, 210px);
    opacity: 0.95;
    pointer-events: none;
    -webkit-mask-image: linear-gradient(90deg, transparent 8%, #000 42%);
    mask-image: linear-gradient(90deg, transparent 8%, #000 42%);
  }
  .hq-tesla-daily__body { position: relative; z-index: 1; display: flex; flex-direction: column; align-items: flex-start; gap: 8px; max-width: 54%; }
  .hq-tesla-daily__from { display: flex; align-items: center; gap: 8px; margin: 0; font-size: 12px; color: var(--text-subtle); }
  .hq-tesla-daily__from strong { font-family: var(--font-display); font-size: 12px; letter-spacing: 0.08em; color: var(--tesla-text); }
  .hq-tesla-daily__title { margin: 2px 0 0; font-family: var(--font-display); font-size: 20px; line-height: 1.2; color: var(--text); }
  /* The open tasks: a quiet glass button to Tasks (owner, 2026-11-27). */
  .hq-tesla-daily__tasks { margin: 2px 0 12px; }
  .hq-tesla-daily__tasks a {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border: 1px solid var(--line-strong, rgba(255, 255, 255, 0.16));
    border-radius: 12px;
    font-size: 13px;
    font-weight: 600;
    line-height: 1.35;
    color: var(--text);
    background: rgba(255, 255, 255, 0.06);
    text-decoration: none;
    transition: background var(--dur-fast) var(--ease-out), border-color var(--dur-fast) var(--ease-out), transform var(--dur-fast) var(--ease-out);
  }
  .hq-tesla-daily__tasks a .icon { flex: none; width: 16px; height: 16px; color: var(--text-muted); }
  .hq-tesla-daily__tasks a:hover { background: rgba(255, 255, 255, 0.11); border-color: rgba(255, 255, 255, 0.26); }
  .hq-tesla-daily__tasks a:active { transform: translateY(1px) scale(var(--press-scale)); }
  .hq-tesla-daily__tasks a:focus-visible { outline: 2px solid var(--blue, #438BFF); outline-offset: 2px; }
  .hq-tesla-daily__go {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-top: auto;
    height: 40px;
    padding: 0 16px;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 700;
    color: #fff;
    background: linear-gradient(180deg, #ff8233, var(--orange) 55%, #e65a00);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.35), 0 1px 1px rgba(0, 0, 0, 0.4), 0 10px 22px -8px rgb(var(--orange-rgb) / 0.8);
    text-decoration: none;
    transition: box-shadow var(--dur-fast) var(--ease-out), transform var(--dur-fast) var(--ease-out);
  }
  .hq-tesla-daily__go .icon { width: 16px; height: 16px; }
  .hq-tesla-daily__go:hover { box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.35), 0 0 0 3px rgb(var(--orange-rgb) / 0.22), 0 12px 26px -8px rgb(var(--orange-rgb) / 0.9); }
  .hq-tesla-daily__go:active { transform: translateY(1px) scale(var(--press-scale)); }
  .hq-tesla-daily__go:focus-visible { outline: 2px solid var(--orange-300); outline-offset: 2px; }

  /* Result of the month: smaller figures, chart at about half height. */
  .hq-result .hq-ledger { margin-bottom: 10px; }
  .hq-result .hq-ledger__value { font-size: clamp(22px, 1.2vw + 9px, 30px); }
  .hq-result .hq-ledger__value--result { font-size: clamp(26px, 1.7vw + 10px, 38px); }
  .hq-result .hq-ledger__item--result { padding: 10px 14px 12px; }
  /* A narrow result card (1200-1500 px screens): revenue and costs side by
     side, the result on its own line, so no figure is ever clipped. */
  @container (max-width: 660px) {
    .hq-result .hq-ledger { grid-template-columns: 1fr 1fr; gap: 12px 16px; }
    .hq-result .hq-ledger__op { display: none; }
    .hq-result .hq-ledger__item--result { grid-column: 1 / -1; margin: 0; display: flex; align-items: baseline; flex-wrap: wrap; gap: 4px 16px; }
    .hq-result .hq-ledger__item--result .hq-ledger__label { flex-basis: 100%; }
    .hq-result .hq-ledger__item--result .hq-ledger__value { margin-top: 0; }
    .hq-result .hq-ledger__margin { margin-top: 0; }
  }

  /* Costs: donut of the categories, legend with share and amount. */
  .hq-costs__body { display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: center; gap: 18px; }
  .hq-donut--costs { width: clamp(150px, 36cqi, 168px); }
  .hq-donut--costs .hq-donut__center { inset: 14%; }
  .hq-donut--costs .hq-donut__label { font-size: 11px; line-height: 1.2; }
  .hq-donut--costs .hq-donut__value { font-size: 16px; }
  @container (max-width: 420px) {
    .hq-costs__body { grid-template-columns: 1fr; justify-items: center; gap: 14px; }
    .hq-costs__legend { width: 100%; }
  }
  .hq-costs__legend { display: grid; gap: 2px; font-size: 13px; }
  .hq-costs__legend li {
    display: grid;
    grid-template-columns: 10px minmax(4.5rem, 1fr) auto auto;
    align-items: center;
    gap: 10px;
    padding: 5px 6px;
    border-radius: 8px;
    transition: background-color var(--dur-fast) var(--ease-out);
  }
  .hq-costs__legend li:hover { background: rgb(var(--fg-rgb) / 0.04); }
  .hq-costs__label { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-muted); }
  .hq-costs__share { font-size: 12px; font-weight: 600; color: var(--text-subtle); font-variant-numeric: tabular-nums; }
  .hq-costs__legend strong { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
  .hq-cost-arc--1 { stroke: var(--series-1); }
  .hq-cost-arc--2 { stroke: var(--series-2); }
  .hq-cost-arc--3 { stroke: var(--series-3); }
  .hq-cost-arc--4 { stroke: var(--series-4); }
  .hq-cost-arc--5 { stroke: var(--series-5); }
  .hq-cost-arc--6 { stroke: var(--series-6); }
  .hq-cost-swatch--1 { background: var(--series-1); }
  .hq-cost-swatch--2 { background: var(--series-2); }
  .hq-cost-swatch--3 { background: var(--series-3); }
  .hq-cost-swatch--4 { background: var(--series-4); }
  .hq-cost-swatch--5 { background: var(--series-5); }
  .hq-cost-swatch--6 { background: var(--series-6); }

  /* Construction projects: fixed columns, work types under each project. */
  .hq-ptable { --pcols: minmax(0, 1fr) 5.2rem 5.2rem 7.4rem; display: grid; font-size: 13.5px; }
  .hq-ptable--no-revenue { --pcols: minmax(0, 1fr) 5.2rem 5.2rem; }
  .hq-ptable__head, .hq-ptable__row { display: grid; grid-template-columns: var(--pcols); align-items: center; gap: 0 14px; }
  .hq-ptable__head { padding: 0 8px 8px; font-size: 11.5px; font-weight: 650; letter-spacing: 0.04em; text-transform: uppercase; color: var(--text-subtle); border-bottom: 1px solid var(--line); }
  .hq-ptable .is-num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
  .hq-ptable__group { padding: 8px; border-radius: 12px; transition: background-color var(--dur-fast) var(--ease-out); }
  .hq-ptable__group + .hq-ptable__group { border-top: 1px solid var(--line-soft); border-radius: 0 0 12px 12px; }
  .hq-ptable__group:hover { background: rgb(var(--fg-rgb) / 0.03); }
  .hq-ptable__project { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; min-height: 30px; }
  .hq-ptable__name a, .hq-ptable__name { display: inline-flex; align-items: center; gap: 8px; min-width: 0; color: var(--text); text-decoration: none; }
  .hq-ptable__name a .icon { width: 15px; height: 15px; color: var(--text-subtle); transition: transform var(--dur-fast) var(--ease-out), color var(--dur-fast) var(--ease-out); }
  .hq-ptable__name a:hover .icon { transform: translateX(2px); color: var(--blue-300); }
  .hq-ptable__name a:hover .hq-ptable__title { color: var(--blue-300); }
  .hq-ptable__title { font-weight: 700; font-size: 14.5px; }
  .hq-ptable__code { font-size: 11.5px; font-weight: 700; letter-spacing: 0.04em; color: var(--text-subtle); font-variant-numeric: tabular-nums; }
  .hq-ptable__flags { display: flex; flex-wrap: wrap; gap: 6px; margin-left: auto; }
  .hq-pstatus, .hq-pwork { display: inline-flex; align-items: center; gap: 6px; height: 22px; padding: 0 9px; border-radius: 999px; font-size: 11.5px; font-weight: 650; white-space: nowrap; }
  .hq-pstatus { color: var(--text-muted); background: rgb(var(--fg-rgb) / 0.05); box-shadow: inset 0 0 0 1px var(--line); }
  .hq-pstatus--active { color: var(--ok-text); background: rgb(var(--green-rgb) / 0.12); box-shadow: none; }
  .hq-pstatus--paused { color: var(--warn); background: rgb(var(--warn-rgb) / 0.10); box-shadow: none; }
  .hq-pstatus--completed { color: var(--blue-300); background: rgb(var(--blue-rgb) / 0.12); box-shadow: none; }
  .hq-pwork { color: var(--text-subtle); }
  .hq-pwork::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: 0.6; }
  .hq-pwork.is-on { color: var(--blue-300); }
  .hq-pwork.is-on::before { opacity: 1; box-shadow: 0 0 0 3px rgb(var(--blue-rgb) / 0.18); }
  .hq-ptable__row { padding: 5px 0; }
  .hq-ptable__row + .hq-ptable__row { border-top: 1px dashed var(--line-soft); }
  .hq-ptable__project + .hq-ptable__row { margin-top: 4px; }
  .hq-ptable__type { position: relative; padding-left: 16px; color: var(--text-muted); font-weight: 600; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .hq-ptable__type::before { content: ""; position: absolute; left: 3px; top: 50%; width: 7px; height: 7px; border-radius: 2px; background: var(--blue-500); transform: translateY(-50%); opacity: 0.75; }
  .hq-ptable__type small { font-weight: 500; color: var(--text-subtle); }
  .hq-ptable__row .is-num { font-family: var(--font-display); font-weight: 600; font-size: 14px; }
  .hq-ptable__money { color: var(--text); }
  .hq-ptable__group.is-idle .hq-ptable__title { color: var(--text-muted); }
  @container (max-width: 520px) {
    .hq-ptable { --pcols: minmax(0, 1fr) 3.8rem 3.8rem 5.8rem; font-size: 12.5px; }
    .hq-ptable--no-revenue { --pcols: minmax(0, 1fr) 3.8rem 3.8rem; }
    .hq-ptable__head, .hq-ptable__row { gap: 0 8px; }
    .hq-ptable__flags { margin-left: 0; }
    .hq-ptable__type { white-space: normal; }
  }

  /* Weekly KARNET */
  .hq-karnet__head { flex-wrap: wrap; row-gap: 10px; }
  .hq-karnet__range { margin-left: 0; color: var(--text-muted); }
  .hq-karnet__tools { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-left: auto; }
  .hq-segmented--small { padding: 3px; }
  .hq-segmented--small .hq-segmented__item { min-height: 28px; padding: 0 12px; font-size: 12.5px; }
  .hq-weeknav { display: inline-flex; align-items: center; gap: 2px; padding: 3px; border-radius: 12px; background: var(--glass-0); box-shadow: inset 0 0 0 1px var(--line); }
  .hq-weeknav__step, .hq-weeknav__today { display: inline-grid; place-items: center; height: 28px; border-radius: 9px; color: var(--text-muted); transition: color var(--dur-fast) var(--ease-out), background-color var(--dur-fast) var(--ease-out); }
  .hq-weeknav__step { width: 28px; }
  .hq-weeknav__step .icon { width: 16px; height: 16px; }
  .hq-weeknav__today { padding: 0 10px; font-size: 12.5px; font-weight: 650; }
  .hq-weeknav a:hover { color: var(--text); background: rgb(var(--fg-rgb) / 0.06); }
  .hq-weeknav__today[aria-current="true"] { color: var(--blue-300); }
  .hq-karnet__scroll { overflow-x: auto; margin: 0 -4px; padding: 0 4px; }
  .hq-kgrid { width: 100%; min-width: 620px; border-collapse: separate; border-spacing: 0; table-layout: fixed; font-size: 13px; }
  .hq-kgrid th, .hq-kgrid td { padding: 0 4px; text-align: center; vertical-align: middle; }
  .hq-kgrid thead th { padding: 6px 4px 8px; }
  .hq-kgrid .hq-kgrid__label { width: 22%; text-align: left; font-weight: 650; padding-left: 8px; }
  .hq-kgrid tbody .hq-kgrid__label, .hq-kgrid tfoot .hq-kgrid__label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .hq-kgrid__label small { display: block; font-size: 11.5px; font-weight: 500; color: var(--text-subtle); }
  .hq-kgrid__label a { color: var(--text); text-decoration: none; }
  .hq-kgrid__label a:hover { color: var(--blue-300); }
  .hq-kgrid__dow { display: block; font-size: 11px; font-weight: 650; letter-spacing: 0.05em; text-transform: uppercase; color: var(--text-subtle); }
  .hq-kgrid__date { display: block; font-family: var(--font-display); font-size: 16px; font-weight: 600; font-variant-numeric: tabular-nums; }
  .hq-kgrid__day.is-weekend .hq-kgrid__date { color: var(--text-muted); }
  .hq-kgrid__day.is-today { border-radius: 12px 12px 0 0; background: rgb(var(--blue-rgb) / 0.14); }
  .hq-kgrid__day.is-today .hq-kgrid__dow, .hq-kgrid__day.is-today .hq-kgrid__date { color: var(--blue-300); }
  .hq-kgrid__total { width: 8%; font-family: var(--font-display); font-weight: 600; font-variant-numeric: tabular-nums; color: var(--text-muted); }
  .hq-kgrid thead .hq-kgrid__total { font-family: var(--font-sans); font-size: 11px; font-weight: 650; letter-spacing: 0.05em; text-transform: uppercase; color: var(--text-subtle); }
  .hq-kgrid tbody tr > * { height: 40px; border-top: 1px solid var(--line-soft); }
  .hq-kgrid tbody tr:hover > * { background-color: rgb(var(--fg-rgb) / 0.025); }
  .hq-kgrid td.is-today { background: rgb(var(--blue-rgb) / 0.07); }
  .hq-kgrid tbody tr:hover > td.is-today { background: rgb(var(--blue-rgb) / 0.11); }
  .hq-kgrid tfoot tr > * { height: 40px; border-top: 1px solid var(--line-strong); font-family: var(--font-display); font-weight: 650; font-variant-numeric: tabular-nums; }
  .hq-kgrid tfoot .hq-kgrid__label { font-family: var(--font-sans); font-size: 12.5px; color: var(--text-muted); }
  .hq-kgrid tfoot td.is-today { border-radius: 0 0 12px 12px; background: rgb(var(--blue-rgb) / 0.14); color: var(--blue-300); }
  .hq-kcount {
    display: inline-grid;
    place-items: center;
    min-width: 34px;
    height: 26px;
    padding: 0 6px;
    border-radius: 8px;
    font-family: var(--font-display);
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    background: color-mix(in srgb, var(--blue-500) calc(var(--fill, 0%) * 0.42), rgb(var(--fg-rgb) / 0.04));
    box-shadow: inset 0 0 0 1px rgb(var(--blue-rgb) / 0.18);
  }
  .hq-kcount.is-zero { color: var(--text-subtle); background: rgb(var(--fg-rgb) / 0.03); box-shadow: inset 0 0 0 1px var(--line-soft); }
  .hq-kmark { display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 7px; font-weight: 700; line-height: 1; }
  .hq-kmark .icon { width: 13px; height: 13px; }
  .hq-kmark--da { color: var(--blue-300); background: rgb(var(--blue-rgb) / 0.18); }
  .hq-kmark--x { color: var(--text-subtle); background: rgb(var(--fg-rgb) / 0.05); font-size: 15px; }
  .hq-kmark--other { color: var(--warn); background: rgb(var(--warn-rgb) / 0.12); font-size: 12px; }
  .hq-kmark--none { color: var(--text-subtle); background: none; }
  .hq-kgrid tbody tr.is-first:not(:first-child) > * { border-top-color: var(--line); }
  .hq-karnet__legend { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 18px; margin-top: 12px; font-size: 12px; color: var(--text-subtle); }
  .hq-karnet__legend > span { display: inline-flex; align-items: center; gap: 6px; }
  .hq-karnet__legend .hq-kmark { width: 18px; height: 18px; border-radius: 6px; }
  .hq-karnet__legend .hq-kmark .icon { width: 11px; height: 11px; }
  .hq-karnet__sum { margin-left: auto; font-weight: 650; color: var(--text-muted); }

  /* Team performance (UČINAK) */
  .hq-perf__stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin-bottom: 14px; }
  .hq-perf__stats > div { position: relative; display: grid; gap: 2px; align-content: start; padding: 10px 12px; border-radius: 12px; background: var(--glass-0); box-shadow: inset 0 0 0 1px var(--line-soft); }
  .hq-perf__stats dt { font-size: 11.5px; font-weight: 600; color: var(--text-subtle); }
  .hq-perf__stats dd { font-family: var(--font-display); font-size: 20px; font-weight: 600; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; white-space: nowrap; }
  .hq-perf__stats dd small { font-family: var(--font-sans); font-size: 12px; font-weight: 600; color: var(--text-subtle); }
  .hq-perf__calc { font-size: 11px; font-weight: 600; color: var(--text-subtle); }
  .hq-perf__teams { display: grid; gap: 12px; }
  .hq-perf__team { display: grid; grid-template-columns: 5.2rem minmax(0, 1fr) 5.4rem; grid-template-areas: "name track value" ". meta meta"; align-items: center; gap: 2px 12px; }
  .hq-perf__name { grid-area: name; font-weight: 700; font-size: 13.5px; white-space: nowrap; }
  .hq-perf__track { grid-area: track; display: block; height: 8px; border-radius: 8px; background: rgb(var(--fg-rgb) / 0.06); overflow: hidden; }
  .hq-perf__value { grid-area: value; text-align: right; font-family: var(--font-display); font-weight: 600; font-size: 15px; font-variant-numeric: tabular-nums; white-space: nowrap; }
  .hq-perf__value small { font-family: var(--font-sans); font-size: 11.5px; color: var(--text-subtle); }
  .hq-perf__meta { grid-area: meta; font-size: 12px; color: var(--text-subtle); }
  .hq-perf__meta strong { color: var(--text-muted); font-variant-numeric: tabular-nums; }
  @container (max-width: 380px) { .hq-perf__stats { grid-template-columns: 1fr 1fr; } }

  /* Completed apartments */
  .hq-apts__scroll { max-height: 312px; overflow: auto; margin: 0 -6px; scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent; }
  .hq-apts__table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13px; }
  .hq-apts__table th, .hq-apts__table td { padding: 7px 6px; text-align: left; vertical-align: middle; white-space: nowrap; }
  .hq-apts__table thead th { position: sticky; top: 0; z-index: 1; font-size: 11.5px; font-weight: 650; letter-spacing: 0.04em; text-transform: uppercase; color: var(--text-subtle); background: var(--surface-solid); border-bottom: 1px solid var(--line); }
  .hq-apts__table tbody > tr > * { border-top: 1px solid var(--line-soft); }
  .hq-apts__table tbody tr:first-child > * { border-top: 0; }
  .hq-apts__table tbody tr:hover > * { background: rgb(var(--fg-rgb) / 0.03); }
  .hq-apts__table .is-num { text-align: right; font-variant-numeric: tabular-nums; }
  .hq-apts__table td.is-num { font-family: var(--font-display); font-weight: 600; }
  .hq-apts__table small { font-size: 12px; color: var(--text-subtle); }
  .hq-apts__table th small { display: block; font-weight: 500; }
  .hq-apts__unit { font-family: var(--font-display); font-weight: 600; font-size: 14px; font-variant-numeric: tabular-nums; }
  .hq-apts__phase { display: inline-block; margin-right: 4px; padding: 1px 8px; border-radius: 999px; font-size: 11.5px; font-weight: 650; color: var(--blue-300); background: rgb(var(--blue-rgb) / 0.12); }

  /* TESLA in its own row: note beside three opportunities. */
  .hq-tesla-row .hq-opp { height: 100%; }
  .hq-tesla-row .hq-opps > li { display: grid; }
  .hq-tesla-row .hq-opp__head { flex-direction: column; gap: 6px; }
  .hq-tesla-row .hq-opp__title { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
  .hq-tesla-row .hq-opp__why { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
  .hq-tesla-row .hq-opp__next > span { display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; }
  .hq-tesla-row .hq-opp__body { align-content: start; }
  @media (min-width: 900px) {
    .hq-tesla-row .hq-opps { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
  }
  /* TESLA's note on one line above the cards: a small figure beside it. */
  .hq-tesla-row .hq-report { grid-template-columns: 78px minmax(0, 1fr); align-items: center; gap: 10px; margin: -4px 0 14px; }
  .hq-tesla-row .hq-report__bubble { padding: 12px 16px; }
  .hq-tesla-row .hq-report__bubble::before { top: 50%; margin-top: -7px; }
  .hq-tesla-row .hq-report__headline { margin-top: 2px; font-size: 16px; }
  .hq-tesla-row .hq-report__text { margin-top: 2px; font-size: 13px; line-height: 1.5; }
  .hq-tesla-row .hq-report__meta { margin-top: 4px; }

  /* Performance indicators: one slim row of tiles. */
  .hq-tiles--inline { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 10px; }
  .hq-tiles--inline .hq-tile { padding: 12px 14px; }
  .hq-tiles--inline .hq-tile__value { font-size: 21px; }
}

@layer motion {
  @media (prefers-reduced-motion: no-preference) {
    .hq-motion .is-revealed .hq-kcount,
    .hq-motion .is-revealed .hq-kmark,
    .hq-motion .is-revealed .hq-apts__table tbody tr { animation: hq-fade 520ms var(--ease-out) 320ms both; }
  }
}

/* ── Profiles: locked actions and veiled cards ───────────────────────────
   An action the account may see but not use keeps its place and its look,
   with a lock in place of its icon; it is a plain element, never a link or a
   form. A veiled card keeps its title above a blurred placeholder: nothing
   of its real content is sent to the page. */
@layer components {
  .is-locked[aria-disabled="true"] {
    cursor: not-allowed;
    opacity: 0.55;
    box-shadow: none;
    filter: saturate(0.4);
  }
  .is-locked[aria-disabled="true"]:hover { background: inherit; }
  .is-locked[aria-disabled="true"] .icon { color: currentColor; }

  .hq-veil { position: relative; display: grid; min-height: 168px; overflow: hidden; border-radius: 14px; }
  .hq-veil__ghost {
    display: grid; align-content: start; gap: 14px; padding: 18px 4px;
    filter: blur(7px); opacity: 0.75; user-select: none; pointer-events: none;
  }
  .hq-veil__ghost--figure { grid-template-columns: 120px 1fr; column-gap: 20px; }
  .hq-veil__figure { grid-row: span 6; width: 120px; height: auto; }
  .hq-veil__line { display: block; height: 12px; width: var(--w, 80%); border-radius: 6px; background: rgb(var(--fg-rgb) / 0.22); }
  .hq-veil__line--strong { height: 16px; background: rgb(var(--fg-rgb) / 0.34); }
  .hq-veil__note {
    position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; gap: 8px;
    margin: 0; padding: 16px; text-align: center; font-size: 13.5px; font-weight: 650; color: var(--text-muted);
  }
  .hq-veil__note .icon { width: 15px; height: 15px; flex: none; }
}
