/* CarsRefer ธีม Quest — the one stylesheet of index.html (2026-11-21, user: "พลิกโฉม" after Dribbble JobQuest by Arounda;
   spec cars/docs/superpowers/specs/2026-11-21-carsrefer-quest-theme-design.md). Written new: it replaces console, glossy,
   sneat, tactile3d and dashboard-motion (and legacy's layers) instead of being stacked on them.
   Order: fonts → tokens → base → layout → components → views → print → reduced motion.
   Rules: WCAG AA for every text; triage and vehicle-state colours keep their meaning; no !important outside print and
   reduced motion. live.html keeps its own sheets and is not styled here. */

/* ---------- fonts: Inter (latin) + IBM Plex Sans Thai, served from /fonts ---------- */
@font-face { font-family: 'Inter'; font-style: normal; font-weight: 400; font-display: swap;
  src: url('../fonts/Inter-latin-ext.woff2') format('woff2'); unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: 'Inter'; font-style: normal; font-weight: 400; font-display: swap;
  src: url('../fonts/Inter-latin.woff2') format('woff2'); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: 'Inter'; font-style: normal; font-weight: 500; font-display: swap;
  src: url('../fonts/Inter-latin-ext.woff2') format('woff2'); unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: 'Inter'; font-style: normal; font-weight: 500; font-display: swap;
  src: url('../fonts/Inter-latin.woff2') format('woff2'); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: 'Inter'; font-style: normal; font-weight: 600; font-display: swap;
  src: url('../fonts/Inter-latin-ext.woff2') format('woff2'); unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: 'Inter'; font-style: normal; font-weight: 600; font-display: swap;
  src: url('../fonts/Inter-latin.woff2') format('woff2'); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: 'Inter'; font-style: normal; font-weight: 700; font-display: swap;
  src: url('../fonts/Inter-latin-ext.woff2') format('woff2'); unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: 'Inter'; font-style: normal; font-weight: 700; font-display: swap;
  src: url('../fonts/Inter-latin.woff2') format('woff2'); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: 'IBM Plex Sans Thai'; font-style: normal; font-weight: 400; font-display: swap;
  src: url('../fonts/IBMPlexSansThai-400-thai.woff2') format('woff2'); unicode-range: U+02D7, U+0303, U+0331, U+0E01-0E5B, U+200C-200D, U+25CC; }
@font-face { font-family: 'IBM Plex Sans Thai'; font-style: normal; font-weight: 400; font-display: swap;
  src: url('../fonts/IBMPlexSansThai-400-latin-ext.woff2') format('woff2'); unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: 'IBM Plex Sans Thai'; font-style: normal; font-weight: 400; font-display: swap;
  src: url('../fonts/IBMPlexSansThai-400-latin.woff2') format('woff2'); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: 'IBM Plex Sans Thai'; font-style: normal; font-weight: 500; font-display: swap;
  src: url('../fonts/IBMPlexSansThai-500-thai.woff2') format('woff2'); unicode-range: U+02D7, U+0303, U+0331, U+0E01-0E5B, U+200C-200D, U+25CC; }
@font-face { font-family: 'IBM Plex Sans Thai'; font-style: normal; font-weight: 500; font-display: swap;
  src: url('../fonts/IBMPlexSansThai-500-latin-ext.woff2') format('woff2'); unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: 'IBM Plex Sans Thai'; font-style: normal; font-weight: 500; font-display: swap;
  src: url('../fonts/IBMPlexSansThai-500-latin.woff2') format('woff2'); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: 'IBM Plex Sans Thai'; font-style: normal; font-weight: 600; font-display: swap;
  src: url('../fonts/IBMPlexSansThai-600-thai.woff2') format('woff2'); unicode-range: U+02D7, U+0303, U+0331, U+0E01-0E5B, U+200C-200D, U+25CC; }
@font-face { font-family: 'IBM Plex Sans Thai'; font-style: normal; font-weight: 600; font-display: swap;
  src: url('../fonts/IBMPlexSansThai-600-latin-ext.woff2') format('woff2'); unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: 'IBM Plex Sans Thai'; font-style: normal; font-weight: 600; font-display: swap;
  src: url('../fonts/IBMPlexSansThai-600-latin.woff2') format('woff2'); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: 'IBM Plex Sans Thai'; font-style: normal; font-weight: 700; font-display: swap;
  src: url('../fonts/IBMPlexSansThai-700-thai.woff2') format('woff2'); unicode-range: U+02D7, U+0303, U+0331, U+0E01-0E5B, U+200C-200D, U+25CC; }
@font-face { font-family: 'IBM Plex Sans Thai'; font-style: normal; font-weight: 700; font-display: swap;
  src: url('../fonts/IBMPlexSansThai-700-latin-ext.woff2') format('woff2'); unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: 'IBM Plex Sans Thai'; font-style: normal; font-weight: 700; font-display: swap;
  src: url('../fonts/IBMPlexSansThai-700-latin.woff2') format('woff2'); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }

/* Sarabun: the paper forms only (ใบตรวจเช็ครถ, บันทึกการใช้รถ: 16pt like HOSOffice's own forms, reports.js waits for it) */
@font-face { font-family: 'Sarabun'; font-style: normal; font-weight: 400; font-display: swap; src: url('../fonts/Sarabun-400-thai.woff2') format('woff2'); unicode-range: U+02D7, U+0303, U+0331, U+0E01-0E5B, U+200C-200D, U+25CC; }
@font-face { font-family: 'Sarabun'; font-style: normal; font-weight: 400; font-display: swap; src: url('../fonts/Sarabun-400-latin.woff2') format('woff2'); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: 'Sarabun'; font-style: normal; font-weight: 700; font-display: swap; src: url('../fonts/Sarabun-700-thai.woff2') format('woff2'); unicode-range: U+02D7, U+0303, U+0331, U+0E01-0E5B, U+200C-200D, U+25CC; }
@font-face { font-family: 'Sarabun'; font-style: normal; font-weight: 700; font-display: swap; src: url('../fonts/Sarabun-700-latin.woff2') format('woff2'); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }

/* ---------- tokens ---------- */
:root {
  --font: 'Inter', 'IBM Plex Sans Thai', system-ui, sans-serif;
  --bg: #EBEFF5;               /* 2026-11-26 "หน้าอื่นก็ปรับด้วย": a darker page grey so white cards stand out (was #F5F7FA) */
  --card: #FFFFFF;
  --line: #DCE3EC;             /* card edges a step darker (was #E8ECF2) */
  --ink: #0F172A;
  --muted: #566579;            /* the reference's #64748B is 4.43:1 on the page grey; this keeps AA (≥ 4.87:1) on white, grey and every pastel tint */
  --primary: #2563EB;
  --primary-hover: #1D4ED8;
  --primary-soft: #EFF4FF;
  /* the banner: indigo → blue → teal, each stop ≥ 5:1 with white (the reference's brighter #4F6BFF/#3DDBB4 fail AA for
     normal text) */
  --hero: linear-gradient(100deg, #4F46E5 0%, #2563EB 52%, #0F766E 100%);
  /* buttons keep their 3D depth (user 2026-11-21): a lit top edge, a solid ledge under them, a soft shadow; pressed they
     sink by the ledge */
  --key-blue: inset 0 2px 0 rgba(255, 255, 255, .32), 0 4px 0 #1E3A8A, 0 10px 20px -6px rgba(37, 99, 235, .5);
  --key-blue-down: inset 0 2px 0 rgba(255, 255, 255, .2), 0 1px 0 #1E3A8A;
  --key-white: inset 0 2px 0 #FFFFFF, 0 3px 0 #D3DCEA, 0 8px 16px -8px rgba(15, 23, 42, .18);
  --key-white-down: inset 0 1px 0 #FFFFFF, 0 1px 0 #D3DCEA;
  /* names the inline styles in index.html and app.js use */
  --text-muted: var(--muted); --text-subtle: var(--muted); --border-divider: var(--line);
  --font-mono: var(--font); --radius-sm: 8px; --radius-md: 12px;
  /* mission types (badge dots, chips, charts) */
  --type-refer: #2a78d6; --type-ems: #eb6834; --type-mobile: #1baf7a; --type-staff: #eda100; --type-lab: #e87ba4;
  --chip-blue-bg: #E0F2FE;   --chip-blue-fg: #0369A1;
  --chip-pink-bg: #FCE7F3;   --chip-pink-fg: #BE185D;
  --chip-purple-bg: #F3E8FF; --chip-purple-fg: #7E22CE;
  --chip-green-bg: #DCFCE7;  --chip-green-fg: #15803D;
  --chip-orange-bg: #FFEDD5; --chip-orange-fg: #C2410C;
  --chip-red-bg: #FEE2E2;    --chip-red-fg: #B91C1C;
  /* colours with a meaning: case severity and vehicle state (unchanged hues) */
  --triage-red: #DC2626; --triage-pink: #DB2777; --triage-yellow: #CA8A04; --triage-green: #16A34A;
  --state-out: #DC2626; --state-at: #D97706; --state-back: #16A34A; --state-ready: #FFFFFF;
  /* fleet state on vehicle cards, chips and rows: text on its tint (AA), and the card's left edge */
  --ready: #1D4ED8;   --ready-bg: #EFF4FF;   --ready-edge: #2563EB;
  --duty: #92400E;    --duty-bg: #FEF3C7;    --duty-edge: #D97706;
  --mission: #B91C1C; --mission-bg: #FEE2E2; --mission-edge: #DC2626;
  --done: #15803D;    --done-bg: #DCFCE7;    --off-edge: #6B7280;
  --soft: #F1F5F9;    --line-strong: #D3DCEA;
  --tabbar-h: 68px; --topbar-h: 60px;
  /* charts whose colours carry no meaning (app.js chartColor/chartText; mission types keep their own colours) */
  --chart-1: #2563EB; --chart-2: #22C55E; --chart-3: #A855F7; --chart-4: #F97316; --chart-5: #0EA5A4; --chart-6: #EC4899;
  --chart-7: #64748B; --chart-text: #566579;
  /* dashboard figures count up once, this long (dashboard-motion.js) */
  --count-up-ms: 250;
  --r-card: 20px;
  --r-inner: 14px;
  --r-pill: 999px;
  --shadow: 0 1px 2px rgba(15, 23, 42, .06), 0 8px 22px -8px rgba(15, 23, 42, .16);  /* was .04: cards lifted off the page */
  --shadow-lift: 0 10px 26px rgba(15, 23, 42, .08);
  --space-1: 4px; --space-2: 8px; --space-3: 12px; --space-4: 16px; --space-5: 20px; --space-6: 24px; --space-8: 32px;
  --fs-page: 32px; --fs-card: 18px; --fs-body: 15px; --fs-small: 13px;
}
/* phones and tablets: darker secondary words (user 2026-11-03, "พื้นขาวทำให้อ่านยาก"), 7.6:1 on white */
@media (max-width: 1023.98px) {
  :root { --muted: #475569; }
}

/* ---------- base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; color-scheme: light; }   /* one light theme: native pickers and lists stay light on a dark-mode phone */
::selection { background: rgba(37, 99, 235, .25); }
body {
  margin: 0;
  font-family: var(--font);
  font-size: var(--fs-body);
  line-height: 1.5;
  color: var(--ink);
  background: var(--bg);
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; }
button { color: inherit; }
a { color: var(--primary); }
img, svg { max-width: 100%; }
h1, h2, h3, h4 { margin: 0; font-weight: 600; line-height: 1.25; }
/* the hidden attribute always hides: one class-and-an-id strong rule instead of an X[hidden] for every component that sets a
   display. Only a rule with an id written after it can show a hidden element (the admin menu column, Task 7) */
[hidden]:not(#_) { display: none; }
/* read by screen readers, not shown */
.sr-only {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.icon {
  width: 20px; height: 20px; flex-shrink: 0;
  fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round;
}
.nowrap { white-space: nowrap; }
:focus-visible { outline: 3px solid var(--primary); outline-offset: 2px; }   /* 5.2:1 on white (WCAG 2.4.11) */

/* ---------- layout: the shell ---------- */
/* views: one shows at a time (app.js proceedSwitchView puts .active on it) */
.view-section { display: none; }
.view-section.active { display: block; }

.app-sidebar, .app-topbar, .app-tabbar { display: none; }

#app-main-layout > .main-content { padding: var(--space-6) var(--space-8) var(--space-8); }

/* sidebar from 1024px: white, the logo on top, menu items with their names, the chosen one a blue rounded bar */
@media screen and (min-width: 1024px) {
  .app-sidebar {
    position: fixed; inset: 0 auto 0 0; z-index: 30; width: 248px;
    display: flex; flex-direction: column; gap: var(--space-5);
    padding: var(--space-5) var(--space-4);
    overflow-y: auto; background: var(--card); border-right: 1px solid var(--line);
  }
  #app-main-layout > .main-content, #app-main-layout > .app-footer { margin-left: 248px; }
}
.app-brand { display: flex; align-items: center; gap: var(--space-3); padding: var(--space-1) var(--space-2); color: var(--ink); text-decoration: none; }
.app-brand img, .app-topbar img { width: 38px; height: 38px; border-radius: 50%; object-fit: contain; background: var(--card); }
.app-brand-text { display: flex; flex-direction: column; line-height: 1.25; }
.app-brand-text strong { font-size: 17px; font-weight: 700; letter-spacing: -.01em; }
.app-brand-text span { font-size: var(--fs-small); color: var(--muted); }
.sidebar-nav { display: flex; flex-direction: column; gap: var(--space-4); }
.sidebar-group { display: flex; flex-direction: column; gap: 2px; }
.sidebar-heading { margin: 0 0 var(--space-1); padding: 0 var(--space-3); font-size: 12px; font-weight: 600; color: var(--muted); }
.sidebar-link {
  display: flex; align-items: center; gap: var(--space-3); min-height: 44px; padding: 0 var(--space-3);
  border-radius: var(--r-inner); color: #334155; font-size: 15px; font-weight: 500; text-decoration: none;
  transition: background-color .15s, color .15s;
}
.sidebar-link .icon { color: var(--muted); }
.sidebar-link:hover { background: var(--primary-soft); color: var(--primary); }
.sidebar-link:hover .icon { color: var(--primary); }
.sidebar-link.active, .sidebar-link[aria-current="page"] {
  background: var(--primary); color: #FFFFFF; font-weight: 600; box-shadow: var(--key-blue);
}
.sidebar-link.active .icon, .sidebar-link[aria-current="page"] .icon { color: #FFFFFF; }
.sidebar-account {
  margin-top: auto; display: flex; flex-direction: column; gap: var(--space-2);
  padding-top: var(--space-4); border-top: 1px solid var(--line);
}
.sidebar-user { padding: 0 var(--space-2) var(--space-1); font-size: var(--fs-small); color: var(--muted); }
#header-driver-name { display: flex; flex-direction: column; gap: 2px; overflow-wrap: anywhere; }
#header-driver-name strong { color: var(--ink); font-size: 14px; font-weight: 600; }
#header-driver-name small { font-size: 12px; }
.sidebar-action {
  display: flex; align-items: center; gap: var(--space-3); min-height: 40px; padding: 0 var(--space-3);
  border: 1px solid var(--line); border-radius: var(--r-pill); background: var(--card); color: #334155;
  font-size: 14px; text-align: left; cursor: pointer; box-shadow: var(--key-white); transition: box-shadow .12s, transform .12s;
}
.sidebar-action:hover { color: var(--primary); }
.sidebar-action:active { transform: translateY(3px); box-shadow: var(--key-white-down); }
.sidebar-action .icon { width: 18px; height: 18px; color: var(--muted); }

/* below 1024px: a top bar, a tab bar at the bottom and the menu sheet */
@media screen and (max-width: 1023.98px) {
  .app-topbar {
    position: sticky; top: 0; z-index: 30; height: var(--topbar-h);
    display: flex; align-items: center; gap: var(--space-3); padding: 0 var(--space-4);
    background: rgba(255, 255, 255, .92); border-bottom: 1px solid var(--line);
    -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  }
  .app-tabbar {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
    height: calc(var(--tabbar-h) + env(safe-area-inset-bottom)); padding: 0 var(--space-2) env(safe-area-inset-bottom);
    display: grid; grid-template-columns: repeat(4, minmax(0, 1fr));
    background: var(--card); border-top: 1px solid var(--line); box-shadow: 0 -6px 18px rgba(15, 23, 42, .05);
  }
  #app-main-layout > .main-content { padding: var(--space-4) var(--space-4) calc(84px + env(safe-area-inset-bottom)); }
  #app-main-layout > .app-footer { padding-bottom: calc(84px + env(safe-area-inset-bottom)); }
}
.app-topbar-title { flex: 1; min-width: 0; overflow: hidden; font-size: 17px; font-weight: 700; white-space: nowrap; text-overflow: ellipsis; }
.app-topbar-user { display: flex; align-items: center; gap: var(--space-2); min-width: 0; }
.app-topbar-avatar {
  display: grid; place-items: center; flex-shrink: 0; width: 36px; height: 36px; border-radius: 50%;
  background: var(--primary-soft); color: var(--primary); font-size: 14px; font-weight: 700;
}
.app-topbar-name { max-width: 30vw; overflow: hidden; font-size: 14px; font-weight: 500; white-space: nowrap; text-overflow: ellipsis; }
.app-topbar-logout {
  display: grid; place-items: center; flex-shrink: 0; width: 44px; height: 44px; border: 1px solid var(--line); border-radius: 50%;
  background: var(--card); color: #334155; cursor: pointer; box-shadow: var(--key-white);
}
.tabbar-link {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; min-height: 56px;
  margin: 6px 2px; border: 0; border-radius: var(--r-inner); background: transparent;
  color: var(--muted); font-size: 12px; font-weight: 500; text-decoration: none; cursor: pointer;
}
.tabbar-link .icon { width: 22px; height: 22px; }
.tabbar-link.active, .tabbar-link[aria-current="page"], .tabbar-link[aria-expanded="true"] { color: var(--primary); font-weight: 600; background: var(--primary-soft); }

.nav-sheet-backdrop { position: fixed; inset: 0; z-index: 59; background: rgba(15, 23, 42, .35); }
.nav-sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 60; max-height: 80dvh; overflow-y: auto;
  display: flex; flex-direction: column; gap: var(--space-1);
  padding: var(--space-2) var(--space-3) calc(var(--space-4) + env(safe-area-inset-bottom));
  border-radius: var(--r-card) var(--r-card) 0 0; background: var(--card); box-shadow: 0 -10px 30px rgba(15, 23, 42, .15);
}
.nav-sheet-handle { width: 40px; height: 4px; margin: var(--space-1) auto var(--space-2); border-radius: 2px; background: var(--line); }
.sheet-link {
  display: flex; align-items: center; gap: var(--space-3); min-height: 48px; padding: 0 var(--space-3);
  border: 0; border-radius: var(--r-inner); background: transparent; color: var(--ink);
  font-size: 15px; text-align: left; text-decoration: none; cursor: pointer;
}
.sheet-link .icon { color: var(--primary); }
.sheet-link:hover, .sheet-link.active { background: var(--primary-soft); }
.nav-sheet-divider { height: 1px; margin: var(--space-2) 0; background: var(--line); }

/* each view's title row: the page name big on the left, the view's buttons on the right */
.page-head {
  display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: var(--space-4);
  margin-bottom: var(--space-5);
}
.page-head-text { min-width: 0; }
.page-head h2 { font-size: var(--fs-page); font-weight: 600; letter-spacing: -.02em; color: var(--ink); }
.page-head p { margin: var(--space-1) 0 0; color: var(--muted); }
.page-actions { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); }
/* ประวัติภารกิจ, จัดการระบบ, รายงาน (user 2026-11-26 "หน้าอื่นด้วย"): a banner like ศูนย์สั่งการ / แดชบอร์ด, each page its own
   colours; every stop keeps white words ≥ 4.5:1 */
#view-archive > .page-head,
#view-admin > .page-head,
#view-reports > .reports-head {
  padding: var(--space-6);
  border-radius: var(--r-card);
  background: var(--page-banner);
  box-shadow: 0 14px 30px -12px rgba(15, 23, 42, .4);
}
#view-archive > .page-head { --page-banner: linear-gradient(100deg, #334155 0%, #4338CA 58%, #6D28D9 100%); }
#view-admin > .page-head { --page-banner: linear-gradient(100deg, #9D174D 0%, #C2410C 60%, #B45309 100%); }
#view-reports > .reports-head { --page-banner: linear-gradient(100deg, #0F766E 0%, #15803D 55%, #3F6212 100%); }
:is(#view-archive, #view-admin) > .page-head :is(h2, p),
#view-reports > .reports-head :is(h2, p) {
  color: #FFFFFF;
}
/* on a phone the secondary buttons keep only their icon (and aria-label) beside the title; the main one takes a full row */
@media screen and (max-width: 767.98px) {
  .page-head { align-items: center; gap: var(--space-3); }
  .page-head-text { flex: 1 1 0; }
  .page-actions { display: contents; }
  .page-actions .btn-label { display: none; }
  .page-actions .btn-outline { width: 44px; padding: 0; }
  .page-actions .btn-primary { flex: 1 0 100%; }
}

.app-footer { margin-top: var(--space-6); padding: var(--space-4); border-top: 1px solid var(--line); color: var(--muted); font-size: var(--fs-small); text-align: center; }
.app-footer strong { color: var(--ink); }
.app-footer-credit { margin-top: 2px; font-size: 12px; }
.app-footer-dev { color: #15803D; font-weight: 600; }
body.driver-night-mode .app-footer-dev { color: #4ADE80; }

/* ---------- components ---------- */
/* buttons: pills with 3D depth (user 2026-11-21); primary blue, outline white; .btn-icon round; .btn-round-go the
   reference's round arrow. Pressed, a key sinks by its ledge */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
  min-height: 40px; padding: 0 var(--space-4); border: 1px solid transparent; border-radius: var(--r-pill);
  font-size: 14px; font-weight: 600; line-height: 1.2; text-decoration: none; cursor: pointer;
  transition: background-color .15s, border-color .15s, color .15s, box-shadow .12s, transform .12s;
}
.btn-primary { background: var(--primary); color: #FFFFFF; box-shadow: var(--key-blue); }
.btn-primary:hover { background: var(--primary-hover); }
.btn-outline { background: var(--card); color: var(--ink); border-color: var(--line); box-shadow: var(--key-white); }
.btn-outline:hover { border-color: #C7D2FE; color: var(--primary); }
.btn-danger { background: var(--chip-red-fg); color: #FFFFFF; box-shadow: inset 0 2px 0 rgba(255, 255, 255, .28), 0 4px 0 #7F1D1D; }
.btn-success { background: var(--chip-green-fg); color: #FFFFFF; box-shadow: inset 0 2px 0 rgba(255, 255, 255, .28), 0 4px 0 #14532D; }
.btn-icon { width: 40px; padding: 0; }
.btn-round-go {
  display: inline-grid; place-items: center; width: 40px; height: 40px; border: 0; border-radius: 50%; color: #FFFFFF;
  background: linear-gradient(135deg, #3B82F6, #1D4ED8); box-shadow: var(--key-blue); cursor: pointer;
  transition: box-shadow .12s, transform .12s;
}
.btn:active:not(:disabled), .btn-round-go:active { transform: translateY(3px); }
.btn-primary:active:not(:disabled), .btn-round-go:active { box-shadow: var(--key-blue-down); }
.btn-outline:active:not(:disabled) { box-shadow: var(--key-white-down); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .5; cursor: not-allowed; box-shadow: none; }
@media screen and (max-width: 1023.98px) {
  .btn { min-height: 44px; }
  .btn-icon, .btn-round-go { width: 44px; height: 44px; }
}

/* cards: the old .glass-card panels become the reference's white cards */
.glass-card, .card {
  position: relative; background: var(--card); border: 1px solid var(--line); border-radius: var(--r-card);
  box-shadow: var(--shadow); padding: var(--space-5);
}

/* driver portraits (thumbs in lists and tables, the vehicle card's driver): a framed square that shows the whole photo; the
   emoji or icon centred when there is none (their base rules lived in ios.css/style.css, 2026-11-21 fix) */
.driver-avatar-thumb, .driver-avatar-fleet {
  box-sizing: border-box; display: inline-flex; flex-shrink: 0; align-items: center; justify-content: center; overflow: hidden;
  padding: 2px; border: 1px solid var(--line); border-radius: 10px; background: var(--soft); font-size: 1.15rem; line-height: 1;
  vertical-align: middle;
}
.driver-avatar-thumb { width: 40px; height: 40px; }
.driver-avatar-fleet { width: 44px; height: 44px; border-color: #86EFAC; }
.driver-avatar-fleet.inactive { border-color: var(--line); }
:is(.driver-avatar-thumb, .driver-avatar-fleet) img {
  display: block; width: 100%; height: 100%; border-radius: 8px; object-fit: contain; background: #F8FAFC;
}

/* dialogs, the base (pulled forward from Task 7, which lays out the forms inside): hidden until .active, a dimmed layer over
   the whole app, a white box that scrolls; below 1024px a sheet from the bottom */
.modal-overlay, .modal {
  position: fixed; inset: 0; z-index: 2000; display: none; align-items: center; justify-content: center;
  padding: var(--space-4); background: rgba(15, 23, 42, .45);
}
.modal-overlay.active, .modal.active { display: flex; }
.modal-box, .modal-content {
  width: 100%; max-width: 640px; max-height: 90dvh; overflow-y: auto;
  background: var(--card); color: var(--ink); border: 1px solid var(--line); border-radius: var(--r-card);
  box-shadow: 0 24px 60px -12px rgba(15, 23, 42, .35);
}
.modal-header {
  display: flex; align-items: center; justify-content: space-between; gap: var(--space-3);
  padding: var(--space-4) var(--space-5); border-bottom: 1px solid var(--line);
}
.modal-body { padding: var(--space-5); }
.modal-footer {
  display: flex; flex-wrap: wrap; justify-content: flex-end; gap: var(--space-3);
  padding: var(--space-4) var(--space-5); border-top: 1px solid var(--line);
}
@media screen and (max-width: 1023.98px) {
  .modal-overlay, .modal { align-items: flex-end; padding: 0; }
  .modal-box, .modal-content { max-width: none; max-height: calc(100dvh - 24px); border-radius: var(--r-card) var(--r-card) 0 0; }
}

/* toasts (showToast): white cards at the bottom right, a 4px stripe in the meaning's colour; below 1024px across the screen
   above the tab bar */
.toast-container {
  position: fixed; right: var(--space-4); bottom: var(--space-4); z-index: 3000; display: grid; gap: var(--space-2);
  width: min(380px, calc(100vw - 2 * var(--space-4))); pointer-events: none;
}
.toast {
  padding: 12px 16px; border: 1px solid var(--line); border-left: 4px solid var(--primary); border-radius: var(--r-inner);
  background: var(--card); color: var(--ink); font-size: 14px; font-weight: 500; line-height: 1.45; overflow-wrap: anywhere;
  box-shadow: var(--shadow-lift); pointer-events: auto; animation: toast-in .2s ease;
}
.toast.success { border-left-color: var(--done); }
.toast.error { border-left-color: var(--mission-edge); }
.toast.warning { border-left-color: var(--duty-edge); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }
@media (prefers-reduced-motion: reduce) {
  .toast { animation: none; }
}
@media screen and (max-width: 1023.98px) {
  .toast-container { right: var(--space-3); left: var(--space-3); width: auto; bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + var(--space-3)); }
}

/* chips and badges: pastel pills */
.badge, .chip, .triage-tag, .dispatch-driver-status-badge {
  display: inline-flex; align-items: center; gap: 6px; padding: 3px 11px; border: 0; border-radius: var(--r-pill);
  font-size: 12px; font-weight: 600; line-height: 1.5; white-space: nowrap;
  background: var(--chip-blue-bg); color: var(--chip-blue-fg);
}
.chip--blue { background: var(--chip-blue-bg); color: var(--chip-blue-fg); }
.chip--pink { background: var(--chip-pink-bg); color: var(--chip-pink-fg); }
.chip--purple { background: var(--chip-purple-bg); color: var(--chip-purple-fg); }
.chip--green { background: var(--chip-green-bg); color: var(--chip-green-fg); }
.chip--orange { background: var(--chip-orange-bg); color: var(--chip-orange-fg); }
.chip--red { background: var(--chip-red-bg); color: var(--chip-red-fg); }
/* case colour (triage) keeps its meaning on every chip: red, pink, yellow, green, each with its own text colour (AA) */
.triage-red, .badge-on_mission { background: var(--mission-bg); color: var(--mission); }
.triage-pink { background: #FCE7F3; color: #9D174D; }
.triage-yellow { background: var(--duty-bg); color: var(--duty); }
.triage-green, .badge-done { background: var(--done-bg); color: var(--done); }

/* the gradient banner (ศูนย์สั่งการ, แดชบอร์ด): white text only on the parts of the gradient that keep AA */
.hero {
  position: relative; overflow: hidden; margin-bottom: var(--space-5); padding: var(--space-6);
  border-radius: var(--r-card); background: var(--hero); color: #FFFFFF;
  box-shadow: 0 14px 30px rgba(59, 130, 246, .25);
}

/* forms */
input:where(:not([type="checkbox"], [type="radio"], [type="range"], [type="file"])), select, textarea,
.form-control, .form-select {
  width: 100%; border: 1px solid var(--line); border-radius: var(--r-inner);
  background: var(--card); color: var(--ink); font-size: 15px;
  transition: border-color .15s, box-shadow .15s;
}
input:where(:not([type="checkbox"], [type="radio"], [type="range"], [type="file"])), select,
.form-control:not(textarea), .form-select { min-height: 44px; padding: 0 var(--space-3); }
textarea { min-height: 96px; padding: var(--space-3); line-height: 1.5; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 4px rgba(37, 99, 235, .15); }
input::placeholder, textarea::placeholder { color: #94A3B8; }
label { color: #334155; }

/* tables: white, light lines; the scroll box a card */
.data-table { width: 100%; border-collapse: collapse; font-size: 14px; }
/* rows only as tall as their text + 8px above and below (user 2026-11-25: "ใช้พื้นที่มากไป" … "ตารางอื่นก็ปรับด้วย") */
.data-table th { padding: 8px 12px; text-align: left; font-size: 12px; font-weight: 600; color: var(--muted); background: #F8FAFC; border-bottom: 1px solid var(--line); }
.data-table td { padding: 8px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.data-table tr:last-child td { border-bottom: 0; }
.data-table-container, .table-wrap {
  overflow-x: auto; -webkit-overflow-scrolling: touch;
  border: 1px solid var(--line); border-radius: var(--r-card); background: var(--card);
}

/* page parts shared by the views (section heads, panels, figures, segments, filter chips, status chips, type badges,
   search, tables that become cards). Phone < 768px, tablet 768–1023px, sidebar from 1024px; anything tappable is at least
   44px below 1024px (filter chips and segments 40px, with room around them) */
/* Section head: icon, Thai title, a count on the right */
.section-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 24px 0 12px;
}
.section-head > .icon {
  color: var(--primary);
}
.section-head h3 {
  margin: 0;
  color: var(--ink);
  font-size: 18px;
  font-weight: 700;
}
.section-count {
  margin-left: auto;
  color: var(--muted);
  font-size: 13px;
}
/* A plain white box */
.panel {
  min-width: 0;
  padding: 20px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r-card);
  box-shadow: var(--shadow);
}
.panel-title {
  margin: 0;
  color: var(--ink);
  font-size: 16px;
  font-weight: 700;
}
.panel-sub {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 13px;
}
/* Figures: 2 a row on a phone, 3 on a tablet, 6 on a wide screen */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}
.kpi {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  padding: 14px 16px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r-inner);
  box-shadow: var(--shadow);
}
/* in the banner the figures are solid white tiles with dark text (AA on any part of the gradient) */
.hero .kpi {
  border-color: transparent;
  box-shadow: 0 8px 18px -10px rgba(15, 23, 42, .45);
}
.hero .kpi-grid {
  margin-bottom: 0;
}
.hero .page-head h2,
.hero .page-head p {
  color: #FFFFFF;
}
.kpi-label {
  display: flex;
  align-items: center;
  color: var(--muted);
  font-size: 13px;
}
.kpi-value {
  color: var(--ink);
  font-size: 24px;
  font-weight: 700;
  line-height: 1.25;
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}
.kpi-value small {
  color: var(--muted);
  font-size: 14px;
  font-weight: 500;
}
.kpi-sub {
  display: flex;
  align-items: center;
  gap: 4px;
  color: var(--muted);
  font-size: 12px;
}
.kpi-sub .icon {
  width: 14px;
  height: 14px;
}
.kpi-sub.is-good {
  color: var(--done);
}
.kpi-sub.is-warn {
  color: var(--duty);
}
/* Segments: one choice out of a few (ช่วงเวลา) */
.seg {
  display: flex;
  gap: 4px;
  padding: 4px;
  background: var(--soft);
  border: 1px solid var(--line);
  border-radius: var(--r-pill);
}
.seg > button {
  flex: 1 1 0;
  min-height: 40px;
  padding: 0 12px;
  border: 0;
  border-radius: var(--r-pill);
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
  transition: box-shadow .12s, transform .12s;
}
.seg > button:is(.active, [aria-pressed="true"]) {
  background: var(--card);
  color: var(--primary);
  box-shadow: var(--key-white);
}
.seg > button:focus-visible,
.chip-row > button:focus-visible {
  outline: 3px solid var(--primary);
  outline-offset: 1px;
}
/* Filter chips: one row that scrolls sideways by itself on a phone, wraps from 768px */
.chip-row {
  display: flex;
  gap: 8px;
  padding: 2px 0 4px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.chip-row > button {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 40px;
  margin-bottom: 4px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: var(--r-pill);
  background: var(--card);
  color: var(--ink);
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
  box-shadow: var(--key-white);
  transition: box-shadow .12s, transform .12s;
}
.chip-row > button:is(.active, [aria-pressed="true"]) {
  background: var(--primary);
  border-color: var(--primary);
  color: #FFFFFF;
  box-shadow: var(--key-blue);
}
.seg > button:active,
.chip-row > button:active {
  transform: translateY(3px);
  box-shadow: var(--key-white-down);
}
.chip-row > button:is(.active, [aria-pressed="true"]):active {
  box-shadow: var(--key-blue-down);
}
.type-dot {
  display: inline-block;
  flex-shrink: 0;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--dot, var(--muted));
}
/* Status chips: always text, the colour only adds to it */
.chip.chip--done {
  background: var(--done-bg); color: var(--done);
}
.chip.chip--duty {
  background: var(--duty-bg); color: var(--duty);
}
.chip.chip--mission {
  background: var(--mission-bg); color: var(--mission);
}
.chip.chip--ready {
  background: var(--ready-bg); color: var(--ready);
}
.chip.chip-alert {
  background: var(--mission-bg); color: var(--mission);
}
.chip.chip--muted {
  background: var(--soft); color: var(--muted);
}
/* Mission-type chips (getMissionTypeBadge, everywhere): neutral chip, the type's colour as a dot */
.badge-refer,
.badge-ems,
.badge-mobile,
.badge-staff,
.badge-lab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 11px;
  border-radius: var(--r-pill);
  background: var(--soft);
  color: var(--ink);
  font-size: 12px;
  font-weight: 600;
  line-height: 1.5;
  white-space: nowrap;
}
:is(.badge-refer, .badge-ems, .badge-mobile, .badge-staff, .badge-lab)::before {
  content: '';
  flex-shrink: 0;
  width: 8px;
  height: 8px;
  border-radius: 50%;
}
.badge-refer::before {
  background: var(--type-refer);
}
.badge-ems::before {
  background: var(--type-ems);
}
.badge-mobile::before {
  background: var(--type-mobile);
}
.badge-staff::before {
  background: var(--type-staff);
}
.badge-lab::before {
  background: var(--type-lab);
}
/* Search box with its icon */
.search-field {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 48px;
  padding: 0 16px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r-pill);
  color: var(--muted);
}
.search-field:focus-within {
  outline: 3px solid var(--primary);
  outline-offset: 1px;
}
.search-field input {
  flex: 1;
  min-width: 0;
  min-height: 46px;
  padding: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-size: 16px;
}
/* Date box with its icon (filters on ศูนย์สั่งการ, แดชบอร์ด, รายงาน): full width on a phone, 220px from 768px */
.date-field {
  display: flex;
  flex: 1 1 100%;
  align-items: center;
  gap: 8px;
  min-width: 0;
  min-height: 48px;
  padding: 0 16px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r-pill);
  color: var(--muted);
}
.date-field:focus-within {
  outline: 3px solid var(--primary);
  outline-offset: 1px;
}
.date-field input {
  flex: 1;
  min-width: 0;
  min-height: 46px;
  padding: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-size: 16px;
}
/* the box draws the focus ring for the search and date inputs inside it */
.search-field input:focus,
.date-field input:focus {
  box-shadow: none;
}
/* The red outline button (delete) */
.btn.btn-danger-outline {
  color: var(--mission);
}
.table-empty {
  padding: 32px 12px;
  color: var(--muted);
  text-align: center;
}
/* Tables that become cards: .table-cards-box is the size container, the .data-table-container inside it is the box.
   labelTableCards() (app.js) gives each cell its column's header as data-label */
.table-cards-box {
  container-type: inline-size;
}
/* In a table (box 960px and wider) a row's buttons sit two by two; จัดการระบบ's tables put them in one line (views, below) */
.row-actions {
  display: grid;
  grid-template-columns: repeat(2, max-content);
  align-items: center;
  gap: 4px;
}
.row-actions > .archive-photos {
  grid-column: 1 / -1;
}
@media (min-width: 768px) {
  .kpi-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
  }
  .kpi {
    padding: 16px 18px;
  }
  .kpi-value {
    font-size: 28px;
  }
  .seg {
    display: inline-flex;
  }
  .seg > button {
    flex: 0 0 auto;
    min-width: 88px;
  }
  .chip-row {
    flex-wrap: wrap;
    overflow: visible;
  }
  .date-field {
    flex: 0 0 220px;
  }
}
@media (min-width: 1440px) {
  .kpi-grid {
    grid-template-columns: repeat(6, minmax(0, 1fr));
  }
}
/* Card layout: below 960px of box width each row is a card (2 a row from 600px). Printing keeps the table */
@media screen {
  @container (max-width: 959.98px) {
    .table-cards-box > .data-table-container {
      overflow: visible;
      border: 0;
      border-radius: 0;
      background: transparent;
      box-shadow: none;
    }
    .table-cards-box .data-table--cards {
      display: block;
      width: 100%;
      min-width: 0;
    }
    .table-cards-box .data-table--cards thead {
      display: none;
    }
    .table-cards-box .data-table--cards tbody {
      display: grid;
      gap: 12px;
      width: 100%;
      min-width: 0;
    }
    .table-cards-box .data-table--cards tr {
      display: flex;
      flex-wrap: wrap;
      align-items: flex-start;
      gap: 8px 12px;
      padding: 16px;
      background: var(--card);
      border: 1px solid var(--line);
      border-radius: var(--r-card);
      box-shadow: var(--shadow);
    }
    /* A plain cell: its label in a 92px column on the left, the value flowing beside it */
    .table-cards-box .data-table--cards td {
      position: relative;
      display: block;
      flex: 1 1 100%;
      min-width: 0;
      padding: 0 0 0 102px;
      border: 0;
      background: transparent;
      font-size: 14px;
      text-align: left;
      overflow-wrap: anywhere;
    }
    .table-cards-box .data-table--cards td::before {
      content: attr(data-label);
      position: absolute;
      top: 0;
      left: 0;
      width: 92px;
      color: var(--muted);
      font-weight: 400;
    }
    .table-cards-box .data-table--cards td:is(.cell-title, .cell-sub, .cell-status, .cell-actions, [colspan]) {
      padding: 0;
    }
    .table-cards-box .data-table--cards td:is(.cell-title, .cell-sub, .cell-status, .cell-actions, [colspan])::before {
      content: none;
    }
    /* Head row: the title grows, the status chip sits at its right */
    .table-cards-box .data-table--cards td.cell-title {
      display: flex;
      flex: 1 1 0;
      order: -2;
      flex-wrap: wrap;
      align-items: center;
      gap: 6px 8px;
    }
    .table-cards-box .data-table--cards td.cell-status {
      flex: 0 0 auto;
      order: -2;
    }
    .table-cards-box .data-table--cards td.cell-sub {
      order: -1;
    }
    /* Figures sit two to a row, the label above the value */
    .table-cards-box .data-table--cards td.cell-stat {
      flex: 1 1 calc(50% - 6px);
      padding: 0;
    }
    .table-cards-box .data-table--cards td.cell-stat::before {
      position: static;
      display: block;
      width: auto;
      font-size: 13px;
    }
    .table-cards-box .data-table--cards td.cell-actions {
      margin-top: 2px;
      padding-top: 10px;
      border-top: 1px solid var(--line);
    }
    .table-cards-box .data-table--cards .row-actions {
      display: flex;
      flex-wrap: wrap;
      gap: 8px;
    }
    .table-cards-box .data-table--cards .row-actions .btn {
      flex: 1 1 auto;
      min-height: 44px;
    }
    .table-cards-box .data-table--cards .row-actions .btn.btn-icon {
      flex: 0 0 44px;
      width: 44px;
    }
    .table-cards-box .data-table--cards td[colspan] {
      text-align: center;
    }
  }
  @container (min-width: 600px) and (max-width: 959.98px) {
    .table-cards-box .data-table--cards tbody {
      grid-template-columns: repeat(2, minmax(0, 1fr));
    }
    .table-cards-box .data-table--cards tr:has(> td[colspan]) {
      grid-column: 1 / -1;
    }
  }
}

/* ---------- views: sign-in (#app-login-overlay) ---------- */
/* the sign-in reads at WCAG AAA (7:1) for older drivers (since 2026-10-16, tests/login-look G3): darker tokens here, a deeper
   banner whose every stop keeps white at 7:1 */
#app-login-overlay {
  --primary: #1E40AF; --primary-hover: #1E3A8A; --muted: #475569; --chip-red-fg: #7F1D1D;
  --hero: linear-gradient(100deg, #3730A3 0%, #1E40AF 52%, #115E59 100%);
}
/* phone: a gradient banner with the hospital on top of the white form card; desktop: banner left, form right */
.signin {
  position: fixed; inset: 0; z-index: 9999; display: flex; align-items: flex-start; justify-content: center;
  overflow-y: auto; padding: max(var(--space-6), env(safe-area-inset-top)) var(--space-3) var(--space-6);
  background: radial-gradient(60% 50% at 0% 0%, #E0ECFF, transparent 70%), radial-gradient(50% 45% at 100% 100%, #DDF7EF, transparent 70%), var(--bg);
}
.signin-card {
  width: 100%; max-width: 460px; margin: auto; overflow: hidden;
  background: var(--card); border: 1px solid var(--line); border-radius: 28px; box-shadow: 0 30px 60px rgba(15, 23, 42, .10);
}
.signin-card > :not(.signin-brand) { margin-left: var(--space-5); margin-right: var(--space-5); }
.signin-brand {
  display: grid; justify-items: center; gap: 2px; margin-bottom: var(--space-5); padding: var(--space-6) var(--space-5);
  text-align: center; color: #FFFFFF; background: var(--hero);
}
.signin-ring { width: 96px; height: 96px; margin-bottom: var(--space-3); padding: 6px; border-radius: 50%; background: rgba(255, 255, 255, .35); box-shadow: 0 10px 24px rgba(15, 23, 42, .18); }
.signin-ring img { display: block; width: 100%; height: 100%; padding: 4px; border-radius: 50%; object-fit: contain; background: #FFFFFF; }
.signin-brand h2 { font-size: 26px; font-weight: 700; color: #FFFFFF; text-wrap: balance; }
.signin-eyebrow { margin: 2px 0 0; font-size: 12px; font-weight: 600; letter-spacing: .18em; color: #FFFFFF; }
.signin-sub { margin: var(--space-1) 0 0; font-size: 15px; color: #FFFFFF; text-wrap: balance; }
.signin-rule { display: none; }
.signin-notice {
  display: flex; gap: var(--space-3); align-items: flex-start; margin-bottom: var(--space-4); padding: var(--space-3) var(--space-4);
  border-radius: var(--r-inner); background: var(--primary-soft); color: #1E3A8A;
}
.signin-notice .icon { width: 24px; height: 24px; margin-top: 2px; color: var(--primary); }
.signin-notice strong { display: block; font-size: 15px; line-height: 1.4; }
.signin-notice span { display: block; margin-top: 2px; font-size: 14px; line-height: 1.5; color: #334155; }
.signin-notice :is(strong, span), .signin-help, .signin-foot p { text-wrap: pretty; }
.signin-tabs {
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--space-1); margin-bottom: var(--space-5);
  padding: var(--space-1); border-radius: var(--r-pill); background: #F1F5F9;
}
.signin-tab {
  appearance: none; display: grid; justify-items: center; align-content: center; gap: 2px; min-height: 56px; padding: var(--space-1);
  border: 0; border-radius: var(--r-pill); background: transparent; color: #334155; font-size: 14px; font-weight: 600; line-height: 1.25; cursor: pointer;
  transition: background-color .15s, color .15s, box-shadow .15s;
}
.signin-tab .icon { width: 22px; height: 22px; }
.signin-tab:hover { color: var(--primary); }
.signin-tab.active { background: var(--card); color: var(--primary); box-shadow: var(--key-white); }
.signin-form { display: grid; gap: var(--space-4); }
.signin-field { display: grid; gap: var(--space-2); }
.signin-label { font-size: 15px; font-weight: 600; color: var(--ink); }
.signin-label.is-center { text-align: center; }
.signin-input { min-height: 52px; font-size: 16px; }
.signin-select {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  min-height: 54px;
  height: 54px;
  padding: 12px 44px 12px 16px;
  border: 1.5px solid var(--line, #CBD5E1);
  border-radius: 14px;
  background-color: var(--card, #FFFFFF);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='18' viewBox='0 0 24 24' fill='none' stroke='%23475569' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  background-size: 18px 18px;
  color: var(--ink, #0F172A);
  font-size: 17px;
  font-weight: 600;
  line-height: 1.3;
  cursor: pointer;
}
.signin-help { margin: 0; font-size: 14px; line-height: 1.5; color: var(--muted); }
.signin-link-btn {
  appearance: none; justify-self: start; display: inline-flex; align-items: center; gap: 6px; min-height: 40px; padding: 0 var(--space-3);
  border: 1px solid var(--line); border-radius: var(--r-pill); background: var(--card); color: var(--primary); font-size: 14px; font-weight: 600; cursor: pointer;
  box-shadow: var(--key-white);
}
.signin-link-btn .icon { width: 18px; height: 18px; }
.signin-error {
  margin-top: var(--space-1); padding: var(--space-2) var(--space-3); border-radius: var(--r-inner);
  font-size: 15px; font-weight: 600; line-height: 1.45; text-align: center; background: var(--chip-red-bg); color: var(--chip-red-fg);
}
.signin-pin { display: grid; justify-items: center; gap: var(--space-3); margin: var(--space-4) 0; text-align: center; }
.signin-pin-label { font-size: 17px; font-weight: 600; color: var(--ink, #0F172A); }
.signin-dots { display: flex; flex-wrap: wrap; justify-content: center; gap: var(--space-4); min-height: 22px; }
.signin-dot { width: 18px; height: 18px; border-radius: 50%; background: #E2E8F0; transition: background-color .15s, transform .15s; }
.signin-dot.filled { background: var(--primary); transform: scale(1.1); }
.signin-keypad {
  display: grid;
  grid-template-columns: repeat(3, 72px);
  justify-content: center;
  gap: var(--space-4) var(--space-5);
  margin: 0 0 var(--space-6, 24px);
}
.signin-key {
  appearance: none; width: 72px; height: 72px; padding: 0; border: 1px solid var(--line); border-radius: 50%;
  background: var(--card); color: var(--ink); font-size: 26px; font-weight: 600; cursor: pointer;
  box-shadow: var(--key-white); -webkit-tap-highlight-color: transparent; touch-action: manipulation;
  transition: background-color .1s, transform .1s, box-shadow .1s;
}
.signin-key:hover { border-color: #C7D2FE; }
.signin-key:active { transform: translateY(3px); background: var(--primary-soft); box-shadow: var(--key-white-down); }
.signin-key.is-clear { color: var(--chip-red-fg); font-size: 20px; }
.signin-key .icon { width: 26px; height: 26px; vertical-align: middle; }
.signin-btn {
  appearance: none; display: flex; align-items: center; justify-content: center; gap: var(--space-2); width: 100%; min-height: 54px;
  border: 0; border-radius: var(--r-pill); background: var(--primary); color: #FFFFFF; font-size: 16px; font-weight: 600; cursor: pointer;
  box-shadow: var(--key-blue); transition: box-shadow .12s, transform .12s;
}
.signin-btn:hover { background: var(--primary-hover); }
.signin-btn:not(.is-ghost):active { transform: translateY(3px); box-shadow: var(--key-blue-down); }
.signin-form .signin-btn { margin-top: var(--space-1); }
.signin-btn.is-ghost { min-height: 48px; margin-top: var(--space-3); background: var(--card); color: var(--ink); border: 1px solid var(--line); box-shadow: var(--key-white); }
.signin-foot {
  display: grid; justify-items: center; gap: var(--space-3); margin-top: var(--space-5); margin-bottom: var(--space-5);
  padding-top: var(--space-4); border-top: 1px solid var(--line); color: var(--muted); font-size: 14px; text-align: center;
}
.signin-foot p { margin: 0; line-height: 1.5; }
.signin-qr {
  appearance: none; display: flex; align-items: center; justify-content: center; gap: 6px; width: 100%; min-height: 48px;
  border: 1px solid var(--line); border-radius: var(--r-pill); background: var(--card); color: var(--ink); font-size: 14px; font-weight: 600; cursor: pointer;
  box-shadow: var(--key-white);
}
.signin-install { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; color: var(--primary); text-decoration: none; }
.signin :is(.signin-qr, .signin-install) .icon { width: 20px; height: 20px; }
.signin-version { font-size: 12px; letter-spacing: .04em; }
/* after a login with a guessable PIN (app.js startPinChange) the driver can neither switch login nor name */
#app-login-overlay.is-pin-change :is(.signin-tabs, #login-driver-picker) { display: none; }
#app-login-overlay:not(.is-pin-change) :is(#pin-rules, #pin-change-cancel) { display: none; }
@media screen and (min-width: 900px) {
  .signin { align-items: center; }
  .signin-card {
    max-width: 960px; display: grid; grid-template-columns: 400px minmax(0, 1fr); column-gap: var(--space-8);
    align-items: start;
  }
  .signin-brand { grid-column: 1; grid-row: 1 / span 30; align-self: stretch; align-content: center; margin: 0; padding: var(--space-8); }
  .signin-card > :not(.signin-brand) { grid-column: 2; margin-left: 0; margin-right: var(--space-8); }
  .signin-card > .signin-notice { margin-top: var(--space-8); }
}

/* ---------- views: ศูนย์สั่งการ (#view-center) — vehicles, radio, drivers, slips and requests, missions; the driver standby
   parts that share the slip cards ---------- */
/* The driver's shift on a vehicle card reads in the mission red; "ยังไม่ขึ้นเวร" keeps the muted grey */
.fleet-shift-on {
  color: var(--mission);
  font-weight: 600;
}
/* The left edge shows the vehicle's status at a glance: blue ready, amber crew on duty, red on a mission (from assignment
   until close-out), grey in the workshop */
.glass-card.vehicle-card {
  --edge: var(--off-edge);
  border-left: 6px solid var(--edge);
}
.glass-card.vehicle-card.ready {
  --edge: var(--ready-edge);
}
.glass-card.vehicle-card.on_duty {
  --edge: var(--duty-edge);
}
.glass-card.vehicle-card:is(.en_route, .fleet-operating) {
  --edge: var(--mission-edge);
}
/* on a mission a small ambulance or van (app.js) laps the card's border; without offset-path it sits on the top edge */
.fleet-ambulance-runner {
  display: none;
}
.glass-card.vehicle-card.fleet-operating {
  overflow: visible;
}
.vehicle-card .fleet-ambulance-runner {
  position: absolute;
  top: -12px;
  left: 12px;
  z-index: 2;
  display: block;
  width: 32px;
  height: 22px;
  pointer-events: none;
  user-select: none;
  filter: drop-shadow(0 2px 2px rgba(15, 23, 42, .3));
}
@supports (offset-path: inset(0 round 20px)) {
  .vehicle-card .fleet-ambulance-runner {
    top: 0;
    left: 0;
    offset-path: inset(0 round var(--r-card)) border-box;
    offset-distance: 0%;
    offset-rotate: 0deg;
    offset-anchor: center;
    animation: fleet-ambulance-lap 10s linear infinite;
  }
}
@keyframes fleet-ambulance-lap {
  to { offset-distance: 100%; }
}
.fleet-operation-dot {
  flex-shrink: 0;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--mission-edge);
  animation: fleet-status-pulse 2.4s ease-in-out infinite;
}
@keyframes fleet-status-pulse {
  0%, 100% { opacity: 1; box-shadow: 0 0 0 0 rgba(220, 38, 38, .3); }
  50% { opacity: .55; box-shadow: 0 0 0 5px rgba(220, 38, 38, 0); }
}
@media (prefers-reduced-motion: reduce) {
  .vehicle-card .fleet-ambulance-runner,
  .fleet-operation-dot {
    animation: none;
  }
}
.kpi-dot {
  display: inline-block;
  flex-shrink: 0;
  width: 8px;
  height: 8px;
  margin-right: 6px;
  border-radius: 50%;
  background: var(--off-edge);
}
.kpi-dot.is-ready {
  background: var(--ready-edge);
}
.kpi-dot.is-mission {
  background: var(--mission-edge);
}
.kpi-dot.is-duty {
  background: var(--duty-edge);
}
@media (min-width: 768px) {
  .kpi-grid.kpi-grid--4 {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}
/* The radio: an icon in the head; while it plays, a thin bar under it */
#cool-radio-toggle[aria-pressed="true"] {
  background: var(--primary-soft);
  border-color: var(--primary);
  color: var(--primary);
}
.radio-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 52px;
  margin: -4px 0 16px;
  padding: 4px 8px 4px 16px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r-pill);
  box-shadow: var(--shadow);
  font-size: 13px;
}
.radio-bar audio {
  display: none;
}
.radio-bar-dot {
  flex-shrink: 0;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--primary);
}
.radio-bar-text {
  flex: 1;
  min-width: 0;
}
.radio-bar-link {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 6px;
  color: var(--primary);
  font-weight: 600;
  white-space: nowrap;
}
/* รถพยาบาล: one card a row on a phone, two on a tablet, three on a wide screen; the left edge carries the state */
#fleet-container.fleet-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 12px;
  margin-bottom: 8px;
}
#fleet-container .vehicle-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
  margin: 0;
  padding: 14px 14px 14px 12px;
}
.vehicle-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 10px;
}
/* in a narrow card the state chip moves under the code, to the right */
.vehicle-head > .chip {
  margin-left: auto;
}
.vehicle-head > :is(img, .vehicle-photo-card) {
  flex-shrink: 0;
  width: 48px;
  height: 48px;
  border-radius: var(--r-inner);
  object-fit: cover;
}
.vehicle-id {
  flex: 1 0 auto;
  min-width: 0;
}
#fleet-container .vehicle-code {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--ink);
  font-size: 16px;
  font-weight: 700;
}
#fleet-container .vehicle-code .icon {
  color: var(--primary);
}
#fleet-container .vehicle-plate {
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 13px;
}
.vehicle-spec {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}
.vehicle-fuel.is-low {
  color: var(--duty);
  font-weight: 700;
}
#fleet-container .vehicle-driver {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0;
  padding: 10px 0 0;
  border: 0;
  border-top: 1px solid var(--line);
  background: none;
}
button.driver-avatar-fleet {
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
}
.driver-avatar-fleet.inactive .icon {
  color: var(--muted);
}
.vehicle-driver-info {
  flex: 1;
  min-width: 0;
}
.vehicle-driver-name {
  color: var(--ink);
  font-size: 14px;
  font-weight: 600;
  overflow-wrap: anywhere;
}
:is(.vehicle-driver-name, .center-driver-name) .mono {
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 500;
}
/* เวรที่1 / เวรที่2, one line each */
.fleet-shift-line {
  display: block;
}
#fleet-container .fleet-shift {
  font-size: 13px;
}
.vehicle-actions {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 6px;
}
.vehicle-actions .vehicle-call {
  flex: 1 1 auto;
  gap: 5px;
  padding: 0 10px;
  font-size: 13.5px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
#fleet-container .btn-reset-duty-quick {
  flex: 0 0 auto;
  margin: 0;
  padding: 0 10px;
  font-size: 13px;
  white-space: nowrap;
}
.vehicle-shared {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}
.vehicle-proof {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 48px;
  padding: 4px 6px;
  border: 1px solid var(--line);
  border-radius: var(--r-inner);
  background: #F8FAFC;
  color: var(--ink);
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.vehicle-proof img {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  object-fit: cover;
}
.vehicle-proof span {
  display: flex;
  flex-direction: column;
}
.vehicle-proof strong {
  color: var(--done);
  font-size: 13px;
}
.vehicle-proof small {
  color: var(--muted);
  font-size: 12px;
}
/* พลขับ: one list with filter chips */
.center-driver-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 10px;
  margin: 10px 0 8px;
}
.center-driver {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  min-width: 0;
  padding: 14px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r-card);
  box-shadow: var(--shadow);
}
.center-driver .driver-avatar-thumb {
  flex-shrink: 0;
  width: 44px;
  height: 44px;
}
.center-driver-info {
  display: flex;
  flex: 1;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  min-width: 0;
}
.center-driver-name strong {
  color: var(--ink);
  font-size: 15px;
  overflow-wrap: anywhere;
}
.center-driver-info p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  overflow-wrap: anywhere;
}
.center-driver .btn-icon {
  flex-shrink: 0;
}
.center-driver .chip {
  white-space: normal;
}
/* คำขอรถจาก LINE */
.line-requests {
  margin: 16px 0;
}
.line-requests .section-head {
  margin-top: 0;
}
.line-requests .section-head .btn-icon {
  margin-left: auto;
}
/* คำขอใช้รถจาก HOSOffice: driver cockpit box (standby) and the centre panel; the left edge carries the state colour */
.hosoffice-driver-box {
  max-width: 480px;
  margin: 0 auto 14px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  text-align: left;
}
/* The state colour is a bar drawn inside the card. Compact card: date/time, place and driver in large type, everything else on a small grey line */
.hosoffice-card {
  --hos-edge: var(--ready);
  position: relative;
  margin-top: .75rem;
  overflow-wrap: anywhere;
}
.glass-card.hosoffice-card {
  padding: 12px 14px 12px 24px;
}
.hosoffice-card::before {
  content: '';
  position: absolute;
  top: 12px;
  bottom: 12px;
  left: 10px;
  width: 4px;
  border-radius: 4px;
  background: var(--hos-edge);
}
/* Colour by mission type, the same colours as the type dots across CarsRefer (2026-10-31); the state is the chip */
.hosoffice-card--request {
  --hos-edge: var(--type-staff);
}
.hosoffice-card--refer {
  --hos-edge: var(--type-refer);
}
/* Advance Refer (keyed in HOSxP, not imported into HOSOffice yet): the same blue card with a dashed edge, nothing to press */
.hosoffice-card--advance {
  outline: 2px dashed var(--type-refer);
  outline-offset: -2px;
}
.hosoffice-advance-heading {
  margin-top: 4px;
  font-weight: 700;
}
.glass-card.hosoffice-card--request {
  background: #FFF9EC;
}
.glass-card.hosoffice-card--refer {
  background: #F2F7FF;
}
.hosoffice-card--muted {
  opacity: .7;
}
/* Refer cards (2026-11-01): a blue band with REFER, time and state, the masked patient name largest below it, and a
   soft blue pulse (drawn by ::after) while the Refer waits to be opened. The band blue is darker than --type-refer so white text reads (6.3:1). */
.hosoffice-card--refer .hosoffice-card__head {
  padding: 6px 10px;
  border-radius: var(--r-inner);
  background: #1E5AA8;
}
.hosoffice-card--refer .hosoffice-card__when {
  color: #FFFFFF;
}
.hosoffice-card__patient {
  margin: 8px 0 0;
  color: var(--ink);
  font-size: 19px;
  font-weight: 700;
  line-height: 1.3;
}
.hosoffice-card--refer.hosoffice-card--ready::after {
  content: '';
  position: absolute;
  inset: -1px;
  border-radius: inherit;
  pointer-events: none;
  animation: hosoffice-refer-pulse 2s ease-in-out infinite;
}
@keyframes hosoffice-refer-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(30, 90, 168, .45); }
  50% { box-shadow: 0 0 0 7px rgba(30, 90, 168, 0); }
}
@media (prefers-reduced-motion: reduce) {
  .hosoffice-card--refer.hosoffice-card--ready::after {
    animation: none;
    box-shadow: 0 0 0 2px rgba(30, 90, 168, .55);
  }
}
/* Colleagues' jobs on the driver screen ("เปิดแทน"), folded until asked for */
.hosoffice-others {
  margin-top: 12px;
}
.hosoffice-others > summary {
  padding: 8px 0;
  color: var(--muted);
  font-weight: 600;
  cursor: pointer;
}
/* ไปพร้อมกัน: tick boxes on the phone-dispatch form, and the folded list under a running mission */
/* Driver standby, design ก (2026-11-09): compact head, own jobs first, doctor-keyed Refers as short rows, and the
   phone-dispatch button kept at the bottom of the screen (above the phone tab bar) so it is never scrolled away */
#no-mission-state.is-compact #no-mission-icon,
#no-mission-state.is-compact #no-mission-desc {
  display: none;
}
#no-mission-state.is-compact #no-mission-title {
  margin: 0 0 8px;
  font-size: 17px;
}
#no-mission-state.is-compact .standby-chips {
  margin-bottom: 8px;
}
/* overflow: hidden on the card would make the card, not the screen, the edge the button sticks to; clip keeps the rounded
   corners without that */
#cockpit-mission-panel {
  overflow: clip;
}
#no-mission-state .phone-dispatch-box {
  margin-top: 14px;
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
}
#no-mission-state .phone-dispatch-box .phone-dispatch-note {
  display: none;
}
/* Anything scrolled into view (a tap, the keyboard) stops above the tab bar */
#hosoffice-driver-box :is(button, a, summary, .hosoffice-card) {
  scroll-margin-bottom: calc(var(--tabbar-h) + 24px);
}
/* "งานของฉันวันนี้" says it now; the box's old heading only took room */
#hosoffice-driver-box > .phone-dispatch-note {
  display: none;
}
.driver-section-heading {
  margin: 12px 0 6px;
  color: var(--ink);
  font-weight: 700;
}
.advance-rows {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 6px;
}
.advance-row {
  display: grid;
  /* the slip number on top (รับงาน Refer จาก HOSxP, 2026-11-18); time, ขอรถ and "รับงานแล้ว · ชื่อ" on one line (2026-11-19),
     so every row is the same height; where from and to in full underneath */
  grid-template-columns: auto auto minmax(0, 1fr) auto;
  grid-template-areas: "number number urgency arrow" "when car taken arrow" "where where where arrow";
  row-gap: 4px;
  align-items: center;
  gap: 8px;
  width: 100%;
  min-height: 48px;
  padding: 8px 12px;
  border: 1px solid #BFD3F2;
  border-left: 5px solid var(--type-refer);
  border-radius: var(--r-inner);
  background: #F2F7FF;
  color: var(--ink);
  text-align: left;
  cursor: pointer;
}
.advance-row.is-quiet {
  border-left-color: #94A3B8;
}
.advance-row__when {
  grid-area: when;
  font-size: 15px;
}
.advance-row > .advance-car {
  grid-area: car;
  justify-self: start;
}
.advance-row > .chip {
  grid-area: urgency; justify-self: end;
}
.advance-row__where {
  grid-area: where;
  font-weight: 600;
  overflow-wrap: anywhere;
}
.advance-row__arrow {
  grid-area: arrow;
  color: var(--muted);
  font-size: 20px;
  transition: transform .15s ease;
}
.advance-row[aria-expanded="true"] .advance-row__arrow {
  transform: rotate(90deg);
}
/* รับงาน Refer จาก HOSxP (2026-11-18): the slip number leads each row and card; a taken slip says so */
.advance-row__number {
  grid-area: number;
  font-size: 20px;
  font-weight: 800;
  letter-spacing: .02em;
  color: #0B2E6B;
}
/* a long name ends in "…" (the full text is the label's title) */
.advance-row__taken {
  grid-area: taken;
  justify-self: end;
  max-width: 100%;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 700;
  background: #E2E8F0;
  color: #1E293B;
}
.advance-row.is-taken {
  background: #F1F5F9; border-left-color: #64748B;
}
.hosoffice-card__number {
  margin: 0 0 6px;
  font-size: 22px;
  font-weight: 800;
  letter-spacing: .02em;
  color: #0B2E6B;
}
.hosoffice-card--compact .hosoffice-card__number {
  margin: 0; font-size: inherit; color: #0B2E6B;
}
.hosoffice-card__taken {
  margin: 8px 0 0;
  padding: 4px 12px;
  border-radius: var(--r-pill);
  font-weight: 700;
  line-height: 1.6;
  /* one line (user 2026-11-20): "รับงานแล้ว: <driver>" / "ส่งต่อผู้ป่วยแล้ว: <driver>"; a long name ends in … (full text on hover) */
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  background: #FEF3C7;
  color: #713F12;
}
.hosoffice-card__taken.is-done {
  background: #DCFCE7; color: #14532D;
}
/* a line too long for its box runs one way round (app.js marqueeText; user 2026-11-20, looping 2026-11-21): a short hold, then
   it slides left with its copy (::after, from data-text) coming in behind, so the cycle ends where it began */
.marquee {
  overflow: hidden; white-space: nowrap;
}
.marquee__text {
  display: inline-block;
}
.marquee.is-marquee {
  text-overflow: clip;
}
.marquee.is-marquee > .marquee__text::after {
  content: "•\00a0\00a0\00a0" attr(data-text); padding-left: 1.2em;
}
.marquee.is-marquee > .marquee__text {
  animation: marqueeLoop var(--marquee-dur, 8s) linear var(--marquee-delay, 0s) infinite;
  will-change: transform;
}
@keyframes marqueeLoop {
  0%, 15% { transform: translateX(0); }
  100% { transform: translateX(calc(-1 * var(--marquee-shift, 0px))); }
}
@media (prefers-reduced-motion: reduce) {
  .marquee.is-marquee > .marquee__text {
    animation: none;
  }
}
.hosoffice-card__taken.is-failed {
  background: #FEE2E2; color: #7F1D1D;
}
.hosxp-accept__summary {
  display: grid;
  gap: 2px;
  margin: 0 0 4px;
  padding: 10px 12px;
  border-radius: var(--r-inner);
  background: #EFF6FF;
  color: #0F172A;
  font-weight: 600;
}
.hosxp-accept__number {
  font-size: 24px; font-weight: 800; color: #0B2E6B;
}
.hosxp-accept__more {
  font-size: 14px; font-weight: 500; color: #334155;
}
.hosxp-accept__hint {
  margin: 0 0 10px; font-size: 14px; color: #334155;
}
.hosxp-accept__people {
  display: grid;
  gap: 6px;
  max-height: 220px;
  overflow-y: auto;
  margin-top: 8px;
  color: #334155;
}
.hosxp-person {
  display: grid;
  gap: 2px;
  min-height: 44px;
  padding: 8px 12px;
  border: 1px solid #BFD3F2;
  border-radius: var(--r-inner);
  background: #FFFFFF;
  color: #0F172A;
  text-align: left;
  cursor: pointer;
}
.hosxp-person span {
  font-size: 13px; color: #475569;
}
.hosxp-person[aria-pressed="true"] {
  border: 2px solid #1D4ED8; background: #DBEAFE;
}
.hosxp-accept__chosen {
  margin: 10px 0 0; font-weight: 700; color: #0F172A;
}
/* ขอรถ / ไม่ขอรถ (2026-11-10): the first thing a driver reads on a doctor-keyed Refer */
.advance-car {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 800;
  white-space: nowrap;
}
.advance-car.is-yes {
  background: #B91C1C;
  color: #FFFFFF;
}
.advance-car.is-no {
  border: 1px solid #94A3B8;
  background: #F1F5F9;
  color: #475569;
}
.advance-car--big {
  justify-self: start;
  width: fit-content;
  margin: 8px 0 2px;
  padding: 6px 14px;
  border-radius: var(--r-inner);
  font-size: 17px;
}
.advance-car--big .icon {
  width: 22px;
  height: 22px;
}
/* The centre's compact card (same size as a HOSOffice card): ขอรถ is a chip in the head, the long lines stay on one */
.advance-car--chip {
  padding: 2px 8px;
  font-size: 11.5px;
}
.hosoffice-card--compact .hosoffice-card__head {
  flex-wrap: nowrap;
  align-items: center;
}
/* การ์ดล้น (2026-11-19): in a compact card the urgency chip gives way ("…") before the time or ขอรถ do, and the bottom line
   stops at two lines (also in the driver's box, which shows full cards' details in full) */
.hosoffice-card--compact .hosoffice-card__head > * {
  flex: 0 0 auto;
}
.hosoffice-card--compact .hosoffice-card__head > .chip {
  flex: 0 1 auto;
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.hosoffice-card--compact .hosoffice-card__detail {
  display: -webkit-box;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}
.hosoffice-card--compact .hosoffice-card__head .chip:first-of-type {
  margin-left: auto;
}
.hosoffice-card--compact .hosoffice-card__when {
  font-size: 15px;
  white-space: nowrap;
}
.hosoffice-card--compact .hosoffice-card__head :is(.chip, .advance-car) {
  padding: 2px 6px;
}
.advance-car--chip.is-yes {
  box-shadow: 0 0 0 1.5px #FFFFFF;
}
.hosoffice-card--compact .hosoffice-card__patient {
  font-size: 16px;
}
.hosoffice-card--compact :is(.hosoffice-card__diagnosis, .hosoffice-card__place) > span {
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.advance-more {
  min-height: 44px;
}
/* EMS quick form (2026-11-09): place, caller, mileage; hospital, colour, nurse and notes folded until asked for */
#form-phone-dispatch.is-ems-quick :is(#phone-destination-group, #phone-nurse-group, #phone-triage-group, #phone-patient-info-group) {
  display: none;
}
/* Incident places: the name on top, the หมู่/ต./อ. under it */
#phone-ems-location-list .dest-option {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 2px;
}
#phone-ems-location-list .dest-option-name {
  font-weight: 700;
}
.ems-more-toggle {
  width: 100%;
  min-height: 48px;
  margin: 0 0 14px;
}
/* Web Push 3-mode notification selector (per device: on_duty / always / off) */
.push-control-card {
  width: 100%;
  margin: 10px 0 6px;
  padding: 12px 14px;
  border-radius: 14px;
  background: var(--card);
  border: 1px solid var(--line-strong);
  display: flex;
  flex-direction: column;
  gap: 8px;
  text-align: left;
}
.push-control-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.push-control-head strong {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13.5px;
  color: var(--ink, #0F172A);
}
.push-test-btn {
  min-height: 32px;
  padding: 0 10px;
  font-size: 12px;
}
.push-mode-group {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
}
.push-mode-group--stack {
  grid-template-columns: 1fr;
}
.push-mode-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-height: 44px;
  padding: 8px 6px;
  border-radius: 10px;
  border: 1.5px solid var(--line-strong);
  background: var(--soft);
  color: var(--ink);
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 600;
  line-height: 1.25;
  cursor: pointer;
  transition: background .15s, border-color .15s, color .15s;
}
.push-mode-group--stack .push-mode-btn {
  align-items: flex-start;
  padding: 10px 14px;
  text-align: left;
}
.push-mode-btn small {
  font-weight: 400;
  font-size: 11.5px;
  opacity: .85;
}
.push-mode-btn.is-active {
  background: #2563EB;
  border-color: #1D4ED8;
  color: #FFFFFF;
}
.push-mode-btn[data-push-mode="off"].is-active {
  background: #475569;
  border-color: #334155;
  color: #FFFFFF;
}
.push-status-note {
  margin: 0;
  font-size: 12px;
  color: var(--text-muted, #64748B);
  line-height: 1.45;
}
.push-mode-badge {
  margin-left: auto;
  font-size: 10.5px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 999px;
  background: rgba(100, 116, 139, 0.16);
  color: #475569;
  white-space: nowrap;
}
.push-mode-badge[data-mode="on_duty"] {
  background: rgba(37, 99, 235, 0.14);
  color: #1D4ED8;
}
.push-mode-badge[data-mode="always"] {
  background: rgba(16, 185, 129, 0.16);
  color: #047857;
}
#view-driver.is-night .push-control-card {
  background: #141B2D;
  border-color: #2A3756;
}
#view-driver.is-night .push-control-head strong {
  color: #F8FAFC;
}
#view-driver.is-night .push-mode-btn:not(.is-active) {
  background: #1E293B;
  border-color: #334155;
  color: #CBD5E1;
}
#view-driver.is-night .push-status-note {
  color: #94A3B8;
}

/* Siren for a new Refer (2026-11-08): the tap that allows sound, and the flashing banner until รับทราบ */
.refer-siren-toggle {
  width: 100%;
  min-height: 48px;
  margin: 8px 0;
  justify-content: center;
  gap: 8px;
}
.refer-siren-toggle.is-on {
  border-color: #15803D;
  color: #14532D;
  background: #DCFCE7;
  box-shadow: var(--key-white);
}
.refer-siren-banner {
  position: fixed;
  top: max(8px, env(safe-area-inset-top));
  left: 8px;
  right: 8px;
  z-index: 3000;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-radius: var(--r-inner);
  background: #B91C1C;
  color: #FFFFFF;
  font-size: 16px;
  font-weight: 700;
  box-shadow: 0 10px 28px rgba(127, 29, 29, .45);
  animation: refer-siren-flash 1s steps(2, jump-none) infinite;
}
.refer-siren-banner p {
  flex: 1 1 220px;
  margin: 0;
  overflow-wrap: anywhere;
}
.refer-siren-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-left: auto;
}
.refer-siren-banner .btn {
  min-height: 44px;
  padding: 0 14px;
  border: 2px solid #FFFFFF;
  border-radius: var(--r-inner);
  background: #FFFFFF;
  color: #7F1D1D;
  font-weight: 800;
}
.refer-siren-banner .refer-siren-dismiss {
  background: rgba(255, 255, 255, 0.96);
  color: #7F1D1D;
}
@keyframes refer-siren-flash {
  from { background: #B91C1C; }
  to { background: #7F1D1D; }
}
@media (prefers-reduced-motion: reduce) {
  .refer-siren-banner {
    animation: none;
  }
}
/* เติมน้ำมัน (2026-11-25): the receipt preview and the recent fills in the driver's form */
.fuel-photo-preview {
  display: block;
  max-width: 100%;
  max-height: 220px;
  margin-top: 8px;
  border: 1px solid var(--line);
  border-radius: 10px;
  object-fit: contain;
}
.fuel-recent-title {
  margin: 16px 0 8px;
  font-size: 15px;
}
.fuel-recent {
  display: grid;
  gap: 8px;
  color: var(--muted);
}
.fuel-fill {
  display: grid;
  gap: 2px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--ink);
  overflow-wrap: anywhere;
}
.fuel-fill__status {
  justify-self: start;
  margin-top: 4px;
  padding: 2px 8px;
  border-radius: var(--r-pill);
  font-size: 13px;
  font-weight: 600;
}
.fuel-fill__status.is-sent {
  background: #DCFCE7;
  color: #166534;
}
.fuel-fill__status.is-pending {
  background: #FEF3C7;
  color: #92400E;
}
.fuel-fill__note {
  color: var(--muted);
}
/* eGO Chat recipients on the settings page */
.ego-recipients,
.api-keys {
  display: grid;
  gap: 8px;
  margin: 8px 0 12px;
}
.ego-recipient,
.api-key {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
}
.ego-recipient__text,
.api-key__text {
  display: grid;
  flex: 1;
  gap: 2px;
  min-width: 0;
  overflow-wrap: anywhere;
}
.ego-recipient__last,
.api-key__when {
  color: var(--muted);
}
/* API แดชบอร์ดรวม: a new key, shown in full this once */
.api-key-once {
  display: grid;
  gap: 6px;
  justify-items: start;
  margin: 8px 0 12px;
  padding: 10px 12px;
  border: 1.5px solid var(--primary);
  border-radius: 10px;
  background: var(--soft);
}
.ego-recipient__last.is-failed {
  color: #B91C1C;
}
.ego-add {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 200px), 1fr));
  gap: 0 12px;
}
.hosoffice-together {
  margin: 0 0 12px;
  padding: 0;
  border: 0;
}
.hosoffice-together__list {
  display: grid;
  gap: 4px;
}
.hosoffice-together__item {
  box-sizing: border-box;
  min-height: 44px;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow-wrap: anywhere;
}
.hosoffice-together__text {
  display: grid;
  gap: 2px;
  min-width: 0;
}
.hosoffice-together__detail {
  color: var(--muted);
  font-size: 12.5px;
  line-height: 1.45;
}
.hosoffice-join {
  margin-top: 16px;
}
/* Refer (แพทย์บันทึก) panel: light pink with a shadow (user, 2026-11-08); the diagnosis line in deep red */
#hosxp-advance-panel {
  background: #FFF0F3;
  border: 1px solid #F9C9D4;
  box-shadow: 0 2px 0 rgba(190, 18, 60, .08), 0 8px 22px rgba(190, 18, 60, .14);
}
.hosoffice-card .hosoffice-card__diagnosis {
  color: #9F1239;
}
#hosxp-advance-list,
#hosoffice-requests-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 270px), 1fr));
  gap: 10px;
  margin-top: .75rem;
}
#hosxp-advance-list .hosoffice-card,
#hosoffice-requests-list .hosoffice-card {
  margin-top: 0;
}
.hosoffice-card__head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 6px;
}
.hosoffice-card__when {
  margin-right: auto;
  color: var(--ink);
  font-size: 16px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.hosoffice-card .chip {
  padding: 2px 8px;
  font-size: 11.5px;
}
.hosoffice-card__diagnosis,
.hosoffice-card__place,
.hosoffice-card__doctor,
.hosoffice-card__nurse,
.hosoffice-card__driver {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  margin: 6px 0 0;
  color: var(--ink);
  font-size: 15px;
  font-weight: 600;
  line-height: 1.35;
}
.hosoffice-card__diagnosis .icon,
.hosoffice-card__place .icon,
.hosoffice-card__doctor .icon,
.hosoffice-card__nurse .icon,
.hosoffice-card__driver .icon {
  flex: none;
  width: 16px;
  height: 16px;
  margin-top: 2px;
  color: var(--primary);
}
.hosoffice-card__detail {
  display: -webkit-box;
  margin: 6px 0 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 12.5px;
  line-height: 1.4;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}
/* Drivers read the meeting point and requester in full */
.hosoffice-driver-box .hosoffice-card__detail {
  display: block;
  -webkit-line-clamp: unset;
}
.hosoffice-card .btn {
  width: 100%;
}
/* Driver card: navigate buttons side by side, "เปิดภารกิจ" across the full width below */
.hosoffice-card__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}
.hosoffice-card__actions .hosoffice-nav {
  flex: 1 1 150px;
  white-space: nowrap;
}
.hosoffice-card__actions .btn-primary {
  flex: 1 1 100%;
}
.hosoffice-nav,
.active-nav-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  text-decoration: none;
}
.btn.active-nav-link {
  margin-top: 8px;
}
.hosoffice-sync--stale {
  color: var(--duty);
  font-weight: 600;
}
/* ภารกิจ: status segments, day stepper, cards below 960px of table width */
.missions-filters {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}
.missions-filters .seg {
  flex: 1 1 100%;
}
.missions-day-filter {
  display: flex;
  flex: 1 1 100%;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.missions-day-filter .date-field {
  flex: 1 1 150px;
  min-height: 46px;
}
.missions-day-filter .date-field input {
  min-height: 44px;
}
.missions-day-filter .chip-row {
  flex-wrap: nowrap;
  padding: 0;
  overflow: visible;
}
.missions-day-filter .chip-row > button {
  min-height: 44px;
}
.mission-crew {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.mission-crew .driver-avatar-thumb {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
}
#active-missions-pager.missions-pager {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin-top: 12px;
}
.missions-pager-gap {
  padding: 0 4px;
  color: var(--muted);
}
#active-missions-pager[hidden] {
  display: none;
}
#active-missions-pager .btn {
  min-width: 44px;
}
@media (max-width: 767.98px) {
  #active-missions-pager .btn-label {
    display: none;
  }
}
@media (min-width: 768px) {
  #fleet-container.fleet-grid,
  .center-driver-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .missions-filters .seg {
    flex: 0 0 auto;
  }
  .missions-day-filter {
    flex: 0 1 auto;
    margin-left: auto;
  }
}
@media (min-width: 1024px) {
  #fleet-container.fleet-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}
@media (min-width: 1280px) {
  #fleet-container.fleet-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
  .center-driver-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

/* ---------- views: แผนที่ (#view-map) — list panel (3 tabs) + map; markers, pins, the symbol key and the crew cards
   (design ก, tinted by leg 2026-11-09). gps-vehicles.css still draws the vehicles and group labels ---------- */
/* GPS live map (js/gps-map.js) */
.gps-map-status {
  font-size: .8rem;
  color: var(--muted);
}
.gps-map-wrap {
  position: relative;
}
#gps-inset-title {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.gps-inset-head button {
  flex: none;
  padding: .1rem .45rem;
  border: 1px solid rgba(255, 255, 255, .4);
  border-radius: 8px;
  background: transparent;
  color: #fff;
  font: inherit;
  cursor: pointer;
}
#gps-inset-map {
  height: clamp(136px, 25.6vh, 272px);
}
.gps-inset.is-collapsed #gps-inset-map {
  display: none;
}
@media (max-width: 600px) {
  .gps-inset {
    display: none;
  }
}
.gps-map-empty {
  position: absolute;
  left: 50%;
  bottom: 1rem;
  transform: translateX(-50%);
  z-index: 500;
  width: max-content;
  max-width: calc(100% - 2rem);
  padding: .5rem .9rem;
  border-radius: 999px;
  background: rgba(13, 11, 26, .82);
  color: #fff;
  font-size: .8rem;
  text-align: center;
}
.gps-marker {
  position: relative;
  padding: .05rem .4rem;
  border-radius: 999px;
  font-size: .62rem;
  font-weight: 600;
  line-height: 1.4;
  white-space: nowrap;
  color: #fff;
  border: 1.5px solid #fff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, .35);
}
.gps-marker.gps-moving {
  background: #16a34a;
}
.gps-marker.gps-stopped {
  background: #2563eb;
}
.gps-marker.gps-offline {
  background: #6b7280;
}
.gps-marker.gps-parked {
  background: #334155;
}
.gps-popup {
  font-family: var(--font);
  line-height: 1.6;
}
.gps-popup a {
  display: inline-block;
  margin-top: .35rem;
}
.gps-popup-btn {
  display: block;
  margin-top: .4rem;
  padding: .3rem .6rem;
  font-size: .8rem;
}
/* GPS map page (#view-map) */
.gps-view-layout {
  display: grid;
  grid-template-columns: minmax(240px, 300px) minmax(0, 1fr);
  gap: 1rem;
  align-items: start;
}
.gps-vehicle-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: .5rem;
}
.gps-vehicle {
  width: 100%;
  display: grid;
  gap: .15rem;
  text-align: left;
  padding: .6rem .75rem;
  border-radius: var(--r-inner);
  border: 1px solid var(--line);
  border-left-width: 5px;
  background: var(--card);
  color: var(--ink);
  font: inherit;
  cursor: pointer;
}
.gps-vehicle:hover,
.gps-vehicle:focus-visible {
  background: var(--soft);
}
.gps-vehicle span,
.gps-vehicle small {
  color: var(--muted);
  font-size: .8rem;
}
.gps-vehicle.gps-moving {
  border-left-color: #16a34a;
}
.gps-vehicle.gps-stopped {
  border-left-color: #2563eb;
}
.gps-vehicle.gps-offline {
  border-left-color: #6b7280;
}
.gps-vehicle.gps-parked {
  border-left-color: #334155;
}
.gps-vehicle-empty {
  color: var(--muted);
  font-size: .85rem;
}
.gps-track-panel {
  display: grid;
  gap: .5rem;
  font-size: .85rem;
}
.gps-track-panel label {
  display: grid;
  gap: .25rem;
  color: var(--muted);
}
.gps-track-panel select,
.gps-track-panel input {
  background: var(--card);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: .45rem .6rem;
  font: inherit;
  width: 100%;
}
.gps-track-actions {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
}
.gps-track-presets {
  display: flex;
  flex-wrap: wrap;
  gap: .35rem;
}
.gps-track-presets .btn {
  padding: .25rem .6rem;
  font-size: .78rem;
}
#gps-map {
  height: calc(100vh - 220px);
  min-height: 420px;
  border-radius: var(--r-card);
  overflow: hidden;
  z-index: 0;
}
#view-map:fullscreen {
  background: var(--bg);
  padding: 1rem;
  overflow: auto;
}
#view-map:fullscreen #gps-map {
  height: calc(100vh - 7rem);
}
@media (max-width: 900px) {
  .gps-view-layout {
    grid-template-columns: minmax(0, 1fr);
  }
  .gps-map-wrap {
    order: -1;
  }
  #gps-map {
    height: 60vh;
    min-height: 320px;
  }
}
.gps-crew-summary {
  color: var(--muted);
  font-size: .8rem;
  margin-bottom: .5rem;
}
.gps-crew-toggle {
  display: flex;
  align-items: flex-start;
  gap: .4rem;
  font-size: .8rem;
  color: var(--muted);
  margin-bottom: .6rem;
}
.gps-crew-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: .5rem;
}
.gps-crew-item {
  width: 100%;
  display: grid;
  gap: .15rem;
  text-align: left;
  padding: .6rem .75rem;
  border-radius: var(--r-inner);
  border: 1px solid var(--line);
  border-left-width: 5px;
  background: var(--card);
  color: var(--ink);
  font: inherit;
  font-size: .85rem;
  cursor: pointer;
}
.gps-crew-item:hover,
.gps-crew-item:focus-visible {
  background: var(--soft);
}
.gps-crew-swatch {
  display: inline-block;
  width: .7rem;
  height: .7rem;
  margin-left: .4rem;
  border-radius: 50%;
  vertical-align: middle;
  box-shadow: 0 0 0 2px var(--card), 0 0 0 3px var(--line);
}
.gps-crew-item small {
  color: var(--muted);
  font-size: .78rem;
}
.gps-marker.gps-on-mission {
  border-width: 2px;
}
/* Label above the vehicle, faint until hovered so it does not hide the road; overspeed stays solid */
/* The GPS point is the middle of the vehicle drawing (bottom of the wrap minus half its height), so the vehicle sits on the road */
.gps-marker-wrap {
  display: flex;
  flex-direction: column-reverse;
  align-items: center;
  gap: 1px;
}
.gps-marker-wrap .gps-marker {
  opacity: .55;
  transition: opacity .15s;
  font-weight: 400;
  line-height: 1.25;
  border-width: 1px;
  text-align: center;
}
.gps-marker-speed {
  display: block;
  font-size: inherit;
}
/* route colour outline */
.gps-marker-wrap:hover .gps-marker,
.gps-marker-wrap .gps-marker.gps-overspeed {
  opacity: 1;
}
.gps-vehicle-icon {
  display: inline-block;
  width: 34px;
  height: 17px;
  filter: drop-shadow(0 1px 1.5px rgba(0, 0, 0, .4));
}
.gps-vehicle-icon svg {
  width: 100%;
  height: 100%;
  display: block;
}
/* Ambulance roof lights flash red/blue on the map; the glow reaches past the tiny drawing */
.gps-marker-wrap .gps-kind-ambulance,
.gps-marker-wrap .gps-kind-pickupEms {
  overflow: visible;
}
.gps-marker-wrap .gps-kind-ambulance svg,
.gps-marker-wrap .gps-kind-pickupEms svg {
  overflow: visible;
}
.gps-legend span {
  display: flex;
  align-items: center;
  gap: .4rem;
}
.gps-marker.gps-overspeed {
  background: #dc2626;
  animation: gps-pulse 1s ease-in-out infinite alternate;
}
@keyframes gps-pulse { from { box-shadow: 0 0 0 0 rgba(220, 38, 38, .6); } to { box-shadow: 0 0 0 8px rgba(220, 38, 38, 0); }
}
@media (prefers-reduced-motion: reduce) {
  .gps-marker.gps-overspeed {
    animation: none;
  }
}
.gps-vehicle.gps-overspeed {
  border-left-color: #dc2626;
}
.gps-hospital-pin {
  --pin-color: #dc2626;
  display: block;
  width: 28px;
  height: 36px;
  font-style: normal;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, .4));
}
.gps-hospital-pin svg {
  display: block;
  width: 100%;
  height: 100%;
}
.gps-hospital-pin-body {
  fill: var(--pin-color);
}
.gps-hospital-pin.gps-hospital-base {
  --pin-color: #16a34a;
}
.gps-hospital-label {
  position: absolute;
  top: 38px;
  left: 14px;
  transform: translateX(-50%);
  white-space: nowrap;
  padding: 0 .35rem;
  border-radius: 8px;
  background: rgba(255, 255, 255, .92);
  color: #166534;
  font-size: .72rem;
  font-weight: 600;
  box-shadow: 0 1px 2px rgba(0, 0, 0, .25);
}
.gps-legend .gps-hospital-pin {
  display: inline-block;
  width: 14px;
  height: 18px;
  vertical-align: -4px;
}
.gps-hospital-pin.gps-hospital-target + .gps-hospital-label {
  top: 46px;
  left: 17px;
}
@keyframes gps-target-pulse { from { filter: drop-shadow(0 1px 2px rgba(0, 0, 0, .4)) drop-shadow(0 0 2px var(--target-color, #dc2626)); } to { filter: drop-shadow(0 1px 2px rgba(0, 0, 0, .4)) drop-shadow(0 0 6px var(--target-color, #dc2626)) drop-shadow(0 0 12px var(--target-color, #dc2626)); }
}
.gps-hospital-pin.gps-hospital-target {
  width: 34px;
  height: 44px;
  animation: gps-target-pulse 1.6s ease-out infinite;
  position: relative;
  z-index: 1;
  animation-direction: alternate;
  animation-duration: .8s;
}
/* Ripples centred on the pin tip (17px, 44px in the 34x44 target pin) */
.gps-target-ring {
  position: absolute;
  left: 17px;
  top: 44px;
  width: 30px;
  height: 30px;
  margin: -15px 0 0 -15px;
  border-radius: 50%;
  border: 3px solid var(--target-color, #dc2626);
  background: color-mix(in srgb, var(--target-color, #dc2626) 25%, transparent);
  box-shadow: 0 0 0 1px #fff;
  pointer-events: none;
  animation: gps-target-ring 1.6s ease-out infinite;
}
.gps-target-ring-late {
  animation-delay: .8s;
}
@keyframes gps-target-ring { from { transform: scale(.3); opacity: 1; } to { transform: scale(2.4); opacity: 0; }
}
@media (prefers-reduced-motion: reduce) {
  .gps-hospital-pin.gps-hospital-target,
  .gps-target-ring {
    animation: none;
  }
  .gps-target-ring-late {
    display: none;
  }
}
.gps-place-pin {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  border: 1.5px solid var(--place-color, #475569);
  font-size: 9px;
  line-height: 1;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .3);
}
.gps-place-pin.gps-place-blackspot {
  background: #fef3c7;
  border-radius: 4px;
}
/* Home-visit pins: larger than landmarks, department-coloured ring, patient-type badge bottom right */
.gps-visit-pin {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: #fff;
  border: 3px solid var(--visit-color, #475569);
  font-size: 13px;
  line-height: 1;
  box-shadow: 0 1px 4px rgba(0, 0, 0, .35);
}
.gps-visit-type {
  position: absolute;
  right: -8px;
  bottom: -7px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  font-size: 10px;
  box-shadow: 0 0 0 1.5px var(--visit-color, #475569), 0 1px 2px rgba(0, 0, 0, .3);
}
/* Longdo tiles are pale pastel: darken and saturate them so white roads, forest and water separate (tiles only, markers keep their colours) */
.basemap-longdo :where(#gps-map, #gps-inset-map) .leaflet-tile-pane {
  filter: brightness(.82) contrast(1.6) saturate(1.9);
}
#gps-map .leaflet-bar {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--r-inner);
  box-shadow: var(--key-white);
}
#gps-map .leaflet-bar a {
  width: 40px;
  height: 40px;
  border-bottom-color: var(--line);
  color: var(--ink);
  font: 600 20px/40px var(--font);
}
#gps-map .leaflet-bar a:hover {
  background: var(--primary-soft);
  color: var(--primary);
}
@media (max-width: 1023.98px) {
  #gps-map .leaflet-bar a {
    width: 44px;
    height: 44px;
    line-height: 44px;
  }
}
#gps-map .leaflet-control-layers-separator {
  margin: 5px 0;
  border-top-color: var(--line);
}
#gps-map .leaflet-control-layers {
  background: rgba(255, 255, 255, .72);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  border: 1px solid rgba(15, 23, 42, .12);
  border-radius: var(--r-inner);
  box-shadow: 0 1px 4px rgba(15, 23, 42, .15);
}
#gps-map .leaflet-control-layers-expanded {
  padding: 4px 8px 4px 5px;
  font-size: .72rem;
  line-height: 1.25;
}
#gps-map .leaflet-control-layers-overlays label {
  margin: 0;
}
#gps-map .leaflet-control-layers-selector {
  width: 12px;
  height: 12px;
  margin: 1px 4px 1px 0;
  vertical-align: -2px;
}
/* Route replay (แผนที่ → เส้นทางย้อนหลัง → เล่นย้อนหลัง) */
.gps-playback {
  display: grid;
  gap: .4rem;
  padding-top: .5rem;
  border-top: 1px dashed var(--line);
}
.gps-playback-row {
  display: flex;
  gap: .5rem;
  align-items: center;
}
.gps-playback-row .btn {
  flex: 1;
  justify-content: center;
}
.gps-playback-row select {
  width: auto;
  flex: none;
}
.gps-playback input[type="range"] {
  width: 100%;
  accent-color: #f97316;
}
.gps-playback-info {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.gps-playback-clock {
  padding: .35rem .7rem;
  border-radius: var(--r-inner);
  background: rgba(15, 23, 42, .82);
  color: #fff;
  font-size: .95rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  box-shadow: 0 2px 8px rgba(0, 0, 0, .3);
}
/* Status-press points (driver's phone GPS); green pin with the code for vehicles without a GPS box */
.gps-checkpoint-pin {
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  padding: 1px 6px 1px 2px;
  border-radius: 999px;
  background: #fff;
  color: #14532d;
  font-size: .7rem;
  font-weight: 700;
  white-space: nowrap;
  box-shadow: 0 0 0 2px var(--checkpoint-color, #16a34a), 0 2px 5px rgba(0, 0, 0, .3);
}
.gps-checkpoint-pin span {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--checkpoint-color, #16a34a);
  box-shadow: 0 0 0 2px #fff;
  animation: gps-checkpoint-pulse 2s ease-out infinite;
}
.gps-checkpoint-pin.gps-legend-dot {
  padding: 1px;
  box-shadow: none;
  background: transparent;
}
@keyframes gps-checkpoint-pulse { 0% { box-shadow: 0 0 0 2px #fff, 0 0 0 2px rgba(22, 163, 74, .6); } 100% { box-shadow: 0 0 0 2px #fff, 0 0 0 10px rgba(22, 163, 74, 0); }
}
@media (prefers-reduced-motion: reduce) {
  .gps-checkpoint-pin span {
    animation: none;
  }
}
/* Mission timeline: status steps with phone GPS, leg durations, numbered map pins */
/* Status colours: each timeline step has its own tint (grey and dashed until it happens) */
/* Crew cards (GPS map and live page): background tint by vehicle status, matching the left rail */
/* Crew card status line while heading out (red) or back (green): running text on a softly blinking band */
/* Map legend: 30% smaller and see-through with a faint shadow so it covers less of the map; solid again on hover */
.gps-legend {
  display: grid;
  gap: .25rem;
  padding: .4rem .6rem;
  border-radius: 10px;
  color: #1f2937;
  font-size: .75rem;
  transform: scale(.7);
  transform-origin: bottom left;
  background: rgba(255, 255, 255, .55);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  box-shadow: 0 1px 2px rgba(0, 0, 0, .12);
  transition: background .2s, box-shadow .2s;
}
.gps-legend:hover {
  background: rgba(255, 255, 255, .92);
  box-shadow: 0 1px 4px rgba(0, 0, 0, .2);
}
/* TV mode keeps its full-size legend for reading across the room */
/* Satellite + road names: dim the imagery a little and give Esri's road lines a dark outline so they stand out */
.leaflet-layer.gps-sat-under-roads {
  filter: brightness(.72) contrast(1.08) saturate(1.1);
}
.leaflet-layer.gps-road-overlay {
  filter: saturate(2.4) contrast(1.35) brightness(1.15) drop-shadow(0 0 1px rgba(0, 0, 0, .95)) drop-shadow(0 0 1.5px rgba(0, 0, 0, .6));
}
.gps-inset {
  position: absolute;
  right: 10px;
  bottom: 26px;
  z-index: 800;
  width: clamp(192px, 22.4%, 352px);
  overflow: hidden;
  background: #fff;
  border: 2px solid #fff;
  box-shadow: 0 4px 16px rgba(0, 0, 0, .35);
  border-color: var(--line);
  border-radius: var(--r-inner);
}
.gps-inset-head {
  display: flex;
  align-items: center;
  gap: .4rem;
  padding: .3rem .5rem;
  font-size: .8rem;
  font-weight: 600;
  background: var(--primary);
  color: #fff;
  box-shadow: none;
}
/* Map popups and controls follow the theme */
.leaflet-popup-content-wrapper,
.leaflet-popup-tip {
  background: var(--card);
  color: var(--ink);
  box-shadow: var(--shadow-lift);
}
.leaflet-popup-content-wrapper {
  border-radius: var(--r-inner);
  border: 1px solid var(--line);
}
/* ---------- Map page (แผนที่): type chips, GPS state dots, the folded symbol key (gps-map.js) ---------- */
/* Mission type on crew cards and popups: a neutral chip with the type's colour as a dot, like the app's type chips */
.gps-type-chip {
  vertical-align: middle;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-left: 6px;
  padding: 1px 9px;
  border: 0;
  border-radius: 999px;
  background: var(--soft);
  color: var(--ink);
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}
.gps-type-chip::before {
  content: '';
  flex-shrink: 0;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--dot, var(--muted));
}
.gps-type-chip.is-refer {
  color: #1d4ed8;
  background: #eff6ff;
  border-color: #bfdbfe;
  --dot: var(--type-refer);
}
.gps-type-chip.is-ems {
  color: #c2410c;
  background: #fff7ed;
  border-color: #fed7aa;
  --dot: var(--type-ems);
}
.gps-type-chip.is-mobile_unit {
  color: #7e22ce;
  background: #faf5ff;
  border-color: #e9d5ff;
  --dot: var(--type-mobile);
}
.gps-type-chip.is-staff_transport {
  color: #0e7490;
  background: #ecfeff;
  border-color: #a5f3fc;
  --dot: var(--type-staff);
}
.gps-type-chip.is-lab_transport {
  color: #047857;
  background: #ecfdf5;
  border-color: #a7f3d0;
  --dot: var(--type-lab);
}
/* GPS state in words after a coloured dot (stateText): moving green, online blue, over the limit red, parked grey */
.gps-state-dot {
  display: inline-block;
  flex-shrink: 0;
  width: 8px;
  height: 8px;
  margin-right: 6px;
  border-radius: 50%;
  background: var(--off-edge);
  vertical-align: 1px;
}
.gps-state-dot.is-moving {
  background: var(--done);
}
.gps-state-dot.is-stopped {
  background: var(--ready-edge);
}
.gps-state-dot.is-overspeed {
  background: var(--mission);
}
.gps-state-dot.is-parked {
  background: var(--off-edge);
}
.gps-state-dot.is-offline {
  background: var(--card);
  box-shadow: inset 0 0 0 2px var(--off-edge);
}
/* Vehicle icons in the crew cards and the vehicle list */
:is(.gps-crew-item, .gps-vehicle) strong > .icon {
  width: 18px;
  height: 18px;
  margin-right: 6px;
  color: var(--primary);
  vertical-align: -3px;
}
/* The symbol key: a round "สัญลักษณ์" button, the key opens above it */
details.gps-legend {
  display: block;
  padding: 0;
  border-radius: var(--r-inner);
  background: var(--card);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.25);
}
details.gps-legend > summary {
  display: flex;
  align-items: center;
  min-height: 40px;
  padding: 0 14px;
  color: var(--ink);
  font-size: 13px;
  font-weight: 600;
  list-style: none;
  cursor: pointer;
}
details.gps-legend > summary::-webkit-details-marker {
  display: none;
}
details.gps-legend > summary:focus-visible {
  outline: 3px solid var(--primary);
  outline-offset: 1px;
  border-radius: var(--r-inner);
}
details.gps-legend .gps-legend-body {
  display: grid;
  gap: 4px;
  padding: 0 12px 10px;
  color: var(--ink);
  font-size: 12px;
}
details.gps-legend .gps-legend-body span {
  display: flex;
  align-items: center;
  gap: 6px;
}
/* Group labels on the app map (gps-vehicles.css draws the shape) */
.gps-group {
  border: 1px solid var(--line-strong);
  background: #FFFFFF;
  color: var(--ink);
  box-shadow: 0 6px 18px rgba(15, 23, 42, .18);
}
.gps-group:focus-visible {
  outline: 3px solid var(--primary);
  outline-offset: 2px;
}
.gps-group-head small,
.gps-group-row span {
  color: var(--muted);
}
.gps-group-more {
  color: var(--primary-hover);
}
/* ---------- Map page layout: list panel (3 tabs) + map. Below 1024px the page fills the room between the bars and
   the panel is a bottom sheet over the map; from 1024px it is a 340px panel left of the map. Scoped to the app
   (#app-main-layout): live.html shares #gps-map and gps-map.js ---------- */
.map-panel {
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r-card);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.map-panel-handle {
  display: none;
}
.map-tabs {
  display: flex;
  flex-shrink: 0;
  gap: 4px;
  margin: 12px 12px 0;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: var(--r-pill);
  background: var(--soft);
}
.map-tabs [role="tab"] {
  flex: 1;
  min-height: 40px;
  padding: 0 6px;
  border: 0;
  border-radius: var(--r-pill);
  background: none;
  color: var(--muted);
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
  transition: box-shadow .12s, transform .12s;
}
.map-tabs [role="tab"][aria-selected="true"] {
  background: var(--card);
  color: var(--primary);
  box-shadow: var(--key-white);
}
.map-tabs [role="tab"]:active {
  transform: translateY(2px);
  box-shadow: var(--key-white-down);
}
.map-tabs [role="tab"]:focus-visible {
  outline: 3px solid var(--primary);
  outline-offset: -3px;
}
.map-pane {
  flex: 1;
  min-height: 0;
  padding: 12px;
  overflow-y: auto;
  overscroll-behavior: contain;
}
.map-pane-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}
.map-pane-head .gps-crew-summary {
  flex: 1;
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}
.map-pane .gps-crew-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 40px;
  margin: 0;
  color: var(--ink);
  font-size: 13px;
  white-space: nowrap;
}
.map-pane .gps-crew-toggle input {
  width: 18px;
  height: 18px;
  accent-color: var(--primary);
}
.map-pane :is(.gps-crew-list, .gps-vehicle-list) {
  gap: 8px;
}
.map-pane :is(.gps-crew-item, .gps-vehicle) {
  gap: 4px;
  min-height: 56px;
  padding: 10px 12px;
  border-radius: var(--r-inner);
  border-color: var(--line);
  background: var(--card);
  color: var(--ink);
  font: inherit;
  font-size: 14px;
  cursor: pointer;
}
.map-pane :is(.gps-crew-item, .gps-vehicle):hover {
  background: #F8FAFC;
}
.map-pane :is(.gps-crew-item, .gps-vehicle) strong {
  font-size: 16px;
}
.map-pane :is(.gps-crew-item small, .gps-vehicle small, .gps-vehicle span) {
  color: var(--muted);
  font-size: 12px;
}
/* Crew cards, design ก "เส้นทางเดินทาง" (user's pick 2026-11-01): a light grey card with a soft shadow, the leg's colour
   along the top, the leg as a line with the vehicle on it, then the crew and the speed (gps-map.js crewCard).
   Leg colours keep white text at AA: out red, back green, at the destination amber, waiting blue, standby green. */
.map-pane .gps-crew-item::before {
  content: '';
  position: absolute;
  inset: 0 0 auto;
  height: 4px;
  background: var(--leg);
}
.map-pane .gps-crew-item:focus-visible {
  outline: 3px solid var(--leg);
  outline-offset: 2px;
}
.map-pane .gps-crew-item .gps-crew-top {
  display: flex;
  align-items: flex-start;
  gap: 8px;
}
.map-pane .gps-crew-item .gps-crew-top strong {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  min-width: 0;
  font-size: 18px;
  font-weight: 700;
}
.map-pane .gps-crew-item .gps-crew-top strong > .icon {
  margin-right: 0;
  color: var(--leg);
}
.map-pane .gps-crew-item .gps-crew-badge {
  flex: none;
  margin-left: auto;
  padding: 2px 10px;
  border-radius: 10px;
  background: var(--leg);
  color: #FFFFFF;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
}
.map-pane .gps-crew-item .gps-crew-route {
  display: grid;
  grid-template-columns: minmax(0, auto) minmax(48px, 1fr) minmax(0, auto);
  align-items: center;
  gap: 10px;
}
.map-pane .gps-crew-item .gps-crew-end {
  display: grid;
  max-width: 120px;
  min-width: 0;
  line-height: 1.25;
}
.map-pane .gps-crew-item .gps-crew-end.is-to {
  justify-items: end;
  text-align: right;
}
.map-pane .gps-crew-item .gps-crew-end b {
  color: var(--ink);
  font: 600 17px/1.2 var(--font-mono);
  font-variant-numeric: tabular-nums;
}
.map-pane .gps-crew-item .gps-crew-end small {
  color: var(--muted);
  font-size: 12.5px;
  overflow-wrap: anywhere;
}
.map-pane .gps-crew-item .gps-crew-track {
  position: relative;
  height: 24px;
}
.map-pane .gps-crew-item .gps-crew-track::before {
  content: '';
  position: absolute;
  top: 11px;
  right: 0;
  left: 0;
  border-top: 2px dashed #CBD5E1;
}
.map-pane .gps-crew-item .gps-crew-fill {
  position: absolute;
  top: 10px;
  left: 0;
  width: var(--p, 0%);
  height: 4px;
  border-radius: 4px;
  background: var(--leg);
}
.map-pane .gps-crew-item .gps-crew-car {
  position: absolute;
  top: 0;
  left: var(--p, 0%);
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--leg);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--leg) 22%, transparent);
  transform: translateX(-50%);
}
.map-pane .gps-crew-item .gps-crew-car .icon {
  width: 14px;
  height: 14px;
  margin: 0;
  color: #FFFFFF;
}
.map-pane .gps-crew-item:is(.is-out, .is-back) .gps-crew-car {
  animation: gps-crew-glide 2.4s ease-in-out infinite;
}
@keyframes gps-crew-glide {
  0%, 100% { transform: translateX(-50%); }
  50% { transform: translateX(calc(-50% + 3px)); }
}
.map-pane .gps-crew-item .gps-crew-left {
  margin-top: -4px;
  color: var(--muted);
  font-size: 13px;
  text-align: center;
}
.map-pane .gps-crew-item .gps-crew-left b {
  color: var(--ink);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.map-pane .gps-crew-item .gps-crew-people {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}
.map-pane .gps-crew-item .gps-crew-avatar {
  position: relative;
  display: grid;
  flex: none;
  place-items: center;
  width: 42px;
  height: 42px;
  overflow: hidden;
  border-radius: 50%;
  background: var(--primary-soft);
  box-shadow: 0 0 0 2px #FFFFFF, 0 2px 6px rgba(15, 23, 42, .16);
  color: var(--primary-hover);
  font-size: 14px;
  font-weight: 600;
}
/* The driver's photo covers the initials; if it fails to load it removes itself and the initials show */
.map-pane .gps-crew-item .gps-crew-photo {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.map-pane .gps-crew-item .gps-crew-who {
  display: grid;
  gap: 2px;
  min-width: 0;
  color: var(--ink);
  font-size: 14px;
  line-height: 1.35;
}
.map-pane .gps-crew-item .gps-crew-who > span {
  font-weight: 600;
}
/* The GPS state stays on one line; one too long for the card slides to show the rest and back (gps-map.js
   fitCrewLines). With reduced motion it ends in … instead; the full words are in its title either way. */
.map-pane .gps-crew-item .gps-crew-gps {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.map-pane .gps-crew-item .gps-crew-gps.is-long {
  text-overflow: clip;
}
.map-pane .gps-crew-item .gps-crew-gps.is-long .gps-crew-gps-text {
  display: inline-block;
  animation: gps-crew-slide var(--slide, 8s) ease-in-out infinite alternate;
}
@keyframes gps-crew-slide {
  0%, 18% { transform: translateX(0); }
  82%, 100% { transform: translateX(var(--shift, 0)); }
}
@media (prefers-reduced-motion: reduce) {
  .map-pane .gps-crew-item .gps-crew-gps.is-long {
    text-overflow: ellipsis;
  }
  .map-pane .gps-crew-item .gps-crew-gps.is-long .gps-crew-gps-text {
    display: inline;
    animation: none;
  }
}
.map-pane .gps-crew-item .gps-crew-gauge {
  flex: none;
  width: 70px;
  margin-left: auto;
}
.map-pane .gps-crew-item .gps-crew-gauge svg {
  display: block;
  width: 100%;
  height: auto;
}
/* Dial ค (gps-map.js crewGauge): dark face, white ticks, red zone from the case's limit, red needle, green LCD digits */
.gps-gauge-face {
  stroke: #9FB3A9;
  stroke-width: 2;
}
.gps-gauge-zone {
  fill: none;
  stroke: #FF4D5E;
  stroke-width: 4;
}
.gps-gauge-tick {
  stroke: #8FA39A;
  stroke-width: .8;
  stroke-linecap: round;
}
.gps-gauge-tick.is-major {
  stroke: #E9F3EE;
  stroke-width: 1.6;
}
.gps-gauge-needle {
  fill: #FF4D5E;
  transform: rotate(var(--to));
  transform-origin: 50px 50px;
  animation: gps-gauge-sweep .9s cubic-bezier(.2, .8, .3, 1.15) both;
}
@keyframes gps-gauge-sweep {
  from { transform: rotate(var(--from)); }
  to { transform: rotate(var(--to)); }
}
.gps-gauge-hub {
  fill: #0B1712;
  stroke: #FF4D5E;
  stroke-width: 2;
}
.gps-gauge-screen {
  fill: #06110C;
  stroke: #2E4A3E;
  stroke-width: 1;
}
.gps-gauge-digits {
  fill: #7CFFB2;
  font: 700 15px var(--font);
  text-anchor: middle;
}
.gps-gauge-unit {
  fill: #B4C6BD;
  font: 500 8px var(--font);
  text-anchor: middle;
}
.gps-crew-gauge:is(.is-stopped, .is-parked) .gps-gauge-digits {
  font-size: 12px;
}
.gps-crew-gauge.is-overspeed .gps-gauge-digits {
  fill: #FF8A96;
  animation: gps-gauge-blink 1s steps(2, start) infinite;
}
@keyframes gps-gauge-blink { to { opacity: .35; }
}
.gps-crew-gauge.is-offline svg {
  opacity: .5;
}
.gps-crew-gauge.is-offline .gps-gauge-digits {
  fill: #B4C6BD;
}
@media (prefers-reduced-motion: reduce) {
  .map-pane .gps-crew-item .gps-crew-car,
  .gps-gauge-needle,
  .gps-crew-gauge.is-overspeed .gps-gauge-digits {
    animation: none;
  }
}
#map-pane-track .gps-track-panel {
  gap: 10px;
}
#map-pane-track .gps-track-panel label {
  color: var(--ink);
  font-size: 13px;
  font-weight: 600;
}
#map-pane-track .gps-track-panel :is(select, input:not([type="range"])) {
  min-height: 44px;
  font-size: 16px;
}
#map-pane-track :is(.gps-track-presets, .gps-track-actions) {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
@media (min-width: 1024px) {
  #app-main-layout #view-map .map-head {
    margin-bottom: 12px;
  }
  #app-main-layout .gps-view-layout {
    display: grid;
    grid-template-columns: 340px minmax(0, 1fr);
    gap: 12px;
    align-items: stretch;
    height: max(520px, calc(100vh - 150px));
  }
  #app-main-layout .gps-map-wrap {
    order: 0;
    height: 100%;
    min-height: 0;
  }
  #app-main-layout #gps-map {
    height: 100%;
    min-height: 0;
    border: 1px solid var(--line);
    border-radius: var(--r-card);
  }
}
@media (max-width: 1023.98px) {
  /* The page fills the room between the top bar and the tab bar; nothing scrolls but the sheet */
  #app-main-layout #view-map.active {
    position: fixed;
    top: var(--topbar-h);
    right: 0;
    bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
    left: 0;
    z-index: 5;
    display: flex;
    flex-direction: column;
    background: var(--bg);
  }
  #app-main-layout:has(#view-map.active) > .app-footer {
    display: none;
  }
  #app-main-layout #view-map .map-head {
    flex-shrink: 0;
    flex-wrap: nowrap;
    min-height: 60px;
    margin: 0;
    padding: 8px 12px 8px 16px;
    background: var(--card);
    border-bottom: 1px solid var(--line);
  }
  #app-main-layout #view-map .map-head h2 {
    font-size: 17px;
  }
  #app-main-layout #view-map .map-head p {
    font-size: 12px;
  }
  #app-main-layout .gps-view-layout {
    position: relative;
    display: block;
    flex: 1;
    min-height: 0;
  }
  #app-main-layout .gps-map-wrap {
    position: absolute;
    inset: 0;
  }
  #app-main-layout #gps-map {
    height: 100%;
    min-height: 0;
    border-radius: 0;
  }
  /* The sheet: folded it shows the handle, the tabs and the top of the first card */
  #app-main-layout .map-panel {
    position: absolute;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 1000;
    height: 206px;
    border: 0;
    border-radius: var(--r-card) var(--r-card) 0 0;
    box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.18);
    transition: height 0.2s ease;
  }
  #app-main-layout .map-panel[data-open="true"] {
    height: 70%;
  }
  #app-main-layout .map-panel-handle {
    display: flex;
    flex-shrink: 0;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 28px;
    padding: 0;
    border: 0;
    background: none;
    cursor: pointer;
  }
  #app-main-layout .map-panel-handle span {
    width: 44px;
    height: 5px;
    border-radius: 3px;
    background: var(--line-strong);
  }
  #app-main-layout .map-panel-handle:focus-visible {
    outline: 3px solid var(--primary);
    outline-offset: -3px;
  }
  /* Leaflet's bottom controls (symbol key, attribution) and the empty note sit above the folded sheet */
  #app-main-layout #gps-map .leaflet-bottom {
    bottom: 214px;
  }
  #app-main-layout .gps-map-empty {
    bottom: 222px;
  }
}
@media (max-width: 1023.98px) and (prefers-reduced-motion: reduce) {
  #app-main-layout .map-panel {
    transition: none;
  }
}
/* ---------- Map crew cards (แผนที่): the shift after each driver's name ---------- */
.gps-crew-shift {
  display: inline-block;
  max-width: 100%;
  padding: 0 7px;
  border-radius: 10px;
  background: var(--done-bg);
  color: var(--done);
  font-size: 12px;
  font-weight: 600;
  line-height: 1.6;
  vertical-align: 1px;
}
/* ---------- Map crew cards (แผนที่): the case colour after Refer / EMS ---------- */
.gps-triage {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-left: 6px;
  padding: 0 8px 0 6px;
  border: 1px solid;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.6;
  vertical-align: middle;
  white-space: nowrap;
}
.gps-triage::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
}
.gps-triage.is-red {
  color: #A4161A;
  background: #FDECEC;
  border-color: #F5B5B5;
}
.gps-triage.is-pink {
  color: #9D174D;
  background: #FCE7F3;
  border-color: #F9A8D4;
}
.gps-triage.is-yellow {
  color: #854D0E;
  background: #FEF3C7;
  border-color: #FCD34D;
}
.gps-triage.is-green {
  color: #166534;
  background: #DCFCE7;
  border-color: #86EFAC;
}
/* Nurse on board, after the driver's name; no nurse is an amber warning */
.gps-nurse {
  display: inline-block;
  padding: 0 8px;
  border: 1px solid;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.6;
  white-space: nowrap;
  vertical-align: 1px;
}
.gps-nurse::before {
  content: "✓ " / "";
}
.gps-nurse.is-yes {
  color: #075985;
  background: #E0F2FE;
  border-color: #7DD3FC;
}
.gps-nurse.is-no {
  color: #9A3412;
  background: #FFEDD5;
  border-color: #FDBA74;
}
.gps-nurse.is-no::before {
  content: "! " / "";
}
.map-pane .gps-crew-item,
.map-pane .gps-crew-item.is-standby {
  --leg: #15803D;
}
/* Map fullscreen leaves the top bar outside, so the page names itself again */
#view-map:fullscreen .page-head h2 {
  position: static;
  width: auto;
  height: auto;
  overflow: visible;
  clip: auto;
  white-space: normal;
}
/* ---------- Map crew cards by state (2026-11-09, user: "การ์ดสีกลืนกันหมด", design ก): a mission card is tinted with its
   leg's colour under a thicker bar of it — on the way red, at the destination amber, on the way back green, waiting
   blue; a free crew is a plain white card with an outlined พร้อม, so the vehicles at work stand out ---------- */
.map-pane .gps-crew-item.is-out {
  --leg: #C8102E;
  --tint: #FFF1F2;
  --tint-edge: #F9C9D2;
}
.map-pane .gps-crew-item.is-at {
  --leg: #B45309;
  --tint: #FFF7E8;
  --tint-edge: #F3D9A9;
}
.map-pane .gps-crew-item.is-back {
  --leg: #0F7A49;
  --tint: #ECFDF3;
  --tint-edge: #B9E6CC;
}
.map-pane .gps-crew-item.is-wait {
  --leg: #1D5FAF;
  --tint: #EFF6FF;
  --tint-edge: #C6DAF6;
}
.map-pane .gps-crew-item.is-standby {
  --tint: #FFFFFF;
  --tint-edge: var(--line);
}
.map-pane .gps-crew-item {
  position: relative;
  display: grid;
  gap: 10px;
  padding: 14px 14px 12px;
  overflow: hidden;
  border-radius: var(--r-inner);
  box-shadow: 0 1px 2px rgba(15, 23, 42, .05), 0 6px 16px rgba(15, 23, 42, .07);
  text-align: left;
  border: 1px solid var(--tint-edge, var(--line));
  background: var(--tint, #FFFFFF);
}
.map-pane .gps-crew-item:hover {
  box-shadow: 0 2px 4px rgba(15, 23, 42, .07), 0 10px 22px rgba(15, 23, 42, .1);
  background: var(--tint, #FFFFFF);
  filter: brightness(.985);
}
.map-pane .gps-crew-item:is(.is-out, .is-at, .is-back, .is-wait)::before {
  height: 6px;
}
.map-pane .gps-crew-item.is-standby::before {
  height: 3px;
}
.map-pane .gps-crew-item.is-standby .gps-crew-badge {
  border: 1.5px solid var(--leg);
  background: #FFFFFF;
  color: var(--leg);
}

/* ---------- views: พลขับ (#view-driver) and the driver's dialogs (เข้าเวร + ตรวจเช็ครถ, เปลี่ยนรถ, ปิดงาน, ส่งต่ออีกที่, รับงาน HOSxP,
   สัญญาณชีพ, แจ้งออกเหตุทางโทรศัพท์, กล้อง) incl. the form-dialog frame they share with the admin forms ---------- */
@media (max-width: 1024px) {
  .cockpit-grid {
    grid-template-columns: 1fr;
  }
}
/* Forms and Inputs */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin-bottom: 1rem;
}
/* Buttons */
.btn-warning {
  background: linear-gradient(135deg, var(--duty-edge), #d97706);
  color: #111827;
  box-shadow: 0 4px 14px rgba(217, 119, 6, .3);
}
.btn-warning:hover {
  background: linear-gradient(135deg, #fbbf24, var(--duty-edge));
  transform: translateY(-1px);
}
.btn-block {
  width: 100%;
}
/* Modal Styling */
.close-btn {
  background: transparent;
  font-size: 1.5rem;
  cursor: pointer;
  line-height: 1;
  padding: 4px;
}
/* =========================================================
   DRIVER AVATAR & PHOTO UPLOAD STYLES
   ========================================================= */
.driver-avatar img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  border-radius: 0;
  display: block;
}
/* Mission Type Selector Cards */
.mission-type-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
  gap: 0.5rem;
  margin-top: 0.35rem;
}
.mission-type-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 0.65rem 0.4rem;
  border-radius: var(--r-inner);
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.03);
  cursor: pointer;
  transition: all .2s ease;
  text-align: center;
  position: relative;
  user-select: none;
}
.mission-type-card input[type="radio"] {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}
.mission-type-card:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.3);
}
.mission-type-card.selected {
  border-color: #3b82f6;
  background: rgba(59, 130, 246, 0.15);
  box-shadow: 0 0 12px rgba(59, 130, 246, 0.25);
}
.mission-type-card.selected[data-type="ems"] {
  border-color: #f59e0b;
  background: rgba(245, 158, 11, 0.15);
  box-shadow: 0 0 12px rgba(245, 158, 11, 0.25);
}
.mission-type-card.selected[data-type="mobile_unit"] {
  border-color: #a855f7;
  background: rgba(168, 85, 247, 0.15);
  box-shadow: 0 0 12px rgba(168, 85, 247, 0.25);
}
.mission-type-card.selected[data-type="staff_transport"] {
  border-color: #06b6d4;
  background: rgba(6, 182, 212, 0.15);
  box-shadow: 0 0 12px rgba(6, 182, 212, 0.25);
}
.mission-type-card.selected[data-type="lab_transport"] {
  border-color: #10b981;
  background: rgba(16, 185, 129, 0.15);
  box-shadow: 0 0 12px rgba(16, 185, 129, 0.25);
}
.mtc-icon {
  font-size: 1.4rem;
  margin-bottom: 0.2rem;
}
.mtc-title {
  font-size: 0.78rem;
  font-weight: 600;
  color: #e2e8f0;
  line-height: 1.2;
}
/* Base styles for mobile elements */
.modal-drag-handle {
  display: none;
}
@media (min-width: 768px) and (max-width: 1024px) {
  .cockpit-grid {
    grid-template-columns: 1fr;
    gap: 1.25rem;
  }
}
@media (max-width: 767px) {
  /* Cockpit Layout for Mobile: Prioritize Mission Panel */
  .cockpit-grid {
    display: flex;
    flex-direction: column;
    gap: 1rem;
  }
  .driver-card {
    order: 2;
  }
  /* Depart Action: Stacks vertically for thumb-friendly interaction */
  .depart-mileage-row {
    flex-direction: column;
    gap: 0.65rem;
  }
  .depart-mileage-row input {
    max-width: 100%;
    width: 100%;
    min-height: 48px;
    font-size: 1.1rem;
    font-weight: 700;
    text-align: center;
  }
  .depart-mileage-row button {
    width: 100%;
    min-height: 50px;
    white-space: normal;
  }
  /* Modern Mobile Modal Bottom Sheet */
  .modal-drag-handle {
    display: block;
    width: 40px;
    height: 4px;
    background: rgba(255, 255, 255, 0.28);
    border-radius: 4px;
    margin: 8px auto 2px auto;
  }
}
@media (max-width: 480px) {
  /* Stepper Timeline on narrow screens */
  .timeline-stepper {
    margin: 1.25rem 0;
  }
  .timeline-stepper::before {
    top: 15px;
    left: 15px;
    right: 15px;
    height: 3px;
  }
  .step-circle {
    width: 30px;
    height: 30px;
    font-size: 0.75rem;
  }
  .step-title {
    font-size: 0.68rem;
    line-height: 1.15;
  }
  .step-time {
    font-size: 0.62rem;
  }
}
/* ============================================== */
.photo-capture-box {
  border-radius: var(--r-card);
  transition: all .2s ease;
}
.photo-capture-box:hover {
  border-color: #60a5fa;
}
.photo-capture-box.has-photo {
  border-style: solid;
  border-color: #10b981;
}
.pcb-subtext {
  max-width: 90%;
}
.photo-capture-box.has-photo .pcb-btn-camera {
  background: linear-gradient(135deg, #059669, #047857);
  box-shadow: 0 4px 14px rgba(5, 150, 105, 0.35);
}
.photo-capture-box.has-photo .pcb-btn-camera:hover {
  background: linear-gradient(135deg, #10b981, #059669);
}
/* ============================================== */
.live-camera-container {
  width: 100%;
  max-width: 520px;
  background: #000;
  border-radius: 20px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: 0 25px 60px rgba(0,0,0,0.9);
  border: 1px solid rgba(255,255,255,0.15);
  position: relative;
}
@media (max-width: 640px) {
  .live-camera-container {
    max-width: 100%;
    height: 100vh;
    max-height: 100vh;
    border-radius: 0;
  }
}
.live-cam-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.85rem 1.2rem;
  backdrop-filter: blur(10px);
  z-index: 10;
  border-bottom: 1px solid rgba(255,255,255,0.1);
}
@keyframes liveCamPulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.3; transform: scale(0.8); }
}
.live-cam-info {
  text-align: center;
}
.live-cam-close:hover {
  background: rgba(239, 68, 68, 0.6);
}
.live-cam-viewport {
  position: relative;
  width: 100%;
  height: 380px;
  background: #050505;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}
@media (max-width: 640px) {
  .live-cam-viewport {
    flex: 1;
    height: auto;
  }
}
#live-camera-video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.live-cam-reticle {
  position: absolute;
  top: 12%;
  left: 10%;
  right: 10%;
  bottom: 12%;
  pointer-events: none;
}
.live-cam-reticle .corner {
  position: absolute;
  width: 28px;
  height: 28px;
  border-color: rgba(96, 165, 250, 0.85);
  border-style: solid;
}
.live-cam-reticle .top-left {
  top: 0;
  left: 0;
  border-width: 3px 0 0 3px;
  border-top-left-radius: 6px;
}
.live-cam-reticle .top-right {
  top: 0;
  right: 0;
  border-width: 3px 3px 0 0;
  border-top-right-radius: 6px;
}
.live-cam-reticle .bottom-left {
  bottom: 0;
  left: 0;
  border-width: 0 0 3px 3px;
  border-bottom-left-radius: 6px;
}
.live-cam-reticle .bottom-right {
  bottom: 0;
  right: 0;
  border-width: 0 3px 3px 0;
  border-bottom-right-radius: 6px;
}
.live-cam-crosshair {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 20px;
  height: 20px;
  transform: translate(-50%, -50%);
}
.live-cam-crosshair::before,
.live-cam-crosshair::after {
  content: '';
  position: absolute;
  background: rgba(255,255,255,0.4);
}
.live-cam-crosshair::before {
  top: 9px;
  left: 0;
  width: 20px;
  height: 2px;
}
.live-cam-crosshair::after {
  top: 0;
  left: 9px;
  width: 2px;
  height: 20px;
}
.live-cam-guide {
  position: absolute;
  bottom: 12px;
  left: 0;
  right: 0;
  text-align: center;
  pointer-events: none;
}
.live-cam-flash {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: #fff;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease-out;
}
.live-cam-flash.flash-active {
  opacity: 0.92;
  transition: none;
}
.live-cam-controls {
  padding: 1.25rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-around;
  border-top: 1px solid rgba(255,255,255,0.1);
  padding-bottom: max(1.25rem, env(safe-area-inset-bottom));
}
.live-cam-tool-btn:hover {
  background: rgba(255,255,255,0.18);
  transform: scale(1.05);
}
.live-cam-shutter {
  width: 76px;
  height: 76px;
  border-radius: 50%;
  background: transparent;
  border: 4px solid #fff;
  padding: 4px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 20px rgba(255,255,255,0.4);
  transition: 0.15s;
}
.live-cam-shutter:hover {
  transform: scale(1.06);
  box-shadow: 0 0 25px rgba(59, 130, 246, 0.6);
}
.live-cam-shutter:active {
  transform: scale(0.92);
}
.shutter-inner {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: #ef4444;
  transition: 0.15s;
}
.live-cam-shutter:hover .shutter-inner {
  background: #dc2626;
}
/* Nurse Escort Toggle Cards */
.nurse-option-card {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.6rem 0.85rem;
  border-radius: var(--r-inner);
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.03);
  cursor: pointer;
  transition: all 0.2s ease;
}
.nurse-option-card:hover {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.2);
}
.nurse-option-card.selected.yes {
  border-color: rgba(16, 185, 129, 0.6);
  background: rgba(16, 185, 129, 0.12);
}
.nurse-option-card.selected.no {
  border-color: rgba(239, 68, 68, 0.6);
  background: rgba(239, 68, 68, 0.12);
  box-shadow: 0 0 10px rgba(239, 68, 68, 0.15);
}
@media screen {
  .login-help {
    font-size: .8rem;
    color: var(--muted);
    margin-top: 6px;
  }
  .photo-capture-box {
    box-shadow: none;
  }
  .pcb-title {
    color: #7e22ce;
  }
  /* Inline color adaptations */
  #modal-live-camera [style*="color: #fff"] {
    color: #fff;
  }
  .status-off-duty,
  .pcb-subtext {
    color: #49494f;
  }
  .status-on-duty {
    color: #137b45;
  }
  .status-en-route {
    color: #915100;
  }
}
/* Saving feedback remains visible above every dialog, including the camera. */
.form-feedback {
  padding: 12px 14px;
  margin: 12px 0;
  border: 1px solid #f0b7b3;
  border-radius: var(--r-inner);
  background: #fff0ee;
  color: #9d241e;
  font-size: .9rem;
  line-height: 1.6;
  overflow-wrap: anywhere;
}
.form-feedback[hidden] {
  display: none;
}
@media screen {
  .cockpit-grid > *,
  .form-group {
    min-width: 0;
  }
}
@media screen and (min-width: 1025px) {
  .cockpit-grid {
    grid-template-columns: minmax(280px, 340px) minmax(0, 1fr);
  }
}
@media screen and (max-width: 767px) {
  #view-driver > .glass-card > :first-child {
    flex-wrap: wrap;
    width: 100%;
  }
  #driver-selector {
    min-width: 0;
    width: 100%;
  }
  #shift-info-box > div {
    gap: .75rem;
    flex-wrap: wrap;
  }
}
@media screen {
  .driver-avatar img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
    object-position: center;
    border-radius: 0;
    background: #f7f9fc;
  }
  .driver-avatar {
    padding: 3px;
    border-width: 1px;
    border-style: solid;
    border-color: #cdd8e6;
    border-radius: 9px;
    background: linear-gradient(145deg, #ffffff, #e8eef6);
    box-shadow: 0 3px 7px rgba(32, 55, 85, .12), 0 1px 2px rgba(32, 55, 85, .08), inset 0 1px 0 rgba(255, 255, 255, .95);
    flex-shrink: 0;
    width: 72px;
    height: 72px;
    min-width: 72px;
  }
  .driver-profile-header > :last-child {
    overflow-wrap: anywhere;
  }
}
@media screen and (max-width: 767px) {
  .driver-avatar {
    width: 64px;
    height: 64px;
    min-width: 64px;
  }
}
/* Prominent, full-width phone request action for touch screens. */
.phone-dispatch-icon {
  width: 32px;
  height: 32px;
  flex-shrink: 0;
}
/* ปุ่มรับภารกิจเฉพาะ EMS (2026-12-03): where Refer / ขอใช้รถ are taken instead, and the form shows the EMS card only */
.phone-dispatch-hint {
  margin: 8px 2px 0;
  color: var(--muted);
  font-size: 13px;
}
#phone-mission-type-grid.is-ems-only .mission-type-card:not([data-type="ems"]) {
  display: none;
}
.phone-dispatch-copy {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
  min-width: 0;
}
.phone-dispatch-copy strong {
  font-size: 1.05rem;
  font-weight: 600;
  line-height: 1.4;
  color: #fff;
}
.phone-dispatch-copy small {
  font-size: 0.85rem;
  font-weight: 400;
  line-height: 1.4;
  color: #FFFFFF;
}
.phone-dispatch-arrow {
  font-size: 26px;
  line-height: 1;
  color: #fff;
}
.btn.phone-dispatch-cta:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 28px rgba(147, 51, 234, .38);
  color: #fff;
}
.btn.phone-dispatch-cta:active {
  transform: translateY(1px);
  box-shadow: 0 4px 12px rgba(147, 51, 234, .25);
}
.btn.phone-dispatch-cta:focus-visible {
  outline: 3px solid #ec4899;
  outline-offset: 4px;
}
@media screen {
  .mission-type-card .mtc-title {
    color: #2c1a40;
    font-weight: 600;
    line-height: 1.4;
  }
  .mission-type-card:focus-within {
    outline: 3px solid rgba(147, 51, 234, 0.4);
    outline-offset: 2px;
  }
}
@media screen and (max-width: 767px) {
  .mission-type-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
@media screen {
  /* ---------- Buttons ---------- */
  .close-btn {
    font-size: 1.4rem;
    background: var(--soft);
  }
  .close-btn,
  .modal-close {
    min-width: 44px;
    min-height: 44px;
    width: 36px;
    height: 36px;
    flex-shrink: 0;
    border: 0;
    color: var(--muted);
    border-radius: 50%;
    box-shadow: none;
  }
  .close-btn:hover,
  .modal-close:hover {
    background: rgba(239, 68, 68, .14);
    color: #dc2626;
  }
  /* ---------- Dialogs ---------- */
  .modal-drag-handle {
    background: var(--muted);
    opacity: .4;
  }
  /* ---------- Misc chrome that was purple/green ---------- */
  .photo-capture-box,
  .pcb-preview {
    background: var(--soft);
    border-color: var(--line);
  }
  .photo-capture-box:hover,
  .pcb-preview:hover {
    background: var(--soft);
  }
  .pcb-gps-badge {
    background: var(--soft);
    color: var(--primary);
  }
  .mission-type-card {
    border: 1.5px solid #e5daf5;
    background: #fff;
    transition: all 0.2s ease;
    border-color: var(--line);
    box-shadow: none;
    border-radius: var(--r-inner);
  }
  .mission-type-card.selected[data-type] {
    border-color: var(--primary);
    background: var(--soft);
    box-shadow: 0 0 0 1px var(--primary), 0 8px 18px -6px rgba(37, 99, 235, .25);
  }
  .form-label {
    font-size: 0.92rem;
    margin-bottom: 6px;
    font-family: var(--font);
    color: var(--ink);
    font-weight: 600;
  }
  .mission-type-card:focus-within,
  .btn.phone-dispatch-cta:focus-visible {
    outline-color: var(--primary);
  }
  /* Neutral legacy inline text; coloured statuses keep their own semantics. */
  #modal-live-camera :is([style*="color: #fff"], [style*="color:#fff"]) {
    color: #fff;
  }
}
/* ---------- Forms ---------- */
.form-label {
  color: var(--ink);
  font-size: 13px;
  font-weight: 600;
}
/* ---------- Driver shared: notices, chips, photo capture ---------- */
.notice-info,
.notice-warn {
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 14px;
  line-height: 1.5;
}
.notice-info {
  background: var(--soft);
  border-left: 3px solid var(--primary);
  color: var(--ink);
}
.notice-warn {
  background: var(--duty-bg);
  color: var(--duty);
}
.notice-info .icon,
.notice-warn .icon {
  width: 18px;
  height: 18px;
  margin-right: 4px;
  vertical-align: -4px;
}
.field-req {
  color: var(--mission);
  font-weight: 600;
}
.text-alert {
  color: var(--mission);
  font-weight: 600;
}
.form-grid-2 {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  column-gap: 12px;
}
@media screen and (min-width: 600px) {
  .form-grid-2 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
.photo-capture-box,
.photo-capture-box:hover,
.photo-capture-box.has-photo {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 0;
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
  text-align: left;
}
.pcb-header-badge {
  align-items: center;
  gap: 6px;
  margin-bottom: 0.65rem;
  display: block;
  margin: 0;
  border: 0;
  font-size: 13px;
  font-weight: 600;
}
.photo-capture-box.has-photo .pcb-header-badge {
  border-color: rgba(16, 185, 129, 0.35);
  background: var(--done-bg);
  color: var(--done);
}
.pcb-preview {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all .2s ease;
  min-height: 112px;
  gap: 4px;
  padding: 14px;
  border: 2px dashed var(--line-strong);
  border-radius: var(--r-inner);
  background: var(--card);
  color: var(--ink);
  text-align: center;
}
.pcb-preview:hover {
  border-color: var(--primary);
  background: var(--soft);
}
.pcb-preview > .icon {
  width: 32px;
  height: 32px;
  color: var(--primary);
}
.pcb-title {
  margin-bottom: 0.2rem;
  margin: 0;
  color: var(--ink);
  font-size: 15px;
  font-weight: 600;
}
.pcb-subtext,
.pcb-note {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}
.pcb-gps-badge {
  align-items: center;
  gap: 6px;
  border-radius: 10px;
  max-width: 100%;
  display: block;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}
.pcb-gps-badge .icon {
  width: 16px;
  height: 16px;
  margin-right: 2px;
  vertical-align: -3px;
}
.pcb-gps-badge strong {
  color: var(--ink);
  font-family: var(--font-mono);
  font-weight: 600;
}
.pcb-actions {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  margin-top: 0;
}
.pcb-footer-tools {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.75rem;
  color: var(--muted);
  margin-top: 0.25rem;
  border: 0;
  padding: 0;
  background: transparent;
}
/* ---------- Driver cockpit ---------- */
.cockpit-selector {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 8px;
  margin-bottom: 16px;
  padding: 12px;
}
.cockpit-selector-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  color: var(--muted);
  font-size: 13px;
}
.cockpit-selector-field[hidden],
#btn-enroute-vitals[hidden] {
  display: none;
}
.cockpit-selector-field .form-select {
  width: 100%;
  min-height: 44px;
  font-size: 15px;
}
.cockpit-selector-summary {
  color: var(--ink);
  font-size: 14px;
  line-height: 1.6;
  overflow-wrap: anywhere;
}
.shift-name {
  color: var(--duty);
  font-weight: 600;
}
.cockpit-guide-note {
  font-size: 12px;
  font-weight: 400;
}
.cockpit-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 16px;
}
.cockpit-grid > * {
  min-width: 0;
}
.driver-profile-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-bottom: 0;
  border-bottom: 0;
}
.driver-avatar {
  overflow: hidden;
  position: relative;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 56px;
  height: 56px;
  border: 0;
  border-radius: var(--r-inner);
  background: var(--done-bg);
  color: var(--done);
  font-size: 28px;
}
.driver-profile-text {
  min-width: 0;
}
.driver-name {
  margin: 0;
  color: var(--ink);
  font-size: 18px;
  font-weight: 700;
  overflow-wrap: anywhere;
}
.driver-meta {
  color: var(--muted);
  font-size: 13px;
}
.driver-status-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 6px;
  padding: 3px 10px;
  border: 0;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
  animation: none;
}
.driver-status-badge::before {
  content: '';
  width: 8px;
  height: 8px;
  flex-shrink: 0;
  border-radius: 50%;
  background: currentColor;
}
.status-on-duty {
  background: var(--duty-bg);
  color: var(--duty);
}
.status-en-route {
  background: var(--mission-bg);
  color: var(--mission);
}
.status-off-duty {
  background: var(--soft);
  color: var(--muted);
}
.status-off-duty::before {
  border: 1.5px solid currentColor;
  background: transparent;
}
.shift-info {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 8px 12px;
  margin: 0;
  padding-top: 12px;
  border-top: 1px solid var(--line);
  font-size: 14px;
}
.shift-info dt {
  color: var(--muted);
}
.shift-info dd {
  margin: 0;
  color: var(--ink);
  font-weight: 600;
  text-align: right;
  overflow-wrap: anywhere;
}
.shift-line {
  display: block;
}
.shift-info .chip {
  margin-top: 4px;
}
.shift-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.shift-actions .btn {
  width: 100%;
  min-height: 44px;
}
.btn-checkout {
  border-color: #E5B7B9;
  background: #FFF1F2;
  color: var(--mission);
}
/* หน้าพลขับ: every key its own colour so a driver knows it by colour (user 2026-11-25: "ให้ปุ่มมีสีแยกเป็นเอกลักษณ์…",
   "ปุ่มอื่นในหน้าพลขับสีแยกด้วย"). A key names its colour (.key-*) and .btn-key makes it a 3D key; white text ≥ 5:1 on each.
   เปลี่ยนรถ violet · เติมน้ำมัน orange · ตรวจเช็กรถ blue (.btn-primary) · ออกเวร red tint · โหมดกลางคืน navy · คู่มือ sky tint ·
   เปิดเสียงไซเรน fuchsia · รับงาน & เดินทาง green · ส่งมอบ & กลับ cyan · รับคนไข้กลับ yellow (.btn-warning) · ส่งต่ออีกที่ lime ·
   สัญญาณชีพ rose · ปิดงาน teal · ใบส่งตัว slate tint; tests/driver-keys.browser.cjs: no two keys on screen share a colour */
.btn-key {
  background: var(--key-bg);
  color: #FFFFFF;
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, .28), 0 4px 0 var(--key-edge), 0 10px 20px -6px var(--key-glow);
}
.btn-key:hover {
  background: var(--key-hover);
}
.btn-key:active:not(:disabled) {
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, .2), 0 1px 0 var(--key-edge);
}
.key-navy { --key-bg: #1E293B; --key-hover: #0F172A; --key-edge: #020617; --key-glow: rgba(15, 23, 42, .4); }
.key-violet { --key-bg: #6D28D9; --key-hover: #5B21B6; --key-edge: #4C1D95; --key-glow: rgba(109, 40, 217, .45); }
.key-orange { --key-bg: #C2410C; --key-hover: #9A3412; --key-edge: #7C2D12; --key-glow: rgba(194, 65, 12, .45); }
.key-fuchsia { --key-bg: #A21CAF; --key-hover: #86198F; --key-edge: #701A75; --key-glow: rgba(162, 28, 175, .4); }
.key-rose { --key-bg: #BE185D; --key-hover: #9D174D; --key-edge: #831843; --key-glow: rgba(190, 24, 93, .4); }
.key-green { --key-bg: #15803D; --key-hover: #166534; --key-edge: #14532D; --key-glow: rgba(21, 128, 61, .4); }
.key-cyan { --key-bg: #0E7490; --key-hover: #155E75; --key-edge: #164E63; --key-glow: rgba(14, 116, 144, .4); }
.key-lime { --key-bg: #4D7C0F; --key-hover: #3F6212; --key-edge: #365314; --key-glow: rgba(77, 124, 15, .4); }
.key-teal { --key-bg: #0F766E; --key-hover: #115E59; --key-edge: #134E4A; --key-glow: rgba(15, 118, 110, .4); }
.btn-tint-sky {
  border-color: #7DD3FC;
  background: #E0F2FE;
  color: #075985;
  box-shadow: var(--key-white);
}
.btn-tint-sky:hover {
  background: #BAE6FD;
}
.btn-tint-slate {
  border-color: #CBD5E1;
  background: #F1F5F9;
  color: #0F172A;
  box-shadow: var(--key-white);
}
.btn-tint-slate:hover {
  background: #E2E8F0;
}
.btn-checkout:hover {
  background: var(--mission-bg);
}
/* Standby / off duty */
.standby-state {
  padding: 0;
  text-align: center;
}
/* the shift's state as a small gradient banner (spec 2026-11-21: แถบสถานะเวรเป็นแบนเนอร์ไล่สีขนาดเล็ก); off duty it is slate */
.standby-head {
  margin: 0 0 14px;
  padding: 16px 16px 14px;
  border-radius: var(--r-card);
  background: var(--hero);
  color: #FFFFFF;
  box-shadow: 0 12px 26px -14px rgba(59, 130, 246, .6);
}
.standby-head:has(> .standby-title[data-state="off"]) {
  background: linear-gradient(100deg, #334155 0%, #475569 100%);
  box-shadow: 0 12px 26px -14px rgba(15, 23, 42, .5);
}
.standby-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  margin: 0 auto 8px;
  border-radius: 50%;
  background: rgba(255, 255, 255, .18);
  color: #FFFFFF;
}
.standby-icon .icon {
  width: 24px;
  height: 24px;
  stroke-width: 2.4;
}
.standby-title {
  margin: 0 0 8px;
  color: #FFFFFF;
  font-size: 19px;
  font-weight: 700;
}
.standby-desc {
  max-width: 520px;
  margin: 0 auto 12px;
  color: #FFFFFF;
  font-size: 14px;
  line-height: 1.6;
}
.btn.phone-dispatch-cta {
  border: none;
  border-radius: var(--r-card);
  background: linear-gradient(135deg, #9333ea 0%, #ec4899 100%);
  color: #fff;
  box-shadow: 0 8px 24px rgba(147, 51, 234, .28), 0 2px 6px rgba(236, 72, 153, .2);
  white-space: normal;
  text-align: left;
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  width: 100%;
  min-height: 64px;
}
/* Active mission */
.mission-active > * + * {
  margin-top: 16px;
}
.mission-head {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}
.mission-head-tags {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}
.mission-code {
  color: var(--ink);
  font-size: 16px;
}
.mission-status-chip {
  padding: 4px 10px;
  border-radius: 8px;
  background: var(--soft);
  color: var(--ink);
  font-size: 13px;
  font-weight: 600;
  line-height: 1.5;
}
.mission-status-chip[data-state="wait"] {
  background: var(--duty-bg);
  color: var(--duty);
}
.mission-status-chip[data-state="mission"] {
  background: var(--mission-bg);
  color: var(--mission);
}
.mission-status-chip[data-state="done"] {
  background: var(--done-bg);
  color: var(--done);
}
.mission-info-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 10px;
}
.mission-info {
  min-width: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--card);
}
.mission-info-label {
  margin-bottom: 2px;
  color: var(--muted);
  font-size: 12px;
}
.mission-info-main {
  color: var(--ink);
  font-size: 16px;
  font-weight: 700;
  overflow-wrap: anywhere;
}
.mission-info-sub {
  color: var(--muted);
  font-size: 13px;
  overflow-wrap: anywhere;
}
/* ส่งต่ออีกที่: where a forwarded Refer was handed over on the way, under the place it is heading to now */
#active-stops {
  margin: 2px 0;
  color: var(--ink);
  font-size: 13px;
  font-weight: 600;
  overflow-wrap: anywhere;
}
.forward-from {
  margin: 0 0 12px;
}
.mission-info-line {
  color: var(--ink);
  font-size: 14px;
  overflow-wrap: anywhere;
}
.mission-diagnosis {
  padding: 12px;
  border-radius: 10px;
  background: var(--soft);
  color: var(--ink);
  font-size: 14px;
  overflow-wrap: anywhere;
}
/* 4-step progress */
.timeline-stepper {
  display: flex;
  justify-content: space-between;
  position: relative;
  margin: 0;
  padding: 4px 0;
}
.timeline-stepper::before {
  content: '';
  position: absolute;
  z-index: 1;
  top: 20px;
  left: 12%;
  right: 12%;
  height: 2px;
  background: var(--line-strong);
}
.step-item {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  flex: 1;
  min-width: 0;
  gap: 4px;
}
.step-circle {
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  transition: all .2s ease;
  position: relative;
  width: 32px;
  height: 32px;
  border: 2px solid var(--line-strong);
  background: var(--card);
  color: var(--muted);
  font-size: 14px;
  box-shadow: none;
  animation: none;
}
/* Done steps show a tick instead of their number */
.step-item.completed .step-circle::after {
  content: '';
  width: 11px;
  height: 6px;
  margin-top: -3px;
  border-left: 2px solid #FFFFFF;
  border-bottom: 2px solid #FFFFFF;
  transform: rotate(-45deg);
}
.step-item.current .step-circle {
  border-color: var(--duty);
  background: var(--duty-bg);
  color: var(--duty);
  box-shadow: none;
  animation: none;
}
.step-title {
  font-weight: 600;
  max-width: 90px;
  color: var(--muted);
  font-size: 13px;
  overflow-wrap: anywhere;
}
.step-item.completed .step-title,
.step-item.current .step-title {
  color: var(--ink);
  font-weight: 600;
}
.step-time {
  font-family: var(--font-mono);
  color: var(--muted);
  font-size: 12px;
}
/* Proof photo banner */
.cockpit-proof-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  transition: all 0.2s ease;
  gap: 12px;
  margin-top: 0;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--card);
}
.cockpit-proof-banner:hover {
  border-color: var(--primary);
  background: var(--soft);
}
.cockpit-proof-main {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}
.cockpit-proof-thumb {
  overflow: hidden;
  background: #000;
  width: 56px;
  min-width: 56px;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
}
.cockpit-proof-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.cockpit-proof-text {
  min-width: 0;
}
.proof-title {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--ink);
  font-size: 14px;
  font-weight: 600;
}
.proof-meta {
  color: var(--muted);
  font-size: 13px;
  overflow-wrap: anywhere;
}
.proof-title .icon,
.proof-meta .icon {
  width: 16px;
  height: 16px;
  vertical-align: -3px;
}
.proof-link {
  color: var(--primary);
  font-size: 13px;
  text-decoration: underline;
  white-space: nowrap;
}
/* Actions for the current step */
.mission-actions {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--r-inner);
  background: var(--card);
}
.action-step > * + * {
  margin-top: 10px;
}
.depart-vehicle {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 12px;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--soft);
}
.depart-vehicle-current {
  color: var(--ink);
  font-size: 14px;
}
.depart-vehicle-label {
  margin-right: 6px;
  color: var(--muted);
}
.depart-vehicle-switch {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
}
.depart-vehicle-switch .form-select {
  width: auto;
  min-width: 170px;
  min-height: 44px;
}
.depart-mileage-row {
  display: flex;
  gap: 10px;
}
.depart-mileage-row .form-control {
  max-width: 200px;
  min-height: 52px;
  font-size: 18px;
}
.btn-depart {
  flex: 1;
  min-height: 52px;
}
/* The step's main action matches the depart button and has room for a second line */
.mission-actions .btn-large {
  min-height: 52px;
  padding: 8px 16px;
  text-align: center;
}
.mission-print {
  display: flex;
  justify-content: flex-end;
}
@media screen and (min-width: 1024px) {
  .cockpit-selector {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px 20px;
    padding: 10px 16px;
  }
  .cockpit-selector-field {
    flex-direction: row;
    align-items: center;
    gap: 10px;
  }
  .cockpit-selector-field .form-select {
    width: auto;
    min-width: 240px;
  }
  /* Moves to its own line when less than 320px is left beside the select (a double shift at 1024px) */
  .cockpit-selector-summary {
    flex: 1 1 320px;
    min-width: 0;
  }
  .cockpit-grid {
    grid-template-columns: 330px minmax(0, 1fr);
    align-items: start;
  }
  /* Three boxes only when each gets 200px, so long Thai names do not break mid-word on narrow panels */
  .mission-info-grid {
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  }
}
@media screen and (max-width: 1023.98px) {
  .depart-vehicle-switch {
    width: 100%;
  }
  .depart-vehicle-switch .form-select {
    flex: 1;
    min-width: 0;
  }
  .mission-actions .btn-large {
    min-height: 56px;
  }
  .mission-print .btn {
    width: 100%;
  }
}
@media screen {
  #input-depart-mileage {
    font-family: var(--font-mono);
  }
}
/* ---------- Driver dialogs (check-in, switch car, close-out, vitals, phone dispatch, camera) ---------- */
.modal-title {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  color: var(--ink);
  font-size: 17px;
  font-weight: 700;
  line-height: 1.35;
  overflow-wrap: anywhere;
}
.modal-intro {
  margin-bottom: 14px;
}
.notice-label {
  margin-bottom: 2px;
  color: var(--muted);
  font-size: 12px;
}
:is(#view-driver, #modal-checkin, #modal-switch-car, #modal-closeout, #modal-vitals, #modal-phone-dispatch) .text-muted {
  color: var(--muted);
}
.form-hint {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 13px;
}
.field-hint {
  color: var(--muted);
  font-size: 12px;
  font-weight: 400;
}
.form-label .field-req,
.form-label .field-hint {
  margin-left: 4px;
}
span.form-label {
  display: block;
  margin-bottom: 6px;
}
.shift-picker {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
}
/* ตรวจเช็ครถประจำวัน 18 จุดแบบ HOSOffice (vehicle-check.js): one row per point, a three-way choice on the right */
#modal-checkin .vcheck-head .form-hint {
  margin: 2px 0 8px;
}
#modal-checkin .vcheck-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(270px, 1fr));
  gap: 1px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--line);
}
#modal-checkin .vcheck-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 48px;
  padding: 6px 8px 6px 10px;
  background: var(--card);
}
#modal-checkin .vcheck-row:has(input[value="2"]:checked) {
  background: var(--mission-bg);
}
#modal-checkin .vcheck-label {
  min-width: 0;
  color: var(--ink);
  font-size: 14px;
  line-height: 1.35;
}
#modal-checkin .vcheck-no {
  display: inline-block;
  min-width: 22px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
#modal-checkin .vcheck-choices {
  display: inline-flex;
  flex-shrink: 0;
  overflow: hidden;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
}
#modal-checkin .vcheck-choice {
  position: relative;
  margin: 0;
  cursor: pointer;
}
#modal-checkin .vcheck-choice + .vcheck-choice {
  border-left: 1px solid var(--line-strong);
}
/* The radio stays in the page for keyboard and screen readers, drawn by the span beside it */
#modal-checkin .vcheck-choice input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}
#modal-checkin .vcheck-choice span {
  display: flex;
  align-items: center;
  min-height: 36px;
  padding: 0 10px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
}
#modal-checkin .vcheck-choice--ok input:checked + span {
  background: var(--done-bg);
  color: var(--done);
  font-weight: 700;
}
#modal-checkin .vcheck-choice--bad input:checked + span {
  background: var(--mission);
  color: #FFFFFF;
  font-weight: 700;
}
#modal-checkin .vcheck-choice--none input:checked + span {
  background: var(--duty-bg);
  color: var(--duty);
  font-weight: 700;
}
#modal-checkin .vcheck-choice input:focus-visible + span {
  outline: 2px solid var(--primary);
  outline-offset: -2px;
}
#modal-checkin .vcheck-done {
  padding: 10px 12px;
  border: 1px solid var(--done);
  border-left-width: 4px;
  border-radius: 10px;
  background: var(--done-bg);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.5;
}
#modal-checkin .vcheck-done-title {
  color: var(--done);
  font-weight: 700;
}
#modal-checkin .vcheck-damaged {
  color: var(--mission);
  font-weight: 700;
}
#modal-checkin .vcheck-done .form-hint {
  margin: 2px 0 0;
}
.summary-dl {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 6px 12px;
  margin: 0 0 16px;
  padding: 12px;
  border-radius: 10px;
  background: var(--soft);
  font-size: 14px;
}
.summary-dl dt {
  color: var(--muted);
}
.summary-dl dd {
  margin: 0;
  color: var(--ink);
  text-align: right;
  overflow-wrap: anywhere;
}
.distance-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--muted);
  font-size: 14px;
}
.distance-row .chip {
  background: var(--done-bg);
  color: var(--done);
  font-size: 17px;
  font-weight: 700;
}
:is(#modal-checkin, #modal-switch-car, #modal-closeout, #modal-vitals, #modal-phone-dispatch) .modal-footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 8px;
  margin-top: 20px;
  padding: 14px 0 0;
  background: var(--card);
}
@media screen and (max-width: 1023.98px) {
  /* The buttons stay in reach while the form scrolls: cancel above, the main action at the bottom */
  :is(#modal-checkin, #modal-switch-car, #modal-closeout, #modal-vitals, #modal-phone-dispatch) .modal-footer {
    position: sticky;
    bottom: 0;
    z-index: 2;
    flex-direction: column;
    padding: 12px 0 calc(16px + env(safe-area-inset-bottom));
  }
  /* Scrolling to an error message or a focused field stops above the pinned buttons (about 133px tall).
     .modal-body is the scroller in these dialogs; .modal-box takes over when a body does not overflow on its own */
  :is(#modal-checkin, #modal-switch-car, #modal-closeout, #modal-vitals, #modal-phone-dispatch) :is(.modal-box, .modal-body) {
    scroll-padding-bottom: 150px;
  }
  /* No gap under the pinned buttons, so the form never shows through below them */
  :is(#modal-checkin, #modal-switch-car, #modal-closeout, #modal-vitals, #modal-phone-dispatch) .modal-body {
    padding-bottom: 0;
  }
  :is(#modal-checkin, #modal-switch-car, #modal-closeout, #modal-vitals, #modal-phone-dispatch) .modal-footer .btn {
    width: 100%;
    flex: none;
  }
}
@media screen {
  :is(#modal-checkin, #modal-switch-car) .form-control[readonly] {
    background: var(--soft);
  }
}
/* Phone dispatch: mission type cards, nurse cards and triage buttons (the nurse's new-refer dialog shares the card classes, hence the id) */
.form-label-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  margin-bottom: 8px;
}
#modal-phone-dispatch .mission-type-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
:is(#modal-phone-dispatch, #modal-new-refer) .mission-type-card {
  gap: 4px;
  padding: 10px 6px;
}
:is(#modal-phone-dispatch, #modal-new-refer) .mission-type-card:hover {
  background: var(--soft);
}
:is(#modal-phone-dispatch, #modal-new-refer) .mission-type-card:focus-within {
  outline: 3px solid var(--primary);
  outline-offset: 2px;
}
:is(#modal-phone-dispatch, #modal-new-refer) .mtc-icon {
  margin: 0;
}
:is(#modal-phone-dispatch, #modal-new-refer) .mtc-title {
  display: flex;
  flex-direction: column;
  line-height: 1.3;
}
.mtc-sub {
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
}
.nurse-picker {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
}
.nurse-options {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}
#modal-phone-dispatch .nurse-option-card {
  min-height: 56px;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--line-strong);
  background: var(--card);
}
#modal-phone-dispatch .nurse-option-card.selected {
  border-color: var(--primary);
  background: var(--soft);
}
#modal-phone-dispatch .nurse-option-card input[type="radio"] {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  margin: 0;
  accent-color: var(--primary);
}
.nurse-option-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
  color: var(--ink);
  font-size: 14px;
  line-height: 1.35;
}
.nurse-option-text small {
  color: var(--muted);
  font-size: 12px;
}
#phone-nurse-no-hint {
  margin-top: 8px;
}
.triage-picker {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}
.triage-option {
  min-height: 48px;
  padding: 7px 9px;
  border: 2px solid transparent;
  border-radius: 10px;
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.3;
  text-align: center;
  cursor: pointer;
}
.triage-option[data-level="red"] {
  background: var(--mission-bg);
  color: var(--mission);
}
.triage-option[data-level="pink"] {
  background: #FCE7F3;
  color: #9D174D;
}
.triage-option[data-level="yellow"] {
  background: var(--duty-bg);
  color: var(--duty);
}
.triage-option[data-level="green"] {
  background: var(--done-bg);
  color: var(--done);
}
.triage-option[aria-pressed="true"] {
  border-color: currentColor;
  font-weight: 700;
}
.triage-option:focus-visible {
  outline: 3px solid var(--primary);
  outline-offset: 2px;
}
@media screen and (min-width: 600px) {
  #modal-phone-dispatch .mission-type-grid {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }
}
/* Live camera: stays dark; every control at least 48px */
.live-cam-header,
.live-cam-controls {
  background: #0B1410;
}
.live-cam-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.5px;
  border: 0;
  background: var(--mission);
  color: #FFFFFF;
}
.live-cam-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  animation: liveCamPulse 1.2s infinite ease-in-out;
  background: #FFFFFF;
}
#live-cam-clock {
  font-family: var(--font-mono);
  font-size: 0.88rem;
  font-weight: 600;
  color: #FFFFFF;
}
.live-cam-gps-row .icon {
  width: 14px;
  height: 14px;
}
.live-cam-close {
  border: none;
  font-size: 1.5rem;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: 0.2s;
  width: 48px;
  height: 48px;
  flex-shrink: 0;
  background: rgba(255, 255, 255, 0.14);
  color: #FFFFFF;
}
.live-cam-close .icon,
.live-cam-tool-btn .icon {
  width: 22px;
  height: 22px;
}
.live-cam-guide span {
  backdrop-filter: blur(4px);
  padding: 4px 14px;
  border-radius: 20px;
  border: 1px solid rgba(255,255,255,0.15);
  background: rgba(0, 0, 0, 0.75);
  color: #FFFFFF;
  font-size: 13px;
}
.live-cam-tool-btn {
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 50%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: 0.2s;
  gap: 2px;
  width: 64px;
  height: 64px;
  border-color: rgba(255, 255, 255, 0.25);
  background: rgba(255, 255, 255, 0.12);
  color: #FFFFFF;
}
.live-cam-tool-label {
  font-size: 11px;
}
@media screen {
  #modal-live-camera {
    color: #fff;
    z-index: 9999;
    background: rgba(0, 0, 0, 0.94);
  }
}
/* พลขับ: one card each, the pie of their missions beside the counts */
.driver-card {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
  padding: 14px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r-inner);
}
/* ---------- Form dialogs (.form-dialog: #modal-new-refer and the admin dialogs): numbered sections, the buttons pinned at
   the bottom. Long forms are full screen below 768px and a 760px box from 768px; .form-dialog--short is a sheet from the
   bottom below 768px and a 520px box from 768px. The new request's type cards share the phone-dispatch card rules ---------- */
.form-dialog .modal-box {
  display: flex;
  flex-direction: column;
  width: min(760px, calc(100% - 32px));
  max-width: 760px;
  max-height: calc(100dvh - 64px);
  padding: 0;
  overflow: hidden;
}
.form-dialog .modal-close {
  flex-shrink: 0;
  width: 44px;
  min-height: 44px;
}
.form-dialog .modal-body {
  flex: 1;
  min-height: 0;
  padding: 0 24px;
  overflow-y: auto;
  scroll-padding-bottom: 96px;
}
.form-dialog .form-section {
  min-width: 0;
  margin: 0;
  padding: 16px 0;
  border: 0;
  border-bottom: 1px solid var(--line);
}
.form-dialog .form-step {
  display: flex;
  float: left;
  align-items: center;
  gap: 10px;
  width: 100%;
  margin: 0 0 12px;
  padding: 0;
  color: var(--ink);
  font-size: 16px;
  font-weight: 700;
}
.form-dialog .form-step + * {
  clear: both;
}
.form-dialog .form-step b {
  display: inline-flex;
  flex-shrink: 0;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--primary);
  color: #FFFFFF;
  font-size: 13px;
}
.form-dialog .form-step small {
  color: var(--muted);
  font-size: 13px;
  font-weight: 400;
}
.form-dialog .form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0 12px;
}
.form-dialog .form-grid--pair {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
.form-dialog textarea.form-control {
  min-height: 88px;
}
#modal-new-refer .mission-type-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
}
#modal-new-refer .mission-type-card input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}
#modal-new-refer .mission-type-card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  cursor: pointer;
}
#modal-new-refer #refer-triage-group .triage-picker {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}
.form-dialog .form-warning {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin: 0 0 10px;
  padding: 10px 12px;
  border-radius: var(--r-inner);
  background: var(--duty-bg);
  color: var(--duty);
  font-size: 13px;
}
.form-dialog .form-warning .icon {
  width: 18px;
  height: 18px;
}
/* The buttons stay at the bottom of the box while the form scrolls */
.form-dialog .modal-footer {
  position: sticky;
  bottom: 0;
  z-index: 2;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin: 0 -24px;
  padding: 12px 24px calc(12px + env(safe-area-inset-bottom));
  background: var(--card);
  box-shadow: 0 -4px 12px rgba(15, 61, 46, 0.08);
}
.form-dialog .modal-footer .btn {
  min-height: 48px;
  font-size: 15px;
}
.form-dialog .modal-footer .btn-primary {
  min-width: 200px;
}
@media screen and (max-width: 1023.98px) {
  .form-dialog.modal-overlay {
    align-items: center;
    justify-content: center;
  }
  .form-dialog .modal-drag-handle {
    display: none;
  }
}
@media screen and (max-width: 767.98px) {
  .form-dialog .modal-body {
    padding: 12px 12px 0;
    background: var(--bg);
  }
  .form-dialog .form-section {
    margin-bottom: 12px;
    padding: 16px;
    border: 1px solid var(--line);
    border-radius: var(--r-inner);
    background: var(--card);
  }
  .form-dialog .form-grid {
    grid-template-columns: minmax(0, 1fr);
  }
  .form-dialog .form-grid--pair {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  #modal-new-refer .mission-type-grid,
  #modal-new-refer #refer-triage-group .triage-picker {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .form-dialog .modal-footer {
    margin: 0 -12px;
    padding: 12px 12px calc(16px + env(safe-area-inset-bottom));
  }
  .form-dialog .modal-footer .btn-outline {
    flex: 0 0 110px;
  }
  .form-dialog .modal-footer .btn-primary {
    flex: 1;
    min-width: 0;
  }
}
@media screen {
  .form-dialog .modal-box {
    width: min(760px, calc(100% - 32px));
    max-width: 760px;
    max-height: calc(100dvh - 64px);
    overflow: hidden;
    border-radius: var(--r-card);
    margin: auto;
  }
  .form-dialog :is(.form-control, .form-select) {
    min-height: 48px;
    font-size: 16px;
  }
}
@media screen and (max-width: 767.98px) {
  .form-dialog .modal-box {
    width: 100%;
    max-width: none;
    height: 100dvh;
    max-height: 100dvh;
    border: 0;
    border-radius: 0;
  }
}
/* Long admin forms: six times in three columns, the map pickers, the photo row, a full-width button inside a section */
.form-dialog .form-grid--3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}
.form-dialog .photo-upload-box {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px 16px;
  margin-bottom: 12px;
}
.form-dialog .modal-footer .btn.btn-icon {
  flex: 0 0 48px;
  width: 48px;
  margin-right: auto;
}
@media screen and (max-width: 767.98px) {
  .form-dialog .form-grid--3 {
    grid-template-columns: minmax(0, 1fr);
  }
}
/* Short forms: as tall as their content. Without numbered sections the body carries its own padding */
.form-dialog--short .modal-body {
  padding: 16px 24px 0;
}
.form-dialog--short .modal-footer {
  flex-wrap: wrap;
}
.form-dialog .form-hint {
  margin: 6px 0 0;
}
.form-dialog form > .form-hint:first-child {
  margin: 0 0 12px;
}
.form-dialog--short .modal-body > :is(p, .admin-actions, .form-group, .qr-body) {
  margin: 0 0 12px;
}
@media screen and (max-width: 767.98px) {
  .form-dialog--short.modal-overlay {
    align-items: flex-end;
  }
  .form-dialog--short .modal-body {
    padding: 16px 16px 0;
    background: var(--card);
  }
  .form-dialog--short .modal-footer {
    margin: 0 -16px;
    padding: 12px 16px calc(16px + env(safe-area-inset-bottom));
  }
}
@media screen {
  .form-dialog--short .modal-box {
    width: min(520px, calc(100% - 32px));
    max-width: 520px;
  }
  .form-dialog .form-control[readonly] {
    background: var(--soft);
  }
  /* console-fix sets every field's font with !important: codes and PINs keep the mono face, PINs their size */
  .form-dialog .form-control:is(.mono, .pin-input) {
    font-family: var(--font-mono);
  }
  .form-dialog .form-control.pin-input {
    font-size: 20px;
  }
}
@media screen and (max-width: 767.98px) {
  .form-dialog--short .modal-box {
    width: 100%;
    height: auto;
    max-height: 90dvh;
    margin: 0;
    border-radius: var(--r-card) 16px 0 0;
  }
}
/* กล่อง GPS and แจ้งเตือนและตั้งค่า: settings panels in one or two columns, labelled check rows, the speed limits grid */
.admin-settings-grid .form-group {
  margin: 0;
}
/* แจ้งเตือนและตั้งค่า / กล่อง GPS settings (user 2026-11-26: "พื้นเป็นสีขาวเหมือนกันหมดทำให้ดูยาก สังเกตได้ยากมากแต่ละการ์ด"):
   a gap between the cards, each with a coloured band on top and a tinted title strip, nine colours in turn */
.admin-settings-grid {
  display: grid;
  gap: 18px;
}
.admin-settings-grid > .panel {
  --accent: #2563EB;
  --accent-soft: #EFF4FF;
  --accent-ink: #1E3A8A;
  border-width: 6px 1px 1px;
  border-style: solid;
  border-color: var(--accent) var(--line-strong) var(--line-strong);
  box-shadow: 0 10px 24px -12px rgba(15, 23, 42, .22);
}
.admin-settings-grid > .panel > .panel-title {
  margin: -20px -20px 12px;
  padding: 12px 20px;
  border-bottom: 1px solid var(--line);
  border-radius: 14px 14px 0 0;
  background: var(--accent-soft);
  color: var(--accent-ink);
}
.admin-settings-grid > .panel:nth-child(9n+1) { --accent: #2563EB; --accent-soft: #EFF4FF; --accent-ink: #1E3A8A; }
.admin-settings-grid > .panel:nth-child(9n+2) { --accent: #7C3AED; --accent-soft: #F3EEFF; --accent-ink: #4C1D95; }
.admin-settings-grid > .panel:nth-child(9n+3) { --accent: #0F766E; --accent-soft: #E6F6F4; --accent-ink: #134E4A; }
.admin-settings-grid > .panel:nth-child(9n+4) { --accent: #EA580C; --accent-soft: #FFF1E8; --accent-ink: #7C2D12; }
.admin-settings-grid > .panel:nth-child(9n+5) { --accent: #C026D3; --accent-soft: #FCEEFE; --accent-ink: #701A75; }
.admin-settings-grid > .panel:nth-child(9n+6) { --accent: #16A34A; --accent-soft: #EAF7EE; --accent-ink: #14532D; }
.admin-settings-grid > .panel:nth-child(9n+7) { --accent: #0891B2; --accent-soft: #E6F6FA; --accent-ink: #164E63; }
.admin-settings-grid > .panel:nth-child(9n+8) { --accent: #E11D48; --accent-soft: #FFEEF1; --accent-ink: #881337; }
.admin-settings-grid > .panel:nth-child(9n+9) { --accent: #D97706; --accent-soft: #FFF6E5; --accent-ink: #78350F; }
/* ---------- Destination picker: type to match the list, Longdo Map for places missing from it (app.js) ----------
   The list sits in the flow under the input, so the scrolling dialog and the phone bottom sheet never clip it. */
.dest-picker-list {
  margin-top: 6px;
  max-height: min(320px, 45dvh);
  overflow-y: auto;
  overscroll-behavior: contain;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: var(--card);
  box-shadow: 0 8px 20px rgba(16, 37, 28, 0.12);
}
.dest-picker-list[hidden],
.dest-picker-note[hidden] {
  display: none;
}
.dest-picker-list > :first-child {
  border-top: 0;
}
.dest-picker-note {
  margin: 6px 0 0;
  padding: 8px 10px;
  border-radius: 10px;
  background: var(--done-bg);
  color: var(--done);
  font-size: 0.8125rem;
  line-height: 1.5;
}
@media screen and (max-width: 1023.98px) {
  .close-btn,
  .modal-close {
    width: 44px;
    height: 44px;
    min-height: 44px;
  }
}
@media screen {
  /* theme-glass.css paints every outline button with !important in the legacy layer */
  .btn.phone-dispatch-cta:hover {
    background: var(--primary-hover);
    border-color: var(--primary-hover);
    box-shadow: var(--key-blue);
  }
  /* Green, yellow and red buttons carry the driver's steps: their colours stay, only the gloss goes */
  .btn-warning,
  .btn-warning:hover {
    border-color: #FACC15;
  }
  .btn-warning:hover {
    background: #FACC15;
    box-shadow: 0 2px 4px rgba(161, 98, 7, .3);
  }
}
/* ---------- Dialogs: white cards on a dim slate veil, plain white heads ---------- */
.modal-title .icon {
  box-sizing: content-box;
  width: 20px;
  height: 20px;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: none;
  box-shadow: none;
  stroke: currentColor;
  filter: none;
  color: var(--primary);
}
.close-btn,
.modal-close {
  width: 44px;
  height: 44px;
  min-height: 44px;
  border-radius: 50%;
  border: 0;
  background-color: transparent;
  color: var(--ink);
  box-shadow: none;
}
.close-btn:hover,
.modal-close:hover {
  background-color: var(--primary-soft);
  color: var(--primary-hover);
}
.form-dialog .modal-header {
  display: flex;
  flex-shrink: 0;
  align-items: center;
  gap: 10px;
  margin: 0;
  padding: 10px 12px 10px 20px;
  border-bottom: 1px solid var(--line);
  background-color: #FFFFFF;
  box-shadow: none;
}
.form-dialog .modal-title {
  flex: 1;
  font-size: 18px;
  text-shadow: none;
}
@media screen {
  .form-dialog .modal-header .modal-title {
    color: var(--ink);
  }
}
/* The live camera's caption sits on its own near-black strip, so it keeps a light colour */
.live-cam-gps-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  font-size: 12px;
  color: #D7D8FF;
}
/* ---------- Greens that mean something: a finished driver step, a crew on standby ---------- */
.step-item.completed .step-circle {
  color: #FFFFFF;
  font-size: 0;
  border-color: #2A660B;
  background: #2A660B;
}
@media screen and (max-width: 1023.98px) {
  .btn.phone-dispatch-cta {
    background: var(--primary-hover);
    border-color: var(--primary-hover);
  }
}
@media screen {
  .candy-form .modal-body {
    background: var(--bg);
  }
  .candy-form :is(.form-control, .form-select),
  .candy-form .hosoffice-together__item {
    border-color: var(--line-strong);
    background-color: #FFFFFF;
  }
  .candy-form :is(.form-control, .form-select):focus {
    border-color: var(--primary);
  }
}
/* ---------- Phone-dispatch form, candy 3D (2026-11-05, user: "มีสีสัน แยกข้อชัด มีเงา ปุ่ม 3D ลูกกวาด ง่ายต่อ พขร ที่มีอายุ"):
   every item is a white card with a coloured edge (data-tone), each mission type its own candy colour (pastel until
   picked, then filled and raised), large type and targets. White words only sit on colours with AA contrast. ---------- */
.candy-form [data-tone="blue"] {
  --tone: #2563EB;
}
.candy-form [data-tone="violet"] {
  --tone: #7C3AED;
}
.candy-form [data-tone="green"] {
  --tone: #16A34A;
}
.candy-form [data-tone="amber"] {
  --tone: #F59E0B;
}
.candy-form [data-tone="teal"] {
  --tone: #0D9488;
}
.candy-form [data-tone="red"] {
  --tone: #E11D48;
}
.candy-form [data-tone="sky"] {
  --tone: #0284C7;
}
.candy-form [data-tone="pink"] {
  --tone: #DB2777;
}
.candy-form [data-tone="orange"] {
  --tone: #EA580C;
}
.candy-form .mission-type-card[data-type="refer"] {
  --candy: #E11D48;
  --candy-top: #FB7185;
  --candy-dark: #9F1239;
  --candy-soft: #FFE4E8;
}
.candy-form .mission-type-card[data-type="ems"] {
  --candy: #C2410C;
  --candy-top: #FB923C;
  --candy-dark: #7C2D12;
  --candy-soft: #FFEDD5;
}
.candy-form .mission-type-card[data-type="mobile_unit"] {
  --candy: #15803D;
  --candy-top: #4ADE80;
  --candy-dark: #14532D;
  --candy-soft: #DCFCE7;
}
.candy-form .mission-type-card[data-type="staff_transport"] {
  --candy: #1D4ED8;
  --candy-top: #60A5FA;
  --candy-dark: #1E3A8A;
  --candy-soft: #DBEAFE;
}
.candy-form .mission-type-card[data-type="lab_transport"] {
  --candy: #7E22CE;
  --candy-top: #C084FC;
  --candy-dark: #581C87;
  --candy-soft: #F3E8FF;
}
@media screen {
  /* Items: white cards with a shadow and a coloured edge; a hidden one stays hidden (older rules set display) */
  .candy-form .form-group[hidden] {
    display: none;
  }
  .candy-form legend.form-label {
    float: left;
    width: 100%;
    margin: 0 0 10px;
    padding: 0;
  }
  .candy-form legend.form-label + * {
    clear: both;
  }
  .candy-form .form-group {
    margin-bottom: 14px;
    padding: 14px 14px 14px 16px;
    border: 0;
    border-left: 6px solid var(--tone, var(--primary));
    border-radius: var(--r-inner);
    background: #FFFFFF;
    box-shadow: 0 2px 0 rgba(67, 89, 113, .10), 0 6px 16px rgba(67, 89, 113, .12);
  }
  .candy-form .form-label,
  .candy-form .form-label-row > span:first-child {
    color: #1F2D3D;
    font-size: 16px;
    font-weight: 700;
  }
  .candy-form :is(.form-control, .form-select) {
    min-height: 52px;
    border-width: 2px;
    border-radius: var(--r-inner);
    font-size: 17px;
    color: #1F2D3D;
  }
  .candy-form .form-control[readonly] {
    background: #F1F3F7;
  }
  /* Mission types: candy buttons, pastel until picked */
  .candy-form .mission-type-grid {
    gap: 12px;
    padding: 4px 2px 8px;
  }
  .candy-form .mission-type-card {
    min-height: 96px;
    border: 2px solid var(--candy);
    border-radius: var(--r-card);
    background: var(--candy-soft);
    color: var(--candy-dark);
    box-shadow: inset 0 3px 0 #FFFFFF, 0 5px 0 var(--candy-dark), 0 9px 14px rgba(31, 45, 61, .18);
    transform: translateY(0);
    transition: transform .12s ease, box-shadow .12s ease;
  }
  .candy-form .mission-type-card :is(.mtc-icon, .mtc-title, .mtc-sub) {
    color: inherit;
  }
  .candy-form .mission-type-card .mtc-icon {
    width: 30px;
    height: 30px;
  }
  .candy-form .mission-type-card .mtc-title {
    font-size: 16px;
    font-weight: 700;
  }
  .candy-form .mission-type-card:hover {
    transform: translateY(-2px);
  }
  .candy-form .mission-type-card:active {
    transform: translateY(4px);
    box-shadow: 0 1px 0 var(--candy-dark), 0 3px 6px rgba(31, 45, 61, .18);
  }
  .candy-form .mission-type-card.selected[data-type] {
    border-color: var(--candy-dark);
    background: var(--candy);
    color: #FFFFFF;
    box-shadow: inset 0 3px 0 rgba(255, 255, 255, .45), inset 0 22px 24px -14px var(--candy-top), inset 0 -12px 16px rgba(0, 0, 0, .2), 0 6px 0 var(--candy-dark), 0 12px 20px rgba(31, 45, 61, .28);
    transform: translateY(-3px);
  }
  .candy-form .mission-type-card.selected[data-type]::after {
    content: "✓";
    position: absolute;
    top: 6px;
    right: 8px;
    display: grid;
    place-items: center;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: #FFFFFF;
    color: var(--candy-dark);
    font-weight: 800;
    font-size: 15px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, .25);
  }
  .candy-form .mission-type-card:has(input:disabled) {
    opacity: .4;
    box-shadow: none;
    transform: none;
    cursor: not-allowed;
  }
  /* Choices inside cards: raised too */
  .candy-form :is(.triage-option, .nurse-option-card) {
    border-radius: var(--r-inner);
    box-shadow: 0 4px 0 rgba(31, 45, 61, .22), 0 6px 10px rgba(31, 45, 61, .10);
  }
  .candy-form .hosoffice-together__item {
    border-width: 2px;
    border-radius: var(--r-inner);
    box-shadow: 0 3px 0 rgba(245, 158, 11, .35);
  }
  .candy-form .hosoffice-together__item:has(input:checked) {
    border-color: #F59E0B;
    background: #FFF7E6;
  }
  .candy-form .hosoffice-together__item input[type="checkbox"] {
    width: 26px;
    height: 26px;
    flex: none;
    accent-color: #D97706;
  }
  /* Save: a big green candy button that presses in; cancel a grey one */
  .candy-form .modal-footer .btn {
    min-height: 56px;
    border-radius: var(--r-inner);
    font-size: 17px;
    font-weight: 700;
    transition: transform .12s ease, box-shadow .12s ease;
  }
  .candy-form .modal-footer .btn-primary {
    border: 2px solid #065F46;
    background: #047857;
    color: #FFFFFF;
    box-shadow: inset 0 3px 0 rgba(255, 255, 255, .4), inset 0 22px 24px -14px #10B981, inset 0 -12px 16px rgba(0, 0, 0, .2), 0 6px 0 #064E3B, 0 12px 18px rgba(4, 120, 87, .3);
  }
  .candy-form .modal-footer .btn-outline {
    border: 2px solid #94A3B8;
    background: #EEF2F6;
    color: #1F2D3D;
    box-shadow: 0 5px 0 #94A3B8, 0 9px 14px rgba(31, 45, 61, .15);
  }
  .candy-form .modal-footer .btn:active {
    transform: translateY(5px);
  }
}
@media (prefers-reduced-motion: reduce) {
  .candy-form :is(.mission-type-card, .modal-footer .btn) {
    transition: none;
  }
}
@media screen {
  #no-mission-state .btn.phone-dispatch-cta {
    border: 2px solid #991B1B;
    border-radius: var(--r-card);
    background: #DC2626;
    color: #FFFFFF;
    text-shadow: 0 1px 1px rgba(0, 0, 0, .25);
    box-shadow: inset 0 3px 0 rgba(255, 255, 255, .45), inset 0 22px 24px -14px #F87171, inset 0 -12px 16px rgba(0, 0, 0, .22), 0 6px 0 #7F1D1D, 0 12px 20px rgba(185, 28, 28, .35);
    transform: translateY(-2px);
    transition: transform .12s ease, box-shadow .12s ease;
  }
  #no-mission-state .btn.phone-dispatch-cta:hover {
    background: #C81E1E;
    border-color: #7F1D1D;
  }
  #no-mission-state .btn.phone-dispatch-cta:active {
    transform: translateY(4px);
    box-shadow: inset 0 3px 0 rgba(255, 255, 255, .35), inset 0 -8px 12px rgba(0, 0, 0, .25), 0 1px 0 #7F1D1D, 0 3px 6px rgba(185, 28, 28, .3);
  }
  #no-mission-state .btn.phone-dispatch-cta:focus-visible {
    outline: 3px solid #7F1D1D;
    outline-offset: 4px;
  }
}
@media (prefers-reduced-motion: reduce) {
  #no-mission-state .btn.phone-dispatch-cta {
    transition: none;
  }
}
@media screen {
  .btn.phone-dispatch-cta {
    text-shadow: none;
    border: none;
    background: var(--primary-hover);
    border-color: #1E40AF;
    color: #FFFFFF;
    box-shadow: var(--key-blue);
  }
  .btn.phone-dispatch-cta:hover:not(:disabled) {
    background: #1E40AF;
    transform: translateY(-1px);
  }
  .btn.phone-dispatch-cta:active:not(:disabled) {
    transform: translateY(3px);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, .3), 0 1px 0 #17369E;
  }
  .btn-warning {
    background: #FACC15;
    color: #422006;
    box-shadow: inset 0 2px 0 rgba(255, 255, 255, .45), 0 4px 0 #CA8A04, 0 10px 20px -6px rgba(202, 138, 4, .45);
  }
}

/* ---------- views: แดชบอร์ด (#view-dashboard), รายงาน (#view-reports), ประวัติภารกิจ (#view-archive) ---------- */
@media screen and (max-width: 767px) {
  #archive-search {
    width: 100%;
  }
}
/* Driver portraits: a lightly raised square frame, with the whole photo visible. */
.vehicle-photo-editor {
  display: grid;
  gap: .6rem;
  margin-bottom: 1.25rem;
}
.vehicle-photo-editor img {
  width: 100%;
  height: 160px;
  object-fit: contain;
  border: 1px solid #d7e0eb;
  border-radius: var(--r-inner);
  background: #f3f6fa;
}
.vehicle-photo-editor img[hidden] {
  display: none;
}
.vehicle-photo-editor .btn {
  justify-self: start;
}
/* ---------- Page header (each view's title row) ---------- */
.page-header {
  gap: 12px;
}
.page-header h2 {
  margin: 0;
  color: var(--ink);
  font-size: var(--fs-page);
  font-weight: 600;
  letter-spacing: -.02em;
  line-height: 1.25;
}
.page-header p {
  margin: 2px 0 0;
  color: var(--muted);
}
.page-header > div:last-child {
  flex-wrap: wrap;
}
.page-header .btn {
  flex: 0 0 auto;
  white-space: nowrap;
}
/* ---------- Archive (ประวัติภารกิจ): cards below 960px of table width, 20 missions a page ---------- */
.archive-summary {
  margin: 6px 0 12px;
  color: var(--muted);
  font-size: 13px;
}
.archive-code {
  font-family: var(--font-mono);
  font-size: 15px;
}
.archive-table .cell-title .archive-code {
  margin-right: 6px;
}
.archive-patient {
  display: block;
  font-weight: 600;
}
.archive-hn {
  display: block;
  color: var(--muted);
  font-size: 13px;
}
.archive-place {
  display: flex;
  align-items: flex-start;
  gap: 4px;
  margin-top: 2px;
  color: var(--muted);
  font-size: 13px;
}
.archive-place .icon {
  width: 16px;
  height: 16px;
  margin-top: 2px;
}
@container (max-width: 959.98px) {
  .archive-patient {
    font-size: 16px;
  }
}
.archive-pager {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px 16px;
  margin-top: 14px;
  color: var(--muted);
  font-size: 14px;
}
.archive-pager[hidden] {
  display: none;
}
.archive-pager-nav {
  display: flex;
  align-items: center;
  gap: 10px;
}
.archive-pager-page {
  color: var(--ink);
  font-weight: 600;
}
@media screen and (max-width: 1023.98px) {
  .archive-pager-nav .btn {
    min-height: 44px;
  }
}
/* Each mission type's colour, as --dot for dots, bar segments and trend columns */
.t-refer {
  --dot: var(--type-refer);
}
.t-ems {
  --dot: var(--type-ems);
}
.t-mobile_unit {
  --dot: var(--type-mobile);
}
.t-staff_transport {
  --dot: var(--type-staff);
}
.t-lab_transport {
  --dot: var(--type-lab);
}
.dash-filters {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 16px;
}
.dash-period {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}
.dash-period .seg {
  flex: 1 1 100%;
}
/* Proportion bars: one segment per type, 2px apart, rounded ends */
.type-stack {
  display: flex;
  gap: 2px;
  height: 16px;
}
.type-stack.is-small {
  height: 12px;
}
.type-stack > span {
  flex: 0 1 0;
  background: var(--dot);
}
.type-stack > span:first-child {
  border-radius: 4px 0 0 4px;
}
.type-stack > span:last-child {
  border-radius: 0 4px 4px 0;
}
.type-stack > span:only-child {
  border-radius: 4px;
}
.type-stack.is-empty {
  background: var(--soft);
  border-radius: 4px;
}
.type-list {
  display: grid;
  gap: 7px;
  margin: 10px 0 0;
  padding: 0;
  list-style: none;
  font-size: 14px;
}
.type-list li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 12px;
  border: 1px solid #E2E8F0;
  border-radius: 10px;
  background: linear-gradient(180deg, #FFFFFF 0%, #F8FAFC 100%);
  box-shadow: inset 0 1px 0 #FFFFFF, 0 1px 2px rgba(15, 23, 42, .03);
}
.type-list li > span:nth-child(2) {
  flex: 1;
  font-weight: 500;
}
.type-list li > strong {
  font-variant-numeric: tabular-nums;
  font-size: 15px;
}
.type-pct {
  min-width: 46px;
  padding: 2px 8px;
  border-radius: 999px;
  background: #EFF4FF;
  color: #1E40AF;
  font-size: 12.5px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  text-align: center;
}
.dash-breakdown .type-stack {
  margin-top: 12px;
  height: 10px;
  border-radius: 999px;
  overflow: hidden;
  box-shadow: inset 0 1px 2px rgba(15, 23, 42, .1);
}
.dash-empty {
  margin: 0;
  padding: 16px 14px;
  border: 1px dashed var(--line);
  border-radius: var(--r-inner);
  background: var(--soft);
  color: var(--muted);
  font-size: 14px;
  text-align: center;
}
/* รถพยาบาล */
.dash-vehicle {
  display: inline-flex;
  align-items: baseline;
  gap: 8px;
}
.dash-vehicle strong {
  font-size: 16px;
}
.dash-vehicle .mono {
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 13px;
}
.dash-vehicle-model {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 13px;
}
.dash-vehicle-model .chip {
  margin-left: 4px;
}
.type-summary {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  font-size: 12px;
}
.dash-vehicle-table td.cell-sub {
  min-width: 160px;
}
@container (max-width: 959.98px) {
  .dash-vehicle-model {
    flex-basis: 100%;
  }
}
@media (min-width: 768px) {
  .dash-period .seg {
    flex: 0 0 auto;
  }
}
/* ---------- Form dialogs (.form-dialog: #modal-new-refer and the admin dialogs): numbered sections, the buttons pinned at
   the bottom. Long forms are full screen below 768px and a 760px box from 768px; .form-dialog--short is a sheet from the
   bottom below 768px and a 520px box from 768px. The new request's type cards share the phone-dispatch card rules ---------- */
#modal-new-refer .mtc-dot.t-refer {
  background: #E6F0FF;
}
#modal-new-refer .mtc-dot.t-ems {
  background: #FDEFE7;
}
#modal-new-refer .mtc-dot.t-mobile_unit {
  background: #E3F4EA;
}
#modal-new-refer .mtc-dot.t-staff_transport {
  background: #FFF4D6;
}
#modal-new-refer .mtc-dot.t-lab_transport {
  background: #FCE7F3;
}
/* Each section: a head (title, one line, the main button), a tools row, notes, then panels and card tables */
.admin-note {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}
/* ---------- Reports (รายงาน): vehicle usage, vehicle log, Refer / nurse (reports.js) ---------- */
.reports-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  margin-bottom: 12px;
}
.reports-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 12px;
  margin-bottom: 14px;
}
.reports-tabs {
  display: inline-flex;
  gap: 4px;
  max-width: 100%;
  padding: 4px;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--r-pill);
  background: var(--soft);
  scrollbar-width: none;
}
.reports-tabs [role="tab"] {
  flex: 0 0 auto;
  min-height: 40px;
  padding: 0 16px;
  border: 0;
  border-radius: var(--r-pill);
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
}
.reports-tabs [role="tab"][aria-selected="true"] {
  background: var(--card);
  color: var(--primary);
  box-shadow: var(--key-white);
}
.reports-tabs [role="tab"]:focus-visible,
.reports-car:focus-visible,
.reports-cell:focus-visible {
  outline: 3px solid var(--primary);
  outline-offset: 2px;
}
.reports-year,
.reports-month {
  color: var(--muted);
  font-size: 14px;
  font-weight: 600;
}
#reports-year,
#reports-month {
  width: auto;
  min-height: 36px;
}
.reports-actions {
  display: flex;
  gap: 8px;
  margin-left: auto;
}
.reports-print-head,
.reports-sign {
  display: none;
}
.reports-note {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 13px;
}
.reports-state {
  padding: 28px 16px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--r-inner);
  background: var(--card);
  color: var(--muted);
  text-align: center;
}
.reports-state p {
  margin: 0 0 10px;
}
.reports-state p:last-child {
  margin-bottom: 0;
}
.reports-body table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
.reports-body th,
.reports-body td {
  padding: 6px 8px;
  border-bottom: 1px solid var(--line);
  color: var(--ink);
  text-align: left;
  vertical-align: top;
}
.reports-body thead th {
  background: var(--soft);
  font-weight: 700;
  white-space: nowrap;
}
.reports-body tfoot th,
.reports-body tfoot td {
  background: var(--soft);
  font-weight: 700;
}
.reports-body .reports-num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
/* The vehicle column stays put while the months scroll sideways */
.reports-usage th[scope="row"],
.reports-usage thead th:first-child {
  position: sticky;
  left: 0;
  z-index: 1;
}
.reports-usage th[scope="row"] {
  background: var(--card);
}
.reports-usage thead th:first-child,
.reports-usage tfoot th[scope="row"] {
  background: var(--soft);
}
.reports-usage td,
.reports-usage th[scope="row"] {
  padding: 2px 4px;
}
.reports-car,
.reports-cell {
  display: flex;
  flex-direction: column;
  width: 100%;
  min-height: 44px;
  padding: 4px 6px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: inherit;
  font: inherit;
  white-space: nowrap;
  cursor: pointer;
}
.reports-car {
  text-align: left;
}
.reports-cell {
  align-items: flex-end;
  text-align: right;
}
.reports-car:hover,
.reports-cell:hover {
  background: var(--soft);
}
.reports-usage td > strong,
.reports-usage td > small {
  display: block;
  padding: 0 6px;
}
.reports-usage small,
.reports-car small {
  color: var(--muted);
  font-size: 12px;
  font-weight: 400;
}
.reports-log-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 16px;
  margin-bottom: 12px;
}
.reports-log-title h3 {
  margin: 0;
  color: var(--ink);
  font-size: 17px;
}
.reports-log-title p {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 13px;
}
.reports-log-nav {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}
.reports-log-month {
  min-width: 92px;
  color: var(--ink);
  font-weight: 700;
  text-align: center;
}
/* One line per cell; on a phone the log scrolls sideways in its box instead of squeezing names into columns */
.reports-log-table th,
.reports-log-table td {
  white-space: nowrap;
}
.reports-flag {
  display: block;
  color: var(--muted);
  font-size: 13px;
}
.reports-flag.is-warn {
  color: var(--mission);
  font-weight: 600;
}
/* Refer / nurse: blue with a nurse, amber without, grey not recorded (as the chips on the map) */
.reports-types {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 12px;
}
.reports-type {
  min-height: 36px;
  padding: 0 14px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: var(--card);
  color: var(--ink);
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}
.reports-type[aria-pressed="true"] {
  border-color: var(--primary);
  background: var(--primary);
  color: #FFFFFF;
}
.reports-type:focus-visible {
  outline: 3px solid var(--primary);
  outline-offset: 2px;
}
.reports-kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}
.reports-kpi {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 2px 8px;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--line-strong);
  border-radius: var(--r-inner);
  background: var(--card);
}
.reports-kpi span {
  flex: 1 0 100%;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}
.reports-kpi strong {
  color: var(--ink);
  font-size: 24px;
  font-variant-numeric: tabular-nums;
}
.reports-kpi small {
  color: var(--muted);
  font-size: 14px;
  font-weight: 600;
}
.reports-kpi.is-with {
  border-left-color: #0284C7;
}
.reports-kpi.is-without {
  border-left-color: #D97706;
}
.reports-kpi.is-unknown {
  border-left-color: #6B7280;
}
/* มีพยาบาล / ไม่มีพยาบาล / ไม่ระบุ are buttons that open their trips (reports.js nurseTrips) */
button.reports-kpi {
  width: 100%;
  margin: 0;
  font: inherit;
  text-align: left;
  cursor: pointer;
}
button.reports-kpi:hover {
  border-color: var(--line-strong);
}
button.reports-kpi[aria-pressed="true"] {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(42, 102, 11, .25);
}
button.reports-kpi:focus-visible {
  outline: 3px solid var(--primary);
  outline-offset: 2px;
}
.reports-kpi-more {
  margin-left: auto;
  align-self: center;
  color: var(--primary);
  font-size: 13px;
  font-style: normal;
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.reports-section {
  margin-bottom: 18px;
}
.reports-section h3 {
  margin: 0 0 8px;
  color: var(--ink);
  font-size: 16px;
}
.reports-body td.is-warn {
  background: var(--mission-bg);
  color: var(--mission);
}
.reports-body td.reports-c-bar {
  min-width: 120px;
  vertical-align: middle;
}
.reports-bar {
  display: flex;
  overflow: hidden;
  height: 10px;
  border-radius: 999px;
  background: var(--soft);
}
/* Driver log (พลขับ): trips by type for per-trip pay, then the driver's and the checker's signatures */
.reports-driver-summary {
  max-width: 420px;
  margin-top: 16px;
}
.reports-bar .is-with {
  background: #0284C7;
}
.reports-bar .is-without {
  background: #D97706;
}
.reports-bar .is-unknown {
  background: #6B7280;
}
/* ตรวจเช็ครถ (reports.js renderChecks, 2026-10-31): HOSOffice-style daily check list, one month at a time */
#view-reports .reports-year[hidden],
#reports-year[hidden],
#view-reports .reports-month[hidden],
#reports-month[hidden] {
  display: none;
}
.check-kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}
.check-kpi {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-left-width: 4px;
  border-radius: 10px;
  background: var(--card);
}
.check-kpi span {
  color: var(--muted);
  font-size: 13px;
}
.check-kpi strong {
  color: var(--ink);
  font-size: 26px;
  line-height: 1.2;
  font-variant-numeric: tabular-nums;
}
.check-kpi--total {
  border-left-color: var(--primary);
}
.check-kpi--ready {
  border-left-color: var(--done);
}
.check-kpi--ready strong {
  color: var(--done);
}
.check-kpi--repair {
  border-left-color: var(--mission);
}
.check-kpi--repair strong {
  color: var(--mission);
}
.check-kpi--today {
  border-left-color: var(--ready-edge);
}
.check-kpi--today strong {
  color: var(--ready);
}
.check-tools {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}
.check-tools input[type="search"] {
  flex: 1 1 260px;
  min-width: 0;
  min-height: 40px;
}
.check-filter {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 4px;
}
.check-filter .btn {
  min-height: 40px;
}
@media screen {
  .check-filter .btn[aria-pressed="true"] {
    border-color: var(--primary);
    background: var(--primary);
    color: #FFFFFF;
  }
}
.check-report-table td {
  vertical-align: middle;
}
.check-report-table [data-check-detail] {
  white-space: nowrap;
}
.check-plate,
.check-marks,
.check-status,
.check-ack {
  white-space: nowrap;
}
.check-marks {
  display: inline-flex;
  gap: 8px;
  font-variant-numeric: tabular-nums;
}
.check-mark--ok {
  color: var(--done);
  font-weight: 600;
}
.check-mark--bad {
  color: var(--muted);
}
.check-row--repair .check-mark--bad {
  color: var(--mission);
  font-weight: 700;
}
.check-mark--none {
  color: var(--duty);
}
.check-status,
.check-ack {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
}
.check-status--ready,
.check-ack--done {
  background: var(--done-bg);
  color: var(--done);
}
.check-status--repair {
  background: var(--mission-bg);
  color: var(--mission);
}
.check-ack--wait {
  background: var(--duty-bg);
  color: var(--duty);
}
.check-ack--none {
  padding: 0;
  color: var(--muted);
}
.check-thumb {
  display: block;
  width: 44px;
  height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  object-fit: cover;
}
.check-source {
  color: var(--muted);
  font-size: 13px;
}
@media screen and (max-width: 1023.98px) {
  .reports-tabs [role="tab"],
  #reports-year,
  #reports-month {
    min-height: 44px;
  }
  .reports-actions {
    margin-left: 0;
  }
}
/* ---------- Dashboard (stage 2): Sneat's analytics page — welcome card, figures with ↑↓ %, ApexCharts, a driver list ---------- */
.dash-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-template-areas: "welcome welcome" "total distance" "trend trend" "price price" "fuel avg" "types types" "drivers drivers";
  gap: 14px;
  margin-bottom: 18px;
}
.dash-grid > * {
  min-width: 0;
  margin: 0;
}
.dash-grid > .dash-kpi:nth-of-type(1) {
  grid-area: total;
}
.dash-grid > .dash-kpi:nth-of-type(2) {
  grid-area: distance;
}
.dash-grid > .dash-kpi:nth-of-type(3) {
  grid-area: fuel;
}
.dash-grid > .dash-kpi:nth-of-type(4) {
  grid-area: avg;
}
.dash-trend {
  position: relative;
  grid-area: trend;
}
.dash-types {
  grid-area: types;
}
.dash-drivers {
  grid-area: drivers;
}
@media screen and (min-width: 768px) {
  .dash-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    grid-template-areas: "welcome welcome total distance" "trend trend trend trend" "price price fuel avg" "types types types types" "drivers drivers drivers drivers";
  }
}
@media screen and (min-width: 1200px) {
  .dash-grid {
    grid-template-areas: "welcome welcome total distance" "trend trend price fuel" "trend trend price avg" "types types drivers drivers";
  }
}
/* Welcome: purple greeting, a summary line, an outline button, the ambulance drawing on the right */
.dash-welcome-body {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  min-width: 0;
}
.dash-welcome-art {
  flex-shrink: 0;
  width: 160px;
  height: auto;
}
@media screen and (max-width: 479.98px) {
  .dash-welcome-art {
    width: 96px;
  }
}
/* Figures: an icon in a soft tile, the label, the value, then the change since the period before */
.dash-kpi {
  position: relative;
  gap: 6px;
  padding: 18px;
}
.kpi-icon .icon {
  width: 22px;
  height: 22px;
}
.kpi-delta {
  font-size: 13px;
  font-weight: 600;
}
.kpi-delta[hidden] {
  display: none;
}
.kpi-delta.is-up {
  color: #2F7A12;
}
.kpi-delta.is-down {
  color: #C62828;
}
.kpi-delta.is-same,
.kpi-delta.is-neutral {
  color: var(--muted);
}
.kpi-delta.is-new {
  color: var(--primary-hover);
}
/* Chart boxes keep their height while ApexCharts loads, so the page does not jump */
.dash-chart {
  min-height: 200px;
}
#dash-chart-trend {
  min-height: 260px;
}
.dash-chart .dash-empty {
  padding: 48px 0;
}
/* Stacked bars (2026-11-16): ApexCharts rounds the bottom piece of a stack by flipping it in CSS (.apexcharts-flip-y:
   scaleY(-1) translateY(-100%) on its fill-box); iPhone Safari flips it about the wrong box, so the Refer piece hung
   below 0. No flip here — app.js (squareStackBottoms) squares that piece off instead; only the top end of a stack rounds */
.dash-chart .apexcharts-flip-y {
  transform: none;
}
.dash-chart .apexcharts-bar-area,
.reports-chart .apexcharts-bar-area {
  filter: drop-shadow(0 3px 5px rgba(15, 23, 42, .11));
  transition: filter .18s ease;
}
.dash-chart .apexcharts-bar-area:hover,
.reports-chart .apexcharts-bar-area:hover {
  filter: drop-shadow(0 6px 12px rgba(15, 23, 42, .22)) brightness(1.04);
}
.dash-chart .apexcharts-bar-series .apexcharts-datalabels text {
  paint-order: stroke fill;
  stroke: #FFFFFF;
  stroke-width: 3px;
  stroke-linejoin: round;
  font-variant-numeric: tabular-nums;
}
.dash-chart .apexcharts-legend-series {
  padding: 3px 8px;
  border: 1px solid #E2E8F0;
  border-radius: 999px;
  background: #F8FAFC;
  box-shadow: inset 0 1px 0 #FFFFFF, 0 1px 2px rgba(15, 23, 42, .04);
  transition: transform .15s ease, border-color .15s ease;
}
.dash-chart .apexcharts-legend-series:hover {
  transform: translateY(-1px);
  border-color: #CBD5E1;
  background: #FFFFFF;
}
.dash-chart .apexcharts-legend-text {
  font-family: var(--font);
}
.dash-chart .apexcharts-tooltip,
.reports-chart .apexcharts-tooltip {
  border: 1px solid #CBD5E1;
  border-radius: 12px;
  box-shadow: 0 12px 28px -6px rgba(15, 23, 42, .18), 0 4px 10px -3px rgba(15, 23, 42, .08);
  font-family: var(--font);
}
.dash-ontime {
  display: flex;
  flex-direction: column;
  gap: 4px;
  text-align: center;
}
.dash-ontime .panel-title,
.dash-ontime .panel-sub {
  text-align: left;
}
.dash-ontime-rate {
  margin: 0;
  color: var(--ink);
  font-size: 15px;
  font-weight: 600;
}
/* The gauge already prints the rate in its middle; the line under it is for when the chart cannot draw */
.dash-ontime:has(.apexcharts-canvas) .dash-ontime-rate {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}
.dash-ontime-avg {
  margin: 0;
  color: var(--ink);
  font-size: 14px;
}
.dash-ontime-avg strong {
  color: var(--ink);
  font-weight: 600;
}
.dash-ontime .kpi-sub {
  justify-content: center;
}
/* Types: the donut beside its counted list */
.dash-types-body {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  align-items: center;
  gap: 8px;
}
@media screen and (min-width: 560px) {
  .dash-types-body {
    grid-template-columns: 200px minmax(0, 1fr);
  }
}
/* Drivers: Sneat's "Transactions" rows */
.dash-driver-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 10px 0 0;
  padding: 0;
  list-style: none;
}
.dash-driver {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 9px 12px;
  border: 1px solid #E2E8F0;
  border-radius: 12px;
  background: linear-gradient(180deg, #FFFFFF 0%, #F8FAFC 100%);
  box-shadow: inset 0 1px 0 #FFFFFF, 0 1px 3px rgba(15, 23, 42, .03);
  transition: transform .15s ease, box-shadow .15s ease, border-color .15s ease;
}
.dash-driver:hover {
  transform: translateY(-1px);
  border-color: #CBD5E1;
  background: #FFFFFF;
  box-shadow: 0 6px 14px -4px rgba(15, 23, 42, .08);
}
.dash-driver-avatar {
  width: 42px;
  height: 42px;
}
.dash-driver-main {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}
.dash-driver-name {
  overflow: hidden;
  color: var(--ink);
  font-size: 14px;
  font-weight: 700;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.dash-driver-sub {
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.dash-driver-count {
  padding: 4px 10px;
  border: 1px solid #BFDBFE;
  border-radius: 999px;
  background: #EFF4FF;
  color: #1E40AF;
  font-size: 13px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
/* The trend's numbers day by day: one tap away under the chart, opened by itself when the chart cannot draw */
.dash-trend-details {
  margin-top: 8px;
  border-top: 1px solid var(--line);
}
.dash-trend-details summary {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 44px;
  margin-top: 6px;
  padding: 0 14px;
  border: 1px solid #DBEAFE;
  border-radius: 999px;
  background: #EFF6FF;
  color: var(--primary-hover);
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s ease, border-color .15s ease;
}
.dash-trend-details summary:hover {
  background: #DBEAFE;
  border-color: #BFDBFE;
}
.dash-trend-details summary:focus-visible {
  outline: 3px solid var(--primary);
  outline-offset: 2px;
  border-radius: 4px;
}
.dash-trend-data {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 4px 16px;
  margin: 0 0 4px;
  padding: 0;
  list-style: none;
  color: var(--ink);
  font-size: 13px;
}
/* Fuel's "ใหม่" is no better or worse than before: grey like its other changes */
.kpi-delta.is-new.is-neutral {
  color: var(--muted);
}
/* Driver bars are backgrounds: keep them on paper */
.dash-driver-bar,
.dash-driver-bar > span {
  -webkit-print-color-adjust: exact;
  print-color-adjust: exact;
}
/* ---------- Fuel (2026-11-12): the dashboard card's how-it-was-counted line, PTT prices on the settings page ---------- */
.dash-kpi .dash-fuel-note {
  display: block;
  margin-top: 2px;
  font-size: 12.5px;
  color: #4B5563;
}
.dash-kpi .dash-fuel-note:empty {
  display: none;
}
/* ---------- Dashboard fuel (2026-11-12): "ออกทันเวลา" under the donut in "แยกตามประเภท", "ราคาน้ำมันวันนี้" in its old
   place, "การใช้น้ำมันรายเดือน" after the vehicle table ---------- */
.dash-types .dash-ontime {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  align-items: center;
  gap: 6px 12px;
  margin-top: 16px;
  padding: 14px 16px;
  border: 1px solid #E2E8F0;
  border-radius: var(--r-inner);
  background: linear-gradient(180deg, #F8FAFC 0%, #F1F5F9 100%);
  box-shadow: inset 0 1px 0 #FFFFFF;
  text-align: center;
}
.dash-types .dash-ontime .panel-title {
  font-size: 16px;
  margin: 0;
}
.dash-types .dash-ontime .panel-sub {
  margin: 0 0 4px;
}
.dash-types .dash-ontime-text {
  display: flex;
  flex-direction: column;
  gap: 4px;
  align-items: center;
}
@media screen and (min-width: 560px) {
  .dash-types .dash-ontime {
    grid-template-columns: 200px minmax(0, 1fr);
    text-align: left;
  }
  .dash-types .dash-ontime-text {
    align-items: flex-start;
  }
  .dash-types .dash-ontime .kpi-sub {
    justify-content: flex-start;
  }
}
.dash-fuelprice {
  grid-area: price;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.dash-fuelprice-list {
  list-style: none;
  margin: 4px 0 0;
  padding: 0;
  display: grid;
  gap: 8px;
}
.dash-fuelprice-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 2px 8px;
  padding: 10px 12px;
  border-radius: 10px;
  background: #FFF8E6;
  color: #384551;
}
.dash-fuelprice-name {
  font-weight: 600;
  font-size: 14px;
}
.dash-fuelprice-price {
  text-align: right;
  font-size: 22px;
  font-weight: 700;
  color: #384551;
  line-height: 1.1;
}
.dash-fuelprice-price small {
  font-size: 12px;
  font-weight: 500;
  color: #4B5563;
}
.dash-fuelprice-change {
  grid-column: 1 / -1;
  font-size: 12.5px;
  color: #4B5563;
}
.dash-fuelprice-change b {
  font-weight: 700;
}
.dash-fuelprice-change.is-up b {
  color: #B42318;
}
.dash-fuelprice-change.is-down b {
  color: #2A660B;
}
.dash-fuelprice-empty {
  padding: 18px 0;
  color: #4B5563;
  text-align: center;
}
.dash-chart.dash-chart--fuelprice[hidden] {
  display: none;
}
.dash-fuelmonthly {
  margin-top: 18px;
}
#dash-chart-fuelmonthly {
  min-height: 280px;
}
/* ---------- การใช้น้ำมันรายเดือน: the hover box as a small table (2026-11-13) — the month on a blue strip, a row per
   mission type with its dot, litres and baht right-aligned in tabular figures, the total on a tinted last row ---------- */
.dash-chart .apexcharts-tooltip:has(.fuel-tip) {
  border-radius: var(--r-inner);
  overflow: hidden;
  background: #FFFFFF;
  box-shadow: 0 4px 0 #CDDBF1, 0 16px 32px -10px rgba(15, 35, 85, .28);
}
.fuel-tip {
  min-width: 232px;
  color: #0B1B3A;
  font-family: var(--font);
}
.fuel-tip-head {
  padding: 8px 14px;
  background: #1E40AF;
  color: #FFFFFF;
  font-size: 14px;
  font-weight: 600;
}
.fuel-tip-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
  font-variant-numeric: tabular-nums;
}
.fuel-tip-table th {
  padding: 7px 14px 4px;
  color: #475569;
  font-size: 12px;
  font-weight: 600;
  text-align: right;
}
.fuel-tip-table th:first-child,
.fuel-tip-table td:first-child {
  text-align: left;
}
.fuel-tip-table td {
  padding: 5px 14px;
  text-align: right;
  white-space: nowrap;
}
.fuel-tip-table td:nth-child(2) {
  font-weight: 600;
}
.fuel-tip-table td:nth-child(3) {
  color: #334155;
}
.fuel-tip-table tbody tr + tr td {
  border-top: 1px solid #EEF2F8;
}
.fuel-tip-table tr.is-none td {
  color: #64748B;
  font-weight: 400;
}
.fuel-tip-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  margin-right: 8px;
  border-radius: 50%;
  vertical-align: baseline;
}
.fuel-tip-table tfoot td {
  padding: 8px 14px 9px;
  border-top: 2px solid #D0DEF2;
  background: #EEF4FD;
  color: #0B1B3A;
  font-weight: 700;
}
/* ---------- Reports summary (2026-11-13, การใช้รถ / พลขับ): the year opens as a totals card, a donut of shares, monthly
   bars and a ranked list whose rows open the log; the 12-month table is folded under "ดูตารางรายเดือนแบบเต็ม".
   Solid fills under every word (css/tactile3d.css); print keeps the table only ---------- */
.reports-summary {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 14px;
  margin-bottom: 18px;
}
@media screen and (min-width: 960px) {
  .reports-summary {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.3fr) minmax(0, 1.3fr);
  }
}
.reports-sum-card {
  min-width: 0;
  padding: 18px 20px;
  border: 1px solid #CFDDF2;
  border-radius: 20px;
  background: #FFFFFF;
  box-shadow: inset 0 2px 0 #FFFFFF, 0 5px 0 #CDDBF1, 0 18px 38px -10px rgba(15, 35, 85, .14);
}
.reports-sum-card h3 {
  margin: 0 0 10px;
  color: #0B1B3A;
  font-size: 16px;
  font-weight: 600;
}
/* The totals: the deep-blue key card */
.reports-sum-total {
  display: flex;
  flex-direction: column;
  gap: 4px;
  border-color: #1E40AF;
  background: #1E3A8A;
  color: #FFFFFF;
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, .3), 0 6px 0 #152C6E, 0 22px 44px -12px rgba(29, 78, 216, .5);
}
.reports-sum-total h3 {
  color: #DBEAFE;
  font-weight: 500;
}
.reports-sum-main {
  font-size: 40px;
  font-weight: 700;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}
.reports-sum-main small {
  font-size: 17px;
  font-weight: 500;
  color: #DBEAFE;
}
.reports-sum-second {
  font-size: 19px;
  font-weight: 600;
}
.reports-sum-avg,
.reports-sum-active {
  color: #DBEAFE;
  font-size: 14px;
}
.reports-sum-avg {
  margin-top: 8px;
  padding-top: 10px;
  border-top: 1px solid #3B5BB5;
}
/* The donut beside its list (the list alone below 480px) */
.reports-share-body {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 8px;
  align-items: center;
}
@media screen and (min-width: 480px) {
  .reports-share-body {
    grid-template-columns: 170px minmax(0, 1fr);
  }
}
.reports-chart {
  min-height: 170px;
}
.reports-chart .dash-empty {
  padding: 56px 8px;
  color: #475569;
  text-align: center;
  font-size: 14px;
}
.reports-share-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 7px;
}
.reports-share-list li {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  color: #0B1B3A;
  font-size: 14.5px;
}
.reports-share-list li span {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.reports-share-list li b {
  flex: none;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.reports-dot {
  flex: none;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  box-shadow: 0 0 0 2px rgba(15, 23, 42, .06);
}
.reports-dot.c0 {
  background: var(--chart-1, #1D4ED8);
}
.reports-dot.c1 {
  background: var(--chart-2, #0E9F6E);
}
.reports-dot.c2 {
  background: var(--chart-3, #D97706);
}
.reports-dot.c3 {
  background: var(--chart-4, #DB2777);
}
.reports-dot.c4 {
  background: var(--chart-5, #7C3AED);
}
.reports-dot.c5 {
  background: #94A3B8;
}
/* Ranking: one raised row each; the whole row opens the log */
.reports-rank-section h3 small {
  margin-left: 8px;
  color: #475569;
  font-size: 13px;
  font-weight: 400;
}
.reports-rank {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 8px;
}
.reports-rank-row {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) auto 18px;
  grid-template-areas: "no name figure go" "no bar pct go";
  align-items: center;
  gap: 4px 12px;
  width: 100%;
  min-height: 56px;
  padding: 10px 14px;
  border: 1px solid #D5E2F4;
  border-radius: var(--r-card);
  background: #FFFFFF;
  color: #0B1B3A;
  font: inherit;
  text-align: left;
  box-shadow: inset 0 1.5px 0 #FFFFFF, 0 3px 0 #D5E2F4;
}
button.reports-rank-row {
  cursor: pointer;
  transition: transform .12s ease, border-color .15s ease;
}
button.reports-rank-row:hover {
  border-color: #93C5FD;
  transform: translateY(-1px);
}
button.reports-rank-row:active {
  transform: translateY(2px);
  box-shadow: inset 0 1px 0 #FFFFFF, 0 1px 0 #D5E2F4;
}
.reports-rank-row > .icon {
  grid-area: go;
  width: 18px;
  height: 18px;
  color: #1E40AF;
}
.reports-rank-no {
  grid-area: no;
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 11px;
  background: #DBEAFE;
  color: #1E40AF;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.reports-rank-row.is-top .reports-rank-no {
  background: #1D4ED8;
  color: #FFFFFF;
  box-shadow: inset 0 1.5px 0 rgba(255, 255, 255, .35), 0 2.5px 0 #17369E;
}
.reports-rank-name {
  grid-area: name;
  min-width: 0;
  display: flex;
  flex-direction: column;
}
.reports-rank-name strong {
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.reports-rank-name small {
  color: #475569;
  font-size: 12.5px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.reports-rank-bar {
  grid-area: bar;
  height: 9px;
  border-radius: 999px;
  background: #DBEAFE;
  box-shadow: inset 0 1px 2px rgba(15, 35, 85, .12);
  overflow: hidden;
}
.reports-rank-bar > span {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: #1D4ED8;
}
.reports-rank-figure {
  grid-area: figure;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.reports-rank-figure strong {
  font-weight: 700;
}
.reports-rank-figure small {
  color: #475569;
  font-size: 12.5px;
}
.reports-rank-pct {
  grid-area: pct;
  justify-self: end;
  color: #1E40AF;
  font-size: 13px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.reports-rank-row.is-none {
  color: #64748B;
}
.reports-rank-row.is-none :is(.reports-rank-pct, .reports-rank-figure small, .reports-rank-name small) {
  color: #64748B;
}
.reports-rank-row.is-none .reports-rank-no {
  background: #EEF2F7;
  color: #475569;
}
@media screen and (min-width: 760px) {
  .reports-rank-row {
    grid-template-columns: 34px minmax(0, 1.1fr) minmax(120px, 2.2fr) minmax(150px, auto) 46px 18px;
    grid-template-areas: "no name bar figure pct go";
    gap: 14px;
  }
  .reports-rank-figure {
    flex-direction: row;
    align-items: baseline;
    justify-content: flex-end;
    gap: 8px;
  }
}
/* The full table, folded */
.reports-full {
  margin-top: 18px;
}
.reports-full > summary {
  display: flex;
  align-items: center;
  min-height: 48px;
  padding: 10px 16px;
  border: 1px solid #C6D6EE;
  border-radius: var(--r-inner);
  background: #FFFFFF;
  color: #1E40AF;
  font-weight: 600;
  cursor: pointer;
  box-shadow: inset 0 2px 0 #FFFFFF, 0 4px 0 #C2D3EC;
}
.reports-full[open] > summary {
  margin-bottom: 12px;
}
/* แบบฟอร์มตรวจเช็ครถรายคัน (2026-11-17, reports.js checkFormHtml): HOSOffice's paper form. Never on screen; while
   body.print-check-form is set, the paper carries this box alone, A4 landscape */
.check-form-action {
  display: flex;
  justify-content: flex-end;
  margin: 0 0 12px;
}
.check-form-cars {
  display: grid;
  gap: 8px;
}
.check-form-cars .btn {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  min-height: 48px;
  text-align: left;
}
.check-form-cars .btn small {
  color: var(--muted, #566A7F);
  font-weight: 400;
}
/* ประวัติภารกิจ: the period bar (2026-11-17) uses the dashboard's .dash-period/.seg/.date-field, under the search */
.archive-period {
  margin: 10px 0 4px;
}
.archive-period select {
  flex: 1;
  min-width: 0;
  min-height: 44px;
  border: 0;
  background: transparent;
  color: var(--ink, #384551);
  font: inherit;
}
.archive-period .seg button {
  min-height: 44px;
}
/* Figures: the icon a raised squircle in its colour */
.kpi-icon {
  display: grid;
  place-items: center;
  margin-bottom: 6px;
  width: 46px;
  height: 46px;
  border-radius: var(--r-inner);
  border: 1px solid #BFDBFE;
  box-shadow: inset 0 2px 0 #FFFFFF, 0 4px 0 #93C5FD, 0 8px 16px -6px rgba(37, 99, 235, .35);
}
.kpi-icon.is-primary {
  background: linear-gradient(150deg, #EFF6FF 0%, #DBEAFE 100%);
  color: #1E40AF;
}
.kpi-icon.is-info {
  background: linear-gradient(150deg, #ECFEFF 0%, #CFFAFE 100%);
  border-color: #A5F3FC;
  color: #0E7490;
  box-shadow: inset 0 2px 0 #FFFFFF, 0 4px 0 #67E8F9, 0 8px 16px -6px rgba(8, 145, 178, .3);
}
.kpi-icon.is-warning {
  background: linear-gradient(150deg, #FFFBEB 0%, #FEF3C7 100%);
  border-color: #FDE68A;
  color: #92400E;
  box-shadow: inset 0 2px 0 #FFFFFF, 0 4px 0 #FCD34D, 0 8px 16px -6px rgba(217, 119, 6, .3);
}
.kpi-icon.is-success {
  background: linear-gradient(150deg, #ECFDF5 0%, #D1FAE5 100%);
  border-color: #A7F3D0;
  color: #166534;
  box-shadow: inset 0 2px 0 #FFFFFF, 0 4px 0 #6EE7B7, 0 8px 16px -6px rgba(16, 185, 129, .3);
}
.dash-kpi .kpi-value {
  font-size: 24px;
  color: var(--ink);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
/* Figure cards in colour (user 2026-11-19): each on a gradient of its icon's colour, white text (AA on every stop, also where the
   faint icon lies under it), a large
   faint icon filling the empty corner, the label and value set low so a tall card does not look empty */
.dash-kpi[class*="kpi-tone-"] {
  --kpi-a: #1D4ED8;
  --kpi-b: #1E3A8A;
  --kpi-ledge: #1E3A8A;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  isolation: isolate;
  border-color: transparent;
  background: radial-gradient(circle at 100% 0%, rgba(255, 255, 255, .22) 0, rgba(255, 255, 255, 0) 46%), linear-gradient(145deg, var(--kpi-a) 0%, var(--kpi-b) 100%);
  color: #FFFFFF;
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, .28), 0 5px 0 var(--kpi-ledge), 0 16px 28px -14px var(--kpi-b);
}
.dash-kpi.kpi-tone-blue {
  --kpi-a: #1D4ED8;
  --kpi-b: #1E3A8A;
  --kpi-ledge: #172E6E;
}
.dash-kpi.kpi-tone-cyan {
  --kpi-a: #0E6680;
  --kpi-b: #134E5E;
  --kpi-ledge: #0F3D4A;
}
.dash-kpi.kpi-tone-amber {
  --kpi-a: #9A4508;
  --kpi-b: #7C2D12;
  --kpi-ledge: #5F230E;
}
.dash-kpi.kpi-tone-green {
  --kpi-a: #166534;
  --kpi-b: #14532D;
  --kpi-ledge: #0F3F22;
}
.dash-kpi[class*="kpi-tone-"] .kpi-icon {
  position: relative;
  border-color: rgba(255, 255, 255, .45);
  background: rgba(255, 255, 255, .18);
  color: #FFFFFF;
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, .35), 0 4px 0 rgba(0, 0, 0, .18);
}
.dash-kpi[class*="kpi-tone-"] .kpi-label {
  position: relative;
  margin-top: auto;
  color: #FFFFFF;
  font-size: 15px;
  font-weight: 500;
}
.dash-kpi[class*="kpi-tone-"] .kpi-value {
  position: relative;
  color: #FFFFFF;
  font-size: clamp(28px, 3.2vw, 38px);
  line-height: 1.15;
  text-shadow: 0 2px 0 rgba(0, 0, 0, .18);
}
.dash-kpi[class*="kpi-tone-"] .kpi-value small {
  color: #FFFFFF;
  font-size: 15px;
  font-weight: 500;
}
.dash-kpi[class*="kpi-tone-"] .kpi-sub {
  position: relative;
  color: #FFFFFF;
}
/* The change since the period before: a white pill, so its green/red stays readable on the colour */
.dash-kpi[class*="kpi-tone-"] .kpi-delta {
  position: relative;
  align-self: flex-start;
  padding: 2px 10px;
  border-radius: 999px;
  background: #FFFFFF;
}
.kpi-watermark {
  display: none;
}
.dash-kpi[class*="kpi-tone-"] .kpi-watermark {
  display: block;
  position: absolute;
  right: -18px;
  bottom: -22px;
  z-index: -1;
  width: clamp(96px, 46%, 170px);
  height: auto;
  aspect-ratio: 1;
  color: #FFFFFF;
  opacity: .12;
  transform: rotate(-12deg);
  pointer-events: none;
}
@media screen and (max-width: 767.98px) {
  .dash-kpi[class*="kpi-tone-"] {
    min-height: 168px;
  }
}
/* ราคาน้ำมันวันนี้ (2026-11-19): a violet top (apart from the amber fuel-cost card beside it) with the title and price in white
   (≥ 5:1 also where the faint pump and the glass row overlap), the chart on
   white underneath, as tall as the card leaves (app.js sizes it from the box) */
.panel.dash-fuelprice {
  padding: 0;
  gap: 0;
  overflow: hidden;
  isolation: isolate;
}
.dash-fuelprice-top {
  position: relative;
  z-index: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 18px 18px 16px;
  overflow: hidden;
  background: radial-gradient(circle at 100% 0%, rgba(255, 255, 255, .2) 0, rgba(255, 255, 255, 0) 50%), linear-gradient(145deg, #6D28D9 0%, #4C1D95 100%);
  color: #FFFFFF;
  box-shadow: inset 0 -4px 0 rgba(0, 0, 0, .12);
}
.dash-fuelprice-top .panel-title,
.dash-fuelprice-top .panel-sub {
  color: #FFFFFF;
}
.dash-fuelprice-top .kpi-watermark {
  display: block;
  position: absolute;
  right: -14px;
  top: -10px;
  z-index: -1;
  width: 120px;
  height: 120px;
  color: #FFFFFF;
  opacity: .12;
  transform: rotate(12deg);
  pointer-events: none;
}
.dash-fuelprice-top .dash-fuelprice-row {
  grid-template-columns: minmax(0, 1fr);
  position: relative;
  padding: 12px 14px;
  border: 1px solid rgba(255, 255, 255, .28);
  border-radius: var(--r-inner);
  background: rgba(17, 6, 46, .32);
  color: #FFFFFF;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .18);
}
.dash-fuelprice-top :is(.dash-fuelprice-name, .dash-fuelprice-price, .dash-fuelprice-price small, .dash-fuelprice-change, .dash-fuelprice-empty) {
  color: #FFFFFF;
}
.dash-fuelprice-top .dash-fuelprice-price {
  text-align: left;
  font-size: 32px;
  text-shadow: 0 2px 0 rgba(0, 0, 0, .2);
}
.dash-fuelprice-top .dash-fuelprice-name {
  font-size: 15px;
}
/* ▲ / ▼ in a white pill: red up, green down, readable on the gold */
.dash-fuelprice-top .dash-fuelprice-change b {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 999px;
  background: #FFFFFF;
  color: #475569;
}
.dash-fuelprice-top .dash-fuelprice-change.is-up b {
  color: #B42318;
}
.dash-fuelprice-top .dash-fuelprice-change.is-down b {
  color: #2A660B;
}
.dash-chart.dash-chart--fuelprice {
  flex: 1 1 auto;
  min-height: 160px;
  padding: 8px 10px 6px;
}
/* แนวโน้มรายวัน (2026-11-19): a deep navy top with the title and three summary chips, the bars on white below */
.panel.dash-trend {
  padding: 0;
  overflow: hidden;
  isolation: isolate;
}
.dash-trend-top {
  position: relative;
  z-index: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px 18px;
  padding: 18px 20px;
  overflow: hidden;
  background: radial-gradient(circle at 100% 0%, rgba(255, 255, 255, .16) 0, rgba(255, 255, 255, 0) 45%), linear-gradient(145deg, #1E293B 0%, #312E81 100%);
  color: #FFFFFF;
  box-shadow: inset 0 -4px 0 rgba(0, 0, 0, .14);
}
.dash-trend-top .panel-title,
.dash-trend-top .panel-sub {
  margin: 0;
  color: #FFFFFF;
}
.dash-trend-head {
  display: grid;
  gap: 4px;
}
.dash-trend-top .kpi-watermark {
  display: block;
  position: absolute;
  right: -10px;
  bottom: -26px;
  z-index: -1;
  width: 130px;
  height: 130px;
  color: #FFFFFF;
  opacity: .1;
  transform: rotate(-10deg);
  pointer-events: none;
}
.dash-trend-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}
.dash-trend-stat {
  display: grid;
  gap: 0;
  min-width: 92px;
  padding: 8px 14px;
  border: 1px solid rgba(255, 255, 255, .26);
  border-radius: var(--r-inner);
  background: rgba(2, 6, 23, .32);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .16);
}
.dash-trend-stat span {
  font-size: 12.5px;
  color: #FFFFFF;
}
.dash-trend-stat b {
  font-size: 17px;
  font-weight: 700;
  color: #FFFFFF;
  font-variant-numeric: tabular-nums;
}
.panel.dash-trend > .dash-chart {
  padding: 10px 12px 0;
}
@media screen and (max-width: 767.98px) {
  .dash-trend-stats {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    width: 100%;
  }
  .dash-trend-stat {
    min-width: 0;
    padding: 8px 10px;
  }
  .dash-trend-stat b {
    font-size: 15px;
    line-height: 1.3;
  }
}
.panel.dash-trend > .dash-trend-details {
  margin: 0 20px 16px;
}
/* Welcome: the SCSNP command banner, deep blue with white text */
.dash-welcome {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 20px 22px;
  grid-area: welcome;
  position: relative;
  isolation: isolate;
  overflow: hidden;
  background: #1E3A8A;
  border-color: #1E40AF;
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, .35), 0 7px 0 #152C6E, 0 24px 48px -12px rgba(29, 78, 216, .55);
}
.dash-welcome::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: -1;
  background: radial-gradient(420px 260px at 88% 20%, rgba(147, 197, 253, .35), transparent 70%), linear-gradient(135deg, #1E3A8A 0%, #1D4ED8 55%, #2563EB 100%);
}
.dash-welcome h3 {
  margin: 0;
  font-size: 20px;
  font-weight: 600;
  color: #FFFFFF;
  text-shadow: 0 2px 4px rgba(0, 0, 0, .22);
}
.dash-welcome p {
  margin: 0 0 6px;
  font-size: 14px;
  line-height: 1.6;
  color: #EFF6FF;
}
/* ---------- Driver list and small rows on the dashboard: raised tiles ---------- */
.dash-driver-bar {
  display: block;
  height: 8px;
  border-radius: 999px;
  overflow: hidden;
  background: #E2E8F0;
  box-shadow: inset 0 1px 2px rgba(15, 23, 42, .12);
}
.dash-driver-bar > span {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #1D4ED8 0%, #2563EB 55%, #0284C7 100%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .38), 0 1px 3px rgba(37, 99, 235, .3);
}
/* การ์ดล้น (2026-11-19): in a compact card the urgency chip gives way ("…") before the time or ขอรถ do, and the bottom line stops
   at two lines; the columns are a little wider */
#view-dashboard .dash-number {
  font-variant-numeric: tabular-nums;
}
#view-dashboard .dash-welcome-art {
  overflow: visible;
}
@media (min-width: 1024px) {
  #view-dashboard .dash-welcome-art {
    width: 210px;
  }
}
/* the dashboard's motion, simple (spec 2026-11-21, replaces the 3D entrance and tilt of 2026-11-18): the figures count up once
   (dashboard-motion.js, --count-up-ms) and a card lifts 2px under a mouse; no flipping, no tilting, no glare */
#view-dashboard .dash-kpi-glare {
  display: none;
}
@media (hover: hover) and (pointer: fine) and (prefers-reduced-motion: no-preference) {
  #view-dashboard :is(.dash-kpi, .dash-grid > .panel) {
    transition: transform .15s ease, box-shadow .15s ease;
  }
  #view-dashboard :is(.dash-kpi, .dash-grid > .panel):hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lift);
  }
}
/* the banner holds the title, the period and the mission types */
.hero--dashboard .dash-filters {
  margin: 4px 0 0;
}

/* ---------- views: จัดการระบบ (#view-admin) and the admin dialogs (บัญชี, พลขับ, รถ, ผลัดเวร, หน่วยงาน, สถานที่, เยี่ยมบ้าน, รพ., ภารกิจ) ---------- */
/* Forms and Inputs */
.checkbox-item {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 0.85rem;
  cursor: pointer;
}
.checkbox-item input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--primary);
  cursor: pointer;
}
/* =========================================================
   DRIVER AVATAR & PHOTO UPLOAD STYLES
   ========================================================= */
.photo-preview-circle {
  width: 64px;
  height: 64px;
  min-width: 64px;
  border-radius: 0;
  background: #1e293b;
  border: 2px solid #3b82f6;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  overflow: hidden;
  flex-shrink: 0;
}
.photo-preview-circle img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}
/* ============================================== */
.pcb-btn-demo:hover {
  color: #94a3b8;
}
/* Timeline Modal: Stage Proof Photos Grid */
.timeline-photos-section {
  margin: 1.25rem 0 1rem 0;
  padding: 1rem;
  background: var(--soft);
  border: 1px solid var(--line);
  border-radius: var(--r-inner);
}
.timeline-photos-title {
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--primary-hover);
  display: flex;
  align-items: center;
  gap: 0.45rem;
  margin-bottom: 0.85rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--line);
}
.timeline-photos-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0.85rem;
}
.timeline-photo-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r-inner);
  padding: 0.65rem;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  transition: all 0.2s ease;
}
.timeline-photo-card.has-photo:hover {
  border-color: var(--primary);
  background: #F8FAFF;
  box-shadow: var(--shadow);
}
.timeline-photo-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--ink);
}
.timeline-photo-card-header .icon {
  width: 15px;
  height: 15px;
  vertical-align: -2px;
  color: var(--primary);
}
.timeline-photo-card-thumb {
  width: 100%;
  height: 120px;
  background: var(--soft);
  border-radius: var(--r-inner);
  overflow: hidden;
  position: relative;
  border: 1px solid var(--line);
  cursor: pointer;
}
.timeline-photo-card-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.25s ease;
}
.timeline-photo-card-thumb:hover img {
  transform: scale(1.05);
}
.timeline-photo-card-thumb .zoom-icon {
  position: absolute;
  top: 6px;
  right: 6px;
  background: rgba(15, 23, 42, 0.82);
  color: #fff;
  font-size: 0.7rem;
  padding: 2px 8px;
  border-radius: 999px;
  pointer-events: none;
}
.timeline-photo-card-thumb.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: #F8FAFC;
  color: var(--muted);
  font-size: 0.78rem;
  cursor: default;
  border-style: dashed;
}
.timeline-photo-meta {
  font-size: 0.75rem;
  color: var(--muted);
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.timeline-gps-link {
  color: var(--primary-hover);
  text-decoration: underline;
  font-size: 0.75rem;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 3px;
  cursor: pointer;
}
/* Print Refer Sheet Photos Section */
.refer-sheet-photos-box {
  border: 1px solid #999;
  padding: 10px;
  margin-bottom: 14px;
  border-radius: 4px;
  background: #fafafa;
}
.refer-sheet-photos-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-top: 8px;
}
.refer-sheet-photo-item {
  border: 1px solid #ccc;
  border-radius: 4px;
  padding: 6px;
  background: #fff;
  text-align: center;
}
.refer-sheet-photo-item img {
  width: 100%;
  height: 100px;
  object-fit: cover;
  border-radius: 3px;
  display: block;
}
.refer-sheet-photo-caption {
  font-size: 0.75rem;
  color: #333;
  margin-top: 4px;
  font-weight: 600;
}
/* GPS live map (js/gps-map.js) */
.gps-admin-unknown {
  border: 1px dashed var(--duty-edge);
  margin-bottom: 1rem;
}
.gps-admin-unknown ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: .5rem;
}
.gps-admin-unknown li span {
  color: var(--muted);
}
.gps-admin-form {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: .75rem;
  align-items: end;
  margin-bottom: 1rem;
}
.gps-admin-form label:not(.admin-check) {
  display: grid;
  gap: .3rem;
}
.gps-admin-form .gps-admin-check {
  display: flex;
  align-items: center;
  gap: .4rem;
}
/* GPS map page (#view-map) */
.gps-crew h3 {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: .25rem;
}
/* Mission timeline: status steps with phone GPS, leg durations, numbered map pins */
.timeline-stage-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: .6rem;
}
.timeline-stage-label {
  color: var(--muted);
  font-size: .78rem;
}
.timeline-stage strong {
  font-size: 1.05rem;
  font-variant-numeric: tabular-nums;
}
.timeline-stage a,
.timeline-stage small {
  font-family: var(--font-mono);
  font-size: .7rem;
  word-break: break-all;
}
.timeline-durations {
  margin-top: 1rem;
  padding: .7rem .9rem;
  border-radius: var(--r-inner);
  background: #fffbeb;
  border: 1px solid #fcd34d;
}
.timeline-duration-row {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: .2rem 0;
  font-size: .88rem;
  border-bottom: 1px dashed rgba(180, 83, 9, .25);
}
.timeline-duration-row:last-child {
  border-bottom: 0;
  font-weight: 700;
}
.timeline-map-pin {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: #006400;
  color: #fff;
  font-weight: 700;
  font-size: .8rem;
  box-shadow: 0 0 0 3px #fff, 0 2px 6px rgba(0, 0, 0, .35);
}
.timeline-map-pin.is-destination {
  background: #16a34a;
  box-shadow: 0 0 0 3px #fff, 0 0 0 6px rgba(22, 163, 74, .35), 0 2px 6px rgba(0, 0, 0, .35);
}
/* Status colours: each timeline step has its own tint (grey and dashed until it happens) */
.timeline-stage {
  display: grid;
  gap: .15rem;
  padding: .55rem .7rem;
  border-radius: var(--r-inner);
  border: 1px solid rgba(0, 100, 0, .12);
  font-size: .85rem;
  border-left: 5px solid var(--stage-color, #006400);
  background: var(--stage-bg, rgba(0, 100, 0, .05));
}
.timeline-stage.stage-assigned {
  --stage-color: #2563eb;
  --stage-bg: #eff6ff;
}
.timeline-stage.stage-depart {
  --stage-color: #ea580c;
  --stage-bg: #fff7ed;
}
.timeline-stage.stage-arrive {
  --stage-color: #16a34a;
  --stage-bg: #dcfce7;
}
.timeline-stage.stage-base {
  --stage-color: #0891b2;
  --stage-bg: #ecfeff;
}
.timeline-stage.stage-closed {
  --stage-color: #7c3aed;
  --stage-bg: #f5f3ff;
}
.timeline-stage.is-empty {
  --stage-color: #cbd5e1;
  --stage-bg: #f8fafc;
  border-style: dashed;
  opacity: .7;
}
@media screen {
  body.modal-open {
    overflow: hidden;
  }
}
@media screen and (max-width: 767px) {
  #admin-missions-search {
    width: 100%;
  }
}
@media screen {
  .photo-preview-circle img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
    object-position: center;
    border-radius: 0;
    background: #f7f9fc;
  }
  .photo-preview-circle {
    padding: 3px;
    border-width: 1px;
    border-style: solid;
    border-color: #cdd8e6;
    border-radius: 9px;
    background: linear-gradient(145deg, #ffffff, #e8eef6);
    box-shadow: 0 3px 7px rgba(32, 55, 85, .12), 0 1px 2px rgba(32, 55, 85, .08), inset 0 1px 0 rgba(255, 255, 255, .95);
    flex-shrink: 0;
    width: 80px;
    height: 80px;
    min-width: 80px;
  }
}
.vehicle-directory-name {
  display: flex;
  align-items: center;
  gap: .6rem;
}
.vehicle-photo-thumb {
  padding: 3px;
  border: 1px solid #d7e0eb;
  border-radius: var(--r-inner);
  background: #f3f6fa;
  cursor: pointer;
  overflow: hidden;
  width: 76px;
  height: 56px;
  flex-shrink: 0;
}
.vehicle-photo-thumb img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
}
@media screen {
  /* Functional colours are restrained and consistent across both themes. */
  tr.driver-retired {
    opacity: .6;
  }
}
/* ---------- Driver shared: notices, chips, photo capture ---------- */
.pcb-photo {
  display: block;
  max-width: 100%;
  max-height: 180px;
  margin: 0 auto;
  border: 2px solid var(--primary);
  border-radius: 10px;
  object-fit: cover;
}
.pcb-done {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin-top: 8px;
  color: var(--done);
  font-size: 14px;
  font-weight: 600;
}
.pcb-done .icon {
  width: 16px;
  height: 16px;
  margin-right: 2px;
  vertical-align: -3px;
}
.pcb-map-link {
  margin-left: 6px;
  color: var(--primary);
  text-decoration: underline;
}
.pcb-btn-demo {
  font-size: 0.72rem;
  text-decoration: underline;
  cursor: pointer;
  padding: 4px;
  transition: color 0.2s;
  min-height: 44px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: var(--card);
  color: var(--ink);
  box-shadow: none;
}
/* Long admin forms: six times in three columns, the map pickers, the photo row, a full-width button inside a section */
.pick-map {
  height: 240px;
  margin-top: 8px;
  border: 1px solid var(--line);
  border-radius: var(--r-inner);
}
.photo-upload-fields {
  flex: 1 1 220px;
  min-width: 0;
}
.form-wide-btn {
  width: 100%;
  margin: 4px 0 12px;
}
.uppercase {
  text-transform: uppercase;
}
/* Short forms: as tall as their content. Without numbered sections the body carries its own padding */
.input-with-button {
  display: flex;
  gap: 8px;
}
.input-with-button > .form-control {
  flex: 1;
  min-width: 0;
}
#modal-mobile-qr {
  z-index: 10050;
}
.qr-frame {
  display: inline-block;
  margin: 4px 0 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--r-inner);
  background: #FFFFFF;
}
.qr-frame img {
  display: block;
  width: 220px;
  max-width: 100%;
  height: auto;
}
.qr-frame img[hidden] {
  display: none;
}
.qr-url {
  display: block;
  margin: 10px 0 14px;
  padding: 10px 14px;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-inner);
  color: var(--primary-hover);
  font-family: var(--font-mono);
  font-weight: 600;
  overflow-wrap: anywhere;
}
.qr-tips {
  text-align: left;
}
.qr-tips ul {
  margin: 4px 0 0;
  padding-left: 20px;
}
@media screen and (max-width: 767.98px) {
  #modal-my-line .modal-footer .btn {
    flex: 1 1 100%;
  }
}
/* ---------- Admin page (จัดการระบบ, spec 2026-10-24-cars-mobile-admin): a section picker that opens a sheet below 1024px,
   a 220px menu column from 1024px; each section's head, tools and card tables ---------- */
.admin-tab-pane[hidden],
.admin-nav-backdrop[hidden] {
  display: none;
}
.admin-picker {
  display: flex;
  flex: 1 1 100%;
  align-items: center;
  gap: 12px;
  min-width: 0;
  min-height: 56px;
  padding: 6px 14px 6px 8px;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-inner);
  background: var(--card);
  color: var(--ink);
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.admin-picker:focus-visible {
  outline: 3px solid rgba(31, 122, 85, 0.45);
  outline-offset: 2px;
}
.admin-picker-icon {
  display: inline-flex;
  flex-shrink: 0;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: var(--r-inner);
  background: var(--done-bg);
  color: var(--primary);
}
.admin-picker-text {
  display: flex;
  flex: 1;
  flex-direction: column;
  min-width: 0;
  line-height: 1.35;
}
.admin-picker-text small {
  color: var(--muted);
  font-size: 12px;
}
.admin-picker-text strong {
  font-size: 16px;
  font-weight: 700;
  overflow-wrap: anywhere;
}
.admin-picker-hint {
  flex-shrink: 0;
  color: var(--primary);
  font-size: 13px;
  font-weight: 600;
}
.admin-picker-chevron {
  flex-shrink: 0;
  color: var(--muted);
  transform: rotate(90deg);
}
.admin-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  box-sizing: border-box;
}
.admin-nav-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 0 4px 12px;
}
.admin-nav-head h3 {
  flex: 1;
  margin: 0;
  color: var(--ink);
  font-size: 18px;
  font-weight: 700;
}
.admin-nav-group {
  margin: 10px 0 2px;
  padding: 0 12px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}
.admin-nav-item > .icon {
  color: var(--primary);
}
.admin-nav-item > span {
  flex: 1;
  min-width: 0;
}
.admin-nav-item:hover {
  background: var(--soft);
}
.admin-nav-item:focus-visible {
  outline: 3px solid rgba(31, 122, 85, 0.45);
  outline-offset: -3px;
}
.admin-nav-check {
  visibility: hidden;
}
.admin-nav-item[aria-current="page"] .admin-nav-check {
  visibility: visible;
}
@media screen and (min-width: 768px) and (max-width: 1023.98px) {
  .admin-picker {
    flex: 0 1 auto;
    min-width: 300px;
    margin-left: auto;
  }
}
@media screen and (max-width: 1023.98px) {
  .admin-nav-backdrop {
    position: fixed;
    inset: 0;
    z-index: 59;
    background: rgba(16, 37, 28, 0.45);
  }
  .admin-nav {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 60;
    max-height: 85dvh;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 12px 12px calc(16px + env(safe-area-inset-bottom));
    border-radius: var(--r-card) 16px 0 0;
    background: var(--card);
    box-shadow: 0 -8px 24px rgba(16, 37, 28, 0.2);
  }
  .admin-nav[hidden] {
    display: none;
  }
}
@media screen and (min-width: 1024px) {
  .admin-picker,
  .admin-nav-head,
  .admin-nav-backdrop {
    display: none;
  }
  .admin-layout {
    display: grid;
    grid-template-columns: 220px minmax(0, 1fr);
    align-items: start;
    gap: 20px;
  }
  .admin-nav-group:first-of-type {
    margin-top: 4px;
  }
  /* 220px leaves no room for the tick: the green fill marks the current section */
  .admin-nav-item {
    gap: 10px;
    min-height: 44px;
    padding: 0 10px;
    font-size: 14px;
  }
  .admin-nav-check {
    display: none;
  }
}
/* Each section: a head (title, one line, the main button), a tools row, notes, then panels and card tables */
.admin-tab-pane {
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-width: 0;
}
.admin-pane-head {
  --pane-accent: #2563EB;
  --pane-soft: #EAF1FF;
  --pane-ink: #1E3A8A;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px 16px;
  padding: 16px 20px;
  border-left: 6px solid var(--pane-accent);
  border-radius: 16px;
  background: var(--pane-soft);
  box-shadow: var(--shadow);
}
/* each section its own colour (user 2026-11-26: "หัวข้อแต่ละหัวข้อ ไม่เด่นเลย") */
#admin-tab-users > .admin-pane-head { --pane-accent: #2563EB; --pane-soft: #EAF1FF; --pane-ink: #1E3A8A; }
#admin-tab-drivers > .admin-pane-head { --pane-accent: #7C3AED; --pane-soft: #F1EBFF; --pane-ink: #4C1D95; }
#admin-tab-shifts > .admin-pane-head { --pane-accent: #0F766E; --pane-soft: #E3F4F1; --pane-ink: #134E4A; }
#admin-tab-ambulances > .admin-pane-head { --pane-accent: #EA580C; --pane-soft: #FFEFE5; --pane-ink: #7C2D12; }
#admin-tab-gps > .admin-pane-head { --pane-accent: #0891B2; --pane-soft: #E3F4F9; --pane-ink: #164E63; }
#admin-tab-hospitals > .admin-pane-head { --pane-accent: #E11D48; --pane-soft: #FFECEF; --pane-ink: #881337; }
#admin-tab-places > .admin-pane-head { --pane-accent: #16A34A; --pane-soft: #E8F6EC; --pane-ink: #14532D; }
#admin-tab-homevisits > .admin-pane-head { --pane-accent: #C026D3; --pane-soft: #FBEBFD; --pane-ink: #701A75; }
#admin-tab-departments > .admin-pane-head { --pane-accent: #D97706; --pane-soft: #FFF4E0; --pane-ink: #78350F; }
#admin-tab-missions > .admin-pane-head { --pane-accent: #475569; --pane-soft: #EDF1F6; --pane-ink: #1E293B; }
#admin-tab-telegram > .admin-pane-head { --pane-accent: #4F46E5; --pane-soft: #EEEDFF; --pane-ink: #312E81; }
.admin-pane-head > div {
  flex: 1 1 260px;
  min-width: 0;
}
.admin-pane-head h3 {
  margin: 0;
  color: var(--pane-ink);
  font-size: 22px;
  font-weight: 700;
  line-height: 1.35;
}
.admin-pane-head h3 .section-count {
  margin-left: 6px;
  font-weight: 400;
}
.admin-pane-head p {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 13px;
  overflow-wrap: anywhere;
}
.admin-tools {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
}
.admin-tools .search-field {
  flex: 1 1 240px;
  max-width: 420px;
}
.admin-tools select {
  flex: 0 1 220px;
  min-height: 44px;
  max-width: 100%;
}
.admin-tab-pane .table-cards-box > .data-table-container {
  margin: 0;
}
@media screen and (max-width: 767.98px) {
  .admin-pane-head > .btn {
    flex: 1 0 100%;
  }
}
.admin-master-pw {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 14px;
  padding: 12px 16px;
}
.admin-master-pw > .icon {
  color: var(--primary);
}
.admin-master-pw p {
  flex: 1 1 220px;
  margin: 0;
  font-size: 14px;
}
.admin-master-pw strong {
  margin-left: 6px;
  letter-spacing: 1px;
  overflow-wrap: anywhere;
}
.admin-person {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.admin-person > span {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.admin-person strong {
  overflow-wrap: anywhere;
}
.admin-person small {
  color: var(--muted);
  font-size: 12px;
}
.admin-pin-cell {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 8px;
}
.admin-pin {
  padding: 0;
  background: none;
  color: var(--ink);
  font-family: var(--font-mono);
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 2px;
}
/* Who may do what: folded by default; the table scrolls inside its box with the first column held */
.admin-rights {
  padding: 0;
}
.admin-rights > summary {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 48px;
  padding: 0 16px;
  color: var(--ink);
  font-size: 15px;
  font-weight: 700;
  list-style: none;
  cursor: pointer;
}
.admin-rights > summary::-webkit-details-marker {
  display: none;
}
.admin-rights > summary .icon {
  color: var(--primary);
  transition: transform 0.15s;
}
.admin-rights[open] > summary .icon {
  transform: rotate(90deg);
}
.admin-rights-scroll {
  overflow-x: auto;
  border-top: 1px solid var(--line);
}
.admin-rights-table {
  width: 100%;
  min-width: 640px;
  border-collapse: collapse;
  font-size: 13px;
}
.admin-rights-table :is(th, td) {
  padding: 8px 12px;
  border-bottom: 1px solid #EDF2EF;
  text-align: left;
  vertical-align: top;
}
.admin-rights-table thead th {
  background: var(--soft);
  color: var(--muted);
  font-weight: 600;
}
.admin-rights-table tbody th {
  color: var(--ink);
  font-weight: 600;
}
.admin-rights-table :is(thead, tbody) th:first-child {
  position: sticky;
  left: 0;
  z-index: 1;
  min-width: 150px;
  background: var(--card);
}
.admin-rights-table thead th:first-child {
  background: var(--soft);
}
.right-yes,
.right-no {
  display: inline-flex;
  align-items: flex-start;
  gap: 6px;
}
.right-yes {
  color: var(--done);
}
.right-no {
  color: var(--mission);
}
:is(.right-yes, .right-no) .icon {
  flex-shrink: 0;
  width: 16px;
  height: 16px;
  margin-top: 2px;
}
@media (prefers-reduced-motion: reduce) {
  .admin-rights > summary .icon {
    transition: none;
  }
}
/* List sections: a pin mark beside a hospital, the source of an imported place, hidden pins, map symbols */
.admin-has-pin {
  display: inline-flex;
  color: var(--primary);
}
.admin-has-pin .icon {
  width: 16px;
  height: 16px;
}
.admin-source {
  padding: 1px 6px;
  border-radius: 8px;
  background: var(--soft);
  color: var(--muted);
  font-size: 12px;
}
.admin-tab-pane tr.is-hidden-row :is(strong, td) {
  color: var(--muted);
}
.admin-cat {
  display: inline-flex;
  align-items: flex-start;
  gap: 6px;
}
.map-symbol {
  flex-shrink: 0;
  font-size: 16px;
  line-height: 1.3;
}
.admin-tab-pane td.cell-title > :is(.chip, .admin-source, .admin-has-pin) {
  margin-left: 6px;
  vertical-align: middle;
}
.gps-visit-pin.admin-visit-pin {
  flex-shrink: 0;
  width: 24px;
  height: 24px;
  border-width: 2px;
  font-size: 12px;
  vertical-align: middle;
  box-shadow: none;
}
.admin-warn {
  color: var(--mission);
  font-family: var(--font);
}
.admin-symbols {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.admin-symbols-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(300px, 100%), 1fr));
  gap: 16px;
}
.admin-symbols-grid h5 {
  margin: 0 0 6px;
  color: var(--ink);
  font-size: 14px;
  font-weight: 700;
}
.homevisit-symbol-editor {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 8px;
}
.hv-row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.hv-row .hv-icon {
  flex: 0 0 64px;
  text-align: center;
}
.hv-row .hv-label {
  flex: 1;
  min-width: 0;
}
.hv-row .hv-color {
  flex: 0 0 48px;
  height: 44px;
  padding: 2px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: var(--card);
}
.admin-save-row {
  display: flex;
  justify-content: flex-end;
}
@media screen and (max-width: 767.98px) {
  .admin-save-row > .btn {
    flex: 1;
  }
}
/* กล่อง GPS and แจ้งเตือนและตั้งค่า: settings panels in one or two columns, labelled check rows, the speed limits grid */
.admin-subhead {
  margin: 10px 0 0;
  color: var(--ink);
  font-size: 18px;
  font-weight: 700;
}
.admin-form-panel {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin: 0;
}
.admin-check {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  color: var(--ink);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}
.admin-check input {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  margin: 0;
  accent-color: var(--primary);
}
.admin-code {
  font-family: var(--font-mono);
  overflow-wrap: anywhere;
}
.gps-admin-traccar {
  margin-bottom: 1rem;
  margin: 0;
  padding: 10px 14px;
  border-left: 4px solid var(--line-strong);
  border-radius: var(--r-inner);
  color: var(--ink);
  font-size: 14px;
}
.gps-admin-traccar.is-error {
  border-left-color: var(--duty-edge);
  background: var(--duty-bg);
}
.panel.gps-admin-unknown {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 0;
  border: 1px dashed var(--duty-edge);
}
.panel.gps-admin-unknown[hidden] {
  display: none;
}
.gps-admin-unknown li {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .5rem;
  font-size: .85rem;
  overflow-wrap: anywhere;
}
.admin-form-panel .gps-admin-form {
  margin: 0;
}
.admin-form-panel .gps-admin-form > label:not(.admin-check) {
  color: var(--ink);
  font-size: 14px;
  font-weight: 600;
}
.admin-form-panel .gps-admin-form :is(input, select),
.gps-limit input {
  font-weight: 400;
}
.gps-limit-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}
.gps-limit {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
  color: var(--ink);
  font-size: 13px;
  font-weight: 600;
}
.gps-limit > span:first-child {
  align-self: flex-start;
}
@media (min-width: 768px) {
  .gps-limit-grid {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }
  .gps-limit-grid--two {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
@media screen and (min-width: 1024px) {
  @container (min-width: 720px) and (max-width: 959.98px) {
    .table-cards-box.table-cards-box--compact > .data-table-container {
      overflow-x: auto;
      border: 1px solid var(--line);
      border-radius: var(--r-inner);
      background: var(--card);
    }
    .table-cards-box.table-cards-box--compact .data-table--cards {
      display: table;
    }
    .table-cards-box.table-cards-box--compact .data-table--cards thead {
      display: table-header-group;
    }
    .table-cards-box.table-cards-box--compact .data-table--cards tbody {
      display: table-row-group;
    }
    .table-cards-box.table-cards-box--compact .data-table--cards tr {
      display: table-row;
      padding: 0;
      background: transparent;
      border: 0;
      border-radius: 0;
    }
    .table-cards-box.table-cards-box--compact .data-table--cards td,
    .table-cards-box.table-cards-box--compact .data-table--cards td:is(.cell-title, .cell-sub, .cell-status, .cell-actions, .cell-stat, [colspan]) {
      display: table-cell;
      position: static;
      margin: 0;
      padding: 8px 12px;
      border: 0;
      border-bottom: 1px solid #EDF2EF;
      font-size: 14px;
      vertical-align: middle;
      overflow-wrap: normal;
    }
    .table-cards-box.table-cards-box--compact .data-table--cards td:is(.mono, .cell-actions) {
      white-space: nowrap;
    }
    .table-cards-box.table-cards-box--compact .data-table--cards td::before {
      content: none;
    }
    .table-cards-box.table-cards-box--compact .data-table--cards td[colspan] {
      text-align: center;
    }
    .table-cards-box.table-cards-box--compact .data-table--cards .row-actions {
      display: flex;
      flex-wrap: nowrap;
      gap: 6px;
      width: max-content;
    }
    /* desktop keys (40px, as everywhere at 1024px and up), not the phone cards' 44px: one-line rows ≈ 57px (2026-11-25) */
    .table-cards-box.table-cards-box--compact .data-table--cards .row-actions .btn {
      flex: 0 0 auto;
      min-height: 40px;
    }
    .table-cards-box.table-cards-box--compact .data-table--cards .row-actions .btn.btn-icon {
      flex: 0 0 40px;
      width: 40px;
    }
  }
}
/* theme-glass.css colours every .btn-outline with !important in the legacy layer; only console-fix outranks it */
#modal-check-detail .check-detail-meta {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 6px 16px;
  margin: 0 0 12px;
}
#modal-check-detail .check-detail-meta dt {
  color: var(--muted);
  font-size: 13px;
}
#modal-check-detail .check-detail-meta dd {
  margin: 0;
  color: var(--ink);
  font-weight: 500;
  overflow-wrap: anywhere;
}
#modal-check-detail .check-points {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 1px;
  margin: 0 0 12px;
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--line);
  list-style: none;
}
#modal-check-detail .check-point-sign {
  display: inline-grid;
  flex-shrink: 0;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  font-weight: 700;
}
#modal-check-detail .check-point-text {
  margin-left: auto;
  color: var(--muted);
  font-size: 13px;
}
#modal-check-detail .check-point--ok .check-point-sign {
  background: var(--done-bg);
  color: var(--done);
}
#modal-check-detail .check-point--bad .check-point-sign {
  background: var(--mission);
  color: #FFFFFF;
}
#modal-check-detail .check-point--bad .check-point-text {
  color: var(--mission);
  font-weight: 700;
}
#modal-check-detail .check-point--none .check-point-sign {
  background: var(--duty-bg);
  color: var(--duty);
}
#modal-check-detail .check-detail-photo img {
  display: block;
  max-width: 100%;
  max-height: 320px;
  border-radius: 10px;
}
/* ---------- Destination picker: type to match the list, Longdo Map for places missing from it (app.js) ----------
   The list sits in the flow under the input, so the scrolling dialog and the phone bottom sheet never clip it. */
.dest-option.is-active {
  background: var(--soft);
  box-shadow: inset 3px 0 0 var(--primary);
}
.dest-option-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.dest-option-meta {
  color: var(--muted);
  font-size: 0.8125rem;
  line-height: 1.4;
}
.dest-picker-caption,
.dest-picker-status {
  padding: 8px 12px;
  border-top: 1px solid var(--border-divider);
  background: var(--bg);
  color: var(--muted);
  font-size: 0.8125rem;
}
/* ไปพร้อมกัน (2026-11-18): other slips that ride in the same car, ticked in the รับงาน dialog */
.hosxp-accept__together {
  margin: 0 0 12px;
  padding: 0;
  border: 0;
}
.hosxp-accept__together-list {
  display: grid;
  gap: 6px;
  margin: 6px 0;
}
.hosxp-together {
  display: grid;
  grid-template-columns: auto auto minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 6px 12px;
  border: 1px solid #BFD3F2;
  border-radius: var(--r-inner);
  background: #FFFFFF;
  color: #0F172A;
  cursor: pointer;
}
.hosxp-together input {
  width: 20px;
  height: 20px;
  accent-color: #1D4ED8;
}
.hosxp-together strong {
  color: #0B2E6B;
}
.hosxp-together span {
  font-size: 14px;
  color: #334155;
  overflow-wrap: anywhere;
}
.hosxp-together:has(input:checked) {
  border: 2px solid #1D4ED8;
  background: #DBEAFE;
}
/* Engine state in the GPS admin table (GpsAdmin.engineLabel): a power icon in a chip, amber while running, silver when off,
   so it reads apart from the green "ออนไลน์" chip beside it */
.engine-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-left: 8px;
  padding: 3px 10px 3px 6px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.4;
  white-space: nowrap;
  vertical-align: middle;
  box-shadow: none;
}
.engine-chip .icon {
  width: 16px;
  height: 16px;
  stroke-width: 2.6;
}
.engine-chip.is-on {
  background: #FDE68A;
  color: #5A3A00;
}
.engine-chip.is-on .icon {
  color: #B45309;
}
.engine-chip.is-off {
  background: var(--soft);
  color: var(--muted);
}
@media screen and (min-width: 1024px) {
  #admin-nav,
  #admin-nav[hidden] {
    display: flex;
    position: sticky;
    padding: 8px;
    border: 1px solid var(--line);
    border-radius: var(--r-inner);
    background: var(--card);
    top: 84px;
  }
}
.gps-admin-traccar.is-ok {
  background: var(--done-bg);
  border-left-color: #2F7A12;
}
/* console.css draws these three rings in a pale green (about 1.9:1); full purple reads at 4:1 */
.admin-nav-item:focus-visible,
.admin-picker:focus-visible {
  outline-color: var(--primary);
}
/* ---------- Car in for repair (admin vehicle list, 2026-11-11): orange chip, tinted row, clear buttons ---------- */
.chip.chip--repair {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: #FFEDD5;
  color: #7C2D12;
  border: 1px solid #FDBA74;
  font-weight: 600;
}
.chip.chip--repair::before {
  content: "🔧";
}
#admin-ambulances-tbody tr.is-repair > td {
  background: #FFF7ED;
}
.btn.btn-repair {
  color: #9A3412;
  border-color: #FDBA74;
}
.btn.btn-repair:hover {
  background: #FFEDD5;
}
.btn.btn-repair-done {
  color: #166534;
  border-color: #86EFAC;
}
.btn.btn-repair-done:hover {
  background: #DCFCE7;
}
/* ---------- Fuel (2026-11-12): the dashboard card's how-it-was-counted line, PTT prices on the settings page ---------- */
.fuel-price-list {
  list-style: none;
  margin: 4px 0 8px;
  padding: 0;
  display: grid;
  gap: 6px;
}
.fuel-price-list li {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 10px;
  padding: 8px 12px;
  border: 1px solid #E5E7EB;
  border-radius: 10px;
  background: #FFFBEB;
  color: #374151;
}
.fuel-price-list li > span {
  flex: 1 1 auto;
  font-weight: 600;
}
.fuel-price-list li > strong {
  font-size: 17px;
  color: #7C2D12;
}
.fuel-price-list li > small {
  color: #4B5563;
}
.fuel-price-list li.fuel-price-empty {
  background: #F9FAFB;
  color: #4B5563;
}
/* แบบฟอร์มตรวจเช็ครถรายคัน (2026-11-17, reports.js checkFormHtml): HOSOffice's paper form. Never on screen; while
   body.print-check-form is set, the paper carries this box alone, A4 landscape */
.check-form-print {
  display: none;
}
/* The admin page's own menu: rows that rise on hover; the open section a raised light-blue key */
.admin-nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 48px;
  padding: 0 12px;
  background: none;
  color: var(--ink);
  font: inherit;
  font-size: 15px;
  text-align: left;
  cursor: pointer;
  border: 1px solid transparent;
  border-radius: var(--r-inner);
  transition: transform .12s ease, background .15s ease, box-shadow .15s ease;
}
.admin-nav-item:hover:not([aria-current="page"]) {
  background: #F3F7FF;
  border-color: #D5E2F6;
  box-shadow: inset 0 1px 0 #FFFFFF, 0 3px 0 #D5E2F6;
}
.admin-nav-item[aria-current="page"] {
  background: #DBEAFE;
  border-color: #BFDBFE;
  color: #1E40AF;
  font-weight: 700;
  box-shadow: inset 0 2px 0 #FFFFFF, 0 3px 0 #93C5FD, 0 8px 16px -6px rgba(37, 99, 235, .3);
}

/* ---------- views: parts whose base rules stayed in the old sheets (found on the live page 2026-11-22: photos at full size) ---------- */
/* the vehicle's photo on its card: the button frames it, the picture fills the frame */
.vehicle-photo-card {
  display: block; overflow: hidden; padding: 0; border: 1px solid var(--line); background: var(--soft); cursor: pointer;
}
.vehicle-photo-card img { display: block; width: 100%; height: 100%; object-fit: cover; }
/* proof photos in a mission row (ศูนย์สั่งการ, ประวัติ): a 36px thumbnail beside its words, one 44px tap */
.archive-photos {
  display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 6px 0 0; border: 0; background: none;
  color: var(--done); font: inherit; font-size: 13px; font-weight: 600; text-align: left; cursor: pointer;
}
.archive-photos img { flex-shrink: 0; width: 36px; height: 36px; border-radius: 8px; object-fit: cover; }
/* a row of the destination picker: 44px to tap */
.dest-option {
  display: flex; align-items: flex-start; gap: 10px; min-height: 44px; padding: 10px 12px; box-sizing: border-box;
  border-top: 1px solid var(--line); cursor: pointer;
}
/* the shift banner's chips: one centred row that wraps */
.standby-chips { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; }
.phone-dispatch-note { margin-bottom: 8px; color: var(--muted); font-size: 13px; }

/* ---------- views: mission tables on a wide screen (user 2026-11-22: "ใช้พื้นที่มากไป ให้ตัวอักษรเท่ากันและให้อยู่ในหนึ่งบรรทัด"): from 960px of table width ศูนย์สั่งการ, ประวัติ and the admin mission list keep one line a row in one text size; on a phone they stay cards ---------- */
.cell-clip { overflow-wrap: anywhere; }
@media screen {
  @container (min-width: 960px) {
    /* fixed columns: the short ones take a set width, ผู้ป่วย / ปลายทาง / รถ · พลขับ share the rest and end in … */
    .data-table--cards:has(.archive-code) { table-layout: fixed; }
    .data-table--cards:has(.archive-code) td {
      overflow: hidden; padding: 8px 10px; font-size: 14px; white-space: nowrap; text-overflow: ellipsis; vertical-align: middle;
    }
    .data-table--cards:has(.archive-code) th { padding: 8px 10px; }
    .data-table--cards:has(.archive-code) :is(.archive-code, .archive-patient, .archive-hn, .archive-place, .triage-tag, .chip) { font-size: 14px; }
    .data-table--cards:has(.archive-code) .archive-code { margin-right: 6px; font-weight: 600; }
    /* the mission type is a dot beside the code (the code's REF-/EMS-/LAB-/STF- names it too) */
    .data-table--cards:has(.archive-code) .cell-title :is(.badge-refer, .badge-ems, .badge-mobile, .badge-staff, .badge-lab) {
      padding: 0; gap: 0; background: none; font-size: 0; vertical-align: middle;
    }
    .data-table--cards:has(.archive-code) :is(.archive-patient, .archive-hn, .cell-clip) { display: inline; }
    .data-table--cards:has(.archive-code) .archive-hn { margin-left: 6px; }
    .data-table--cards:has(.archive-code) .archive-place { display: inline; margin: 0 0 0 6px; }
    .data-table--cards:has(.archive-code) .mission-crew { display: flex; min-width: 0; }
    .data-table--cards:has(.archive-code) .mission-crew .cell-clip { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
    .data-table--cards:has(.archive-code) .mission-crew .driver-avatar-thumb { display: none; }
    .data-table--cards:has(.archive-code) :is(.triage-tag, .chip) { max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
    /* the buttons in one row as 40px keys with their icon (the words in the title); the proof photo a thumbnail */
    .data-table--cards:has(.archive-code) .row-actions { display: flex; flex-wrap: nowrap; align-items: center; gap: 4px; }
    .data-table--cards:has(.archive-code) .row-actions .btn { width: 40px; padding: 0; font-size: 0; }
    .data-table--cards:has(.archive-code) .archive-photos { gap: 0; min-height: 40px; padding: 0; font-size: 0; }
    .data-table--cards:has(.archive-code) .archive-photos img { width: 40px; height: 40px; }
    /* keys and the photo never shrink below 40px (2026-11-24: a full row had squeezed them to 32px) */
    .data-table--cards:has(.archive-code) .row-actions > * { flex: none; }
    /* the centre's row (user 2026-11-24, option 3): no proof photo (it is in ไทม์ไลน์) and the driver only under พลขับ, the car in
       the title, so ปลายทาง and พลขับ get the room; on a phone the card keeps both */
    .center-missions-table .row-actions .archive-photos, .center-missions-table .crew-car { display: none; }
    .center-missions-table th:nth-child(1), .archive-table th:nth-child(1), .admin-missions-table th:nth-child(1) { width: 186px; }
    /* the patient narrow, the case colour in full ("Resuscitation (แดง)" is the longest, 155px; user 2026-11-22); the code
       (16 characters, REF-20261124-002), time, date and status in full (2026-11-24, quest-rows W4) */
    .center-missions-table th:nth-child(2) { width: 112px; }
    .center-missions-table th:nth-child(3) { width: 176px; }
    .center-missions-table th:nth-child(6) { width: 148px; }
    .center-missions-table th:nth-child(7) { width: 76px; }
    .center-missions-table th:nth-child(8) { width: 196px; }
    .archive-table th:nth-child(2) { width: 160px; }
    .archive-table th:nth-child(6) { width: 68px; }
    .archive-table th:nth-child(7) { width: 66px; }
    .archive-table th:nth-child(8) { width: 138px; }
    .archive-table th:nth-child(9) { width: 236px; }
    .admin-missions-table th:nth-child(5) { width: 144px; }
    .admin-missions-table th:nth-child(6) { width: 76px; }
    .admin-missions-table th:nth-child(7) { width: 70px; }
    .admin-missions-table th:nth-child(8) { width: 138px; }
    .admin-missions-table th:nth-child(9) { width: 148px; }
    /* จัดการระบบ (user 2026-11-25: "ใช้พื้นที่มากไป บรรทัดกว้างเกินความจำเป็น"): a row's keys in one line instead of two by two, and
       rows only as tall as their content (one line ≈ 57px, was 109px; the padding is .data-table's); the mission list above keeps its own rules */
    .admin-tab-pane .data-table--cards:not(:has(.archive-code)) .row-actions { display: flex; flex-wrap: nowrap; gap: 4px; width: max-content; }
    .admin-tab-pane .data-table--cards:not(:has(.archive-code)) .row-actions > * { flex: none; }
  }
}

/* ---------- Detail, Timeline, Lightbox & Print Modals (Quest Theme Polish) ---------- */
.detail-modal-box { max-width: 680px; }
.lightbox-box { max-width: 640px; }
.timeline-modal-box, .print-modal-box { max-width: 820px; }
.lightbox-stage {
  display: flex; align-items: center; justify-content: center; overflow: hidden;
  max-height: 480px; border: 1px solid var(--line); border-radius: var(--r-inner); background: #0F172A;
}
.lightbox-stage img { display: block; width: 100%; max-height: 480px; object-fit: contain; }
.lightbox-meta {
  display: grid; gap: 6px; margin-top: 12px; padding: 12px 14px;
  border: 1px solid var(--line); border-radius: var(--r-inner); background: var(--soft);
  color: var(--ink); font-size: 14px; text-align: left;
}
.lightbox-meta-row { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.lightbox-gps-code {
  padding: 2px 8px; border: 1px solid var(--line); border-radius: 6px;
  background: var(--card); color: var(--primary-hover); font-family: var(--font-mono); font-size: 13px;
}
.lightbox-map-link {
  display: inline-flex; align-items: center; gap: 4px;
  color: var(--primary-hover); font-size: 13px; font-weight: 600; text-decoration: underline;
}
.lightbox-map-link .icon { width: 15px; height: 15px; }
.timeline-map-box {
  display: flex; align-items: center; justify-content: center;
  width: 100%; height: 350px; margin-top: 16px;
  border: 1px solid var(--line); border-radius: var(--r-inner); background: var(--soft); color: var(--muted);
}
.timeline-summary-card {
  margin-bottom: 14px; padding: 12px 16px;
  border: 1px solid var(--line); border-radius: var(--r-inner); background: var(--soft);
}
.timeline-summary-code { color: var(--muted); font-size: 13px; }
.timeline-summary-code strong { color: var(--primary-hover); }
.timeline-summary-dest { margin-top: 2px; color: var(--ink); font-size: 17px; font-weight: 700; }
.timeline-gps-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 2px; }
.timeline-gps-coords { color: var(--ink); font-family: var(--font-mono); font-size: 12px; }
.timeline-empty-note { color: var(--muted); font-size: 12px; }
.detail-loading { padding: 24px; color: var(--muted); text-align: center; }
.detail-error {
  padding: 14px 16px; border: 1px solid var(--mission-edge); border-radius: var(--r-inner);
  background: var(--mission-bg); color: var(--mission); font-weight: 600;
}
.detail-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; margin-bottom: 12px; }
.detail-grid--3 { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
.detail-card {
  padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--r-inner); background: var(--soft);
}
.detail-label { color: var(--muted); font-size: 12px; font-weight: 600; }
.detail-value { margin-top: 2px; color: var(--ink); font-size: 15px; font-weight: 700; }
.detail-value--primary { color: var(--primary-hover); }
.detail-sub { margin-top: 4px; color: var(--muted); font-size: 13px; }
.detail-section { margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--line); }
.detail-section-title {
  display: flex; align-items: center; gap: 6px; margin-bottom: 10px;
  color: var(--ink); font-size: 14px; font-weight: 700;
}
.detail-section-title .icon { width: 18px; height: 18px; color: var(--primary); }
.detail-time-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 8px; font-size: 14px; }
.detail-photo-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; }
.detail-photo-card {
  padding: 8px; border: 1px solid var(--line); border-radius: var(--r-inner);
  background: var(--card); text-align: center;
}
.detail-photo-card img {
  display: block; width: 100%; height: 100px; margin-top: 6px;
  border-radius: 8px; object-fit: cover;
}
.detail-gps {
  display: inline-flex; align-items: center; gap: 4px; margin-top: 6px;
  color: var(--done); font-family: var(--font-mono); font-size: 12px;
}
.detail-gps .icon { width: 14px; height: 14px; }

/* ---------- UX Enhancements: Live sync badge, Interactive KPIs, Fleet filter, Mission search, Elapsed timer & Driver Night Mode ---------- */
.center-sync-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-left: 6px;
  padding: 2px 10px;
  border: 1px solid rgba(255, 255, 255, .28);
  border-radius: 999px;
  background: rgba(15, 23, 42, .28);
  color: #FFFFFF;
  font-size: 12px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  vertical-align: middle;
}
.center-sync-badge[hidden] { display: none; }
.center-sync-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #4ADE80;
  box-shadow: 0 0 0 2px rgba(74, 222, 128, .28);
}
.kpi-action {
  width: 100%;
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: transform .15s ease, box-shadow .15s ease;
}
.kpi-action:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 24px -10px rgba(15, 23, 42, .52);
}
.kpi-action:focus-visible {
  outline: 3px solid #FFFFFF;
  outline-offset: 2px;
}
.fleet-filter-row {
  margin-bottom: 12px;
}
.missions-search-field {
  flex: 1 1 240px;
  margin-bottom: 0;
}
.cockpit-selector-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.cockpit-selector-actions > .btn {
  flex: 1 1 auto;
}
.mission-elapsed-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border: 1px solid #BFDBFE;
  border-radius: 999px;
  background: var(--primary-soft);
  color: var(--primary-hover);
  font-size: 13px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.mission-elapsed-chip[hidden] { display: none; }
.mission-elapsed-chip .icon { width: 15px; height: 15px; }

/* Driver Cockpit Night Shift Mode (opt-in low-glare dark cabin palette, WCAG AA >= 7:1) */
body.is-driver-night {
  background: #0B1220;
  color: #F1F5F9;
}
body.is-driver-night .app-topbar,
body.is-driver-night .app-tabbar,
body.is-driver-night .app-sidebar {
  background: #0F172A;
  border-color: #1E293B;
  color: #F1F5F9;
}
body.is-driver-night .topbar-title,
body.is-driver-night .tabbar-link,
body.is-driver-night .sidebar-link,
body.is-driver-night .app-brand-text strong {
  color: #E2E8F0;
}
body.is-driver-night .app-footer {
  border-color: #1E293B;
  color: #94A3B8;
}
#view-driver.is-night .glass-card {
  background: #131C2E;
  border-color: #24324A;
  color: #F1F5F9;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .35);
}
#view-driver.is-night .cockpit-selector-summary,
#view-driver.is-night .driver-name,
#view-driver.is-night .shift-info dd,
#view-driver.is-night .mission-code,
#view-driver.is-night .mission-info-main,
#view-driver.is-night .mission-info-line,
#view-driver.is-night .mission-diagnosis,
#view-driver.is-night .driver-section-heading,
#view-driver.is-night .step-title {
  color: #F1F5F9;
}
#view-driver.is-night .shift-name {
  color: #FCD34D;
}
#view-driver.is-night .text-alert {
  color: #FCA5A5;
}
#view-driver.is-night .cockpit-proof-banner {
  background: #1B263B;
  border-color: #2D3F5E;
  color: #F1F5F9;
}
#view-driver.is-night .proof-title,
#view-driver.is-night .proof-link {
  color: #93C5FD;
}
#view-driver.is-night .proof-meta {
  color: #CBD5E1;
}
#view-driver.is-night .driver-meta,
#view-driver.is-night .shift-info dt,
#view-driver.is-night .mission-info-label,
#view-driver.is-night .mission-info-sub,
#view-driver.is-night .step-time,
#view-driver.is-night .cockpit-selector-field,
#view-driver.is-night .depart-vehicle-label,
#view-driver.is-night .depart-vehicle-switch {
  color: #CBD5E1;
}
/* the car the mission leaves in, readable at night (2026-11-25: it kept the day colours on the dark box) */
#view-driver.is-night .depart-vehicle-current {
  color: #F1F5F9;
}
#view-driver.is-night .shift-info,
#view-driver.is-night .mission-info,
#view-driver.is-night .mission-diagnosis,
#view-driver.is-night .depart-vehicle {
  background: #1B263B;
  border-color: #2D3F5E;
}
#view-driver.is-night .btn-outline {
  background: #1E293B;
  border-color: #334155;
  color: #F1F5F9;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .08), 0 3px 0 #0F172A;
}
/* the tinted keys keep their colour at night too (2026-11-25) */
#view-driver.is-night .btn-tint-sky {
  border-color: #0369A1;
  background: #0C4A6E;
  color: #E0F2FE;
}
#view-driver.is-night .btn-tint-slate {
  border-color: #64748B;
  background: #475569;
  color: #F8FAFC;
}
/* ออกเวร stays red at night (its own colour, 2026-11-25) */
#view-driver.is-night .btn-checkout {
  background: #3B1219;
  border-color: #7F1D1D;
  color: #FCA5A5;
}
#view-driver.is-night .form-control,
#view-driver.is-night .form-select {
  background: #0F172A;
  border-color: #334155;
  color: #F1F5F9;
}
#view-driver.is-night .mission-elapsed-chip {
  background: #1E3A8A;
  border-color: #3B82F6;
  color: #EFF6FF;
}
#view-driver.is-night .advance-row,
#view-driver.is-night .hosoffice-card {
  background: #1B263B;
  border-color: #2D3F5E;
  color: #F1F5F9;
}
#view-driver.is-night .advance-row__summary,
#view-driver.is-night .advance-row__number,
#view-driver.is-night .advance-row__place,
#view-driver.is-night .hosoffice-card__patient,
#view-driver.is-night .hosoffice-card__diagnosis,
#view-driver.is-night .hosoffice-card__place,
#view-driver.is-night .hosoffice-card__doctor,
#view-driver.is-night .hosoffice-card__nurse {
  color: #F1F5F9;
}
#view-driver.is-night .advance-row__detail,
#view-driver.is-night .hosoffice-card__detail {
  color: #CBD5E1;
}

/* ---------- print: the shell, dialogs and screen-only parts never print; the report, check and usage forms print as on paper.
   !important is allowed here (spec): no screen rule of any weight may leak onto paper ---------- */
@media print {
  .view-switcher {
    display: none !important;
  }
  .print-area {
    display: block !important;
    padding: 0 !important;
    color: #000 !important;
  }
  body:has(#modal-print-refer.active) > *:not(#modal-print-refer) {
    display: none !important;
  }
  #modal-print-refer.active {
    position: static !important;
    display: block !important;
    padding: 0 !important;
    background: #fff !important;
  }
  #modal-print-refer.active .modal-box {
    width: 100% !important;
    max-width: none !important;
    max-height: none !important;
    margin: 0 !important;
    padding: 0 !important;
    overflow: visible !important;
    border: 0 !important;
    border-radius: 0 !important;
    background: #fff !important;
    box-shadow: none !important;
  }
  #modal-print-refer.active .modal-header,
  #modal-print-refer.active .modal-footer {
    display: none !important;
  }
  body {
    background: #fff !important;
    color: #000 !important;
  }
  .btn,
  button,
  .toast-container,
  .modal-close,
  .modal-footer {
    display: none !important;
  }
  .main-content {
    padding: 0 !important;
  }
  .glass-card {
    background: #fff !important;
    border: 1px solid #ccc !important;
    box-shadow: none !important;
    color: #000 !important;
    padding: 1rem !important;
    margin-bottom: 1.5rem !important;
    page-break-inside: avoid;
  }
  .data-table {
    border-collapse: collapse;
    width: 100% !important;
    color: #000 !important;
  }
  .data-table th,
  .data-table td {
    border: 1px solid #ddd !important;
    padding: 8px 10px !important;
  }
  .data-table td {
    color: #000 !important;
  }
  .data-table th {
    background: #f3f4f6 !important;
    color: #111827 !important;
  }
  h1,
  h2,
  h3,
  h4,
  strong {
    color: #000 !important;
  }
  .triage-tag,
  .badge-ems,
  .badge-refer {
    border: 1px solid #000 !important;
    color: #000 !important;
    background: #fff !important;
  }
  #view-map {
    display: none !important;
  }
  .signin {
    display: none !important;
  }
  .type-stack,
  .type-dot {
    print-color-adjust: exact;
    -webkit-print-color-adjust: exact;
  }
  .reports-types {
    display: none;
  }
  .reports-bar span {
    print-color-adjust: exact;
    -webkit-print-color-adjust: exact;
  }
  .check-tools,
  #view-reports [data-check-detail] {
    display: none !important;
  }
  .reports-head,
  .reports-toolbar,
  .reports-note,
  .reports-log-head,
  #view-reports [data-report-action] {
    display: none !important;
  }
  .reports-print-head {
    display: block;
    margin-bottom: 8px;
    font-size: 16px;
    font-weight: 700;
  }
  .reports-sign {
    display: block;
    margin-top: 28px;
    text-align: right;
    break-inside: avoid;
  }
  .reports-sign p {
    margin: 0 0 6px;
  }
  .reports-sign.reports-sign-pair {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
    text-align: center;
  }
  #view-reports .table-wrap {
    overflow: visible;
    border: 0;
  }
  /* สมุดบันทึกการใช้รถ / พลขับ on paper at one standard size (user 2026-11-27 "พิมพ์บางคันเล็กบางคันใหญ่"): one-line cells
     made a long place name widen the table past A4 and Chrome shrank that car's page; fixed columns, wrapped text, 12px */
  .reports-log-table {
    width: 100%;
    table-layout: fixed;
    font-size: 12px;
  }
  .reports-log-table th,
  .reports-log-table td {
    padding: 4px 5px;
    font-size: 12px;
    white-space: normal;
    overflow-wrap: anywhere;
    vertical-align: top;
  }
  /* the total once, under the last trip, not at the foot of every page (user 2026-11-27 "หน้าแรกไม่ต้องมีสรุป") */
  .reports-log-table tfoot {
    display: table-row-group;
  }
  /* หมายเหตุ wide enough for its longest warning on one line at 10px (user 2026-11-27 "ย่อให้เป็นตัวเล็กได้ให้เหลือบรรทัดเดียว") */
  .reports-log-table thead th:nth-child(1) { width: 3.8%; }
  .reports-log-table thead th:nth-child(2) { width: 5%; }
  .reports-log-table thead th:nth-child(3) { width: 11.2%; }
  .reports-log-table thead th:nth-child(4) { width: 6.3%; }
  .reports-log-table thead th:nth-child(5) { width: 7.3%; }
  .reports-log-table thead th:nth-child(6) { width: 14.9%; }
  .reports-log-table thead th:nth-child(7) { width: 11%; }
  .reports-log-table thead th:nth-child(8) { width: 9.2%; }
  .reports-log-table thead th:nth-child(9) { width: 6%; }
  .reports-log-table thead th:nth-child(10) { width: 6%; }
  .reports-log-table thead th:nth-child(11) { width: 3.8%; }
  .reports-log-table thead th:nth-child(12) { width: 15.5%; }
  /* the driver's log (user 2026-11-27 "ปรับฟอร์มพลขับด้วย"): the car with its plate on one line, หมายเหตุ as the car log's */
  .reports-driver-table thead th:nth-child(6) { width: 22.2%; }
  .reports-driver-table thead th:nth-child(7) { width: 15.8%; }
  .reports-driver-table thead th:nth-child(9) { width: 3.8%; }
  .reports-driver-table thead th:nth-child(10) { width: 15.4%; }
  /* สรุปจำนวนเที่ยว: the heading stays with its table on one page */
  .reports-driver-summary {
    break-inside: avoid;
  }
  .reports-log-table .reports-flag {
    font-size: 10px;
    white-space: nowrap;
  }
  .reports-usage th[scope="row"],
  .reports-usage thead th:first-child {
    position: static;
  }
  .reports-car,
  .reports-cell {
    min-height: 0;
    padding: 0;
  }
  .app-sidebar,
  .app-topbar,
  .app-tabbar,
  .nav-sheet,
  .nav-sheet-backdrop,
  .archive-pager {
    display: none;
  }
  #app-main-layout > .main-content,
  #app-main-layout > .app-footer {
    margin-left: 0;
  }
  .reports-summary,
  .reports-rank-section,
  .reports-full > summary {
    display: none !important;
  }
  .reports-full::details-content {
    content-visibility: visible !important;
    display: block !important;
  }
  /* One font (Sarabun) at the size that fits the 18-column form (user, 2026-11-17: 16pt overflowed, "ใช้ขนาดพอดี" → 12pt; then "ใช้ตัว 8 pt ทั้งหมด" → 8pt everywhere); bold only for the title, the two labels and the column heads */
  body.print-check-form {
    background: #fff !important;
  }
  body.print-check-form > *:not(#check-form-print) {
    display: none !important;
  }
  body.print-check-form::before,
  body.print-check-form::after {
    display: none !important;
  }
  body.print-check-form #check-form-print {
    display: block !important;
    color: #000;
    font-family: 'Sarabun', sans-serif;
    font-size: 8pt;
    font-weight: 400;
    line-height: 1.25;
  }
  #check-form-print * {
    font-family: 'Sarabun', sans-serif;
    font-size: 8pt;
    font-weight: 400;
    color: #000;
  }
  #check-form-print .check-form-title,
  #check-form-print .check-form-label,
  #check-form-print th,
  #check-form-print th span {
    font-weight: 700;
  }
  /* The three lines above the table 10pt (user, 2026-11-17), the table 8pt */
  #check-form-print .check-form-title,
  #check-form-print .check-form-meta,
  #check-form-print .check-form-meta * {
    font-size: 10pt;
  }
  /* Breathing room (user, 2026-11-17): heading lines apart, cell text clear of the lines above and below */
  .check-form-title {
    margin: 0 0 4pt;
  }
  .check-form-meta {
    margin: 0 0 3pt;
  }
  .check-form-label {
    margin-right: 8pt;
  }
  .check-form-dots {
    display: inline-block;
    width: 60mm;
    border-bottom: 1px dotted #000;
  }
  .check-form-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 6pt;
    table-layout: fixed;
  }
  .check-form-table thead {
    display: table-header-group;
  }
  .check-form-table tr {
    break-inside: avoid;
  }
  .check-form-table th,
  .check-form-table td {
    border: 0.6pt solid #000;
    padding: 3pt 4pt;
    vertical-align: middle;
    line-height: 1.4;
  }
  .check-form-table th {
    text-align: center;
  }
  .check-form-table th.check-form-date {
    width: 39mm;
  }
  .check-form-table th.check-form-mile {
    width: 21mm;
  }
  .check-form-table th.check-form-point {
    width: 7.4mm;
    padding: 3pt 0;
  }
  /* line-height 1.6: room for Thai marks above and below, which spilled into the next column at 1 */
  .check-form-table th.check-form-point span {
    writing-mode: vertical-rl;
    transform: rotate(180deg);
    white-space: nowrap;
    display: inline-block;
    line-height: 1.6;
  }
  .check-form-table th.check-form-name {
    width: 25mm;
  }
  .check-form-table td.check-form-date,
  .check-form-table td.check-form-mile,
  .check-form-table td.check-form-name {
    white-space: nowrap;
    overflow: hidden;
  }
  /* Sarabun's digits are all one width, so mileages line up (Kanit's "1" was narrow) */
  .check-form-table td.check-form-mile {
    text-align: right;
    font-variant-numeric: tabular-nums;
  }
  .check-form-table td.check-form-mark {
    text-align: center;
    padding: 3pt 0;
  }
  .check-form-table td.check-form-note {
    word-break: break-word;
  }
  /* สมุดบันทึกการใช้รถ (2026-11-17): the hand-written book's columns; สถานที่ไป takes what is left */
  .usage-form-month {
    margin-left: 18pt;
  }
  .usage-form-table th {
    vertical-align: middle;
  }
  /* table-layout: fixed takes widths from the first head row, which has joined cells, so the widths sit on <col> */
  .usage-form-table .usage-col-num {
    width: 9mm;
  }
  .usage-form-table .usage-col-date {
    width: 12mm;
  }
  .usage-form-table .usage-col-time {
    width: 11mm;
  }
  .usage-form-table .usage-col-user {
    width: 30mm;
  }
  .usage-form-table .usage-col-mile {
    width: 21mm;
  }
  .usage-form-table .usage-col-km {
    width: 14mm;
  }
  .usage-form-table .usage-col-name {
    width: 20mm;
  }
  .usage-form-table .usage-col-fuel {
    width: 13mm;
  }
  .usage-form-table td.usage-form-num,
  .usage-form-table td.usage-form-date,
  .usage-form-table td.usage-form-time {
    text-align: center;
    white-space: nowrap;
  }
  .usage-form-table td.usage-form-mile,
  .usage-form-table td.usage-form-km,
  .usage-form-table td.usage-form-fuel {
    text-align: right;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
  }
  .usage-form-table td.usage-form-name {
    white-space: nowrap;
    overflow: hidden;
  }
  .usage-form-table td.usage-form-user,
  .usage-form-table td.usage-form-place {
    word-break: break-word;
  }
  /* The total once, under the last trip (a footer group repeats at the foot of every printed page) */
  .usage-form-table tfoot {
    display: table-row-group;
  }
  .usage-form-table tfoot th {
    text-align: right;
  }
  .usage-form-table tfoot td,
  .usage-form-table tfoot th {
    white-space: nowrap;
  }
  #check-form-print .usage-form-note {
    margin: 4pt 0 0;
  }
  .dash-trend-top {
    background: #FFFFFF;
    color: #000000;
    box-shadow: none;
  }
  .dash-trend-top :is(.panel-title, .panel-sub, .dash-trend-stat span, .dash-trend-stat b) {
    color: #000000;
  }
  .dash-trend-stat {
    background: #FFFFFF;
    border-color: #94A3B8;
  }
  .dash-trend-top .kpi-watermark {
    display: none;
  }
  .dash-fuelprice-top {
    background: #FFFFFF;
    color: #000000;
    box-shadow: none;
  }
  .dash-fuelprice-top :is(.panel-title, .panel-sub, .dash-fuelprice-name, .dash-fuelprice-price, .dash-fuelprice-price small, .dash-fuelprice-change) {
    color: #000000;
  }
  .dash-fuelprice-top .kpi-watermark {
    display: none;
  }
  .dash-kpi[class*="kpi-tone-"] {
    background: #FFFFFF;
    color: #000000;
    box-shadow: none;
    border: 1px solid #94A3B8;
  }
  .dash-kpi[class*="kpi-tone-"] :is(.kpi-label, .kpi-value, .kpi-value small, .kpi-sub) {
    color: #000000;
    text-shadow: none;
  }
  .dash-kpi[class*="kpi-tone-"] .kpi-watermark {
    display: none;
  }
}
@media print, (prefers-reduced-motion: reduce) {
  #view-dashboard .dash-grid > *,
  #view-dashboard .dash-kpi,
  #view-dashboard .dash-fuelmonthly,
  #view-dashboard #dash-chart-types,
  #view-dashboard .dash-welcome-art,
  #view-dashboard .dash-scene-layer,
  #view-dashboard .dash-ambulance-body,
  #view-dashboard .dash-road-streak,
  #view-dashboard .dash-driver,
  #view-dashboard .dash-driver-bar > span {
    animation: none !important;
    transform: none !important;
    opacity: 1 !important;
  }
  #view-dashboard .dash-siren-glow {
    animation: none !important;
    opacity: 0 !important;
  }
  #view-dashboard .dash-kpi-glare {
    display: none !important;
  }
  #view-dashboard .kpi-icon,
  #view-dashboard .dash-filters button,
  #view-dashboard .dash-grid > *,
  #view-dashboard .dash-fuelmonthly,
  #view-dashboard .dash-scene-layer {
    transition: none !important;
  }
}
