:root {
  --ink: #12202e;
  --ink-2: #44525f;
  --muted: #5d6b78;
  --bg: #f3f5f7;
  --card: #ffffff;
  --line: #d5dbe1;
  --accent: #0a58ca;
  --accent-ink: #ffffff;
  --brand: #f5b400;
  --ok: #0c6b3a;
  --ok-bg: #dff5e8;
  --warn: #7a4b00;
  --warn-bg: #ffecc2;
  --bad: #9b1c1c;
  --bad-bg: #fde3e3;
  --idle-bg: #e6eaee;
  --map-h: 42dvh;
  --topbar-h: 44px;
  --radius: 12px;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --ink: #eef2f6;
    --ink-2: #c6ced6;
    --muted: #9eaab6;
    --bg: #0e151c;
    --card: #17212b;
    --line: #2c3946;
    --accent: #6ea8ff;
    --accent-ink: #0b1622;
    --ok: #7be0a6;
    --ok-bg: #123524;
    --warn: #ffd27a;
    --warn-bg: #3d2c08;
    --bad: #ff9f9f;
    --bad-bg: #431717;
    --idle-bg: #22303d;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--ink);
  background: var(--bg);
}
h2, h3, p { margin: 0; }
h2 { font-size: 1.35rem; line-height: 1.2; }
h3 { font-size: 1rem; margin-top: 18px; margin-bottom: 6px; }
a { color: var(--accent); }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.skip { position: absolute; left: -999px; top: 0; background: var(--card); padding: 8px 12px; z-index: 2000; }
.skip:focus { left: 8px; top: 8px; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

/* ---------- top bar ---------- */
.topbar {
  height: var(--topbar-h);
  padding: 0 12px;
  padding-left: max(12px, env(safe-area-inset-left));
  padding-right: max(12px, env(safe-area-inset-right));
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  background: #12202e; color: #fff;
}
.brand { display: flex; align-items: center; gap: 8px; }
.brand-name { font-weight: 700; font-size: 1.1rem; letter-spacing: .2px; }
.brand-note { font-size: .7rem; color: #c3ccd6; text-align: right; line-height: 1.2; }

/* ---------- layout ---------- */
.mapwrap {
  position: sticky; top: 0; z-index: 500;
  height: var(--map-h); min-height: 240px;
  background: #cfd6dc;
  border-bottom: 1px solid var(--line);
}
#map { position: absolute; inset: 0; }
.panel { min-width: 0; }
.tabpanel { padding: 14px; padding-left: max(14px, env(safe-area-inset-left)); padding-right: max(14px, env(safe-area-inset-right)); }

@media (min-width: 900px) {
  body { height: 100dvh; overflow: hidden; }
  .layout { display: grid; grid-template-columns: 430px 1fr; height: calc(100dvh - var(--topbar-h)); }
  .mapwrap { grid-column: 2; grid-row: 1; height: auto; position: relative; border-bottom: 0; border-left: 1px solid var(--line); }
  .panel { grid-column: 1; grid-row: 1; overflow-y: auto; }
  .tabs { top: 0 !important; }
}

/* ---------- map overlays ---------- */
.chip {
  position: absolute; left: 10px; top: 10px; z-index: 600; max-width: calc(100% - 84px);
  padding: 7px 11px; border-radius: 10px; font-weight: 650; font-size: .92rem; line-height: 1.25;
  box-shadow: 0 1px 6px rgba(0,0,0,.3);
  border: 2px solid transparent;
}
.chip small { display: block; font-weight: 500; font-size: .78rem; }
.chip-idle { background: var(--idle-bg); color: var(--ink); border-color: var(--line); }
.chip-inside { background: var(--ok-bg); color: var(--ok); border-color: var(--ok); }
.chip-outside { background: var(--bad-bg); color: var(--bad); border-color: var(--bad); }
.chip-uncertain { background: var(--warn-bg); color: var(--warn); border-color: var(--warn); }

.mapbtns { position: absolute; right: 10px; top: 10px; z-index: 600; display: flex; flex-direction: column; gap: 8px; }
.mapbtn {
  width: 52px; min-height: 52px; padding: 5px 2px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--card); color: var(--ink); font: inherit; font-size: .68rem; font-weight: 600;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px;
  box-shadow: 0 1px 5px rgba(0,0,0,.25); cursor: pointer;
}
.mapbtn[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.mapbtn:disabled { opacity: .5; cursor: default; }
.pickbanner {
  position: absolute; left: 10px; right: 10px; bottom: 26px; z-index: 600;
  background: #12202e; color: #fff; padding: 9px 12px; border-radius: 10px;
  display: flex; align-items: center; justify-content: space-between; gap: 10px; font-weight: 600;
}
.leaflet-container { font: inherit; background: #cfd6dc; }
.leaflet-container.picking { cursor: crosshair; }

.gps-dot { width: 18px; height: 18px; border-radius: 50%; background: #1a73e8; border: 3px solid #fff; box-shadow: 0 0 0 1px rgba(0,0,0,.35), 0 1px 4px rgba(0,0,0,.4); }
.gps-dot.stale { background: #8a97a5; }
.stop-pin {
  width: 28px; height: 28px; border-radius: 50% 50% 50% 4px; transform: rotate(-45deg);
  background: #5b2a86; border: 2px solid #fff; box-shadow: 0 1px 4px rgba(0,0,0,.45);
  display: flex; align-items: center; justify-content: center;
}
.stop-pin span { transform: rotate(45deg); color: #fff; font-weight: 700; font-size: 12px; }
.stop-pin.start { background: #0c6b3a; }
.stop-pin.end { background: #9b1c1c; }
.area-pin { width: 16px; height: 16px; background: #c2410c; border: 3px solid #fff; transform: rotate(45deg); box-shadow: 0 1px 4px rgba(0,0,0,.45); }

/* ---------- tabs ---------- */
.tabs {
  position: sticky; top: max(var(--map-h), 240px); z-index: 400;
  display: grid; grid-template-columns: repeat(4, 1fr);
  background: var(--card); border-bottom: 1px solid var(--line);
}
.tabs button {
  appearance: none; border: 0; background: none; color: var(--ink-2); font: inherit; font-weight: 600; font-size: .92rem;
  padding: 13px 4px 10px; border-bottom: 3px solid transparent; cursor: pointer; min-height: 48px;
}
.tabs button[aria-selected="true"] { color: var(--accent); border-bottom-color: var(--accent); }

/* ---------- forms & buttons ---------- */
label { display: block; font-weight: 600; font-size: .9rem; margin: 10px 0 4px; }
input[type="text"], input[type="password"], input[type="date"], select {
  width: 100%; min-height: 46px; padding: 9px 11px; font: inherit; font-size: 16px; /* 16px stops iOS zoom */
  color: var(--ink); background: var(--card); border: 1.5px solid var(--line); border-radius: 10px;
}
.row-form { margin-bottom: 12px; }
.row-form > label:first-child { margin-top: 0; }
.inline { display: flex; gap: 8px; }
.inline input { flex: 1; min-width: 0; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.btn {
  appearance: none; min-height: 44px; padding: 9px 14px; border-radius: 10px; border: 1.5px solid var(--line);
  background: var(--card); color: var(--ink); font: inherit; font-weight: 600; cursor: pointer; text-decoration: none;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; white-space: nowrap;
}
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-danger { color: var(--bad); border-color: var(--bad); }
.btn-small { min-height: 38px; padding: 6px 11px; font-size: .88rem; }
.btn:disabled { opacity: .5; cursor: default; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0; }
.actions.tight { margin: 8px 0 0; }
.filebtn { position: relative; overflow: hidden; margin: 0; }
.filebtn input { position: absolute; inset: 0; opacity: 0; cursor: pointer; font-size: 0; }
.filebtn:focus-within { outline: 3px solid var(--accent); outline-offset: 2px; }

.msg { margin-top: 8px; padding: 9px 11px; border-radius: 10px; background: var(--bad-bg); color: var(--bad); font-weight: 600; font-size: .92rem; }
.msg.info { background: var(--idle-bg); color: var(--ink); }
.status { margin: 10px 0; font-size: .92rem; color: var(--ink-2); }
.muted { color: var(--muted); }
.small { font-size: .82rem; }
.empty { color: var(--muted); padding: 6px 0 10px; }
.notice { margin: 12px 0; padding: 10px 12px; border-radius: 10px; background: var(--idle-bg); font-size: .88rem; color: var(--ink-2); }
.notice-strong { background: var(--warn-bg); color: var(--warn); margin-top: 0; }
.lead-in { margin-bottom: 10px; }
.pre { white-space: pre-wrap; overflow-wrap: anywhere; }

/* ---------- ticket card ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; margin-bottom: 14px; }
.card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.eyebrow { font-size: .72rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.card h2 { font-variant-numeric: tabular-nums; letter-spacing: .02em; }
.lead { font-weight: 650; font-size: 1.05rem; margin-top: 4px; }
.badge { padding: 4px 9px; border-radius: 999px; font-size: .78rem; font-weight: 700; white-space: nowrap; background: var(--idle-bg); }
.badge.expired { background: var(--bad-bg); color: var(--bad); }
.badge.active { background: var(--ok-bg); color: var(--ok); }
.fields { margin: 4px 0 0; display: grid; grid-template-columns: minmax(96px, 34%) 1fr; }
.fields dt, .fields dd { margin: 0; padding: 8px 0; border-top: 1px solid var(--line); }
.fields dt { color: var(--muted); font-size: .86rem; padding-right: 10px; }
.fields dd { font-weight: 550; overflow-wrap: anywhere; }
.fields dd small { display: block; font-weight: 500; color: var(--muted); }
.contacts { display: grid; gap: 8px; margin-top: 12px; }
.contact { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 10px; background: var(--bg); }
.contact .who small { display: block; color: var(--muted); font-size: .76rem; text-transform: uppercase; letter-spacing: .06em; font-weight: 700; }
.more { margin-top: 14px; }
.more summary { cursor: pointer; font-weight: 600; padding: 6px 0; }
.source { margin-top: 14px; font-size: .92rem; }
.qr { display: flex; justify-content: center; padding: 14px; background: #fff; border-radius: 10px; margin: 12px 0; }
.qr img, .qr canvas { max-width: 100%; height: auto; }

/* ---------- lists ---------- */
.results, .stops { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.result { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 11px 12px; }
.result-head { display: flex; justify-content: space-between; gap: 10px; align-items: baseline; }
.result-head strong { font-variant-numeric: tabular-nums; }
.dist { font-size: .82rem; font-weight: 700; padding: 3px 8px; border-radius: 999px; background: var(--idle-bg); white-space: nowrap; }
.dist.sel { background: var(--warn-bg); color: var(--warn); }
.choices { display: grid; gap: 6px; margin-top: 8px; }
.choices button { text-align: left; white-space: normal; justify-content: flex-start; }
.choices p { font-size: .86rem; color: var(--muted); }

.list-title { margin-top: 16px; }
.endpoints { display: grid; gap: 8px; margin-top: 4px; }
.endpoint { display: flex; gap: 10px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; }
.endpoint-body { min-width: 0; flex: 1; overflow-wrap: anywhere; }
.pin { flex: none; width: 28px; height: 28px; border-radius: 50%; color: #fff; font-weight: 700; font-size: .85rem; display: flex; align-items: center; justify-content: center; background: #5b2a86; }
.pin-start { background: #0c6b3a; }
.pin-end { background: #9b1c1c; }
.stop {
  display: grid; grid-template-columns: 36px 28px 1fr; gap: 8px; align-items: center;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 8px 10px 8px 4px;
}
.stop.dragging { opacity: .85; box-shadow: 0 6px 18px rgba(0,0,0,.3); border-color: var(--accent); position: relative; z-index: 2; }
.stop-handle {
  width: 36px; height: 48px; border: 0; background: none; color: var(--muted); cursor: grab; touch-action: none;
  display: flex; align-items: center; justify-content: center; border-radius: 8px;
}
.stop-body { min-width: 0; }
.stop-title { font-weight: 650; overflow-wrap: anywhere; }
.stop-sub { font-size: .8rem; color: var(--muted); overflow-wrap: anywhere; }
.stop-actions { grid-column: 2 / -1; display: flex; flex-wrap: wrap; gap: 6px; }
.stop-actions .btn { min-height: 38px; min-width: 40px; padding: 5px 9px; font-size: .84rem; }
.navlinks ul { padding-left: 18px; margin: 6px 0; }
.navlinks li { margin: 6px 0; }
.plain { padding-left: 18px; margin: 8px 0; }
.plain li { margin: 8px 0; }

.footer { text-align: center; color: var(--muted); font-size: .86rem; padding: 18px 12px calc(20px + env(safe-area-inset-bottom)); }

.toast {
  position: fixed; left: 50%; bottom: calc(18px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 3000;
  background: #12202e; color: #fff; padding: 10px 16px; border-radius: 999px; font-weight: 600; font-size: .92rem;
  box-shadow: 0 4px 16px rgba(0,0,0,.35); max-width: calc(100vw - 32px); text-align: center;
}

@media (max-width: 420px) {
  .brand-note { font-size: .62rem; max-width: 150px; }
}
@media (prefers-reduced-motion: no-preference) {
  .btn, .mapbtn { transition: background-color .12s, border-color .12s; }
}

.leaflet-control-attribution, .leaflet-control-scale-line { font-size: 11px; }
.leaflet-tooltip { font-size: 12px; }


/* ---------- utilities notified ---------- */
.utils, .history { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.util { padding: 9px 12px; border-radius: 10px; background: var(--bg); border-left: 4px solid var(--line); }
.util.pending { background: var(--warn-bg); border-left-color: var(--warn); }
.util.pending .util-status { color: var(--warn); font-weight: 700; }
.util-name { font-weight: 650; overflow-wrap: anywhere; }
.util-status { font-size: .92rem; }
.history li { padding: 8px 0; border-top: 1px solid var(--line); overflow-wrap: anywhere; }
#tUtilsWrap .status { margin: 4px 0 8px; }



/* ---------- tap-the-map popup ---------- */
.tap-box { display: grid; gap: 10px; min-width: 220px; font-size: 14px; color: #12202e; }
.tap-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.tap-row small { display: block; font-size: 11px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: #5d6b78; }
.tap-row .tap-note { text-transform: none; letter-spacing: 0; font-weight: 500; margin-top: 2px; }
.tap-value { font-weight: 650; overflow-wrap: anywhere; user-select: all; -webkit-user-select: all; }
.tap-box .btn { background: #fff; color: #12202e; border-color: #d5dbe1; flex: none; }
.leaflet-popup-content { margin: 12px 14px; }

.btn[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }

/* Search-by-ticket-number block on the Ticket Search tab: a thin outline in the logo's yellow sets it apart from the area search below. */
.ticket-lookup { border: 1.5px solid var(--brand); border-radius: var(--radius); padding: 12px; margin-bottom: 16px; }
.ticket-lookup > :last-child { margin-bottom: 0; }
/* Ticket Bucket: a ticket's name can be tapped to open it in place; the open one is outlined in the logo's yellow. */
.stop-open { cursor: pointer; }
.stop-open .stop-title { text-decoration: underline; text-underline-offset: 3px; }
.stop.selected { outline: 1.5px solid var(--brand); outline-offset: 2px; border-radius: 10px; }
/* A bucket button whose ticket is already in the Ticket Bucket. */
.btn.in-bucket { background: var(--ok-bg); color: var(--ok); border-color: var(--ok); }
/* Ticket Bucket: a stop ticked off as done is greyed out, in the list and on the map. */
.stop.done .pin, .stop.done .stop-body { opacity: .55; }
.stop.done .stop-title { text-decoration: line-through; }
.stop-pin.done { filter: grayscale(1); opacity: .6; }
/* Ticket Bucket: each ticket's utility responses, under its address. */
.stop-status { font-size: .82rem; margin-top: 3px; overflow-wrap: anywhere; }
.stop-status.all-clear { color: var(--ok); font-weight: 650; }
.stop-status .badge { margin-right: 6px; }
/* Ticket Bucket: the opened ticket's details, expanded under its row. */
.stop-detail { list-style: none; margin: 8px 0 14px; }

/* "Louisiana" beside the TicketRunner name: the state this edition covers. */
@font-face {
  font-family: "Kaushan Script";
  src: url("/vendor/kaushan-script-latin.woff2") format("woff2");
  font-weight: 400; font-style: normal; font-display: swap;
}
.brand-state { font-family: "Kaushan Script", "Segoe Script", "Brush Script MT", cursive; font-size: 1.35rem; line-height: 1; color: #e23a3a; margin-left: -1px; }
/* Ticket card: the badge and the "Remove ticket" button sit together at the top right. */
.card-head-side { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
/* Address popup: the credit for the address service, shown with a looked-up address. */
.tap-row .tap-credit a { color: #0a58ca; }
/* Ticket Bucket: the order number is the thing to read at a glance, in the list and on the map.
   Both use the logo's yellow with a dark number so a pin and its row are easy to match up. */
.stop .pin {
  width: 40px; height: 40px; font-size: 1.25rem; font-weight: 800;
  background: var(--brand); color: #12202e; border: 2px solid #12202e;
}
.stop-pin {
  width: 38px; height: 38px; background: var(--brand); border: 2px solid #12202e;
  box-shadow: 0 2px 6px rgba(0,0,0,.5);
}
.stop-pin span { color: #12202e; font-weight: 800; font-size: 17px; }
/* Ticket Search results: a row can be tapped to pick its ticket. The picked row is outlined in the same red as its shape on the map. */
.result { cursor: pointer; }
.result.selected { border-color: #dc2626; box-shadow: 0 0 0 1px #dc2626; }
.result-detail { margin-top: 12px; cursor: auto; }
.result-detail .card { margin-bottom: 0; }

/* ---------- polish: bucket rows, compact search form, phone tab names ---------- */
.stop-more { grid-column: 2 / -1; display: flex; flex-wrap: wrap; gap: 6px; }
.stop-more[hidden] { display: none; }
.stop-more .btn { min-height: 38px; min-width: 40px; padding: 5px 9px; font-size: .84rem; }

/* Radius, Utility and Response: radius on its own line on phones, all three side by side on a computer. */
.grid3 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 10px; }
.grid3 > div { min-width: 0; }
.grid3-first { grid-column: 1 / -1; }

.tabs button { white-space: nowrap; }
@media (max-width: 520px) {
  .tab-wide { display: none; }
}

@media (min-width: 900px) {
  /* Mouse-sized controls, so the whole search form and its Search button fit a laptop screen without scrolling. */
  .panel input[type="text"], .panel input[type="date"], .panel select { min-height: 38px; padding: 6px 9px; font-size: 15px; }
  .panel .btn { min-height: 38px; padding: 6px 12px; }
  .panel label { margin: 7px 0 3px; }
  .panel .row-form { margin-bottom: 8px; }
  .panel .actions { margin: 9px 0; }
  .panel .actions.tight { margin: 6px 0 0; }
  .tabpanel { padding-top: 10px; }
  .grid3 { grid-template-columns: 1fr 1.25fr 1fr; }
  .grid3-first { grid-column: auto; }
  #areaDateHint { margin: 3px 0 0; }
  .ticket-lookup { margin-bottom: 8px; }
  .tabs button { min-height: 42px; padding: 10px 4px 8px; }
}
