/* Dropspot. Graphite (black and white) by default; a business can pick an accent. Status colors never change. */
:root {
  --bg: #f5f5f2; --surface: #ffffff; --sunk: #ecece7; --ink: #1b1c1a; --muted: #666862; --line: #d9dad4; --line2: #c7c8c1;
  --accent: #1b1c1a; --on-accent: #ffffff;
  --ok: #2c8547; --warn: #b86e00; --bad: #c3352b; --info: #2a68ad; --yard: #7d7f79;
  --map-land: #efefea; --map-road: #ffffff; --map-road-edge: #d6d7d0; --map-water: #c9dbe6; --map-park: #dde6d4; --map-building: #e2e2dc; --map-label: #5f615b;
  --display: "Archivo", "Arial Narrow", system-ui, sans-serif;
  --body: "Public Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, Menlo, Consolas, monospace;
  --r: 10px; --tap: 48px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #151614; --surface: #1e1f1c; --sunk: #272825; --ink: #ececea; --muted: #9c9e97; --line: #34362f; --line2: #44463f;
    --accent: #ececea; --on-accent: #151614;
    --ok: #52b46e; --warn: #e29a30; --bad: #e85a4f; --info: #5d99d8; --yard: #8f918a;
    --map-land: #1f201d; --map-road: #3a3c36; --map-road-edge: #2b2d28; --map-water: #1d313d; --map-park: #242e1f; --map-building: #2a2b27; --map-label: #a3a59e;
    color-scheme: dark;
  }
}
:root[data-accent="yellow"] { --accent: #f2b200; --on-accent: #1b1c1a; }
:root[data-accent="orange"] { --accent: #ec6a1e; --on-accent: #1b1c1a; }
:root[data-accent="teal"] { --accent: #0e7f86; --on-accent: #ffffff; }
:root[data-accent="blue"] { --accent: #2450b8; --on-accent: #ffffff; }
:root[data-accent="plum"] { --accent: #7b3f9e; --on-accent: #ffffff; }
@media (prefers-color-scheme: dark) {
  :root[data-accent="yellow"] { --accent: #f5c22f; --on-accent: #151614; }
  :root[data-accent="orange"] { --accent: #f47b34; --on-accent: #151614; }
  :root[data-accent="teal"] { --accent: #3fb8be; --on-accent: #10201f; }
  :root[data-accent="blue"] { --accent: #7097ec; --on-accent: #0f1630; }
  :root[data-accent="plum"] { --accent: #c08be0; --on-accent: #1e1226; }
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.5 var(--body); -webkit-font-smoothing: antialiased; }
h1, h2, h3 { font-family: var(--display); font-stretch: 88%; line-height: 1.15; text-wrap: balance; margin: 0; }
h1 { font-size: 26px; font-weight: 800; }
h2 { font-size: 19px; font-weight: 750; }
h3 { font-size: 15px; font-weight: 700; font-stretch: 95%; }
p { margin: 0; }
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
.mono { font-family: var(--mono); font-size: .9em; letter-spacing: -.01em; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.label { font: 600 11px/1.2 var(--body); letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.num { font-variant-numeric: tabular-nums; }
[hidden] { display: none !important; }
.stack { display: grid; gap: 12px; align-content: start; min-width: 0; }
.stack-lg { display: grid; gap: 22px; align-content: start; min-width: 0; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; min-width: 0; }
.between { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 40px; padding: 8px 14px; border-radius: 9px; border: 1px solid var(--line2); background: var(--surface); font-weight: 600; font-size: 14px; cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn:hover { border-color: var(--ink); }
.btn.primary { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.btn.accent { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }
.btn.danger { color: var(--bad); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.big { min-height: var(--tap); font-size: 15px; border-radius: 11px; width: 100%; }
.btn.sm { min-height: 32px; padding: 4px 10px; font-size: 13px; }
.btn:disabled { opacity: .5; cursor: default; }
.btn-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.icon { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* Forms */
.field { display: grid; gap: 5px; min-width: 0; }
.field > span { font-size: 13px; font-weight: 600; }
.field small { color: var(--muted); font-size: 12px; }
input[type=text], input[type=password], input[type=tel], input[type=email], input[type=number], input[type=date], input[type=search], select, textarea {
  width: 100%; min-height: 42px; padding: 9px 11px; border: 1px solid var(--line2); border-radius: 9px; background: var(--surface); }
textarea { min-height: 76px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--ink); outline-offset: -1px; border-color: var(--ink); }
.check { display: flex; gap: 9px; align-items: center; font-size: 14px; }
.check input { width: 18px; height: 18px; accent-color: var(--ink); }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; }
.err { color: var(--bad); font-size: 13px; }
.suggest { border: 1px solid var(--line2); border-radius: 9px; background: var(--surface); overflow: hidden; }
.suggest button { display: block; width: 100%; text-align: left; padding: 9px 11px; border: 0; border-bottom: 1px solid var(--line); background: none; cursor: pointer; font-size: 14px; }
.suggest button:last-child { border-bottom: 0; }
.suggest button:hover { background: var(--sunk); }

/* Chips */
.chip { display: inline-flex; align-items: center; gap: 5px; font: 600 11.5px/1 var(--body); padding: 4px 7px; border-radius: 6px; white-space: nowrap; border: 1px solid currentColor; }
.chip::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.chip.nodot::before { display: none; }
.s-ok, .s-out { color: var(--ok); } .s-warn, .s-full, .s-service, .s-repair { color: var(--warn); } .s-bad, .s-lost, .s-overdue { color: var(--bad); }
.s-info { color: var(--info); } .s-yard, .s-hauling, .s-retired, .s-muted { color: var(--yard); }
.role { font: 600 11px/1 var(--body); letter-spacing: .03em; padding: 5px 8px; border-radius: 6px; background: var(--sunk); white-space: nowrap; }
.role.owner { background: var(--accent); color: var(--on-accent); }

/* Cards, lists, tables */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 16px; display: grid; gap: 12px; align-content: start; min-width: 0; }
.card.flat { padding: 0; overflow: hidden; gap: 0; }
.list > * { border-bottom: 1px solid var(--line); }
.list > *:last-child { border-bottom: 0; }
.item { display: flex; gap: 12px; align-items: center; padding: 12px 14px; text-decoration: none; min-width: 0; }
a.item:hover, button.item:hover { background: var(--sunk); }
button.item { width: 100%; text-align: left; border: 0; background: none; cursor: pointer; }
.item .meta { display: grid; gap: 2px; min-width: 0; flex: 1; }
.item .meta > * { overflow: hidden; text-overflow: ellipsis; }
.sq { width: 40px; height: 40px; border-radius: 9px; background: var(--sunk); display: grid; place-items: center; font: 700 12px/1 var(--display); flex: none; font-variant-numeric: tabular-nums; }
.tablewrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: 14px; }
th, td { text-align: left; padding: 10px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-weight: 600; color: var(--muted); font-size: 12px; letter-spacing: .03em; white-space: nowrap; }
tbody tr:last-child td { border-bottom: 0; }
tr.click { cursor: pointer; } tr.click:hover td { background: var(--sunk); }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 7px 14px; font-size: 14px; margin: 0; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; min-width: 0; overflow-wrap: anywhere; }
.note { background: var(--sunk); border-radius: 9px; padding: 10px 12px; font-size: 14px; line-height: 1.45; overflow-wrap: anywhere; }
.banner { border: 1px solid var(--warn); border-radius: 9px; padding: 10px 12px; font-size: 14px; }
.banner b { color: var(--warn); }
.banner.bad { border-color: var(--bad); } .banner.bad b { color: var(--bad); }
.empty { text-align: center; padding: 34px 18px; color: var(--muted); display: grid; gap: 10px; justify-items: center; }
.empty h3 { color: var(--ink); }
.bar { height: 8px; border-radius: 99px; background: var(--sunk); overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--ink); border-radius: 99px; }
.bar.warn i { background: var(--warn); } .bar.bad i { background: var(--bad); }
.seg { display: inline-flex; border: 1px solid var(--line2); border-radius: 9px; overflow: hidden; background: var(--surface); flex-wrap: wrap; }
.seg button, .seg a { padding: 7px 12px; border: 0; background: none; color: var(--muted); cursor: pointer; font-size: 13px; text-decoration: none; }
.seg .on { background: var(--sunk); color: var(--ink); font-weight: 600; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chips button { border: 1px solid var(--line2); background: var(--surface); border-radius: 999px; padding: 6px 12px; font-size: 13px; cursor: pointer; }
.chips button.on { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.thumb { width: 64px; height: 64px; border-radius: 8px; object-fit: cover; border: 1px solid var(--line); }
.photo-pick { border: 1.5px dashed var(--line2); border-radius: 10px; padding: 14px; text-align: center; color: var(--muted); cursor: pointer; font-size: 14px; display: grid; gap: 8px; justify-items: center; }
.photo-pick img { max-height: 160px; border-radius: 8px; }
.timeline { display: grid; gap: 0; }
.timeline .ev { display: grid; grid-template-columns: 14px 1fr; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.timeline .ev:last-child { border-bottom: 0; }
.timeline .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--line2); margin-top: 6px; }

/* App shells */
.app { min-height: 100%; }
.office { display: grid; grid-template-columns: 220px minmax(0, 1fr); min-height: 100vh; background: linear-gradient(90deg, var(--surface) 0 219px, var(--line) 219px 220px, transparent 220px); }
.side { border-right: 1px solid var(--line); background: var(--surface); padding: 16px 10px; display: flex; flex-direction: column; gap: 2px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.brand { display: flex; align-items: center; gap: 9px; font: 800 17px/1.1 var(--display); font-stretch: 90%; padding: 2px 8px 16px; text-decoration: none; min-width: 0; }
.brand .pin { width: 22px; height: 22px; flex: none; }
.brand .pin path { fill: var(--accent); } .brand .pin circle { fill: var(--on-accent); }
.brand span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 8px; font-size: 14px; color: var(--muted); text-decoration: none; }
.nav:hover { color: var(--ink); background: var(--sunk); }
.nav.on { background: var(--sunk); color: var(--ink); font-weight: 600; }
.nav .count { margin-left: auto; font: 700 11px/1 var(--body); padding: 3px 7px; border-radius: 999px; background: var(--bad); color: #fff; }
.side .foot { margin-top: auto; padding: 12px 8px 0; border-top: 1px solid var(--line); display: grid; gap: 4px; font-size: 13px; }
.main { padding: 22px 26px 60px; display: grid; gap: 18px; align-content: start; min-width: 0; max-width: 1280px; width: 100%; }
.pagehead { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; flex-wrap: wrap; }
.pagehead .sub { color: var(--muted); font-size: 14px; margin-top: 3px; }
.topbar { display: none; }
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 12px 14px; display: grid; gap: 2px; text-decoration: none; }
a.stat:hover { border-color: var(--ink); }
.stat b { font: 750 26px/1.1 var(--display); font-variant-numeric: tabular-nums; }
.stat span { font-size: 13px; color: var(--muted); }
.stat.bad b { color: var(--bad); } .stat.warn b { color: var(--warn); }
.split { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.mapbox { position: relative; border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; background: var(--map-land); min-height: 320px; }
.mapbox .map { position: absolute; inset: 0; }
.mapbox.tall { height: min(70vh, 640px); }
.mapbox.med { height: 420px; }
.mapbox.short { height: 240px; min-height: 200px; }
.mapfail { position: absolute; inset: 0; display: grid; place-items: center; padding: 20px; text-align: center; color: var(--muted); font-size: 14px; }
.legend { position: absolute; left: 8px; bottom: 8px; display: flex; gap: 10px; flex-wrap: wrap; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 6px 9px; font-size: 12px; z-index: 2; max-width: calc(100% - 16px); }
.legend i { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 5px; vertical-align: 0; }
.mapfilters { position: absolute; left: 8px; top: 8px; z-index: 2; right: 50px; }
.centerpin { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -100%); z-index: 3; pointer-events: none; width: 34px; height: 34px; }
.centerpin path { fill: var(--bad); stroke: var(--surface); stroke-width: 1.5; } .centerpin circle { fill: var(--surface); }
.maplibregl-popup-content { background: var(--surface); color: var(--ink); border-radius: 10px; padding: 10px 12px; font: 14px/1.4 var(--body); box-shadow: 0 6px 24px rgba(0,0,0,.18); }
.maplibregl-popup-tip { border-top-color: var(--surface) !important; border-bottom-color: var(--surface) !important; }
.maplibregl-popup-close-button { color: var(--muted); font-size: 18px; padding: 0 6px; }
.maplibregl-ctrl-attrib { font-size: 10px; }

/* Phone shells (driver + customer + scan pages) */
.phone { max-width: 560px; margin: 0 auto; min-height: 100vh; display: flex; flex-direction: column; }
.phone-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: calc(12px + env(safe-area-inset-top, 0px)) 16px 12px; position: sticky; top: 0; background: var(--bg); z-index: 5; border-bottom: 1px solid var(--line); }
.phone-head .brand { padding: 0; font-size: 16px; }
.phone-body { flex: 1; padding: 16px 16px 100px; display: grid; gap: 14px; align-content: start; }
.tabs { position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; background: var(--surface); border-top: 1px solid var(--line); padding: 6px 8px calc(8px + env(safe-area-inset-bottom, 0px)); }
.tabs .in { max-width: 560px; margin: 0 auto; display: grid; grid-template-columns: repeat(4, 1fr); }
.tabs a { display: grid; justify-items: center; gap: 3px; padding: 6px 0; font-size: 11px; color: var(--muted); text-decoration: none; }
.tabs a.on { color: var(--ink); font-weight: 700; }
.tabs a.scan .pill { background: var(--accent); color: var(--on-accent); border-radius: 999px; padding: 6px 16px; display: grid; place-items: center; }
.tabs a .icon { width: 22px; height: 22px; }
.big { font: 800 23px/1.15 var(--display); font-stretch: 88%; text-wrap: balance; }
.nextcard { border: 2px solid var(--ink); border-radius: 13px; padding: 14px; display: grid; gap: 10px; background: var(--surface); }
.stop { display: grid; grid-template-columns: 26px minmax(0, 1fr) auto; gap: 10px; align-items: center; padding: 11px 12px; border-bottom: 1px solid var(--line); text-decoration: none; background: none; border-left: 0; border-right: 0; border-top: 0; width: 100%; text-align: left; cursor: pointer; font-size: 14px; }
.stop:last-child { border-bottom: 0; }
.stop .n { width: 26px; height: 26px; border-radius: 50%; border: 1.5px solid var(--line2); display: grid; place-items: center; font: 700 12px/1 var(--body); font-variant-numeric: tabular-nums; }
.stop.done { color: var(--muted); } .stop.done .n { background: var(--ok); border-color: var(--ok); color: #fff; }
.stop.skipped { color: var(--muted); text-decoration: line-through; }
.stop.next .n { background: var(--ink); border-color: var(--ink); color: var(--bg); }
.stop .addr { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.asset-head { display: flex; align-items: center; gap: 12px; }
.asset-head .sq { width: 52px; height: 52px; font-size: 15px; border-radius: 11px; }
.scanbox { position: relative; border-radius: 14px; overflow: hidden; background: #000; aspect-ratio: 3 / 4; max-height: 60vh; }
.scanbox video { width: 100%; height: 100%; object-fit: cover; display: block; }
.scanbox .frame { position: absolute; inset: 18%; border: 3px solid #fff; border-radius: 16px; box-shadow: 0 0 0 999px rgba(0,0,0,.35); }

/* Landing + auth pages */
.center-page { max-width: 980px; margin: 0 auto; padding: 28px 20px 60px; display: grid; gap: 28px; }
.land-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.hero { display: grid; gap: 12px; max-width: 640px; padding-top: 18px; }
.hero h1 { font-size: 34px; }
.hero p { font-size: 17px; color: var(--muted); max-width: 56ch; }
.doors { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 14px; }
.door { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 20px; display: grid; gap: 12px; align-content: start; }
.door p { color: var(--muted); font-size: 14px; }
.features { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 18px 26px; }
.features div { display: grid; gap: 4px; } .features p { color: var(--muted); font-size: 14px; }
.narrow { max-width: 460px; margin: 0 auto; width: 100%; }

/* Dialogs + toast */
dialog { border: 1px solid var(--line); border-radius: 14px; padding: 0; background: var(--surface); color: var(--ink); width: min(560px, calc(100% - 24px)); max-height: calc(100% - 40px); box-shadow: 0 20px 60px rgba(0,0,0,.25); }
dialog::backdrop { background: rgba(10, 10, 9, .45); }
dialog .dhead { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 16px 18px 0; }
dialog .dbody { padding: 14px 18px 18px; display: grid; gap: 14px; }
dialog .dfoot { display: flex; justify-content: flex-end; gap: 8px; padding: 0 18px 18px; flex-wrap: wrap; }
@media (max-width: 640px) {
  dialog { width: 100%; max-width: 100%; margin: auto 0 0; border-radius: 16px 16px 0 0; max-height: 92%; }
  dialog .dfoot .btn { flex: 1; }
}
.toast { position: fixed; left: 50%; bottom: calc(86px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 10px; font-size: 14px; z-index: 100; max-width: calc(100% - 32px); box-shadow: 0 8px 24px rgba(0,0,0,.25); }
.toast.bad { background: var(--bad); color: #fff; }
.secret { display: flex; gap: 8px; align-items: center; background: var(--sunk); border-radius: 9px; padding: 10px 12px; font-family: var(--mono); font-size: 15px; overflow-wrap: anywhere; }
.secret span { flex: 1; min-width: 0; }
.loading { padding: 40px; text-align: center; color: var(--muted); }

/* Accent picker */
.accents { display: flex; gap: 10px; flex-wrap: wrap; }
.accents button { width: 40px; height: 40px; border-radius: 50%; border: 3px solid var(--surface); box-shadow: 0 0 0 1px var(--line2); cursor: pointer; }
.accents button.on { box-shadow: 0 0 0 2px var(--ink); }

/* Print tags */
.tags-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.qrtag { border: 1px solid var(--line2); border-radius: 10px; padding: 10px; display: grid; grid-template-columns: 92px 1fr; gap: 10px; align-items: center; background: #fff; color: #111; break-inside: avoid; }
.qrtag img { width: 92px; height: 92px; display: block; }
.qrtag b { font: 800 17px/1.1 var(--mono); }
.qrtag .t { font-size: 11px; line-height: 1.3; }
@media print {
  body { background: #fff; }
  .side, .topbar, .noprint, .tabs { display: none !important; }
  .office { display: block; }
  .main { padding: 0; max-width: none; }
  .tags-grid { gap: 6px; }
  .qrtag { border-color: #999; }
}

@media (max-width: 980px) {
  .split { grid-template-columns: 1fr; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .tags-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 860px) {
  .office { display: block; background: none; }
  .side { display: none; position: fixed; inset: 0 auto 0 0; width: 260px; z-index: 50; box-shadow: 0 0 40px rgba(0,0,0,.3); }
  .office.menu-open .side { display: flex; }
  .office.menu-open::after { content: ""; position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 40; }
  .topbar { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: calc(10px + env(safe-area-inset-top, 0px)) 14px 10px; border-bottom: 1px solid var(--line); background: var(--surface); position: sticky; top: 0; z-index: 30; }
  .topbar .brand { padding: 0; font-size: 16px; }
  .main { padding: 16px 16px 60px; }
  .hide-sm { display: none !important; }
}
@media (max-width: 480px) {
  h1 { font-size: 23px; }
  .hero h1 { font-size: 28px; }
  .tags-grid { grid-template-columns: 1fr; }
  .stat b { font-size: 22px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
