/* UpEnergy Reports - shared theme (from the External Impact and ICS Monitoring apps)
   Brand: UpEnergy blue #006593 (from upenergygroup.com), orange #E36C26,
   slate #2C3E50. Series colors validated for colorblind separation in both
   modes (adjacent-pair CVD dE >= 8.4, normal-vision dE >= 19.8). */

:root {
  color-scheme: light;
  --bg: #f4f6f8;
  --surface: #ffffff;
  --surface-2: #f8fafb;
  --ink: #1f2f3d;
  --ink-2: #53687a;
  --muted: #7d8d9a;
  --grid: #e7ebef;
  --axis: #c9d2d9;
  --border: rgba(44, 62, 80, 0.10);
  --shadow: 0 1px 2px rgba(31, 47, 61, 0.04), 0 4px 16px rgba(31, 47, 61, 0.05);

  --primary: #006593;
  --primary-strong: #004e72;
  --primary-soft: #e6f1f6;
  --accent: #e36c26;
  --accent-soft: #fdf1ea;
  --good: #0f7b3f;
  --bad: #b3422a;
  --warn: #c98500;

  --s1: #006593; /* product slot 1 */
  --s2: #e36c26;
  --s3: #1baf7a;
  --s4: #eda100;
  --s-other: #a3aeb8;

  --map-dot: #006593;
  --radius: 14px;
  --font: "Inter", "Poppins", system-ui, -apple-system, "Segoe UI", sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    color-scheme: dark;
    --bg: #0b1820;
    --surface: #132530;
    --surface-2: #172c38;
    --ink: #e8eef2;
    --ink-2: #a9bac5;
    --muted: #7f929e;
    --grid: #21394a;
    --axis: #2f4a5c;
    --border: rgba(255, 255, 255, 0.08);
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 6px 20px rgba(0, 0, 0, 0.25);
    --primary: #2b9ed6;
    --primary-strong: #57b4e2;
    --primary-soft: #16374a;
    --accent: #e8793a;
    --accent-soft: #33231a;
    --good: #3ccf7f;
    --bad: #f08a6f;
    --warn: #eda100;
    --s1: #2b9ed6;
    --s2: #d95f1e;
    --s3: #199e70;
    --s4: #c98500;
    --s-other: #5f7483;
    --map-dot: #2b9ed6;
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0b1820;
  --surface: #132530;
  --surface-2: #172c38;
  --ink: #e8eef2;
  --ink-2: #a9bac5;
  --muted: #7f929e;
  --grid: #21394a;
  --axis: #2f4a5c;
  --border: rgba(255, 255, 255, 0.08);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 6px 20px rgba(0, 0, 0, 0.25);
  --primary: #2b9ed6;
  --primary-strong: #57b4e2;
  --primary-soft: #16374a;
  --accent: #e8793a;
  --accent-soft: #33231a;
  --good: #3ccf7f;
  --bad: #f08a6f;
  --warn: #eda100;
  --s1: #2b9ed6;
  --s2: #d95f1e;
  --s3: #199e70;
  --s4: #c98500;
  --s-other: #5f7483;
  --map-dot: #2b9ed6;
}

/* ------------------------------------------------------------ base */

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

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, p { margin: 0; }

a { color: var(--primary); }

.wrap {
  width: 100%;
  max-width: 1240px;
  margin: 0 auto;
  padding: 0 16px;
}
@media (min-width: 720px) { .wrap { padding: 0 28px; } }

[hidden] { display: none !important; }

:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

/* ------------------------------------------------------------ top bar */

.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.topbar__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
  gap: 12px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--ink);
  min-width: 0;
}
.brand { gap: 14px; }
.brand__logo { height: 34px; width: auto; flex: none; display: block; }
/* Light logo by default; the reversed (white wordmark) variant in dark mode. */
.brand__logo--dark { display: none; }
:root[data-theme="dark"] .brand__logo--light { display: none; }
:root[data-theme="dark"] .brand__logo--dark { display: block; }
@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) .brand__logo--light { display: none; }
  :root:where(:not([data-theme="light"])) .brand__logo--dark { display: block; }
}
.brand__divider { width: 1px; height: 22px; background: var(--axis); }
.brand__product { font-weight: 500; font-size: 14px; color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.topbar__actions { display: flex; align-items: center; gap: 8px; }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 36px;
  padding: 0 14px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--ink);
  font: 500 13px var(--font);
  text-decoration: none;
  cursor: pointer;
  transition: background-color .15s, border-color .15s;
}
.btn:hover { background: var(--surface-2); border-color: var(--axis); }
.btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.btn--icon { width: 36px; padding: 0; justify-content: center; }
.icon-moon { display: none; }
:root[data-theme="dark"] .icon-sun { display: none; }
:root[data-theme="dark"] .icon-moon { display: block; }
@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) .icon-sun { display: none; }
  :root:where(:not([data-theme="light"])) .icon-moon { display: block; }
}

@media (max-width: 560px) {
  .hide-sm { display: none; }
  .btn--ghost { width: 36px; padding: 0; justify-content: center; }
  .brand__divider, .brand__product { display: none; }
}

/* ------------------------------------------------------------ hero */

.hero {
  background:
    radial-gradient(1200px 400px at 85% -10%, rgba(227, 108, 38, 0.18), transparent 60%),
    linear-gradient(120deg, #006593 0%, #004e72 70%, #003f5c 100%);
  color: #f5f9fb;
  padding: 36px 0 64px;
}
.eyebrow {
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #ffc9a6;
  margin-bottom: 8px;
}
.hero h1 {
  font-size: clamp(24px, 4vw, 34px);
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: -0.02em;
  max-width: 22ch;
}
.hero__lede {
  margin-top: 10px;
  max-width: 60ch;
  color: rgba(245, 249, 251, 0.82);
  font-size: 15px;
}

/* ------------------------------------------------------------ filters */

.filters {
  position: sticky;
  top: calc(8px + env(safe-area-inset-top, 0px));
  z-index: 1000;
  margin-top: -32px;
}
.filters__panel {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 12px 16px;
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.filters__status {
  margin-left: auto;
  color: var(--muted);
  font-size: 13px;
  align-self: center;
}
@media (max-width: 720px) {
  .filters__panel { gap: 10px; padding: 12px; }
  .field--country, .field--product { flex: 1 1 100%; }
  .filters__panel .field:not(.field--country):not(.field--product) { flex: 1 1 0; }
  .filters__panel select { min-width: 0; width: 100%; }
  .filters__status { flex: 1 1 100%; margin-left: 0; }
}

.field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.field__label { font-size: 12px; font-weight: 500; color: var(--ink-2); }
select, input[type="number"] {
  appearance: none;
  height: 38px;
  min-width: 120px;
  padding: 0 34px 0 12px;
  border-radius: 10px;
  border: 1px solid var(--axis);
  background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M3 4.5 6 7.5 9 4.5' fill='none' stroke='%237d8d9a' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") no-repeat right 12px center;
  color: var(--ink);
  font: 500 14px var(--font);
  cursor: pointer;
}
.field--country select { min-width: 180px; }
.field--product select { min-width: 220px; }
input[type="number"] { background-image: none; padding-right: 12px; cursor: text; width: 100%; }
select:hover, input[type="number"]:hover { border-color: var(--muted); }
select:focus-visible, input:focus-visible { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
input[type="range"] { width: 100%; accent-color: var(--primary); height: 38px; }

/* ------------------------------------------------------------ layout */

/* main also carries .wrap (horizontal padding), so only set the vertical sides. */
main.wrap { padding-top: 40px; padding-bottom: 48px; display: grid; gap: 20px; transition: opacity .2s; }
@media (max-width: 720px) { main.wrap { padding-top: 24px; } }
main.is-loading { opacity: 0.55; pointer-events: none; }

.grid { display: grid; gap: 20px; grid-template-columns: repeat(12, minmax(0, 1fr)); }
.grid > * { grid-column: span 12; }
@media (min-width: 960px) {
  .span-5 { grid-column: span 5; }
  .span-7 { grid-column: span 7; }
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  min-width: 0;
}
@media (min-width: 720px) { .card { padding: 24px; } }
.card__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 16px;
}
.card__title { font-size: 17px; font-weight: 600; letter-spacing: -0.01em; }
.card__sub { font-size: 13px; color: var(--ink-2); margin-top: 2px; }
.card__note { font-size: 12.5px; color: var(--muted); margin-top: 14px; line-height: 1.5; }

.alert {
  background: var(--accent-soft);
  border: 1px solid var(--accent);
  color: var(--ink);
  border-radius: var(--radius);
  padding: 14px 18px;
  font-size: 14px;
}

/* ------------------------------------------------------------ KPIs */

.kpis {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
@media (min-width: 720px) { .kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (min-width: 1100px) { .kpis { grid-template-columns: 1.6fr repeat(5, minmax(0, 1fr)); } }

.kpi {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px 18px;
  min-width: 0;
}
.kpi--hero {
  grid-column: span 2;
  background: linear-gradient(135deg, var(--surface) 55%, var(--primary-soft));
  border-top: 3px solid var(--accent);
}
@media (min-width: 720px) { .kpi--hero { grid-column: span 3; } }
@media (min-width: 1100px) { .kpi--hero { grid-column: span 1; } }
.kpi__label { font-size: 12px; font-weight: 500; color: var(--ink-2); line-height: 1.35; }
.kpi__value {
  font-size: 26px;
  font-weight: 600;
  letter-spacing: -0.02em;
  margin-top: 4px;
  line-height: 1.2;
  overflow-wrap: anywhere;
}
.kpi--hero .kpi__value { font-size: clamp(30px, 4vw, 38px); color: var(--primary); }
.kpi__meta { font-size: 12.5px; color: var(--muted); margin-top: 4px; }
.delta { font-weight: 600; }
.delta--up { color: var(--good); }
.delta--down { color: var(--bad); }

/* ------------------------------------------------------------ segmented control */

.seg {
  display: inline-flex;
  padding: 3px;
  gap: 2px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
}
.seg__btn {
  border: 0;
  background: transparent;
  color: var(--ink-2);
  font: 500 12.5px var(--font);
  padding: 6px 12px;
  border-radius: 7px;
  cursor: pointer;
}
.seg__btn:hover { color: var(--ink); }
.seg__btn.is-active { background: var(--surface); color: var(--ink); box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08); }

/* ------------------------------------------------------------ legend */

.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; margin: -4px 0 12px; font-size: 12.5px; color: var(--ink-2); }
.legend__item { display: inline-flex; align-items: center; gap: 6px; }
.legend__swatch { width: 10px; height: 10px; border-radius: 3px; flex: none; }

/* ------------------------------------------------------------ charts */

.chart { position: relative; width: 100%; height: 300px; }
.chart--md { height: 300px; }
@media (min-width: 720px) { .chart--md { height: 320px; } }

/* HTML bar list (product breakdown) */
.bars { display: grid; gap: 12px; }
.bar { display: grid; gap: 5px; }
.bar__top { display: flex; justify-content: space-between; gap: 12px; font-size: 13px; }
.bar__name { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar__val { color: var(--ink-2); font-variant-numeric: tabular-nums; white-space: nowrap; }
.bar__val b { color: var(--ink); font-weight: 600; }
.bar__track { height: 8px; border-radius: 4px; background: var(--grid); overflow: hidden; }
.bar__fill { height: 100%; border-radius: 4px; background: var(--s1); min-width: 2px; transition: width .4s ease; }

/* Gender split */
.split { display: flex; height: 14px; gap: 2px; border-radius: 7px; overflow: hidden; margin: 6px 0 16px; }
.split__seg { height: 100%; min-width: 2px; }
.split-rows { display: grid; gap: 10px; }
.split-row { display: flex; align-items: center; gap: 10px; font-size: 14px; }
.split-row__name { flex: 1; }
.split-row__pct { font-weight: 600; font-variant-numeric: tabular-nums; }
.split-row__n { color: var(--muted); font-size: 12.5px; font-variant-numeric: tabular-nums; min-width: 84px; text-align: right; }
.gender-hero { font-size: 32px; font-weight: 600; letter-spacing: -0.02em; color: var(--primary); line-height: 1.1; }
.gender-hero small { display: block; font-size: 13px; font-weight: 400; color: var(--ink-2); letter-spacing: 0; margin-top: 4px; }

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

.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: 10px; }
.table-wrap--tall { max-height: 520px; overflow-y: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th, td { padding: 10px 14px; text-align: left; white-space: nowrap; }
th {
  position: sticky;
  top: 0;
  z-index: 3; /* above body cells, incl. sticky first columns (1) and positioned content */
  background: var(--surface-2);
  color: var(--ink-2);
  font-weight: 500;
  font-size: 12px;
  border-bottom: 1px solid var(--border);
}
td { border-bottom: 1px solid var(--grid); }
tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: var(--surface-2); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
td.muted { color: var(--muted); }

/* ------------------------------------------------------------ map */

.card--map { padding-bottom: 18px; }
.map {
  height: 460px;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--surface-2);
  z-index: 0;
}
@media (max-width: 720px) { .map { height: 360px; } }
.map-wrap { position: relative; }
.map-empty {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  z-index: 500;
  max-width: min(360px, calc(100% - 32px));
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  border-radius: 10px;
  padding: 12px 16px;
  font-size: 13px;
  color: var(--ink-2);
  text-align: center;
}
.leaflet-container { font-family: var(--font); background: var(--surface-2); }
.leaflet-control-attribution { font-size: 10px; background: color-mix(in srgb, var(--surface) 85%, transparent) !important; color: var(--muted); }
.leaflet-control-attribution a { color: var(--ink-2); }
.leaflet-bar a { background: var(--surface); color: var(--ink); border-color: var(--border); }
.leaflet-bar a:hover { background: var(--surface-2); }

.map-legend { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 18px; margin-top: 12px; font-size: 12.5px; color: var(--ink-2); }
.map-legend__item { display: inline-flex; align-items: center; gap: 8px; }
.map-legend__dot { border-radius: 50%; background: var(--map-dot); opacity: 0.6; border: 1px solid var(--surface); flex: none; }

/* ------------------------------------------------------------ tooltip */

.tooltip {
  position: fixed;
  z-index: 2000;
  pointer-events: none;
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--border);
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.14);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 12.5px;
  min-width: 150px;
  max-width: 280px;
}
.tooltip__title { font-weight: 600; margin-bottom: 6px; }
.tooltip__row { display: flex; align-items: center; gap: 8px; line-height: 1.7; }
.tooltip__row span:nth-child(2) { flex: 1; color: var(--ink-2); }
.tooltip__row b { font-variant-numeric: tabular-nums; font-weight: 600; }
.tooltip__total { border-top: 1px solid var(--grid); margin-top: 4px; padding-top: 4px; }

/* ------------------------------------------------------------ footer */

.footer { border-top: 1px solid var(--border); padding: 20px 0 32px; color: var(--muted); font-size: 12.5px; }
.footer__inner { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px 24px; }
.footer__inner p:first-child { max-width: 75ch; }

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

/* ------------------------------------------------------------ shared pieces from the ICS app */

:root {
  --good-bg: #e2f3e9; --good-ink: #0d6633;
  --fair-bg: #fcefd2; --fair-ink: #835400;
  --low-bg:  #fbe3dc; --low-ink:  #a1371f;
  --day-none: #e4e9ed;
  --day-data: #c3d0d9;
}
@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    --good-bg: #133a2a; --good-ink: #72dba5;
    --fair-bg: #3a2f13; --fair-ink: #f0c25e;
    --low-bg:  #401f18; --low-ink:  #f59c84;
    --day-none: #1b3240;
    --day-data: #355266;
  }
}
:root[data-theme="dark"] {
  --good-bg: #133a2a; --good-ink: #72dba5;
  --fair-bg: #3a2f13; --fair-ink: #f0c25e;
  --low-bg:  #401f18; --low-ink:  #f59c84;
  --day-none: #1b3240;
  --day-data: #355266;
}

:root { padding-top: env(safe-area-inset-top, 0px); padding-bottom: env(safe-area-inset-bottom, 0px); }
html { scroll-padding-top: env(safe-area-inset-top, 0px); }

.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
code { font-size: 0.92em; }

.filters__panel .field select { min-width: 150px; }
@media (max-width: 720px) {
  .filters__panel .field:not(.field--country):not(.field--product) { flex: 1 1 calc(50% - 10px); }
  .filters__panel .field select { min-width: 0; width: 100%; }
}
.field--inline select { min-width: 250px; }
@media (max-width: 560px) { .field--inline, .field--inline select { width: 100%; min-width: 0; } }

.alert--demo { background: var(--primary-soft); border-color: var(--primary); }

.chart--lg { height: 320px; }
@media (min-width: 720px) { .chart--lg { height: 360px; } }

/* KPI hero tint follows the cooking colour family */
.kpi__value small { font-size: 0.5em; font-weight: 500; color: var(--ink-2); margin-left: 2px; }

/* group rows */
.meter { display: flex; align-items: center; gap: 10px; min-width: 160px; }
.meter__track { flex: 1; height: 8px; background: var(--grid); border-radius: 4px; overflow: hidden; }
.meter__fill { height: 100%; border-radius: 4px; background: var(--s1); }
.meter__val { width: 46px; text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; font-size: 13px; }

/* device table */
.search { position: relative; display: flex; align-items: center; }
.search svg { position: absolute; left: 11px; width: 16px; height: 16px; fill: none; stroke: var(--muted); stroke-width: 1.7; stroke-linecap: round; }
.search input {
  height: 38px; width: 280px; max-width: 100%; padding: 0 12px 0 34px;
  border-radius: 10px; border: 1px solid var(--axis); background: var(--surface); color: var(--ink); font: 500 14px var(--font);
}
.search input:focus-visible { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
@media (max-width: 560px) { .search, .search input { width: 100%; } }

.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.chip {
  display: inline-flex; align-items: center; gap: 8px; height: 32px; padding: 0 12px;
  border-radius: 16px; border: 1px solid var(--border); background: var(--surface-2);
  color: var(--ink-2); font: 500 13px var(--font); cursor: pointer;
}
.chip b { color: var(--ink); font-weight: 600; font-variant-numeric: tabular-nums; }
.chip:hover { border-color: var(--axis); }
.chip[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: var(--surface); }
.chip[aria-pressed="true"] b { color: var(--surface); }
.dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }

.key { display: flex; flex-wrap: wrap; gap: 6px 18px; font-size: 12px; color: var(--ink-2); margin-bottom: 12px; }
.key__item { display: inline-flex; align-items: center; gap: 6px; }
.key__sw { width: 14px; height: 14px; border-radius: 4px; flex: none; }

.linkbtn {
  border: 0; background: none; padding: 0; color: var(--primary); font: 600 13.5px var(--font);
  cursor: pointer; text-decoration: underline; text-decoration-color: color-mix(in srgb, var(--primary) 35%, transparent);
  text-underline-offset: 3px;
}
.linkbtn:hover { text-decoration-color: currentColor; }

.status { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 500; }

.stat__value small { font-size: 13px; font-weight: 500; color: var(--muted); margin-left: 4px; }
.stat__value--sm { font-size: 17px; }

/* ============================================================
   Platform shell (UpEnergy Reports)
   ============================================================ */

:root {
  --warn-bg: #fcefd2; --warn-ink: #835400;
  --heat-0: #e4e9ed; --heat-1: #b9d6e4; --heat-2: #74b1cf; --heat-3: #2a86b4; --heat-4: #00577f;
  --topbar-h: 64px;
}
@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    --warn-bg: #3a2f13; --warn-ink: #f0c25e;
    --heat-0: #1b3240; --heat-1: #1f5a78; --heat-2: #2479a6; --heat-3: #2b9ed6; --heat-4: #86ccef;
  }
}
:root[data-theme="dark"] {
  --warn-bg: #3a2f13; --warn-ink: #f0c25e;
  --heat-0: #1b3240; --heat-1: #1f5a78; --heat-2: #2479a6; --heat-3: #2b9ed6; --heat-4: #86ccef;
}

body { min-height: 100vh; display: flex; flex-direction: column; font-feature-settings: "cv11", "ss01"; }
body > main, body > .page { flex: 1 0 auto; }
.num, td.num, .kpi__value, .bar__val, .tabnum { font-variant-numeric: tabular-nums; }

/* ------------------------------------------------------------ top bar */

.topbar { position: relative; z-index: 1100; }
.topbar__inner { gap: 16px; }
.topbar__left { display: flex; align-items: center; gap: 14px; min-width: 0; }
.topbar__actions { gap: 6px; }

.menu { position: relative; }
.menu > summary { list-style: none; cursor: pointer; }
.menu > summary::-webkit-details-marker { display: none; }
.menu__panel {
  position: absolute; top: calc(100% + 8px); left: 0; z-index: 1200; min-width: 280px; max-width: min(420px, calc(100vw - 24px));
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: 0 12px 40px rgba(0, 0, 0, 0.16);
  padding: 6px;
}
.menu--right .menu__panel { left: auto; right: 0; }
.menu__item {
  display: flex; flex-direction: column; gap: 1px; padding: 9px 12px; border-radius: 8px; color: var(--ink);
  text-decoration: none; font-size: 14px; font-weight: 500; border: 0; background: none; width: 100%; text-align: left; cursor: pointer; font-family: var(--font);
}
.menu__item small { color: var(--muted); font-weight: 400; font-size: 12px; }
.menu__item:hover, .menu__item:focus-visible, .menu__item[aria-selected="true"] { background: var(--surface-2); }
.menu__item.is-current { background: var(--primary-soft); }
.menu__sep { height: 1px; background: var(--border); margin: 6px 4px; }
.menu__label { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); padding: 8px 12px 4px; }

.switcher { display: inline-flex; align-items: center; gap: 6px; height: 36px; padding: 0 10px; border-radius: 10px; border: 1px solid transparent; font-weight: 500; font-size: 14px; color: var(--ink-2); max-width: 340px; }
.switcher:hover, .menu[open] .switcher { background: var(--surface-2); border-color: var(--border); color: var(--ink); }
.switcher span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.switcher svg { width: 14px; height: 14px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.gsearch { position: relative; }
.gsearch input {
  height: 36px; width: 240px; padding: 0 12px 0 34px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--surface-2); color: var(--ink); font: 500 13.5px var(--font);
}
.gsearch input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); background: var(--surface); }
.gsearch > svg { position: absolute; left: 11px; top: 10px; width: 16px; height: 16px; fill: none; stroke: var(--muted); stroke-width: 1.7; stroke-linecap: round; }
.gsearch .menu__panel { right: 0; left: auto; width: 360px; }
.gsearch kbd { position: absolute; right: 9px; top: 8px; font: 500 11px var(--font); color: var(--muted); border: 1px solid var(--border); border-radius: 5px; padding: 1px 5px; }
@media (max-width: 960px) { .gsearch input { width: 160px; } .gsearch kbd { display: none; } }
@media (max-width: 720px) { .gsearch { display: none; } .switcher { max-width: 160px; } }

.avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--primary); color: #fff; display: inline-grid; place-items: center; font-weight: 600; font-size: 13px; overflow: hidden; flex: none; }
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar-btn { border-radius: 50%; padding: 2px; border: 1px solid transparent; }
.avatar-btn:hover, .menu[open] .avatar-btn { border-color: var(--axis); }
.menu__who { padding: 10px 12px 8px; font-size: 13px; }
.menu__who b { display: block; font-weight: 600; }
.menu__who span { color: var(--muted); font-size: 12px; word-break: break-all; }
.rolechips { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.rolechip { font-size: 11px; font-weight: 600; padding: 2px 7px; border-radius: 999px; background: var(--primary-soft); color: var(--primary); }

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

.dhead { background: radial-gradient(1200px 400px at 85% -10%, rgba(227, 108, 38, 0.18), transparent 60%), linear-gradient(120deg, #006593 0%, #004e72 70%, #003f5c 100%); color: #f5f9fb; padding: 22px 0 0; }
.dhead__row { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 14px 24px; }
.dhead h1 { font-size: clamp(21px, 3vw, 28px); font-weight: 600; letter-spacing: -0.02em; line-height: 1.2; }
.dhead .eyebrow { margin-bottom: 4px; }
.dhead__sub { color: rgba(245, 249, 251, 0.82); font-size: 14px; margin-top: 4px; max-width: 70ch; }
.dhead__actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.dhead .btn { background: rgba(255, 255, 255, 0.10); border-color: rgba(255, 255, 255, 0.22); color: #fff; }
.dhead .btn:hover { background: rgba(255, 255, 255, 0.18); border-color: rgba(255, 255, 255, 0.4); }
.fresh { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; color: rgba(245, 249, 251, 0.85); background: rgba(0, 0, 0, 0.16); border-radius: 999px; padding: 4px 10px; }
.fresh::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: #3ccf7f; }
.fresh--stale::before { background: #eda100; }
.fresh--error::before { background: #f08a6f; }
.crumbs { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; font-size: 13px; color: rgba(245, 249, 251, 0.75); margin-bottom: 6px; }
.crumbs a, .crumbs button { color: #fff; text-decoration: none; font: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
.crumbs a:hover, .crumbs button:hover { text-decoration: underline; }
.crumbs__sep { opacity: .55; }

.tabs { position: sticky; top: 0; z-index: 1050; background: var(--surface); border-bottom: 1px solid var(--border); box-shadow: 0 1px 0 rgba(0, 0, 0, 0.02); }
.tabs__inner { display: flex; gap: 2px; overflow-x: auto; scrollbar-width: none; }
.tabs__inner::-webkit-scrollbar { display: none; }
.tab { display: inline-flex; align-items: center; gap: 6px; padding: 14px 14px 12px; color: var(--ink-2); font-weight: 500; font-size: 14px; text-decoration: none; border-bottom: 2px solid transparent; white-space: nowrap; }
.tab:hover { color: var(--ink); }
.tab[aria-current="page"] { color: var(--primary); border-bottom-color: var(--primary); }
.tab--docs { margin-left: auto; }
.tab svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }

.dash .filters { margin-top: 16px; top: 58px; z-index: 1000; }
@media (max-width: 720px) { .dash .filters { position: static; } }
.filters__summary { flex: 1 1 100%; display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; font-size: 13px; color: var(--muted); border-top: 1px solid var(--grid); padding-top: 10px; margin-top: 2px; }
.filters__summary b { color: var(--ink-2); font-weight: 500; }
.linkish { background: none; border: 0; padding: 0; color: var(--primary); font: 500 13px var(--font); cursor: pointer; }
.linkish:hover { text-decoration: underline; }
.field--dates { display: flex; gap: 6px; }
.field--dates input[type="date"] {
  height: 38px; padding: 0 8px; border-radius: 10px; border: 1px solid var(--axis); background: var(--surface); color: var(--ink); font: 500 13px var(--font); min-width: 0;
}
.filters__more { display: contents; }
.filters__toggle { display: none !important; }
@media (max-width: 720px) {
  .filters__toggle { display: inline-flex !important; }
  .filters__panel:not(.is-open) .filters__more { display: none; }
}
.dash main.wrap { padding-top: 20px; }

/* ------------------------------------------------------------ KPI cards */

.kpis--6 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (min-width: 720px) { .kpis--6 { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (min-width: 1180px) { .kpis--6 { grid-template-columns: repeat(6, minmax(0, 1fr)); } }
.kpis--4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (min-width: 960px) { .kpis--4 { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.kpis--8 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (min-width: 720px) { .kpis--8 { grid-template-columns: repeat(4, minmax(0, 1fr)); } }

.kpi { position: relative; display: flex; flex-direction: column; gap: 2px; }
.kpi__head { display: flex; align-items: flex-start; justify-content: space-between; gap: 6px; }
.kpi__cmp { font-size: 12.5px; color: var(--ink-2); margin-top: 2px; }
.kpi__foot { display: flex; align-items: flex-end; justify-content: space-between; gap: 8px; margin-top: auto; padding-top: 8px; min-height: 30px; }
.kpi--hero .kpi__value { font-size: clamp(28px, 3.4vw, 34px); }
.kpi.is-good { box-shadow: inset 3px 0 0 var(--good), var(--shadow); }
.kpi.is-warn { box-shadow: inset 3px 0 0 var(--warn), var(--shadow); }
.kpi.is-bad { box-shadow: inset 3px 0 0 var(--bad), var(--shadow); }
.spark { width: 84px; height: 26px; flex: none; overflow: visible; }
.spark path { fill: none; stroke: var(--primary); stroke-width: 1.6; stroke-linejoin: round; stroke-linecap: round; }
.spark circle { fill: var(--primary); }
.spark .spark__area { fill: var(--primary-soft); stroke: none; }

.info-btn { flex: none; width: 22px; height: 22px; border-radius: 50%; border: 1px solid var(--border); background: var(--surface); color: var(--muted); display: inline-grid; place-items: center; cursor: pointer; padding: 0; margin: -2px -4px 0 0; }
.info-btn:hover { color: var(--primary); border-color: var(--primary); }
.info-btn svg { width: 12px; height: 12px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }

/* ------------------------------------------------------------ status pills (colour + icon, never colour alone) */

.pill { display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 8px 0 6px; border-radius: 999px; font-size: 11.5px; font-weight: 600; white-space: nowrap; }
.pill svg { width: 12px; height: 12px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.pill--good, .pill--active { background: var(--good-bg); color: var(--good-ink); }
.pill--warn, .pill--at_risk { background: var(--warn-bg); color: var(--warn-ink); }
.pill--bad, .pill--inactive { background: var(--low-bg); color: var(--low-ink); }
.pill--new { background: var(--primary-soft); color: var(--primary); }
.pill--none, .pill--churned { background: var(--surface-2); color: var(--muted); box-shadow: inset 0 0 0 1px var(--border); }
.pill--est { background: var(--accent-soft); color: var(--accent); }

.good { color: var(--good); } .bad { color: var(--bad); } .warn { color: var(--warn-ink); }

/* ------------------------------------------------------------ side drawer (KPI docs) */

.sdrawer { position: fixed; inset: 0; z-index: 3000; display: flex; justify-content: flex-end; }
.sdrawer[hidden] { display: none; }
.sdrawer__scrim { position: absolute; inset: 0; background: rgba(11, 24, 32, 0.45); animation: fade .15s ease-out; }
.sdrawer__panel { position: relative; width: min(480px, 100vw); height: 100%; overflow-y: auto; background: var(--surface); box-shadow: -12px 0 40px rgba(0, 0, 0, 0.2); padding: 22px 24px 32px; animation: slide-in .2s ease-out; }
@keyframes slide-in { from { transform: translateX(24px); opacity: 0; } }
@keyframes fade { from { opacity: 0; } }
.sdrawer__head { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; margin-bottom: 14px; }
.sdrawer__head h2 { font-size: 19px; font-weight: 600; letter-spacing: -0.01em; }

/* ------------------------------------------------------------ KPI doc card (docs page + drawer) */

.kdoc { display: grid; gap: 14px; font-size: 14px; }
.kdoc__q { font-size: 15px; color: var(--ink-2); font-style: italic; }
.kdoc__label { font-size: 11.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin-bottom: 4px; }
.kdoc__formula { background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 14px; overflow-x: auto; text-align: center; min-height: 52px; }
.kdoc__formula code { font-size: 13px; color: var(--ink-2); }
.kdoc__meta { display: flex; flex-wrap: wrap; gap: 6px; }
.tag { display: inline-flex; align-items: center; height: 22px; padding: 0 8px; border-radius: 6px; font-size: 12px; background: var(--surface-2); border: 1px solid var(--border); color: var(--ink-2); }
.tag--src { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 11.5px; }
.tbar { display: flex; height: 12px; border-radius: 6px; overflow: hidden; gap: 2px; }
.tbar__seg { height: 100%; }
.tbar__seg--good { background: var(--good); } .tbar__seg--warn { background: var(--warn); } .tbar__seg--bad { background: var(--bad); }
.tbar__labels { display: flex; justify-content: space-between; font-size: 11.5px; color: var(--muted); margin-top: 4px; font-variant-numeric: tabular-nums; }
.tbar__legend { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 12.5px; color: var(--ink-2); margin-top: 6px; }

/* ------------------------------------------------------------ states */

.skel { position: relative; overflow: hidden; background: var(--grid); border-radius: 6px; color: transparent !important; }
.skel::after { content: ""; position: absolute; inset: 0; transform: translateX(-100%); background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.45), transparent); animation: shimmer 1.3s infinite; }
:root[data-theme="dark"] .skel::after { background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.06), transparent); }
@keyframes shimmer { to { transform: translateX(100%); } }
.is-loading .kpi__value, .is-loading .kpi__cmp { position: relative; overflow: hidden; background: var(--grid); border-radius: 6px; color: transparent; }
.is-loading .kpi__value::after, .is-loading .kpi__cmp::after { content: ""; position: absolute; inset: 0; transform: translateX(-100%); background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.45), transparent); animation: shimmer 1.3s infinite; }
.is-loading .chart, .is-loading .skel-box { position: relative; }
.is-loading .chart::after, .is-loading .skel-box::after { content: ""; position: absolute; inset: 0; border-radius: 8px; background: linear-gradient(90deg, var(--surface-2), var(--grid), var(--surface-2)); background-size: 200% 100%; animation: shimmer-bg 1.3s infinite linear; opacity: .7; }
@keyframes shimmer-bg { from { background-position: 100% 0; } to { background-position: -100% 0; } }
main.is-loading { opacity: 1; pointer-events: auto; }
main.is-refreshing { opacity: 0.6; transition: opacity .15s; }

.state { display: grid; justify-items: center; gap: 10px; text-align: center; padding: 36px 16px; color: var(--ink-2); font-size: 14px; }
.state svg { width: 40px; height: 40px; fill: none; stroke: var(--muted); stroke-width: 1.4; stroke-linecap: round; stroke-linejoin: round; }
.state h3 { font-size: 16px; font-weight: 600; color: var(--ink); }
.state p { max-width: 52ch; }
.empty-inline { color: var(--muted); font-size: 13px; padding: 18px 4px; text-align: center; }
.alert--error { background: var(--low-bg); border-color: var(--bad); display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; }
.alert--loading { background: var(--primary-soft); border-color: var(--primary); display: flex; align-items: center; gap: 12px; }
.spinner { width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--primary-soft); border-top-color: var(--primary); animation: spin .8s linear infinite; flex: none; }
@keyframes spin { to { transform: rotate(360deg); } }
.alert--est { background: var(--accent-soft); border-color: var(--accent); font-size: 13.5px; }

/* ------------------------------------------------------------ card tools */

.card__tools { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.card--flush { padding: 0; overflow: hidden; }
.card__n { font-size: 12px; color: var(--muted); margin-top: 10px; }
.grid--2 > * { grid-column: span 12; }
@media (min-width: 960px) {
  .span-4 { grid-column: span 4; } .span-6 { grid-column: span 6; } .span-8 { grid-column: span 8; }
}
.chart--sm { height: 220px; }
.chart--xl { height: 420px; }
.toggle-view { margin-left: auto; }
.bars--compact { gap: 9px; }
.bar__fill--alt { background: var(--s2); }
.bar__fill--muted { background: var(--s-other); }
.bar[data-click] { cursor: pointer; border-radius: 6px; }
.bar[data-click]:hover .bar__name { color: var(--primary); text-decoration: underline; }
.bar__target { position: relative; }
.bar__marker { position: absolute; top: -3px; width: 2px; height: 14px; background: var(--ink); border-radius: 1px; }
.pair { display: grid; gap: 3px; }
.pair .bar__track { height: 6px; }

.table-wrap table th[data-sort] { cursor: pointer; user-select: none; }
.table-wrap table th[aria-sort="ascending"]::after { content: " ↑"; }
.table-wrap table th[aria-sort="descending"]::after { content: " ↓"; }
.t-sticky th:first-child, .t-sticky td:first-child { position: sticky; left: 0; z-index: 1; background: var(--surface); }
.t-sticky th:first-child { z-index: 4; background: var(--surface-2); } /* corner: above both */
.t-sticky tbody tr:hover td:first-child { background: var(--surface-2); }
td .sub { display: block; font-size: 11.5px; color: var(--muted); }
.rank { color: var(--muted); font-variant-numeric: tabular-nums; }

/* ------------------------------------------------------------ attention list */

.flags { display: grid; gap: 8px; counter-reset: flag; }
.flag { display: grid; grid-template-columns: auto 1fr auto; gap: 4px 12px; align-items: center; padding: 11px 12px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface-2); text-decoration: none; color: var(--ink); }
.flag:hover { border-color: var(--axis); background: var(--surface); }
.flag__icon { width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; }
.flag__icon svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.flag--bad .flag__icon { background: var(--low-bg); color: var(--low-ink); }
.flag--warn .flag__icon { background: var(--warn-bg); color: var(--warn-ink); }
.flag__title { font-weight: 600; font-size: 14px; }
.flag__why { font-size: 12.5px; color: var(--ink-2); grid-column: 2; }
.flag__go { grid-row: 1 / span 2; grid-column: 3; color: var(--muted); font-size: 18px; }
.allclear { display: flex; align-items: center; gap: 12px; padding: 16px; border-radius: 10px; background: var(--good-bg); color: var(--good-ink); font-weight: 500; }

/* ------------------------------------------------------------ to-date strip */

.todate { display: grid; gap: 1px; grid-template-columns: repeat(2, minmax(0, 1fr)); background: var(--border); border-radius: var(--radius); overflow: hidden; border: 1px solid var(--border); }
@media (min-width: 720px) { .todate { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (min-width: 1100px) { .todate { grid-template-columns: repeat(6, minmax(0, 1fr)); } }
.todate > div { background: var(--surface); padding: 14px 16px; }
.todate b { display: block; font-size: 20px; font-weight: 600; letter-spacing: -0.01em; font-variant-numeric: tabular-nums; }
.todate span { font-size: 12px; color: var(--ink-2); }

/* ------------------------------------------------------------ heatmap */

.heat { border-collapse: separate; border-spacing: 2px; font-size: 12px; }
.heat th { position: static; background: none; border: 0; padding: 4px 6px; font-weight: 500; color: var(--ink-2); }
.heat th.rowh { text-align: right; white-space: nowrap; }
.heat td { padding: 0; border: 0; min-width: 40px; height: 28px; text-align: center; border-radius: 4px; font-variant-numeric: tabular-nums; font-size: 11px; }
.heat td.h0 { background: var(--heat-0); color: var(--muted); }
.heat td.h1 { background: var(--heat-1); color: var(--ink); }
.heat td.h2 { background: var(--heat-2); color: #06202e; }
.heat td.h3 { background: var(--heat-3); color: #fff; }
.heat td.h4 { background: var(--heat-4); color: #fff; }
:root[data-theme="dark"] .heat td.h2 { color: #fff; }
.heat tbody tr:hover td { background-image: none; outline: 1px solid var(--axis); }
.heat td.h0, .heat td.h1, .heat td.h2, .heat td.h3, .heat td.h4 { border-bottom: 0; }
.heat-key { display: flex; align-items: center; gap: 4px; font-size: 12px; color: var(--muted); margin-top: 10px; }
.heat-key i { width: 22px; height: 10px; border-radius: 2px; display: inline-block; }

/* ------------------------------------------------------------ funnel */

.funnel { display: grid; gap: 10px; }
.funnel__step { display: grid; grid-template-columns: minmax(150px, 30%) 1fr; gap: 12px; align-items: center; }
.funnel__name { font-size: 13px; font-weight: 500; }
.funnel__name small { display: block; color: var(--muted); font-weight: 400; font-size: 12px; }
.funnel__bar { height: 30px; border-radius: 6px; background: var(--s1); display: flex; align-items: center; padding: 0 10px; color: #fff; font-weight: 600; font-size: 13px; min-width: 64px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.funnel__drop { font-size: 12px; color: var(--muted); grid-column: 2; margin-top: -6px; }
@media (max-width: 560px) { .funnel__step { grid-template-columns: 1fr; } .funnel__drop { grid-column: 1; } }

/* ------------------------------------------------------------ agent calendar (12 months) */

.acal-wrap { overflow-x: auto; padding-bottom: 4px; }
.acal { display: grid; grid-template-rows: 14px repeat(7, 11px); grid-auto-flow: column; grid-auto-columns: 11px; gap: 3px; width: max-content; }
.acal__m { font-size: 10.5px; color: var(--muted); white-space: nowrap; }
.acal__d { border-radius: 2px; background: var(--heat-0); }
.acal__d.h1 { background: var(--heat-1); } .acal__d.h2 { background: var(--heat-2); } .acal__d.h3 { background: var(--heat-3); } .acal__d.h4 { background: var(--heat-4); }
.acal__d.pre { background: transparent; }
.acal__d.off { background: transparent; box-shadow: inset 0 0 0 1px var(--grid); }

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

.agent-card { display: grid; gap: 16px; }
@media (min-width: 900px) { .agent-card { grid-template-columns: 1.2fr 2fr; align-items: start; } }
.agent-id { display: flex; gap: 14px; align-items: center; }
.agent-id .avatar { width: 52px; height: 52px; font-size: 18px; background: var(--accent); }
.agent-id h2 { font-size: 20px; font-weight: 600; letter-spacing: -0.01em; }
.facts { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); }
.fact { background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; }
.fact span { display: block; font-size: 11.5px; color: var(--ink-2); font-weight: 500; }
.fact b { display: block; font-size: 16px; font-weight: 600; margin-top: 2px; font-variant-numeric: tabular-nums; }
.cmp-list { display: grid; gap: 12px; }
.cmp-row { display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; font-size: 13px; }
.cmp-row__name { font-weight: 500; }
.cmp-row__vals { text-align: right; font-variant-numeric: tabular-nums; }
.cmp-row__vals small { color: var(--muted); }
.cmp-row .pair { grid-column: 1 / -1; }

/* ------------------------------------------------------------ catalogue */

.page { padding: 32px 0 56px; }
.hello { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 22px; }
.hello h1 { font-size: clamp(24px, 3.4vw, 32px); font-weight: 600; letter-spacing: -0.02em; }
.hello p { color: var(--ink-2); margin-top: 4px; }
.cat-tools { display: flex; flex-wrap: wrap; gap: 10px 16px; align-items: center; margin-bottom: 20px; }
.cat-tools .chips { margin: 0; }
.section-h { font-size: 13px; font-weight: 600; color: var(--ink-2); text-transform: uppercase; letter-spacing: .06em; margin: 26px 0 12px; }
.cards { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 320px), 1fr)); }
.dcard { position: relative; display: flex; flex-direction: column; gap: 10px; padding: 20px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow); color: var(--ink); text-decoration: none; transition: border-color .15s, transform .15s; min-height: 210px; }
.dcard:hover { border-color: var(--primary); transform: translateY(-1px); }
.dcard:focus-within { outline: 2px solid var(--primary); outline-offset: 2px; }
.dcard__link { position: absolute; inset: 0; border-radius: inherit; }
.dcard__link:focus-visible { outline: none; }
.dcard__top { display: flex; justify-content: space-between; gap: 12px; }
.dcard__icon { width: 40px; height: 40px; border-radius: 10px; display: grid; place-items: center; background: var(--primary-soft); color: var(--primary); flex: none; }
.dcard__icon svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.dcard h2 { font-size: 17px; font-weight: 600; letter-spacing: -0.01em; line-height: 1.3; }
.dcard__sum { font-size: 13.5px; color: var(--ink-2); }
.dcard__head { font-size: 22px; font-weight: 600; color: var(--primary); letter-spacing: -0.01em; font-variant-numeric: tabular-nums; }
.dcard__foot { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: auto; font-size: 12px; color: var(--muted); }
.dcard__foot .tag { position: relative; z-index: 1; }
.dcard__owner { margin-right: auto; }
.star { position: relative; z-index: 2; width: 32px; height: 32px; border-radius: 8px; border: 1px solid transparent; background: none; color: var(--muted); cursor: pointer; display: grid; place-items: center; padding: 0; }
.star:hover { background: var(--surface-2); border-color: var(--border); }
.star svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linejoin: round; }
.star[aria-pressed="true"] { color: var(--s4); }
.star[aria-pressed="true"] svg { fill: currentColor; }
.recent { display: flex; flex-wrap: wrap; gap: 8px; }
.recent a { display: inline-flex; align-items: center; gap: 8px; padding: 7px 12px; border-radius: 10px; background: var(--surface); border: 1px solid var(--border); text-decoration: none; color: var(--ink); font-size: 13.5px; font-weight: 500; }
.recent a:hover { border-color: var(--primary); }
.recent a small { color: var(--muted); font-weight: 400; }

/* ------------------------------------------------------------ login */

.login { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; background: radial-gradient(1200px 500px at 85% -10%, rgba(227, 108, 38, 0.22), transparent 60%), linear-gradient(120deg, #006593 0%, #004e72 70%, #003f5c 100%); }
.login__card { width: min(420px, 100%); background: var(--surface); border-radius: 18px; padding: 32px 28px 26px; box-shadow: 0 30px 80px rgba(0, 0, 0, 0.3); display: grid; gap: 18px; }
.login__card .brand__logo { height: 40px; }
.login__card h1 { font-size: 22px; font-weight: 600; letter-spacing: -0.02em; }
.login__card p { color: var(--ink-2); font-size: 14px; }
.btn--sso { height: 46px; justify-content: center; font-size: 15px; background: var(--primary); color: #fff; border-color: var(--primary); width: 100%; }
.btn--sso:hover { background: var(--primary-strong); border-color: var(--primary-strong); }
.btn--sso[aria-disabled="true"] { opacity: .55; pointer-events: none; }
.btn--sso .g { width: 20px; height: 20px; background: #fff; border-radius: 4px; display: grid; place-items: center; }
.login__dev { border-top: 1px dashed var(--axis); padding-top: 16px; display: grid; gap: 8px; }
.login__dev input { height: 38px; padding: 0 12px; border-radius: 10px; border: 1px solid var(--axis); background: var(--surface); color: var(--ink); font: 500 14px var(--font); }
.login__foot { font-size: 12.5px; color: var(--muted); }
.flash { background: var(--low-bg); color: var(--low-ink); border-radius: 10px; padding: 10px 12px; font-size: 13.5px; }
.btn--primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn--primary:hover { background: var(--primary-strong); border-color: var(--primary-strong); color: #fff; }

/* ------------------------------------------------------------ docs page */

.docs-grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 420px), 1fr)); }
.doc-card { scroll-margin-top: 80px; }
.doc-card:target { outline: 2px solid var(--primary); outline-offset: 2px; }
.doc-card h3 { font-size: 17px; font-weight: 600; letter-spacing: -0.01em; }
.lineage { display: grid; gap: 8px; }
.lineage__row { display: grid; grid-template-columns: minmax(0, 1.2fr) 24px minmax(0, 1fr); align-items: center; gap: 8px; font-size: 13px; }
.lineage__src { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; overflow-wrap: anywhere; }
.lineage__arrow { color: var(--muted); text-align: center; }
.lineage__to { display: flex; flex-wrap: wrap; gap: 4px; }
.changelog { display: grid; gap: 10px; }
.changelog li { display: grid; grid-template-columns: 110px 1fr; gap: 12px; font-size: 14px; }
.changelog time { color: var(--muted); font-variant-numeric: tabular-nums; }
ul.plain { list-style: none; padding: 0; margin: 0; }
.prose { font-size: 14.5px; color: var(--ink-2); display: grid; gap: 8px; max-width: 80ch; }

/* ------------------------------------------------------------ toast */

.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 4000; background: var(--ink); color: var(--surface); padding: 10px 16px; border-radius: 10px; font-size: 13.5px; font-weight: 500; box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25); animation: fade .15s; }

/* ------------------------------------------------------------ print */

@media print {
  .topbar, .tabs, .filters, .dhead__actions, .info-btn, .footer, .seg, .card__tools, .toast, .sdrawer, .gsearch, .star { display: none !important; }
  body { background: #fff; color: #000; font-size: 12px; }
  .dhead { background: none !important; color: #000; padding: 0 0 8px; border-bottom: 2px solid #006593; }
  .dhead .eyebrow, .dhead__sub, .crumbs, .crumbs a { color: #333 !important; }
  .fresh { background: none; color: #333; padding: 0; }
  .card, .kpi { box-shadow: none !important; border: 1px solid #ccd; break-inside: avoid; }
  main.wrap { padding-top: 12px; }
  .table-wrap--tall { max-height: none; overflow: visible; }
  a { color: inherit; text-decoration: none; }
}

/* hero KPI inside 4- and 8-column KPI rows */
@media (min-width: 720px) { .kpis--4 .kpi--hero, .kpis--8 .kpi--hero { grid-column: span 2; } }
@media (min-width: 960px) { .kpis--4 .kpi--hero { grid-column: span 1; } }
@media (min-width: 720px) and (max-width: 1179px) { .kpis--6 .kpi--hero { grid-column: span 3; } }
@media (min-width: 1180px) { .kpis--6 .kpi--hero { grid-column: span 1; } }

/* admin: users */
.uform { display: grid; gap: 14px; }
.uform input[type="email"], .uform input[type="text"] { height: 38px; padding: 0 12px; border-radius: 10px; border: 1px solid var(--axis); background: var(--surface); color: var(--ink); font: 500 14px var(--font); width: 100%; }
.uform input[readonly] { background: var(--surface-2); color: var(--ink-2); }
.ufield { border: 0; padding: 0; margin: 0; display: grid; gap: 8px; }
.ucheck { display: flex; gap: 10px; align-items: flex-start; padding: 9px 10px; border: 1px solid var(--border); border-radius: 10px; cursor: pointer; font-size: 14px; }
.ucheck:hover { background: var(--surface-2); }
.ucheck input { margin-top: 3px; accent-color: var(--primary); }
.ucheck small { display: block; color: var(--muted); font-size: 12px; margin-top: 1px; }
.okmsg { background: var(--good-bg); color: var(--good-ink); border-radius: 10px; padding: 10px 12px; font-size: 13.5px; }
.btn--danger { background: var(--bad); color: #fff; border-color: var(--bad); }
.btn--danger:hover { filter: brightness(1.08); background: var(--bad); }
.uacts { display: block; margin-top: 6px; font-size: 13px; font-weight: 500; }
.uacts a { text-decoration: none; } .uacts a:hover { text-decoration: underline; }

/* external users: who the view is shared with */
.shared-banner { background: var(--primary-soft); color: var(--ink); border-bottom: 1px solid var(--border); font-size: 13px; padding: 8px 0; }
.shared-banner b { color: var(--primary); }
@media print { .shared-banner { display: block !important; background: none; border: 1px solid #999; } }

/* Admin: invite external users */
.ext-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }
.ext-dash { border: 1px solid var(--border); border-radius: 10px; padding: 10px 14px 12px; margin: 0; }
.ext-dash legend { padding: 0 6px; }
.ext-dash__body { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; margin-top: 6px; }
.ext-dash__body .ucheck { margin-right: 12px; }
.ext-dash select[multiple] { min-height: 90px; }
