/* AeroAssist design system — dnata (Emirates Group) edition.
   Brand: dnata blue with the green tick as secondary accent.
   Light and dark themes share one token set; component rules read the
   tokens only, so nothing below needs a [data-theme] selector of its own. */

:root {
  /* ---- base surfaces & text (light values; dark overrides further down) ---- */
  --bg: #f5f7fb;
  --panel: #ffffff;
  --panel-2: #eef1f7;
  --panel-3: #e3e8f1;
  --border: #dde3ee;
  --border-strong: #c7cfde;
  --text: #10182b;
  --muted: #5b6478;

  /* ---- brand ---- */
  --accent: #0f7dc4;        /* dnata blue — solid fills (buttons, active states) */
  --accent-2: #0a6aa8;      /* darker blue for links/text on light backgrounds */
  --accent-soft: #e5f2fb;   /* tinted accent background, light */
  --brand-green: #6fa42e;   /* dnata tick, tuned for light backgrounds */
  --gold: #a8823f;          /* Emirates gold, tuned for light backgrounds */
  --focus-ring: rgba(15, 125, 196, .22);

  /* ---- semantic (status) tokens: bg / fg / border per state ---- */
  --success-bg: #e7f8ee; --success-fg: #146c38; --success-border: #b8e6c9;
  --warning-bg: #fff6e0; --warning-fg: #8a5a06; --warning-border: #f3dda0;
  --danger-bg: #fdeceb;  --danger-fg: #b42318;  --danger-border: #f6bfba;
  --info-bg: #e8f4fc;    --info-fg: #0a6aa8;    --info-border: #bfe1f5;
  --violet-bg: #f1edfc;  --violet-fg: #5b3aa8;  --violet-border: #d9cdf7;

  /* solid indicator colors (dots, pulses) — same hue family as the tokens above */
  --green: #1a9850;
  --amber: #b9790a;
  --red: #d33a30;
  --purple: #7c5ad1;

  --radius: 14px;
  --radius-sm: 9px;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .07);
  --shadow-md: 0 4px 12px rgba(16, 24, 40, .08), 0 2px 4px rgba(16, 24, 40, .06);
  --shadow-lg: 0 16px 40px rgba(16, 24, 40, .14), 0 4px 10px rgba(16, 24, 40, .06);
}

/* ---- dark values: applied when the OS prefers dark AND the user hasn't
       explicitly chosen a theme this session (data-theme attribute wins, see below) ---- */
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0c1220;
    --panel: #151e2e;
    --panel-2: #1c2839;
    --panel-3: #24324a;
    --border: #2b3a52;
    --border-strong: #3d4f6b;
    --text: #eef2f8;
    --muted: #93a3bb;

    --accent: #1f8ad6;
    --accent-2: #4fc0f0;
    --accent-soft: #10273a;
    --brand-green: #8cc63f;
    --gold: #c9a96a;
    --focus-ring: rgba(79, 192, 240, .28);

    --success-bg: #0e2e1c; --success-fg: #86efac; --success-border: #1c5233;
    --warning-bg: #2a1a04; --warning-fg: #fcd34d; --warning-border: #5c3d0c;
    --danger-bg: #2a0707;  --danger-fg: #fca5a5;  --danger-border: #7f1d1d;
    --info-bg: #0a2334;    --info-fg: #9bd7f5;    --info-border: #14496b;
    --violet-bg: #1c1033;  --violet-fg: #c4b5fd;  --violet-border: #4c1d95;

    --green: #22c55e;
    --amber: #f59e0b;
    --red: #ef4444;
    --purple: #a78bfa;

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .3);
    --shadow-md: 0 6px 16px rgba(0, 0, 0, .35);
    --shadow-lg: 0 20px 48px rgba(0, 0, 0, .5);
  }
}

/* ---- explicit user choice always wins over the OS preference, in both
       directions. A tiny inline script in each HTML file sets this
       attribute before first paint so there is no flash of the wrong theme. ---- */
:root[data-theme="dark"] {
  --bg: #0c1220; --panel: #151e2e; --panel-2: #1c2839; --panel-3: #24324a;
  --border: #2b3a52; --border-strong: #3d4f6b; --text: #eef2f8; --muted: #93a3bb;
  --accent: #1f8ad6; --accent-2: #4fc0f0; --accent-soft: #10273a;
  --brand-green: #8cc63f; --gold: #c9a96a; --focus-ring: rgba(79, 192, 240, .28);
  --success-bg: #0e2e1c; --success-fg: #86efac; --success-border: #1c5233;
  --warning-bg: #2a1a04; --warning-fg: #fcd34d; --warning-border: #5c3d0c;
  --danger-bg: #2a0707;  --danger-fg: #fca5a5;  --danger-border: #7f1d1d;
  --info-bg: #0a2334;    --info-fg: #9bd7f5;    --info-border: #14496b;
  --violet-bg: #1c1033;  --violet-fg: #c4b5fd;  --violet-border: #4c1d95;
  --green: #22c55e; --amber: #f59e0b; --red: #ef4444; --purple: #a78bfa;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .3);
  --shadow-md: 0 6px 16px rgba(0, 0, 0, .35);
  --shadow-lg: 0 20px 48px rgba(0, 0, 0, .5);
}
:root[data-theme="light"] {
  --bg: #f5f7fb; --panel: #ffffff; --panel-2: #eef1f7; --panel-3: #e3e8f1;
  --border: #dde3ee; --border-strong: #c7cfde; --text: #10182b; --muted: #5b6478;
  --accent: #0f7dc4; --accent-2: #0a6aa8; --accent-soft: #e5f2fb;
  --brand-green: #6fa42e; --gold: #a8823f; --focus-ring: rgba(15, 125, 196, .22);
  --success-bg: #e7f8ee; --success-fg: #146c38; --success-border: #b8e6c9;
  --warning-bg: #fff6e0; --warning-fg: #8a5a06; --warning-border: #f3dda0;
  --danger-bg: #fdeceb;  --danger-fg: #b42318;  --danger-border: #f6bfba;
  --info-bg: #e8f4fc;    --info-fg: #0a6aa8;    --info-border: #bfe1f5;
  --violet-bg: #f1edfc;  --violet-fg: #5b3aa8;  --violet-border: #d9cdf7;
  --green: #1a9850; --amber: #b9790a; --red: #d33a30; --purple: #7c5ad1;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .07);
  --shadow-md: 0 4px 12px rgba(16, 24, 40, .08), 0 2px 4px rgba(16, 24, 40, .06);
  --shadow-lg: 0 16px 40px rgba(16, 24, 40, .14), 0 4px 10px rgba(16, 24, 40, .06);
}

/* ---------------------------------------------------------------------- */

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { color-scheme: light dark; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, sans-serif;
  min-height: 100vh;
  transition: background-color .18s ease, color .18s ease;
}
h1, h2, h3 { margin: 0 0 .5em; font-weight: 700; letter-spacing: -.01em; text-wrap: balance; }
h1 { letter-spacing: -.02em; }
a { color: var(--accent-2); text-decoration: none; }
a:hover { text-decoration: underline; }

button {
  font: inherit; color: var(--text); background: var(--panel-2);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 9px 16px; cursor: pointer;
  transition: filter .18s ease, transform .12s cubic-bezier(.2, .8, .3, 1),
    background-color .18s ease, border-color .18s ease, box-shadow .18s ease;
}
button:hover { background: var(--panel-3); }
button:active { transform: scale(.97); }
button.primary {
  background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600;
  box-shadow: 0 3px 10px color-mix(in srgb, var(--accent) 35%, transparent);
}
button.primary:hover { background: var(--accent); filter: brightness(1.08); }
button.danger { background: transparent; border-color: var(--danger-border); color: var(--danger-fg); }
button.danger:hover { background: var(--danger-bg); }
button.big {
  width: 100%; padding: 18px; font-size: 18px; font-weight: 700;
  border-radius: 14px; background: var(--accent); border-color: var(--accent); color: #fff;
  box-shadow: 0 6px 18px color-mix(in srgb, var(--accent) 38%, transparent);
}
button.big:active { transform: scale(.98); }
button.big.green { background: var(--success-fg); border-color: var(--success-fg);
  box-shadow: 0 6px 18px color-mix(in srgb, var(--success-fg) 38%, transparent); }
button:disabled { opacity: .5; cursor: not-allowed; filter: none; transform: none; box-shadow: none; }
button:focus-visible, .icon-btn:focus-visible {
  outline: none; box-shadow: 0 0 0 3px var(--focus-ring);
}

.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 34px; height: 34px; padding: 0; border-radius: 999px;
  background: var(--panel-2); border: 1px solid var(--border); color: var(--muted);
  transition: background-color .18s ease, border-color .18s ease, color .18s ease,
    transform .12s cubic-bezier(.2, .8, .3, 1);
}
.icon-btn:hover { color: var(--text); filter: none; background: var(--panel-3); }
.icon-btn:active { transform: scale(.92); }

input, select, textarea {
  font: inherit; color: var(--text); background: var(--panel-2);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 9px 12px; width: 100%;
  transition: border-color .18s ease, box-shadow .18s ease, background-color .18s ease;
}
input::placeholder, textarea::placeholder { color: var(--muted); opacity: .8; }
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--focus-ring);
}
label {
  display: block; font-size: 12px; color: var(--muted); margin: 12px 0 5px;
  font-weight: 650; text-transform: uppercase; letter-spacing: .05em;
}

.card {
  background: var(--panel); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow-sm);
  transition: background-color .2s ease, border-color .2s ease, box-shadow .2s ease;
}
.badge {
  display: inline-block; font-size: 11.5px; font-weight: 700;
  padding: 3px 10px; border-radius: 999px; letter-spacing: .02em;
  background: var(--panel-2); border: 1px solid var(--border); color: var(--muted);
  transition: background-color .2s ease, border-color .2s ease, color .2s ease;
}
.badge.green  { color: var(--success-fg); border-color: var(--success-border); background: var(--success-bg); }
.badge.amber  { color: var(--warning-fg); border-color: var(--warning-border); background: var(--warning-bg); }
.badge.red    { color: var(--danger-fg);  border-color: var(--danger-border);  background: var(--danger-bg); }
.badge.blue   { color: var(--info-fg);    border-color: var(--info-border);    background: var(--info-bg); }
.badge.purple { color: var(--violet-fg);  border-color: var(--violet-border);  background: var(--violet-bg); }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.spread { justify-content: space-between; }
.grow { flex: 1; }
.mt { margin-top: 14px; }

/* top bar */
.topbar {
  display: flex; align-items: center; gap: 16px;
  padding: 12px 20px;
  border-bottom: 1px solid var(--border);
  border-top: 3px solid var(--accent);
  border-image: linear-gradient(90deg, var(--accent) 70%, var(--brand-green)) 1;
  position: sticky; top: 0; z-index: 20;
  box-shadow: var(--shadow-sm);
}
/* The frosted-glass fill lives on a pseudo-element rather than directly on
   .topbar: a `backdrop-filter` on an element makes it a "containing block"
   for any `position: fixed` descendant — and the phone bottom nav (#tabs)
   is a child of .topbar, so putting it there fixed #tabs to the topbar's
   own box instead of the viewport. The pseudo-element sidesteps that. */
.topbar::before {
  content: ''; position: absolute; inset: 0; z-index: -1;
  background: color-mix(in srgb, var(--panel) 86%, transparent);
  backdrop-filter: blur(16px) saturate(1.5); -webkit-backdrop-filter: blur(16px) saturate(1.5);
  transition: background-color .2s ease;
}
.logo { font-weight: 800; font-size: 17px; letter-spacing: -.01em; display: flex; align-items: center; gap: 10px; }
.logo span { color: var(--accent-2); }
.brand-logo { height: 30px; display: block; }
.brand-logo-lg { height: 46px; display: block; margin: 0 auto 6px; }

.tabs {
  display: flex; gap: 2px; flex: 1; flex-wrap: wrap;
  background: var(--panel-2); border: 1px solid var(--border);
  border-radius: 11px; padding: 3px;
}
.tabs button {
  border: none; background: transparent; color: var(--muted);
  padding: 7px 13px; border-radius: 8px; font-size: 13.5px; font-weight: 550;
  box-shadow: none;
}
.tabs button.active { background: var(--panel); color: var(--text); font-weight: 650; box-shadow: var(--shadow-sm); }

.page { padding: 20px; max-width: 1500px; margin: 0 auto; }

/* board */
.board { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 14px; align-items: start; }
.col h3 { font-size: 12.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 700; display: flex; justify-content: space-between; }
.col .cards { display: flex; flex-direction: column; gap: 10px; }
.task-card {
  cursor: pointer;
  transition: border-color .18s ease, box-shadow .18s ease, transform .18s cubic-bezier(.2, .8, .3, 1);
  animation: card-in .32s cubic-bezier(.2, .8, .3, 1) both;
}
.task-card:hover { border-color: var(--accent); box-shadow: var(--shadow-md); transform: translateY(-2px); }
.task-card:active { transform: scale(.98); }
.task-card .route { font-weight: 700; font-size: 15px; margin: 6px 0 4px; }
.task-card .route em { color: var(--accent-2); font-style: normal; }

/* Cards "materialize" into place on render — the first several stagger in,
   the rest (if any) settle at the same modest delay so a long list never
   feels sluggish to finish appearing. */
@keyframes card-in { from { opacity: 0; transform: translateY(10px) scale(.98); } }
.col .cards > .task-card:nth-child(1) { animation-delay: 0ms; }
.col .cards > .task-card:nth-child(2) { animation-delay: 25ms; }
.col .cards > .task-card:nth-child(3) { animation-delay: 50ms; }
.col .cards > .task-card:nth-child(4) { animation-delay: 75ms; }
.col .cards > .task-card:nth-child(5) { animation-delay: 100ms; }
.col .cards > .task-card:nth-child(n+6) { animation-delay: 120ms; }

/* Every tab/view switch swaps in fresh DOM, so a plain entrance animation
   on the page's/agent app's top-level content plays automatically on
   every navigation — the "smoothness" that was missing before. */
@keyframes view-in { from { opacity: 0; transform: translateY(8px); } }
.page > *, .agent-page > * { animation: view-in .28s cubic-bezier(.2, .8, .3, 1) both; }
/* A `transform` animation on an element makes it a containing block for any
   `position: fixed` descendant *while the animation runs* — and the agent
   app's primary action button (#nextBtn) is fixed and nested inside this
   card, so the translateY entrance briefly yanked it away from the
   viewport bottom. Give that one card an opacity-only fade instead. */
@keyframes fade-in-only { from { opacity: 0; } }
.agent-page > *:has(#nextBtn) { animation: fade-in-only .28s ease both; }
@media (prefers-reduced-motion: reduce) {
  .task-card, .page > *, .agent-page > * { animation: none; }
}

/* ---------- task status colours ----------
   Each stage fills the card with one solid, opaque colour that progresses
   grey → blue → purple → teal → green as the task advances, so a card's colour
   alone tells you how far along it is. Completed = green, cancelled = red.
   Colours are dark enough that white text stays readable; inner chips flip to
   solid white so nothing is faint or see-through. */
.st-CREATED             { --stc: #5b6675; }  /* unassigned — slate */
.st-ASSIGNED            { --stc: #2563eb; }  /* blue */
.st-ACCEPTED            { --stc: #3f51d4; }  /* indigo */
.st-EN_ROUTE_TO_STORAGE { --stc: #6d28d9; }  /* violet */
.st-WHEELCHAIR_COLLECTED{ --stc: #8324c9; }  /* purple */
.st-ARRIVED_AT_PICKUP   { --stc: #b8620a; }  /* amber-brown */
.st-PASSENGER_PICKED_UP { --stc: #0f766e; }  /* teal */
.st-IN_TRANSIT          { --stc: #0e7490; }  /* cyan */
.st-PASSENGER_DELIVERED { --stc: #15803d; }  /* green-teal */
.st-COMPLETED           { --stc: #16a34a; }  /* clear green */
.st-CANCELLED           { --stc: #b91c1c; }  /* red */

.task-card[class*="st-"] {
  background: var(--stc);
  border-color: rgba(0, 0, 0, .18);
  color: #ffffff;
}
.task-card[class*="st-"]:hover { border-color: #ffffff; }
.task-card[class*="st-"] .route,
.task-card[class*="st-"] .route em,
.task-card[class*="st-"] .pname,
.task-card[class*="st-"] .pax,
.task-card[class*="st-"] b { color: #ffffff; }
.task-card[class*="st-"] .muted,
.task-card[class*="st-"] .small { color: #eef3fb; }
.task-card[class*="st-"] .stage-chip { color: #ffffff; }
/* inner chips → solid white with the status colour as text (no transparency) */
.task-card[class*="st-"] .badge {
  background: #ffffff; color: var(--stc); border-color: #ffffff;
}
.task-card[class*="st-"] .badge.red    { color: #b91c1c; }
.task-card[class*="st-"] .badge.amber  { color: #b45309; }
.task-card[class*="st-"] .badge.green  { color: #15803d; }
.task-card[class*="st-"] .badge.blue   { color: #1d4ed8; }
.task-card[class*="st-"] .badge.purple { color: #7c3aed; }
.task-card[class*="st-"] .sla-pill          { background: #ffffff; }
.task-card[class*="st-"] .sla-pill.green    { color: #15803d; }
.task-card[class*="st-"] .sla-pill.amber    { color: #b45309; }
.task-card[class*="st-"] .sla-pill.red      { color: #b91c1c; }
/* the mini progress stepper on a coloured card */
.task-card[class*="st-"] .stepper .step { background: rgba(255, 255, 255, .35); }
.task-card[class*="st-"] .stepper .step.done { background: #ffffff; }
.task-card[class*="st-"] .stepper .step.current { background: #ffffff; }
/* solid colour status banner (agent task detail) — turns green on completion */
.status-banner {
  display: inline-block; background: var(--stc, var(--accent)); color: #ffffff;
  font-weight: 700; padding: 6px 16px; border-radius: 999px; font-size: 14px;
  margin: 8px 0 2px;
}
/* a solid colour key so the palette is legible at a glance */
.status-legend { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
.status-legend .lg { display: inline-flex; align-items: center; gap: 6px; font-size: 11.5px; color: var(--muted); }
.status-legend .sw { width: 14px; height: 14px; border-radius: 4px; display: inline-block; }

.sla-pill {
  font-variant-numeric: tabular-nums; font-weight: 700; font-size: 12px;
  padding: 3px 10px; border-radius: 999px;
}
.sla-pill.green { background: var(--success-bg); color: var(--success-fg); }
.sla-pill.amber { background: var(--warning-bg); color: var(--warning-fg); }
.sla-pill.red   { background: var(--danger-bg);  color: var(--danger-fg); animation: pulse 1.2s infinite; }
@keyframes pulse { 50% { opacity: .55; } }
@media (prefers-reduced-motion: reduce) {
  .sla-pill.red, .stepper .step.current { animation: none; }
}

/* modal */
.modal-back {
  position: fixed; inset: 0; background: rgba(10, 14, 24, .55);
  backdrop-filter: blur(2px);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 4vh 16px; z-index: 50; overflow: auto;
  animation: fade-in .15s ease;
}
.modal {
  background: var(--panel); border: 1px solid var(--border);
  border-radius: 18px; padding: 22px; width: 860px; max-width: 100%;
  box-shadow: var(--shadow-lg);
  animation: modal-in .18s cubic-bezier(.2, .8, .3, 1);
}
@keyframes fade-in { from { opacity: 0; } }
@keyframes modal-in { from { opacity: 0; transform: translateY(6px) scale(.985); } }
@media (prefers-reduced-motion: reduce) {
  .modal-back, .modal { animation: none; }
}

/* timeline */
.timeline { border-inline-start: 2px solid var(--border); margin: 8px 0; margin-inline-start: 8px; padding-inline-start: 18px; }
.timeline .ev { position: relative; padding: 6px 0; }
.timeline .ev::before {
  content: ''; position: absolute; inset-inline-start: -24px; top: 13px;
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--accent); border: 2px solid var(--panel);
}
.timeline .ev.problem::before { background: var(--red); }

/* tables */
table { width: 100%; border-collapse: collapse; }
th, td { text-align: start; padding: 10px 12px; border-bottom: 1px solid var(--border); font-size: 14px; }
th { color: var(--muted); font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em; font-weight: 700; background: var(--panel-2); }
tr:hover td { background: var(--panel-2); }

/* stat cards */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 14px; }
.stat .v { font-size: 30px; font-weight: 800; margin-top: 4px; font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.stat .k { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .05em; font-weight: 650; }

/* map — a deliberately dark "ops radar" canvas, independent of the app theme
   (same convention as flight-tracking / ride-hailing live maps) */
.map-wrap { background: #0b1120; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow-sm); }
.map-wrap svg { display: block; width: 100%; height: auto; }

/* login */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.login-card { width: 380px; max-width: 100%; box-shadow: var(--shadow-lg); }

/* toast */
#toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: var(--panel); border: 1px solid var(--border);
  padding: 12px 22px; border-radius: 12px; box-shadow: var(--shadow-lg);
  z-index: 100; display: none; font-weight: 600;
  animation: toast-in .18s cubic-bezier(.2, .8, .3, 1);
}
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 8px); } }
@media (prefers-reduced-motion: reduce) { #toast { animation: none; } }
#toast.err { border-color: var(--danger-border); color: var(--danger-fg); }

/* agent app (mobile-first) */
.agent-page { max-width: 520px; margin: 0 auto; padding: 16px; padding-bottom: 90px; }
.agent-task-card { margin-bottom: 12px; }
.stage-chip {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; font-weight: 700; color: var(--accent-2);
}
.big-timer { font-size: 42px; font-weight: 800; font-variant-numeric: tabular-nums; letter-spacing: -.02em; text-align: center; margin: 8px 0; }
.info-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 10px; }
.info-grid .cell { background: var(--panel-2); border-radius: 10px; padding: 10px 12px; }
.info-grid .cell .k { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; font-weight: 650; }
.info-grid .cell .v { font-weight: 700; margin-top: 2px; }
.stepper { display: flex; gap: 4px; margin: 14px 0 6px; }
.stepper .step { flex: 1; height: 5px; border-radius: 3px; background: var(--panel-2); transition: background-color .2s ease; }
.stepper .step.done { background: var(--success-fg); }
.stepper .step.current { background: var(--accent); animation: pulse 1.4s infinite; }
.offline-banner {
  background: var(--warning-bg); color: var(--warning-fg); text-align: center;
  padding: 7px; font-size: 13px; font-weight: 600; border-radius: 9px; margin-bottom: 12px;
  border: 1px solid var(--warning-border);
}

/* ===========================================================================
   Admin dashboard — responsive layout for phone and tablet.
   Desktop (>1080px) is untouched by design: everything below is scoped to
   narrower viewports so the existing desktop look never changes.
   Tab icons are declared as a custom property so they cost nothing on
   desktop (no ::before content there) and only render inside the phone
   bottom-nav / tablet top-nav rules further down.
   =========================================================================== */
#tabs button[data-tab="board"]      { --icon: "🗂️"; }
#tabs button[data-tab="map"]        { --icon: "🗺️"; }
#tabs button[data-tab="flights"]    { --icon: "✈️"; }
#tabs button[data-tab="wheelchairs"]{ --icon: "♿"; }
#tabs button[data-tab="locations"]  { --icon: "📍"; }
#tabs button[data-tab="templates"]  { --icon: "⏱️"; }
#tabs button[data-tab="reports"]    { --icon: "📊"; }
#tabs button[data-tab="team"]       { --icon: "👥"; }
#tabs button[data-tab="audit"]      { --icon: "🧾"; }
/* "＋ New task" already carries its own plus glyph in the label — no separate icon */

/* Any table dropped straight into a card (flights, wheelchairs, locations,
   templates, reports, staff, audit…) scrolls horizontally inside its own
   card instead of blowing out the page width on a narrow screen. A no-op on
   desktop, where cards are already wider than the tables they hold. */
.card:has(table) { overflow-x: auto; -webkit-overflow-scrolling: touch; }

/* ---------------------------------------------------------------------
   Tablet (721px–1080px): roomier touch targets, a steadier 2-column board
   and a centered, tablet-sized modal — top tab bar stays put, just bigger.
   --------------------------------------------------------------------- */
@media (min-width: 721px) and (max-width: 1080px) {
  .page { max-width: 980px; padding: 20px 26px; }
  .board { grid-template-columns: repeat(2, 1fr); }

  /* The logo + account/theme/lang/logout controls keep row 1; the tab list
     drops to its own full-width row 2 instead of being squeezed into a
     sliver of leftover space (which wrapped it into a single narrow,
     tall column at tablet widths). */
  .topbar { flex-wrap: wrap; row-gap: 10px; }
  #tabs { order: 3; flex: 1 1 100%; width: 100%; }
  .tabs button { padding: 10px 16px; font-size: 14px; }
  #tabs button::before { content: var(--icon, ""); margin-inline-end: 6px; }
  .icon-btn { width: 40px; height: 40px; }
  .modal { width: 660px; }
  input, select, textarea, button { min-height: 42px; }
}

/* ---------------------------------------------------------------------
   Phone (≤720px): native-app shell — icon bottom-nav bar (tabs move out of
   the top bar), full-width single-column board, sheet-style modals that
   slide up from the bottom, and larger touch targets throughout.
   --------------------------------------------------------------------- */
@media (max-width: 720px) {
  html { -webkit-text-size-adjust: 100%; }

  /* Compact top bar: brand mark + condensed icon actions only — the tab
     list below becomes the bottom navigation bar instead. */
  .topbar {
    gap: 8px; padding: 10px 12px calc(10px + env(safe-area-inset-top)) 12px;
    padding-top: max(10px, env(safe-area-inset-top));
  }
  .logo span { display: none; }
  .brand-logo { height: 24px; }
  #whoami { display: none; }
  .icon-btn {
    width: 38px; height: 38px; padding: 0;
    display: inline-flex; align-items: center; justify-content: center; border-radius: 999px;
  }
  #logout {
    width: 38px; height: 38px; font-size: 0; padding: 0;
    display: inline-flex; align-items: center; justify-content: center; border-radius: 999px;
  }
  #logout::before { content: "⏻"; font-size: 16px; }
  #langHost button {
    font-size: 0; width: 38px; height: 38px; padding: 0; border-radius: 999px;
    display: inline-flex; align-items: center; justify-content: center;
  }
  #langHost button::before { content: "🌐"; font-size: 15px; }

  /* Tabs leave the top bar entirely and become a fixed bottom navigation
     bar, icon-over-label, horizontally scrollable if it can't all fit —
     the same shape as a native app's tab bar. */
  #tabs {
    position: fixed; inset-inline: 0; bottom: 0; top: auto; z-index: 30;
    display: flex; flex-wrap: nowrap; overflow-x: auto;
    scrollbar-width: none; scroll-snap-type: x proximity;
    background: color-mix(in srgb, var(--panel) 88%, transparent);
    backdrop-filter: blur(16px) saturate(1.5); -webkit-backdrop-filter: blur(16px) saturate(1.5);
    border: none; border-top: 1px solid var(--border);
    border-radius: 0; padding: 4px 4px calc(4px + env(safe-area-inset-bottom)) 4px;
    box-shadow: 0 -6px 16px rgba(0, 0, 0, .12);
  }
  #tabs::-webkit-scrollbar { display: none; }
  #tabs button {
    flex: 0 0 auto; scroll-snap-align: start;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 3px; min-width: 68px; padding: 7px 10px 6px; border-radius: 10px;
    font-size: 10.5px; line-height: 1.15; white-space: nowrap;
  }
  #tabs button::before { content: var(--icon, ""); font-size: 18px; line-height: 1; }
  #tabs button.active { background: var(--accent-soft); color: var(--accent-2); box-shadow: none; }

  .page { padding: 14px 12px calc(74px + env(safe-area-inset-bottom)); max-width: 100%; }
  .board { grid-template-columns: 1fr; }
  .stats { grid-template-columns: repeat(2, 1fr); }

  /* iOS zooms the viewport when focusing a <16px input — 16px avoids that. */
  input, select, textarea { font-size: 16px; padding: 11px 12px; }
  button { padding: 11px 16px; }
  button.big { padding: 16px; }
  /* action-button pairs inside a modal (assign/cancel, auto-assign/reassign…)
     wrap onto their own full-width line each instead of squeezing side by
     side — a 160px floor is enough to force the wrap on a phone-width row.
     The header's lone close button is excluded — it must stay put next to
     the title, not stretch across its own line. */
  .modal .row button:not(#closeModal) { flex: 1 1 160px; }

  /* Modals become bottom sheets: full width, rounded only at the top,
     sliding up rather than fading in from the center. `!important` is
     needed here because a few modals set an inline `style="width:520px"`
     (etc.) for their desktop size — an inline style always beats a
     stylesheet rule, so without it those modals would ignore the sheet
     treatment entirely and stay pinned at a fixed desktop width. */
  .modal-back { align-items: flex-end; padding: 0; }
  .modal {
    width: 100% !important; max-width: 100% !important; margin: 0; border-radius: 20px 20px 0 0;
    max-height: 92vh; overflow-y: auto;
    padding: 18px 16px calc(18px + env(safe-area-inset-bottom));
    animation: sheet-in .22s cubic-bezier(.2, .8, .3, 1);
  }
  .modal::before {
    content: ''; display: block; width: 36px; height: 4px; border-radius: 99px;
    background: var(--border-strong); margin: -6px auto 14px;
  }
  @keyframes sheet-in { from { opacity: .4; transform: translateY(20px); } }
  @media (prefers-reduced-motion: reduce) { .modal { animation: none; } }

  /* Any field-group / sub-panel wrapped in a bare <div> inside a .row
     (form field pairs, the report date-range controls, the task-detail
     content/sidebar split, the locations page's two side-by-side cards…)
     stacks to full width instead of being squeezed side by side — one
     column, thumb-height fields, the way a native form screen reads. */
  .row > div { flex: 1 1 100%; min-width: 0 !important; }

  /* ---------- data tables → native list rows ----------
     A wide table read sideways is what makes mobile web feel like a
     shrunk desktop site. Instead every row becomes its own card with
     "label: value" lines (label from data-label, set in admin.js) — the
     same shape as a native Mail/Files/Settings list row. The header row
     is visually hidden (kept for screen readers). */
  .card table, .card thead, .card tbody, .card tr, .card th, .card td { display: block; width: 100%; }
  .card table { border: none; }
  .card thead tr {
    position: absolute; width: 1px; height: 1px; overflow: hidden;
    clip: rect(0 0 0 0); white-space: nowrap; border: 0; padding: 0; margin: -1px;
  }
  .card tbody tr {
    background: var(--panel-2); border: 1px solid var(--border); border-radius: 12px;
    padding: 10px 12px; margin-bottom: 10px;
  }
  .card tbody tr:last-child { margin-bottom: 0; }
  .card td {
    border: none; padding: 6px 0; display: flex; align-items: center;
    justify-content: space-between; gap: 12px; text-align: end; font-size: 14px;
  }
  .card td[data-label]::before {
    content: attr(data-label); font-weight: 700; color: var(--muted); text-align: start;
    text-transform: uppercase; font-size: 10.5px; letter-spacing: .04em; flex: 0 0 auto;
  }
  .card td:empty { display: none; }
  /* a cell's own inline width (QR/code/lat-lng inputs sized for a table
     column) no longer applies once that cell is a full-width list row */
  .card td input, .card td select, .card td textarea { width: 100% !important; }
  .card td .row { justify-content: flex-end; }

  /* ---------- agent app: sticky bottom action bar ----------
     The primary action ("Chair collected", "Complete", …) is the one
     thing a courier/agent app should never make you scroll to find —
     pin it to the bottom of the screen, like a native app's persistent
     CTA. Extra bottom padding only applies on screens that actually have
     the button, so the home task list and completed-task view don't
     carry dead space. */
  .agent-page:has(#nextBtn) { padding-bottom: calc(88px + env(safe-area-inset-bottom)); }
  #nextBtn {
    position: fixed; inset-inline: 16px; bottom: calc(16px + env(safe-area-inset-bottom));
    z-index: 25; margin-top: 0 !important; box-shadow: var(--shadow-lg);
  }
}
