/* App layout on top of the Mileloft Interstate components (interstate.css) and tokens (tokens.css). */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--fg); font: 16px/1.55 var(--font-display); }
a { color: var(--sign-ink); }
a:focus-visible, button:focus-visible, select:focus-visible, textarea:focus-visible, input:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.wrap { max-width: 760px; margin: 0 auto; padding: var(--sp-16) var(--sp-16) 48px; display: grid; gap: var(--sp-18); }

/* Top bar: wordmark slab + nav */
.top { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--sp-10); }
.wordmark { background: var(--sign-plate); color: var(--on-sign); font-weight: 800; font-size: 18px; padding: 4px 12px;
  border-radius: var(--radius-label); box-shadow: inset 0 0 0 2px var(--on-sign); text-decoration: none; letter-spacing: .01em; }
.nav { display: flex; flex-wrap: wrap; gap: var(--sp-4); align-items: center; }
.nav a, .nav button { font: 600 13px var(--font-mono); color: var(--muted); text-decoration: none; padding: 4px 10px;
  border-radius: var(--radius-pill); border: 1px solid transparent; background: none; cursor: pointer; }
.nav a[aria-current="page"] { color: var(--fg); border-color: var(--line); background: var(--surface); }
.nav form { margin: 0; }

/* Period switcher */
.bar { display: flex; flex-wrap: wrap; gap: var(--sp-8); align-items: center; justify-content: space-between; }
.bar .grp { display: flex; gap: var(--sp-6); flex-wrap: wrap; align-items: center; }
.ml-btn.pill[aria-current="true"] { color: var(--on-sign); background: var(--sign-plate); border-color: var(--sign-plate); }

/* Drive rows inside forms */
.ml-drive form { display: contents; }
.ml-drive .actions { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: var(--sp-8); align-items: center; }
.ml-drive .actions .ml-seg { grid-column: auto; }
.ml-drive .purpose { flex: 1 1 200px; display: flex; gap: var(--sp-6); }
.ml-drive .purpose input { flex: 1; min-width: 0; font: 15px var(--font-display); color: var(--fg); background: var(--bg);
  border: 1px solid var(--line); border-radius: var(--radius-control); padding: 6px 10px; }
.ml-drive .purpose button { font: 600 12px var(--font-mono); }
.js .ml-drive .purpose button { display: none; }
.ml-drive.busy { opacity: .6; }
.day-head { margin: var(--sp-6) 0 0; }
.ml-drive:first-of-type { border-top: 0; }
.cross { color: var(--muted); }
.cross.off { color: var(--amber); }

/* Forms */
.form { display: grid; gap: var(--sp-10); }
.form .row { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: var(--sp-10); }
.ml-field select, .ml-field textarea { font: 16px var(--font-display); color: var(--fg); background: var(--bg);
  border: 1px solid var(--line); border-radius: var(--radius-control); padding: 8px 10px; }
.ml-field input { width: 100%; }
.err { color: var(--alert); font-size: 13px; }
.inline { display: inline; margin: 0; }
.linkish { background: none; border: 0; padding: 0; font: inherit; color: var(--sign-ink); cursor: pointer; text-decoration: underline; }
.danger { color: var(--alert); }
.list { list-style: none; margin: 0; padding: 0; display: grid; }
.list > li { padding: var(--sp-10) 0; border-top: 1px solid var(--line); display: flex; flex-wrap: wrap; gap: var(--sp-6) var(--sp-12);
  align-items: center; justify-content: space-between; }
.list > li:first-child { border-top: 0; }
.list .what { display: grid; gap: 2px; min-width: 0; }
.list .what b { font-weight: 700; }
.secret { font: 600 14px var(--font-mono); background: var(--bg); border: 1px dashed var(--line); border-radius: var(--radius-control);
  padding: 10px; word-break: break-all; user-select: all; }
.ml-sign .stat-row { display: grid; }
.ml-stat .biz { color: var(--on-sign); }
.chips { display: flex; flex-wrap: wrap; gap: var(--sp-6); }
.ml-chip.biz { color: var(--sign-ink); } .ml-chip.per { color: var(--family); }
.empty { color: var(--muted); }
.consent { font-size: 18px; line-height: 1.5; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Print: the Pub 463 report */
.print-only { display: none; }
@media print {
  :root { color-scheme: light; }
  body { background: #fff; }
  .top, .no-print { display: none !important; }
  .print-only { display: block; }
  .wrap { max-width: none; padding: 0; }
  .ml-panel { border: 0; padding: 0; }
  .ml-table { min-width: 0; font-size: 11px; }
  .ml-table-wrap { overflow: visible; }
  .ml-sign { box-shadow: none; border: 2px solid #1d6b45; background: #fff; color: #1c211e; }
  tr { break-inside: avoid; }
}

/* Grid children may shrink (datetime inputs otherwise overflow their cell on phones). */
.form .row > * { min-width: 0; }
.ml-field input, .ml-field select { min-width: 0; max-width: 100%; }
/* Tables that wrap text instead of scrolling sideways (report tables with few numeric columns). */
.ml-table.fit { min-width: 0; }
.ml-table.fit td.txt { font-family: var(--font-display); white-space: normal; text-align: left; }
.ml-table.fit th.txt { text-align: left; }

/* Drive endpoints: tap to save a place. */
.ml-drive .route a.ep { color: inherit; text-decoration: underline dotted var(--line); text-underline-offset: 3px; }
.ml-drive .route a.ep:hover { text-decoration-color: var(--muted); }

/* Add a car */
.choices { display: grid; gap: var(--sp-8); }
.scan { display: grid; gap: var(--sp-8); }
.scan video { width: 100%; max-height: 260px; object-fit: cover; border-radius: var(--radius-control); background: #000; }
.scan video { outline: 3px solid transparent; outline-offset: -3px; transition: outline-color .2s; }
.scan.found video { outline-color: var(--ok); }
.vin-found { font-size: 20px; color: var(--ok); letter-spacing: .04em; }
details > summary { list-style: none; cursor: pointer; display: inline-block; }
details > summary::-webkit-details-marker { display: none; }
.ml-mono { font-family: var(--font-mono); }
.ml-btn.big { display: block; text-align: center; font-size: 17px; padding: 14px; border-radius: var(--radius-panel); }
[hidden] { display: none !important; }

/* Which car */
.ml-drive .car { display: flex; flex-wrap: wrap; gap: var(--sp-6); align-items: center; }
.ml-drive .car select, .drive-now select { font: 600 12px var(--font-mono); color: var(--fg); background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius-pill); padding: 4px 10px; max-width: 220px; }
.drive-now { display: flex; flex-wrap: wrap; gap: var(--sp-8); align-items: center; justify-content: space-between;
  padding: var(--sp-8) 0; border-top: 1px solid var(--line); }
.drive-now:first-of-type { border-top: 0; }

/* Deleting drives */
.ml-btn.alert { color: var(--alert); border-color: var(--alert); }
details.del { display: inline-flex; flex-wrap: wrap; gap: var(--sp-6); align-items: center; }
details.del[open] > summary { color: var(--alert); }
.ml-drive .pick { grid-column: 1 / -1; display: flex; }
.bulk { margin-top: var(--sp-8); }

/* Trip viewer and family map (MapLibre) */
.trip-map { height: 56vh; min-height: 300px; max-height: 640px; border-radius: var(--radius-panel); overflow: hidden;
  border: var(--stroke-hairline) solid var(--line); background: var(--surface); }
.trip-map .maplibregl-ctrl-attrib { font-size: 11px; }
.stop-row .when { font: 600 12px var(--font-mono); color: var(--muted); text-align: right; }
.stop-row.passed .where { color: var(--muted); text-decoration: line-through; }
.wx-alert { margin-bottom: var(--sp-8); }
.person-dot { width: 18px; height: 18px; border-radius: 50%; background: var(--family); border: 3px solid var(--surface);
  box-shadow: 0 0 0 2px var(--family); }
@media (max-width: 520px) { .trip-map { height: 48vh; } }

/* Trip planner (trips/plan) */
.plan-stops { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--sp-8); counter-reset: stop; }
.plan-stop { display: grid; grid-template-columns: 110px minmax(0, 1fr) minmax(0, 1.4fr) 64px auto; gap: var(--sp-6); align-items: center; }
.plan-stop select, .plan-stop input { font: 15px var(--font-display); color: var(--fg); background: var(--bg); border: var(--stroke-hairline) solid var(--line);
  border-radius: var(--radius-control); padding: 6px 8px; min-width: 0; }
.plan-stop .ctl { display: flex; gap: var(--sp-4); align-items: center; justify-content: flex-end; }
@media (max-width: 640px) { .plan-stop { grid-template-columns: 1fr 1fr; } .plan-stop .ctl { grid-column: 1 / -1; } }
.plan-seg { grid-column: auto; }
.plan-seg label { font: 600 12px var(--font-mono); padding: 6px 12px; color: var(--muted); cursor: pointer; display: inline-flex; gap: 6px; align-items: center; }
.plan-seg label:has(input:checked) { background: var(--sign-plate); color: var(--on-sign); }
.plan-seg input { accent-color: var(--on-sign); }
.ml-check input[type="datetime-local"] { font: 15px var(--font-display); color: var(--fg); background: var(--bg); border: var(--stroke-hairline) solid var(--line);
  border-radius: var(--radius-control); padding: 4px 8px; }
#plan-out { display: grid; gap: var(--sp-12); }
#plan-out.busy { opacity: .55; }
.plan-flag .chips { margin-top: var(--sp-6); }
.plan-fixes .amt { color: var(--muted); }
