/* OPERATEOS — the one design system.
 *
 * The owner, 24 September 2026: "create one consistent design system so the
 * entire OperateOS feels like one premium, production-ready application rather
 * than pages built at different times."
 *
 * This sheet loads FIRST on every page — the sign-in, the workspace, the
 * entrance, every room, the Holding board, the driver's
 * page and the phone app. It does three things and nothing else:
 *
 *   1. TOKENS. One type scale, one spacing scale, one set of radii, shadows,
 *      motion curves, control heights and a focus ring, on `:root`. Two
 *      SURFACES share them: PAPER (the workspace: warm paper, emerald) and
 *      NIGHT (the office: navy glass, cyan edge-light). A page is one or the
 *      other; nothing else changes between them.
 *   2. MAPPING. Each page's own tokens (`--mr-*`, `--fd-*`, `--hb-*`)
 *      resolve from these, so the pages keep their names and their sheets and
 *      stop disagreeing about the font, the corner and the shadow.
 *   3. BASE BEHAVIOUR every page had written separately or forgotten: a
 *      visible focus ring, dark scrollbars on dark pages, honest disabled
 *      controls, thumb-sized targets on touch screens, no motion for people
 *      who asked for none, and the same empty / loading / notice components.
 *
 * Nothing here repaints a page's identity. Selectors stay at the lowest
 * specificity so a page's own rule always wins where it deliberately differs.
 */

:root {
  /* type */
  --os-font-sans: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --os-font-serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --os-font-mono: ui-monospace, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --os-text-xs: 11px;  --os-text-sm: 12px;  --os-text: 13px;  --os-text-md: 14px;
  --os-text-lg: 16px;  --os-text-xl: 19px;  --os-text-2xl: 24px;  --os-text-3xl: 30px;
  --os-lh-tight: 1.2;  --os-lh: 1.5;  --os-lh-loose: 1.65;
  --os-track-caps: .14em;
  /* space — a four-pixel grid */
  --os-1: 4px; --os-2: 8px; --os-3: 12px; --os-4: 16px; --os-5: 20px; --os-6: 24px; --os-8: 32px; --os-10: 40px; --os-12: 48px;
  /* shape */
  --os-r-sm: 6px; --os-r: 9px; --os-r-lg: 12px; --os-r-xl: 14px; --os-r-pill: 999px;
  /* motion */
  --os-fast: 120ms; --os-base: 200ms; --os-slow: 280ms; --os-ease: cubic-bezier(.2, .7, .2, 1);
  /* controls */
  --os-ctl-h: 36px; --os-ctl-h-sm: 30px; --os-ctl-h-lg: 44px; --os-touch: 44px;
  /* layers */
  --os-z-raised: 3; --os-z-sticky: 10; --os-z-drawer: 20; --os-z-modal: 40; --os-z-toast: 60;
  /* status — fixed for every surface and every tenant; a repaint could make
     an overdue filing look settled */
  --os-ok: #1B6B52; --os-ok-bg: rgba(27,107,82,.10);
  --os-warn: #C2410C; --os-warn-bg: rgba(194,65,12,.10);
  --os-stop: #DC2626; --os-stop-bg: rgba(220,38,38,.10);
  --os-info: #2563EB; --os-info-bg: rgba(37,99,235,.10);

  /* PAPER — the default surface */
  --os-bg: #F5F2EC; --os-bg-2: #EFEBE3; --os-panel: #FFFFFF; --os-panel-2: #FAFAF8;
  --os-line: #E2DDD5; --os-line-strong: #D4CFC6;
  --os-ink: #1A1A1A; --os-ink-2: #4A4A4A; --os-mute: #767676; --os-faint: #C0C0C0;
  --os-accent: #047857; --os-accent-h: #059669; --os-accent-ink: #065F46; --os-accent-tint: #D1FAE5; --os-on-accent: #FFFFFF;
  --os-shadow-sm: 0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
  --os-shadow: 0 4px 16px rgba(0,0,0,.08), 0 2px 6px rgba(0,0,0,.04);
  --os-shadow-lg: 0 20px 60px rgba(0,0,0,.15);
  --os-focus: 0 0 0 3px color-mix(in srgb, var(--os-accent) 30%, transparent);
  --os-scrollbar: rgba(0,0,0,.22);
}

/* NIGHT — the office: the entrance, every room, the Holding board. */
.mr-page, .fd-page, .hb-page, .os-night, body.night {
  --os-bg: #070b1a; --os-bg-2: #101838; --os-panel: rgba(12,20,46,.82); --os-panel-2: rgba(8,14,34,.86);
  --os-line: rgba(138,196,255,.22); --os-line-strong: rgba(138,196,255,.44);
  --os-ink: #eaf1ff; --os-ink-2: #b9c9ee; --os-mute: #8595c4; --os-faint: rgba(133,149,196,.5);
  --os-accent: #5aa9ff; --os-accent-h: #8ac6ff; --os-accent-ink: #cfe6ff; --os-accent-tint: rgba(90,169,255,.16); --os-on-accent: #061021;
  --os-gold: #f0c35a; --os-miss: #e0705f;
  --os-shadow-sm: 0 6px 18px rgba(0,0,0,.35);
  --os-shadow: 0 18px 50px rgba(0,0,0,.55), inset 0 1px 0 rgba(180,215,255,.16);
  --os-shadow-lg: 0 24px 70px rgba(0,0,0,.65);
  --os-focus: 0 0 0 3px rgba(150,236,255,.35);
  --os-scrollbar: rgba(138,196,255,.28);
  --os-ok: #9fe9b8; --os-ok-bg: rgba(150,240,190,.12);
  --os-warn: #ffe9b8; --os-warn-bg: rgba(255,224,150,.12);
  --os-stop: #ffd2c8; --os-stop-bg: rgba(255,150,135,.14);
  --os-info: #cfe6ff; --os-info-bg: rgba(90,169,255,.14);
  color-scheme: dark;
}

/* ── MAPPING: the pages' own names, one source of truth ─────────────────── */
.mr-page { --mr-sans: var(--os-font-sans); --mr-serif: var(--os-font-serif); --mr-mono: var(--os-font-mono);
  --mr-bg: var(--os-bg); --mr-panel: var(--os-panel); --mr-line: var(--os-line); --mr-line2: var(--os-line-strong);
  --mr-ink: var(--os-ink); --mr-ink2: var(--os-ink-2); --mr-mute: var(--os-mute); --mr-accent: var(--os-accent); --mr-gold: var(--os-gold); --mr-miss: var(--os-miss); }
.fd-page { --fd-sans: var(--os-font-sans); --fd-mono: var(--os-font-mono);
  --fd-bg: var(--os-bg); --fd-line: var(--os-line); --fd-ink: var(--os-ink); --fd-ink2: var(--os-ink-2); --fd-mute: var(--os-mute); }
.hb-page { --hb-sans: var(--os-font-sans); --hb-mono: var(--os-font-mono); --hb-serif: var(--os-font-serif);
  --hb-bg: var(--os-bg); --hb-ink: var(--os-ink); }

/* ── BASE ───────────────────────────────────────────────────────────────── */
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body { font-family: var(--os-font-sans); -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }
button, input, select, textarea { font-family: inherit; }
[hidden] { display: none !important; }
img, svg, video { max-width: 100%; }

/* A visible focus ring on every page, for the keyboard only — a mouse click
   does not light it. Pages that draw their own ring keep it (theirs is more
   specific). */
:where(a, button, input, select, textarea, summary, [tabindex]):focus-visible {
  outline: 2px solid var(--os-accent); outline-offset: 2px; }
:where(input, select, textarea):focus-visible { outline: none; box-shadow: var(--os-focus); }

/* A disabled control says so, the same way everywhere. */
:where(button, input, select, textarea, a):is(:disabled, [aria-disabled="true"]) {
  cursor: not-allowed; opacity: .55; }
:where(button, [role="button"]):not(:disabled) { cursor: pointer; }
:where(button, [role="button"], a).os-busy, :where(button).busy { position: relative; pointer-events: none; }

/* Selection and scrollbars follow the surface. */
::selection { background: color-mix(in srgb, var(--os-accent) 28%, transparent); }
* { scrollbar-width: thin; scrollbar-color: var(--os-scrollbar) transparent; }
*::-webkit-scrollbar { width: 6px; height: 6px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb { background: var(--os-scrollbar); border-radius: 3px; }

/* On a touch screen every primary control is a thumb's size. A page's small
   secondary keys (a tuck, a close) are left alone. */
@media (pointer: coarse) {
  :where(.fd-btn, .fd-go, .mr-btn, .hb-btn, .dlv-btn, .primary, button.primary, .btn, .cp-seg button, .tab, .fd-key, .mr-key) { min-height: var(--os-touch); }
  :where(input:not([type="checkbox"]):not([type="radio"]), select) { min-height: var(--os-ctl-h-lg); }
  :where(input, select, textarea) { font-size: max(16px, 1em); }   /* under 16px iOS zooms the page on focus */
}

/* Motion is a courtesy, never a requirement. */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
}

/* ── COMPONENTS every page may use ──────────────────────────────────────── */
/* An eyebrow: the small tracked label over a title. */
.os-eyebrow { font: 600 var(--os-text-xs) / 1.2 var(--os-font-sans); letter-spacing: var(--os-track-caps); text-transform: uppercase; color: var(--os-mute); margin: 0 0 var(--os-2); }

/* The empty state: an icon, one line of what is here, one line of what to do,
   one action — the same on paper and at night. */
.os-empty { display: grid; justify-items: center; text-align: center; gap: var(--os-2); padding: var(--os-10) var(--os-4); color: var(--os-ink-2); }
.os-empty i { width: 44px; height: 44px; border-radius: var(--os-r-lg); display: grid; place-items: center; font: 600 18px var(--os-font-sans); font-style: normal;
  color: var(--os-mute); background: color-mix(in srgb, var(--os-accent) 10%, var(--os-panel)); border: 1px solid var(--os-line); margin-bottom: var(--os-1); }
.os-empty h3 { margin: 0; font: 600 var(--os-text-md) / var(--os-lh-tight) var(--os-font-sans); color: var(--os-ink); }
.os-empty p { margin: 0; max-width: 42ch; font-size: var(--os-text); line-height: var(--os-lh); color: var(--os-mute); }
.os-empty > :is(button, a) { margin-top: var(--os-2); }

/* The loading state: a shimmer the shape of what is coming, never a bare word. */
.os-skeleton { display: block; height: 1em; border-radius: var(--os-r-sm); background: linear-gradient(90deg, color-mix(in srgb, var(--os-ink) 7%, transparent) 25%, color-mix(in srgb, var(--os-ink) 13%, transparent) 50%, color-mix(in srgb, var(--os-ink) 7%, transparent) 75%);
  background-size: 200% 100%; animation: os-shimmer 1.4s linear infinite; }
.os-skeleton.line { width: 100%; }
.os-skeleton.short { width: 55%; }
.os-skeleton.title { height: 1.4em; width: 40%; margin-bottom: var(--os-2); }
.os-skeleton.card { height: 56px; border-radius: var(--os-r-lg); }
.os-skeletons { display: grid; gap: var(--os-2); }
@keyframes os-shimmer { to { background-position: -200% 0; } }

/* The notice — a toast, fixed low on the page; a tone says what kind. */
.os-toast { position: fixed; left: 50%; bottom: max(18px, env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: var(--os-z-toast); max-width: min(92vw, 520px);
  padding: 10px 14px; border-radius: var(--os-r); font: 500 var(--os-text) / var(--os-lh) var(--os-font-sans); color: var(--os-ink);
  background: var(--os-panel); border: 1px solid var(--os-line-strong); box-shadow: var(--os-shadow); animation: os-rise var(--os-slow) var(--os-ease); }
.os-toast.ok { border-color: var(--os-ok); background: var(--os-ok-bg); }
.os-toast.warn { border-color: var(--os-warn); background: var(--os-warn-bg); }
.os-toast.stop, .os-toast.error { border-color: var(--os-stop); background: var(--os-stop-bg); }
@keyframes os-rise { from { opacity: 0; transform: translate(-50%, 8px); } }

/* A state pill. */
.os-badge { display: inline-flex; align-items: center; gap: 6px; padding: 2px 8px; border-radius: var(--os-r-pill); font: 600 var(--os-text-xs) / 1.6 var(--os-font-sans); letter-spacing: .04em; text-transform: uppercase; border: 1px solid transparent; }
.os-badge.ok { color: var(--os-ok); background: var(--os-ok-bg); border-color: color-mix(in srgb, var(--os-ok) 40%, transparent); }
.os-badge.warn { color: var(--os-warn); background: var(--os-warn-bg); border-color: color-mix(in srgb, var(--os-warn) 40%, transparent); }
.os-badge.stop { color: var(--os-stop); background: var(--os-stop-bg); border-color: color-mix(in srgb, var(--os-stop) 40%, transparent); }
.os-badge.info { color: var(--os-info); background: var(--os-info-bg); border-color: color-mix(in srgb, var(--os-info) 40%, transparent); }
.os-badge.live::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; animation: os-pulse 1.6s ease-in-out infinite; }
@keyframes os-pulse { 50% { opacity: .35; } }

/* Keyboard hint. */
.os-kbd { font: 500 var(--os-text-xs) / 1 var(--os-font-mono); padding: 2px 5px; border-radius: 4px; border: 1px solid var(--os-line-strong); color: var(--os-mute); background: var(--os-panel-2); }

/* Screen-reader only. */
.os-sr { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
