/*
 * SAMN base styles. Copied into every SAMN app's public/ folder rather than shared
 * (FR-X-09: each app is built as if by a different party). Keep the copies identical;
 * each page sets only its party colour on :root:
 *
 *   --accent      the party colour (header band, primary buttons, progress bar)
 *   --accent-ink  text on the party colour (white, or dark on a light colour)
 *   --accent-2    optional: where the header gradient ends (default: a darker accent)
 *   --accent-text optional: the accent as text on white (default: a darker accent)
 *
 * Always light: the apps no longer follow the operating system's dark mode.
 */
:root {
  color-scheme: light;
  --accent: #12a594;
  --accent-ink: #ffffff;
  --accent-2: color-mix(in srgb, var(--accent) 72%, #1c2024);
  --fg: #1c2024;
  --muted: #60646c;
  --line: #e2e4ea;
  --card: #ffffff;
  --bg: color-mix(in srgb, var(--accent) 7%, #f4f5f8);
  --soft: color-mix(in srgb, var(--accent) 9%, #ffffff);
  --accent-text: color-mix(in srgb, var(--accent) 72%, #1c2024);
  --alarm: #dc3e42;
  --warn: #ab6400;
  --ok: #218358;
  --info: #0d74ce;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 6px 18px rgba(16, 24, 40, .06);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  padding: 1rem 1rem 3rem;
  color: var(--fg);
  background:
    radial-gradient(1200px 380px at 50% -120px, color-mix(in srgb, var(--accent) 22%, transparent), transparent 70%),
    var(--bg);
  background-attachment: fixed;
  font: 15px/1.5 "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}
main { max-width: 1240px; margin: 0 auto; }

/* ------------------------------------------------------------ header band */
header {
  display: flex; justify-content: space-between; align-items: center; gap: .8rem 1.2rem; flex-wrap: wrap;
  margin-bottom: 1rem; padding: .85rem 1.1rem;
  color: var(--accent-ink);
  background: linear-gradient(120deg, var(--accent), var(--accent-2));
  border-radius: 18px;
  box-shadow: 0 10px 28px color-mix(in srgb, var(--accent) 28%, transparent);
}
h1 { display: flex; align-items: center; gap: .75rem; margin: 0; font-size: 1.25rem; font-weight: 700; letter-spacing: -.01em; line-height: 1.2; }
h1 small { display: block; margin: .15rem 0 0; font-size: .8rem; font-weight: 500; opacity: .82; }
h1 .logo {
  flex: none; display: grid; place-items: center; width: 42px; height: 42px; border-radius: 12px;
  background: color-mix(in srgb, var(--accent-ink) 18%, transparent);
}
h1 .logo svg { width: 24px; height: 24px; }
.id { display: flex; gap: .55rem; align-items: center; flex-wrap: wrap; font-size: 13px; color: inherit; }
.id select, .id #whoami, header .who {
  font: inherit; padding: .3rem .65rem; border-radius: 999px; color: inherit;
  border: 1px solid color-mix(in srgb, var(--accent-ink) 35%, transparent);
  background: color-mix(in srgb, var(--accent-ink) 14%, transparent);
}
.id #whoami:empty, header .who:empty { display: none; }
.id select { width: auto; max-width: 18rem; }
.id select option { color: #1c2024; background: #fff; }
header button.link, header .live { color: inherit; opacity: .9; }
header .live.on::before { color: #3dd68c; }

/* ------------------------------------------------------------ cards and text */
section {
  background: var(--card); border: 1px solid color-mix(in srgb, var(--line) 70%, transparent);
  border-radius: var(--radius); padding: 1.05rem 1.15rem; margin-bottom: 1rem; box-shadow: var(--shadow);
}
h2 {
  display: flex; justify-content: space-between; align-items: center; gap: .5rem;
  margin: 0 0 .75rem; font-size: .78rem; font-weight: 700; text-transform: uppercase; letter-spacing: .07em;
  color: var(--accent-text);
}
h3 { font-size: .92rem; margin: 1rem 0 .45rem; }
code, .mono { font-family: ui-monospace, "Cascadia Mono", SFMono-Regular, Menlo, monospace; font-size: 12.5px; }
.uri { display: block; padding: .6rem .75rem; border: 1px dashed color-mix(in srgb, var(--accent) 45%, var(--line)); border-radius: 10px; background: var(--soft); overflow-x: auto; white-space: nowrap; }
.row { display: flex; gap: .5rem; margin-top: .7rem; flex-wrap: wrap; align-items: center; }
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: .45rem .8rem; }
.grid3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: .45rem .8rem; }
.grid4 { display: grid; grid-template-columns: 2fr 1fr 1fr 1fr; gap: .3rem .6rem; }
.cols { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); gap: 1rem; align-items: start; }
@media (max-width: 860px) { .cols, .grid3, .grid4 { grid-template-columns: 1fr; } }
.muted { color: var(--muted); font-size: 13.5px; margin: .25rem 0 0; }
.error { color: var(--alarm); font-size: 13.5px; margin: .5rem 0 0; font-weight: 500; }
.warn { color: var(--warn); font-size: 13.5px; margin: .5rem 0 0; }
.ok { color: var(--ok); font-size: 13.5px; margin: .5rem 0 0; font-weight: 500; }
.banner { border: 1px solid #f3d58a; background: #fff8e1; color: var(--warn); border-radius: 10px; padding: .55rem .75rem; font-size: 13.5px; margin-bottom: .6rem; }
.steps { margin: 0; padding-left: 1.2rem; color: var(--muted); font-size: 14px; }
.steps li { margin: .2rem 0; }
.steps strong { color: var(--fg); font-weight: 600; }
/* eID wallet: a QR code on a desktop, an open-in-wallet button on a phone (samnWalletAction) */
.wallet { margin-top: .7rem; }
.wallet .qr { display: inline-block; padding: 8px; background: #fff; border: 1px solid var(--line); border-radius: 10px; line-height: 0; }
.wallet-open { display: block; text-align: center; padding: .8rem 1rem; border-radius: 12px; background: var(--accent); color: var(--accent-ink); font-weight: 600; text-decoration: none; box-shadow: 0 2px 8px color-mix(in srgb, var(--accent) 35%, transparent); }
.wallet-hint { color: var(--muted); font-size: 13px; margin: .4rem 0 0; }
.wallet-hint a { color: var(--accent-text); }
details summary { cursor: pointer; font-size: 13.5px; color: var(--accent-text); font-weight: 500; }
ul.plain { list-style: none; margin: 0; padding: 0; }
ul.reasons { margin: .2rem 0 0; padding-left: 1rem; font-size: 12.5px; color: var(--muted); }
ul.reasons li.no { color: var(--alarm); }
.prov { font-size: 10.5px; color: var(--muted); }
.flags span { margin-right: .3rem; }
.ack { font-size: 13px; margin: .2rem 0; }

/* Empty states: any "…-empty" placeholder */
p[id$="-empty"], section[id$="-empty"] > p {
  margin: .2rem 0 0; padding: 1.1rem 1rem; text-align: center; color: var(--muted); font-size: 13.5px;
  border: 1.5px dashed color-mix(in srgb, var(--accent) 30%, var(--line)); border-radius: 12px;
  background: color-mix(in srgb, var(--accent) 3%, #fff);
}
p[id$="-empty"]::before, section[id$="-empty"] > p::before { content: "○"; display: block; font-size: 1.3rem; line-height: 1; margin-bottom: .35rem; color: color-mix(in srgb, var(--accent) 55%, var(--line)); }

/* ------------------------------------------------------------ forms */
label { display: block; font-size: 12.5px; font-weight: 500; color: var(--muted); margin-bottom: .2rem; }
input[type=text], input[type=number], input[type=date], input[type=datetime-local], select, textarea {
  width: 100%; font: inherit; padding: .48rem .6rem; border: 1px solid var(--line); border-radius: 10px;
  background: #fff; color: var(--fg); transition: border-color .12s, box-shadow .12s;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent); }
textarea { min-height: 4rem; resize: vertical; }
.checks { display: grid; grid-template-columns: repeat(3, 1fr); gap: .2rem .6rem; }
.checks label { display: flex; gap: .35rem; align-items: center; color: var(--fg); font-weight: 400; font-size: 13.5px; margin: 0; }
.damage { display: grid; grid-template-columns: repeat(auto-fill, minmax(12.5rem, 1fr)); gap: .3rem .6rem; }
.damage div { display: grid; grid-template-columns: 1fr 6.2rem; gap: .3rem; align-items: center; font-size: 13px; }
.damage select { padding: .2rem .3rem; font-size: 12.5px; }

button {
  font: inherit; font-weight: 500; padding: .5rem .95rem; border-radius: 10px; cursor: pointer;
  border: 1px solid var(--line); background: #fff; color: var(--fg);
  transition: background .12s, border-color .12s, color .12s, box-shadow .12s, transform .06s;
}
button:hover:not(:disabled) { border-color: color-mix(in srgb, var(--accent) 60%, var(--line)); color: var(--accent-text); }
button:active:not(:disabled) { transform: translateY(1px); }
button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; box-shadow: 0 2px 8px color-mix(in srgb, var(--accent) 35%, transparent); }
button.primary:hover:not(:disabled) { background: color-mix(in srgb, var(--accent) 88%, #000); color: var(--accent-ink); }
button.danger { border-color: color-mix(in srgb, var(--alarm) 45%, var(--line)); color: var(--alarm); }
button.danger:hover:not(:disabled) { background: #fff1f1; color: var(--alarm); border-color: var(--alarm); }
button:disabled { opacity: .5; cursor: default; }
button.link { border: 0; background: none; color: var(--accent-text); padding: 0; text-decoration: underline; text-underline-offset: 2px; font-size: 13px; box-shadow: none; }
button.small { padding: .25rem .6rem; font-size: 13px; }

/* ------------------------------------------------------------ tabs */
.tabs {
  display: inline-flex; flex-wrap: wrap; gap: .25rem; margin-bottom: 1rem; padding: .3rem;
  background: #fff; border-radius: 999px; box-shadow: var(--shadow);
}
.tabs button { border: 0; border-radius: 999px; padding: .4rem 1rem; background: transparent; color: var(--muted); }
.tabs button:hover:not(:disabled) { background: var(--soft); color: var(--accent-text); }
.tabs button.on, .tabs button.on:hover:not(:disabled) { background: var(--accent); color: var(--accent-ink); box-shadow: 0 2px 8px color-mix(in srgb, var(--accent) 35%, transparent); }

/* ------------------------------------------------------------ tables and lists */
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 600; padding: .35rem .45rem; border-bottom: 1px solid var(--line); }
td { padding: .55rem .45rem; border-bottom: 1px solid color-mix(in srgb, var(--line) 75%, transparent); vertical-align: top; }
tr.case, tr.pick { cursor: pointer; }
tr.case:hover td, tr.pick:hover td { background: var(--soft); }
tr.selected td { background: color-mix(in srgb, var(--accent) 13%, #fff); }
tr.selected td:first-child { box-shadow: inset 3px 0 0 var(--accent); }
tr.closed td, tr.done td, tr.ineligible td { opacity: .55; }
dl { display: grid; grid-template-columns: 9.5rem 1fr; gap: .3rem .8rem; margin: 0; font-size: 13.5px; }
dt { color: var(--muted); }
dd { margin: 0; word-break: break-word; }
.timeline li { display: grid; grid-template-columns: 6.5rem 1fr; gap: .6rem; padding: .5rem 0; border-bottom: 1px dashed var(--line); font-size: 13.5px; }
.timeline li:last-child { border-bottom: 0; }
.timeline .when { font-size: 12px; color: var(--accent-text); font-family: ui-monospace, "Cascadia Mono", monospace; }
.timeline .by { font-size: 12px; color: var(--muted); word-break: break-all; }
.box { border: 1px solid var(--line); border-radius: 12px; padding: .75rem .85rem; margin-top: .75rem; background: #fff; }
.box.todo { border-color: color-mix(in srgb, var(--accent) 55%, var(--line)); background: color-mix(in srgb, var(--accent) 5%, #fff); }
.box.alert { border-color: color-mix(in srgb, var(--alarm) 55%, var(--line)); background: #fff5f5; }
.live { font-size: 12px; color: var(--muted); }
.live.on::before { content: "● "; color: var(--ok); }

/* ------------------------------------------------------------ status chips */
.badge {
  display: inline-block; font-size: 10.5px; font-weight: 600; line-height: 1.5; padding: .08rem .55rem;
  border-radius: 999px; border: 0; background: #eef0f3; color: #555a63;
  text-transform: uppercase; letter-spacing: .04em; white-space: nowrap; vertical-align: 1px;
}
/* waiting for someone */
.badge:is(.raised, .draft, .offered, .pending, .awaitingIntake, .awaitingAuthorisation, .assigned, .needs, .heard, .medium, .cannotFixOnSite, .busy, .referred, .expected, .delayed) { background: #fff1c2; color: #8a5300; }
/* moving */
.badge:is(.triaged, .roadsideDispatched, .recovery, .enRoute, .onScene, .inProgress, .inTransport, .accepted, .diagnosing, .inRepair, .returning, .atDepot, .atGarage, .loaded, .collected) { background: #e1efff; color: #0b5cad; }
/* done */
.badge:is(.completed, .closed, .readyForCollection, .released, .valid, .available, .free, .both, .low, .approved, .settled, .delivered, .signed, .yes) { background: #ddf3e4; color: #1a6b45; }
/* a problem */
.badge:is(.declined, .cancelled, .failed, .invalid, .outOfService, .high, .crash, .hazard, .totalLoss, .refused, .no) { background: #ffe5e6; color: #c4232b; }
.badge.critical { background: var(--alarm); color: #fff; }
/* energy that matters to whoever handles the vehicle */
.badge:is(.electric, .hybrid, .lpg, .cng, .hydrogen) { background: #fdf6b2; color: #7a5a00; }
.badge.electric::before { content: "⚡"; margin-right: .15rem; }

/* ------------------------------------------------------------ case progress bar */
.progress { display: flex; align-items: flex-start; margin: .5rem 0 1rem; overflow-x: auto; padding-bottom: .2rem; }
.progress .step { position: relative; flex: 1 1 0; min-width: 3.7rem; text-align: center; font-size: 10.5px; line-height: 1.25; color: var(--muted); }
.progress .step::before { content: ""; position: absolute; top: 9px; right: 50%; width: 100%; height: 3px; background: var(--line); }
.progress .step:first-child::before { display: none; }
.progress .dot { position: relative; z-index: 1; width: 20px; height: 20px; margin: 0 auto .3rem; border-radius: 50%; background: #fff; border: 3px solid var(--line); }
.progress .step.done::before, .progress .step.now::before { background: var(--accent); }
.progress .step.done .dot { background: var(--accent); border-color: var(--accent); }
.progress .step.now .dot { border-color: var(--accent); box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 25%, transparent); }
.progress .step.now { color: var(--fg); font-weight: 700; }
.progress.stopped .step.now .dot { border-color: var(--alarm); box-shadow: 0 0 0 4px #ffe5e6; }

/* ------------------------------------------------------------ maps */
.map { height: 270px; margin-top: .75rem; border-radius: 12px; overflow: hidden; border: 1px solid var(--line); z-index: 0; background: #eef0f3; }
.map.tall { height: 360px; }
.map .leaflet-control-attribution { font-size: 10px; }
.pin { display: block; width: 18px; height: 18px; border-radius: 50%; border: 3px solid #fff; box-shadow: 0 1px 4px rgba(0, 0, 0, .35); background: #8b8d98; }
.pin.incident { background: #dc3e42; }
.pin.unit { background: #f76b15; }
.pin.depot { background: #0090ff; }
.pin.garage { background: #8e4ec6; }
.pin.home { background: #30a46c; }
.pin.truck { background: #2b2f36; }
.pin.car { background: #d6409f; }
.pin.stop { background: #b9bbc6; width: 14px; height: 14px; border-width: 2px; }
.pin.new { background: var(--accent); width: 22px; height: 22px; }
.pin.big { width: 24px; height: 24px; }
.leaflet-tooltip.pin-label { font: 600 11.5px/1.3 "Inter", system-ui, sans-serif; padding: 2px 7px; border-radius: 7px; border: 0; box-shadow: 0 1px 4px rgba(0, 0, 0, .25); }
.legend { display: flex; flex-wrap: wrap; gap: .3rem .9rem; margin-top: .4rem; font-size: 12px; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: .3rem; }
.legend .pin { width: 11px; height: 11px; border-width: 2px; box-shadow: none; }
