/* ===================== Design tokens (design pass, December 2026) =====================
   One system: every colour, size, corner, shadow and motion value below is a token, and components use
   the tokens, never raw values. Text colours are checked at 4.5:1 or better on cards, panels and their
   own tinted pills, in both themes; control borders at 3:1.
   One accent: blue marks actions, links, selection and focus. Linestar red (--brand) is identity only
   (logo and wordmark). Status colours mean status and nothing else. */
:root {
  color-scheme: light;
  /* Surfaces and lines */
  --bg: #F5F6F8;
  --sidebar-bg: #FFFFFF;
  --panel-bg: #FFFFFF;          /* cards, dialogs (opaque) */
  --panel-bg-2: #F2F4F7;        /* subtle raised areas, table heads */
  --panel-strong: #E6E9EE;      /* pressed / selected areas */
  --border: #E3E6EB;            /* card and divider lines */
  --control-border: #8C94A0;    /* field and control outlines (3:1 on white) */
  /* Text */
  --text: #1A1D29;
  --text-muted: #4B5563;
  --text-dim: #5C6877;          /* hints; still 5.1:1 on panel-bg-2 */
  /* The one accent */
  --accent: #2563EB;            /* fills (white text on it 5.2:1) */
  --accent-hover: #1D4ED8;
  --accent-fg: #1D4ED8;         /* accent-coloured text and icons */
  --accent-rgb: 37, 99, 235;    /* tints: rgba(var(--accent-rgb), .12) */
  --on-accent: #FFFFFF;
  --focus: #2563EB;
  --brand: #E11D48;             /* Linestar red: logo and wordmark only */
  --brand-fg: #BE123C;          /* Linestar red as small text (5.6:1 on white) */
  --danger: #DC2626;            /* destructive fills (white text 4.8:1) */
  /* Status: text shade + its tint. green done, amber waiting, red refused / error / overdue, blue in progress */
  --status-green: #15803D;  --status-green-bg: #DCFCE7;
  --status-yellow: #B45309; --status-yellow-bg: #FEF3C7;
  --status-red: #B91C1C;    --status-red-bg: #FEE2E2;
  --status-blue: #1D4ED8;   --status-blue-bg: #DBEAFE;
  --status-gray: #4B5563;   --status-gray-bg: #F1F3F6;
  /* Category colours (kinds, never status) */
  --cat-violet: #6D28D9; --cat-violet-bg: #EDE9FE;
  --cat-pink: #BE185D;   --cat-pink-bg: #FCE7F3;
  --cat-orange: #C2410C; --cat-orange-bg: #FFEDD5;
  --cat-brown: #8A5A2B;  --cat-brown-bg: #F3EBE2;
  --cat-sky: #0369A1;    --cat-sky-bg: #E0F2FE;
  /* Elevation: e1 resting, e2 raised (hover, menus), e3 floating (dialogs, bars). Never coloured. */
  --e1: 0 1px 2px rgba(16,24,40,.05);
  --e2: 0 4px 12px rgba(16,24,40,.08), 0 1px 3px rgba(16,24,40,.06);
  --e3: 0 18px 44px rgba(16,24,40,.18), 0 2px 6px rgba(16,24,40,.08);
  --shadow: var(--e1);
  /* Corners: controls 8, menus 10, cards 12, dialogs 16 */
  --radius: 8px; --radius-menu: 10px; --radius-card: 12px; --radius-dialog: 16px;
  /* Control heights: md 38, sm 34, xs 26 */
  --h-md: 38px; --h-sm: 34px; --h-xs: 26px;
  /* Type scale (nothing under 11) */
  --fs-xs: 11px; --fs-sm: 12px; --fs-base: 13px; --fs-md: 14px; --fs-lg: 16px; --fs-xl: 18px; --fs-2xl: 20px; --fs-3xl: 24px; --fs-4xl: 28px;
  /* Motion: one curve, three durations; --move is 1 at Full, .6 at Calm and 0 at Off (see html[data-motion]).
     --dur-flash is the one exception: the tint on a row that just changed must stay long enough to be seen. */
  --dur-fast: 150ms; --dur-base: 200ms; --dur-slow: 300ms; --dur-flash: 1200ms;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --move: 1;
  /* Layout */
  --tabbar-h: 0px;
  /* Old names, kept so every existing rule and chart picks up the tokens */
  --accent-cyan: var(--accent);
  --accent-blue: var(--accent);
  --accent-blue-hover: var(--accent-hover);
  --accent-red-solid: var(--danger);
  --accent-green: var(--status-green);
  --accent-yellow: var(--status-yellow);
  --accent-red: var(--status-red);
}
html[data-theme="dark"] {
  /* Native controls (a select's own popup, scrollbars) follow the theme too. */
  color-scheme: dark;
  /* Neutral near-black, GitHub-style (Brydon's choice), designed per token rather than inverted. */
  --bg: #0D1117;
  --sidebar-bg: #0D1117;
  --panel-bg: #161B22;
  --panel-bg-2: #1C2128;
  --panel-strong: #262C36;
  --border: #30363D;
  --control-border: #6E7681;
  --text: #E6EDF3;
  --text-muted: #B4BCC6;
  --text-dim: #8B949E;
  --accent: #2563EB;
  --accent-hover: #1D4ED8;
  --accent-fg: #6CA8FB;
  --accent-rgb: 108, 168, 251;
  --focus: #6CA8FB;
  --brand: #FB7185;
  --brand-fg: #FB7185;
  --danger: #DC2626;
  --status-green: #4ADE80;  --status-green-bg: rgba(74,222,128,.13);
  --status-yellow: #FBBF24; --status-yellow-bg: rgba(251,191,36,.13);
  --status-red: #F87171;    --status-red-bg: rgba(248,113,113,.14);
  --status-blue: #6CA8FB;   --status-blue-bg: rgba(108,168,251,.14);
  --status-gray: #B4BCC6;   --status-gray-bg: rgba(156,163,175,.14);
  --cat-violet: #C4B5FD; --cat-violet-bg: rgba(167,139,250,.18);
  --cat-pink: #F9A8D4;   --cat-pink-bg: rgba(244,114,182,.18);
  --cat-orange: #FDBA74; --cat-orange-bg: rgba(251,146,60,.16);
  --cat-brown: #D9B48F;  --cat-brown-bg: rgba(192,154,114,.18);
  --cat-sky: #7DD3FC;    --cat-sky-bg: rgba(56,189,248,.16);
  --e1: 0 1px 2px rgba(0,0,0,.5);
  --e2: 0 6px 16px rgba(0,0,0,.45), 0 1px 3px rgba(0,0,0,.4);
  --e3: 0 20px 48px rgba(0,0,0,.6), 0 2px 8px rgba(0,0,0,.45);
}
html[data-theme="light"] { color-scheme: light; }
/* Motion levels (Settings → Appearance → Motion). Stamped on <html> before first paint by js/motion.js.
   Full is the default since 2026-12-03 (Andrew). Calm: things move a little (about 60% of Full's distance), nothing loops.
   Off: every animation and transition finishes at once. */
html[data-motion="calm"] { --move: .6; }
html[data-motion="off"] { --move: 0; }
html[data-motion="off"] *, html[data-motion="off"] *::before, html[data-motion="off"] *::after {
  animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: "Plus Jakarta Sans", Inter, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}

/* ---- App shell ---- */
/* ---- Login screen (gates the whole app) — split hero/card layout ---- */
.login-screen {
  position: fixed; inset: 0; z-index: 2000; background: #0A0E1A;
  display: flex; align-items: stretch;
}
.login-screen[hidden] { display: none; }

.login-hero {
  flex: 1.15; position: relative; overflow: hidden; color: #fff;
  background:
    radial-gradient(ellipse 900px 600px at 85% -10%, rgba(225,29,72,.25), transparent 60%),
    radial-gradient(ellipse 700px 500px at -10% 110%, rgba(225,29,72,.15), transparent 60%),
    linear-gradient(160deg, #0A0E1A 0%, #121729 55%, #171D33 100%);
  display: flex; flex-direction: column; justify-content: center;
  padding: 60px 64px; min-width: 0;
}
.login-hero::before {
  /* faint dot grid, same idea as the reference design, kept subtle */
  content: ""; position: absolute; inset: 0; opacity: .35; pointer-events: none;
  background-image: radial-gradient(rgba(255,255,255,.14) 1px, transparent 1px);
  background-size: 22px 22px;
  -webkit-mask-image: radial-gradient(ellipse 70% 70% at 30% 30%, #000, transparent);
  mask-image: radial-gradient(ellipse 70% 70% at 30% 30%, #000, transparent);
}
.login-hero-brand { display: flex; align-items: center; gap: 10px; margin-bottom: 48px; position: relative; }
.login-hero-brand img { height: 30px; width: auto; display: block; }
.login-hero-brand span { font-weight: 700; font-size: 18px; }
.login-hero-brand b { color: var(--brand); font-weight: 700; }
.login-hero h1 {
  font-size: clamp(28px, 3.4vw, 42px); line-height: 1.15; font-weight: 800; margin: 0 0 16px;
  max-width: 520px; position: relative;
}
.login-hero h1 em { font-style: normal; color: var(--brand); }
.login-hero p { color: #B7BDD0; font-size: 14px; line-height: 1.6; max-width: 460px; margin: 0 0 28px; position: relative; }
.login-hero-features { list-style: none; margin: 0 0 32px; padding: 0; display: flex; flex-direction: column; gap: 14px; position: relative; }
.login-hero-features li { display: flex; align-items: center; gap: 12px; font-size: 14px; font-weight: 500; color: #E5E7EF; }
.login-hero-features li i {
  width: 32px; height: 32px; border-radius: 8px; background: rgba(225,29,72,.16); color: var(--brand);
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.login-hero-features li i svg { width: 16px; height: 16px; }
.login-hero-badge {
  display: inline-flex; align-items: center; gap: 10px; align-self: flex-start;
  background: rgba(255,255,255,.06); border: 1px solid rgba(255,255,255,.12); border-radius: 10px;
  padding: 12px 16px; font-size: 13px; color: #C7CBDA; max-width: 420px; position: relative;
}
.login-hero-badge i { color: var(--brand); flex-shrink: 0; }
.login-hero-badge i svg { width: 18px; height: 18px; }

.login-card-wrap {
  flex: 0 0 440px; background: var(--bg); display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 24px; overflow-y: auto;
}
.login-box { width: 100%; max-width: 340px; }
.login-brand {
  color: var(--brand-fg); font-weight: 700; font-size: 24px; letter-spacing: -.3px;
  margin-bottom: 6px;
}
.login-brand span { display: block; color: var(--text-muted); font-weight: 500; font-size: 13px; letter-spacing: 0; margin-top: 2px; }
.login-welcome { font-size: 13px; color: var(--text-dim); margin: 0 0 26px; }
.login-link { display: block; text-align: center; margin-top: 14px; font-size: 13px; color: var(--accent-fg); text-decoration: none; }
.login-link:hover { text-decoration: underline; }
.login-legal-footer { margin-top: 28px; text-align: center; font-size: 12px; color: var(--text-dim); }
.login-legal-footer a { color: var(--text-dim); text-decoration: none; }
.login-legal-footer a:hover { text-decoration: underline; color: var(--text-muted); }
.login-legal-copyright { margin-top: 6px; }

@media (max-width: 900px) {
  .login-hero { display: none; }
  .login-card-wrap { flex: 1; }
}

/* ---- Login splash — plays the real Linestar logo clip full-screen while a login is in flight ---- */
.login-splash {
  position: fixed; inset: 0; z-index: 2500; background: #fff;
  display: flex; align-items: center; justify-content: center;
  opacity: 0; pointer-events: none; transition: opacity var(--dur-slow) var(--ease);
}
.login-splash.show { opacity: 1; pointer-events: all; }
.login-splash-inner { display: flex; flex-direction: column; align-items: center; gap: 22px; }
.login-splash video { max-height: min(85vh, 640px); max-width: 94vw; width: auto; height: auto; }
.login-splash-loading {
  font-size: 14px; font-weight: 600; color: var(--text-dim, #6B7280);
  display: flex; align-items: baseline;
}
.login-splash-dots span { animation: loginSplashDot 1.4s infinite; opacity: 0; }
.login-splash-dots span:nth-child(2) { animation-delay: .2s; }
.login-splash-dots span:nth-child(3) { animation-delay: .4s; }
@keyframes loginSplashDot { 0%, 80%, 100% { opacity: 0; } 40% { opacity: 1; } }

.dash-attention-more {
  display: block; width: 100%; text-align: left; margin-top: 8px; padding: 6px 0 0; border: none;
  border-top: 1px dashed rgba(255,255,255,.16); background: none; color: var(--accent-fg);
  font-size: 12px; font-weight: 600; cursor: pointer; font-family: inherit;
}
.dash-attention-more:hover { color: var(--accent-blue-hover); }

html[data-theme="light"] .dash-attention-more { border-top-color: rgba(20,30,60,.14); }
html[data-theme="light"] .dash-pm-chip { border-color: rgba(20,30,60,.12); }
/* The .ok/.due/.over text colors below are light pastels tuned to sit on the hero's dark glass
   card — on the light-theme glass card (which is white/near-white) they were nearly invisible.
   Darker, more saturated versions of the same three hues for the light card background. */

.dash-pm-summary { display: flex; gap: 8px; margin-bottom: 10px; flex-wrap: wrap; }
.dash-pm-chip { font-size: 11px; font-weight: 700; padding: 4px 9px; border-radius: 999px; border: 1px solid rgba(255,255,255,.18); }

/* ---- Shared period-filter pills + big stat number, used by the Dashboard's Repairs Spend / Vendor
   Invoices / Task Tracker panels ---- */
.dash-period-pills { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
.dash-period-pill {
  border: 1px solid var(--border); background: var(--panel-bg-2); color: var(--text-muted);
  font-size: 12px; font-weight: 600; padding: 5px 12px; border-radius: 999px; cursor: pointer;
  font-family: inherit; transition: background-color var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease);
}
.dash-period-pill.active { background: var(--accent-blue); border-color: var(--accent-blue); color: var(--on-accent); }
.dash-period-pill:hover:not(.active) { border-color: var(--accent-blue); color: var(--accent-fg); }
.dash-big-stat { font-size: 28px; font-weight: 800; letter-spacing: -.6px; color: var(--text); margin-bottom: 10px; }
.dash-panel-count { font-weight: 500; }

.dash-diag-row { display: flex; align-items: center; gap: 14px; padding: 10px 0; }
.dash-diag-clickable { cursor: pointer; border-radius: 8px; margin: 0 -8px; padding: 10px 8px; transition: background-color var(--dur-fast) var(--ease); }
.dash-diag-clickable:hover { background: var(--panel-bg-2); }
.dash-diag-clickable:focus-visible { background: var(--panel-bg-2); outline: none; box-shadow: 0 0 0 2px var(--accent-blue); }
.dash-diag-icon { width: 40px; height: 40px; border-radius: 10px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.dash-diag-icon svg { width: 19px; height: 19px; }
.dash-diag-value { font-size: 24px; font-weight: 800; letter-spacing: -.4px; color: var(--text); }
.dash-diag-label { font-size: 12px; color: var(--text-dim); margin-top: 1px; }

/* Whole-page immersive theme for the Dashboard — matches the hero above so the page reads as one
   continuous surface instead of "styled hero, plain page." Scoped to #page-dashboard only (every
   other page keeps the normal flat panel style — dense data tables need high-contrast rows, not a
   "premium" treatment) and now correctly FOLLOWS the site-wide light/dark toggle instead of always
   forcing the dark look — dark mode gets the night glass treatment below, light mode just uses the
   normal light panel/card styling every other page already has (no override needed for it at all).
   Re-pointing the shared --panel-bg/--border/--text/etc vars here is what makes every existing
   KPI card, chart, legend and table on this page pick up the glass look automatically, with zero
   changes to the chart-drawing JS (it already reads these vars, never hardcoded colors). */
html[data-theme="dark"] #page-dashboard {
  background: linear-gradient(180deg, #0A0E1A 0%, #121729 45%, #171D33 100%);
  margin: -28px -32px; padding: 28px 32px 32px;
  --bg: transparent;
  --panel-bg: rgba(255,255,255,.055);
  --panel-bg-2: rgba(255,255,255,.09);
  --border: rgba(255,255,255,.13);
  --text: #F2F3F7;
  --text-muted: #C7CCD8;
  --text-dim: #96A0B5;
  --shadow: 0 8px 22px rgba(0,0,0,.35);
}
html[data-theme="dark"] #page-dashboard .kpi-card, html[data-theme="dark"] #page-dashboard .panel {
  border-radius: 14px; transition: transform var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease);
}
html[data-theme="dark"] #page-dashboard .kpi-card:hover, html[data-theme="dark"] #page-dashboard .panel:hover { box-shadow: var(--e3); }
html[data-theme="dark"] #page-dashboard .select-field, html[data-theme="dark"] #page-dashboard input, html[data-theme="dark"] #page-dashboard select {
  background: rgba(255,255,255,.06); color: var(--text); border-color: var(--border);
}
html[data-theme="dark"] #page-dashboard table thead { background: rgba(255,255,255,.04); }
html[data-theme="dark"] #page-dashboard .empty-state { color: var(--text-dim); }

/* Grid, not flex, specifically so the collapse/expand below can animate grid-template-columns
   instead of the sidebar's own width — animating `width` directly forces a full layout recalc on
   every frame (a real jank source the design-quality hook flags); a grid track resize is the
   standard GPU-friendlier equivalent for a "push/reclaim horizontal space" transition. */
.app-shell { display: grid; grid-template-columns: 230px 1fr; grid-template-rows: 1fr; height: 100vh; transition: grid-template-columns var(--dur-fast) var(--ease); }
/* This is the third .app-shell child (after .sidebar and .main) and only ever means anything on
   the mobile overlay layout below — it used to just sit at 0 width in the old flex row, harmless.
   Under grid, an item with no explicit placement gets auto-placed into the next open cell, which
   landed it in column 2 ahead of .main and bumped .main into a whole second implicit row (the
   exact "content area went blank" bug this whole rule exists to prevent). display:none removes it
   from grid placement entirely on desktop; the mobile media query below turns it back on. */
.sidebar-backdrop { display: none; }

.sidebar {
  grid-column: 1; min-width: 0; background: var(--sidebar-bg);
  border-right: 1px solid var(--border); padding: 20px 0; display: flex; flex-direction: column;
  height: 100vh; overflow-y: auto;
}
/* Hidden, not removed — the toggle button that brings it back lives in the topbar, outside the
   sidebar itself, so it's still reachable once its track collapses to 0. Every page's own content
   sits in .main (explicitly pinned to grid-column 2, see below), so it naturally expands to fill
   the reclaimed width, no per-page changes needed. */
.app-shell.sidebar-collapsed { grid-template-columns: 0px 1fr; }
.app-shell.sidebar-collapsed .sidebar { border-right: none; overflow: hidden; }
#btn-toggle-sidebar svg { transition: transform var(--dur-fast) var(--ease); }
.app-shell.sidebar-collapsed #btn-toggle-sidebar svg { transform: rotate(180deg); }

/* ---- Mobile: the sidebar was permanently 230px wide with no breakpoint at all, so on a phone it
   just sat there full-height and squeezed every page's real content into a sliver a few dozen
   pixels wide — the app was effectively unusable below ~820px. Below that width the sidebar becomes
   a slide-in overlay instead (closed by default — see settings.js), opened by the same topbar
   toggle button, with a backdrop to tap-dismiss. Desktop behavior (push/reclaim layout width) is
   untouched above this breakpoint. */
@media (max-width: 1023px) {
  .sidebar {
    position: fixed; top: 0; left: 0; z-index: 500; width: 260px; max-width: 82vw;
    transform: translateX(0); box-shadow: 12px 0 32px rgba(0,0,0,.35);
    transition: transform var(--dur-base) var(--ease);
  }
  .app-shell.sidebar-collapsed .sidebar { width: 260px; max-width: 82vw; transform: translateX(-100%); box-shadow: none; }
  .sidebar-backdrop {
    display: none; position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 499;
  }
  .app-shell:not(.sidebar-collapsed) .sidebar-backdrop { display: block; }
  #btn-toggle-sidebar svg { transform: none !important; }
}
.sidebar .brand { padding: 2px 18px 16px; margin-bottom: 6px; display: flex; align-items: center; gap: 9px; border-bottom: 1px solid var(--border); }
.sidebar .brand img { width: 22px; height: auto; display: block; flex-shrink: 0; }
.sidebar .brand .name { color: var(--text); font-weight: 700; font-size: 16px; letter-spacing: -.2px; white-space: nowrap; }
.sidebar .brand .sub { color: var(--brand-fg); font-weight: 600; font-size: 11px; margin-top: 1px; }
.sidebar .section-label { color: var(--text-muted); font-size: 11px; font-weight: 800; padding: 16px 22px 7px; }
/* Password field with a show/hide eye — lets you see exactly what was typed (phones auto-fill or
   auto-correct passwords without you noticing). */
.password-wrap { position: relative; }
.password-wrap input { width: 100%; padding-right: 42px; }
.password-eye { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); border: none; background: none; padding: 6px; cursor: pointer; color: var(--text-dim); display: flex; }
.password-eye svg { width: 18px; height: 18px; }
.sidebar nav { display: flex; flex-direction: column; gap: 1px; padding: 0 10px; }
.sidebar nav button {
  display: flex; align-items: center; gap: 10px; width: 100%; text-align: left;
  background: none; border: none; color: var(--text); font-size: 14px; font-weight: 700;
  padding: 8px 12px; cursor: pointer; border-radius: 7px; transition: background-color var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
}
.sidebar nav button:hover { background: var(--panel-bg-2); color: var(--text); }
.sidebar nav button.active { background: color-mix(in srgb, var(--accent-blue) 12%, transparent); color: var(--accent-fg); font-weight: 800; }
.sidebar nav button.disabled { color: var(--text-dim); cursor: default; opacity: .55; }
.sidebar nav button.disabled:hover { background: none; color: var(--text-dim); }
.sidebar .spacer { flex: 1; }
.sidebar .footer-status { margin: 8px 10px 0; padding: 12px 12px; border-top: 1px solid var(--border); font-size: 12px; color: var(--text-dim); }
.sidebar .footer-status .dot { color: var(--status-green); }

/* ---- Main / topbar ---- */
/* min-height:0 overrides the grid item's default min-height:auto (content-based floor) — without
   it, .main was free to grow taller than its own grid row to fit .content's full unclipped height,
   which made the WHOLE PAGE (not just .content) scroll, dragging the sidebar along with it instead
   of staying pinned. This is what makes .content's own overflow:auto actually the thing that
   scrolls, exactly like it did under the old flex layout (flex items have this identical footgun,
   which is why min-width:0 was already here for the horizontal axis). */
.main { grid-column: 2; display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.topbar {
  display: flex; align-items: center; padding: 18px 28px; border-bottom: 1px solid var(--border);
  gap: 14px; background: var(--panel-bg); flex-shrink: 0;
}
.topbar h1 { font-size: 18px; letter-spacing: -.2px; margin: 0; color: var(--text); font-weight: 600; white-space: nowrap; }
.topbar .spacer { flex: 1; }
.pill { padding: 6px 12px; border-radius: 6px; font-size: 12px; font-weight: 600; letter-spacing: .2px; }
.pill-connecting { background: var(--status-yellow-bg); color: var(--status-yellow); }
.pill-connected { background: var(--status-green-bg); color: var(--status-green); }
.topbar-btn {
  background: var(--panel-bg); border: 1px solid var(--border); color: var(--text-muted);
  padding: 7px 12px; border-radius: 6px; font-size: 12px; cursor: pointer;
}
.topbar-btn:hover { border-color: var(--accent-blue); color: var(--accent-fg); }
.topbar-date { color: var(--text-muted); font-size: 13px; }
.avatar {
  width: 30px; height: 30px; border-radius: 50%; background: var(--accent-blue); color: var(--on-accent);
  display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 700;
  border: none; font-family: inherit; cursor: pointer; flex-shrink: 0;
}
.user-chip { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text); position: relative; }
.profile-popover {
  position: absolute; top: calc(100% + 10px); right: 0; width: 250px; z-index: 60;
  background: var(--panel-bg); border: 1px solid var(--border); border-radius: 10px;
  box-shadow: var(--e3); padding: 14px;
}
.profile-popover-header { display: flex; align-items: center; gap: 10px; }
.profile-popover-header .avatar { cursor: default; }
.profile-popover-name { font-size: 14px; font-weight: 600; color: var(--text); }
.profile-popover-role { font-size: 12px; color: var(--text-muted); }
.profile-popover-divider { height: 1px; background: var(--border); margin: 12px 0; }
.profile-popover-label { display: block; font-size: 11px; color: var(--text-dim); margin-bottom: 5px; }

/* overflow-anchor:none — same fix as .table-scroll-pane below: this is the outer per-page
   scroll container, and its children (KPI cards, filters) reflow every second from the 1s
   repaint loop, which was enough to trigger Chrome's scroll-anchoring and silently snap the
   whole page back toward the top mid-scroll on pages taller than one screen (Task Tracker). */
.content { padding: 28px 32px; flex: 1; overflow: auto; overflow-anchor: none; }
.page[hidden] { display: none; }

/* ---- Toolbar / controls ---- */
.toolbar { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; }
.btn {
  border: none; border-radius: var(--radius); padding: 9px 18px; font-size: 14px;
  cursor: pointer; font-weight: 500; font-family: inherit;
}
.btn-primary { background: var(--accent-blue); color: var(--on-accent); }
.btn-primary:hover { background: var(--accent-blue-hover); }
.btn-secondary { background: var(--panel-bg); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { border-color: var(--accent-blue); color: var(--accent-fg); }
.btn-danger { background: var(--accent-red-solid); color: var(--on-accent); }
.btn-danger:hover { filter: brightness(.9); }
/* Every actual "Save" button, sitewide — deliberately its own green, not the brand accent (which
   happens to be a rose/red and reads as a warning color on a Save action, easy to confuse with
   Delete/Close right next to it in the same header/footer). */
.btn-save { background: var(--status-green); color: #fff; }
.btn-save:hover { filter: brightness(.92); }
.spacer { flex: 1; }
/* Toolbar search box (icon inside the field) + a right-aligned group that keeps Filters / Download /
   Columns / Settings together in one place instead of scattered along the bar. */
.search-field { position: relative; flex: 1; max-width: 460px; }
.search-field svg { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; color: var(--text-dim); pointer-events: none; }
.search-field input { width: 100%; padding: 9px 12px 9px 34px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--panel-bg); color: var(--text); font-size: 14px; font-family: inherit; }
.search-field input:focus { outline: none; border-color: var(--accent-blue); box-shadow: 0 0 0 3px rgba(37,99,235,.12); }
.toolbar-group { display: flex; align-items: center; gap: 8px; }
.toolbar-group .btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; }
.toolbar-group .btn svg { width: 16px; height: 16px; }
.filter-count-badge { background: var(--accent-cyan); color: var(--on-accent); border-radius: 999px; font-size: 11px; font-weight: 700; padding: 1px 7px; margin-left: 2px; }
.filter-count-badge[hidden] { display: none; }
.filters-results { flex-basis: 100%; padding-bottom: 14px; margin-bottom: 2px; border-bottom: 1px solid var(--border); }
/* ---- Filters panel (v2): results strip, header with "Clear all", tidy auto-fit grid ---- */
.filters-panel.filters-panel-v2 { flex-direction: column; flex-wrap: nowrap; gap: 14px; padding: 18px 20px; }
.filters-panel.filters-panel-v2 .filters-results { flex-basis: auto; padding-bottom: 16px; margin: 0; }
.filters-section-title { display: flex; align-items: center; gap: 7px; font-size: 13px; font-weight: 700; color: var(--text); margin-bottom: 10px; }
.filters-section-title svg { width: 15px; height: 15px; color: var(--text-dim); }
.filters-head { display: flex; align-items: center; justify-content: space-between; }
.filters-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 14px 16px; }
.filters-grid .form-field { min-width: 0; }
.filters-grid .select-field { width: 100%; }
.filters-grid .filters-wide { grid-column: span 2; }
.filters-range { display: flex; align-items: center; gap: 6px; }
.filters-range > * { flex: 1; min-width: 0; }
.filters-range > span { flex: 0; color: var(--text-dim); }
@media (max-width: 700px) { .filters-grid .filters-wide { grid-column: span 1; } }

/* ---- Columns menu: every column as a switch, drag the grip to reorder (personal per user) ---- */
.col-menu {
  position: fixed; z-index: 10000; width: 300px; background: var(--panel-bg); border: 1px solid var(--border);
  border-radius: 12px; box-shadow: var(--shadow); padding: 12px; display: flex; flex-direction: column; gap: 8px;
}
.col-menu[hidden] { display: none; }
.col-menu-head { display: flex; align-items: flex-start; justify-content: space-between; font-size: 14px; color: var(--text); }
.col-menu-note { margin: 0; font-size: 12px; }
.col-menu-list { display: flex; flex-direction: column; max-height: 360px; overflow-y: auto; margin: 0 -4px; }
.col-menu-row { display: flex; align-items: center; gap: 8px; padding: 6px 6px; border-radius: 8px; cursor: grab; font-size: 13px; color: var(--text); }
.col-menu-row:hover { background: var(--panel-bg-2); }
.col-menu-row.dragging { opacity: .4; }
.col-menu-grip { width: 15px; height: 15px; color: var(--text-dim); flex-shrink: 0; }
.col-menu-label { flex: 1; }
.col-menu-foot { display: flex; justify-content: space-between; border-top: 1px solid var(--border); padding-top: 8px; }
.col-menu-link { display: inline-flex; align-items: center; gap: 5px; border: none; background: none; padding: 4px 6px; border-radius: 6px; cursor: pointer; font-size: 13px; font-weight: 600; color: var(--accent-fg); font-family: inherit; }
.col-menu-link:hover { background: var(--panel-bg-2); }
.col-menu-link svg { width: 14px; height: 14px; }
.col-menu-link[hidden] { display: none; }
.toggle-switch.toggle-switch-sm { width: 34px; height: 20px; }
.toggle-switch.toggle-switch-sm .slider::before { width: 14px; height: 14px; left: 3px; bottom: 3px; }
.toggle-switch.toggle-switch-sm input:checked + .slider::before { transform: translateX(14px); }
.summary-bar { font-size: 13px; color: var(--text-muted); margin-bottom: 12px; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.summary-bar > span + span { margin-left: 18px; } /* "Label: 123" stays together; separate groups keep their spacing */
.summary-bar b { color: var(--text); }
/* Bulk select/delete bar — appears once at least one row checkbox is ticked, instead of having to
   open each record on its own just to delete it. */
.bulk-actions-bar {
  display: flex; align-items: center; gap: 12px; margin-bottom: 12px; padding: 10px 14px;
  background: color-mix(in srgb, var(--accent-blue) 8%, var(--panel-bg)); border: 1px solid var(--accent-blue);
  border-radius: var(--radius); font-size: 13px; color: var(--text);
}
.bulk-actions-bar .spacer-none { flex: 0; }
.icon-btn {
  width: 36px; height: 36px; border-radius: var(--radius); border: none; cursor: pointer;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0; font-family: inherit;
}
.icon-btn.primary { background: var(--accent-blue); color: var(--on-accent); }
.icon-btn.primary:hover { background: var(--accent-blue-hover); }
.icon-btn.secondary { background: var(--panel-bg); color: var(--text); border: 1px solid var(--border); }
.icon-btn.secondary:hover { border-color: var(--accent-blue); color: var(--accent-fg); }
.select-field {
  padding: 8px 12px; border: 1px solid var(--border); border-radius: var(--radius); font-size: 14px;
  background: var(--panel-bg); color: var(--text); font-family: inherit; accent-color: var(--accent-blue);
}
/* color-scheme alone (on html[data-theme="dark"]) gets the dropdown POPUP itself dark, but Chrome
   still renders each <option> row's own background/text from ordinary CSS when it's set explicitly
   — without this, unselected rows fell back to a plain white background with barely-visible text
   while only the hovered row (native blue highlight) was readable. Deliberately NOT var(--panel-bg)
   here: on #page-dashboard that variable is a translucent white glass tint meant to sit over that
   page's own dark gradient — inside a native, OS-rendered popup there's no gradient behind it to
   tint, so the "glass" just reads as plain white. These are the real solid theme colors instead. */
html[data-theme="dark"] .select-field option { background: #161B22; color: #E6EDF3; }
html[data-theme="light"] .select-field option { background: #FFFFFF; color: #1A1D29; }
/* Placeholder text had no rule at all, so every input fell back to the browser's own default
   placeholder color — a mid-gray tuned for a white field, which goes low-contrast/hard to read once
   the field itself is dark. Checkboxes/radios get the same accent-color treatment for the same
   reason (unstyled = browser default blue, not this app's own accent). */
input::placeholder, textarea::placeholder, .select-field::placeholder { color: var(--text-dim); opacity: 1; }
input[type="checkbox"], input[type="radio"] { accent-color: var(--accent-blue); }

/* ---- Custom date/datetime segmented input — see js/date-input.js. Replaces the native
   type="date"/"datetime-local" picker (which has no way for JS to know which of its internal
   segments the mouse selected, so "select month+day, hit Backspace once" can't be built on top of
   it) with plain spans this app fully controls, styled to match .select-field so it drops in
   wherever a date field already sits. */
.dt-input {
  display: inline-flex; align-items: center; padding: 8px 10px; border: 1px solid var(--border);
  border-radius: var(--radius); font-size: 14px; background: var(--panel-bg); color: var(--text);
  font-family: inherit; cursor: text; user-select: none; gap: 1px; line-height: 1.2;
}
.dt-input.dt-focused { border-color: var(--accent-blue); }
.dt-seg { padding: 1px 2px; border-radius: 3px; color: var(--text); outline: none; }
.dt-seg.dt-placeholder { color: var(--text-dim); }
.dt-input.dt-focused .dt-seg.dt-seg-focus { background: color-mix(in srgb, var(--accent-blue) 16%, transparent); }
.dt-seg.dt-seg-selected { background: color-mix(in srgb, var(--accent-blue) 30%, transparent); color: var(--text); }
.dt-sep { color: var(--text-dim); padding: 0 1px; }
.dt-input .dt-gap { width: 6px; }
.filters-panel {
  display: flex; gap: 14px; background: var(--panel-bg); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px;
  margin-bottom: 16px; flex-wrap: wrap; box-shadow: var(--shadow);
}
.filters-panel[hidden] { display: none; }
.filters-panel .form-field { min-width: 160px; }
/* A plain <div>, not a <label> — a <label> wrapping the checkbox toggles it from a click anywhere
   in the row (including the text), which reads as "I can't click the text without also flipping the
   setting." Only the checkbox square itself is interactive; the checkbox keeps its own native pointer
   cursor, the row itself does not. */
.checkbox-row { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text); }
.checkbox-row input[type="checkbox"] { cursor: pointer; flex-shrink: 0; }

/* ---- Dashboard / stat cards ---- */
.cards { display: flex; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.card {
  background: var(--panel-bg); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 18px 20px; min-width: 170px; flex: 1; box-shadow: var(--shadow);
}
/* A flat accent border across a rounded top edge clips awkwardly right where the straight border
   meets the curve — squaring off just the top two corners on these variants (bottom stays rounded)
   is the standard fix, not removing the accent. */
.card.accent-green, .card.accent-yellow, .card.accent-red { border-top-left-radius: 0; border-top-right-radius: 0; }
.card.accent-green { border-top: 3px solid var(--status-green); }
.card.accent-yellow { border-top: 3px solid var(--status-yellow); }
.card.accent-red { border-top: 3px solid var(--status-red); }
.card .label { font-size: 12px; color: var(--text-muted); margin-bottom: 8px; font-weight: 500; }
.card .value { font-size: 24px; font-weight: 600; color: var(--text); letter-spacing: -.4px; }
.card .hint { font-size: 12px; color: var(--text-dim); margin-top: 4px; }

.panel {
  background: var(--panel-bg); border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 20px; box-shadow: var(--shadow);
}
.panel-header {
  display: flex; align-items: center; padding: 14px 20px; border-bottom: 1px solid var(--border);
  font-size: 14px; font-weight: 600; color: var(--text);
}
.panel-body { padding: 20px; color: var(--text-muted); font-size: 13px; }

/* ---- Table ---- */
/* overflow:hidden used to live here for the rounded corners — but that makes the <table> itself a
   scroll-clip container, which silently defeats position:sticky on the header (its "nearest
   scrolling ancestor" becomes the table, whose own box never actually scrolls, instead of the real
   page). Corners are very slightly square in the table's own two bottom corners now instead — a
   fair trade for a header that actually stays put while scrolling a long list. */
table { width: 100%; border-collapse: collapse; background: var(--panel-bg); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
/* A table nested inside a .panel (e.g. Dashboard's "Recent repair cases") already sits inside one
   card — giving it its own border/shadow/radius on top doubles the frame for no reason. Panel-body
   background already matches, so dropping all three here just leaves one clean edge, not two. */
.panel table { border: none; box-shadow: none; border-radius: 0; background: transparent; }
thead { background: var(--panel-bg-2); color: var(--text-muted); border-bottom: 2px solid var(--border); }
/* Sticky header — the header row stays put at the top of the scrolling page while you scroll down
   through however many rows a table has, instead of scrolling away with row 1 and leaving every row
   after it unlabeled. Every table gets this for free since header markup is already consistent
   across pages. */
thead th { position: sticky; top: 0; z-index: 3; background: var(--panel-bg-2); }
th, td { text-align: left; padding: 12px 14px; font-size: 13px; border-color: var(--border); }
/* Column headers read as labels that point at the data under them — full text color, bold, a touch
   larger than before (was muted grey 11px, easy to miss). Applies to every table sitewide. */
th { font-weight: 800; font-size: 12px; color: var(--text); border-right: 1px solid var(--border); }
/* Key identifiers in a row (Unit #, Amount) — bold so the eye lands on them first. */
td.cell-strong { font-weight: 700; color: var(--text); }
/* Vehicle type — same colors the Maintenance sheet used: Truck light red, Trailer light blue,
   Brokerage trailer light yellow. */
.vt-pill { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; }

th:last-child { border-right: none; }
/* ---- Draggable column headers — grab a header and drop it on another to swap their order ---- */
th.col-draggable { cursor: grab; }
th.col-draggable:hover { background: var(--panel-bg-2); }
th.col-dragging { opacity: .4; }
th.col-drop-target { box-shadow: inset 2px 0 0 var(--accent-blue), inset -2px 0 0 var(--accent-blue); }
/* ---- Self-scrolling table pane (Repairs/PM/Task Tracker) ----
   A browser will not let one element scroll horizontally (overflow-x:auto) while also letting a
   sticky child escape vertically to the page's own scroll — overflow-y silently gets forced back to
   auto to match (tested directly: setting overflow-y:visible with !important still computes to
   auto). Giving the wrapper its OWN bounded height and letting it scroll BOTH axes itself sidesteps
   that entirely: the sticky header now sticks to the top of this pane (its real, intended scrolling
   ancestor), and the table's own horizontal scrollbar sits at the bottom of a pane that's always
   within about one screen's reach, never thousands of rows down the page. Same pattern Notion/
   Airtable use for a big database view. */
/* overflow-anchor:none stops the browser's own scroll-anchoring from "helpfully" nudging scrollTop
   on its own after a big DOM replacement (which is what every 1-second repaint does here) — it was
   fighting the explicit scroll-position restore in renderTaskListInto (tasks.js), adding a small
   extra drift on top of it every single tick until the two together crept the view down the page on
   their own with no scrolling from the user at all. */
.table-scroll-pane { max-height: 60vh; overflow: auto; overflow-anchor: none; }
tbody tr { border-bottom: 1px solid var(--border); color: var(--text); }
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: var(--panel-bg-2); }
tbody tr.row-pending { color: var(--text-muted); }
tbody tr.row-pending td.col-status { color: var(--text-muted); }
td.col-status { font-weight: 500; }
.row-status-paid { color: var(--status-green); }
.row-status-dispute { color: var(--status-red); }
/* Open-record icon in every table — kept small so rows stay compact. */
.row-link-icon { width: 26px; padding-left: 6px !important; padding-right: 4px !important; text-align: center; color: var(--text-dim); cursor: pointer; }
.row-link-icon svg { width: 14px; height: 14px; }
#btn-sync.syncing svg { animation: sync-spin .8s linear infinite; }
@keyframes sync-spin { to { transform: rotate(360deg); } }
.row-link-icon:hover { color: var(--accent-fg); }
/* Repairs is the densest board — tighter rows/text and a smaller open-case icon so more cases fit
   on one screen. */
#repairs-table th { padding: 9px 10px; }
#repairs-table td { padding: 7px 10px; font-size: 13px; }
#repairs-table td:first-child, #repairs-table th:first-child { width: 28px; padding: 7px 6px; }
#repairs-table .row-link-icon { width: 26px; padding: 7px 4px; }
#repairs-table .row-link-icon svg { width: 14px; height: 14px; }
/* One line per case (no wrapping into 2-3 line rows); long notes are cut with "…" and shown in full
   on hover. The pane uses the room the old KPI row took, so more cases are visible at once. */
#repairs-table th, #repairs-table td { white-space: nowrap; }
#repairs-table td.cell-clip { max-width: 240px; overflow: hidden; text-overflow: ellipsis; }
#repairs-table-wrap { max-height: calc(100vh - 230px); }
/* PM table: same compact one-line rows as Repair Expenses. */
#pm-table th { padding: 9px 10px; }
#pm-table td { padding: 7px 10px; font-size: 13px; }
#pm-table th, #pm-table td { white-space: nowrap; }

.task-quickadd-btn {
  width: 100%; text-align: left; padding: 10px 12px; background: none; border: none;
  border-top: 1px dashed var(--border); color: var(--accent-fg); cursor: pointer;
  font-size: 13px; font-weight: 600; font-family: inherit;
  display: flex; align-items: center; gap: 6px;
}
.task-quickadd-btn:hover { background: var(--panel-bg-2); color: var(--accent-fg); }
.sla-ontime { color: var(--status-green); font-weight: 600; }
.sla-late { color: var(--status-red); font-weight: 600; }
.sla-na { color: var(--text-dim); }

/* ---- Full-screen views (Add/Edit Case, Add/Edit Invoice, Add/Edit Item) ---- */
.fullscreen-view {
  position: fixed; inset: 0; background: var(--bg); z-index: 1000;
  display: flex; flex-direction: column; overflow: hidden;
}
.fullscreen-view[hidden] { display: none; }
.fullscreen-header {
  display: flex; align-items: center; padding: 18px 28px; border-bottom: 1px solid var(--border);
  gap: 10px; flex-shrink: 0; background: var(--panel-bg);
}
.fullscreen-header h2 { font-size: 18px; margin: 0; flex: 1; color: var(--text); font-weight: 600; }
.fullscreen-body { flex: 1; overflow: auto; padding: 28px 32px; }
/* A case opened from "Spend by unit" must sit above that report view. */
#repair-view { z-index: 1001; }
#record-history-modal { z-index: 1100; }
/* ---- Spend by unit ---- */
.ru-type-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.ru-chip { border: 1px solid var(--border); background: var(--panel-bg); color: var(--text-dim); border-radius: 999px; padding: 4px 11px; font-size: 13px; cursor: pointer; font-family: inherit; text-decoration: line-through; }
.ru-chip.on { background: color-mix(in srgb, var(--accent-blue) 12%, transparent); border-color: var(--accent-blue); color: var(--accent-fg); text-decoration: none; font-weight: 600; }
.ru-bar-row { display: flex; align-items: center; gap: 10px; padding: 4px 0; font-size: 13px; }
.ru-bar-label { width: 220px; flex-shrink: 0; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ru-bar-track { flex: 1; background: var(--panel-bg-2); border-radius: 6px; height: 12px; overflow: hidden; }
.ru-bar { display: block; height: 100%; background: var(--accent-blue); border-radius: 6px; }
.ru-bar-value { width: 110px; text-align: right; color: var(--text); }
.ru-detail td { background: var(--panel-bg-2); }
.ru-detail-grid { display: grid; grid-template-columns: 1fr 1.6fr; gap: 24px; padding: 6px 0; }
.ru-mini-row { display: flex; justify-content: space-between; gap: 12px; padding: 4px 0; border-bottom: 1px solid var(--border); font-size: 13px; }
.ru-case { cursor: pointer; }
.ru-case:hover { color: var(--accent-fg); }
#ru-table td svg { width: 15px; height: 15px; color: var(--text-dim); }
.fullscreen-footer {
  padding: 16px 28px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end;
  gap: 10px; flex-shrink: 0; background: var(--panel-bg);
}

/* ---- Small centered modal (e.g. fault codes) — dims the current page instead of covering it ---- */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(15, 23, 42, .45); z-index: 1000;
  display: flex; align-items: center; justify-content: center; padding: 24px;
}
.modal-overlay[hidden] { display: none; }
.modal-box {
  background: var(--panel-bg); border-radius: 12px; width: 100%; max-width: 480px;
  max-height: 80vh; display: flex; flex-direction: column; box-shadow: var(--e3);
}
.modal-box-header {
  display: flex; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--border); gap: 10px; flex-shrink: 0;
}
.modal-box-header h3 { font-size: 14px; margin: 0; flex: 1; color: var(--text); font-weight: 600; }
.modal-box-body { flex: 1; overflow-y: auto; padding: 16px 20px; }
.fault-code-item { padding: 10px 0; border-bottom: 1px solid var(--border); font-size: 13px; }
.fault-code-item:last-child { border-bottom: none; }
.fault-code-item .fc-title { color: var(--text); font-weight: 500; }
.fault-code-item .fc-meta { color: var(--text-dim); font-size: 11px; margin-top: 2px; }

/* ---- Acquisitions — deliberately NOT the standard table look, per explicit request: a card
   grid with a dark "spec sheet" photo header, so it reads as a distinct kind of record (money/
   investment tracking) at a glance rather than blending into every other data table. ---- */
.acq-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 18px; }
.acq-card {
  background: var(--panel-bg); border-radius: 14px; overflow: hidden; border: 1px solid var(--border);
  box-shadow: var(--e2); transition: transform var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease);
}
.acq-card:hover { box-shadow: var(--e3); }
.acq-card-photo {
  height: 130px; background: linear-gradient(135deg, #1e293b, #0b1220); display: flex;
  align-items: center; justify-content: center; position: relative;
}
.acq-card-photo img { width: 100%; height: 100%; object-fit: cover; }
.acq-card-photo-placeholder { color: rgba(255,255,255,.3); }
.acq-card-photo-placeholder svg { width: 34px; height: 34px; }
.acq-card-status-badge {
  position: absolute; top: 10px; right: 10px; padding: 3px 10px; border-radius: 20px;
  font-size: 11px; font-weight: 700; }
.acq-card-body { padding: 16px; }
.acq-card-unit { font-size: 20px; font-weight: 800; color: var(--text); letter-spacing: -.4px; line-height: 1.1; }
.acq-card-makemodel {
  display: inline-block; margin-top: 6px; padding: 3px 10px; border-radius: 20px;
  background: color-mix(in srgb, var(--accent-blue) 12%, transparent); color: var(--accent-fg);
  font-size: 11px; font-weight: 700; }
.acq-card-meta { margin-top: 10px; font-size: 12px; color: var(--text-muted); }
.acq-card-financials { margin-top: 14px; display: grid; grid-template-columns: 1fr 1fr; gap: 10px; padding-top: 14px; border-top: 1px dashed var(--border); }
.acq-card-fin-label { font-size: 11px; font-weight: 700; color: var(--text-dim); }
.acq-card-fin-value { font-size: 18px; font-weight: 800; color: #B45309; margin-top: 2px; }
.acq-card-fin-value.positive { color: var(--status-green); }
.acq-card-fin-value.negative { color: var(--status-red); }
html[data-theme="dark"] .acq-card-fin-value { color: #F59E0B; }
/* Purchased Units gets its own gold "ledger" accent on KPI figures, distinct from every other
   page's brand-red accent — a deliberate visual cue that this page is about money in/out. */
#page-acquisitions .kpi-card .kpi-value { color: #B45309; }
html[data-theme="dark"] #page-acquisitions .kpi-card .kpi-value { color: #F59E0B; }

/* ---- Photo gallery + photo pickers (Truck Sales / Purchased Units) ---- */
.gallery-item { border-radius: 8px; overflow: hidden; border: 1px solid var(--border); }
.gallery-item img { width: 100%; height: 160px; object-fit: cover; display: block; }
.gallery-item-actions { display: flex; gap: 6px; padding: 8px; background: var(--panel-bg-2); }
.photo-picker-grid { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }
.photo-picker-thumb { position: relative; width: 72px; height: 72px; border-radius: 8px; overflow: hidden; border: 1px solid var(--border); }
.photo-picker-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo-picker-thumb .photo-picker-remove {
  position: absolute; top: 2px; right: 2px; width: 18px; height: 18px; border-radius: 50%; border: none;
  background: rgba(0,0,0,.6); color: #fff; font-size: 11px; line-height: 1; cursor: pointer; display: flex; align-items: center; justify-content: center;
}
.card-photo-thumb { width: 40px; height: 40px; object-fit: cover; border-radius: 6px; cursor: pointer; }

/* ---- Kanban board (List/Kanban toggle, reused across pages) ---- */
.view-toggle { display: flex; background: var(--panel-bg-2); border-radius: 8px; padding: 3px; gap: 2px; }
.view-toggle button { border: none; background: none; padding: 6px 12px; font-size: 12px; font-weight: 600; border-radius: 6px; cursor: pointer; color: var(--text-muted); font-family: inherit; display: flex; align-items: center; gap: 5px; }
.view-toggle button.active { background: var(--panel-bg); color: var(--accent-fg); box-shadow: var(--shadow); }
.kanban-board { display: flex; gap: 14px; overflow-x: auto; padding-bottom: 8px; align-items: flex-start; }
.kanban-column { flex: 0 0 260px; background: var(--panel-bg-2); border-radius: 12px; padding: 10px; }
.kanban-column-header { font-size: 12px; font-weight: 700; color: var(--text); display: flex; justify-content: space-between; align-items: center; padding: 4px 6px 10px; }
.kanban-count { background: var(--panel-bg); border-radius: 10px; padding: 1px 8px; font-size: 11px; color: var(--text-muted); }
.kanban-column-body { display: flex; flex-direction: column; gap: 8px; min-height: 40px; }
.kanban-card { background: var(--panel-bg); border-radius: 10px; padding: 12px; cursor: pointer; box-shadow: var(--shadow); border: 1px solid var(--border); }
.kanban-card:hover { border-color: var(--accent-blue); }
.kanban-card .kanban-card-title { font-weight: 700; color: var(--text); font-size: 14px; }
.kanban-card .kanban-card-sub { font-size: 12px; color: var(--text-muted); margin-top: 3px; }
.kanban-card .kanban-card-meta { font-size: 11px; color: var(--text-dim); margin-top: 6px; }

.modal-tabs { display: flex; gap: 4px; background: var(--panel-bg-2); padding: 4px; margin: 0 0 20px; border-radius: var(--radius); width: fit-content; }
.modal-tabs button {
  border: none; background: none; padding: 8px 18px; font-size: 13px; border-radius: 8px; cursor: pointer; color: var(--text-muted); font-family: inherit;
}
.modal-tabs button.active { background: var(--panel-bg); font-weight: 600; color: var(--text); box-shadow: var(--shadow); }
.tab-panel[hidden] { display: none; }

.form-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px 22px; }
.form-field { display: flex; flex-direction: column; gap: 6px; }
.form-field.span2 { grid-column: span 2; }
.form-field.span3 { grid-column: span 3; }
.form-field label { font-size: 12px; color: var(--text-muted); font-weight: 700; }
.form-field label .req { color: var(--status-red); }
.form-field input, .form-field select, .form-field textarea {
  padding: 9px 11px; border: 1px solid var(--border); border-radius: 8px; font-size: 14px; font-family: inherit;
  background: var(--panel-bg); color: var(--text);
}
.form-field input:focus, .form-field select:focus, .form-field textarea:focus {
  outline: none; border-color: var(--accent-blue); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent-blue) 15%, transparent);
}
.form-field textarea { resize: vertical; min-height: 70px; }
.form-field input::-webkit-calendar-picker-indicator { opacity: .6; }

/* Item cards inside Invoiced items — each unit/charge is its own card, "+ Add unit" opens a full item editor */
.item-card {
  background: var(--panel-bg); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; margin-bottom: 10px;
  display: flex; align-items: center; gap: 16px; cursor: pointer; box-shadow: var(--shadow);
}
.item-card:hover { border-color: var(--accent-blue); }
.item-card .field { font-size: 12px; color: var(--text-muted); }
.item-card .field b { color: var(--text); font-weight: 600; display: block; font-size: 13px; }
.item-card .spacer { flex: 1; }
.items-total { text-align: right; font-weight: 600; margin-top: 14px; font-size: 14px; color: var(--text); }
/* Compact Invoiced Items sheet — up to ~13 dynamic columns need to fit on one screen without
   horizontal scrolling; tighter padding/font + smaller per-cell min-widths (set inline by
   itemCellInputHtml in app.js) get most invoice types to fit at normal window widths. */
#items-table th { padding: 4px 3px; font-size: 11px; white-space: normal; line-height: 1.25; vertical-align: bottom; word-break: break-word; }
#items-table td { padding: 3px 3px; font-size: 12px; }
#items-table input.select-field, #items-table select.select-field { padding: 3px 4px; font-size: 12px; height: 26px; }

/* ---- Hover tooltip for the hand-rolled SVG charts (Dashboard trend/donut, Task Tracker Reports) ---- */
.chart-tooltip {
  position: fixed; z-index: 10001; background: var(--panel-bg); border: 1px solid var(--border);
  border-radius: 8px; padding: 6px 10px; font-size: 12px; color: var(--text); box-shadow: var(--shadow);
  pointer-events: none; white-space: nowrap;
}
.chart-tooltip[hidden] { display: none; }
svg .chart-hover { filter: brightness(1.15); }

.hint { font-size: 12px; color: var(--text-dim); margin: 8px 0 0; }
.upload-field {
  border: 1px dashed var(--border); border-radius: var(--radius); padding: 14px; display: flex; align-items: center; gap: 10px;
  background: var(--panel-bg-2);
}
.upload-field .filename { font-size: 13px; color: var(--text-muted); }

/* ---- Tags: two families ----
   1) status pills (Monday-bold, solid tint, fixed 4-color semantic meaning: green/yellow/red/gray) —
      used wherever a value genuinely means a status: Task status/priority, Vendor invoice status, SLA.
   2) categorical labels (soft translucent, rotating palette) — used for descriptive-but-non-status
      values like Task type / Shift, where there's no "good/bad" meaning, just identity. */
.status-pill { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 6px; font-size: 11px; font-weight: 700; white-space: nowrap; margin-right: 4px; }
.status-pill .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex-shrink: 0; }

.tag { display: inline-block; padding: 3px 9px; border-radius: 4px; font-size: 11px; font-weight: 600; margin-right: 4px; white-space: nowrap; }

/* ---- Task Tracker cards ---- */
.task-card {
  background: var(--panel-bg); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; margin-bottom: 10px; cursor: pointer; box-shadow: var(--shadow);
}
.task-card:hover { border-color: var(--accent-blue); }
.task-card .task-top { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.task-card .task-unit { font-weight: 700; color: var(--text); font-size: 13px; }
.task-card .task-driver { color: var(--text-muted); font-size: 12px; }
.task-card .task-notes { color: var(--text); font-size: 13px; margin-bottom: 8px; }
.task-card .task-tags { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
.task-card .task-meta { color: var(--text-dim); font-size: 11px; margin-left: auto; white-space: nowrap; }
.task-card .locked-icon { color: var(--text-dim); font-size: 12px; }

.task-tabs { display: flex; gap: 4px; background: var(--panel-bg-2); padding: 4px; margin-bottom: 18px; border-radius: var(--radius); width: fit-content; }
.task-tabs button { border: none; background: none; padding: 8px 18px; font-size: 13px; border-radius: 8px; cursor: pointer; color: var(--text-muted); font-family: inherit; }
.task-tabs button.active { background: var(--panel-bg); font-weight: 600; color: var(--text); box-shadow: var(--shadow); }
.task-tab-panel[hidden] { display: none; }

/* Generic version of the same tab look, for any page with its own sub-sections (P&L, and future
   pages) — same visual language as .task-tabs without coupling to Task Tracker's own JS/markup. */
.subtabs { display: flex; gap: 4px; background: var(--panel-bg-2); padding: 4px; margin-bottom: 18px; border-radius: var(--radius); width: fit-content; flex-wrap: wrap; }
.subtabs button { border: none; background: none; padding: 8px 18px; font-size: 13px; border-radius: 8px; cursor: pointer; color: var(--text-muted); font-family: inherit; white-space: nowrap; }
.subtabs button.active { background: var(--panel-bg); font-weight: 600; color: var(--text); box-shadow: var(--shadow); }
.subtab-panel[hidden] { display: none; }

/* ---- Comments ---- */
.comment-thread { display: flex; flex-direction: column; gap: 14px; }
.comment-item { display: flex; gap: 10px; }
.comment-avatar {
  width: 28px; height: 28px; border-radius: 50%; background: var(--accent-blue); color: var(--on-accent); flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 700;
}
.comment-body { flex: 1; }
.comment-header { display: flex; align-items: baseline; gap: 8px; margin-bottom: 3px; }
.comment-author { font-weight: 600; font-size: 13px; color: var(--text); }
.comment-date { font-size: 11px; color: var(--text-dim); }
.comment-text { font-size: 13px; color: var(--text); white-space: pre-wrap; }
.comment-image { max-width: 260px; border-radius: 8px; margin-top: 8px; display: block; border: 1px solid var(--border); }
.comment-reactions { display: flex; gap: 6px; margin-top: 6px; }
.reaction-pill {
  border: 1px solid var(--border); background: var(--panel-bg-2); border-radius: 10px; padding: 2px 8px; font-size: 12px;
  cursor: pointer; color: var(--text-muted);
}
.reaction-pill.mine { border-color: var(--accent-blue); color: var(--accent-fg); background: color-mix(in srgb, var(--accent-blue) 8%, transparent); }
.reaction-picker { display: flex; gap: 6px; margin-top: 6px; }
.reaction-picker button { border: none; background: none; cursor: pointer; font-size: 14px; opacity: .5; }
.reaction-picker button:hover { opacity: 1; }
.comment-input-row { display: flex; gap: 10px; margin-top: 16px; align-items: flex-start; }
.comment-input-row textarea { flex: 1; min-height: 44px; }

/* ---- Notion-style inline quick-edit (Task Tracker pills) ---- */
.quick-edit-trigger { cursor: pointer; border-radius: 6px; padding: 2px 2px; display: inline-block; }
.quick-edit-trigger:hover { background: var(--panel-bg-2); outline: 1px dashed var(--border); }
/* Excel-style fill handle — a small square docked to the bottom-right corner of a Start-date cell
   that already has a value; grab and drag it down (or up) across other rows to copy that date onto
   all of them in one motion, instead of editing each row on its own. */
.td-fill-handle { position: absolute; right: 2px; bottom: 2px; width: 8px; height: 8px; background: var(--accent-blue); border: 1px solid var(--panel-bg); border-radius: 1px; cursor: crosshair; }
.td-startdate.td-fill-preview { background: color-mix(in srgb, var(--accent-blue) 14%, transparent); outline: 1px dashed var(--accent-blue); outline-offset: -1px; }
.task-quickadd-row td { background: var(--panel-bg-2); }
#quick-edit-popover {
  position: fixed; z-index: 10000; background: var(--panel-bg); border: 1px solid var(--border);
  border-radius: 10px; box-shadow: var(--shadow); padding: 8px; min-width: 160px; max-width: 240px;
  display: flex; flex-direction: column; gap: 4px; max-height: 320px; overflow-y: auto;
}
#quick-edit-popover .qe-option { display: flex; width: 100%; border: none; background: none; padding: 4px; border-radius: 6px; cursor: pointer; text-align: left; }
#quick-edit-popover .qe-option:hover { background: var(--panel-bg-2); }

/* ---- Notion-style emoji picker ---- */
/* ---- "Add" choice menu (Manual entry / Add with Bi AI) — small anchored dropdown ---- */
.add-choice-menu {
  position: fixed; z-index: 10000; min-width: 190px; background: var(--panel-bg); border: 1px solid var(--border);
  border-radius: 10px; box-shadow: var(--shadow); padding: 6px; display: flex; flex-direction: column; gap: 2px;
}
.add-choice-menu[hidden] { display: none; }
.add-choice-menu button {
  display: flex; align-items: center; gap: 8px; border: none; background: none; padding: 8px 10px;
  border-radius: 7px; cursor: pointer; text-align: left; font-size: 13px; color: var(--text); width: 100%;
}
.add-choice-menu button:hover, .add-choice-menu button.dragover { background: var(--panel-bg-2); }
.add-choice-menu button i { width: 15px; height: 15px; color: var(--text-dim); }

/* ---- Upload dropzone — used by the Repairs/Vendor Invoices "Add with Bi AI" upload modals ---- */
.upload-dropzone {
  border: 2px dashed var(--border); border-radius: 10px; padding: 32px 16px; text-align: center;
  cursor: pointer; color: var(--text-muted); transition: border-color var(--dur-fast) var(--ease), background-color var(--dur-fast) var(--ease);
}
.upload-dropzone:hover, .upload-dropzone.dragover { border-color: var(--accent-blue); background: var(--panel-bg-2); }
.upload-dropzone i { width: 30px; height: 30px; margin-bottom: 8px; color: var(--text-dim); }
.upload-dropzone div { font-size: 13px; color: var(--text); margin-bottom: 4px; }

/* ---- Diagnostics "Ask Bi" fault-code explainer — small floating popover, not the full chat panel ---- */
.fault-explain-popover {
  position: fixed; z-index: 10000; width: 320px; max-height: 260px; overflow-y: auto;
  background: var(--panel-bg); border: 1px solid var(--border); border-radius: 10px;
  box-shadow: var(--shadow); padding: 12px 14px; font-size: 13px; line-height: 1.5; color: var(--text);
}
.fault-explain-popover[hidden] { display: none; }

/* ---- Compact multi-select field (Task Tracker's Task type(s) / Assignee(s)) — chips + a small
   "+ Select" trigger instead of a wall of checkboxes ---- */
.multiselect-field { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }

.emoji-picker { position: fixed; z-index: 10000; width: 280px; max-height: 340px; background: var(--panel-bg); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow); display: flex; flex-direction: column; overflow: hidden; }
.emoji-picker-search { border: none; border-bottom: 1px solid var(--border); padding: 10px 12px; font-size: 13px; background: var(--panel-bg); color: var(--text); outline: none; }
.emoji-picker-body { overflow-y: auto; padding: 8px; flex: 1; }
.emoji-picker-cat-label { font-size: 11px; font-weight: 700; color: var(--text-dim); margin: 8px 4px 4px; }
.emoji-picker-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
.emoji-picker-grid button { border: none; background: none; font-size: 20px; padding: 5px 0; border-radius: 6px; cursor: pointer; line-height: 1; }
.emoji-picker-grid button:hover { background: var(--panel-bg-2); }
.emoji-sticker-btn { border: 1px solid var(--border); background: var(--panel-bg-2); border-radius: 8px; padding: 5px 9px; cursor: pointer; font-size: 14px; color: var(--text-muted); }
.emoji-sticker-btn:hover { border-color: var(--accent-blue); color: var(--accent-fg); }

/* ---- BI ai — floating assistant ---- */
#bi-ai-launcher {
  position: fixed; bottom: 22px; right: 22px; z-index: 9000; width: 52px; height: 52px; border-radius: 50%;
  background: var(--accent-blue); color: var(--on-accent); border: none; box-shadow: var(--e2);
  display: flex; align-items: center; justify-content: center; cursor: pointer;
}
#bi-ai-launcher:hover { background: var(--accent-hover); }
/* The floating Bi launcher sits bottom-right — the exact corner every fullscreen editor's footer
   Save button and every modal's action row also lives in. Hide it (and the chat panel, if it was
   left open) while any of those are open instead of letting them visually collide. */
body:has(.fullscreen-view:not([hidden])) #bi-ai-launcher,
body:has(.fullscreen-view:not([hidden])) #bi-ai-panel,
body:has(.modal-overlay:not([hidden])) #bi-ai-launcher,
body:has(.modal-overlay:not([hidden])) #bi-ai-panel {
  display: none;
}
#bi-ai-panel {
  position: fixed; bottom: 86px; right: 22px; z-index: 9000; width: 380px; max-width: calc(100vw - 32px);
  height: 520px; max-height: calc(100vh - 120px); background: var(--panel-bg); border: 1px solid var(--border);
  border-radius: 14px; box-shadow: var(--e3); display: flex; flex-direction: column; overflow: hidden;
}
.bi-ai-header { display: flex; align-items: center; justify-content: space-between; padding: 12px 14px; border-bottom: 1px solid var(--border); background: var(--panel-bg-2); }
.bi-ai-title { font-weight: 700; color: var(--text); font-size: 14px; }
.bi-ai-subtitle { font-size: 11px; color: var(--text-dim); }
.bi-ai-messages { flex: 1; overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.bi-ai-msg { max-width: 88%; padding: 8px 12px; border-radius: 12px; font-size: 13px; line-height: 1.45; white-space: pre-wrap; }
.bi-ai-msg-bot { align-self: flex-start; background: var(--panel-bg-2); color: var(--text); border-bottom-left-radius: 4px; }
.bi-ai-msg-user { align-self: flex-end; background: var(--accent-blue); color: var(--on-accent); border-bottom-right-radius: 4px; }
.bi-ai-msg-thinking { align-self: flex-start; color: var(--text-dim); font-style: italic; }
.bi-ai-input-row { display: flex; gap: 8px; padding: 10px; border-top: 1px solid var(--border); }
.bi-ai-input-row textarea { flex: 1; resize: none; min-height: 38px; max-height: 90px; }

/* ---- @mention autocomplete ---- */
.mention-autocomplete { position: fixed; z-index: 10000; background: var(--panel-bg); border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow); min-width: 180px; max-width: 260px; overflow: hidden; }
.mention-autocomplete button { display: flex; width: 100%; border: none; background: none; padding: 8px 12px; cursor: pointer; text-align: left; font-size: 13px; color: var(--text); }
.mention-autocomplete button:hover, .mention-autocomplete button.active { background: var(--panel-bg-2); }
.mention-chip { color: var(--accent-fg); font-weight: 600; }

/* ---- Settings ---- */
.settings-row { display: flex; align-items: center; justify-content: space-between; padding: 16px 0; border-bottom: 1px solid var(--border); }
.settings-row:last-child { border-bottom: none; }
.settings-row .label { color: var(--text); font-size: 14px; font-weight: 500; }
.settings-row .desc { color: var(--text-muted); font-size: 12px; margin-top: 2px; }
.toggle-switch { position: relative; width: 42px; height: 24px; flex-shrink: 0; }
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.toggle-switch .slider {
  position: absolute; inset: 0; background: var(--border); border-radius: 24px; cursor: pointer; transition: background-color var(--dur-fast) var(--ease), transform var(--dur-fast) var(--ease);
}
.toggle-switch .slider::before {
  content: ""; position: absolute; width: 18px; height: 18px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: background-color var(--dur-fast) var(--ease), transform var(--dur-fast) var(--ease);
}
.toggle-switch input:checked + .slider { background: var(--accent-blue); }
.toggle-switch input:checked + .slider::before { transform: translateX(18px); }

.clocks-row { display: flex; gap: 14px; flex-wrap: wrap; }
.clock-card { background: var(--panel-bg-2); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 20px; min-width: 150px; text-align: center; }
.clock-card .zone-name { font-size: 11px; color: var(--text-muted); margin-bottom: 6px; font-weight: 500; }
.clock-card .zone-time { font-size: 24px; font-weight: 600; color: var(--text); font-variant-numeric: tabular-nums; }
.clock-card .zone-date { font-size: 11px; color: var(--text-dim); margin-top: 4px; }

/* ---- Chart chrome shared by Reports tabs ---- */
.status-track { display: flex; height: 22px; border-radius: 6px; overflow: hidden; background: var(--panel-bg-2); }
.status-seg { height: 100%; }
.legend { display: flex; gap: 16px; margin-top: 10px; font-size: 12px; color: var(--text-muted); flex-wrap: wrap; }
.legend .item { display: flex; align-items: center; gap: 6px; }
.legend .swatch { width: 10px; height: 10px; border-radius: 3px; }
.bar-row { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.bar-row .bar-label { width: 170px; font-size: 12px; color: var(--text-muted); flex-shrink: 0; }
.bar-row .bar-track { flex: 1; position: relative; height: 18px; background: var(--panel-bg-2); border-radius: 4px; }
.bar-row .bar-fill { height: 18px; border-radius: 4px; }
.bar-row .bar-value { width: 90px; font-size: 12px; color: var(--text); text-align: right; flex-shrink: 0; }
.dash-breakdown-toggle {
  display: block; margin-top: 2px; padding: 0; border: none; background: none;
  color: var(--accent-fg); font-size: 12px; font-weight: 600; cursor: pointer; font-family: inherit;
}
.dash-breakdown-toggle:hover { color: var(--accent-blue-hover); text-decoration: underline; }

.viewing-as-select {
  background: var(--panel-bg); border: 1px solid var(--border); color: var(--text); padding: 6px 10px; border-radius: 8px; font-size: 12px; font-family: inherit;
}
.quick-date-btn {
  border: 1px solid var(--border); background: var(--panel-bg-2); color: var(--text-muted); border-radius: 6px;
  padding: 0 10px; font-size: 11px; cursor: pointer; margin-left: 6px; font-family: inherit;
}
.quick-date-btn:hover { color: var(--accent-fg); border-color: var(--accent-blue); }
.date-with-btn { display: flex; align-items: center; }
.date-with-btn input { flex: 1; }

/* ---- Topbar clocks (always visible, no dropdown) + sun/moon theme toggle ---- */
.topbar-clocks { gap: 10px; flex-wrap: nowrap; }
.topbar-clocks .clock-card {
  padding: 4px 10px; min-width: auto; text-align: left; background: none; border: none;
  display: flex; align-items: baseline; gap: 5px;
}
.topbar-clocks .clock-card .zone-name { font-size: 11px; margin-bottom: 0; }
.topbar-clocks .clock-card .zone-time { font-size: 13px; font-weight: 600; }
.theme-toggle-btn {
  width: 34px; height: 34px; border-radius: 50%; border: 1px solid var(--border); background: var(--panel-bg);
  color: var(--text-muted); cursor: pointer; display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.theme-toggle-btn:hover { border-color: var(--accent-blue); color: var(--accent-fg); }
.theme-toggle-btn { font-size: 16px; line-height: 1; }

/* ---- Alerts bell (topbar) ---- */
.alerts-chip { position: relative; }
.alerts-btn {
  width: 34px; height: 34px; border-radius: 50%; border: 1px solid var(--border); background: var(--panel-bg);
  color: var(--text-muted); cursor: pointer; display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; position: relative;
}
.alerts-btn:hover { border-color: var(--accent-blue); color: var(--accent-fg); }
.alerts-btn svg { width: 16px; height: 16px; }
.alerts-badge {
  position: absolute; top: -4px; right: -4px; min-width: 16px; height: 16px; padding: 0 3px;
  border-radius: 8px; background: var(--danger); color: #fff; font-size: 11px; font-weight: 700;
  display: flex; align-items: center; justify-content: center; line-height: 1;
}
.alerts-popover { width: 340px; max-height: 420px; overflow-y: auto; }
.alert-item { display: flex; gap: 8px; align-items: flex-start; padding: 8px 0; border-bottom: 1px solid var(--border); font-size: 13px; }
.alert-item:last-child { border-bottom: none; }
.alert-item i { width: 15px; height: 15px; flex-shrink: 0; margin-top: 1px; }
.alert-item.alert-overdue i, .alert-item.alert-fault i { color: var(--status-red); }
.alert-item.alert-due-soon i { color: var(--status-yellow); }
.alert-item .alert-text { flex: 1; color: var(--text); }
.alert-item .alert-time { font-size: 11px; color: var(--text-dim); white-space: nowrap; }

/* ---- Fleet Units: expandable fault-codes row ---- */
.faults-toggle[data-count]:not([data-count="0"]) { cursor: pointer; }
.fault-detail-row td { background: var(--panel-bg-2); padding: 10px 14px; font-size: 12px; }
.fault-detail-row .fault-code-line { padding: 2px 0; color: var(--text-muted); }

/* ---- Admin-only elements: hidden unless the "Viewing as" user is the admin ---- */
.admin-only[hidden] { display: none !important; }

/* ---- Lucide icon sizing (applies wherever an <i data-lucide> gets replaced with an inline <svg>) ---- */
.sidebar nav button svg { width: 16px; height: 16px; flex-shrink: 0; }
.topbar-btn svg, .btn svg { width: 14px; height: 14px; flex-shrink: 0; margin-right: 6px; vertical-align: -2px; }
.icon-btn svg { width: 16px; height: 16px; }
.kpi-top svg, .panel-header svg { width: 15px; height: 15px; flex-shrink: 0; }
.panel-header { gap: 8px; }
svg.lucide { stroke-width: 2; }

/* ---- KPI cards with trend (Dashboard v2 + module mini-dashboards) ---- */
.kpi-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 16px; margin-bottom: 20px; }
.kpi-card { background: var(--panel-bg); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 20px; box-shadow: var(--shadow); }
.kpi-card .kpi-top { display: flex; align-items: center; gap: 8px; color: var(--text-muted); font-size: 12px; font-weight: 700; margin-bottom: 10px; }
.kpi-card .kpi-value { font-size: 24px; font-weight: 600; color: var(--text); letter-spacing: -.4px; }
.kpi-trend { display: inline-flex; align-items: center; gap: 3px; font-size: 12px; font-weight: 600; margin-top: 6px; }
.kpi-trend svg { width: 13px; height: 13px; margin-right: 0; }
.kpi-trend.up { color: var(--status-green); }
.kpi-trend.down { color: var(--status-red); }
.kpi-trend.flat { color: var(--text-dim); font-weight: 500; }

.donut-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 16px; }
.donut-wrap { display: flex; align-items: center; gap: 20px; }

.empty-state { text-align: center; padding: 26px 10px; color: var(--text-dim); font-size: 13px; }
.empty-state .emoji { font-size: 24px; display: block; margin-bottom: 8px; }

/* ===================== One table style for every page (same as Repair Expenses) =====================
   Compact text, one line per record (long text cut with "…"), and the table uses the full height
   of the screen instead of stopping at 60% with empty space below. Dashboard keeps its own look. */
/* The pane itself is the framed box (border, rounded corners, shadow), so the frame — including the
   BOTTOM edge — is always visible, whether the table scrolls or not, with a gap below it instead of
   running to the very bottom of the screen. The table inside drops its own frame to avoid a double one. */
.table-scroll-pane { max-height: calc(100vh - 250px); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); background: var(--panel-bg); margin-bottom: 20px; }
.table-scroll-pane > table { border: none; border-radius: 0; box-shadow: none; }
.page:not(#page-dashboard) table th { padding: 9px 10px; }
.page:not(#page-dashboard) table td { padding: 7px 10px; font-size: 13px; }
.page:not(#page-dashboard) .table-scroll-pane th,
.page:not(#page-dashboard) .table-scroll-pane td { white-space: nowrap; }
.page:not(#page-dashboard) .table-scroll-pane td { max-width: 300px; overflow: hidden; text-overflow: ellipsis; }

/* Colored labels (statuses, task types, shifts, priorities…): the color lives in the background and
   the dot only — the text itself is the normal theme text color, readable in light and dark mode. */
html .status-pill[class*="status-pill-"] { color: var(--text); }

html .tag[class*="tag-"] { color: var(--text); }

/* ---- Change History page: grouped by day, one readable line per change ---- */
.ch-summary { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; font-size: 13px; color: var(--text-muted); margin-bottom: 6px; }
.ch-sum-chip { display: inline-flex; align-items: center; gap: 5px; background: var(--panel-bg); border: 1px solid var(--border); border-radius: 999px; padding: 3px 10px; color: var(--text); }
.ch-sum-chip svg { width: 13px; height: 13px; color: var(--text-dim); }
.ch-sum-del svg { color: var(--status-red); }
.ch-page-tabs { display: flex; gap: 6px; overflow-x: auto; padding: 4px 2px 10px; margin-bottom: 6px; scrollbar-width: thin; }
.ch-page-tab { flex: 0 0 auto; border: 1px solid var(--border); background: var(--panel-bg); color: var(--text-muted); border-radius: 999px; padding: 6px 12px; font: inherit; font-size: 13px; font-weight: 600; cursor: pointer; white-space: nowrap; }
.ch-page-tab:hover { color: var(--text); }
.ch-page-tab.active { background: var(--accent-blue); border-color: var(--accent-blue); color: var(--on-accent); }
.ch-page-head { font-size: 14px; font-weight: 800; color: var(--text); margin: 22px 0 4px; display: flex; align-items: baseline; gap: 10px; }
.ch-page-count { font-size: 12px; font-weight: 600; color: var(--text-muted); }
.ch-day { font-size: 12px; font-weight: 800; color: var(--text-muted); margin: 18px 0 8px; }
.ch-group { background: var(--panel-bg); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.ch-item { display: flex; align-items: flex-start; gap: 12px; padding: 11px 14px; border-bottom: 1px solid var(--border); }
.ch-item:last-child { border-bottom: none; }
.ch-icon { width: 28px; height: 28px; border-radius: 50%; display: flex; align-items: center; justify-content: center; flex-shrink: 0; background: var(--panel-bg-2); }
.ch-icon svg { width: 14px; height: 14px; }
.ch-create .ch-icon { background: var(--status-green-bg); color: var(--status-green); }
.ch-update .ch-icon { background: var(--status-yellow-bg); color: var(--status-yellow); }
.ch-delete .ch-icon { background: var(--status-red-bg); color: var(--status-red); }
.ch-restore .ch-icon { background: color-mix(in srgb, var(--accent-blue) 12%, transparent); color: var(--accent-fg); }
.ch-main { flex: 1; min-width: 0; }
.ch-line { font-size: 14px; color: var(--text); }
.ch-meta { font-size: 12px; color: var(--text-dim); margin-top: 2px; }
.ch-toggle { border: none; background: none; padding: 0; color: var(--accent-fg); cursor: pointer; font-size: 12px; font-family: inherit; }
.ch-details { margin-top: 8px; padding: 9px 11px; background: var(--panel-bg-2); border-radius: 8px; font-size: 13px; line-height: 1.6; color: var(--text); word-break: break-word; }
.ch-actions .btn { padding: 6px 12px; font-size: 13px; }

/* Repair Costs by Unit — issue-type picker as one tidy dropdown instead of a wall of chips */
.ru-types-btn { display: flex; align-items: center; justify-content: space-between; gap: 8px; width: 100%; text-align: left; cursor: pointer; font-family: inherit; }
.ru-types-btn svg { width: 15px; height: 15px; color: var(--text-dim); }
.ru-types-menu { z-index: 10001; }
.ru-type-row { cursor: pointer; }
.ru-type-row input { margin: 0; }

/* ---- My Truck (private lease-to-own page) ---- */
.mt-hero { background: var(--panel-bg); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px 20px; margin-bottom: 16px; }
.mt-hero-top { display: flex; justify-content: space-between; gap: 20px; flex-wrap: wrap; align-items: flex-start; }
.mt-unit { font-size: 24px; font-weight: 800; color: var(--text); letter-spacing: -.3px; }
.mt-terms { display: flex; flex-wrap: wrap; gap: 6px 18px; font-size: 13px; color: var(--text-muted); max-width: 720px; justify-content: flex-end; }
.mt-terms b { color: var(--text); }
.mt-progress { height: 12px; background: var(--panel-bg-2); border-radius: 999px; overflow: hidden; margin-top: 16px; }
.mt-progress-bar { height: 100%; background: var(--status-green); border-radius: 999px; transition: width var(--dur-slow) var(--ease); }
.mt-progress-label { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; font-size: 13px; color: var(--text-muted); margin-top: 8px; }
.mt-progress-label b { color: var(--text); }
.mt-grid { display: grid; grid-template-columns: 1.4fr 1fr; gap: 16px; }
.mt-grid .panel { margin-bottom: 16px; }
@media (max-width: 1000px) { .mt-grid { grid-template-columns: 1fr; } }
.mt-stat-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 10px; font-size: 14px; color: var(--text); }
.mt-cost-total { margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--border); font-size: 13px; color: var(--text-muted); }
.mt-cost-total b { color: var(--text); }
.mt-week-form, .mt-deal-form { background: var(--panel-bg); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px 18px; margin-bottom: 14px; }
.mt-week-form[hidden], .mt-deal-form[hidden] { display: none; }

.mt-form-group { padding: 12px 0; border-top: 1px solid var(--border); }
.mt-week-totals { margin-top: 10px; padding: 10px 12px; background: var(--panel-bg-2); border-radius: 8px; font-size: 14px; color: var(--text); }

/* Dark mode: every colored label uses the same soft, translucent tint (not deep saturated blocks),
   so Status / Shift / Task type / Priority read calmly and match the rest of the dark UI. */

.comment-toolbar { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-top: 6px; }

/* ---- Page & feature access grid (Settings) ---- */
.access-matrix-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); }
.access-matrix { border: none; box-shadow: none; border-radius: 0; min-width: 100%; }
.access-matrix th, .access-matrix td { padding: 8px 10px; text-align: center; white-space: nowrap; }
.access-matrix .am-person { text-align: left; position: sticky; left: 0; background: var(--panel-bg); z-index: 2; min-width: 170px; }
.access-matrix thead .am-person { background: var(--panel-bg-2); z-index: 4; }
.access-matrix .am-group { font-size: 11px; color: var(--accent-fg); background: color-mix(in srgb, var(--accent-blue) 7%, var(--panel-bg-2)); }
.access-matrix .am-group-feat { color: var(--status-yellow); background: color-mix(in srgb, var(--status-yellow) 8%, var(--panel-bg-2)); }
.access-matrix .am-col { font-size: 11px; font-weight: 700; text-transform: none; letter-spacing: 0; max-width: 92px; white-space: normal; line-height: 1.25; vertical-align: bottom; }
.access-matrix .am-sep { border-left: 2px solid var(--border); }
.access-matrix tbody tr:hover td { background: var(--panel-bg-2); }
.access-matrix .am-cell .toggle-switch { display: inline-block; vertical-align: middle; }

.profile-popover-email { font-size: 12px; color: var(--text-muted); margin-top: 8px; word-break: break-all; }
#btn-profile-account { display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
#btn-profile-account svg { width: 15px; height: 15px; }

#mt-month-table .mt-year-row td { background: var(--panel-bg-2); font-weight: 700; border-top: 2px solid var(--border); }

/* ---- Open Issues Board: comments right under the task row ---- */
.task-inline-comments td { background: var(--panel-bg-2); white-space: normal !important; max-width: none !important; overflow: visible !important; padding: 12px 16px !important; }
.tic-wrap { display: grid; grid-template-columns: minmax(280px, 420px) 1fr; gap: 18px; align-items: start; }
.tic-title { font-size: 13px; font-weight: 700; color: var(--text); margin-bottom: 8px; }
.tic-compose textarea { width: 100%; min-height: 70px; font-family: inherit; font-size: 13px; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--panel-bg); color: var(--text); resize: vertical; }
.tic-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }
.tic-thread { max-height: 300px; overflow-y: auto; }
@media (max-width: 900px) { .tic-wrap { grid-template-columns: 1fr; } }

/* ---- Diagnostics: one card per unit ---- */
.diag-seg { display: inline-flex; background: var(--panel-bg-2); border: 1px solid var(--border); border-radius: var(--radius); padding: 3px; }
.diag-seg button { border: none; background: none; padding: 6px 12px; border-radius: 7px; font-size: 13px; cursor: pointer; color: var(--text-muted); font-family: inherit; }
.diag-seg button.active { background: var(--panel-bg); color: var(--text); font-weight: 600; box-shadow: var(--shadow); }
.diag-summary { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.diag-chip { display: inline-flex; align-items: center; gap: 6px; background: var(--panel-bg); border: 1px solid var(--border); border-radius: 999px; padding: 5px 12px; font-size: 13px; color: var(--text); }
.diag-chip .dot, .diag-badge .dot { width: 8px; height: 8px; border-radius: 50%; }
.diag-sev-stop .dot { background: var(--status-red); }
.diag-sev-warn .dot { background: var(--status-yellow); }
.diag-sev-info .dot { background: var(--status-gray); }
.diag-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(380px, 1fr)); gap: 14px; }
.diag-card { background: var(--panel-bg); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.diag-card-head { display: flex; justify-content: space-between; gap: 12px; padding: 14px 16px; border-bottom: 1px solid var(--border); }
.diag-unit { font-size: 18px; font-weight: 800; color: var(--text); }
.diag-badge { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 700; padding: 4px 10px; border-radius: 999px; color: var(--text); }
.diag-badge.diag-sev-stop { background: var(--status-red-bg); }
.diag-badge.diag-sev-warn { background: var(--status-yellow-bg); }
.diag-badge.diag-sev-info { background: var(--status-gray-bg); }
.diag-codes { padding: 6px 16px 10px; }
.diag-code { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--border); font-size: 13px; color: var(--text); }
.diag-code:last-child { border-bottom: none; }
@media (max-width: 600px) { .diag-grid { grid-template-columns: 1fr; } }
.diag-code .col-menu-link { white-space: nowrap; flex-shrink: 0; }
.diag-more { margin-top: 6px; }

.dp-card { cursor: pointer; transition: border-color var(--dur-fast) var(--ease), transform var(--dur-fast) var(--ease); }
.dp-card:hover { border-color: var(--accent-blue); }
.dp-dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; margin: 0 4px 0 2px; vertical-align: 1px; }
.dp-red { background: var(--status-red); } .dp-yellow { background: var(--status-yellow); }
.dp-row { display: flex; gap: 16px; align-items: stretch; }
.dp-row > .panel { flex: 1; min-width: 0; }
.dp-row > .panel[hidden] { display: none; }
.dp-attention-panel { flex: 2 !important; }
.dp-att { display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; border: none; background: none; padding: 9px 6px; border-bottom: 1px solid var(--border); cursor: default; font-family: inherit; font-size: 13px; color: var(--text); border-radius: 6px; }
.dp-att:last-child { border-bottom: none; }
.dp-att:hover { background: var(--panel-bg-2); }
.dp-att > svg:first-child { width: 16px; height: 16px; flex-shrink: 0; }
.dp-att span { flex: 1; min-width: 0; }
.dp-att-go { width: 14px; height: 14px; color: var(--text-dim); }
.dp-sev-0 > svg:first-child { color: var(--status-red); }
.dp-sev-1 > svg:first-child { color: var(--status-yellow); }
.dp-sev-2 > svg:first-child { color: var(--text-dim); }
.dp-fin-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; }
.dp-fin { padding: 10px 12px; background: var(--panel-bg-2); border-radius: 8px; }
.dp-fin-v { font-size: 20px; margin: 4px 0; color: var(--text); }
.dp-target { font-size: 12px; font-weight: 700; padding: 2px 8px; border-radius: 999px; }
.dp-target.ok { background: var(--status-green-bg); color: var(--text); }
.dp-target.bad { background: var(--status-red-bg); color: var(--text); }
.dp-top-row { cursor: pointer; }
.dp-rank { width: 20px; height: 20px; border-radius: 50%; background: var(--panel-bg-2); display: inline-flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 800; color: var(--text); flex-shrink: 0; }
@media (max-width: 1000px) { .dp-row { flex-direction: column; } }

/* ---- My Truck v2 hero ---- */
.mt-hero2 { display: grid; grid-template-columns: auto 1fr auto; gap: 26px; align-items: center; }
.mt-ring { position: relative; width: 128px; height: 128px; }
.mt-ring-bg { fill: none; stroke: var(--panel-bg-2); stroke-width: 12; }
.mt-ring-fg { fill: none; stroke: var(--status-green); stroke-width: 12; stroke-linecap: round; transition: stroke-dashoffset var(--dur-slow) var(--ease); }
.mt-ring-label { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.mt-ring-label b { font-size: 24px; font-weight: 800; color: var(--text); line-height: 1; }
.mt-ring-label span { font-size: 11px; color: var(--text-muted); margin-top: 3px; }
.mt-hero-stats { display: grid; grid-template-columns: repeat(4, auto); gap: 8px 26px; justify-content: start; }
.mt-hero-stats span, .mt-terms2 span { display: block; font-size: 12px; color: var(--text-muted); }
.mt-hero-stats b { font-size: 18px; color: var(--text); }
.mt-terms2 { display: grid; grid-template-columns: repeat(2, auto); gap: 8px 22px; padding: 12px 16px; background: var(--panel-bg-2); border-radius: 10px; }
.mt-terms2 b { font-size: 14px; color: var(--text); }
@media (max-width: 1100px) { .mt-hero2 { grid-template-columns: auto 1fr; } .mt-terms2 { grid-column: 1 / -1; grid-template-columns: repeat(3, auto); } }
@media (max-width: 640px) { .mt-hero2 { grid-template-columns: 1fr; justify-items: stretch; } .mt-hero2 > :first-child { justify-self: start; } .mt-hero-stats { grid-template-columns: repeat(2, auto); } }

/* ---- Toasts (save errors etc.) ---- */
#toast-box { position: fixed; right: 18px; bottom: 18px; z-index: 20000; display: flex; flex-direction: column; gap: 8px; max-width: 380px; }
.toast { padding: 11px 14px; border-radius: 10px; font-size: 13px; box-shadow: var(--shadow); color: #fff; animation: toast-in .2s ease; }
.toast-error { background: #B91C1C; }
.toast-ok { background: #15803D; }
@keyframes toast-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ---- Phones: the top bar must fit the screen (it was ~850px wide and pushed the whole page sideways).
   Clocks and the date hide, the title shrinks and truncates; the toolbar wraps instead of overflowing. ---- */
@media (max-width: 760px) {
  .topbar { padding: 10px 12px; gap: 8px; min-width: 0; }
  .topbar h1 { font-size: 14px; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
  .topbar .topbar-clocks, .topbar .topbar-date { display: none; }
  .content { padding: 14px 12px; }
  .toolbar { flex-wrap: wrap; }
  .toolbar .search-field { flex-basis: 100%; max-width: none; order: 5; }
  .toolbar-group { flex-wrap: wrap; }
  .toolbar-group .btn { padding: 7px 10px; font-size: 13px; }
  .dp-row, .mt-grid { flex-direction: column; display: flex; }
}
.ch-pager { text-align: center; margin: 16px 0; }

/* ---- Password & recovery codes view ---- */
.pw-grid { display: grid; grid-template-columns: minmax(300px, 420px) 1fr; gap: 18px; align-items: start; }
@media (max-width: 900px) { .pw-grid { grid-template-columns: 1fr; } }
.pw-card .form-field { margin-bottom: 10px; }
.pw-checks { list-style: none; padding: 0; margin: 4px 0 10px; font-size: 13px; color: var(--text-muted); }
.pw-checks li { padding: 2px 0; }
.pw-checks li.ok { color: var(--status-green); }
.pw-person { border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; margin-bottom: 8px; }
.pw-person-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.pw-person-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.pw-person-actions .btn { display: inline-flex; align-items: center; gap: 5px; padding: 6px 10px; font-size: 13px; }
.pw-person-actions .btn svg { width: 14px; height: 14px; }
.pw-person-body { margin-top: 10px; }
.pw-inline { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.pw-inline .password-wrap { flex: 1; min-width: 220px; }
.pw-code { display: flex; align-items: center; gap: 10px; }
.pw-code span { font-family: ui-monospace, Menlo, monospace; font-size: 18px; font-weight: 700; letter-spacing: 1px; padding: 8px 12px; background: var(--panel-bg-2); border-radius: 8px; color: var(--text); }

/* ---- Toll Payments ---- */
.toll-form-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; margin-bottom: 16px; }
@media (max-width: 900px) { .toll-form-grid { grid-template-columns: 1fr; } }
.toll-match { margin-top: 12px; padding: 10px 12px; border-radius: 8px; background: var(--surface-2, rgba(127,127,127,.08)); font-size: 13px; }
.toll-warn { margin-top: 10px; padding: 10px 12px; border-radius: 8px; border: 1px solid var(--status-yellow); font-size: 13px; line-height: 1.5; }
.toll-dup { color: var(--status-yellow); font-weight: 700; cursor: help; }
.toll-files { display: flex; flex-wrap: wrap; gap: 6px; }
.toll-file { display: inline-flex; align-items: center; gap: 4px; padding: 3px 8px; border: 1px solid var(--border); border-radius: 6px; font-size: 12px; }
.toll-file button { border: 0; background: none; color: var(--accent-red); cursor: pointer; font-size: 14px; line-height: 1; }
.toll-lines { width: 100%; border-collapse: collapse; }
.toll-lines th, .toll-lines td { padding: 6px 10px; text-align: left; border-bottom: 1px solid var(--border); }
.toll-lines input { width: 100%; min-width: 0; }
.toll-by-state { display: flex; flex-wrap: wrap; gap: 6px; }
.toll-state-chip { border: 1px solid var(--border); background: var(--panel-bg); color: var(--text); border-radius: 8px; padding: 6px 10px; font-size: 12px; cursor: pointer; }
.toll-state-chip:hover, .toll-state-chip.active { border-color: var(--text); }
.toll-state-chip.active { background: var(--status-gray-bg); }
.toll-ro { padding: 8px 0; font-size: 13px; font-weight: 600; }
@media (max-width: 700px) {
  #toll-view .fullscreen-header, #toll-plates-view .fullscreen-header, #toll-settings-view .fullscreen-header { flex-wrap: wrap; padding: 12px 16px; }
  #toll-view .fullscreen-header h2 { flex-basis: 100%; }
  #toll-view .fullscreen-body, #toll-plates-view .fullscreen-body, #toll-settings-view .fullscreen-body { padding: 16px; }
  #toll-view .fullscreen-footer { padding: 12px 16px !important; }
  .toll-lines th, .toll-lines td { padding: 6px 4px; }
}
.toll-settings-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; align-items: start; }
.toll-set-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 5px 0; border-bottom: 1px solid var(--border); font-size: 13px; }
.toll-form-grid .req, .toll-lines .req, #toll-plates-body .req { color: var(--accent-red); font-weight: 700; }
.pl-two-col { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 24px; }
@media (max-width: 700px) { .pl-two-col { grid-template-columns: minmax(0, 1fr); } }

/* ---- QA pass 2026-10-14: layout fixes ---- */
/* A fullscreen form that the browser scrolled to an invalid field must not shift up out of reach. */
.fullscreen-view { overflow: clip; }
.upload-field { flex-wrap: wrap; min-width: 0; }
.upload-field input[type="file"] { min-width: 0; max-width: 100%; }
@media (max-width: 900px) {
  .form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .form-field.span3 { grid-column: span 2; }
}
@media (max-width: 600px) {
  .form-grid { grid-template-columns: minmax(0, 1fr); }
  .form-field.span2, .form-field.span3 { grid-column: span 1; }
}
.toolbar { flex-wrap: wrap; }
.toolbar .search-field { min-width: 180px; flex: 1 1 300px; }
.chart-grid-wide, .chart-grid-even { display: grid; gap: 16px; }
.chart-grid-wide { grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); }
.chart-grid-even { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
@media (max-width: 800px) { .chart-grid-wide, .chart-grid-even { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 600px) {
  .alerts-popover { position: fixed !important; left: 8px !important; right: 8px !important; top: 60px !important; width: auto !important; max-width: none; }
}
.task-view-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 380px); gap: 24px; align-items: start; }
@media (max-width: 1100px) { .task-view-grid { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 900px) { .toll-form-grid { grid-template-columns: minmax(0, 1fr) !important; } }
#manage-columns-modal { z-index: 1100; } /* opened from full-screen windows (Toll settings) — must sit on top */
/* Medium screens (laptops ~1024px): the 4 clocks + date pushed the bells/avatar off-screen. */
@media (max-width: 1200px) { .topbar .topbar-date { display: none; } }
@media (max-width: 1100px) { .topbar .topbar-clocks { display: none; } }
.pm-kpi-howto { margin-top: 12px; padding: 10px 12px; border-radius: 8px; background: var(--panel-bg-2); font-size: 13px; color: var(--text-muted); line-height: 1.55; }
.pm-report-two { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 20px; }
@media (max-width: 900px) { .pm-report-two { grid-template-columns: minmax(0, 1fr); } }

/* ---- QA pass 2026-10-16 (screenshots) ---- */
/* Empty-state rows inside wide, sideways-scrolling tables stay in view instead of being centred off-screen. */
td > .empty-state { position: sticky; left: 0; max-width: calc(100vw - 48px); }
/* KPI card titles with an extra note ("(Sep 2026) / target …") wrap instead of squeezing into columns. */
.kpi-top { flex-wrap: wrap; }
/* Full-screen window titles: icon and text on one line. */
.fullscreen-header h2 { display: flex; align-items: center; gap: 6px; min-width: 0; }
/* Tables scrolling sideways get a soft edge shadow, so it's clear there is more to the right. */
.table-scroll-pane, div[style*="overflow-x:auto"] {
  background:
    linear-gradient(to right, var(--panel-bg) 30%, transparent) left / 24px 100% no-repeat local,
    linear-gradient(to left, var(--panel-bg) 30%, transparent) right / 24px 100% no-repeat local,
    radial-gradient(farthest-side at 0 50%, rgba(0,0,0,.14), transparent) left / 10px 100% no-repeat scroll,
    radial-gradient(farthest-side at 100% 50%, rgba(0,0,0,.14), transparent) right / 10px 100% no-repeat scroll;
  background-color: var(--panel-bg);
}
.pl-reports-gap, #page-pl div[style*="overflow-x:auto"] { margin-bottom: 16px; }
.task-tabs button, .subtabs button { white-space: nowrap; }
@media (max-width: 760px) {
  /* Sub-tab strips: one sideways-scrolling row instead of 5 wrapped rows. */
  .subtabs, .task-tabs { flex-wrap: nowrap; overflow-x: auto; width: 100%; scrollbar-width: none; }
  .subtabs::-webkit-scrollbar, .task-tabs::-webkit-scrollbar { display: none; }
  .task-tabs button { padding: 8px 12px; }
  /* Bi button smaller and the page leaves room for it, so it never covers the last row / buttons. */
  #bi-ai-launcher { width: 44px !important; height: 44px !important; right: 14px !important; bottom: 14px !important; }
  .content, main { padding-bottom: 76px; }
  /* Page title gets the room: the Sync button hides on phones (pull-to-refresh / Sync in the profile menu are enough). */
  .topbar #btn-sync { display: none; }
  .topbar h1 { font-size: 14px; }
  /* Two KPI cards per row on phones. */
  .kpi-row { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .kpi-card { padding: 12px 14px; }
  .kpi-value { font-size: 20px; }
  /* Filters panels: the filter fields first, the summary numbers after them. */
  .filters-panel-v2 { display: flex; flex-direction: column; padding: 14px; }
  .filters-panel-v2 > .filters-results { order: 2; margin-top: 14px; }
  /* PM interval rules wrap onto two lines. */
  .pm-rule-row { flex-wrap: wrap; row-gap: 6px; }
  .pm-rule-row input[data-field="label"] { width: 100% !important; }
  .settings-row { flex-direction: column; align-items: flex-start; gap: 8px; }
}
#fleet-table td { white-space: nowrap; }
#fleet-table td:nth-child(n+8) { max-width: 260px; overflow: hidden; text-overflow: ellipsis; }
#pm-view-toggle { width: fit-content; }
.diag-badge { white-space: nowrap; }
.settings-row { gap: 12px; }
.settings-row > :last-child { flex-shrink: 0; }
.settings-row .pill, .settings-row .btn { white-space: nowrap; }
.kpi-value .hint, .dp-card .hint span { white-space: nowrap; }
/* Dashboard top cards: 4 in a row on wide screens, 2×2 on laptops (no lonely 4th card). */
@media (min-width: 1101px) { #dash-kpi-row { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
@media (max-width: 1100px) and (min-width: 761px) { #dash-kpi-row { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
/* Phones: the hero picture without its truck looked like a failed image — hide it there. */

/* Short laptop screens: tighter sidebar so the last item isn't cut off. */
@media (max-height: 800px) { .sidebar .section-label { padding-top: 10px; } .sidebar nav button { padding-top: 6px; padding-bottom: 6px; } }
/* Wide P&L / Fleet tables: dates, money and week labels stay on one line. */
#page-pl table td, #page-pl table th, #fleet-table th { white-space: nowrap; }
/* Open Issues Board: task-type pills wrap inside their cell instead of being cut off. */
#page-tasks td .quick-edit-trigger { display: inline-flex; flex-wrap: wrap; gap: 4px; white-space: normal; }
/* P&L sub-tabs fit on one line at 1440. */
.subtabs button { padding-left: 12px; padding-right: 12px; }

/* ---- Notion-style comments panel (Open Issues Board 💬) ---- */
.tic-pop { position: fixed; z-index: 1200; background: var(--panel-bg); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--e3); display: flex; flex-direction: column; overflow: hidden; }
.tic-pop[hidden] { display: none; }
.tic-pop-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 10px 12px 10px 16px; border-bottom: 1px solid var(--border); }
.tic-pop-title { font-size: 13px; font-weight: 700; color: var(--text); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tic-pop-thread { flex: 1; overflow-y: auto; padding: 14px 16px; gap: 16px; min-height: 120px; }
.tic-pop-compose { border-top: 1px solid var(--border); padding: 10px 12px; }
.tic-pop-inputrow { display: flex; align-items: flex-end; gap: 8px; }
.tic-pop-inputrow textarea { flex: 1; resize: none; min-height: 36px; max-height: 140px; padding: 8px 10px; border: 1px solid var(--border); border-radius: 10px; background: var(--panel-bg-2); color: var(--text); font: inherit; font-size: 13px; line-height: 1.4; }
.tic-pop-inputrow textarea:focus { outline: none; border-color: var(--accent-blue); background: var(--panel-bg); }
.tic-send { width: 32px; height: 32px; border-radius: 50%; border: none; background: var(--accent-blue); color: var(--on-accent); cursor: pointer; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.tic-send svg { width: 16px; height: 16px; margin: 0; }
#tic-preview .photo-picker-thumb { margin-bottom: 8px; }
.comment-tag { font-size: 11px; color: var(--text-dim); margin: -2px 0 4px; }
.tic-pop .comment-image { max-width: 100%; }
/* Dashboard report cards: clicking the card does nothing; the small "Open →" button goes to the page. */
.dp-card { cursor: default; }
.dp-card:hover { transform: none; }
.dp-open { margin-left: auto; display: inline-flex; align-items: center; gap: 3px; border: 1px solid var(--border); background: var(--panel-bg); color: var(--text-muted); border-radius: 999px; padding: 2px 9px; font: inherit; font-size: 12px; font-weight: 600; cursor: pointer; }
.dp-open:hover { color: var(--accent-fg); border-color: var(--accent-blue); }
.dp-open svg { width: 12px !important; height: 12px !important; margin: 0 !important; }
.dp-top-row { cursor: default; }
/* Notes column: long text ends with "…" and the 💬 comments button always stays visible next to it. */
#page-tasks .table-scroll-pane td.td-notes { min-width: 260px; max-width: 460px; white-space: normal; }
/* The whole note is shown (wrapped onto several lines) — nothing is cut off, nothing needs opening. */
#page-tasks .table-scroll-pane td.td-notes > .quick-edit-trigger, #page-tasks .table-scroll-pane td.td-notes > .td-notes-text { display: inline; white-space: normal; overflow-wrap: anywhere; line-height: 1.4; }
#page-tasks .table-scroll-pane td.td-move { padding-left: 4px; padding-right: 4px; }
#page-tasks td.td-move .icon-btn { padding: 2px 4px; }
#page-tasks td.td-notes .quick-comment-btn { vertical-align: middle; }
/* Comments: reaction "+" and delete appear on hover only (like Notion), so the thread stays clean. */
.comment-item .emoji-sticker-btn, .comment-item [data-delete-comment] { opacity: 0; transition: opacity var(--dur-fast) var(--ease); }
.comment-item:hover .emoji-sticker-btn, .comment-item:hover [data-delete-comment], .comment-item:focus-within .emoji-sticker-btn { opacity: 1; }
.tic-pop .comment-item [data-delete-comment] { padding: 2px 5px !important; }
.tic-pop .comment-reactions:empty { display: none; }
.tic-pop .emoji-sticker-btn { margin-top: 2px; padding: 1px 6px; font-size: 11px; }
@media (hover: none) { .comment-item .emoji-sticker-btn, .comment-item [data-delete-comment] { opacity: 1; } }

/* ===================== Animated background ("glow") — per-person choice in Settings → Appearance =====================
   Colours come from js/glow.js as CSS variables (--glow-base, --glow-1..3) for the chosen palette and
   the current light/dark theme. Three soft blobs drift slowly along the edges. Only `transform` is
   animated (GPU, no layout/paint of the page) and panels are just semi-transparent — no backdrop blur —
   so the moving background never slows the tables or typing. Off for "reduce motion". */
#bg-glow { display: none; }
html[data-glow] #bg-glow { display: block; position: fixed; inset: 0; z-index: 0; pointer-events: none; overflow: hidden; background: var(--glow-base); }
html[data-glow] body { background: var(--glow-base); }
html[data-glow] .app-shell { position: relative; z-index: 1; }
#bg-glow i { position: absolute; display: block; border-radius: 50%; will-change: transform; }
/* b1 falls from the top to the bottom, b2 rises from the bottom to the top (and back, smoothly),
   b3 drifts sideways through the middle, b4 travels up and down along the left edge / sidebar. */
#bg-glow .b1 { width: 58vmax; height: 58vmax; left: 38%; top: -45vmax; background: radial-gradient(circle, var(--glow-1) 0%, transparent 62%); animation: glowFall 46s ease-in-out infinite alternate; }
#bg-glow .b2 { width: 50vmax; height: 50vmax; left: 6%; bottom: -40vmax; background: radial-gradient(circle, var(--glow-2) 0%, transparent 62%); animation: glowRise 54s ease-in-out infinite alternate; }
#bg-glow .b3 { width: 44vmax; height: 44vmax; left: 62%; top: 30%; background: radial-gradient(circle, var(--glow-3) 0%, transparent 62%); animation: glowSide 70s ease-in-out infinite alternate; }
#bg-glow .b4 { width: 30vmax; height: 30vmax; left: -12vmax; top: 10%; background: radial-gradient(circle, var(--glow-1) 0%, transparent 62%); opacity: .85; animation: glowEdge 38s ease-in-out infinite alternate; }
@keyframes glowFall { 0% { transform: translate(0, 0) scale(1); } 50% { transform: translate(-12vw, 60vh) scale(1.08); } 100% { transform: translate(8vw, calc(100vh + 30vmax)) scale(.95); } }
@keyframes glowRise { 0% { transform: translate(0, 0) scale(1); } 50% { transform: translate(18vw, -60vh) scale(1.06); } 100% { transform: translate(4vw, calc(-100vh - 26vmax)) scale(.94); } }
@keyframes glowSide { 0% { transform: translate(0, 0) scale(1); } 50% { transform: translate(-40vw, 14vh) scale(1.1); } 100% { transform: translate(-62vw, -20vh) scale(.92); } }
@keyframes glowEdge { 0% { transform: translate(0, -20vh); } 50% { transform: translate(3vw, 45vh); } 100% { transform: translate(0, 85vh); } }
html:not([data-motion="full"]) #bg-glow i { animation: none !important; }
/* Glass: everything that sat on the plain background becomes semi-transparent so the colour shows through. */
html[data-glow] .sidebar, html[data-glow] .topbar { background: color-mix(in srgb, var(--panel-bg) 38%, transparent); border-color: color-mix(in srgb, var(--border) 60%, transparent); }
html[data-glow] .panel, html[data-glow] .kpi-card, html[data-glow] .filters-panel, html[data-glow] .subtabs, html[data-glow] .task-tabs, html[data-glow] .summary-card, html[data-glow] .card {
  background-color: color-mix(in srgb, var(--panel-bg) 58%, transparent); border-color: color-mix(in srgb, var(--panel-bg) 70%, transparent); box-shadow: var(--e3);
}
/* Tables stay easy to read: a denser surface under rows. */
html[data-glow] .table-scroll-pane { background-color: color-mix(in srgb, var(--panel-bg) 84%, transparent); }
html[data-glow] .table-scroll-pane thead th, html[data-glow] table thead th { background: color-mix(in srgb, var(--panel-bg-2) 92%, transparent); }
html[data-glow] .subtabs button.active, html[data-glow] .task-tabs button.active { background: var(--panel-bg); }
/* Settings → Appearance swatches */
.glow-swatches { display: flex; flex-wrap: wrap; gap: 10px; }
.glow-swatch { width: 74px; border: 2px solid transparent; border-radius: 12px; padding: 4px; background: none; cursor: pointer; text-align: center; font: inherit; font-size: 12px; color: var(--text-muted); }
.glow-swatch .sw { display: block; height: 42px; border-radius: 9px; border: 1px solid var(--border); margin-bottom: 4px; }
.glow-swatch.active { border-color: var(--accent-blue); color: var(--text); font-weight: 700; }
.glow-swatch:hover { border-color: color-mix(in srgb, var(--accent-blue) 45%, transparent); }

/* ---- Dashboard: Celebrations ---- */
.dp-celebrations-panel .panel-body { max-height: 330px; overflow-y: auto; padding-top: 6px; }
.cel-sec { font-size: 11px; font-weight: 800; color: var(--text-muted); margin: 12px 0 4px; }
.cel-row { display: flex; align-items: center; gap: 12px; padding: 9px 0; border-bottom: 1px solid var(--border); }
.cel-row:last-child { border-bottom: none; }
.cel-when { width: 74px; flex-shrink: 0; font-size: 13px; font-weight: 600; color: var(--text-muted); }
.cel-when.today { color: var(--cat-pink); }
.cel-when.new { color: var(--status-green); }
.cel-who { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.cel-who b { font-size: 14px; color: var(--text); font-weight: 600; }
.cel-who span { font-size: 12px; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cel-congrats { border: none; border-radius: 999px; background: #FCE7F3; color: #BE185D; font: inherit; font-size: 13px; font-weight: 600; padding: 6px 12px; cursor: pointer; white-space: nowrap; }
.cel-congrats:disabled { opacity: .7; cursor: default; }
html[data-theme="dark"] .cel-congrats { background: rgba(219, 39, 119, .18); color: #F9A8D4; }
.ec-info-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
@media (max-width: 600px) { .ec-info-grid { grid-template-columns: minmax(0, 1fr); } }

/* Dark theme: glass a bit clearer so the colour shows through the cards too. */
html[data-glow][data-theme="dark"] .panel, html[data-glow][data-theme="dark"] .kpi-card, html[data-glow][data-theme="dark"] .filters-panel,
html[data-glow][data-theme="dark"] .subtabs, html[data-glow][data-theme="dark"] .task-tabs { background-color: color-mix(in srgb, var(--panel-bg) 46%, transparent); border-color: rgba(255,255,255,.07); }
html[data-glow][data-theme="dark"] .sidebar, html[data-glow][data-theme="dark"] .topbar { background: color-mix(in srgb, var(--panel-bg) 30%, transparent); }
#employee-card-modal, #add-account-modal { z-index: 1100; } /* opened from the Users window (full screen) */
/* Appearance window: transparent, the page behind it is hidden, so the moving background itself is the
   preview — click a colour and see it right away without closing the window. */
#appearance-view { background: transparent; }
html.appearance-open .app-shell { visibility: hidden; }
html.appearance-open:not([data-glow]) body { background: var(--bg); }
#appearance-view .fullscreen-header { background: color-mix(in srgb, var(--panel-bg) 55%, transparent); }
#appearance-view .panel { max-width: 1000px; }
.appearance-theme { display: flex; align-items: center; gap: 8px; margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--border); }
.appearance-theme span { font-size: 13px; font-weight: 600; color: var(--text); margin-right: 6px; }

/* ---- "Liquid glass" shapes: glossy iridescent blobs with irregular corners, shine and a soft shadow.
   The shape and colours are painted once (blur is static); only transform (move / turn / scale) is
   animated, so it costs the page nothing while it moves. ---- */
#bg-glow .lq { display: none; }
html[data-glow-style="liquid"] #bg-glow .b1, html[data-glow-style="liquid"] #bg-glow .b2, html[data-glow-style="liquid"] #bg-glow .b3 { display: none; }
html[data-glow-style="liquid"] #bg-glow .lq { display: block; }
#bg-glow .lq {
  border-radius: 43% 57% 62% 38% / 46% 38% 62% 54%;
  /* glossy highlight (top-left) + shadowed underside + smooth iridescent body that turns as it moves */
  background:
    radial-gradient(30% 24% at 30% 24%, rgba(255,255,255,.98), rgba(255,255,255,0) 72%),
    radial-gradient(22% 16% at 64% 30%, rgba(255,255,255,.55), rgba(255,255,255,0) 75%),
    radial-gradient(70% 55% at 66% 84%, rgba(30,20,60,.30), rgba(30,20,60,0) 72%),
    conic-gradient(from 200deg at 46% 52%, var(--glow-1) 0%, var(--glow-1) 14%, rgba(255,255,255,.92) 28%, var(--glow-3) 42%, var(--glow-2) 62%, var(--glow-3) 78%, var(--glow-1) 92%, var(--glow-1) 100%);
  box-shadow: inset 30px 36px 70px rgba(255,255,255,.65), inset -40px -46px 80px rgba(40,25,80,.28), 0 60px 110px rgba(40,30,80,.20);
  filter: blur(7px) saturate(1.12);
  opacity: .95;
}
#bg-glow .lq1 { width: 40vmax; height: 34vmax; left: 46%; top: -38vmax; animation: lqFall 52s ease-in-out infinite alternate; }
#bg-glow .lq2 { width: 30vmax; height: 36vmax; left: 8%; bottom: -36vmax; border-radius: 58% 42% 37% 63% / 52% 61% 39% 48%; animation: lqRise 60s ease-in-out infinite alternate; }
#bg-glow .lq3 { width: 22vmax; height: 19vmax; left: 70%; top: 58%; border-radius: 61% 39% 48% 52% / 38% 56% 44% 62%; opacity: .8; animation: lqSide 44s ease-in-out infinite alternate; }
@keyframes lqFall { 0% { transform: translate(0, 0) rotate(0deg) scale(1); } 50% { transform: translate(-14vw, 62vh) rotate(110deg) scale(1.08); } 100% { transform: translate(6vw, calc(100vh + 34vmax)) rotate(220deg) scale(.94); } }
@keyframes lqRise { 0% { transform: translate(0, 0) rotate(0deg) scale(1); } 50% { transform: translate(20vw, -58vh) rotate(-120deg) scale(1.06); } 100% { transform: translate(6vw, calc(-100vh - 36vmax)) rotate(-230deg) scale(.95); } }
@keyframes lqSide { 0% { transform: translate(0, 0) rotate(0deg); } 50% { transform: translate(-38vw, -16vh) rotate(160deg); } 100% { transform: translate(-60vw, -40vh) rotate(300deg); } }
html[data-theme="dark"] #bg-glow .lq { opacity: .7; box-shadow: inset 20px 26px 50px rgba(255,255,255,.18), inset -30px -36px 70px rgba(0,0,0,.45), 0 50px 90px rgba(0,0,0,.4); }
html:not([data-motion="full"]) #bg-glow .lq { animation: none !important; }
.appearance-theme button.active { border-color: var(--accent-blue); color: var(--accent-fg); font-weight: 700; }

/* ---- Full-screen windows (Users, Page & feature access, Costs by unit, forms…) keep the background
   colour too: the page behind is hidden while one is open and the window itself is lightly tinted. ---- */
html[data-glow] body:has(.fullscreen-view:not([hidden])) .app-shell { visibility: hidden; }
/* the windows live inside .app-shell — an open one must stay visible (otherwise every "+" showed an empty screen) */
html[data-glow] .fullscreen-view:not([hidden]) { visibility: visible; }
html[data-glow] .fullscreen-view { background: color-mix(in srgb, var(--bg) 40%, transparent); }
html[data-glow] .fullscreen-header { background: color-mix(in srgb, var(--panel-bg) 55%, transparent); border-color: color-mix(in srgb, var(--border) 60%, transparent); }
html[data-glow] .fullscreen-footer { background: color-mix(in srgb, var(--panel-bg) 70%, transparent) !important; }

/* ---- Birthday greeting card + confetti ---- */
.bday-overlay { z-index: 3000; }
.bday-card { background: var(--panel-bg); border-radius: 18px; padding: 30px 32px 24px; max-width: 440px; width: calc(100% - 32px); text-align: center; box-shadow: var(--e3); animation: bdayPop .35s ease-out; }
.bday-card h2 { margin: 6px 0 8px; font-size: 20px; color: var(--text); }
.bday-card p { margin: 0 0 14px; color: var(--text-muted); font-size: 14px; line-height: 1.5; }
.bday-emoji { font-size: 54px; line-height: 1; }
.bday-people { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-bottom: 8px; }
.bday-actions { margin-top: 8px; }
@keyframes bdayPop { from { transform: scale(.9); opacity: 0; } to { transform: none; opacity: 1; } }
.bday-confetti { position: fixed; inset: 0; pointer-events: none; z-index: 3001; overflow: hidden; }
.bday-confetti span { position: absolute; top: -40px; animation-name: bdayFall; animation-timing-function: linear; animation-fill-mode: forwards; }
@keyframes bdayFall { to { transform: translateY(110vh) rotate(540deg); } }
/* ---- "New version" banner (all users) ---- */
#update-banner { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); z-index: 9999; max-width: calc(100% - 32px);
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap; justify-content: center;
  background: var(--danger); color: var(--on-accent); border-radius: 12px; padding: 10px 14px 10px 18px; font-size: 14px; font-weight: 600; box-shadow: var(--e3); }
#update-banner[hidden] { display: none; }
#update-banner button { border: none; border-radius: 8px; padding: 6px 14px; font: inherit; font-size: 13px; font-weight: 700; cursor: pointer; }
#update-banner-reload { background: #fff; color: #b91c1c; }
/* Open Issues Board — drag a case by its grip to any place in the list (Notion-style). */
#page-tasks .table-scroll-pane td.td-move { width: 26px; padding: 0 2px; text-align: center; }
#page-tasks .task-grip { display: inline-block; cursor: grab; color: var(--text-dim); font-size: 14px; letter-spacing: -2px; line-height: 1; padding: 6px 2px; user-select: none; opacity: .55; }
#page-tasks tr[data-id]:hover .task-grip { opacity: 1; }
#page-tasks .task-grip:active { cursor: grabbing; }
#page-tasks tr.task-dragging { opacity: .45; }
#page-tasks tr.drop-above > td { box-shadow: inset 0 3px 0 var(--accent-blue); }
#page-tasks tr.drop-below > td { box-shadow: inset 0 -3px 0 var(--accent-blue); }

/* ---- Open Issues Board layout: tabs and tools share one top row; the table takes the rest of the screen ---- */
.task-topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.task-topbar .task-tabs { margin-bottom: 0; }
.task-topbar-tools { display: flex; align-items: center; gap: 10px; margin-left: auto; }
.task-tools { display: flex; align-items: center; gap: 8px; }
.task-tools[hidden] { display: none; }
#page-tasks .table-scroll-pane { max-height: calc(100vh - 150px); }
#page-tasks .table-scroll-pane th, #page-tasks .table-scroll-pane td { padding: 6px 9px; font-size: 13px; line-height: 1.35; }
#page-tasks .table-scroll-pane th { padding-top: 8px; padding-bottom: 8px; }
#page-tasks .table-scroll-pane td .quick-edit-trigger { font-size: 13px; }
#page-tasks .table-scroll-pane td.td-notes { min-width: 280px; }
/* compact the four numbers above the board so more cases fit on screen */
#tasks-kpi-row { gap: 10px; margin-bottom: 10px; }
#tasks-kpi-row .kpi-card { padding: 8px 14px; min-height: 0; }
#tasks-kpi-row .kpi-top { margin-bottom: 2px; font-size: 12px; }
#tasks-kpi-row .kpi-value { font-size: 20px; line-height: 1.1; }
#tasks-kpi-row .hint { display: none; }
/* names and assignees stay on one line (full name on hover) so rows stay short and more cases fit */
#page-tasks .table-scroll-pane td.td-name, #page-tasks .table-scroll-pane td.td-assignee { max-width: 140px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#page-tasks .table-scroll-pane td.td-assignee { max-width: 130px; }
#page-tasks .table-scroll-pane td.td-tasktype { max-width: 150px; white-space: normal; }
#page-tasks .table-scroll-pane td.td-tasktype .quick-edit-trigger { display: inline-flex; flex-wrap: wrap; gap: 3px; }
#page-tasks .table-scroll-pane th:first-child, #page-tasks .table-scroll-pane td.row-link-icon { width: 30px; padding-left: 8px; padding-right: 4px; }
#page-tasks .table-scroll-pane td.td-move { width: 34px; }
#page-tasks .table-scroll-pane td.td-notes { min-width: 260px; }
#page-tasks .table-scroll-pane td.td-name > .quick-edit-trigger, #page-tasks .table-scroll-pane td.td-assignee > .quick-edit-trigger { display: inline-block; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; vertical-align: middle; }
#page-tasks .table-scroll-pane { max-height: calc(100vh - 140px); }
#page-tasks .table-scroll-pane th, #page-tasks .table-scroll-pane td { padding-left: 6px; padding-right: 6px; }
#page-tasks .table-scroll-pane td.td-move { width: 30px; padding: 0; text-align: center; }
#page-tasks .table-scroll-pane th.th-move { width: 30px; padding: 0; }
#page-tasks .table-scroll-pane td.td-updated, #page-tasks .table-scroll-pane td:last-child { white-space: normal; }

/* P&L dashboard: net profit by month */
.pl-bars { display: flex; align-items: flex-end; gap: 14px; min-height: 230px; padding: 8px 4px 4px; overflow-x: auto; }
.pl-bar { flex: 1 0 96px; display: flex; flex-direction: column; align-items: center; gap: 6px; }
.pl-bar-value { font-size: 12px; font-weight: 700; white-space: nowrap; }
.pl-bar-track { height: 160px; width: 100%; display: flex; align-items: flex-end; justify-content: center; }
.pl-bar-fill { width: 62%; min-height: 2px; border-radius: 6px 6px 0 0; background: var(--accent-blue); }
.pl-bar-fill.neg { background: var(--accent-red-solid, var(--danger)); }
.pl-bar-label { font-size: 12px; color: var(--text-muted); text-align: center; }

/* ===== P&L — Sheet (Google-sheet layout) and Calculator ===== */
.pl-sheet-scroll { overflow: auto; max-height: calc(100vh - 300px); border: 1px solid var(--border); border-radius: var(--radius); background: var(--panel-bg); box-shadow: var(--shadow); }
.pl-sheet { border-collapse: separate; border-spacing: 0; font-size: 13px; white-space: nowrap; width: max-content; }
.pl-sheet th, .pl-sheet td { padding: 6px 10px; border-bottom: 1px solid var(--border); text-align: right; min-width: 112px; font-variant-numeric: tabular-nums; }
.pl-sheet thead th { position: sticky; top: 0; z-index: 2; background: var(--panel-bg); font-weight: 600; color: var(--text-muted); }
.pl-sheet thead tr.pl-sheet-dates th { top: 33px; z-index: 2; font-weight: 400; font-size: 11px; color: var(--text-dim); }
.pl-sheet .pl-sheet-label { position: sticky; left: 0; z-index: 1; text-align: left; min-width: 250px; background: var(--panel-bg); }
.pl-sheet thead .pl-sheet-label { z-index: 3; }
.pl-sheet .pl-sheet-total { min-width: 128px; background: var(--panel-bg-2); }
.pl-sheet .pl-sheet-section td { background: var(--panel-bg-2); font-size: 11px; font-weight: 700; color: var(--text-dim); text-align: left; }
.pl-sheet input { width: 100%; min-width: 96px; border: 1px solid transparent; background: transparent; text-align: right; color: var(--accent-fg); font: inherit; padding: 2px 4px; border-radius: 6px; }
.pl-sheet input:focus { border-color: var(--accent-blue); outline: none; background: var(--panel-bg); }
.pl-sheet .pl-sheet-bold { font-weight: 600; }
.pl-sheet .pl-sheet-now { background: rgba(37,99,235,.06); }
.pl-sheet .neg { color: var(--status-red); }
.pl-calc-layout { display: grid; grid-template-columns: minmax(280px, 380px) 1fr; gap: 18px; align-items: start; }
.pl-calc-results .kpi-row { margin-bottom: 14px; }
.pl-calc-results .neg { color: var(--status-red); }
@media (max-width: 760px) { .pl-calc-layout { grid-template-columns: 1fr; } }
#pl-calc-form { grid-template-columns: 1fr; }

/* ===== Maintenance Log — weeks you open to see what was spent ===== */
.maint-weeks { display: flex; flex-direction: column; gap: 10px; }
.maint-week { background: var(--panel-bg); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.maint-week > summary { list-style: none; cursor: pointer; display: grid; grid-template-columns: 22px minmax(150px, 1.2fr) repeat(3, minmax(100px, 1fr)) minmax(160px, 1.1fr); align-items: center; gap: 12px; padding: 14px 18px; }
.maint-week > summary::-webkit-details-marker { display: none; }
.maint-week > summary:hover { background: var(--panel-bg-2); border-radius: var(--radius); }
.maint-chev { width: 18px; height: 18px; color: var(--text-dim); transition: transform var(--dur-fast) var(--ease); }
.maint-week[open] .maint-chev { transform: rotate(90deg); }
.maint-when { font-weight: 600; font-size: 14px; display: flex; flex-direction: column; }
.maint-when small, .maint-fig small { font-weight: 400; font-size: 11px; color: var(--text-dim); }
.maint-fig { display: flex; flex-direction: column; text-align: right; font-variant-numeric: tabular-nums; }
.maint-total { font-weight: 700; font-size: 14px; }
.maint-rep { color: var(--text-muted); }
.maint-rep em { font-style: normal; font-size: 11px; color: var(--status-yellow); }
.maint-rep.ok em { color: var(--status-green); }
.maint-week-body { padding: 0 18px 16px; border-top: 1px solid var(--border); }
.maint-cats { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 8px; margin: 14px 0; }
.maint-cat { position: relative; overflow: hidden; display: flex; justify-content: space-between; gap: 8px; padding: 8px 12px; border: 1px solid var(--border); border-radius: 8px; font-size: 13px; }
.maint-cat b { font-variant-numeric: tabular-nums; }
.maint-cat i { position: absolute; left: 0; bottom: 0; height: 3px; background: var(--accent-blue); opacity: .55; }
.maint-table { max-height: none; margin-bottom: 0; box-shadow: none; }
.maint-table tbody tr { cursor: pointer; }
.maint-notes { white-space: normal; min-width: 170px; max-width: 250px; color: var(--text-muted); font-size: 12px; }
.maint-warn { color: var(--status-red); font-size: 12px; }
@media (max-width: 900px) {
  .maint-week > summary { grid-template-columns: 22px 1fr 1fr; }
}

.maint-removed td { color: var(--text-dim); text-decoration: line-through; text-decoration-color: var(--text-dim); }
.maint-removed td .maint-tag { text-decoration: none; display: inline-block; }
.maint-tag { font-size: 11px; padding: 1px 7px; border-radius: 999px; background: var(--panel-bg-2); color: var(--text-muted); white-space: nowrap; }
.maint-ro { padding: 9px 12px; border: 1px solid var(--border); border-radius: 8px; background: var(--panel-bg-2); min-height: 38px; white-space: pre-wrap; }
/* Weekly P&L grid: the pinned header row and label column need a solid background (the glass/glow theme makes
   panels see-through, so scrolled cells showed through the pinned ones) */
.pl-sheet thead th, .pl-sheet .pl-sheet-label { background-color: #FFFFFF !important; }
.pl-sheet .pl-sheet-section td.pl-sheet-label { background-color: #F3F4F6 !important; }
html[data-theme="dark"] .pl-sheet thead th, html[data-theme="dark"] .pl-sheet .pl-sheet-label { background-color: #161B22 !important; }
html[data-theme="dark"] .pl-sheet .pl-sheet-section td.pl-sheet-label { background-color: #1C2128 !important; }
.pl-sheet thead tr th.pl-sheet-label, .pl-sheet thead tr.pl-sheet-dates th.pl-sheet-label { z-index: 4; }

/* ===== P&L — entry by vendor + Vendor P&L ===== */
.plv-table { width: 100%; font-variant-numeric: tabular-nums; }
.plv-table th, .plv-table td { text-align: right; white-space: nowrap; }
.plv-table th:first-child, .plv-table td:first-child { text-align: left; }
.plv-table .neg { color: var(--status-red); }
.plv-table-wrap { max-height: none; margin-bottom: 8px; }
.plv-entry input { width: 110px; text-align: right; padding: 6px 8px; border: 1px solid var(--border); border-radius: 6px; font: inherit; color: var(--accent-fg); background: var(--panel-bg); }
.plv-entry input.plv-bad { border-color: var(--accent-red-solid); }
.plv-entry .plv-name { font-weight: 600; }
.plv-entry tfoot td { font-weight: 700; background: var(--panel-bg-2); }
.plv-add { display: flex; gap: 8px; margin: 0 0 16px; max-width: 460px; }
.plv-legacy { padding: 10px 14px; border-radius: 8px; background: var(--status-yellow-bg); color: var(--text); font-size: 13px; margin-bottom: 12px; }
.plv-group td { font-size: 11px; font-weight: 700; color: var(--text-dim); background: var(--panel-bg-2); text-align: left !important; }
.plv-sub td { color: var(--text-muted); }
.plv-strong td, .plv-total td { font-weight: 700; color: var(--text); }
.plv-total td { border-top: 2px solid var(--border); font-size: 14px; }
.plv-weekhead, .pl-sheet-weekhead { cursor: pointer; }
.plv-weekhead:hover, .pl-sheet-weekhead:hover { color: var(--accent-fg); }
.pl-sheet td.pl-sheet-fromvendor { color: var(--text); cursor: pointer; }
.kpi-value.neg { color: var(--status-red); }
.plv-table th, .plv-table td { padding: 9px 10px; }
.plv-table th { font-size: 11px; }
.plv-entry input { width: 92px; }
.plv-add .select-field { flex: 1; min-width: 200px; }
.task-find { min-width: 260px; }
.report-section-title { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 14px; margin: 4px 0 10px; color: var(--text); }
.report-section-title i, .report-section-title svg { width: 16px; height: 16px; }
.report-total { font-size: 13px; color: var(--text-muted); margin: 0 0 12px; }
.report-table { max-height: 420px; margin-bottom: 0; box-shadow: none; }
.report-wrap { white-space: normal; min-width: 180px; max-width: 360px; font-size: 12px; color: var(--text-muted); }
.report-age { font-weight: 700; }
.report-age.a14 { color: var(--status-yellow); }
.report-age.a30 { color: var(--status-red); }
.report-link { color: var(--accent-fg); text-decoration: none; white-space: nowrap; }

/* ---- image viewer (comment pictures, profile photos) ---- */
.image-viewer { position: fixed; inset: 0; z-index: 4000; background: rgba(10,12,18,.86); display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 64px 24px 24px; visibility: visible; }
.image-viewer[hidden] { display: none; }
.image-viewer-bar { position: absolute; top: 0; left: 0; right: 0; display: flex; align-items: center; gap: 10px; padding: 12px 16px; color: #fff; }
.image-viewer-title { flex: 1; font-weight: 600; }
.image-viewer-img { max-width: 100%; max-height: 100%; object-fit: contain; border-radius: 8px; box-shadow: var(--e3); background: #fff; }
.comment-image { cursor: zoom-in; }
[data-avatar-name][style*="background-image"] { cursor: zoom-in; }
.comment-edit-box { margin-top: 6px; }
.comment-edit-input { width: 100%; font: inherit; padding: 8px 10px; border: 1px solid var(--accent-blue); border-radius: 8px; background: var(--panel-bg); color: var(--text); resize: vertical; }
.comment-edit-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 6px; }
.comment-edit-actions .btn { padding: 6px 14px; }

/* ---- Dark theme labels, Notion-style: solid muted colour + light text (the 13% tints disappeared on dark) ---- */
html[data-theme="dark"] .tag, html[data-theme="dark"] .status-pill { color: rgba(255,255,255,.9) !important; font-weight: 600; }

/* ===== Repair case form: one compact 4-column block, nothing stretched across the whole screen ===== */
.repair-body { padding: 18px 20px; }
.repair-compact { max-width: 1080px; margin: 0 auto; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px 16px; align-items: start; }
.repair-compact .span2 { grid-column: span 2; }
.repair-compact .span3 { grid-column: span 3; }
.repair-compact .form-field { margin: 0; }
.repair-compact .form-field > label { font-size: 12px; margin-bottom: 4px; }
.repair-compact input:not([type="file"]), .repair-compact select, .repair-compact textarea { padding: 7px 10px; font-size: 13px; }
.repair-compact textarea { resize: vertical; min-height: 0; }
.repair-ib-row { display: grid; grid-template-columns: minmax(0, 1fr) 120px 34px; gap: 6px; align-items: center; margin-bottom: 6px; }
.repair-ib-row .icon-btn { padding: 6px 8px; }
.repair-breakdown-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-size: 13px; }
.repair-breakdown-foot .btn { padding: 5px 12px; font-size: 12px; }
.repair-upload { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; }
.repair-upload #repair-invoice-current:empty { display: none; }
@media (max-width: 860px) { .repair-compact { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 560px) { .repair-compact { grid-template-columns: 1fr; } .repair-compact .span2, .repair-compact .span3 { grid-column: auto; } }

/* ---- Invoice items: Copy / Paste / Fill down bar over the focused cell ---- */
.items-cell-tools { position: fixed; z-index: 3500; display: flex; gap: 2px; padding: 3px; border-radius: 8px; background: var(--text); box-shadow: var(--e3); }
.items-cell-tools[hidden] { display: none; }
.items-cell-tools button { border: none; background: transparent; color: var(--bg, #fff); font: 600 11px/1 inherit; padding: 6px 9px; border-radius: 6px; cursor: pointer; }
html:not([data-theme="dark"]) .items-cell-tools button { color: #fff; }
.items-cell-tools button:hover { background: rgba(255,255,255,.15); }
.items-cell-tools.flash::after { content: attr(data-msg); position: absolute; left: 0; top: calc(100% + 4px); white-space: nowrap; font-size: 11px; padding: 4px 8px; border-radius: 6px; background: #1F2430; color: #fff; } html[data-theme="dark"] .items-cell-tools.flash::after { background: #E6EDF3; color: #0D1117; }

/* Repair case form v3: everything to fill out on the left, the two notes on the right (as in the reference) */
.repair-split { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(320px, .85fr); gap: 16px; align-items: start; }
.repair-panel { background: var(--panel-bg); border: 1px solid var(--border); border-radius: 12px; padding: 14px 16px; box-shadow: var(--shadow); }
.repair-right { display: flex; flex-direction: column; gap: 16px; position: sticky; top: 0; }
.repair-panel-title { font-size: 11px; font-weight: 700; color: var(--text-dim); margin-bottom: 10px; }
.repair-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 14px; align-items: start; }
.repair-fields .span2 { grid-column: 1 / -1; }
.repair-fields .form-field { margin: 0; }
.repair-fields .form-field > label { font-size: 12px; margin-bottom: 4px; }
.repair-fields input:not([type="file"]), .repair-fields select { padding: 7px 10px; font-size: 13px; }
.repair-note { width: 100%; min-height: 190px; resize: vertical; font: inherit; font-size: 13px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px; background: var(--panel-bg); color: var(--text); }
.repair-note:focus { outline: none; border-color: var(--accent-blue); }
@media (max-width: 900px) { .repair-split { grid-template-columns: 1fr; } .repair-right { position: static; } }
@media (max-width: 560px) { .repair-fields { grid-template-columns: 1fr; } }

/* ---- Repair Expenses: columns no longer stretch to fill the screen; drag a header's right edge to resize ---- */
#repairs-table { width: max-content; min-width: 0; }
#repairs-table th[data-col-key] { position: relative; }
#repairs-table .cc { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#repairs-table td[data-col-key="driver"] .cc { max-width: 170px; }
#repairs-table td[data-col-key="issueType"] .cc { max-width: 170px; }
#repairs-table td[data-col-key="note"] .cc { max-width: 240px; }
#repairs-table td[data-col-key="accountantNotes"] .cc { max-width: 220px; }
#repairs-table td[data-col-key="createdBy"] .cc, #repairs-table td[data-col-key="closedBy"] .cc { max-width: 140px; }
.col-resize { position: absolute; top: 0; right: -3px; width: 7px; height: 100%; cursor: col-resize; z-index: 2; }
.col-resize::after { content: ""; position: absolute; top: 25%; bottom: 25%; left: 3px; width: 1px; background: var(--border); }
#repairs-table th:hover .col-resize::after, .col-resizing .col-resize::after { background: var(--accent-blue); width: 2px; }
body.col-resizing, body.col-resizing * { cursor: col-resize !important; user-select: none !important; }

/* ---- Invoice items: spreadsheet-style selected cells ---- */
#items-tbody td.cell-sel { background: rgba(37,99,235,.12); box-shadow: inset 0 0 0 1px rgba(37,99,235,.35); }
#items-tbody td.cell-anchor { box-shadow: inset 0 0 0 2px var(--accent-blue); }
#items-tbody td.cell-sel input, #items-tbody td.cell-sel select { background: transparent; }

/* ---- Settings → API keys ---- */
.apikeys-body { padding: 18px 22px; }
.apikeys-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr); gap: 16px; align-items: start; }
.apikeys-grid .panel { margin: 0; }
.apikey-modules { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 4px 12px; max-height: 260px; overflow: auto; padding: 8px; border: 1px solid var(--border); border-radius: 8px; }
.apikey-mod { display: flex; gap: 6px; align-items: center; font-size: 12px; font-weight: 400 !important; }
.apikey-new { margin-top: 12px; padding: 12px; border-radius: 8px; background: var(--status-yellow-bg); }
.apikey-new-row { display: flex; gap: 8px; align-items: center; margin-top: 6px; }
.apikey-new code { flex: 1; word-break: break-all; font-size: 13px; padding: 6px 8px; background: var(--panel-bg); border-radius: 6px; user-select: all; }
.apikey-docs p { margin: 0 0 10px; font-size: 13px; }
.apikey-docs code, #apikeys-table code { font-size: 12px; padding: 1px 5px; border-radius: 4px; background: var(--panel-bg-2); }
.apikey-docs pre { font-size: 12px; padding: 10px; border-radius: 8px; background: var(--panel-bg-2); overflow-x: auto; margin: 0 0 10px; }
.apikey-endpoints { width: 100%; margin-bottom: 10px; font-size: 12px; box-shadow: none; border: none; }
.apikey-endpoints td { padding: 5px 6px; vertical-align: top; }
.apikey-pages { white-space: normal; max-width: 320px; font-size: 12px; }
.apikey-revoked td { opacity: .55; }
@media (max-width: 900px) { .apikeys-grid { grid-template-columns: 1fr; } }

/* PM (2026-11-17): odometer row in the Repair Expenses form when the case is a PM on a tracked truck, and the
   "who gets PM notifications" checkbox list in PM Settings. */
.repair-pm-odometer { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 8px; font-size: 13px; }
.repair-pm-odometer[hidden] { display: none; }
.pm-notify-users { display: flex; flex-wrap: wrap; gap: 8px 18px; }
.pm-notify-users label { display: flex; align-items: center; gap: 6px; font-size: 13px; cursor: pointer; }

/* My Truck (2026-11-25): simpler page — three answers on top, clickable cards that explain their number, sections folded away. */
.mt-click { cursor: pointer; }
.mt-click:hover { outline: 1px solid var(--accent-blue); }
.mt-bar { height: 6px; background: var(--panel-bg-2); border-radius: 3px; margin: 8px 0 4px; overflow: hidden; }
.mt-bar > i { display: block; height: 6px; background: var(--status-green); border-radius: 3px; }
.mt-explain { margin-bottom: 14px; }
.mt-explain[hidden] { display: none; }
.mt-ex-table { width: 100%; border-collapse: collapse; font-size: 13px; margin-bottom: 12px; }
.mt-ex-table th { text-align: right; font-weight: 600; color: var(--text-muted); padding: 5px 8px; }
.mt-ex-table td { text-align: right; padding: 5px 8px; border-top: 1px solid var(--border); }
.mt-ex-table th:first-child, .mt-ex-table td:first-child { text-align: left; }
.mt-ex-table .mt-ex-total td { font-weight: 700; }
.mt-ex-line { padding: 10px 12px; background: var(--panel-bg-2); border-radius: 8px; font-size: 14px; margin-bottom: 8px; }
.mt-sec { margin-bottom: 10px; }
.mt-sec > summary { cursor: pointer; list-style: none; padding: 12px 16px; background: var(--panel-bg); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); font-weight: 600; display: flex; gap: 10px; align-items: center; }
.mt-sec > summary::-webkit-details-marker { display: none; }
.mt-sec > summary::before { content: "▸"; color: var(--text-muted); }
.mt-sec[open] > summary::before { content: "▾"; }
.mt-sec > summary .hint { margin: 0 0 0 auto; font-weight: 400; }
.mt-sec-body { padding: 14px 4px 4px; }
.mt-check { display: flex; align-items: center; gap: 8px; font-size: 14px; cursor: pointer; margin-top: 4px; }

/* ===================== Design system layer (design pass, December 2026) =====================
   Shared rules for every page. It sits last on purpose: at equal specificity these win, so one rule here
   keeps a whole family of controls the same everywhere. Page rules above only add what is page-specific. */

/* ---- Base ---- */
body { line-height: 1.5; font-variant-numeric: tabular-nums; -webkit-font-smoothing: antialiased; }
/* Controls inherit the app's font (browsers default buttons and fields to Arial / system UI). */
button, input, select, textarea, optgroup { font-family: inherit; letter-spacing: inherit; }
button { -webkit-tap-highlight-color: transparent; }
::selection { background: rgba(var(--accent-rgb), .22); }

/* ---- One focus style: a 2 px ring from a token, never animated, never removed ---- */
:focus:not(:focus-visible) { outline: none; }
:focus-visible { outline: 2px solid var(--focus) !important; outline-offset: 2px; box-shadow: none; }
input:focus-visible, select:focus-visible, textarea:focus-visible { outline-offset: 0; border-color: var(--focus) !important; }
.dt-input.dt-focused { outline: 2px solid var(--focus); outline-offset: 0; border-color: var(--focus); }
tr:focus-visible, td:focus-visible, [role="row"]:focus-visible { outline-offset: -2px; }

/* ---- Skip link, screen-reader-only text ---- */
.skip-link {
  position: fixed; left: 12px; top: -64px; z-index: 30000; background: var(--panel-bg); color: var(--accent-fg);
  border: 1px solid var(--control-border); border-radius: var(--radius); padding: 8px 14px; font-weight: 600;
  text-decoration: none; box-shadow: var(--e2);
}
.skip-link:focus { top: 12px; }
.sr-only { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

/* ---- Buttons: one height per step (38 / 34 / 26), one corner, at most one filled button per view ---- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: var(--h-md);
  padding: 0 16px; border: 1px solid transparent; border-radius: var(--radius); font-size: var(--fs-md);
  font-weight: 600; line-height: 20px; white-space: nowrap; text-decoration: none;
  transition: background-color var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease), transform var(--dur-fast) var(--ease);
}
.btn svg { width: 16px; height: 16px; flex-shrink: 0; }
.btn:active:not(:disabled) { transform: scale(calc(1 - .03 * var(--move))); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .5; cursor: not-allowed; }
.btn[aria-busy="true"] { cursor: progress; }
.btn-primary, .btn-save { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }
.btn-primary:hover:not(:disabled), .btn-save:hover:not(:disabled) { background: var(--accent-hover); border-color: var(--accent-hover); color: var(--on-accent); filter: none; }
.btn-secondary { background: var(--panel-bg); color: var(--text); border-color: var(--control-border); }
.btn-secondary:hover:not(:disabled) { background: var(--panel-bg-2); border-color: var(--control-border); color: var(--text); }
/* Destructive: quiet (red outline) until hovered, so Delete never competes with Save and Close never looks like Delete. */
.btn-danger { background: var(--panel-bg); color: var(--status-red); border-color: color-mix(in srgb, var(--status-red) 60%, var(--panel-bg)); }
.btn-danger:hover:not(:disabled) { background: var(--danger); border-color: var(--danger); color: var(--on-accent); filter: none; }
.toolbar-group .btn { padding: 0 14px; }
.btn.btn-sm, .toolbar .btn-sm { min-height: var(--h-sm); padding: 0 12px; font-size: var(--fs-base); }
.icon-btn { width: var(--h-md); height: var(--h-md); border-radius: var(--radius); }
.icon-btn.primary { background: var(--accent); color: var(--on-accent); }
.icon-btn.primary:hover { background: var(--accent-hover); }
.icon-btn.secondary { border: 1px solid var(--control-border); }
.icon-btn.secondary:hover { background: var(--panel-bg-2); border-color: var(--control-border); color: var(--text); }
.topbar-btn, .theme-toggle-btn, .alerts-btn { min-height: var(--h-sm); min-width: var(--h-sm); border-color: var(--control-border); }
.topbar-btn:hover, .theme-toggle-btn:hover, .alerts-btn:hover { background: var(--panel-bg-2); border-color: var(--control-border); color: var(--text); }
.avatar, .tic-send, #bi-ai-launcher, .bi-ai-msg-user, .dash-period-pill.active, .ch-page-tab.active { background-color: var(--accent); }
#bi-ai-launcher:hover { background: var(--accent-hover); transform: none; }
.filter-count-badge { background: var(--accent); color: var(--on-accent); }

/* ---- Fields: 38 px (8 + 20 + 8 + borders), 3:1 outline ---- */
.form-field input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="file"]):not([type="color"]),
.form-field select, .select-field, .search-field input, .dt-input {
  min-height: var(--h-md); padding-top: 8px; padding-bottom: 8px; line-height: 20px;
  border: 1px solid var(--control-border); border-radius: var(--radius); background-color: var(--panel-bg); color: var(--text);
  font-size: var(--fs-md);
}
.form-field textarea { border: 1px solid var(--control-border); border-radius: var(--radius); background-color: var(--panel-bg); color: var(--text); font-size: var(--fs-md); line-height: 20px; }
.form-field input:focus, .form-field select:focus, .form-field textarea:focus, .search-field input:focus, .select-field:focus { box-shadow: none; }
.form-field label { font-size: var(--fs-sm); font-weight: 600; color: var(--text-muted); }
input:disabled, select:disabled, textarea:disabled { opacity: .6; cursor: not-allowed; }
.toggle-switch input:checked + .slider { background: var(--accent); }
.toggle-switch .slider { background: var(--control-border); }

/* ---- Tabs and segmented controls: the strip is control height (4 + 30 + 4) ---- */
.subtabs, .task-tabs, .modal-tabs, .view-toggle { padding: 4px; gap: 2px; border-radius: var(--radius); background: var(--panel-bg-2); }
.subtabs button, .task-tabs button, .modal-tabs button, .view-toggle button {
  min-height: 30px; padding: 0 14px; border-radius: 6px; font-size: var(--fs-base); font-weight: 500; color: var(--text-muted);
  transition: background-color var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
}
.subtabs button:hover:not(.active), .task-tabs button:hover:not(.active), .modal-tabs button:hover:not(.active), .view-toggle button:hover:not(.active) { color: var(--text); background: var(--panel-strong); }
.subtabs button.active, .task-tabs button.active, .modal-tabs button.active, .view-toggle button.active { background: var(--panel-bg); color: var(--text); font-weight: 600; box-shadow: var(--e1); }
/* Filter chips (toggle buttons) are the xs step */
.dash-period-pill, .ru-chip, .toll-state-chip, .ch-page-tab, .diag-chip { min-height: var(--h-xs); display: inline-flex; align-items: center; gap: 6px; border-radius: 999px; padding: 0 12px; font-size: var(--fs-sm); }
.dash-period-pill { border-color: var(--control-border); }
.dash-period-pill:hover:not(.active) { border-color: var(--accent); color: var(--accent-fg); }

/* ---- Status pills: one shape, a dot, a fixed set of tones, never wraps ---- */
.status-pill, .tag, .vt-pill, .diag-badge, .dash-pm-chip, .pill, .maint-tag, .acq-card-status-badge {
  display: inline-flex; align-items: center; gap: 6px; min-height: 22px; padding: 0 9px; border-radius: 999px;
  font-size: var(--fs-sm); font-weight: 600; line-height: 1.3; white-space: nowrap; border: 0; vertical-align: middle;
}
.status-pill .dot, .diag-badge .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex-shrink: 0; }
.status-pill-green, .pill-connected, .tag-green, .dash-pm-chip.ok { background: var(--status-green-bg); color: var(--status-green); }
.status-pill-yellow, .pill-connecting, .tag-yellow, .dash-pm-chip.due { background: var(--status-yellow-bg); color: var(--status-yellow); }
.status-pill-red, .tag-red, .dash-pm-chip.over { background: var(--status-red-bg); color: var(--status-red); }
.status-pill-gray, .tag-gray, .maint-tag { background: var(--status-gray-bg); color: var(--status-gray); }
.tag-blue { background: var(--status-blue-bg); color: var(--status-blue); }
/* Vehicle types are kinds, not statuses: category colours in the maintenance sheet's red / blue / yellow family */
.vt-truck { background: var(--cat-pink-bg); color: var(--cat-pink); }
.vt-trailer { background: var(--cat-sky-bg); color: var(--cat-sky); }
.vt-brokerage { background: var(--cat-orange-bg); color: var(--cat-orange); }
.tag-purple { background: var(--cat-violet-bg); color: var(--cat-violet); }
.tag-pink { background: var(--cat-pink-bg); color: var(--cat-pink); }
.tag-orange { background: var(--cat-orange-bg); color: var(--cat-orange); }
.tag-brown { background: var(--cat-brown-bg); color: var(--cat-brown); }
.diag-badge.diag-sev-stop { color: var(--status-red); }
.diag-badge.diag-sev-warn { color: var(--status-yellow); }
.diag-badge.diag-sev-info { color: var(--status-gray); }
.sla-ontime, .row-status-paid { color: var(--status-green); }
.sla-late, .row-status-dispute, .report-age.a30 { color: var(--status-red); }

/* ---- Surfaces: solid, hairline border, cards 12 / menus 10 / dialogs 16, shadows from tokens ---- */
.card, .panel, .kpi-card, .filters-panel, table, .acq-card, .pw-card, .item-card { border-radius: var(--radius-card); }
.panel table, .table-scroll-pane table { border-radius: 0; }
.modal-box { border-radius: var(--radius-dialog); box-shadow: var(--e3); }
.profile-popover, .col-menu, .alerts-popover, .add-choice-menu, .quick-edit-popover, .reaction-picker, .emoji-picker,
.mention-autocomplete, .fault-explain-popover, .ru-types-menu, .tic-pop, .chart-tooltip { border-radius: var(--radius-menu); box-shadow: var(--e2); }
.modal-overlay { background: rgba(10, 14, 24, .5); }
.card .value, .kpi-card .kpi-value { font-size: var(--fs-3xl); font-weight: 600; letter-spacing: -.02em; }
.kpi-card .kpi-top { font-size: var(--fs-sm); font-weight: 600; color: var(--text-muted); }
.panel-header { font-size: var(--fs-md); font-weight: 600; }
.panel-header h2, .panel-header h3 { font: inherit; margin: 0; color: inherit; display: inline-flex; align-items: center; gap: 8px; }
.empty-state { color: var(--text-muted); }

/* ---- Tables: sentence-case headers, tabular figures ---- */
th { font-size: var(--fs-sm); font-weight: 600; color: var(--text-muted); }

/* ---- Toasts: confirmations neutral with a check, errors red; both announced ---- */
.toast { display: flex; align-items: flex-start; gap: 8px; border-radius: var(--radius-menu); box-shadow: var(--e3); line-height: 1.45; animation: ui-enter var(--dur-base) var(--ease); }
.toast svg { width: 16px; height: 16px; flex-shrink: 0; margin-top: 1px; }
.toast-ok { background: #1F2430; color: #fff; }
html[data-theme="dark"] .toast-ok { background: #E6EDF3; color: #0D1117; }
.toast-error { background: #B91C1C; color: #fff; }

/* ---- Motion: one entrance and one exit keyframe; components set --enter-y / --enter-scale, travel scales with
   --move (1 Full, .6 Calm, 0 Off). They use the separate translate / scale properties, so a component's own
   transform is never overwritten. Closing (.is-closing) and menu origins are timed by js/motion-fx.js. ---- */
:root { --enter-y: 8px; --enter-scale: .03; }
@keyframes ui-enter { from { opacity: 0; translate: 0 calc(var(--enter-y) * var(--move)); scale: calc(1 - var(--enter-scale) * var(--move)); } }
@keyframes ui-exit { to { opacity: 0; translate: 0 calc(var(--enter-y) * var(--move) * .5); scale: calc(1 - var(--enter-scale) * var(--move)); } }
@keyframes ui-fade { from { opacity: 0; } }
@keyframes ui-fade-out { to { opacity: 0; } }
@keyframes ui-reveal { to { opacity: 1; } }
/* Pages: a short fade with a small rise (Andrew, 2026-12-03). */
.page:not([hidden]) { --enter-y: 6px; --enter-scale: 0; animation: ui-enter var(--dur-base) var(--ease); }
.modal-overlay:not([hidden]) { animation: ui-fade var(--dur-base) var(--ease); }
.modal-overlay > .modal-box { --enter-y: 8px; --enter-scale: .03; }
.modal-overlay:not([hidden]) > .modal-box { animation: ui-enter var(--dur-base) var(--ease); }
.fullscreen-view { --enter-y: 10px; --enter-scale: 0; }
.fullscreen-view:not([hidden]) { animation: ui-enter var(--dur-base) var(--ease); }
/* Menus and pop-overs grow out of the button that opened them: motion-fx.js sets transform-origin at the button
   and --enter-y to -4px (opened below it) or 4px (opened above it). */
:where(.profile-popover, .col-menu, .alerts-popover, .add-choice-menu, #quick-edit-popover, .emoji-picker, #emoji-picker, .fault-explain-popover, .ru-types-menu, .tic-pop) { --enter-y: -4px; --enter-scale: .04; transform-origin: top center; }
:where(.profile-popover, .col-menu, .alerts-popover, .add-choice-menu, #quick-edit-popover, .emoji-picker, #emoji-picker, .fault-explain-popover, .ru-types-menu, .tic-pop):not([hidden]) { animation: ui-enter var(--dur-fast) var(--ease); }
/* Closing: exits are quicker than entrances, and a closing window takes no clicks. */
.is-closing { pointer-events: none; }
.modal-overlay.is-closing { animation: ui-fade-out var(--dur-fast) var(--ease) forwards; }
.modal-overlay.is-closing > .modal-box { animation: ui-exit var(--dur-fast) var(--ease) forwards; }
.fullscreen-view.is-closing { animation: ui-exit var(--dur-fast) var(--ease) forwards; }
:where(.profile-popover, .col-menu, .alerts-popover, .add-choice-menu, #quick-edit-popover, .emoji-picker, #emoji-picker, .fault-explain-popover, .ru-types-menu, .tic-pop).is-closing { animation: ui-exit var(--dur-fast) var(--ease) forwards; }
.toast { --enter-y: 8px; --enter-scale: .03; }
.toast.is-closing { animation: ui-exit var(--dur-fast) var(--ease) forwards; }

/* ---- Tabs and segmented switches: the "selected" box slides to the tab you pick (motion-fx.js places it).
   Until it is placed (.has-glider), the active tab draws its own box as before. ---- */
.subtabs, .task-tabs, .modal-tabs, .view-toggle { position: relative; }
.tab-glider {
  position: absolute; left: 0; top: 0; width: 0; height: 0; border-radius: 6px; background: var(--panel-bg); box-shadow: var(--e1);
  pointer-events: none; opacity: 0; z-index: 0;
  transition: transform var(--dur-base) var(--ease), width var(--dur-base) var(--ease), height var(--dur-base) var(--ease);
}
.has-glider > .tab-glider { opacity: 1; }
:is(.subtabs, .task-tabs, .modal-tabs, .view-toggle) > button { position: relative; z-index: 1; }
html :is(.subtabs, .task-tabs, .modal-tabs, .view-toggle).has-glider > button.active { background: transparent; box-shadow: none; }

/* ---- Fold-outs (<details>): the panel grows open and closed instead of snapping (browsers that can animate to
   "auto" height; others open at once, as before). The arrow turns. ---- */
@supports selector(::details-content) {
  details { interpolate-size: allow-keywords; }
  details::details-content { block-size: 0; overflow-y: clip; transition: block-size var(--dur-slow) var(--ease), content-visibility var(--dur-slow) allow-discrete; }
  details[open]::details-content { block-size: auto; }
  html[data-motion="off"] details::details-content { transition: none; }
}
.mt-sec > summary::before { content: "▸"; display: inline-block; transition: rotate var(--dur-fast) var(--ease); }
.mt-sec[open] > summary::before { content: "▸"; rotate: 90deg; }

/* ---- Checkboxes: the tick draws itself in (left to right) when ticked. Toggle switches keep their own look. ---- */
input[type="checkbox"]:not(.toggle-switch input) {
  appearance: none; -webkit-appearance: none; width: 14px; height: 14px; border: 1.5px solid var(--control-border); border-radius: 4px;
  background: var(--panel-bg); display: inline-grid; place-content: center; vertical-align: -2px; cursor: pointer; flex-shrink: 0;
  transition: background-color var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease);
}
input[type="checkbox"]:not(.toggle-switch input)::before {
  content: ""; width: 9px; height: 9px; background: var(--on-accent);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M2 6.5 4.8 9 10 3' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M2 6.5 4.8 9 10 3' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / contain no-repeat;
  clip-path: inset(0 100% 0 0); transition: clip-path var(--dur-base) var(--ease);
}
input[type="checkbox"]:not(.toggle-switch input):checked, input[type="checkbox"]:not(.toggle-switch input):indeterminate { background: var(--accent); border-color: var(--accent); }
input[type="checkbox"]:not(.toggle-switch input):checked::before { clip-path: inset(0 0 0 0); }
input[type="checkbox"]:not(.toggle-switch input):indeterminate::before { -webkit-mask: none; mask: none; width: 8px; height: 2px; border-radius: 1px; clip-path: none; }
input[type="checkbox"]:not(.toggle-switch input):disabled { opacity: .5; cursor: default; }

/* ---- A Save button that stays on screen shows a check for a moment after saving (motion-fx.js). ---- */
.btn .saved-check { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round; }
.btn .saved-check path { stroke-dasharray: 1; stroke-dashoffset: 1; animation: ui-draw var(--dur-slow) var(--ease) forwards; }
@keyframes ui-draw { to { stroke-dashoffset: 0; } }

/* ---- Lists after a save or a live update (motion-fx.js): a changed or new row gets a short blue tint. ---- */
@keyframes row-flash { from, 30% { background-color: rgba(var(--accent-rgb), .16); } }
tr.row-flash > td { animation: row-flash var(--dur-flash) var(--ease) var(--flash-delay, 0ms); }

/* ---- The desktop sidebar slides out on top of the page while the page slides left under it (motion-fx.js). ---- */
.app-shell.sidebar-sliding { overflow: clip; }
.app-shell.sidebar-leaving .sidebar { position: fixed; left: 0; top: 0; bottom: 0; z-index: 40; border-right: 1px solid var(--border); }
/* The background glow drifts only at Full; at Calm and Off it stays still. Confetti only at Full. */
html:not([data-motion="full"]) #bg-glow i, html:not([data-motion="full"]) #bg-glow .lq { animation: none !important; }
html:not([data-motion="full"]) .bday-confetti { display: none !important; }
/* Layout never animates (it re-measures the page every frame). */
.app-shell, .mt-progress-bar { transition: none; }

/* ---- Loading, failed and empty states ---- */
.skeleton-block { opacity: 0; animation: ui-reveal var(--dur-fast) var(--ease) 200ms forwards; }  /* fast answers never flash it */
.skeleton { display: block; height: 12px; margin: 10px 0; border-radius: 6px; background: linear-gradient(90deg, var(--panel-bg-2) 25%, var(--panel-strong) 50%, var(--panel-bg-2) 75%); background-size: 200% 100%; animation: skeleton-sweep 1.4s linear infinite; }
.skeleton.w60 { width: 60%; } .skeleton.w80 { width: 80%; } .skeleton.w40 { width: 40%; }
html:not([data-motion="full"]) .skeleton { animation: none; }
@keyframes skeleton-sweep { to { background-position: -200% 0; } }
.load-failed { display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 28px 16px; text-align: center; color: var(--text); font-size: var(--fs-base); }
.load-failed p { margin: 0; max-width: 46ch; color: var(--text-muted); }
.load-failed strong { color: var(--status-red); font-weight: 600; }
.empty-filtered { display: flex; flex-direction: column; align-items: center; gap: 10px; }
/* Error and status lines keep their space, so nothing jumps when a message appears */
.field-error, .form-status { min-height: 20px; margin: 4px 0 0; font-size: var(--fs-base); }
.field-error { color: var(--status-red); }

/* ---- Bottom tab bar (phones and tablets, below 1024 px) ---- */
.tabbar { display: none; }
@media (max-width: 1023px) {
  :root { --tabbar-h: 60px; }
  .tabbar {
    display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); position: fixed; left: 0; right: 0; bottom: 0; z-index: 480;
    height: calc(var(--tabbar-h) + env(safe-area-inset-bottom, 0px)); padding-bottom: env(safe-area-inset-bottom, 0px);
    background: var(--panel-bg); border-top: 1px solid var(--border);
  }
  .tabbar button {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; min-width: 0; min-height: 44px;
    background: none; border: 0; padding: 0 2px; color: var(--text-muted); font-size: var(--fs-xs); font-weight: 600; cursor: pointer;
  }
  .tabbar button span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .tabbar button svg { width: 20px; height: 20px; }
  .tabbar button.active { color: var(--accent-fg); }
  .tabbar button:active { background: var(--panel-bg-2); }
  .content { padding-bottom: calc(var(--tabbar-h) + 28px); }
  #toast-box { left: 12px; right: 12px; max-width: none; bottom: calc(var(--tabbar-h) + 12px + env(safe-area-inset-bottom, 0px)); }
  #bi-ai-launcher { bottom: calc(var(--tabbar-h) + 14px + env(safe-area-inset-bottom, 0px)) !important; }
  body:has(#toast-box .toast) #bi-ai-launcher { opacity: 0; pointer-events: none; }
  .sidebar { padding-bottom: calc(var(--tabbar-h) + 12px); }
}
@media (max-width: 760px) {
  /* iOS zooms into any field under 16 px */
  input:not([type="checkbox"]):not([type="radio"]), select, textarea, .dt-input, .select-field { font-size: 16px !important; }
  .content { padding-left: 16px; padding-right: 16px; }
  .topbar { padding: 12px 16px; }
  /* Hit areas of at least 44 px, even where the drawn control is smaller */
  .icon-btn, .password-eye, .topbar-btn, .theme-toggle-btn, .alerts-btn, .avatar, .tic-send, [data-delete-comment], .emoji-sticker-btn, .dp-open { position: relative; }
  .icon-btn::after, .password-eye::after, .topbar-btn::after, .theme-toggle-btn::after, .alerts-btn::after, .avatar::after, .tic-send::after,
  [data-delete-comment]::after, .emoji-sticker-btn::after, .dp-open::after {
    content: ""; position: absolute; left: 50%; top: 50%; width: max(100%, 44px); height: max(100%, 44px); transform: translate(-50%, -50%);
  }
  .filters-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 420px) { .filters-grid { grid-template-columns: minmax(0, 1fr); } }
/* The segmented date field is a flex box of spans: pin it to the field height instead of padding + line-height. */
.dt-input { height: var(--h-md); padding-top: 0; padding-bottom: 0; align-items: center; }
/* Error lines keep their space: shown or not, a form never jumps when one appears. */
p[id$="-error"] { min-height: 20px; }
p[id$="-error"][style*="display:none"], p[id$="-error"][style*="display: none"] { display: block !important; visibility: hidden; }

/* ---- Spacing and layout helpers (replace repeated one-off inline styles; spacing steps 4 / 8 / 12 / 16) ---- */
.m-0 { margin: 0 !important; }
.mt-4 { margin-top: 4px !important; } .mt-8 { margin-top: 8px !important; } .mt-12 { margin-top: 12px !important; } .mt-16 { margin-top: 16px !important; }
.mb-8 { margin-bottom: 8px !important; } .mb-16 { margin-bottom: 16px !important; } .ml-8 { margin-left: 8px !important; }
.w-full { width: 100% !important; } .flex-1 { flex: 1 !important; } .text-right { text-align: right !important; }
.scroll-x { overflow-x: auto; overflow-y: hidden; }
.clickable { cursor: pointer; } .no-select { user-select: none; }
.text-red { color: var(--status-red) !important; } .text-green { color: var(--status-green) !important; }
.status-pill-blue { background: var(--status-blue-bg); color: var(--status-blue); }
/* Small actions inside rows and comments are the xs step */
.comment-item .icon-btn, td .icon-btn, .toll-set-row .icon-btn, .ru-type-row .icon-btn { width: var(--h-xs); height: var(--h-xs); padding: 0 !important; }
/* Phones: stat cards stack (a long figure must never spill past its card) */
@media (max-width: 600px) { .kpi-row, .kpi-row.dp-now { grid-template-columns: minmax(0, 1fr) !important; } .kpi-card { min-width: 0; } }

/* ---- Start-up: a neutral loading screen while a reload checks the sign-in and loads the data ---- */
.boot-screen {
  position: fixed; inset: 0; z-index: 2100; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px;
  background: var(--bg); color: var(--text-muted); font-size: var(--fs-md); font-weight: 500;
  opacity: 0; animation: ui-reveal var(--dur-base) var(--ease) 250ms forwards; /* a fast answer never flashes it */
}
.boot-screen[hidden] { display: none; }
.boot-screen img { width: 40px; height: auto; }

/* ---- Files open inside the app (js/platform.js) ---- */
.file-viewer .file-viewer-box { max-width: min(1100px, 96vw); height: min(90vh, 1000px); max-height: none; }
.file-viewer .modal-box-header .btn { min-height: var(--h-sm); }
.file-viewer-body { flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; background: var(--panel-bg-2); border-radius: 0 0 var(--radius-dialog) var(--radius-dialog); overflow: auto; }
.file-viewer-frame { width: 100%; height: 100%; border: 0; border-radius: 0 0 var(--radius-dialog) var(--radius-dialog); background: var(--panel-bg); }
.file-viewer-img { max-width: 100%; max-height: 100%; object-fit: contain; display: block; }
.file-viewer-body .skeleton-block, .file-viewer-body .load-failed { width: min(480px, 90%); }
/* ---- One scroll lock for every dialog (js/a11y.js): the page behind an open dialog doesn't scroll ---- */
.content { scrollbar-gutter: stable; } /* the scrollbar space never comes and goes */
html.dialog-open .content { overflow: hidden; }
.modal-box-body, .fullscreen-body { overscroll-behavior: contain; }

/* ---- P&L: "How this is counted" fold-outs and the 8-week chart (js/pl2.js) ---- */
.calc-note { margin-top: 8px; font-size: var(--fs-sm); color: var(--text-muted); }
.calc-note summary { cursor: pointer; color: var(--accent-fg); font-weight: 500; width: fit-content; }
.calc-note p { margin: 6px 0 0; line-height: 1.5; max-width: 60ch; }
.trend-card { grid-column: 1 / -1; }
.trend-chart { display: block; width: 100%; height: 120px; margin-top: 8px; overflow: visible; }
.trend-chart .trend-pos { fill: var(--status-green); }
.trend-chart .trend-neg { fill: var(--status-red); }
.trend-chart .trend-axis { stroke: var(--border); stroke-width: 1; vector-effect: non-scaling-stroke; }
.trend-chart .trend-label { fill: var(--text-muted); font-size: 11px; }
.dp-todo-n { min-width: 28px; text-align: right; font-variant-numeric: tabular-nums; }
/* P&L → Maintenance Log: one week split by who carries the repair cost (December 2026) */
.maint-split { margin-bottom: 16px; }
.maint-split .panel-header { justify-content: space-between; flex-wrap: wrap; }
.maint-split-grid { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: 20px; align-items: start; }
@media (max-width: 900px) { .maint-split-grid { grid-template-columns: minmax(0, 1fr); } }
.maint-split-table { width: 100%; font-variant-numeric: tabular-nums; }
.maint-split-table th, .maint-split-table td { padding: 6px 10px; }
.maint-split-total td { font-weight: 700; color: var(--text); }
/* Settings → Integrations (December 2026) */
.form-error { color: var(--status-red); font-size: 13px; min-height: 1.4em; margin: 8px 0 0; }
.int-steps { margin: 10px 0 14px; padding-left: 20px; line-height: 1.6; }
.int-form { display: flex; align-items: flex-end; gap: 10px; flex-wrap: wrap; max-width: 720px; }
.int-form .form-field { min-width: 260px; margin: 0; }
/* (#page-pl tables never wrap — line ~1449; the split names may, so the two tables fit side by side) */
#page-pl .maint-split-table td:first-child, #page-pl .maint-split-table th:first-child { white-space: normal; overflow-wrap: break-word; min-width: 9em; }
.maint-split-scroll { overflow-x: auto; min-width: 0; }
.maint-split .panel-header h2 { white-space: normal; flex: 1 1 200px; }
.maint-split .panel-header select { max-width: 100%; }
/* Trucks page (December 2026): status counts you can click, and the truck card */
.truck-counts { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.truck-count { display: inline-flex; align-items: center; gap: 8px; min-height: 38px; padding: 6px 12px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--panel-bg); color: var(--text); font: inherit; font-size: 13px; cursor: pointer; }
.truck-count b { font-variant-numeric: tabular-nums; font-size: 15px; }
.truck-count.active { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.truck-count:hover { background: var(--panel-bg-2); }
#trucks-table tbody tr.clickable { cursor: pointer; }
.truck-card-box { max-width: 560px; }
.truck-card-status { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.truck-status-form { grid-template-columns: minmax(0, 1fr) minmax(0, 2fr); }
@media (max-width: 600px) { .truck-status-form { grid-template-columns: minmax(0, 1fr); } }
