/* ==========================================================================
   Bulbary dashboard: shared design system
   Clean neutral greys with an emerald accent; near-black, cool-neutral surfaces
   in dark mode. Tokens on :root; dark values via prefers-color-scheme unless the
   toggle stamped <html data-theme="light">, and via <html data-theme="dark">.
   ========================================================================== */

:root {
  color-scheme: light;
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #f1f3f6;
  --border: #e3e6eb;
  --border-strong: #cdd2da;
  --text: #111827;
  --text-muted: #5b6472;
  --accent: #047857;
  --accent-hover: #065f46;
  --accent-soft: #e6f6ef;
  --accent-contrast: #ffffff;
  --ok: #047857;
  --ok-soft: #e3f5ec;
  --warn: #b45309;
  --warn-soft: #fdf1dc;
  --danger: #c81e3a;
  --danger-soft: #fde7ea;
  --info: #1d5fd1;
  --info-soft: #e5eefc;
  --muted-soft: #eef0f3;
  --header-bg: #0f141a;
  --header-text: #f3f5f8;
  --header-muted: #a3acb9;
  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 1px 2px rgb(16 24 40 / 0.05), 0 1px 3px rgb(16 24 40 / 0.06);
  --shadow-hover: 0 2px 4px rgb(16 24 40 / 0.06), 0 10px 24px rgb(16 24 40 / 0.09);
  --font-sans: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
  --header-h: 56px;

  /* Categorical series, slot = position in filter_options.varieties (colour
     follows the variety, not its rank). Shared by overview and detail pages. */
  --series-1: #059669;
  --series-2: #7c3aed;
  --series-3: #d97706;
  --series-4: #2563eb;
  --series-5: #e11d48;
  --series-6: #0891b2;
  --series-7: #db2777;
  --series-8: #65a30d;
  --grid-line: #eceef2;
}

@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    color-scheme: dark;
    --bg: #0b0d10;
    --surface: #13161b;
    --surface-2: #1a1e24;
    --border: #242931;
    --border-strong: #343b45;
    --text: #e9ecf1;
    --text-muted: #9ba4b1;
    --accent: #34d399;
    --accent-hover: #6ee7b7;
    --accent-soft: #0e2a21;
    --accent-contrast: #04140d;
    --ok: #34d399;
    --ok-soft: #0e2a20;
    --warn: #fbbf24;
    --warn-soft: #2e2410;
    --danger: #fb7185;
    --danger-soft: #34171d;
    --info: #60a5fa;
    --info-soft: #12223a;
    --muted-soft: #1c2027;
    --header-bg: #07090b;
    --header-text: #e9ecf1;
    --header-muted: #8c95a3;
    --shadow: 0 1px 2px rgb(0 0 0 / 0.5), 0 0 0 1px rgb(255 255 255 / 0.02);
    --shadow-hover: 0 2px 4px rgb(0 0 0 / 0.5), 0 10px 26px rgb(0 0 0 / 0.4);
    --series-1: #34d399;
    --series-2: #a78bfa;
    --series-3: #fbbf24;
    --series-4: #60a5fa;
    --series-5: #fb7185;
    --series-6: #22d3ee;
    --series-7: #f472b6;
    --series-8: #a3e635;
    --grid-line: #20252c;
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0b0d10;
  --surface: #13161b;
  --surface-2: #1a1e24;
  --border: #242931;
  --border-strong: #343b45;
  --text: #e9ecf1;
  --text-muted: #9ba4b1;
  --accent: #34d399;
  --accent-hover: #6ee7b7;
  --accent-soft: #0e2a21;
  --accent-contrast: #04140d;
  --ok: #34d399;
  --ok-soft: #0e2a20;
  --warn: #fbbf24;
  --warn-soft: #2e2410;
  --danger: #fb7185;
  --danger-soft: #34171d;
  --info: #60a5fa;
  --info-soft: #12223a;
  --muted-soft: #1c2027;
  --header-bg: #07090b;
  --header-text: #e9ecf1;
  --header-muted: #8c95a3;
  --shadow: 0 1px 2px rgb(0 0 0 / 0.5), 0 0 0 1px rgb(255 255 255 / 0.02);
  --shadow-hover: 0 2px 4px rgb(0 0 0 / 0.5), 0 10px 26px rgb(0 0 0 / 0.4);
  --series-1: #34d399;
  --series-2: #a78bfa;
  --series-3: #fbbf24;
  --series-4: #60a5fa;
  --series-5: #fb7185;
  --series-6: #22d3ee;
  --series-7: #f472b6;
  --series-8: #a3e635;
  --grid-line: #20252c;
}

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

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

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

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 { margin: 0; line-height: 1.2; font-weight: 600; letter-spacing: -0.01em; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.05rem; }
h3 { font-size: 0.95rem; }
p { margin: 0 0 var(--space-3); }

a { color: var(--accent); text-underline-offset: 2px; }
a:hover { color: var(--accent-hover); }

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

table { border-collapse: collapse; }
svg.icon,
.icon { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.muted { color: var(--text-muted); }
.mono { font-family: var(--font-mono); font-size: 0.92em; }
.num { font-variant-numeric: tabular-nums; }
.nowrap { white-space: nowrap; }
.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;
}

.skip-link {
  position: absolute; left: var(--space-3); top: var(--space-2); z-index: 100;
  padding: var(--space-2) var(--space-3); border-radius: var(--radius-sm);
  background: var(--accent); color: var(--accent-contrast); font-weight: 600;
  transform: translateY(-200%); transition: transform 0.15s;
}
.skip-link:focus { transform: none; color: var(--accent-contrast); }

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

.site-header {
  position: sticky; top: 0; z-index: 50;
  background: var(--header-bg);
  color: var(--header-text);
  border-bottom: 3px solid var(--accent);
}
:root[data-theme="dark"] .site-header { border-bottom-color: #2e6b3d; }
@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) .site-header { border-bottom-color: #2e6b3d; }
}

.site-header__inner {
  max-width: 1600px; margin: 0 auto;
  min-height: var(--header-h);
  padding: 0 var(--space-5);
  display: flex; align-items: center; gap: var(--space-5);
}

.site-title {
  display: inline-flex; align-items: center; gap: var(--space-2);
  color: var(--header-text); text-decoration: none; white-space: nowrap;
}
.site-title:hover { color: var(--header-text); }
.site-title__mark {
  display: inline-block; flex: none; width: 26px; height: 26px;
  background: var(--logo-url) center / contain no-repeat;
}
.site-title__name { font-weight: 700; font-size: 1.15rem; letter-spacing: -0.01em; }
.site-title__tag {
  font-family: var(--font-mono); font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--header-muted); border: 1px solid rgb(255 255 255 / 0.18); border-radius: 999px; padding: 1px 7px;
}

.site-nav { display: flex; gap: 2px; flex: 1; min-width: 0; overflow-x: auto; scrollbar-width: none; }
.site-nav::-webkit-scrollbar { display: none; }
.site-nav a {
  color: var(--header-muted); text-decoration: none; font-weight: 500; white-space: nowrap;
  padding: 7px 12px; border-radius: var(--radius-sm);
}
.site-nav a:hover { color: var(--header-text); background: rgb(255 255 255 / 0.07); }
.site-nav a[aria-current="page"] { color: var(--header-text); background: rgb(255 255 255 / 0.12); box-shadow: inset 0 -2px 0 var(--accent); }

.theme-toggle { color: var(--header-muted); margin-left: auto; }
.theme-toggle:hover { color: var(--header-text); background: rgb(255 255 255 / 0.08); }
.theme-toggle .icon--sun { display: none; }
:root[data-theme="dark"] .theme-toggle .icon--sun { display: block; }
:root[data-theme="dark"] .theme-toggle .icon--moon { display: none; }
@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) .theme-toggle .icon--sun { display: block; }
  :root:where(:not([data-theme="light"])) .theme-toggle .icon--moon { display: none; }
}

/* Signed-in user: email, change password, log out (a POST form). */
.site-user { display: flex; align-items: center; gap: 2px; flex: none; min-width: 0; }
.site-user__email {
  color: var(--header-muted); font-size: 0.8rem; padding: 0 var(--space-2);
  max-width: 22ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.site-user__logout { display: contents; }
.site-header .site-user__btn { color: var(--header-muted); padding: 0 10px; font-weight: 500; }
.site-header .site-user__btn:hover { color: var(--header-text); background: rgb(255 255 255 / 0.08); }
@media (max-width: 1280px) {
  .site-user__label { display: none; }
  .site-header .site-user__btn { width: 34px; padding: 0; }
}
@media (max-width: 1000px) { .site-user__email { display: none; } }

@media (max-width: 720px) {
  .site-header__inner { flex-wrap: wrap; gap: 0 var(--space-3); padding: 0 var(--space-4); }
  .site-title { min-height: 48px; }
  .site-title__tag { display: none; }
  .theme-toggle { order: 2; }
  .site-user { order: 2; }
  .site-nav { order: 3; flex-basis: 100%; margin: 0 calc(-1 * var(--space-2)); padding-bottom: var(--space-2); }
  .site-nav a { padding: 6px 7px; font-size: 0.82rem; }
}

/* ---- Fullscreen page mode (page_class contains "is-fullscreen") ------------ */

body.is-fullscreen { display: flex; flex-direction: column; height: 100vh; height: 100dvh; overflow: hidden; }
body.is-fullscreen .site-header { flex: none; border-bottom-width: 2px; }
body.is-fullscreen .site-header__inner { --header-h: 40px; max-width: none; padding: 0 var(--space-3); flex-wrap: nowrap; }
body.is-fullscreen .site-title { min-height: 0; }
body.is-fullscreen .site-title__tag { display: none; }
body.is-fullscreen .site-title__mark { width: 20px; height: 20px; }
body.is-fullscreen .site-title__name { font-size: 1rem; }
body.is-fullscreen .site-nav { order: 0; flex-basis: auto; margin: 0; padding: 0; }
body.is-fullscreen .site-nav a { padding: 4px 9px; font-size: 0.85rem; }
body.is-fullscreen .theme-toggle { width: 30px; height: 30px; }
body.is-fullscreen .site-user__email,
body.is-fullscreen .site-user__label { display: none; }
body.is-fullscreen .site-header .site-user__btn { width: 30px; min-height: 30px; padding: 0; }
body.is-fullscreen .site-main { flex: 1; min-height: 0; position: relative; display: flex; flex-direction: column; }
body.is-fullscreen .site-main > .page { max-width: none; padding: 0; flex: 1; min-height: 0; display: flex; flex-direction: column; }

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

.page { max-width: 1600px; margin: 0 auto; padding: var(--space-5) var(--space-5) var(--space-6); }
.page-header {
  display: flex; align-items: flex-end; justify-content: space-between; gap: var(--space-4); flex-wrap: wrap;
  margin-bottom: var(--space-4);
}
.page-header__sub { margin: var(--space-1) 0 0; font-size: 0.85rem; }
@media (max-width: 720px) {
  .page { padding: var(--space-4) var(--space-4) var(--space-5); }
  h1 { font-size: 1.35rem; }
}

.grid { display: grid; gap: var(--space-4); grid-template-columns: repeat(auto-fill, minmax(min(100%, 320px), 1fr)); }

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

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
  min-height: 34px; padding: 0 var(--space-4);
  font: inherit; font-weight: 600; font-size: 0.875rem; line-height: 1;
  color: var(--accent-contrast); background: var(--accent);
  border: 1px solid transparent; border-radius: var(--radius-sm);
  cursor: pointer; text-decoration: none; white-space: nowrap;
  transition: background-color 0.12s, color 0.12s, border-color 0.12s;
}
.btn:hover { background: var(--accent-hover); color: var(--accent-contrast); }
.btn--ghost { background: transparent; color: var(--text-muted); border-color: transparent; }
.btn--ghost:hover { background: var(--surface-2); color: var(--text); }
.btn--outline { background: var(--surface); color: var(--text); border-color: var(--border-strong); }
.btn--outline:hover { background: var(--surface-2); color: var(--text); }
.btn--icon { width: 34px; padding: 0; }

/* ---- Badges, dots, meters ------------------------------------------------- */

.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 1px 8px; border-radius: 999px;
  font-size: 0.75rem; font-weight: 600; line-height: 1.6; white-space: nowrap;
  background: var(--muted-soft); color: var(--text-muted);
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex: none; }
.badge--ok, .badge--approved, .badge--online { background: var(--ok-soft); color: var(--ok); }
.badge--warn, .badge--has_issues { background: var(--warn-soft); color: var(--warn); }
.badge--danger, .badge--rejected { background: var(--danger-soft); color: var(--danger); }
.badge--info, .badge--received { background: var(--info-soft); color: var(--info); }
.badge--muted, .badge--offline { background: var(--muted-soft); color: var(--text-muted); }
.badge--rejected::before { border-radius: 1px; }
.badge--has_issues::before { border-radius: 0; clip-path: polygon(50% 0, 100% 100%, 0 100%); width: 8px; height: 7px; }
.badge--plain::before { display: none; }

.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; flex: none; background: var(--text-muted); }
.dot--online, .dot--ok { background: var(--ok); box-shadow: 0 0 0 3px var(--ok-soft); }
.dot--offline, .dot--muted { background: transparent; border: 2px solid var(--text-muted); }
.dot--warn { background: var(--warn); }
.dot--danger { background: var(--danger); }

.meter { display: inline-flex; align-items: center; gap: var(--space-2); }
.meter__track { width: 44px; height: 6px; border-radius: 3px; background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--border); overflow: hidden; }
.meter__fill { display: block; height: 100%; background: var(--ok); border-radius: 3px; }
.meter--warn .meter__fill { background: var(--warn); }
.meter--danger .meter__fill { background: var(--danger); }
.meter__value { font-variant-numeric: tabular-nums; font-size: 0.8rem; min-width: 3ch; text-align: right; }
.meter--danger .meter__value { color: var(--danger); font-weight: 600; }

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

.card {
  position: relative; min-width: 0;
  display: flex; flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.card--clickable { cursor: pointer; transition: box-shadow 0.15s, border-color 0.15s, transform 0.15s; }
.card--clickable:hover { border-color: var(--border-strong); box-shadow: var(--shadow-hover); }
.card--clickable:focus-within { border-color: var(--border-strong); }
.card--clickable :is(table, .mini-map, .viz) { cursor: default; }
.card--clickable :is(a, button) { cursor: pointer; }

.card__header {
  display: flex; align-items: center; gap: var(--space-3);
  padding: var(--space-3) var(--space-3) var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--border);
}
.card__title { font-size: 0.95rem; font-weight: 600; display: flex; align-items: center; gap: var(--space-2); }
.card__title::before { content: ""; width: 4px; height: 16px; border-radius: 2px; background: var(--accent); }
.card__link { color: var(--text); text-decoration: none; }
.card__link:hover { color: var(--accent); }
.card__meta { color: var(--text-muted); font-size: 0.8rem; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.card__actions { margin-left: auto; display: flex; gap: 2px; flex: none; }
.card__actions .btn--icon { width: 30px; min-height: 30px; }
.card__open { color: var(--text-muted); }
.card--clickable:hover .card__open { color: var(--accent); }
.card__body { padding: var(--space-4); display: flex; flex-direction: column; gap: var(--space-4); flex: 1; min-height: 0; }

.card__expand .icon--collapse { display: none; }
.card.is-expanded .card__expand .icon--expand { display: none; }
.card.is-expanded .card__expand .icon--collapse { display: block; }
.card.is-expanded { grid-column: 1 / -1; }
.card__expand[aria-pressed="true"] { color: var(--accent); background: var(--accent-soft); }

@media (max-width: 560px) {
  .card__meta { display: none; }
  .card__body { padding: var(--space-3); }
}

/* Legacy section header component. */
.section-header { display: flex; align-items: baseline; justify-content: space-between; gap: var(--space-3); margin-bottom: var(--space-3); }
.section-header a { font-size: 0.85rem; font-weight: 500; }

/* ---- Stat tiles ----------------------------------------------------------- */

.stats {
  display: grid; gap: var(--space-3);
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  margin-bottom: var(--space-4);
}
.stat-tile {
  position: relative; overflow: hidden;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: var(--space-3) var(--space-4) var(--space-3) calc(var(--space-4) + 2px);
}
.stat-tile::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--border-strong); }
.stat-tile--ok::before { background: var(--ok); }
.stat-tile--warn::before { background: var(--warn); }
.stat-tile--danger::before { background: var(--danger); }
.stat-tile__label { font-family: var(--font-mono); font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.07em; color: var(--text-muted); }
.stat-tile__value { font-size: 1.65rem; font-weight: 600; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; line-height: 1.25; margin-top: 2px; }
.stat-tile__detail { font-size: 0.78rem; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 560px) {
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-2); }
  .stat-tile { padding: var(--space-2) var(--space-3) var(--space-2) calc(var(--space-3) + 2px); }
  .stat-tile__value { font-size: 1.35rem; }
}

/* ---- Filters bar ---------------------------------------------------------- */

.filters {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--space-3);
  margin-bottom: var(--space-4);
}
.filters__form { display: flex; flex-wrap: wrap; align-items: flex-end; gap: var(--space-3); }
.filters__fields {
  flex: 1 1 640px; min-width: 0;
  display: grid; gap: var(--space-2) var(--space-3);
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
}
.filters__actions { display: flex; gap: var(--space-2); }

.field { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.field__label { font-family: var(--font-mono); font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.07em; color: var(--text-muted); }
.input {
  width: 100%; min-height: 34px; padding: 0 var(--space-2);
  font: inherit; font-size: 0.875rem; color: var(--text);
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
}
select.input {
  appearance: none; padding-right: 26px;
  background-image: linear-gradient(45deg, transparent 50%, var(--text-muted) 50%), linear-gradient(135deg, var(--text-muted) 50%, transparent 50%);
  background-position: calc(100% - 13px) 50%, calc(100% - 8px) 50%;
  background-size: 5px 5px; background-repeat: no-repeat;
  text-overflow: ellipsis;
}
.input:hover { border-color: var(--text-muted); }
.input:focus-visible { outline: 2px solid var(--accent); outline-offset: 0; border-color: var(--accent); }

.chips { list-style: none; margin: var(--space-3) 0 0; padding: var(--space-3) 0 0; border-top: 1px dashed var(--border-strong); display: flex; flex-wrap: wrap; gap: var(--space-2); }
.chip {
  display: inline-flex; align-items: center; gap: var(--space-1);
  padding: 2px 4px 2px 10px; border-radius: 999px;
  background: var(--accent-soft); color: var(--text); font-size: 0.8rem; font-weight: 500;
  border: 1px solid color-mix(in srgb, var(--accent) 35%, transparent);
}
.chip__label { color: var(--text-muted); font-weight: 400; }
.chip__remove { display: inline-flex; border-radius: 50%; padding: 3px; color: var(--text-muted); }
.chip__remove:hover { background: color-mix(in srgb, var(--accent) 20%, transparent); color: var(--text); }
.chip__remove .icon { width: 13px; height: 13px; stroke-width: 2.4; }

@media (max-width: 560px) {
  .filters__fields { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .filters__actions { width: 100%; }
  .filters__actions .btn { flex: 1; }
}

/* ---- Tables --------------------------------------------------------------- */

.table-wrap { overflow: auto; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); }
.table-wrap--short { max-height: 340px; }
.table { width: 100%; font-size: 0.85rem; }
.table th,
.table td { padding: var(--space-2) var(--space-3); text-align: left; vertical-align: middle; border-bottom: 1px solid var(--border); }
.table thead th {
  position: sticky; top: 0; z-index: 1;
  background: var(--surface-2);
  font-family: var(--font-mono); font-size: 0.68rem; font-weight: 500; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--text-muted); white-space: nowrap;
  box-shadow: inset 0 -1px 0 var(--border);
  border-bottom: 0;
}
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover td { background: color-mix(in srgb, var(--accent-soft) 55%, transparent); }
.table .num, .table th.num { text-align: right; }
.table td.num:first-child { text-align: left; }
.table a { font-weight: 500; }
.table--compact th, .table--compact td { padding: 6px var(--space-3); }

@media (max-width: 900px) { .hide-md { display: none; } }
.card:not(.is-expanded) .show-expanded { display: none; }
@media (max-width: 560px) { .hide-sm { display: none; } }

/* ---- Overview ------------------------------------------------------------- */

.overview-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: stretch; }
@media (max-width: 1000px) { .overview-grid { grid-template-columns: minmax(0, 1fr); } }

.figure-row { display: flex; align-items: flex-end; justify-content: space-between; gap: var(--space-3) var(--space-5); flex-wrap: wrap; }
.hero-number { display: flex; flex-direction: column; }
.hero-number__value { font-size: 2rem; font-weight: 600; letter-spacing: -0.02em; line-height: 1.1; font-variant-numeric: tabular-nums; }
.hero-number__unit { color: var(--text-muted); font-size: 0.8rem; }

.mini-totals { list-style: none; margin: 0; padding: 0; display: flex; gap: var(--space-4); }
.mini-totals li { display: flex; flex-direction: column; }
.mini-totals__label { font-family: var(--font-mono); font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.07em; color: var(--text-muted); }
.mini-totals .num { font-weight: 600; }

/* Production chart */
.viz { position: relative; margin: 0; display: flex; flex-direction: column; gap: var(--space-3); flex: 1; }
.viz__plot { width: 100%; flex: 1; min-height: 200px; max-height: 420px; }
.card.is-expanded .viz__plot { min-height: 300px; }
.viz__plot svg { display: block; width: 100%; height: 100%; overflow: visible; }
.viz .axis text { fill: var(--text-muted); font-size: 11px; font-family: var(--font-sans); font-variant-numeric: tabular-nums; }
.viz .gridline { stroke: var(--grid-line); stroke-width: 1; }
.viz .baseline { stroke: var(--border-strong); stroke-width: 1; }
.viz .col-hit { fill: transparent; }
.viz .col.is-active .col-hit { fill: var(--text); fill-opacity: 0.05; }
.viz .seg { stroke: var(--surface); stroke-width: 1; }
.viz .s-1 { fill: var(--series-1); background: var(--series-1); }
.viz .s-2 { fill: var(--series-2); background: var(--series-2); }
.viz .s-3 { fill: var(--series-3); background: var(--series-3); }
.viz .s-4 { fill: var(--series-4); background: var(--series-4); }
.viz .s-5 { fill: var(--series-5); background: var(--series-5); }
.viz .s-6 { fill: var(--series-6); background: var(--series-6); }
.viz .s-7 { fill: var(--series-7); background: var(--series-7); }
.viz .s-8 { fill: var(--series-8); background: var(--series-8); }

.viz__tooltip {
  position: absolute; z-index: 5; pointer-events: none; min-width: 170px;
  padding: var(--space-2) var(--space-3);
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm); box-shadow: var(--shadow-hover);
  font-size: 0.8rem;
}
.viz__tooltip-title { font-weight: 600; margin-bottom: 4px; display: flex; justify-content: space-between; gap: var(--space-3); }
.viz__tooltip-row { display: grid; grid-template-columns: 10px 1fr auto; align-items: center; gap: 6px; font-variant-numeric: tabular-nums; }
.viz__tooltip-row .legend__swatch { width: 10px; height: 10px; }

.legend { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 2px var(--space-4); font-size: 0.8rem; }
.legend__item { display: grid; grid-template-columns: 10px 1fr auto; align-items: center; gap: var(--space-2); padding: 2px 0; border-bottom: 1px dotted var(--border); }
.legend__swatch { display: inline-block; width: 10px; height: 10px; border-radius: 3px; background: var(--border-strong); }
.legend__value { font-variant-numeric: tabular-nums; color: var(--text-muted); }

/* Questionnaires */
.split { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr); gap: var(--space-4) var(--space-5); }
@media (max-width: 560px) { .split { grid-template-columns: minmax(0, 1fr); } }

.count-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: var(--space-3); }
.count-list__item { display: grid; grid-template-columns: 1fr auto; gap: 4px var(--space-2); align-items: baseline; }
.count-list__label { font-size: 0.85rem; }
.count-list__value { font-weight: 600; font-size: 1.05rem; }
.bar { grid-column: 1 / -1; height: 6px; border-radius: 3px; background: var(--surface-2); overflow: hidden; }
.bar__fill { display: block; height: 100%; background: var(--accent); border-radius: 3px; }

.status-summary { display: flex; flex-direction: column; gap: var(--space-3); }
.stack-bar { display: flex; gap: 2px; height: 10px; border-radius: 4px; overflow: hidden; }
.stack-bar__seg { flex-basis: 0; min-width: 3px; background: var(--text-muted); }
.stack-bar__seg--received { background: var(--info); }
.stack-bar__seg--approved { background: var(--ok); }
.stack-bar__seg--has_issues { background: var(--warn); }
.stack-bar__seg--rejected { background: var(--danger); }
.status-list { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-2) var(--space-3); }
.status-list li { display: flex; align-items: center; justify-content: space-between; gap: var(--space-2); font-weight: 600; }

/* Map */
.card--map .card__body { padding: 0; }
.mini-map {
  flex: 1; min-height: 300px; height: 100%;
  border-radius: 0 0 var(--radius) var(--radius); overflow: hidden;
  background:
    radial-gradient(circle at 1px 1px, var(--border) 1px, transparent 0) 0 0 / 14px 14px,
    var(--surface-2);
}
.card.is-expanded .mini-map { min-height: 480px; }

/* Phones */
.device { display: grid; grid-template-columns: 9px auto; align-items: center; column-gap: var(--space-2); line-height: 1.25; }
.device .dot { grid-row: 1 / span 2; }
.device__name { font-weight: 500; white-space: nowrap; }
.device__sub { font-size: 0.75rem; white-space: nowrap; }
.charging { margin-left: 4px; font-size: 0.75rem; color: var(--warn); }
@media (max-width: 560px) {
  .card--phones .meter__track { display: none; }
  .card--phones .table th, .card--phones .table td { padding-left: var(--space-2); padding-right: var(--space-2); }
}

/* MapLibre controls follow the theme. */
.maplibregl-ctrl-group { background: var(--surface) !important; border: 1px solid var(--border); box-shadow: var(--shadow) !important; }
.maplibregl-ctrl-attrib { font-size: 10px; }

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