/* Fonts are served from this site (no Google Fonts request), which keeps visitors private and lets the app work offline. */
@font-face { font-family: "Barlow"; font-weight: 400; font-style: normal; font-display: swap; src: url(../fonts/barlow-latin-400-normal.woff2) format("woff2"); }
@font-face { font-family: "Barlow"; font-weight: 500; font-style: normal; font-display: swap; src: url(../fonts/barlow-latin-500-normal.woff2) format("woff2"); }
@font-face { font-family: "Barlow"; font-weight: 600; font-style: normal; font-display: swap; src: url(../fonts/barlow-latin-600-normal.woff2) format("woff2"); }
@font-face { font-family: "Barlow"; font-weight: 700; font-style: normal; font-display: swap; src: url(../fonts/barlow-latin-700-normal.woff2) format("woff2"); }
@font-face { font-family: "Barlow Semi Condensed"; font-weight: 600; font-style: normal; font-display: swap; src: url(../fonts/barlow-semi-condensed-latin-600-normal.woff2) format("woff2"); }
@font-face { font-family: "Barlow Semi Condensed"; font-weight: 700; font-style: normal; font-display: swap; src: url(../fonts/barlow-semi-condensed-latin-700-normal.woff2) format("woff2"); }
body { margin: 0; } [hidden] { display: none !important; } img { max-width: 100%; }
/* Layout: dispatcher's console — control column on the left (plan / routes / proof), live route map filling the rest; stacks map-over-panel on phones. Accent is highway-sign green. */
:root {
  --bg: #F1F3EF;
  --surface: #FFFFFF;
  --surface-2: #F6F7F4;
  --ink: #142019;
  --muted: #5A665F;
  --faint: #8A948D;
  --line: #D8DDD5;
  --accent: #0A6A3A;
  --accent-ink: #FFFFFF;
  --accent-soft: #DCEEE2;
  --good: #006300;
  --critical: #C23434;
  --critical-soft: #FBE3E1;
  --map: #FAFBF8;
  --grid: #E7EAE4;
  --s1: #2a78d6; --s2: #eb6834; --s3: #1baf7a; --s4: #eda100; --s5: #e87ba4; --s6: #008300; --s7: #4a3aa7; --s8: #e34948;
  --font: "Barlow", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-cond: "Barlow Semi Condensed", "Barlow", system-ui, sans-serif;
  --r: 10px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0E1310; --surface: #161C18; --surface-2: #1C241F; --ink: #EDF2EE; --muted: #9DAAA2; --faint: #6F7B74; --line: #2A342E;
    --accent: #43C07C; --accent-ink: #04120A; --accent-soft: #15301F; --good: #0ca30c; --critical: #EF6A6A; --critical-soft: #3A1717;
    --map: #111713; --grid: #1F2823;
    --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500; --s5: #d55181; --s6: #008300; --s7: #9085e9; --s8: #e66767;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0E1310; --surface: #161C18; --surface-2: #1C241F; --ink: #EDF2EE; --muted: #9DAAA2; --faint: #6F7B74; --line: #2A342E;
  --accent: #43C07C; --accent-ink: #04120A; --accent-soft: #15301F; --good: #0ca30c; --critical: #EF6A6A; --critical-soft: #3A1717;
  --map: #111713; --grid: #1F2823;
  --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500; --s5: #d55181; --s6: #008300; --s7: #9085e9; --s8: #e66767;
  color-scheme: dark;
}
html, body { height: 100%; }
*, *::before, *::after { box-sizing: border-box; }
body { background: var(--bg); color: var(--ink); font-family: var(--font); font-size: 15px; line-height: 1.45; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.num { font-variant-numeric: tabular-nums; }

#app { height: 100%; display: flex; flex-direction: column; }
header.top { display: flex; align-items: center; gap: 14px; padding-inline: 16px; padding-block: 10px; background: var(--surface); border-bottom: 1px solid var(--line); flex-shrink: 0; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 10px; margin-right: auto; }
.brand { text-decoration: none; color: inherit; }
.brand img { width: 34px; height: 34px; display: block; border-radius: 8px; }
.brand b { font-family: var(--font-cond); font-size: 1.45rem; letter-spacing: 0.01em; line-height: 1; }
.brand small { display: block; color: var(--muted); font-size: 0.8rem; line-height: 1.2; }
.tabs { display: flex; gap: 4px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 999px; padding: 3px; }
.tabs button { border: 0; background: transparent; border-radius: 999px; padding: 6px 14px; font-weight: 600; color: var(--muted); }
.tabs button[aria-selected="true"] { background: var(--ink); color: var(--surface); }

.layout { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(360px, 440px) 1fr; }
.panel { min-height: 0; overflow-y: auto; background: var(--surface); border-right: 1px solid var(--line); }
.panel-inner { padding-inline: 16px; padding-block: 14px 40px; display: flex; flex-direction: column; gap: 18px; }
.mapwrap { position: relative; min-height: 0; background: var(--map); }
#map { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; cursor: grab; }
#map.dragging { cursor: grabbing; }
.map-ctl { position: absolute; right: 12px; top: 12px; display: flex; flex-direction: column; gap: 6px; }
.map-ctl button { width: 36px; height: 36px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); font-weight: 700; font-size: 1.05rem; }
.map-legend { position: absolute; left: 12px; bottom: 12px; background: color-mix(in srgb, var(--surface) 92%, transparent); border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; font-size: 0.8rem; color: var(--muted); display: flex; gap: 12px; align-items: center; flex-wrap: wrap; max-width: calc(100% - 160px); }
.map-legend i { display: inline-block; vertical-align: middle; margin-right: 4px; }
.map-title { position: absolute; left: 12px; top: 12px; background: color-mix(in srgb, var(--surface) 92%, transparent); border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; font-size: 0.85rem; font-weight: 600; max-width: calc(100% - 80px); }
#tip { position: absolute; pointer-events: none; background: var(--ink); color: var(--surface); border-radius: 8px; padding: 7px 10px; font-size: 0.82rem; line-height: 1.35; max-width: 260px; z-index: 5; }
#tip b { display: block; }

h2 { font-family: var(--font-cond); font-size: 1.05rem; letter-spacing: 0.06em; text-transform: uppercase; margin: 0; color: var(--ink); }
h3 { margin: 0; font-size: 1rem; }
.sec { display: flex; flex-direction: column; gap: 10px; }
.sec + .sec { border-top: 1px solid var(--line); padding-top: 16px; }
.sec-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.hint { color: var(--muted); font-size: 0.86rem; margin: 0; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.grid3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; }
.field { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.field label { font-size: 0.78rem; font-weight: 600; color: var(--muted); letter-spacing: 0.02em; }
input[type="text"], input[type="number"], input[type="time"], select, textarea { border: 1px solid var(--line); background: var(--surface-2); border-radius: 8px; padding: 7px 9px; min-height: 36px; width: 100%; min-width: 0; }
textarea { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.8rem; }
.btn { border: 1px solid var(--line); background: var(--surface-2); border-radius: 8px; padding: 7px 12px; font-weight: 600; min-height: 36px; display: inline-flex; align-items: center; gap: 6px; text-decoration: none; }
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.small { min-height: 30px; padding: 4px 9px; font-size: 0.85rem; }
.btn.ghost { background: transparent; }
.btn[disabled] { opacity: 0.5; cursor: not-allowed; }
.big-go { width: 100%; min-height: 50px; font-size: 1.1rem; font-family: var(--font-cond); letter-spacing: 0.03em; justify-content: center; border-radius: 10px; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.seg button { border: 0; background: var(--surface-2); padding: 6px 12px; font-weight: 600; min-height: 34px; }
.seg button + button { border-left: 1px solid var(--line); }
.seg button[aria-pressed="true"] { background: var(--ink); color: var(--surface); }

.tbl-wrap { overflow: auto; max-height: 280px; border: 1px solid var(--line); border-radius: 8px; }
table { border-collapse: collapse; width: 100%; font-size: 0.85rem; }
th, td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { position: sticky; top: 0; background: var(--surface-2); font-weight: 600; color: var(--muted); font-size: 0.78rem; z-index: 1; }
td.name { white-space: normal; min-width: 150px; }
td.r, th.r { text-align: right; }
tr:last-child td { border-bottom: 0; }

.fleet-row { display: grid; grid-template-columns: 1.3fr 0.7fr 0.8fr; gap: 8px; padding: 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface-2); position: relative; }
.fleet-row .grid-x { grid-column: 1 / -1; display: grid; grid-template-columns: 1fr 1fr 1fr 1fr; gap: 8px; }
.fleet-row .del { position: absolute; top: 6px; right: 6px; border: 0; background: transparent; color: var(--muted); font-size: 0.8rem; font-weight: 600; }
.fleet-row .grid-x .field input { background: var(--surface); }
.fleet-row > .field input { background: var(--surface); }

.progress { display: flex; flex-direction: column; gap: 6px; padding: 12px; border-radius: var(--r); background: var(--accent-soft); }
.bar { height: 6px; border-radius: 3px; background: color-mix(in srgb, var(--accent) 20%, transparent); overflow: hidden; }
.bar i { display: block; height: 100%; width: 0; background: var(--accent); transition: width .2s linear; }
.progress .stat { display: flex; justify-content: space-between; font-size: 0.88rem; gap: 8px; flex-wrap: wrap; }
.spark { width: 100%; height: 44px; display: block; }

.kpis { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.kpi { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.kpi span { font-size: 0.75rem; font-weight: 600; color: var(--muted); letter-spacing: 0.03em; text-transform: uppercase; }
.kpi b { font-family: var(--font-cond); font-size: 1.5rem; line-height: 1.1; }
.kpi small { color: var(--muted); font-size: 0.8rem; }
.savings { border-radius: var(--r); background: var(--accent-soft); padding: 14px; display: flex; flex-direction: column; gap: 6px; }
.savings .big { font-family: var(--font-cond); font-size: 1.9rem; line-height: 1.05; font-weight: 700; color: var(--ink); }
.savings p { margin: 0; font-size: 0.9rem; }
.warnbox { border-radius: var(--r); background: var(--critical-soft); padding: 12px; font-size: 0.9rem; display: flex; flex-direction: column; gap: 6px; }
.warnbox b { color: var(--critical); }

.route { border: 1px solid var(--line); border-radius: var(--r); background: var(--surface); }
.route[aria-expanded="true"] { border-color: var(--muted); }
.route-head { width: 100%; border: 0; background: transparent; display: grid; grid-template-columns: auto 1fr auto; gap: 10px; align-items: center; padding: 10px 12px; text-align: left; }
.swatch { width: 26px; height: 26px; border-radius: 6px; display: grid; place-items: center; font-family: var(--font-cond); font-weight: 700; font-size: 0.85rem; color: #fff; }
.route-head .meta { min-width: 0; display: flex; flex-direction: column; }
.route-head .meta b { font-size: 0.95rem; }
.route-head .meta small { color: var(--muted); font-size: 0.8rem; }
.route-head .right { text-align: right; font-size: 0.85rem; }
.loadbar { height: 4px; background: var(--line); border-radius: 2px; overflow: hidden; margin-top: 4px; }
.loadbar i { display: block; height: 100%; }
.route-body { padding: 0 12px 12px; display: flex; flex-direction: column; gap: 10px; }
.legs { display: flex; flex-wrap: wrap; gap: 6px; }

.pill { display: inline-block; border-radius: 999px; padding: 1px 8px; font-size: 0.75rem; font-weight: 600; background: var(--surface-2); border: 1px solid var(--line); color: var(--muted); }
.pill.tw { color: var(--ink); }

/* Proof tab */
.proof-hero { display: flex; flex-direction: column; gap: 8px; }
.proof-hero .big { font-family: var(--font-cond); font-size: 2.1rem; line-height: 1.02; font-weight: 700; text-wrap: balance; margin: 0; }
.proof-hero p { margin: 0; max-width: 60ch; }
.chart { width: 100%; display: flex; flex-direction: column; gap: 16px; }
.bgroup { display: flex; flex-direction: column; gap: 6px; }
.bg-h { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.bg-h span { color: var(--muted); font-size: 0.82rem; }
.brow { display: grid; grid-template-columns: 84px minmax(0, 1fr) 56px; gap: 8px; align-items: center; font-size: 0.85rem; }
.brow .bl { display: flex; align-items: center; gap: 6px; color: var(--ink); white-space: nowrap; }
.brow .bl i { width: 10px; height: 10px; border-radius: 3px; flex-shrink: 0; }
.btrack { height: 16px; position: relative; overflow: hidden; background-image: linear-gradient(90deg, var(--grid) 1px, transparent 1px); background-repeat: repeat-x; border-left: 1px solid var(--muted); }
.btrack i { position: absolute; left: 0; top: 2px; bottom: 2px; border-radius: 0 4px 4px 0; min-width: 2px; }
.brow .bv { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }
.brow.fail .bv { color: var(--muted); font-weight: 500; }
.bscale { display: grid; grid-template-columns: 84px minmax(0, 1fr) 56px; gap: 8px; font-size: 0.75rem; color: var(--muted); }
.bscale div { display: flex; justify-content: space-between; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 0.85rem; color: var(--muted); }
.legend i { width: 12px; height: 12px; border-radius: 3px; display: inline-block; vertical-align: -1px; margin-right: 5px; }
.win { color: var(--good); font-weight: 700; }
.muted { color: var(--muted); }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.78rem; overflow-wrap: anywhere; }
details summary { cursor: pointer; font-weight: 600; }
details > div { padding-top: 8px; display: flex; flex-direction: column; gap: 8px; }
.live-out { border: 1px solid var(--line); border-radius: var(--r); padding: 12px; display: flex; flex-direction: column; gap: 8px; background: var(--surface-2); }

#toast { position: fixed; left: 50%; bottom: calc(52px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); background: var(--ink); color: var(--surface); padding: 9px 14px; border-radius: 10px; font-weight: 600; z-index: 50; max-width: calc(100% - 32px); text-align: center; }
.sheet-bg { position: fixed; inset: 0; background: color-mix(in srgb, var(--ink) 40%, transparent); display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 40; }
.sheet { background: var(--surface); border-radius: 14px; padding: 18px; width: 100%; max-width: 680px; max-height: 100%; overflow-y: auto; display: flex; flex-direction: column; gap: 12px; }


/* ---------- Header actions ---------- */
.top-actions { display: flex; gap: 6px; align-items: center; }
.icon-btn { width: 36px; height: 36px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface-2); display: inline-grid; place-items: center; color: var(--ink); padding: 0; }
.icon-btn:hover { border-color: var(--muted); }
.icon-btn svg { width: 18px; height: 18px; }
.help-btn { border-radius: 999px; border: 1px solid var(--line); background: var(--surface-2); min-height: 36px; padding: 0 12px; font-weight: 600; display: inline-flex; align-items: center; gap: 6px; }
.help-btn:hover { border-color: var(--muted); }
.tab-badge { display: inline-block; min-width: 18px; padding: 0 5px; margin-left: 5px; border-radius: 999px; background: var(--accent); color: var(--accent-ink); font-size: 0.72rem; line-height: 18px; text-align: center; }
.tabs button[aria-selected="true"] .tab-badge { background: var(--surface); color: var(--ink); }
.skip { position: absolute; left: -9999px; top: 8px; z-index: 100; background: var(--ink); color: var(--surface); padding: 8px 12px; border-radius: 8px; }
.skip:focus { left: 8px; }
.btn.danger { background: var(--critical); color: #fff; border-color: var(--critical); }
a { color: var(--accent); }
.btn { color: var(--ink); }
.btn.primary { color: var(--accent-ink); }
.linkish { border: 0; background: none; padding: 0; color: var(--muted); text-decoration: underline; font-size: 0.86rem; min-height: 0; }
.linkish:hover { color: var(--ink); }

/* ---------- Footer ---------- */
.site-foot { flex-shrink: 0; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 4px 16px; padding: 7px 16px calc(7px + env(safe-area-inset-bottom, 0px)); border-top: 1px solid var(--line); background: var(--surface); font-size: 0.8rem; color: var(--muted); }
.site-foot a { color: var(--muted); text-decoration: none; }
.site-foot a:hover { color: var(--ink); text-decoration: underline; }
.site-foot nav { display: flex; gap: 14px; flex-wrap: wrap; }

/* ---------- Dialog ---------- */
body.modal-open { overflow: hidden; }
.sheet:focus { outline: none; }
.sheet .row input[type="text"] { flex: 1; min-width: 180px; width: auto; }
.sheet-h { font-size: 1.25rem; letter-spacing: 0.02em; text-transform: none; }
.how { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 12px; }
.how-step { display: grid; grid-template-columns: 30px 1fr; gap: 10px; align-items: start; }
.how-step p { margin: 2px 0 0; }
.how-n { width: 30px; height: 30px; border-radius: 50%; background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; font-family: var(--font-cond); font-weight: 700; }
.how-note { background: var(--accent-soft); border-radius: var(--r); padding: 10px 12px; font-size: 0.9rem; }

/* ---------- Print: route sheets only ---------- */
#printArea { display: none; }
@media print {
  @page { margin: 12mm; }
  body.printing #app, body.printing #sheetWrap, body.printing #toast { display: none !important; }
  body.printing { background: #fff; color: #000; height: auto; }
  body.printing #printArea { display: block; }
  .print-route { break-after: page; font-family: var(--font); color: #000; }
  .print-route:last-child { break-after: auto; }
  .print-route h2 { font-size: 18pt; text-transform: none; letter-spacing: 0; color: #000; margin: 0 0 4pt; }
  .print-route p { margin: 0 0 8pt; font-size: 10pt; }
  .print-route table { width: 100%; border-collapse: collapse; font-size: 10pt; }
  .print-route th, .print-route td { border: 1px solid #999; padding: 4pt 6pt; white-space: normal; color: #000; background: #fff; position: static; }
  .print-route td.sig { width: 30%; }
  .print-foot { margin-top: 8pt; color: #555; font-size: 8pt; }
}

@media (max-width: 900px) {
  .layout { grid-template-columns: minmax(0, 1fr); grid-template-rows: 44vh auto; overflow-y: auto; }
  .mapwrap { order: -1; min-height: 44vh; border-bottom: 1px solid var(--line); }
  .panel { overflow: visible; border-right: 0; }
  .brand small { display: none; }
  .help-btn span { display: none; }
  .help-btn { padding: 0 11px; }
}
@media (max-width: 640px) {
  header.top { gap: 8px 10px; padding-inline: 12px; }
  .tabs { order: 3; width: 100%; justify-content: space-between; }
  .tabs button { flex: 1; }
  .site-foot { justify-content: center; text-align: center; padding-block: 6px; }
}
@media (max-width: 460px) {
  .kpis { grid-template-columns: 1fr 1fr; }
  .brow { grid-template-columns: 70px minmax(0, 1fr) 50px; }
  .bscale { grid-template-columns: 70px minmax(0, 1fr) 50px; }
  .fleet-row .grid-x { grid-template-columns: 1fr 1fr; }
  .grid3 { grid-template-columns: 1fr 1fr; }
  .tabs button { padding: 6px 10px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
