/* ============================================================================
   Eletek Reports Dashboard — design system
   ----------------------------------------------------------------------------
   A dense analytics tool. Compact spacing, hairline rules, information-rich
   rows. Usable at 1280px, does not break at 1024px.

   All colour/space/type is a custom property on :root. Dark mode is SELECTED,
   not an automatic flip: its own steps, validated against the dark surface.
   Declared under both the media query (OS setting) and [data-theme] (the in-app
   toggle), with the toggle winning both ways.
   ========================================================================= */

/* ─────────────────────────────────────────────────────────── 1. TOKENS ── */

:root {
  color-scheme: light;

  /* surfaces ------------------------------------------------------------ */
  --plane:        #f4f4f1;   /* page background, behind the cards           */
  --surface-1:    #fcfcfb;   /* card & chart surface (validator surface)    */
  --surface-2:    #f2f1ed;   /* table header, hover wash, inset fills       */
  --surface-3:    #e9e8e2;   /* pressed, track                             */
  --surface-nav:  #fcfcfb;

  /* ink ----------------------------------------------------------------- */
  --text-1:       #0b0b0b;
  --text-2:       #52514e;
  --text-3:       #898781;   /* axis / muted labels                        */

  /* lines --------------------------------------------------------------- */
  --grid:         #e1e0d9;   /* gridline hairline, one step off surface    */
  --axis:         #c3c2b7;
  --border:       rgba(11, 11, 11, .10);
  --border-2:     rgba(11, 11, 11, .18);

  /* categorical slots — fixed order, never cycled ----------------------- */
  --c1: #2a78d6;  /* blue    */
  --c2: #eb6834;  /* orange  */
  --c3: #1baf7a;  /* aqua    */
  --c4: #eda100;  /* yellow  */
  --c5: #e87ba4;  /* magenta */
  --c6: #008300;  /* green   */
  --c7: #4a3aa7;  /* violet  */
  --c8: #e34948;  /* red     */
  --series-other: #a3a29b;   /* the «Інші» fold, never a 9th hue           */

  /* brand identity — a brand is drawn in its own colour on every chart
     (format.js BRAND_TOKENS). The exact official hex, one value for both themes: a brand
     recolour «for contrast» reads as the wrong brand. Monochrome brands (Edifier, Glorious, FL Esports) get
     neutral slots from the palette in format.js instead. */
  --brand-hator:       #f7ea48;  /* hator.com: theme-color and the logo file       */
  --brand-razer:       #44d62c;  /* razer.com                                     */
  --brand-rapoo:       #6c16fa;  /* rapoo.com violet                              */
  --brand-steelseries: #ff5200;  /* SteelSeries orange (their style guide)        */
  --brand-logitech:    #00b8fc;  /* Logitech G blue                               */
  --brand-hyperx:      #e31837;  /* HyperX red                                    */

  /* client identity — the retailer's logo colour, one value for both themes.
     Two near-identical colours never meet on a chart: the smaller client takes
     a free palette hue (format.js assigned()). Ябко and CompX have no single
     logo colour and get a palette hue. */
  --client-comfy:       #fc5e0f;  /* comfy.ua logo, orange end                    */
  --client-foxtrot:     #e95d2a;  /* Foxtrot_logo.svg, Wikimedia Commons           */
  --client-rozetka:     #05bc52;  /* rozetka.com.ua logo                           */
  --client-brain:       #33d0ff;  /* brain.com.ua og image / touch icon            */
  --client-3ona51:      #a5d300;  /* 3ona51.com z51_logo_new.svg                    */
  --client-allo:        #e00028;  /* Allo logo, Wikimedia Commons                  */
  --client-telemart:    #a2c617;  /* telemart.ua theme-color and logo              */
  --client-dclink:      #1444e3;  /* dclink.ua logo                                */
  --client-citrus:      #ff680a;  /* citrus.ua logo                                */
  --client-ktc:         #20b1a9;  /* ktc.ua og logo                                */
  --client-artline:     #19bcc9;  /* artline.ua header logo                        */
  --client-kv:          #2880ba;  /* kvshop.com.ua og logo                         */
  --client-kibernetiky: #fcc703;  /* kibernetiki.com.ua favicon.svg                */
  --client-elmir:       #1890e0;  /* elmir.ua touch icon                           */
  --client-mta:         #2c80e5;  /* mta.ua favicon                                */
  --client-izona:       #e51e23;  /* izona.store logo                              */
  --client-expert:      #ff6600;  /* EXPERT chain favicon — confirm it is the partner */
  --client-epicentr:    #1060c1;  /* epicentrk.ua theme-color                      */
  --client-vodafone:    #e60000;  /* vodafone.ua logo                              */
  --client-yabluka:     #ffec00;  /* yabloki.ua favicon                            */
  --client-dzvinok:     #509c58;  /* dzvinok.ua logo                               */

  /* sequential blue ramp (magnitude): one hue, light → dark.
     The NAMED STEPS are mode-invariant (they name positions on one ramp);
     only the chart ramp ORDER flips per mode, via --seq-stops, so that "near
     zero" always recedes toward that mode's surface. */
  --seq-100: #cde2fb; --seq-200: #9ec5f4; --seq-250: #86b6ef; --seq-300: #6da7ec;
  --seq-400: #3987e5; --seq-500: #256abf; --seq-600: #184f95; --seq-700: #0d366b;
  --seq-stops: #cde2fb, #9ec5f4, #6da7ec, #3987e5, #256abf, #184f95, #0d366b;

  /* ABC is an ORDINAL scale (A→B→C is ordered), so it takes one-hue steps,
     not categorical slots. Each step clears 2:1 against its own surface. */
  --abc-a-bg: #256abf; --abc-a-fg: #ffffff;
  --abc-b-bg: #86b6ef; --abc-b-fg: #0d366b;

  /* diverging: two poles + NEUTRAL grey midpoint ------------------------- */
  --div-up:   #2a78d6;
  --div-mid:  #f0efec;
  --div-down: #e34948;

  /* status — reserved, never «series 4». Always shipped with icon+label -- */
  --good:     #0ca30c;
  --warning:  #fab219;
  --serious:  #ec835a;
  --critical: #d03b3b;
  --delta-up:   #006300;
  --delta-down: #c0302f;

  /* accent chrome -------------------------------------------------------- */
  --accent:      #2a78d6;
  --accent-ink:  #184f95;
  --accent-wash: rgba(42, 120, 214, .10);
  --focus:       #2a78d6;

  /* type ----------------------------------------------------------------- */
  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --fs-10: 10px; --fs-11: 11px; --fs-12: 12px; --fs-13: 13px;
  --fs-15: 15px; --fs-18: 18px; --fs-22: 22px; --fs-28: 28px; --fs-40: 40px;
  --lh-tight: 1.2; --lh: 1.4;

  /* spacing — compact scale for a dense tool ----------------------------- */
  --sp-1: 2px;  --sp-2: 4px;  --sp-3: 6px;  --sp-4: 8px;
  --sp-5: 12px; --sp-6: 16px; --sp-7: 20px; --sp-8: 24px; --sp-9: 32px;

  --r-1: 3px; --r-2: 5px; --r-3: 8px; --r-4: 12px;
  --shadow-1: 0 1px 2px rgba(11, 11, 11, .05);
  --shadow-2: 0 6px 24px rgba(11, 11, 11, .12);

  /* layout --------------------------------------------------------------- */
  --nav-w: 198px;
  --header-h: 46px;
  --filter-h: 46px;
}

/* dark: same hues, re-stepped for the dark surface and validated there.
   The :not() guard lets an explicit light stamp beat OS-dark; :where() keeps
   this block's specificity below the [data-theme] scope beneath it. */
@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    color-scheme: dark;
    --plane:       #0d0d0d;
    --surface-1:   #1a1a19;
    --surface-2:   #232321;
    --surface-3:   #2c2c2a;
    --surface-nav: #151514;
    --text-1:      #ffffff;
    --text-2:      #c3c2b7;
    --text-3:      #898781;
    --grid:        #2c2c2a;
    --axis:        #383835;
    --border:      rgba(255, 255, 255, .10);
    --border-2:    rgba(255, 255, 255, .18);
    --c1: #3987e5; --c2: #d95926; --c3: #199e70; --c4: #c98500;
    --c5: #d55181; --c6: #008300; --c7: #9085e9; --c8: #e66767;
    --series-other: #6f6e69;
    --seq-stops: #0d366b, #184f95, #256abf, #3987e5, #6da7ec, #9ec5f4, #cde2fb;
    --abc-a-bg: #256abf; --abc-a-fg: #ffffff;
    --abc-b-bg: #184f95; --abc-b-fg: #9ec5f4;
    --div-up: #3987e5; --div-mid: #383835; --div-down: #e66767;
    --accent: #3987e5; --accent-ink: #86b6ef;
    --accent-wash: rgba(57, 135, 229, .16);
    --focus: #6da7ec;
    --delta-up: #0ca30c; --delta-down: #e66767;
    --shadow-1: 0 1px 2px rgba(0, 0, 0, .40);
    --shadow-2: 0 6px 24px rgba(0, 0, 0, .55);
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --plane:       #0d0d0d;
  --surface-1:   #1a1a19;
  --surface-2:   #232321;
  --surface-3:   #2c2c2a;
  --surface-nav: #151514;
  --text-1:      #ffffff;
  --text-2:      #c3c2b7;
  --text-3:      #898781;
  --grid:        #2c2c2a;
  --axis:        #383835;
  --border:      rgba(255, 255, 255, .10);
  --border-2:    rgba(255, 255, 255, .18);
  --c1: #3987e5; --c2: #d95926; --c3: #199e70; --c4: #c98500;
  --c5: #d55181; --c6: #008300; --c7: #9085e9; --c8: #e66767;
  --series-other: #6f6e69;
  --seq-stops: #0d366b, #184f95, #256abf, #3987e5, #6da7ec, #9ec5f4, #cde2fb;
  --abc-a-bg: #256abf; --abc-a-fg: #ffffff;
  --abc-b-bg: #184f95; --abc-b-fg: #9ec5f4;
  --div-up: #3987e5; --div-mid: #383835; --div-down: #e66767;
  --accent: #3987e5; --accent-ink: #86b6ef;
  --accent-wash: rgba(57, 135, 229, .16);
  --focus: #6da7ec;
  --delta-up: #0ca30c; --delta-down: #e66767;
  --shadow-1: 0 1px 2px rgba(0, 0, 0, .40);
  --shadow-2: 0 6px 24px rgba(0, 0, 0, .55);
}

/* ────────────────────────────────────────────────────────── 2. RESET ──── */

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

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--plane);          /* explicit page background */
  color: var(--text-1);
  font: var(--fs-13) / var(--lh) var(--font);
  -webkit-font-smoothing: antialiased;
}

/* The UA sheet's `[hidden] { display: none }` LOSES to any author `display`
   rule, so a component that sets `display: flex` silently ignores the hidden
   attribute and renders wide open. This makes `hidden` authoritative. */
[hidden] { display: none !important; }

h1, h2, h3, h4, p, figure { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
a { color: var(--accent-ink); text-decoration-color: var(--border-2); text-underline-offset: 2px; }

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

::selection { background: var(--accent-wash); }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ───────────────────────────────────────────────────────── 3. LAYOUT ──── */

.app {
  display: grid;
  grid-template-columns: var(--nav-w) minmax(0, 1fr);
  grid-template-rows: var(--header-h) minmax(0, 1fr);
  grid-template-areas: "brand header" "nav main";
  min-height: 100vh;
}

/* header ---------------------------------------------------------------- */

.brand {
  grid-area: brand;
  display: flex; align-items: center; gap: var(--sp-3);
  padding: 0 var(--sp-5);
  background: var(--surface-nav);
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 40;
}
.brand__mark {
  width: 20px; height: 20px; border-radius: var(--r-1); flex: none;
  background: linear-gradient(135deg, var(--c1), var(--c7));
}
.brand__name { font-size: var(--fs-13); font-weight: 650; letter-spacing: -.01em; }
.brand__sub  { font-size: var(--fs-10); color: var(--text-3); margin-left: auto; }

.topbar {
  grid-area: header;
  display: flex; align-items: center; gap: var(--sp-5);
  padding: 0 var(--sp-6) 0 var(--sp-6);
  background: var(--surface-1);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 40;
}
.topbar__title { font-size: var(--fs-13); font-weight: 600; }
.topbar__desc  { font-size: var(--fs-11); color: var(--text-3); }
.topbar__right { margin-left: auto; display: flex; align-items: center; gap: var(--sp-4); }
.topbar__meta  { font-size: var(--fs-11); color: var(--text-3); font-variant-numeric: tabular-nums; }

.datamode {
  display: inline-flex; align-items: center; gap: var(--sp-2);
  padding: 2px var(--sp-3);
  border: 1px solid var(--border); border-radius: 999px;
  font-size: var(--fs-10); color: var(--text-2); letter-spacing: .02em;
}
.datamode__dot { width: 6px; height: 6px; border-radius: 50%; background: var(--good); }

/* nav -------------------------------------------------------------------- */

.nav {
  grid-area: nav;
  background: var(--surface-nav);
  border-right: 1px solid var(--border);
  padding: var(--sp-4) var(--sp-3);
  position: sticky; top: var(--header-h);
  height: calc(100vh - var(--header-h));
  overflow-y: auto;
  display: flex; flex-direction: column; gap: var(--sp-1);
}
.nav__group {
  font-size: var(--fs-10); text-transform: uppercase; letter-spacing: .07em;
  color: var(--text-3); padding: var(--sp-5) var(--sp-4) var(--sp-2);
}
.nav__item {
  display: flex; align-items: center; gap: var(--sp-4);
  padding: var(--sp-3) var(--sp-4);
  border-radius: var(--r-2);
  color: var(--text-2); font-size: var(--fs-13);
  text-decoration: none; width: 100%; text-align: left;
  border-left: 2px solid transparent;
}
.nav__item:hover { background: var(--surface-2); color: var(--text-1); }
.nav__item.is-on {
  background: var(--accent-wash); color: var(--text-1);
  font-weight: 600; border-left-color: var(--accent);
}
.nav__icon { width: 14px; text-align: center; color: var(--text-3); flex: none; font-size: var(--fs-12); }
.nav__item.is-on .nav__icon { color: var(--accent); }
.nav__foot { margin-top: auto; padding: var(--sp-5) var(--sp-4); font-size: var(--fs-10); color: var(--text-3); line-height: 1.5; }

/* main + filter bar ------------------------------------------------------ */

.main { grid-area: main; min-width: 0; display: flex; flex-direction: column; }

/* Filters sit in ONE row above everything they scope — never inside a card,
   never per-chart. */
.filterbar {
  position: sticky; top: var(--header-h); z-index: 30;
  display: flex; align-items: center; gap: var(--sp-4);
  padding: var(--sp-3) var(--sp-6);
  min-height: var(--filter-h);
  background: color-mix(in srgb, var(--surface-1) 92%, transparent);
  backdrop-filter: saturate(180%) blur(8px);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.filterbar__sep { width: 1px; align-self: stretch; background: var(--border); margin: 0 var(--sp-1); }
.filterbar__spacer { flex: 1 1 auto; }
.filterbar__row2 {
  display: flex; align-items: center; gap: var(--sp-3);
  padding: var(--sp-2) var(--sp-6) var(--sp-3);
  border-bottom: 1px solid var(--border);
  background: var(--surface-1);
  flex-wrap: wrap;
}

.content { padding: var(--sp-6); min-width: 0; flex: 1; }

.grid { display: grid; gap: var(--sp-5); grid-template-columns: repeat(12, minmax(0, 1fr)); }
.col-3  { grid-column: span 3; }
.col-4  { grid-column: span 4; }
.col-5  { grid-column: span 5; }
.col-6  { grid-column: span 6; }
.col-7  { grid-column: span 7; }
.col-8  { grid-column: span 8; }
.col-9  { grid-column: span 9; }
.col-12 { grid-column: span 12; }

.stack { display: flex; flex-direction: column; gap: var(--sp-5); }
.row   { display: flex; align-items: center; gap: var(--sp-4); }
.row--wrap { flex-wrap: wrap; }

/* ─────────────────────────────────────────────────────────── 4. CARD ──── */

.card {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--r-3);
  box-shadow: var(--shadow-1);
  min-width: 0;
  display: flex; flex-direction: column;
}
.card__head {
  display: flex; align-items: flex-start; gap: var(--sp-4);
  padding: var(--sp-5) var(--sp-5) var(--sp-3);
}
.card__titles { min-width: 0; flex: 1; }
.card__title { font-size: var(--fs-13); font-weight: 650; letter-spacing: -.005em; }
.card__sub   { font-size: var(--fs-11); color: var(--text-3); margin-top: 2px; line-height: 1.45; }
.card__actions { display: flex; align-items: center; gap: var(--sp-3); flex: none; }
.card__body { padding: 0 var(--sp-5) var(--sp-5); min-width: 0; flex: 1; }
.card--flush .card__body { padding: 0; }
.card--flush .card__head { padding-bottom: var(--sp-4); }

/* ─────────────────────────────────────────────────────── 5. KPI TILES ── */

.kpirow {
  display: grid; gap: var(--sp-4);
  grid-template-columns: repeat(auto-fit, minmax(168px, 1fr));
}
.tile {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--r-3);
  padding: var(--sp-5);
  display: flex; flex-direction: column; gap: var(--sp-2);
  min-width: 0; text-align: left;
  box-shadow: var(--shadow-1);
}
.tile--btn:hover { border-color: var(--border-2); background: var(--surface-2); }
.tile__label {
  font-size: var(--fs-11); color: var(--text-2);
  display: flex; align-items: center; gap: var(--sp-2);
  line-height: 1.3;
}
.tile__valline { display: flex; align-items: baseline; gap: var(--sp-2); min-width: 0; }
/* Proportional figures on standalone values — tabular-nums makes 121 look loose. */
.tile__value {
  font-size: var(--fs-22); font-weight: 620; letter-spacing: -.02em;
  color: var(--text-1); line-height: 1.1;
}
.tile__unit { font-size: var(--fs-11); color: var(--text-3); }
.tile__meta { display: flex; align-items: center; gap: var(--sp-3); min-height: 20px; }
.tile__deltalabel { font-size: var(--fs-10); color: var(--text-3); }
.tile__spark { margin-left: auto; display: flex; line-height: 0; }
.tile__foot { font-size: var(--fs-10); color: var(--text-3); line-height: 1.4; }

/* The one hero figure a view leads with. Same sans as everything else. */
.tile--hero { gap: var(--sp-3); }
.tile--hero .tile__value { font-size: var(--fs-40); font-weight: 600; letter-spacing: -.03em; }
.tile--hero .tile__label { font-size: var(--fs-12); }

.tile--accent { border-color: color-mix(in srgb, var(--accent) 38%, var(--border)); background: color-mix(in srgb, var(--accent) 5%, var(--surface-1)); }
.tile--warning { border-color: color-mix(in srgb, var(--warning) 48%, var(--border)); }
.tile--skel { gap: var(--sp-4); }

.delta {
  display: inline-flex; align-items: center; gap: 3px;
  font-size: var(--fs-11); font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.delta--good { color: var(--delta-up); }
.delta--bad  { color: var(--delta-down); }
.delta--flat { color: var(--text-3); }
.delta__arrow { font-size: 8px; line-height: 1; }

.hint {
  display: inline-flex; align-items: center; justify-content: center;
  width: 13px; height: 13px; border-radius: 50%; flex: none;
  border: 1px solid var(--border-2); color: var(--text-3);
  font-size: 9px; font-weight: 700; cursor: help; line-height: 1;
}
.hint:hover { color: var(--text-1); border-color: var(--text-3); }

/* ─────────────────────────────────────────────────────── 6. BADGES ───── */

/* Status is icon + label, never colour alone. */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: var(--fs-10); font-weight: 600;
  padding: 1px var(--sp-3); border-radius: 999px;
  border: 1px solid; white-space: nowrap;
}
.badge__icon { font-size: 7px; line-height: 1; }
.badge--good     { color: var(--good);     border-color: color-mix(in srgb, var(--good) 40%, transparent);     background: color-mix(in srgb, var(--good) 10%, transparent); }
.badge--warning  { color: var(--text-1);   border-color: color-mix(in srgb, var(--warning) 60%, transparent);  background: color-mix(in srgb, var(--warning) 16%, transparent); }
.badge--serious  { color: var(--text-1);   border-color: color-mix(in srgb, var(--serious) 60%, transparent);  background: color-mix(in srgb, var(--serious) 16%, transparent); }
.badge--critical { color: var(--critical); border-color: color-mix(in srgb, var(--critical) 45%, transparent); background: color-mix(in srgb, var(--critical) 10%, transparent); }
.badge--ok       { color: var(--text-2);   border-color: var(--border); }

.abc {
  display: inline-flex; align-items: center; justify-content: center;
  width: 18px; height: 18px; border-radius: var(--r-1);
  font-size: var(--fs-10); font-weight: 700;
  border: 1px solid var(--border);
}
.abc--a { background: var(--abc-a-bg); color: var(--abc-a-fg); border-color: transparent; }
.abc--b { background: var(--abc-b-bg); color: var(--abc-b-fg); border-color: transparent; }
.abc--c { background: var(--surface-3); color: var(--text-3); }

.blankdim {
  color: var(--text-2); font-style: italic;
  border-bottom: 1px dashed var(--warning);
}
.inf { color: var(--text-3); font-weight: 600; }

/* ────────────────────────────────────────────────────── 7. CONTROLS ──── */

.btn {
  display: inline-flex; align-items: center; gap: var(--sp-2);
  padding: var(--sp-3) var(--sp-4);
  border: 1px solid var(--border-2); border-radius: var(--r-2);
  background: var(--surface-1); color: var(--text-1);
  font-size: var(--fs-12); font-weight: 500; white-space: nowrap;
}
.btn:hover:not(:disabled) { background: var(--surface-2); border-color: var(--text-3); }
.btn:disabled { opacity: .4; cursor: default; }
.btn--sm { padding: var(--sp-2) var(--sp-4); font-size: var(--fs-12); }
.btn--xs { padding: 2px var(--sp-3); font-size: var(--fs-11); border-radius: var(--r-1); }
.btn--ghost { border-color: transparent; background: transparent; color: var(--text-2); }
.btn--ghost:hover:not(:disabled) { background: var(--surface-2); border-color: var(--border); color: var(--text-1); }
.btn--ghost.is-on { background: var(--accent-wash); color: var(--accent-ink); border-color: transparent; }
.btn--primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn--primary:hover:not(:disabled) { background: var(--accent-ink); border-color: var(--accent-ink); }

/* segmented control ------------------------------------------------------ */
.seg {
  display: inline-flex; padding: 2px; gap: 2px;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--r-2);
}
.seg__btn {
  padding: 3px var(--sp-4); border-radius: var(--r-1);
  font-size: var(--fs-12); color: var(--text-2); white-space: nowrap;
}
.seg__btn:hover { color: var(--text-1); }
.seg__btn.is-on { background: var(--surface-1); color: var(--text-1); font-weight: 600; box-shadow: var(--shadow-1); }
.seg--sm .seg__btn { padding: 2px var(--sp-3); font-size: var(--fs-11); }

/* switch ----------------------------------------------------------------- */
.sw { display: inline-flex; align-items: center; gap: var(--sp-3); cursor: pointer; user-select: none; }
.sw__input { position: absolute; opacity: 0; width: 0; height: 0; }
.sw__track {
  width: 30px; height: 17px; border-radius: 999px; flex: none;
  background: var(--surface-3); border: 1px solid var(--border-2);
  position: relative; transition: background .12s;
}
.sw__thumb {
  position: absolute; top: 1px; left: 1px; width: 13px; height: 13px;
  border-radius: 50%; background: var(--surface-1); box-shadow: var(--shadow-1);
  transition: transform .12s;
}
.sw.is-on .sw__track { background: var(--accent); border-color: var(--accent); }
.sw.is-on .sw__thumb { transform: translateX(13px); background: #fff; }
.sw__label { font-size: var(--fs-12); color: var(--text-2); }
.sw.is-on .sw__label { color: var(--text-1); font-weight: 600; }
.sw__input:focus-visible + .sw__track { outline: 2px solid var(--focus); outline-offset: 2px; }
/* the like-for-like toggle is the most important control in the bar */
.sw--lfl.is-on .sw__track { background: var(--c2); border-color: var(--c2); }

/* multiselect ------------------------------------------------------------ */
.ms { position: relative; }
.ms__btn {
  display: inline-flex; align-items: center; gap: var(--sp-2);
  padding: var(--sp-2) var(--sp-3);
  border: 1px solid var(--border-2); border-radius: var(--r-2);
  background: var(--surface-1); font-size: var(--fs-12); max-width: 230px;
}
.ms__btn:hover { border-color: var(--text-3); }
.ms__btn.is-active { border-color: var(--accent); background: var(--accent-wash); }
.ms__label { color: var(--text-3); font-size: var(--fs-11); flex: none; }
.ms__btnlabel { color: var(--text-1); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ms__caret { color: var(--text-3); font-size: 9px; flex: none; }
/* Closed by default, in CSS — never an open panel waiting for JS to shut it. */
.ms__pop {
  position: absolute; top: calc(100% + 4px); left: 0; z-index: 60;
  min-width: 250px; max-width: 340px;
  background: var(--surface-1); border: 1px solid var(--border-2);
  border-radius: var(--r-3); box-shadow: var(--shadow-2);
  padding: var(--sp-3); flex-direction: column; gap: var(--sp-2);
  display: none;
}
.ms.is-open .ms__pop { display: flex; }
.ms__search {
  width: 100%; padding: var(--sp-3);
  border: 1px solid var(--border); border-radius: var(--r-2);
  background: var(--surface-2); font-size: var(--fs-12);
}
.ms__list { overflow-y: auto; display: flex; flex-direction: column; }
.ms__opt {
  display: flex; align-items: center; gap: var(--sp-3);
  padding: var(--sp-3); border-radius: var(--r-2);
  font-size: var(--fs-12); cursor: pointer;
}
.ms__opt:hover { background: var(--surface-2); }
.ms__opt.is-on { background: var(--accent-wash); }
.ms__opt input { position: absolute; opacity: 0; width: 0; }
.ms__check {
  width: 14px; flex: none; text-align: center;
  color: var(--accent); font-weight: 700; font-size: var(--fs-13);
}
.ms__swatch { width: 9px; height: 9px; border-radius: 2px; flex: none; }
.ms__optlabel { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ms__hint { color: var(--text-3); font-size: var(--fs-10); font-variant-numeric: tabular-nums; flex: none; }
.ms__empty { padding: var(--sp-4); color: var(--text-3); font-size: var(--fs-12); }
.ms__foot {
  display: flex; align-items: center; justify-content: space-between;
  border-top: 1px solid var(--border); padding-top: var(--sp-2);
}
.ms__count { font-size: var(--fs-10); color: var(--text-3); font-variant-numeric: tabular-nums; }

/* week range ------------------------------------------------------------- */
.wkrange { display: inline-flex; align-items: center; gap: var(--sp-2); }
.wkrange__sel {
  padding: var(--sp-2) var(--sp-3); font-size: var(--fs-12);
  border: 1px solid var(--border-2); border-radius: var(--r-2);
  background: var(--surface-1); max-width: 120px;
}
.wkrange__dash { color: var(--text-3); }
.field__label { font-size: var(--fs-11); color: var(--text-3); }

.search {
  display: inline-flex; align-items: center; gap: var(--sp-2);
  border: 1px solid var(--border-2); border-radius: var(--r-2);
  background: var(--surface-1); padding: 0 var(--sp-3);
}
.search:focus-within { border-color: var(--accent); }
.search input { border: 0; background: none; padding: var(--sp-2) 0; width: 150px; font-size: var(--fs-12); outline: none; }
.search__icon { color: var(--text-3); font-size: var(--fs-12); }

/* chips ------------------------------------------------------------------ */
.chips { display: flex; align-items: center; gap: var(--sp-2); flex-wrap: wrap; min-height: 22px; }
.chips__none { font-size: var(--fs-11); color: var(--text-3); }
.chip {
  display: inline-flex; align-items: center; gap: var(--sp-2);
  padding: 1px var(--sp-2) 1px var(--sp-3);
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 999px; font-size: var(--fs-11); max-width: 240px;
}
.chip__field { color: var(--text-3); flex: none; }
.chip__val { color: var(--text-1); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip__x {
  color: var(--text-3); font-size: var(--fs-13); line-height: 1;
  padding: 0 2px; border-radius: 50%; flex: none;
}
.chip__x:hover { color: var(--critical); background: var(--surface-3); }
.chip--lfl { border-color: var(--c2); background: color-mix(in srgb, var(--c2) 12%, transparent); }
.chips__clear { margin-left: var(--sp-2); }

/* ──────────────────────────────────────────────────────── 8. CHARTS ──── */

.chart { display: flex; flex-direction: column; min-width: 0; }
.chart__head {
  display: flex; align-items: flex-start; gap: var(--sp-4);
  margin-bottom: var(--sp-3);
}
.chart__titles { flex: 1; min-width: 0; }
.chart__title { font-size: var(--fs-12); font-weight: 650; }
.chart__sub { font-size: var(--fs-11); color: var(--text-3); margin-top: 1px; }
.chart__actions { display: flex; align-items: center; gap: var(--sp-2); flex: none; }
.chart__body { position: relative; min-width: 0; }
.chart__plot { position: absolute; inset: 0; transition: opacity .15s; }
/* Hidden by default. This one is load-bearing: the overlay is opaque and
   inset:0, so if it ignores [hidden] it paints over the whole chart. */
.chart__overlay {
  position: absolute; inset: 0; align-items: center;
  justify-content: center; gap: var(--sp-3); flex-direction: column;
  background: var(--surface-1); border-radius: var(--r-2);
  display: none;
}
.chart__overlay:not([hidden]) { display: flex; }
.chart__overlay--skeleton { align-items: stretch; justify-content: flex-end; padding: var(--sp-5); flex-direction: row; gap: var(--sp-4); }
.chart__msg { font-size: var(--fs-12); color: var(--text-3); text-align: center; max-width: 280px; }
.chart__overlay--error .chart__msg { color: var(--critical); }
.chart__note { font-size: var(--fs-11); color: var(--text-3); margin-top: var(--sp-3); line-height: 1.45; }
.chart__table { margin-top: var(--sp-4); max-height: 260px; overflow: auto; border: 1px solid var(--border); border-radius: var(--r-2); }
.chart__tablebtn { flex: none; }

/* legend built in HTML (when a chart needs one outside the canvas) */
.legend { display: flex; flex-wrap: wrap; gap: var(--sp-2) var(--sp-5); margin-top: var(--sp-3); }
.legend__item { display: inline-flex; align-items: center; gap: var(--sp-2); font-size: var(--fs-11); color: var(--text-2); }
.legend__key { width: 11px; height: 3px; border-radius: 2px; flex: none; }
.legend__key--box { width: 9px; height: 9px; border-radius: 2px; }
.legend__val { color: var(--text-1); font-weight: 600; font-variant-numeric: tabular-nums; }

/* sparkline + bar-in-cell ------------------------------------------------ */
.spark { display: block; overflow: visible; }
.cellbar { display: inline-flex; align-items: center; gap: var(--sp-3); justify-content: flex-end; width: 100%; }
.cellbar__val { font-variant-numeric: tabular-nums; }
.cellbar__track { height: 4px; border-radius: 2px; background: var(--surface-3); flex: none; overflow: hidden; }
.cellbar__fill { display: block; height: 100%; border-radius: 2px; }

/* ────────────────────────────────────────────────────── 9. DATA TABLE ── */

.dtwrap { display: flex; flex-direction: column; min-width: 0; }
.dtwrap.is-loading .dt__scroll { opacity: .45; }         /* keep the frame */
.dt__toolbar {
  display: flex; align-items: center; gap: var(--sp-4);
  padding: 0 var(--sp-5) var(--sp-3);
}
.dt__info { font-size: var(--fs-11); color: var(--text-3); font-variant-numeric: tabular-nums; }
.dt__tools { margin-left: auto; display: flex; align-items: center; gap: var(--sp-3); }
.dt__sizelabel { font-size: var(--fs-11); color: var(--text-3); }
.dt__size {
  padding: 1px var(--sp-2); font-size: var(--fs-11);
  border: 1px solid var(--border); border-radius: var(--r-1); background: var(--surface-1);
}
.dt__scroll { overflow: auto; max-height: 70vh; transition: opacity .15s; border-top: 1px solid var(--border); }

.dt { width: 100%; border-collapse: separate; border-spacing: 0; font-size: var(--fs-12); }
.dt__caption { caption-side: top; text-align: left; font-size: var(--fs-11); color: var(--text-3); padding: 0 var(--sp-5) var(--sp-3); }
.dt thead th {
  position: sticky; top: 0; z-index: 2;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border-2);
  padding: var(--sp-3) var(--sp-4);
  text-align: left; font-size: var(--fs-11); font-weight: 600; color: var(--text-2);
  white-space: nowrap; vertical-align: bottom;
}
.dt thead th.num { text-align: right; }
.dt thead th.is-sorted { color: var(--text-1); }
.dt__sortbtn { display: inline-flex; align-items: center; gap: 3px; color: inherit; font: inherit; }
.dt thead th.num .dt__sortbtn { flex-direction: row-reverse; }
.dt__arrow { color: var(--text-3); font-size: 9px; }
.dt thead th.is-sorted .dt__arrow { color: var(--accent); }

.dt tbody td {
  padding: var(--sp-3) var(--sp-4);
  border-bottom: 1px solid var(--grid);
  vertical-align: middle;
  max-width: 340px; overflow: hidden; text-overflow: ellipsis;
}
/* numerics right-aligned with aligned digits — this is where tabular-nums belongs */
.dt tbody td.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.dt tbody tr:hover td { background: var(--surface-2); }
.dt tbody tr.is-clickable { cursor: pointer; }
.dt tbody tr.is-neg td.num { color: var(--delta-down); }
.dt tbody tr.is-flagged td:first-child { box-shadow: inset 2px 0 0 var(--warning); }
.dt th.sticky, .dt td.sticky {
  position: sticky; left: 0; z-index: 1; background: var(--surface-1);
  border-right: 1px solid var(--border);
}
.dt thead th.sticky { z-index: 3; background: var(--surface-2); }
.dt tbody tr:hover td.sticky { background: var(--surface-2); }
.dt--dense tbody td, .dt--dense thead th { padding: var(--sp-2) var(--sp-3); }
.dt--mini { font-size: var(--fs-11); }
.dt--mini thead th, .dt--mini tbody td { padding: var(--sp-2) var(--sp-3); }
.dt tfoot td { padding: var(--sp-3) var(--sp-4); font-weight: 600; border-top: 1px solid var(--border-2); background: var(--surface-2); }

.dt__foot {
  display: flex; align-items: center; gap: var(--sp-4);
  padding: var(--sp-3) var(--sp-5) 0;
  border-top: 1px solid var(--border);
}
.dt__pager { display: flex; align-items: center; gap: 2px; }
.dt__page {
  min-width: 24px; height: 24px; padding: 0 var(--sp-2);
  border-radius: var(--r-1); font-size: var(--fs-11); color: var(--text-2);
  font-variant-numeric: tabular-nums;
}
.dt__page:hover:not(:disabled) { background: var(--surface-2); color: var(--text-1); }
.dt__page.is-on { background: var(--accent); color: #fff; font-weight: 600; }
.dt__page:disabled { opacity: .3; cursor: default; }
.dt__gap { color: var(--text-3); padding: 0 2px; }
.dt__note { font-size: var(--fs-10); color: var(--text-3); margin-left: auto; }

/* ────────────────────────────────────────── 10. STATES & FEEDBACK ────── */

.state { display: flex; flex-direction: column; align-items: center; gap: var(--sp-3); padding: var(--sp-9) var(--sp-5); text-align: center; }
.state__msg { font-size: var(--fs-12); color: var(--text-2); }
.state__hint { font-size: var(--fs-11); color: var(--text-3); max-width: 380px; }
.state--error .state__msg { color: var(--critical); font-weight: 500; }

.banner {
  display: flex; align-items: flex-start; gap: var(--sp-3);
  padding: var(--sp-4) var(--sp-5);
  border: 1px solid var(--border); border-left-width: 3px;
  border-radius: var(--r-2); background: var(--surface-1);
  font-size: var(--fs-12);
}
.banner__icon { font-size: var(--fs-10); line-height: 1.5; flex: none; font-weight: 700; }
.banner__text { color: var(--text-2); line-height: 1.5; flex: 1; }
.banner--info     { border-left-color: var(--accent); }
.banner--info .banner__icon { color: var(--accent); }
.banner--warning  { border-left-color: var(--warning); background: color-mix(in srgb, var(--warning) 7%, var(--surface-1)); }
.banner--warning .banner__icon { color: color-mix(in srgb, var(--warning) 70%, var(--text-1)); }
.banner--critical { border-left-color: var(--critical); background: color-mix(in srgb, var(--critical) 6%, var(--surface-1)); }
.banner--critical .banner__icon { color: var(--critical); }
.banner__x { color: var(--text-3); font-size: var(--fs-15); line-height: 1; padding: 0 var(--sp-2); }

/* skeletons — only before the FIRST render; a refetch dims instead */
.skel {
  background: linear-gradient(90deg, var(--surface-2) 25%, var(--surface-3) 37%, var(--surface-2) 63%);
  background-size: 400% 100%;
  animation: shimmer 1.4s ease-in-out infinite;
  border-radius: var(--r-1);
}
@keyframes shimmer { 0% { background-position: 100% 0; } 100% { background-position: 0 0; } }
.skel--text { height: 10px; width: 60%; }
.skel--big  { height: 22px; width: 45%; }
.skel--cell { height: 10px; flex: none; }
.skel--bar  { flex: 1; align-self: flex-end; height: 40%; }
.skel--bar:nth-child(2) { height: 72%; }
.skel--bar:nth-child(3) { height: 54%; }
.skeltable { display: flex; flex-direction: column; gap: var(--sp-4); padding: var(--sp-4); }
.skeltable__row { display: flex; gap: var(--sp-5); align-items: center; }
@media (prefers-reduced-motion: reduce) { .skel { animation: none; } }

/* toasts ----------------------------------------------------------------- */
.toasts {
  position: fixed; right: var(--sp-6); bottom: var(--sp-6); z-index: 90;
  display: flex; flex-direction: column; gap: var(--sp-3); max-width: 380px;
}
.toast {
  display: flex; align-items: flex-start; gap: var(--sp-3);
  padding: var(--sp-4) var(--sp-5);
  background: var(--surface-1); border: 1px solid var(--border-2);
  border-left-width: 3px; border-radius: var(--r-2);
  box-shadow: var(--shadow-2); font-size: var(--fs-12);
  animation: toastin .18s ease-out;
}
@keyframes toastin { from { opacity: 0; transform: translateY(6px); } }
.toast__icon { font-size: var(--fs-10); line-height: 1.6; flex: none; }
.toast__msg { flex: 1; color: var(--text-1); line-height: 1.45; }
.toast__x { color: var(--text-3); font-size: var(--fs-15); line-height: 1; padding: 0 2px; }
.toast--error   { border-left-color: var(--critical); }
.toast--error .toast__icon { color: var(--critical); }
.toast--warning { border-left-color: var(--warning); }
.toast--warning .toast__icon { color: color-mix(in srgb, var(--warning) 70%, var(--text-1)); }
.toast--success { border-left-color: var(--good); }
.toast--success .toast__icon { color: var(--good); }
.toast--info    { border-left-color: var(--accent); }
.toast--info .toast__icon { color: var(--accent); }
@media (prefers-reduced-motion: reduce) { .toast { animation: none; } }

/* ────────────────────────────────────────────────── 11. MISC / UTILS ── */

.view { min-width: 0; }
.muted { color: var(--text-3); }
.num   { font-variant-numeric: tabular-nums; }
.nowrap { white-space: nowrap; }
.mono  { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: var(--fs-11); }
.sect__title { font-size: var(--fs-11); text-transform: uppercase; letter-spacing: .07em; color: var(--text-3); margin-bottom: var(--sp-3); }

.keyfig { display: flex; align-items: baseline; gap: var(--sp-3); flex-wrap: wrap; }
.keyfig__value { font-size: var(--fs-28); font-weight: 600; letter-spacing: -.025em; }
.keyfig__unit  { font-size: var(--fs-12); color: var(--text-3); }

.splitmeta { display: flex; gap: var(--sp-7); flex-wrap: wrap; }
.splitmeta__item { display: flex; flex-direction: column; gap: 1px; }
.splitmeta__k { font-size: var(--fs-10); color: var(--text-3); display: flex; align-items: center; gap: var(--sp-2); }
.splitmeta__v { font-size: var(--fs-15); font-weight: 600; font-variant-numeric: tabular-nums; }
.splitmeta__dot { width: 8px; height: 8px; border-radius: 2px; }

.stub { padding: var(--sp-9); text-align: center; color: var(--text-3); }
.stub__title { font-size: var(--fs-18); color: var(--text-1); font-weight: 600; margin-bottom: var(--sp-4); }
.stub__desc { font-size: var(--fs-13); max-width: 520px; margin: 0 auto var(--sp-5); line-height: 1.6; }
.stub__api { display: inline-block; padding: var(--sp-3) var(--sp-5); background: var(--surface-2); border-radius: var(--r-2); }

/* ───────────────────────────────────────────────────── 12. RESPONSIVE ── */

/* 1280px is the design target; 1024px must still work. */
@media (max-width: 1280px) {
  :root { --nav-w: 176px; }
  .content { padding: var(--sp-5); }
  .col-3 { grid-column: span 4; }
  .col-5 { grid-column: span 6; }
  .col-7 { grid-column: span 6; }
}

@media (max-width: 1024px) {
  :root { --nav-w: 56px; }
  .brand__name, .brand__sub { display: none; }
  .nav__item { justify-content: center; padding: var(--sp-4) 0; }
  .nav__item span:not(.nav__icon) { display: none; }
  .nav__group, .nav__foot { display: none; }
  .col-3, .col-4 { grid-column: span 6; }
  .col-5, .col-7, .col-8, .col-9 { grid-column: span 12; }
  .topbar__desc { display: none; }
  .filterbar { gap: var(--sp-3); }
}

@media (max-width: 720px) {
  .app { grid-template-columns: 0 minmax(0, 1fr); }
  .nav, .brand { display: none; }
  .col-3, .col-4, .col-6 { grid-column: span 12; }
  .content { padding: var(--sp-4); }
}

@media print {
  .nav, .brand, .filterbar, .dt__toolbar, .dt__foot, .toasts { display: none !important; }
  .app { grid-template-columns: 1fr; grid-template-areas: "header" "main"; }
  .card { break-inside: avoid; box-shadow: none; }
}

/* ======================================================================
   forms · login · upload · users
   ====================================================================== */
.form { display: grid; gap: var(--sp-5); }
.form__row { display: grid; gap: var(--sp-2); }
.form__row--inline { display: flex; flex-wrap: wrap; gap: var(--sp-4); align-items: end; }
.form__hint { font-size: var(--fs-11); color: var(--text-3); line-height: 1.45; }
.form__error { font-size: var(--fs-12); color: var(--critical); white-space: pre-line; line-height: 1.45; }
.input, .select {
  padding: var(--sp-3) var(--sp-4); font: inherit; font-size: var(--fs-13); color: var(--text-1);
  border: 1px solid var(--border-2); border-radius: var(--r-2); background: var(--surface-1);
  min-width: 0;
}
.input:focus, .select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-wash); }
.input[aria-invalid="true"] { border-color: var(--critical); }

.dropzone {
  display: grid; place-items: center; gap: var(--sp-2); text-align: center;
  padding: var(--sp-9) var(--sp-5); border: 1.5px dashed var(--border-2); border-radius: var(--r-3);
  background: var(--surface-2); color: var(--text-2); cursor: pointer;
}
.dropzone:hover, .dropzone.is-over { border-color: var(--accent); background: var(--accent-wash); }
.dropzone__name { font-weight: 600; color: var(--text-1); }
.dropzone input[type="file"] { display: none; }

.pill { display: inline-block; padding: 1px var(--sp-3); border-radius: 999px; font-size: var(--fs-11);
        background: var(--surface-3); color: var(--text-2); }
.pill--admin { background: var(--accent-wash); color: var(--accent-ink); }
.pill--new { background: color-mix(in srgb, var(--good) 14%, var(--surface-1)); color: var(--text-1); }
.pill--exists { background: color-mix(in srgb, var(--warning) 18%, var(--surface-1)); color: var(--text-1); }

.usermenu { display: inline-flex; align-items: center; gap: var(--sp-3); font-size: var(--fs-12); color: var(--text-2); }

.authpage { min-height: 100vh; display: grid; place-items: center; background: var(--plane); padding: var(--sp-6); }
.authcard { width: min(360px, 100%); background: var(--surface-1); border: 1px solid var(--border);
            border-radius: var(--r-4); padding: var(--sp-9); display: grid; gap: var(--sp-6); }
.authcard__brand { display: flex; align-items: center; gap: var(--sp-3); font-weight: 650; font-size: var(--fs-15); }
.authcard .btn { justify-content: center; padding: var(--sp-3); }
.disclosure { padding-left: 0; color: var(--accent-ink); font-weight: 600; }

/* UX workspace: hierarchy, report context and responsive navigation. */
:root { --nav-w: 208px; --header-h: 60px; --r-2: 7px; --r-3: 12px; --r-4: 16px; }
:root:not(.is-dark) {
  --plane:#f3f6fa; --surface-1:#ffffff; --surface-2:#f5f7fb; --surface-3:#e8edf5;
  --surface-nav:#f9fbff; --text-1:#182438; --text-2:#485972; --text-3:#66758b;
  --grid:#e6ecf3; --axis:#c0ccdb; --border:rgba(40,65,100,.11); --border-2:rgba(40,65,100,.22);
  --shadow-1:0 2px 8px rgba(26,45,75,.025); --shadow-2:0 14px 42px rgba(26,45,75,.15);
}
:root.is-dark {
  --plane:#101721; --surface-1:#182230; --surface-2:#202d3e; --surface-3:#2a394c;
  --surface-nav:#141e2c; --text-1:#edf3fc; --text-2:#c0cddd; --text-3:#99abc1;
  --grid:#2c3a4c; --axis:#45556d; --border:rgba(178,202,235,.12); --border-2:rgba(178,202,235,.25);
}
.brand { padding:0 20px; gap:10px; }
.brand__mark { width:25px; height:25px; border-radius:7px; background:var(--accent); position:relative; }
.brand__mark::after { content:'▥'; position:absolute; inset:1px 0 0; text-align:center; color:white; font-size:20px; }
.brand__name { font-size:14px; letter-spacing:-.035em; }
.topbar { padding:0 24px; }
.topbar__title { font-size:17px; letter-spacing:-.02em; }
.topbar__desc { font-size:11px; margin-top:2px; }
.topbar__right { gap:12px; }
.nav { padding:12px 10px; gap:3px; }
.nav__group { font-size:10px; letter-spacing:.09em; padding:17px 12px 5px; }
.nav__item { min-height:37px; border:0; padding:8px 12px; gap:10px; font-size:13px; border-radius:8px; }
.nav__item.is-on { color:var(--accent-ink); box-shadow:inset 3px 0 var(--accent); }
.nav__icon { font-size:15px; width:18px; }
.nav__foot { font-size:11px; padding:20px 12px 8px; }
.nav-toggle, .nav-backdrop, .filters-toggle { display:none; }
.content { padding:20px 24px 40px; }
.grid, .stack { gap:16px; }
.card__head { padding:18px 18px 12px; align-items:flex-start; flex-wrap:wrap; }
.card__title { font-size:15px; letter-spacing:-.02em; }
.card__sub { font-size:12px; margin-top:4px; }
.card__body { padding:0 18px 18px; }
.card--flush .card__body { padding:0; }
.card__actions { flex-wrap:wrap; }
.tile { padding:18px; gap:8px; }
.tile__label { font-size:12px; }
.tile__value { font-size:30px; font-weight:650; letter-spacing:-.04em; }
.tile__unit { font-size:12px; }
.tile__deltalabel, .tile__foot { font-size:12px; line-height:1.45; }
.tile--hero { background:var(--accent-wash); border-color:color-mix(in srgb,var(--accent) 24%,transparent); }
.btn { min-height:32px; border-radius:7px; }
.btn--sm { font-size:12px; }
.btn--xs { min-height:26px; }
.view-tools { padding:14px 24px 10px; display:flex; align-items:center; gap:12px; background:var(--surface-1); }
.view-tools__label { font-size:11px; text-transform:uppercase; letter-spacing:.08em; color:var(--text-3); }
.view-tools__actions { margin-left:auto; display:flex; align-items:center; gap:8px; }
.filterbar { padding:8px 24px; position:relative; top:auto; backdrop-filter:none; background:var(--surface-1); border-bottom:0; gap:8px; }
.filterbar__row2 { padding:3px 24px 12px; min-height:30px; font-size:12px; }
.main[data-local-period="true"] .filter-period,
.main[data-local-brand="true"] .filter-brand,
.main[data-local-lfl="true"] .filter-lfl { display:none; }
.saved-views { position:relative; }
.saved-views>summary, .column-picker>summary { list-style:none; cursor:pointer; }
.saved-views>summary::-webkit-details-marker, .column-picker>summary::-webkit-details-marker { display:none; }
.saved-views__panel { position:absolute; z-index:70; top:calc(100% + 8px); right:0; width:350px; max-width:calc(100vw - 28px); padding:18px; border:1px solid var(--border-2); border-radius:12px; background:var(--surface-1); box-shadow:var(--shadow-2); }
.saved-views__list { display:grid; gap:6px; max-height:300px; overflow:auto; margin:12px 0; }
.saved-views__item { display:flex; align-items:center; gap:6px; padding:6px 0; border-bottom:1px solid var(--border); }
.saved-views__item>button:first-child { flex:1; text-align:left; overflow-wrap:anywhere; }
.saved-views__form { display:grid; gap:10px; margin-top:12px; }
.saved-views__form .input { width:100%; }
.saved-views__note { color:var(--text-3); font-size:12px; }
.profile-grid { display:grid; grid-template-columns:minmax(230px,1fr) minmax(300px,1.3fr); gap:20px; max-width:1000px; }
.profile-grid .form { max-width:500px; }
.profile-grid .form__row { display:grid; gap:6px; }
.reporting-strip { display:flex; justify-content:space-between; align-items:center; gap:16px; padding:16px 18px; border:1px solid var(--border); border-radius:12px; background:var(--surface-1); }
.reporting-strip strong { font-size:14px; }
.reporting-strip p { margin-top:5px; color:var(--text-2); font-size:12px; }
.reporting-strip details { margin-top:7px; font-size:12px; }
.reporting-strip summary, .overview-basis summary { cursor:pointer; color:var(--accent-ink); }
.reporting-strip.is-incomplete { border-color:color-mix(in srgb,var(--warning) 38%,var(--border)); background:color-mix(in srgb,var(--warning) 7%,var(--surface-1)); }
.overview-trust { gap:7px; }
.overview-scope { font-size:12px; color:var(--text-2); padding:0 2px; }
.overview-kpis .kpirow { grid-template-columns:repeat(4,minmax(0,1fr)); gap:12px; }
.overview-kpis .tile { min-height:134px; }
.overview-snapshot { display:flex; align-items:flex-start; flex-wrap:wrap; gap:10px 18px; }
.overview-context { font-size:12px; color:var(--text-2); display:grid; gap:5px; flex:1; min-width:250px; }
.overview-context details { margin-top:2px; }
.overview-basis p { margin-top:6px; }
.overview-caution { color:var(--text-2); }
.overview-actions { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:12px; }
.overview-action { text-align:left; padding:17px 18px; display:grid; gap:7px; background:var(--surface-1); border:1px solid var(--border); border-radius:12px; }
.overview-action:hover { border-color:var(--accent); }
.overview-action__title { font-weight:600; color:var(--accent-ink); }
.overview-action .muted { font-size:12px; }
.overview-supply { display:flex; gap:32px; align-items:center; }
.overview-supply>div { display:grid; gap:4px; flex:none; }
.overview-supply strong { font-size:22px; letter-spacing:-.03em; font-weight:600; }
.overview-supply p { margin-left:auto; max-width:420px; font-size:12px; }
.overview-grid .card--flush .dt__toolbar { flex-wrap:wrap; }
.overview-grid .card--flush .dt__tools { flex-wrap:wrap; margin-left:0; }
.is-updating .overview-kpis, .is-updating .overview-trust, .is-updating .overview-snapshot { opacity:.5; }
.is-updating::before { content:'Оновлюємо дані…'; display:block; color:var(--text-2); font-size:12px; margin-bottom:8px; }
.dt__toolbar { flex-wrap:wrap; gap:10px; padding:12px 16px; }
.dt__tools { flex-wrap:wrap; }
.dt__info, .dt__note { font-size:12px; }
.dt { font-size:13px; }
.dt--dense tbody td { padding:9px 10px; }
.dt--dense thead th { padding:10px; }
.dt__foot { flex-wrap:wrap; padding:12px 16px; gap:8px; }
.dt__note { max-width:100%; }
.dt__loading { font-size:12px; color:var(--accent-ink); }
.column-picker { position:relative; }
.column-picker__panel { position:absolute; right:0; top:calc(100% + 6px); z-index:25; background:var(--surface-1); border:1px solid var(--border-2); border-radius:10px; box-shadow:var(--shadow-2); padding:12px; min-width:210px; max-height:320px; overflow:auto; }
.column-picker__panel label { display:flex; gap:8px; align-items:center; padding:5px; font-size:12px; }
.info { font-size:13px; }
@media (max-width:1280px) {
  :root { --nav-w:190px; }
  .topbar, .content { padding-left:18px; padding-right:18px; }
  .view-tools, .filterbar, .filterbar__row2 { padding-left:18px; padding-right:18px; }
  .topbar__meta { display:none; }
  .overview-kpis .tile { padding:16px; }
}
@media (max-width:1024px) {
  :root { --nav-w:60px; }
  .brand { padding:0 17px; }
  .nav { padding:12px 7px; }
  .nav__item { justify-content:center; padding:9px 0; }
  .nav__group { display:none; }
  .overview-grid> [style*="span 5"], .overview-grid>[style*="span 7"] { grid-column:span 12!important; }
  .overview-kpis .tile__value { font-size:25px; }
  .view-tools__label { display:none; }
}
@media (max-width:720px) {
  :root { --header-h:56px; }
  .app { grid-template-columns:0 minmax(0,1fr); }
  .topbar { gap:9px; padding:0 12px; z-index:60; }
  .topbar__title { font-size:16px; }
  .topbar__right { gap:6px; }
  .topbar .datamode, .usermenu .pill { display:none; }
  .usermenu { gap:4px; font-size:12px; }
  .usermenu .btn { padding:4px; }
  .nav-toggle { display:inline-flex; min-width:34px; align-items:center; justify-content:center; font-size:18px; }
  .nav { display:none; position:fixed; z-index:59; top:var(--header-h); left:0; width:258px; height:calc(100dvh - var(--header-h)); padding:12px; box-shadow:var(--shadow-2); }
  .nav-open .nav { display:flex; }
  .nav-open .nav-backdrop { display:block; position:fixed; inset:var(--header-h) 0 0; background:rgba(0,0,0,.36); z-index:58; }
  .nav-open { overflow:hidden; }
  .nav .nav__group { display:block; padding:14px 12px 4px; }
  .nav .nav__item { justify-content:flex-start; padding:10px 12px; min-height:42px; }
  .nav .nav__item span:not(.nav__icon) { display:inline; }
  .nav .nav__foot { display:block; }
  .content { padding:12px 12px 28px; }
  .view-tools { padding:10px 12px; gap:6px; }
  .view-tools__actions { gap:3px; }
  .view-tools .btn { font-size:11px; padding:5px 7px; min-height:34px; }
  .filters-toggle { display:inline-flex; white-space:nowrap; }
  .filterbar { display:none; padding:10px 12px; }
  .main.filters-open .filterbar { display:flex; }
  .filterbar .wkrange { flex-wrap:wrap; }
  .filterbar__row2 { padding:3px 12px 10px; gap:5px; font-size:11px; }
  .saved-views__panel { position:fixed; left:12px; right:12px; top:110px; width:auto; max-height:70dvh; overflow:auto; }
  .grid, .stack { gap:12px; }
  .grid>[style*="span"] { grid-column:span 12!important; }
  .card__head { padding:15px 14px 10px; gap:8px; }
  .card__body { padding:0 14px 14px; }
  .card--flush .card__body { padding:0; }
  .card__title { font-size:14px; }
  .card__sub { font-size:12px; }
  .card__actions { max-width:100%; }
  .seg { max-width:100%; flex-wrap:wrap; }
  .seg__btn { white-space:normal; }
  .kpirow, .overview-kpis .kpirow { grid-template-columns:repeat(2,minmax(0,1fr)); gap:8px; }
  .tile, .overview-kpis .tile { padding:13px; min-height:115px; }
  .tile__value { font-size:27px; }
  .tile__label, .tile__deltalabel, .tile__foot { font-size:11px; }
  .tile__spark { display:none; }
  .reporting-strip { padding:13px; flex-direction:column; align-items:flex-start; gap:10px; }
  .reporting-strip strong { font-size:13px; }
  .overview-scope { font-size:11px; }
  .overview-actions { grid-template-columns:1fr; gap:8px; }
  .overview-action { padding:13px 15px; }
  .overview-supply { flex-wrap:wrap; gap:18px 25px; }
  .overview-supply p { margin-left:0; }
  .overview-snapshot { gap:9px; }
  .overview-context { min-width:0; flex-basis:100%; }
  .profile-grid { grid-template-columns:1fr; gap:12px; }
  .dt__toolbar { padding:10px 12px; }
  .dt__tools { margin-left:0; gap:6px; }
  .dt__tools .btn { font-size:11px; }
  .dt__foot { padding:10px 12px; }
  .dt__note { margin-left:0; }
  .dt th.sticky, .dt td.sticky { max-width:190px; min-width:140px!important; }
  .column-picker__panel { right:auto; left:0; }
  .form__row--inline { flex-direction:column; align-items:stretch; }
  .pl-hero { flex-wrap:wrap; }
}
@media print { .view-tools,.nav-toggle,.nav-backdrop,.usermenu { display:none!important; } }
