/* =============================================================================
   public/css/console.css — the console: the company panel and the Rovo back
   office. Loaded only by konsolla.html.

   Colours come from the semantic tier in tokens.css (night by default,
   daylight with [data-theme='light']); this file defines tier 3, the sizes of
   the frame and its controls, and never names a hex value except for the
   registration plate, which is a physical object and looks the same in both
   themes.

   Layout, by width:
     ≥ 1024px  sidebar 248px, or a 68px rail if the person collapsed it
     768–1023  the rail, always
     < 768     the sidebar slides over the page from the menu button
   ============================================================================= */

/* ---- 3. Component tokens -------------------------------------------------- */
[data-surface='console'] {
  --side-w: 248px;
  --rail-w: 68px;
  --topbar-h: 60px;
  --gutter: 32px;
  --control-h: 40px;
  --view-max: 1440px;
  --plate-white: #ffffff;
  --plate-ink: #0b1220;
  --plate-edge: #1b2333;
  --plate-band: #244aa5;
}
@media (pointer: coarse) { [data-surface='console'] { --control-h: 44px; } }
@media (max-width: 1023.98px) { [data-surface='console'] { --gutter: 24px; } }
@media (max-width: 767.98px) { [data-surface='console'] { --gutter: 16px; } }

[data-surface='console'] body {
  background: var(--page);
  color: var(--ink);
  font-family: var(--font-text);
  -webkit-font-smoothing: antialiased;
}
body.is-locked { overflow: hidden; }
[hidden] { display: none !important; }

.ic { width: 20px; height: 20px; flex: none; }

/* -----------------------------------------------------------------------------
   Frame
   ----------------------------------------------------------------------------- */
.app {
  display: grid;
  grid-template-columns: var(--side-w) minmax(0, 1fr);
  min-height: 100vh;
  min-height: 100dvh;
}
:root.is-rail .app { grid-template-columns: var(--rail-w) minmax(0, 1fr); --side-col: var(--rail-w); }
/* The navy column runs the full height even when the sidebar itself is sticky. */
.app { background: linear-gradient(to right, var(--side-bg) var(--side-col, var(--side-w)), transparent 0); }
.main { min-width: 0; display: flex; flex-direction: column; }

/* ---- Sidebar: navy in both themes ---------------------------------------- */
.side {
  position: sticky;
  top: 0;
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--side-bg);
  color: var(--side-ink);
  border-right: 1px solid var(--side-line);
  z-index: 30;
}
.side :focus-visible { outline: 2px solid var(--side-accent); outline-offset: 2px; }

.side-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--topbar-h);
  padding: 0 16px;
  border-bottom: 1px solid var(--side-line);
  flex: none;
}
.side-brand { display: inline-flex; align-items: center; gap: 10px; color: #ffffff; text-decoration: none; min-height: 44px; }

/* The brand kit's marks: the wordmark in the full sidebar, the monogram in
   the rail. Both white on navy, as the kit specifies. */
.side-mark { display: none; height: 26px; width: auto; aspect-ratio: 123 / 100; }
.side-word { display: inline-flex; align-items: flex-end; gap: 8px; }
.side-word .rovo-logo { height: 22px; }
.side-word small { padding-bottom: 1px; }
.side-word small { font: 500 12px/1 var(--font-text); color: var(--side-ink-3); letter-spacing: 0; }
:root.is-rail .side-mark { display: block; }
.icon-btn.side-close { display: none; color: var(--side-ink-2); }
.icon-btn.side-close:hover { background: var(--side-hover); color: var(--side-ink); }

.side-org {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 12px 12px 4px;
  padding: 10px;
  border: 1px solid var(--side-line);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.03);
  flex: none;
}
.side-org:empty { display: none; }
.org-mark {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: var(--gold-500);
  color: var(--navy-900);
  flex: none;
}
.org-mark .ic { width: 18px; height: 18px; }
.org-mark.is-initials { font: 700 semi-condensed 14px/1 var(--font-display); letter-spacing: 0.02em; }
.org-text { display: flex; flex-direction: column; min-width: 0; }
.org-text b { font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.org-text small { font-size: 12px; color: var(--side-ink-3); }

.side-nav { flex: 1; overflow-y: auto; padding: 4px 0 12px; overscroll-behavior: contain; }
.nav-group ul { list-style: none; margin: 0; padding: 0; }
.nav-group-label { margin: 0; padding: 16px 20px 6px; font-size: 12px; font-weight: 600; color: var(--side-ink-3); }

.nav-link {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: var(--control-h);
  margin: 1px 8px;
  padding: 0 12px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--side-ink-2);
  font: 500 14px/1.2 var(--font-text);
  text-decoration: none;
  text-align: left;
  cursor: pointer;
  transition: background-color var(--transition), color var(--transition);
}
.nav-link .ic { color: var(--side-ink-3); transition: color var(--transition); }
.nav-link:hover { background: var(--side-hover); color: var(--side-ink); }
.nav-link:hover .ic { color: var(--side-ink-2); }
.nav-link[aria-current='page'] { background: var(--side-active); color: var(--side-ink); font-weight: 600; }
.nav-link[aria-current='page'] .ic { color: var(--side-accent); }
.nav-link[aria-current='page']::before {
  content: '';
  position: absolute;
  left: -8px;
  top: 9px;
  bottom: 9px;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: var(--side-accent);
}
.nav-label { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nav-count {
  display: inline-grid;
  place-items: center;
  min-width: 22px;
  height: 20px;
  padding: 0 6px;
  border-radius: var(--radius-pill);
  background: var(--gold-500);
  color: var(--navy-900);
  font-size: 12px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.side-foot { flex: none; padding: 8px 0 12px; border-top: 1px solid var(--side-line); }
.side-rail { width: calc(100% - 16px); }

/* ---- Rail ----------------------------------------------------------------- */
:root.is-rail .nav-label,
:root.is-rail .nav-group-label,
:root.is-rail .org-text,
:root.is-rail .side-word {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}
:root.is-rail .side,
:root.is-rail .side-nav { overflow: visible; }
:root.is-rail .side-head { justify-content: center; padding: 0; }
:root.is-rail .side-org { justify-content: center; margin: 12px 10px 4px; padding: 6px; }
:root.is-rail .nav-group + .nav-group { margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--side-line); }
:root.is-rail .nav-group:first-child { padding-top: 8px; }
:root.is-rail .nav-link { justify-content: center; margin: 2px 10px; padding: 0; }
:root.is-rail .side-rail { width: calc(100% - 20px); }
:root.is-rail .nav-count {
  position: absolute;
  top: 3px;
  right: 3px;
  min-width: 17px;
  height: 17px;
  padding: 0 4px;
  font-size: 10px;
  box-shadow: 0 0 0 2px var(--side-bg);
}
/* The label, on hover or keyboard focus, beside the icon. */
:root.is-rail .nav-link[data-tip]:hover::after,
:root.is-rail .nav-link[data-tip]:focus-visible::after {
  content: attr(data-tip);
  position: absolute;
  left: calc(100% + 12px);
  top: 50%;
  transform: translateY(-50%);
  padding: 6px 10px;
  border-radius: 6px;
  background: var(--navy-950);
  color: var(--side-ink);
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  box-shadow: var(--shadow-lg);
  pointer-events: none;
  z-index: 40;
}
@media (max-width: 1023.98px) { .side-foot { display: none; } }

/* ---- Top bar --------------------------------------------------------------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 12px;
  height: var(--topbar-h);
  padding: 0 var(--gutter);
  background: color-mix(in srgb, var(--page) 86%, transparent);
  -webkit-backdrop-filter: saturate(1.4) blur(10px);
  backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--line);
}
.icon-btn.topbar-nav { display: none; }
.crumbs { flex: 1; min-width: 0; }
.crumbs ol { display: flex; align-items: center; gap: 8px; margin: 0; padding: 0; list-style: none; font-size: 14px; color: var(--ink-3); white-space: nowrap; }
.crumbs li { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.crumbs li + li::before { content: '/'; margin-right: 8px; color: var(--line-strong); }
.crumbs [aria-current] { color: var(--ink); font-weight: 600; }
.topbar-tools { display: flex; align-items: center; gap: 8px; flex: none; }

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: var(--control-h);
  height: var(--control-h);
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--ink-2);
  cursor: pointer;
  transition: background-color var(--transition), color var(--transition);
}
.icon-btn:hover { background: var(--surface-2); color: var(--ink); }

.search-btn {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  width: clamp(220px, 26vw, 340px);
  height: var(--control-h);
  padding: 0 8px 0 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-sunken);
  color: var(--ink-3);
  font: 400 14px/1 var(--font-text);
  cursor: pointer;
  transition: border-color var(--transition);
}
.search-btn:hover { border-color: var(--line-strong); color: var(--ink-2); }
.search-text { flex: 1; text-align: left; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
kbd {
  display: inline-block;
  padding: 2px 6px;
  border: 1px solid var(--line-strong);
  border-radius: 5px;
  background: var(--surface-2);
  color: var(--ink-2);
  font: 500 11px/1.3 var(--font-text);
  white-space: nowrap;
}

.account { position: relative; }
.account-btn {
  display: inline-grid;
  place-items: center;
  width: var(--control-h);
  height: var(--control-h);
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  cursor: pointer;
}
.avatar {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--accent-fill);
  color: var(--accent-on-fill);
  font: 700 semi-condensed 14px/1 var(--font-display);
  letter-spacing: 0.03em;
  transition: box-shadow var(--transition);
}
.account-btn:hover .avatar,
.account-btn[aria-expanded='true'] .avatar { box-shadow: 0 0 0 3px var(--accent-soft); }
.account-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 40;
  width: 280px;
  max-width: calc(100vw - 24px);
  padding: 6px;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  background: var(--overlay);
  box-shadow: var(--shadow-lg);
}
.menu-who { display: flex; flex-direction: column; gap: 2px; padding: 10px 10px 12px; margin-bottom: 6px; border-bottom: 1px solid var(--line); }
.menu-who b { font-size: 14px; overflow: hidden; text-overflow: ellipsis; }
.menu-who span { font-size: 13px; color: var(--ink-3); }
.menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: var(--control-h);
  padding: 0 10px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--ink);
  font: 500 14px/1.2 var(--font-text);
  text-decoration: none;
  text-align: left;
  cursor: pointer;
}
.menu-item .ic { width: 18px; height: 18px; color: var(--ink-3); }
.menu-item:hover, .menu-item:focus-visible { background: var(--surface-2); }

/* ---- The view ------------------------------------------------------------- */
.view {
  display: flex;
  flex-direction: column;
  gap: 20px;
  width: 100%;
  max-width: var(--view-max);
  margin: 0 auto;
  padding: 28px var(--gutter) 72px;
  outline: none;
}
.view > div:empty { display: none; }
.view h1:focus { outline: none; }

/* ---- Gate (signed out, wrong role, no permission) ------------------------- */
body[data-shell='gate'] .app { grid-template-columns: minmax(0, 1fr); background: none; }
body[data-shell='gate'] .side,
body[data-shell='gate'] .side-scrim,
body[data-shell='gate'] .topbar-nav,
body[data-shell='gate'] .search-btn,
body[data-shell='gate'] .account { display: none !important; }
.gate { max-width: 520px; margin: 10vh auto 0; text-align: center; }
.gate-mark {
  display: grid;
  place-items: center;
  width: 56px;
  height: 56px;
  margin: 0 auto 18px;
  border-radius: 16px;
  background: var(--accent-soft);
  color: var(--accent);
}
.gate-mark .ic { width: 26px; height: 26px; }
.gate.is-error .gate-mark { background: var(--bad-soft); color: var(--bad); }
.gate h1 { font: 600 semi-condensed clamp(1.75rem, 1.5rem + 1vw, 2.125rem)/1.1 var(--font-display); letter-spacing: -0.005em; }
.gate p { margin-top: 10px; color: var(--ink-2); }
.gate .row { justify-content: center; gap: 10px; margin-top: 22px; }

/* -----------------------------------------------------------------------------
   Page pieces
   ----------------------------------------------------------------------------- */
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 16px 24px; margin-bottom: 4px; }
.page-head-text { min-width: 0; flex: 1 1 420px; }
.page-head h1 {
  font: 600 semi-condensed clamp(1.75rem, 1.45rem + 1vw, 2.375rem)/1.05 var(--font-display);
  letter-spacing: -0.008em;
  color: var(--ink);
}
.page-head p { margin-top: 8px; max-width: 70ch; color: var(--ink-2); font-size: 15px; line-height: 1.5; }
.page-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; margin-top: 12px; font-size: 13px; }
.page-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.btn .ic { width: 18px; height: 18px; }

.section-title { font: 600 semi-condensed 1.375rem/1.15 var(--font-display); letter-spacing: 0; color: var(--ink); }

.panel {
  min-width: 0;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 56px; padding: 10px 20px; border-bottom: 1px solid var(--line); }
.panel-head h2 { font-size: 15px; font-weight: 600; letter-spacing: var(--tracking-tight); }
.panel-actions { display: flex; gap: 6px; }
.panel-body { padding: 20px; min-width: 0; }
.panel-body > .tbl-wrap { margin: -20px; border: 0; border-radius: 0 0 var(--radius-lg) var(--radius-lg); box-shadow: none; background: transparent; }
.panel-body > .empty { padding: 28px 12px; }

.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; align-items: start; }
.grid-2.grid-wide-left { grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); }
.grid-2 > :empty { display: none; }
@media (max-width: 1099.98px) { .grid-2, .grid-2.grid-wide-left { grid-template-columns: minmax(0, 1fr); } }

/* KPI strip: one panel split by hairlines, number first. */
/* Columns follow the count (data-n), so a row never ends in a hole: four go
   2 x 2 below desktop, everything goes two-up on a phone. Hairlines are
   shadows on each cell; the ones on the outer edge are clipped. */
.kpis {
  --n: 4;
  display: grid;
  grid-template-columns: repeat(var(--n), minmax(0, 1fr));
  margin: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}
.kpi { display: flex; flex-direction: column; gap: 4px; padding: 18px 20px; min-width: 0; box-shadow: 1px 0 0 var(--line), 0 1px 0 var(--line); }
.kpis[data-n='1'] { --n: 1; }
.kpis[data-n='2'] { --n: 2; }
.kpis[data-n='3'] { --n: 3; }
@media (max-width: 1099.98px) { .kpis[data-n='4'] { --n: 2; } }
@media (max-width: 559.98px) { .kpis[data-n='3'] { --n: 2; } .kpis[data-n='3'] .kpi:last-child { grid-column: 1 / -1; } }
.kpi dd {
  order: -1;
  margin: 0;
  font: 600 semi-condensed clamp(1.625rem, 1.4rem + 0.8vw, 2.125rem)/1 var(--font-display);
  font-variant-numeric: tabular-nums;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.kpi dt { font-size: 13px; color: var(--ink-2); overflow-wrap: anywhere; }
.kpi p { font-size: 12px; color: var(--ink-3); }
.kpi.is-due dd { color: var(--warn); }
.kpi.is-due dt::after { content: ''; display: inline-block; width: 6px; height: 6px; margin-left: 6px; border-radius: 50%; background: var(--warn); vertical-align: middle; }

.notice {
  padding: 12px 16px;
  border: 1px solid color-mix(in srgb, var(--accent) 28%, transparent);
  border-radius: 10px;
  background: var(--accent-soft);
  color: var(--ink-2);
  font-size: 14px;
  line-height: 1.5;
}

.empty { padding: 44px 20px; text-align: center; }
.empty h3 { font: 600 semi-condensed 1.25rem/1.2 var(--font-display); color: var(--ink); }
.empty p { max-width: 46ch; margin: 6px auto 0; color: var(--ink-3); font-size: 14px; }
.empty .btn { margin-top: 16px; }
.subtle { color: var(--ink-3); }
.is-bad { color: var(--bad); }
.is-warn { color: var(--warn); }
.is-quiet { color: var(--ink-3); }

.dfacts { margin: 0; }
.dfacts > div { display: grid; grid-template-columns: minmax(0, 38%) minmax(0, 1fr); gap: 12px; padding: 9px 0; border-bottom: 1px solid var(--line); }
.dfacts > div:last-child { border-bottom: 0; }
.dfacts dt { font-size: 13px; color: var(--ink-3); }
.dfacts dd { margin: 0; font-size: 14px; color: var(--ink); overflow-wrap: anywhere; }
.dfacts dd small { display: block; color: var(--ink-3); font-size: 12px; }

.lines-dl { margin: 0; font-size: 14px; }
.lines-dl > div { display: flex; justify-content: space-between; gap: 16px; padding: 7px 0; }
.lines-dl dt { color: var(--ink-2); }
.lines-dl dd { margin: 0; font-variant-numeric: tabular-nums; }
.lines-dl .is-sub { border-top: 1px solid var(--line); }
.lines-dl .is-total { margin-top: 4px; padding-top: 10px; border-top: 1px solid var(--line-strong); font-size: 16px; font-weight: 600; }
.lines-dl .is-total dt { color: var(--ink); }

/* -----------------------------------------------------------------------------
   Plates: a vehicle by its registration, a city by its region code.
   ----------------------------------------------------------------------------- */
.regplate, .cityplate {
  display: inline-flex;
  align-items: stretch;
  height: 26px;
  border-radius: 4px;
  background: var(--plate-white);
  color: var(--plate-ink);
  box-shadow: inset 0 0 0 1.5px var(--plate-edge);
  overflow: hidden;
  white-space: nowrap;
  vertical-align: middle;
  flex: none;
}
.regplate-band {
  display: flex;
  align-items: flex-end;
  padding: 0 4px 3px;
  background: var(--plate-band);
  color: #ffffff;
  font: 700 8px/1 var(--font-text);
  letter-spacing: 0.04em;
}
.regplate-num { display: flex; align-items: center; padding: 0 9px 0 8px; font: 600 semi-condensed 15px/1 var(--font-display); letter-spacing: 0.07em; }
.cityplate { height: 24px; }
.cityplate-code { display: flex; align-items: center; padding: 0 5px 0 7px; font: 700 semi-condensed 14px/1 var(--font-display); letter-spacing: 0.04em; }
.cityplate-name { display: flex; align-items: center; padding: 0 8px 0 5px; border-left: 1px solid rgba(11, 27, 64, 0.2); font: 500 12px/1 var(--font-text); }
.cityplate .regplate-band { padding-bottom: 2px; font-size: 7px; }

/* -----------------------------------------------------------------------------
   Lists: toolbar, table, pager. Tables become cards on a phone.
   ----------------------------------------------------------------------------- */
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.toolbar-search { position: relative; flex: 1 1 280px; max-width: 440px; }
.toolbar-search .ic { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); width: 18px; height: 18px; color: var(--ink-3); pointer-events: none; }
.toolbar-search .input { width: 100%; padding-left: 38px; }
.toolbar .input, .toolbar .select { height: auto; min-height: var(--control-h); min-width: 0; padding-block: 0; line-height: 1.2; }
@media (min-width: 768px) { .toolbar .input, .toolbar .select, .act > .row .select { font-size: 14px; } }
.toolbar-filter { flex: 0 1 auto; min-width: 0; }
.toolbar-count { margin-left: auto; font-size: 13px; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.input { min-width: 0; }

.tbl-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}
.tbl { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 14px; }
.tbl th {
  padding: 11px 16px;
  border-bottom: 1px solid var(--line-strong);
  color: var(--ink-3);
  font-size: 12.5px;
  font-weight: 600;
  text-align: left;
  white-space: nowrap;
  background: var(--surface);
}
.tbl tbody th { color: var(--ink-2); font-weight: 500; font-size: 13px; border-bottom: 1px solid var(--line); white-space: normal; }
.tbl td { padding: 12px 16px; border-bottom: 1px solid var(--line); vertical-align: middle; color: var(--ink); }
.tbl tbody tr:last-child > * { border-bottom: 0; }
.tbl td b { font-weight: 600; }
.tbl td small { display: block; margin-top: 3px; color: var(--ink-3); font-size: 12px; }
.tbl td > .regplate + small { margin-top: 6px; }
.tbl .is-num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tbl .is-center { text-align: center; }
.tbl tr[data-row] { cursor: pointer; transition: background-color 120ms ease; }
.tbl tr[data-row]:hover > td { background: color-mix(in srgb, var(--surface-2) 60%, var(--surface)); }
.tbl tr[data-row]:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.th-sort {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  cursor: pointer;
}
.is-num .th-sort { flex-direction: row-reverse; }
.th-sort .ic { width: 14px; height: 14px; }
.th-sort .ic.is-idle { opacity: 0; transition: opacity var(--transition); }
.th-sort:hover .ic.is-idle, .th-sort:focus-visible .ic.is-idle { opacity: 0.6; }
th[aria-sort='ascending'], th[aria-sort='descending'] { color: var(--ink); }
.tbl-compact th, .tbl-compact td { padding: 8px 12px; }

.pager { display: flex; align-items: center; justify-content: flex-end; gap: 8px; margin-top: 12px; font-size: 13px; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.pager span { margin-right: 4px; }
.pager .btn { width: var(--control-h); padding: 0; }
.pager .btn .ic { margin: 0; }

.matrix .yes { color: var(--ok); }
.matrix .yes .ic { width: 18px; height: 18px; }
.matrix .no { color: var(--ink-3); }
.diff td { max-width: 260px; overflow-wrap: anywhere; font-size: 13px; }
.diff-before { color: var(--bad); }
.diff-after { color: var(--ok); }

@media (max-width: 719.98px) {
  .tbl-wrap:has(> .tbl:not(.tbl-compact)) { overflow: visible; border: 0; background: transparent; box-shadow: none; }
  .panel-body > .tbl-wrap:has(> .tbl:not(.tbl-compact)) { margin: -8px -8px; }
  .tbl:not(.tbl-compact) thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .tbl:not(.tbl-compact), .tbl:not(.tbl-compact) tbody, .tbl:not(.tbl-compact) tr, .tbl:not(.tbl-compact) td { display: block; }
  .tbl:not(.tbl-compact) tr {
    margin-bottom: 10px;
    padding: 12px 14px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--surface);
  }
  .tbl:not(.tbl-compact) tbody tr:last-child > * { border-bottom: 0; }
  .tbl:not(.tbl-compact) td {
    position: relative;
    min-height: 32px;
    padding: 6px 0 6px 38%;
    border: 0;
    text-align: left;
    white-space: normal;
  }
  .tbl:not(.tbl-compact) td::before { content: attr(data-label); position: absolute; left: 0; top: 8px; width: calc(38% - 12px); color: var(--ink-3); font-size: 12.5px; }
  .tbl:not(.tbl-compact) td.is-primary { display: block; min-height: 0; padding: 0 0 10px; margin-bottom: 4px; border-bottom: 1px solid var(--line); font-size: 15px; }
  .tbl:not(.tbl-compact) td.is-primary::before { content: none; }
  .tbl:not(.tbl-compact) tr[data-row]:hover > td { background: none; }
  .toolbar-search { max-width: none; flex-basis: 100%; }
  .toolbar-filter { flex: 1 1 140px; }
  .toolbar-filter .select { width: 100%; }
  .toolbar-count { width: 100%; margin-left: 0; }
}

/* -----------------------------------------------------------------------------
   Drawer: one record's detail, from the right; full screen on a phone.
   ----------------------------------------------------------------------------- */
.drawer-backdrop { position: fixed; inset: 0; z-index: 45; background: rgba(3, 8, 20, 0.5); }
.drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: 50;
  display: flex;
  flex-direction: column;
  width: min(580px, 100vw);
  background: var(--overlay);
  border-left: 1px solid var(--line-strong);
  box-shadow: var(--shadow-lg);
  transform: translateX(24px);
  opacity: 0;
  transition: transform 220ms cubic-bezier(0.2, 0, 0, 1), opacity 160ms ease;
}
.drawer.is-open { transform: none; opacity: 1; }
.drawer-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: var(--topbar-h); padding: 8px 12px 8px 24px; border-bottom: 1px solid var(--line); }
.drawer-head h2 { font: 600 semi-condensed 1.375rem/1.15 var(--font-display); min-width: 0; overflow-wrap: anywhere; }
.drawer-body { flex: 1; overflow-y: auto; padding: 20px 24px 32px; overscroll-behavior: contain; }
.drawer-h { margin: 24px 0 6px; font-size: 13px; font-weight: 600; color: var(--ink-2); }
.drawer-body > .drawer-h:first-child { margin-top: 0; }
.drawer-plate { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; margin-bottom: 16px; }
.drawer-plate .regplate { height: 34px; }
.drawer-plate .regplate .regplate-num { font-size: 20px; padding: 0 12px 0 10px; }
.drawer-plate .regplate .regplate-band { font-size: 9px; padding: 0 5px 4px; }
.drawer-photos { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; margin-bottom: 16px; }
.drawer-photos img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: 8px; background: var(--surface-2); }
.drawer-actions { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 10px; margin-top: 24px; padding-top: 18px; border-top: 1px solid var(--line); }
.drawer-actions > .subtle { font-size: 14px; }

.act { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.act > .btn { align-self: flex-start; }
.application-actions .act > .btn, .vq-actions .act > .btn { align-self: stretch; }
.act:has(> .reason-form:not([hidden])) { flex-basis: 100%; }
.act > .row { display: flex; gap: 8px; flex-wrap: wrap; }
.act > .row .select { flex: 1 1 160px; min-height: var(--control-h); padding-block: 0; }
.reason-form { padding: 14px; border: 1px solid color-mix(in srgb, var(--bad) 35%, transparent); border-radius: 10px; background: var(--bad-soft); }
.reason-form.is-calm { border-color: var(--line); background: var(--surface-2); }
.reason-form .row { justify-content: flex-end; gap: 8px; margin-top: 10px; }
.btn-reject { color: var(--bad); }
.btn-reject:hover { border-color: var(--bad); }

@media (max-width: 767.98px) {
  .drawer { width: 100vw; border-left: 0; }
  .drawer-head { padding-left: 16px; }
  .drawer-body { padding: 16px 16px 32px; }
}

/* -----------------------------------------------------------------------------
   Command palette
   ----------------------------------------------------------------------------- */
.palette {
  position: fixed;
  inset: 0;
  z-index: 70;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 12vh 16px 16px;
  background: rgba(3, 8, 20, 0.55);
}
.palette-box {
  display: flex;
  flex-direction: column;
  width: min(640px, 100%);
  max-height: min(560px, 76vh);
  border: 1px solid var(--line-strong);
  border-radius: 14px;
  background: var(--overlay);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  animation: palette-in 140ms ease-out;
}
@keyframes palette-in { from { transform: translateY(-6px) scale(0.99); opacity: 0; } }
.palette-input { display: flex; align-items: center; gap: 12px; height: 58px; padding: 0 12px 0 18px; border-bottom: 1px solid var(--line); flex: none; }
.palette-input .ic { color: var(--ink-3); }
.palette-input input:focus-visible { outline: none; }
.palette-input:focus-within { box-shadow: inset 0 -2px 0 var(--accent); }
.palette-input input { flex: 1; min-width: 0; height: 100%; border: 0; background: transparent; color: var(--ink); font: 400 16px/1 var(--font-text); outline: none; }
.palette-input input::placeholder { color: var(--ink-3); }
.palette-esc { padding: 3px 8px; border: 1px solid var(--line-strong); border-radius: 6px; background: transparent; color: var(--ink-3); font: 500 12px/1.2 var(--font-text); cursor: pointer; }
.palette-list { flex: 1; margin: 0; padding: 6px; overflow-y: auto; list-style: none; overscroll-behavior: contain; }
.palette-kind { padding: 12px 10px 4px; font-size: 12px; font-weight: 600; color: var(--ink-3); }
.palette-item { display: flex; align-items: center; gap: 12px; min-height: 44px; padding: 0 10px; border-radius: 8px; cursor: pointer; }
.palette-item .ic { width: 18px; height: 18px; color: var(--ink-3); }
.palette-item.is-active { background: var(--surface-2); }
.palette-item.is-active .ic { color: var(--accent); }
.palette-label { flex: 1; min-width: 0; color: var(--ink); font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.palette-hint { max-width: 45%; color: var(--ink-3); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.palette-empty { padding: 28px 12px; text-align: center; color: var(--ink-3); font-size: 14px; }
.palette-foot { display: flex; gap: 18px; padding: 10px 18px; border-top: 1px solid var(--line); color: var(--ink-3); font-size: 12px; flex: none; }
.palette-foot kbd { margin-right: 3px; }
@media (pointer: coarse) { .palette-foot, .palette-esc { display: none; } }

/* -----------------------------------------------------------------------------
   Admin work: overview, applications, vehicle queue, feed
   ----------------------------------------------------------------------------- */
.worklist { margin: -8px 0; padding: 0; list-style: none; }
.work { display: grid; grid-template-columns: 36px minmax(0, 1fr) auto minmax(96px, auto); align-items: center; gap: 14px; min-height: 60px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.work:last-child { border-bottom: 0; }
.work-ic { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 10px; background: var(--surface-2); color: var(--ink-3); }
.work-ic .ic { width: 18px; height: 18px; }
.work.is-due .work-ic { background: var(--accent-soft); color: var(--accent); }
.work-label { font-size: 14px; color: var(--ink-2); }
.work.is-due .work-label { color: var(--ink); font-weight: 500; }
.work-n { font: 600 semi-condensed 1.625rem/1 var(--font-display); font-variant-numeric: tabular-nums; color: var(--ink-3); }
.work.is-due .work-n { color: var(--ink); }
.work-done { font-size: 13px; color: var(--ink-3); text-align: right; }
.work .btn { justify-self: end; }

.feed { margin: -8px 0; padding: 0; list-style: none; }
.feed li { display: grid; gap: 3px; padding: 11px 0; border-bottom: 1px solid var(--line); }
.feed li:last-child { border-bottom: 0; }
.feed-when { font-size: 12px; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.feed-what { font-size: 14px; color: var(--ink-2); }
.feed-what b { color: var(--ink); font-weight: 600; }
.feed-why { margin-top: 2px; padding-left: 10px; border-left: 2px solid var(--line-strong); font-size: 13px; color: var(--ink-3); }

.ledger { display: flex; flex-direction: column; gap: 12px; }
.application {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(0, 0.8fr) minmax(0, 1.4fr) minmax(150px, auto);
  gap: 20px 28px;
  align-items: start;
  padding: 20px 22px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}
.application h2 { font: 600 semi-condensed 1.375rem/1.15 var(--font-display); }
.application-where { margin-top: 8px; font-size: 14px; color: var(--ink-2); }
.application-ref { margin-top: 8px; font-size: 13px; color: var(--ink-3); }
.application-prev { margin-top: 10px; font-size: 13px; color: var(--ink-2); }
.application-key { margin: 0; }
.application-key dt { font-size: 12px; font-weight: 600; color: var(--ink-3); }
.application-key dd { margin: 4px 0 0; }
.nui { display: inline-flex; gap: 6px; font: 600 semi-condensed 1.5rem/1 var(--font-display); font-variant-numeric: tabular-nums; letter-spacing: 0.02em; color: var(--ink); }
.application-sub { font-size: 13px; color: var(--ink-3); }
.application-sub b { color: var(--ink-2); font-weight: 600; }
.application .dfacts > div { padding: 6px 0; }
.application-actions { display: flex; flex-direction: column; gap: 8px; }
.application-actions .btn { width: 100%; }
.application-actions .act:has(> .reason-form:not([hidden])) { position: relative; }
.ledger.is-quiet .application { background: transparent; box-shadow: none; border-style: dashed; }
.ledger-later { margin-top: 20px; }
.ledger-later > h2 { font: 600 semi-condensed 1.375rem/1.15 var(--font-display); }
.ledger-later > p { margin: 4px 0 12px; color: var(--ink-3); font-size: 14px; }
@media (max-width: 1199.98px) {
  .application { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .application-actions { grid-column: 1 / -1; flex-direction: row; flex-wrap: wrap; }
  .application-actions .btn { width: auto; }
  .application-actions .act:has(> .reason-form:not([hidden])) { flex-basis: 100%; }
}
@media (max-width: 719.98px) { .application { grid-template-columns: minmax(0, 1fr); padding: 16px; } }

.vq { display: flex; flex-direction: column; gap: 14px; }
.vq-item { display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1.3fr) minmax(170px, auto); gap: 24px; padding: 20px; align-items: start; }
.vq-photos { position: relative; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
.vq-photos img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: 8px; background: var(--surface-2); }
.vq-count { position: absolute; right: 8px; bottom: 8px; padding: 3px 9px; border-radius: var(--radius-pill); background: rgba(7, 13, 26, 0.82); color: #ffffff; font-size: 12px; font-weight: 500; }
.vq-main h2 { margin-top: 2px; font: 600 semi-condensed 1.375rem/1.15 var(--font-display); }
.vq-main .drawer-plate { margin-bottom: 10px; }
.vq-sub { margin: 4px 0 12px; font-size: 13px; color: var(--ink-3); }
.vq-actions { display: flex; flex-direction: column; gap: 8px; }
.vq-actions .btn { width: 100%; }
@media (max-width: 1199.98px) {
  .vq-item { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .vq-actions { grid-column: 1 / -1; flex-direction: row; flex-wrap: wrap; }
  .vq-actions .btn { width: auto; }
  .vq-actions .act:has(> .reason-form:not([hidden])) { flex-basis: 100%; }
}
@media (max-width: 719.98px) { .vq-item { grid-template-columns: minmax(0, 1fr); padding: 16px; } }

.form-stack { display: flex; flex-direction: column; gap: 14px; }
.form-stack .btn { align-self: flex-start; }

/* -----------------------------------------------------------------------------
   Company: onboarding track, lists, registration
   ----------------------------------------------------------------------------- */
.track { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0 20px; margin: 0; padding: 0; list-style: none; }
.track-step { position: relative; padding-top: 38px; min-width: 0; }
.track-node {
  position: absolute;
  top: 0;
  left: 0;
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border: 2px solid var(--line-strong);
  border-radius: 50%;
  background: var(--surface);
  color: var(--page);
  z-index: 1;
}
.track-node .ic { width: 14px; height: 14px; stroke-width: 2.6; }
.track-step::before { content: ''; position: absolute; top: 12px; left: 34px; right: -12px; height: 2px; border-radius: 2px; background: var(--line-strong); }
.track-step:last-child::before { content: none; }
.track-step.is-done .track-node { border-color: var(--ok); background: var(--ok); }
.track-step.is-done::before { background: var(--ok); }
.track-step.is-current .track-node { border-color: var(--accent); box-shadow: inset 0 0 0 4px var(--surface), inset 0 0 0 10px var(--accent); }
.track-step.is-failed .track-node { border-color: var(--bad); background: var(--bad); }
.track-step h2 { font-size: 16px; font-weight: 600; color: var(--ink); }
.track-step.is-todo h2 { color: var(--ink-2); }
.track-meta { margin-top: 2px; font-size: 13px; color: var(--ink-3); }
.track-note { margin-top: 8px; max-width: 42ch; font-size: 14px; line-height: 1.5; color: var(--ink-2); }
.track-action { margin-top: 12px; }
.track-reason { margin-top: 10px; padding: 10px 12px; border-left: 3px solid var(--bad); border-radius: 6px; background: var(--bad-soft); font-size: 14px; color: var(--ink); }
.track-reason span { display: block; margin-bottom: 2px; font-size: 12px; font-weight: 600; color: var(--bad); }
.drawer-body .track-reason { margin: 0 0 16px; }
@media (max-width: 719.98px) {
  .track { grid-template-columns: minmax(0, 1fr); }
  .track-step { padding: 0 0 22px 42px; }
  .track-step::before { top: 32px; bottom: 4px; left: 12px; right: auto; width: 2px; height: auto; }
}

.list { margin: -8px 0; padding: 0; list-style: none; }
.list-row { display: flex; align-items: center; gap: 14px; min-height: 58px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.list-row:last-child { border-bottom: 0; }
.list-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.list-main b { font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list-main span { font-size: 13px; color: var(--ink-3); }
.list-main span.is-bad { color: var(--bad); }
.list-main span.is-warn { color: var(--warn); }
@media (max-width: 479.98px) { .list-row { flex-wrap: wrap; } .list-row .list-main { flex-basis: calc(100% - 140px); } }

.register { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 320px); gap: 24px; align-items: start; }
.register-form { padding: 24px; }
.register-form fieldset { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 18px; margin: 0 0 28px; padding: 0; border: 0; min-width: 0; }
.register-form legend { grid-column: 1 / -1; margin-bottom: 14px; padding: 0; font: 600 semi-condensed 1.25rem/1.2 var(--font-display); color: var(--ink); }
.register-form legend small { display: block; margin-top: 2px; font: 400 13px/1.4 var(--font-text); color: var(--ink-3); }
.register-form .field.is-wide { grid-column: 1 / -1; }
.register-submit { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 12px; padding-top: 18px; border-top: 1px solid var(--line); }
.register-submit .error-text { flex: 1 1 200px; margin: 0; }
.register-aside { position: sticky; top: calc(var(--topbar-h) + 20px); padding: 20px; border: 1px solid var(--line); border-radius: var(--radius-lg); background: var(--surface-2); }
.register-aside h2 { font: 600 semi-condensed 1.25rem/1.2 var(--font-display); }
.register-steps { margin: 14px 0 0; padding: 0; list-style: none; counter-reset: step; }
.register-steps li { position: relative; padding: 0 0 14px 34px; font-size: 14px; line-height: 1.5; color: var(--ink-2); counter-increment: step; }
.register-steps li::before {
  content: counter(step);
  position: absolute;
  left: 0;
  top: 0;
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  font: 700 12px/1 var(--font-text);
}
@media (max-width: 899.98px) {
  .register { grid-template-columns: minmax(0, 1fr); }
  .register-aside { position: static; order: -1; }
}
@media (max-width: 599.98px) {
  .register-form { padding: 18px; }
  .register-form fieldset { grid-template-columns: minmax(0, 1fr); }
}

/* -----------------------------------------------------------------------------
   Analytics and charts (see public/js/charts.js)
   ----------------------------------------------------------------------------- */
.an-custom { display: inline-flex; flex-wrap: wrap; gap: 8px; }
.an-custom .input { width: auto; }
.an-body { display: flex; flex-direction: column; gap: 40px; transition: opacity 160ms ease; }
.an-body.is-refreshing { opacity: 0.55; }
.an-section { display: flex; flex-direction: column; gap: 16px; }
.an-hero-label { font-size: 14px; color: var(--ink-2); }
.an-hero-value { margin-top: 2px; font: 600 semi-condensed clamp(2.5rem, 2rem + 2.4vw, 4rem)/1 var(--font-display); font-variant-numeric: tabular-nums; color: var(--ink); }
.an-hero-note { margin-top: 8px; max-width: 64ch; font-size: 14px; color: var(--ink-3); }
.an-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 440px), 1fr)); gap: 20px; }

.chart-card {
  height: 100%;
  margin: 0;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  min-width: 0;
}
.chart-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 12px; }
.chart-title { font-size: 15px; font-weight: 600; letter-spacing: var(--tracking-tight); color: var(--ink); }
.chart-note { margin-top: 2px; font-size: 12.5px; color: var(--ink-3); }
.chart-toggle { flex: 0 0 auto; }
.chart-legend { display: flex; flex-wrap: wrap; gap: 6px 16px; margin: 0 0 12px; padding: 0; list-style: none; font-size: 12.5px; color: var(--ink-2); }
.chart-legend li { display: inline-flex; align-items: center; gap: 6px; }
.chart-key { display: inline-block; width: 12px; height: 12px; border-radius: 3px; }
.chart-key.is-line { width: 16px; height: 3px; border-radius: 2px; }
.chart-plot { min-width: 0; }
.chart-plot[hidden], .chart-table[hidden] { display: none; }
.chart-svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart-grid { stroke: var(--chart-grid); stroke-width: 1; }
.chart-base { stroke: var(--chart-base); stroke-width: 1; }
.chart-tick { fill: var(--ink-3); font-size: 11px; font-variant-numeric: tabular-nums; }
.chart-cat { fill: var(--ink-2); font-size: 12px; }
.chart-val { fill: var(--ink); font-size: 12px; font-weight: 600; font-variant-numeric: tabular-nums; }
.chart-bar { transition: filter 120ms ease; }
.chart-bar.is-hot { filter: brightness(1.15); }
.chart-line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart-area { opacity: 0.12; }
.chart-dot { stroke: var(--surface); stroke-width: 2; }
.chart-cross { stroke: var(--ink-3); stroke-width: 1; pointer-events: none; }
.chart-hit { fill: transparent; cursor: crosshair; }
.chart-hit:focus { outline: none; }
.chart-hit:focus-visible { stroke: var(--accent); stroke-width: 2; }
.chart-empty { padding: 32px 0; text-align: center; color: var(--ink-3); font-size: 14px; }
.chart-table { max-height: 320px; overflow-y: auto; }
.chart-table .tbl-wrap { box-shadow: none; }
.chart-tip {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 60;
  min-width: 140px;
  padding: 8px 12px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--overlay);
  box-shadow: var(--shadow-lg);
  font-size: 12px;
  pointer-events: none;
  opacity: 0;
  transition: opacity 90ms ease;
}
.chart-tip.is-on { opacity: 1; }
.chart-tip-title { margin-bottom: 4px; color: var(--ink-3); }
.chart-tip-row { display: flex; align-items: center; gap: 6px; }
.chart-tip-row b { color: var(--ink); font-size: 14px; font-variant-numeric: tabular-nums; }
.chart-tip-row span { color: var(--ink-2); }
.chart-tip-key { display: inline-block; width: 12px; height: 3px; border-radius: 2px; }
@media (max-width: 719.98px) { .chart-card { padding: 16px; } }

/* -----------------------------------------------------------------------------
   Phone: the sidebar slides over the page.
   ----------------------------------------------------------------------------- */
@media (max-width: 767.98px) {
  .app, :root.is-rail .app { grid-template-columns: minmax(0, 1fr); background: none; }
  .side {
    position: fixed;
    inset: 0 auto 0 0;
    width: min(304px, 86vw);
    transform: translateX(-102%);
    transition: transform 240ms cubic-bezier(0.2, 0, 0, 1);
    z-index: 60;
    visibility: hidden;
  }
  body.nav-open .side { transform: none; visibility: visible; box-shadow: var(--shadow-lg); }
  .side-scrim { position: fixed; inset: 0; z-index: 55; background: rgba(3, 8, 20, 0.5); }
  .icon-btn.side-close { display: inline-grid; }
  .topbar { gap: 4px; padding: 0 8px 0 4px; }
  .icon-btn.topbar-nav { display: inline-grid; }
  .crumbs .crumb-root, .crumbs .crumb-group { display: none; }
  .crumbs li + li::before { content: none; }
  .crumbs ol { font-size: 15px; }
  .search-btn { width: var(--control-h); padding: 0; justify-content: center; border-color: transparent; background: transparent; color: var(--ink-2); }
  .search-text, .search-btn kbd { display: none; }
  .view { padding-top: 20px; gap: 16px; }
  .page-head-text { flex-basis: 100%; }
  .page-actions { width: 100%; }
  .kpi { padding: 14px 16px; }
  .work { grid-template-columns: 36px minmax(0, 1fr) auto; }
  .work .btn, .work-done { grid-column: 2 / -1; justify-self: start; text-align: left; }
  .work-done:empty { display: none; }
  .palette { padding-top: 8px; }
}
@media (min-width: 768px) { .side-scrim { display: none !important; } }

@media (prefers-reduced-motion: reduce) {
  .drawer, .side, .palette-box, .nav-link, .chart-bar { transition: none; animation: none; }
}

/* =============================================================================
   Fleet management: one page per listing (listing.js), notifications, bell.
   ============================================================================= */
.kpi.is-bad dd { color: var(--bad); }
.panel-meta { font-size: 13px; color: var(--ink-3); }
.panel-meta.is-warn { color: var(--warn); font-weight: 600; }
.list-link { color: inherit; text-decoration: none; }
.list-link:hover b { text-decoration: underline; text-underline-offset: 3px; }

/* Countdown chip: how long until a document lapses. */
.due { display: inline-flex; align-items: center; gap: 5px; padding: 2px 8px 2px 6px; border-radius: var(--radius-pill); font-size: 12.5px; font-weight: 600; white-space: nowrap; }
.due .ic { width: 14px; height: 14px; }
.due.is-ok { color: var(--ok); background: var(--ok-soft); }
.due.is-warn { color: var(--warn); background: var(--warn-soft); }
.due.is-bad { color: var(--bad); background: var(--bad-soft); }

/* One sentence on where the listing stands. */
.state-banner { display: flex; align-items: flex-start; gap: 12px; padding: 14px 16px; border: 1px solid var(--line); border-left-width: 4px; border-radius: 10px; background: var(--surface); font-size: 14.5px; line-height: 1.5; color: var(--ink); }
.state-banner .ic { margin-top: 1px; }
.state-banner.is-ok { border-left-color: var(--ok); }
.state-banner.is-ok .ic { color: var(--ok); }
.state-banner.is-warn { border-left-color: var(--warn); }
.state-banner.is-warn .ic { color: var(--warn); }
.state-banner.is-bad { border-left-color: var(--bad); background: var(--bad-soft); }
.state-banner.is-bad .ic { color: var(--bad); }
.state-banner.is-info { border-left-color: var(--line-strong); }
.state-banner.is-info .ic { color: var(--ink-3); }

.listing { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 340px); gap: 20px; align-items: start; }
.listing-main { display: flex; flex-direction: column; gap: 20px; min-width: 0; }
.listing-form { display: flex; flex-direction: column; gap: 20px; min-width: 0; }
.listing-form[inert] { opacity: 0.6; }
.listing-aside { position: sticky; top: calc(var(--topbar-h) + 20px); display: flex; flex-direction: column; gap: 16px; min-width: 0; }
@media (max-width: 1099.98px) {
  .listing { grid-template-columns: minmax(0, 1fr); }
  .listing-aside { position: static; order: -1; }
}

.form-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px 18px; }
.form-grid .field.is-wide { grid-column: 1 / -1; }
@media (max-width: 899.98px) { .form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 519.98px) { .form-grid { grid-template-columns: minmax(0, 1fr); } }
.form-note { margin: 0 0 16px; font-size: 13.5px; line-height: 1.5; color: var(--ink-2); max-width: 70ch; }
.form-sub { margin: 24px 0 12px; padding-top: 18px; border-top: 1px solid var(--line); font-size: 14px; font-weight: 600; color: var(--ink); }
.field .input, .field .select { width: 100%; }
.field.is-flagged, .panel.is-flagged { animation: flag 1.6s ease; }
@keyframes flag { 0%, 60% { box-shadow: 0 0 0 3px var(--accent-soft); border-radius: 10px; } 100% { box-shadow: none; } }
#descCount.is-warn { color: var(--warn); }

/* Number with a unit. */
.affix { position: relative; }
.affix .input { padding-right: 44px; }
.affix span { position: absolute; right: 14px; top: 50%; transform: translateY(-50%); color: var(--ink-3); font-size: 14px; pointer-events: none; }

/* Yes / no and two-way choices as one segmented control. */
.choice { margin: 0; padding: 0; border: 0; min-width: 0; }
.choice legend { padding: 0; margin-bottom: 6px; font-size: var(--text-sm); font-weight: 600; color: var(--ink); }
.seg { display: inline-flex; width: 100%; padding: 3px; border: 1px solid var(--line-strong); border-radius: 10px; background: var(--surface-sunken); }
.seg input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.seg label { flex: 1; display: grid; place-items: center; min-height: calc(var(--control-h) - 8px); padding: 0 12px; border-radius: 7px; font-size: 14px; font-weight: 500; color: var(--ink-2); cursor: pointer; transition: background-color var(--transition), color var(--transition); }
.seg input:checked + label { background: var(--accent-fill); color: var(--accent-on-fill); font-weight: 600; }
.seg input:focus-visible + label { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Feature chips. */
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.chip { min-height: 36px; padding: 0 14px; border: 1px solid var(--line-strong); border-radius: var(--radius-pill); background: transparent; color: var(--ink-2); font: 500 13.5px/1 var(--font-text); cursor: pointer; transition: background-color var(--transition), border-color var(--transition), color var(--transition); }
.chip:hover { border-color: var(--ink-3); color: var(--ink); }
.chip[aria-pressed='true'] { border-color: transparent; background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.chip[aria-pressed='true']::before { content: '✓ '; }
@media (pointer: coarse) { .chip { min-height: 44px; } }
.chip-add { display: flex; gap: 8px; margin-top: 12px; max-width: 420px; }
.chip-add .input { flex: 1; min-width: 0; }

/* Photos: the first is the cover in search. */
.ph-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 136px), 1fr)); gap: 12px; margin: 0; padding: 0; list-style: none; }
.ph { position: relative; aspect-ratio: 4 / 3; border-radius: 10px; overflow: hidden; background: var(--surface-2); border: 1px solid var(--line); }
.ph img { width: 100%; height: 100%; object-fit: cover; display: block; }
.ph-cover { position: absolute; left: 8px; top: 8px; padding: 3px 9px; border-radius: var(--radius-pill); background: var(--accent-fill); color: var(--accent-on-fill); font-size: 12px; font-weight: 700; }
.ph-tools { position: absolute; inset: auto 0 0 0; display: flex; justify-content: flex-end; gap: 4px; padding: 6px; background: linear-gradient(to top, rgba(7, 13, 26, 0.75), transparent); }
.ph-btn { display: inline-grid; place-items: center; width: 34px; height: 34px; border: 0; border-radius: 8px; background: rgba(7, 13, 26, 0.6); color: #ffffff; cursor: pointer; }
.ph-btn .ic { width: 18px; height: 18px; }
.ph-btn:hover:not(:disabled) { background: rgba(7, 13, 26, 0.85); }
.ph-btn.is-danger:hover { background: #b3261e; }
.ph-btn:disabled { opacity: 0.35; cursor: default; }
@media (pointer: coarse) { .ph-btn { width: 40px; height: 40px; } }
.ph-confirm { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; background: rgba(7, 13, 26, 0.82); color: #ffffff; font-size: 14px; font-weight: 600; }
.ph-confirm .btn-quiet { color: #ffffff; }
.ph-add { border: 1.5px dashed var(--line-strong); background: transparent; }
.ph-drop { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; height: 100%; padding: 12px; text-align: center; color: var(--ink-2); cursor: pointer; }
.ph-drop .ic { width: 26px; height: 26px; color: var(--accent); }
.ph-drop b { font-size: 14px; color: var(--ink); }
.ph-drop span { font-size: 12px; line-height: 1.4; color: var(--ink-3); }
.ph-add:hover, .ph-add:focus-within { border-color: var(--accent); }
#photoInput:focus-visible + .ph-progress, .ph-add:has(#photoInput:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }
.ph-progress { display: flex; flex-direction: column; justify-content: center; gap: 8px; height: 100%; padding: 16px; font-size: 13px; color: var(--ink-2); }
#photoBody.is-dropping { outline: 2px dashed var(--accent); outline-offset: -6px; border-radius: 10px; }

.meter { height: 6px; border-radius: 6px; background: var(--surface-2); overflow: hidden; }
.meter i { display: block; height: 100%; border-radius: 6px; background: var(--ok); transition: width 300ms ease; }

/* Save bar: sticks to the bottom of the editor while scrolling it. */
.savebar {
  position: sticky;
  bottom: 12px;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 12px 12px 18px;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  background: color-mix(in srgb, var(--overlay) 94%, transparent);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  box-shadow: var(--shadow);
}
.savebar-state { margin: 0; font-size: 13.5px; line-height: 1.4; color: var(--ink-3); }
.savebar.is-dirty .savebar-state { color: var(--ink); }
.savebar.is-warn { border-color: color-mix(in srgb, var(--warn) 55%, transparent); }
.savebar.is-warn .savebar-state { color: var(--warn); }
.savebar .btn { flex: none; }
@media (max-width: 599.98px) { .savebar { flex-direction: column; align-items: stretch; } .savebar .btn { width: 100%; } }

/* The checklist on the right. */
.ready .panel-body { display: flex; flex-direction: column; gap: 6px; }
.ready .meter { margin-bottom: 6px; }
.ready-h { margin: 12px 0 2px; font-size: 12px; font-weight: 600; color: var(--ink-3); }
.ready-list { margin: 0; padding: 0; list-style: none; }
.ready-list li { font-size: 13.5px; }
.ready-list li.is-ok { display: flex; align-items: center; gap: 10px; min-height: 30px; color: var(--ink-3); }
.ready-ic { display: inline-grid; place-items: center; flex: none; width: 18px; height: 18px; border-radius: 50%; border: 1.5px solid var(--line-strong); }
.is-ok .ready-ic { border-color: var(--ok); background: var(--ok); color: var(--surface); }
.is-ok .ready-ic .ic { width: 12px; height: 12px; stroke-width: 3; }
.ready-go { display: flex; align-items: flex-start; gap: 10px; width: 100%; min-height: 32px; padding: 6px 6px 6px 0; border: 0; border-radius: 6px; background: none; color: var(--ink); font: 500 13.5px/1.35 var(--font-text); text-align: left; cursor: pointer; }
.ready-go .ready-ic { margin-top: 1px; border-color: var(--warn); }
.ready-go small { display: block; margin-top: 2px; font-size: 12px; font-weight: 400; color: var(--ink-3); }
.ready-go:hover > span:last-child { text-decoration: underline; text-underline-offset: 3px; }
.ready .btn-block { margin-top: 14px; }

/* The listing's road: Draft, review, online (a real sequence). */
.flow { display: grid; gap: 0; margin: 0; padding: 4px 4px 0; list-style: none; counter-reset: flow; }
.flow li { position: relative; padding: 0 0 16px 36px; counter-increment: flow; }
.flow li::before {
  content: counter(flow);
  position: absolute;
  left: 0;
  top: 0;
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 1.5px solid var(--line-strong);
  background: var(--page);
  color: var(--ink-3);
  font-size: 12px;
  font-weight: 700;
}
.flow li::after { content: ''; position: absolute; left: 11.5px; top: 26px; bottom: 2px; width: 1.5px; background: var(--line-strong); }
.flow li:last-child::after { content: none; }
.flow b { display: block; font-size: 14px; color: var(--ink-2); }
.flow span { font-size: 12.5px; color: var(--ink-3); }
.flow .is-done::before { content: '✓'; border-color: var(--ok); background: var(--ok); color: var(--page); }
.flow .is-done::after { background: var(--ok); }
.flow .is-current::before { border-color: var(--accent); color: var(--accent); }
.flow .is-current b { color: var(--ink); }

/* History and notifications. */
.timeline { margin: -6px 0; padding: 0; list-style: none; }
.timeline li { position: relative; display: grid; gap: 2px; padding: 10px 0 10px 22px; border-bottom: 1px solid var(--line); }
.timeline li:last-child { border-bottom: 0; }
.timeline li::before { content: ''; position: absolute; left: 3px; top: 17px; width: 8px; height: 8px; border-radius: 50%; background: var(--line-strong); }
.timeline li.is-ok::before { background: var(--ok); }
.timeline li.is-warn::before { background: var(--warn); }
.timeline li.is-bad::before { background: var(--bad); }
.timeline time { font-size: 12px; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.timeline b { font-size: 14px; font-weight: 600; }
.timeline span { font-size: 13px; color: var(--ink-2); }

.notes { margin: -8px 0; padding: 0; list-style: none; }
.note { display: grid; grid-template-columns: 32px minmax(0, 1fr) auto; gap: 12px; align-items: start; padding: 12px 0; border-bottom: 1px solid var(--line); }
.note:last-child { border-bottom: 0; }
.note-ic { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 9px; background: var(--surface-2); color: var(--ink-3); }
.note-ic .ic { width: 17px; height: 17px; }
.note.is-ok .note-ic { background: var(--ok-soft); color: var(--ok); }
.note.is-warn .note-ic { background: var(--warn-soft); color: var(--warn); }
.note.is-bad .note-ic { background: var(--bad-soft); color: var(--bad); }
.note-main { min-width: 0; color: inherit; text-decoration: none; }
.note-title { display: block; font-size: 14px; font-weight: 500; color: var(--ink-2); text-decoration: none; }
a.note-title:hover, a.note-main:hover .note-title { text-decoration: underline; text-underline-offset: 3px; }
.note.is-unread .note-title { color: var(--ink); font-weight: 600; }
.note-main p { margin-top: 2px; font-size: 13px; color: var(--ink-3); line-height: 1.45; }
.note time { font-size: 12px; color: var(--ink-3); white-space: nowrap; font-variant-numeric: tabular-nums; }
.note.is-unread time::before { content: ''; display: inline-block; width: 7px; height: 7px; margin-right: 6px; border-radius: 50%; background: var(--accent); vertical-align: middle; }
@media (max-width: 599.98px) { .note { grid-template-columns: 32px minmax(0, 1fr); } .note time { grid-column: 2; } }

/* The bell. */
.bell { position: relative; }
.bell-btn { position: relative; }
.bell-dot {
  position: absolute;
  top: 4px;
  right: 3px;
  display: grid;
  place-items: center;
  min-width: 17px;
  height: 17px;
  padding: 0 4px;
  border-radius: var(--radius-pill);
  background: var(--accent-fill);
  color: var(--accent-on-fill);
  font-size: 10px;
  font-weight: 700;
  box-shadow: 0 0 0 2px var(--page);
}
.bell-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: -52px;
  z-index: 40;
  width: 360px;
  max-width: calc(100vw - 16px);
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  background: var(--overlay);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}
.bell-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 48px; padding: 6px 8px 6px 16px; border-bottom: 1px solid var(--line); }
.bell-head b { font-size: 14px; }
.bell-list { max-height: min(420px, 60vh); margin: 0; padding: 0 16px; overflow-y: auto; list-style: none; }
.bell-list .note { grid-template-columns: 32px minmax(0, 1fr); padding: 10px 0; }
.bell-list .note-main time { display: block; margin-top: 2px; }
.bell-list .note.is-unread time::before { content: none; }
.bell-list .note.is-unread .note-ic { box-shadow: 0 0 0 2px var(--accent); }
.bell-empty { padding: 24px 16px; text-align: center; font-size: 14px; color: var(--ink-3); }
.bell-all { display: block; padding: 12px 16px; border-top: 1px solid var(--line); font-size: 13.5px; font-weight: 600; color: var(--link); text-align: center; text-decoration: none; }
.bell-all:hover { background: var(--surface-2); }
@media (max-width: 767.98px) { .bell-menu { position: fixed; top: calc(var(--topbar-h) + 4px); right: 8px; left: 8px; width: auto; max-width: none; } }

.crumb-parent a { color: var(--ink-2); text-decoration: none; }
.crumb-parent a:hover { color: var(--ink); text-decoration: underline; text-underline-offset: 3px; }
@media (max-width: 767.98px) { .crumbs .crumb-parent { display: none; } }

.vq-checks { display: flex; align-items: flex-start; gap: 8px; margin: 0 0 12px; padding: 8px 10px; border-radius: 8px; font-size: 13px; line-height: 1.4; }
.vq-checks .ic { width: 16px; height: 16px; margin-top: 1px; }
.vq-checks.is-ok { background: var(--ok-soft); color: var(--ok); }
.vq-checks.is-bad { background: var(--bad-soft); color: var(--bad); }

@media (prefers-reduced-motion: reduce) {
  .field.is-flagged, .panel.is-flagged { animation: none; }
  .meter i { transition: none; }
}

/* Below desktop the checklist sits above the form: show only what is missing. */
@media (max-width: 1099.98px) {
  .ready-list li.is-ok { display: none; }
  .ready-sec.is-done { display: none; }
  .flow { display: none; }
}

/* A toast clears the save bar instead of covering its button. */
body:has(.savebar) .toast { bottom: calc(96px + env(safe-area-inset-bottom, 0px)); }
@media (max-width: 599.98px) { body:has(.savebar) .toast { bottom: calc(150px + env(safe-area-inset-bottom, 0px)); } }

/* A gate with no problem to report (signed out) shows the monogram itself. */
.gate-mark.is-brand { width: auto; height: auto; margin-bottom: 22px; background: none; color: var(--ink); }
.gate-mark.is-brand .rovo-mark { height: 56px; }

/* -----------------------------------------------------------------------------
   Sign-in, sign-up and new password: one card per portal (see portals.js).
   ----------------------------------------------------------------------------- */
.signin {
  width: min(420px, 100%);
  margin: 7vh auto 0;
  padding: 32px 28px 28px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow);
}
.signin .rovo-mark { height: 44px; margin-bottom: 22px; color: var(--ink); }
.signin h1 { font: 600 semi-condensed 1.75rem/1.1 var(--font-display); color: var(--ink); }
.signin-lede { margin-top: 8px; font-size: 14.5px; line-height: 1.5; color: var(--ink-2); }
.signin-form { display: flex; flex-direction: column; gap: 14px; margin-top: 22px; }
.signin-form .input { width: 100%; }
.signin-form .error-text a { color: inherit; font-weight: 600; }
.signin-forgot { align-self: flex-end; min-height: 32px; margin-top: -6px; padding: 4px 0; border: 0; background: none; color: var(--link); font: 500 13px/1 var(--font-text); cursor: pointer; }
.signin-forgot:hover { text-decoration: underline; text-underline-offset: 3px; }
.signin-alt { margin-top: 16px; font-size: 14px; text-align: center; color: var(--ink-2); }
.signin-alt a { color: var(--link); font-weight: 600; }
@media (max-width: 767.98px) {
  .signin { margin-top: 3vh; padding: 20px 4px; border: 0; background: transparent; box-shadow: none; }
}
