/* ==========================================================================
 * Stopflow — professional B2B theme (deep navy + teal + aqua)
 * STOPFLOW rebrand spec, §§2-3. Dark theme; system font stack only.
 * Restrained surfaces — no neon glows, no webfonts.
 * ========================================================================== */
/* The hidden attribute must always win over display rules. */
[hidden] { display: none !important; }
:root {
  /* Stopflow brand tokens (required by spec) */
  --sf-navy: #0B1B33;
  --sf-teal: #0E7C7B;
  --sf-aqua: #2DD4BF;
  --sf-ink: #E8F1F2;
  --sf-muted: #8AA0B4;
  --sf-ok: #34D399;
  --sf-warn: #FBBF24;
  --sf-late: #F87171;
  /* Derived surfaces (navy scale) */
  --sf-navy-2: #10243F;   /* page depth */
  --sf-card: #13294A;     /* cards */
  --sf-card-2: #18324F;   /* raised surfaces / inputs */
  --sf-card-3: #1F3A5C;   /* pressed / active */
  --sf-line: #213B5E;     /* hairline borders */
  --sf-line-2: #2C4C78;   /* stronger borders */
  --sf-faint: #5E7A96;    /* placeholder text */
  --sf-teal-deep: #0A5B5A;/* darker teal for gradients */
  --sf-teal-soft: #149089;/* lighter teal for gradients */
  --sf-teal-dim: rgba(14, 124, 123, .16);
  --sf-aqua-dim: rgba(45, 212, 191, .10);
  --sf-ok-dim: rgba(52, 211, 153, .12);
  --sf-warn-dim: rgba(251, 191, 36, .12);
  --sf-late-dim: rgba(248, 113, 113, .12);

  /* Backwards-compatible aliases (old theme var names → Stopflow tokens).
     Kept so any other consumer of these names needs no change. */
  --bg: var(--sf-navy);
  --bg2: var(--sf-navy-2);
  --card: var(--sf-card);
  --card2: var(--sf-card-2);
  --card3: var(--sf-card-3);
  --line: var(--sf-line);
  --line2: var(--sf-line-2);
  --text: var(--sf-ink);
  --text-dim: var(--sf-muted);
  --dim: var(--sf-muted);
  --faint: var(--sf-faint);
  --border: var(--sf-line);
  --accent: var(--sf-teal);
  --accent2: var(--sf-teal-soft);
  --accent-dim: var(--sf-teal-dim);
  --green: var(--sf-ok);
  --green-dim: var(--sf-ok-dim);
  --amber: var(--sf-warn);
  --amber-dim: var(--sf-warn-dim);
  --red: var(--sf-late);
  --red-dim: var(--sf-late-dim);

  --radius: 16px;
  --radius-s: 12px;
  --shadow: 0 8px 24px rgba(0, 0, 0, .35);
  --shadow-s: 0 2px 8px rgba(0, 0, 0, .25);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--sf-navy); color: var(--sf-ink);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  padding-bottom: 96px; /* room for action bar */
  min-height: 100vh; min-height: 100dvh;
  touch-action: manipulation; /* no double-tap zoom delay */
  -webkit-text-size-adjust: 100%;
  -webkit-font-smoothing: antialiased;
  line-height: 1.45;
}

/* iOS Safari auto-zooms when a focused form control is < 16px.
   Keep every text-like control at 16px minimum. */
input[type=text], input[type=time], input[type=number], input:not([type]), select, textarea { font-size: 16px; }

/* Header */
#topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; justify-content: space-between; align-items: center;
  padding: calc(12px + env(safe-area-inset-top)) 16px 12px;
  background: rgba(11, 27, 51, .88); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--sf-line);
}
/* Brand lockup: S-mark img + "Stopflow" wordmark + (optional) tagline */
.brand { display: flex; align-items: center; gap: 11px; min-width: 0; }
.logo {
  width: 44px; height: 44px; display: flex; align-items: center; justify-content: center;
  border-radius: 13px; overflow: hidden; box-shadow: var(--shadow-s); flex-shrink: 0;
  background: var(--sf-navy-2); border: 1px solid var(--sf-line);
}
.logo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.brand h1 { margin: 0; font-size: 21px; font-weight: 700; letter-spacing: .2px; color: var(--sf-ink); }
.brand p { margin: 1px 0 0; font-size: 12px; color: var(--sf-muted); font-weight: 500; }
.top-right { display: flex; align-items: center; gap: 8px; }
#progressWrap { position: relative; width: 44px; height: 44px; }
#progressText {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  font-size: 10px; font-weight: 700;
}
.icon-btn {
  background: var(--sf-card-2); color: var(--sf-ink); border: 1px solid var(--sf-line);
  border-radius: 13px; width: 44px; height: 44px; font-size: 19px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background .15s, border-color .15s, transform .1s;
}
.icon-btn:active { transform: scale(.94); background: var(--sf-card-3); }

main { padding: 14px 14px 0; max-width: 640px; margin: 0 auto; }
.card {
  background: var(--sf-card); border: 1px solid var(--sf-line);
  border-radius: var(--radius); padding: 14px; margin-bottom: 14px;
  box-shadow: var(--shadow-s);
}

/* --------------------------------------------------------------------------
 * Today's Route dashboard card (spec §3 — markup built by dashboard agent)
 * .sf-dash card → .sf-dash-title, .sf-dash-stats row of .sf-dash-stat
 * (big .sf-dash-num + small-caps .sf-dash-label)
 * -------------------------------------------------------------------------- */
.sf-dash {
  background: var(--sf-card); border: 1px solid var(--sf-line);
  border-radius: var(--radius); padding: 16px; margin-bottom: 14px;
  box-shadow: var(--shadow-s);
}
.sf-dash-title {
  margin: 0 0 12px; font-size: 13px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .08em; color: var(--sf-muted);
}
.sf-dash-stats {
  display: flex; gap: 8px;
}
.sf-dash-stat {
  flex: 1; min-width: 0; text-align: center;
  background: var(--sf-card-2); border: 1px solid var(--sf-line);
  border-radius: var(--radius-s); padding: 12px 8px;
}
.sf-dash-num {
  font-size: 24px; font-weight: 800; color: var(--sf-ink);
  font-variant-numeric: tabular-nums; line-height: 1.2;
}
.sf-dash-num.aqua { color: var(--sf-aqua); }
.sf-dash-label {
  margin-top: 4px; font-size: 10px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .08em; color: var(--sf-muted);
}

/* Origin */
.origin-btn {
  width: 100%; display: flex; align-items: center; gap: 10px;
  background: none; border: none; color: var(--sf-ink); padding: 2px; cursor: pointer; text-align: left;
}
.origin-pin { font-size: 24px; color: var(--sf-aqua); }
.origin-text { flex: 1; display: flex; flex-direction: column; }
.origin-text small { color: var(--sf-muted); font-size: 11px; letter-spacing: 1px; }
#originLabel { font-size: 16px; font-weight: 600; }
.origin-edit { font-size: 18px; opacity: .7; }

/* Add stops */
#searchWrap { position: relative; }
#searchInput {
  width: 100%; padding: 15px 16px; font-size: 16px; border-radius: var(--radius-s);
  border: 1px solid var(--sf-line); background: var(--sf-card-2); color: var(--sf-ink);
  transition: border-color .15s, box-shadow .15s;
}
#searchInput:focus {
  outline: none; border-color: var(--sf-teal);
  box-shadow: 0 0 0 3px var(--sf-teal-dim);
}
#searchInput::placeholder { color: var(--sf-faint); }
#suggestList {
  position: absolute; top: 100%; left: 0; right: 0; z-index: 30;
  list-style: none; margin: 6px 0 0; padding: 6px;
  background: var(--sf-card-2); border: 1px solid var(--sf-line); border-radius: 12px;
  max-height: 260px; overflow-y: auto;
}
#suggestList li { padding: 12px; border-radius: 8px; font-size: 15px; cursor: pointer; }
#suggestList li:active { background: var(--sf-teal); }
#suggestList li small { display: block; color: var(--sf-muted); font-size: 12px; }
/* Universal address dropdown (attachAddressDropdown) — shared styles */
.dd-list {
  position: absolute; top: 100%; left: 0; right: 0; z-index: 40;
  list-style: none; margin: 6px 0 0; padding: 6px;
  background: var(--sf-card-2); border: 1px solid var(--sf-line); border-radius: 12px;
  max-height: 280px; overflow-y: auto;
  box-shadow: 0 8px 24px rgba(0,0,0,.45);
}
.dd-list li { padding: 12px; border-radius: 8px; font-size: 15px; cursor: pointer; }
.dd-list li:active, .dd-list li.active { background: var(--sf-teal); color: #fff; }
.dd-list li small { display: block; color: var(--sf-muted); font-size: 12px; }
.dd-list li.active small { color: #e6fffa; }
.dd-list li.dd-head {
  font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em;
  color: var(--sf-muted); padding: 8px 12px 4px; cursor: default; background: none;
}
/* Item 1 (2026-10-05): the Set-location chooser's saved list lives directly
 * inside the sheet (no relative input wrapper), so the dropdown's absolute
 * positioning would hang it off the bottom of the viewport. In-flow here. */
#setSheet #setSavedList { position: static; }
/* Star save toggle */
.star-btn {
  background: none; border: 0; font-size: 18px; cursor: pointer;
  padding: 6px; line-height: 1; opacity: .55;
}
.star-btn.on { opacity: 1; color: var(--sf-warn); }
.star-btn:active { transform: scale(1.2); }
/* Saved locations settings list */
.saved-list { list-style: none; margin: 8px 0 0; padding: 0; }
.saved-list .saved-row {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 4px; border-bottom: 1px solid var(--sf-line);
}
.saved-list .saved-star { font-size: 18px; }
.saved-list .info { flex: 1; min-width: 0; }
.saved-list .addr { font-size: 15px; font-weight: 600; }
.saved-list .meta { margin-top: 2px; }
.saved-list .acts { display: flex; gap: 4px; }
.saved-list .acts button {
  background: none; border: 0; font-size: 16px; cursor: pointer; padding: 6px;
}
/* Pinned start/end rows */
.endpoint-row { border-left: 3px solid var(--sf-teal); }
.endpoint-row.end-row { border-left-color: var(--sf-ok); }
.endpoint-row .num { font-size: 18px; }
.endpoint-editor { padding: 10px 12px; display: flex; flex-direction: column; gap: 8px; }
.endpoint-editor .dd-wrap { position: relative; }
.endpoint-editor input[type="text"] { width: 100%; }
#setStartSuggest, #setEndSuggest {
  position: absolute; top: 100%; left: 0; right: 0; z-index: 30;
  list-style: none; margin: 6px 0 0; padding: 6px;
  background: var(--sf-card-2); border: 1px solid var(--sf-line); border-radius: 12px;
  max-height: 260px; overflow-y: auto;
}
#setStartSuggest li, #setEndSuggest li { padding: 12px; border-radius: 8px; font-size: 15px; cursor: pointer; }
#setStartSuggest li:active, #setEndSuggest li:active { background: var(--sf-teal); }
#setStartSuggest li small, #setEndSuggest li small { display: block; color: var(--sf-muted); font-size: 12px; }
.add-btns { display: flex; gap: 8px; margin-top: 10px; }
.add-btns .btn { flex: 1; }

#manualForm { margin-top: 10px; display: flex; flex-direction: column; gap: 8px; }
#manualForm[hidden] { display: none; }
#manualForm input {
  padding: 13px 14px; font-size: 16px; border-radius: var(--radius-s);
  border: 1px solid var(--sf-line); background: var(--sf-card-2); color: var(--sf-ink);
  transition: border-color .15s, box-shadow .15s;
}
#manualForm input:focus {
  outline: none; border-color: var(--sf-teal);
  box-shadow: 0 0 0 3px var(--sf-teal-dim);
}
#manualForm input::placeholder { color: var(--sf-faint); }
.mrow { display: flex; gap: 8px; }
.mrow input { min-width: 0; } /* inputs refuse to shrink below intrinsic width otherwise */
.mrow #mCity { flex: 2; } .mrow #mState { flex: 0 0 56px; } .mrow #mZip { flex: 1; }

/* Buttons */
.btn {
  border: 1px solid var(--sf-line); background: var(--sf-card-2); color: var(--sf-ink);
  border-radius: var(--radius-s); padding: 13px 16px; font-size: 16px; font-weight: 600;
  cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  -webkit-user-select: none; user-select: none;
  transition: transform .1s, background .15s, border-color .15s, box-shadow .15s;
}
.btn:active { transform: scale(.97); }
.btn.primary {
  background: linear-gradient(135deg, var(--sf-teal-soft), var(--sf-teal) 60%, var(--sf-teal-deep));
  border-color: transparent; color: #fff;
  box-shadow: 0 4px 16px rgba(14, 124, 123, .35);
}
.btn.primary:active { box-shadow: 0 2px 8px rgba(14, 124, 123, .3); }
.btn.secondary span { font-size: 14px; }
.btn.ghost { background: none; padding: 10px 14px; font-size: 14px; }
.btn.danger { background: var(--sf-late-dim); border-color: rgba(248, 113, 113, .3); color: var(--sf-late); width: 100%; margin-top: 12px; }
.btn:disabled { opacity: .45; }

/* Side-by-side popup buttons */
.btn-row { display: flex; gap: 10px; margin-top: 14px; }
.btn-row .btn { flex: 1; }

/* Install gate steps */
.install-steps { margin: 12px 0 4px; padding-left: 22px; color: var(--sf-ink); font-size: 15px; line-height: 1.5; }
.install-steps li { margin-bottom: 10px; }

/* Status line */
.status-line { text-align: center; font-size: 13px; color: var(--sf-muted); margin: 2px 0 10px; min-height: 18px; }
.status-line.warn { color: var(--sf-warn); }
.status-line.ok { color: var(--sf-ok); }

/* Stop list */
.list-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.list-head h2 { margin: 0; font-size: 17px; font-weight: 700; letter-spacing: .2px; }
#stopList { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.stop {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  background: var(--sf-card-2); border: 1px solid var(--sf-line); border-radius: var(--radius-s); padding: 12px;
  box-shadow: var(--shadow-s);
  transition: border-color .15s, transform .15s;
}
.stop .num {
  flex: 0 0 32px; height: 32px; border-radius: 50%;
  background: linear-gradient(135deg, var(--sf-teal-soft), var(--sf-teal));
  color: #fff; font-weight: 800; font-size: 14px;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 2px 8px rgba(14, 124, 123, .3);
}
.stop.is-last .num { background: #000; border: 2px dashed rgba(255,255,255,.7); box-shadow: none; }
.stop.is-first .num { background: linear-gradient(135deg, #16a34a, #15803d); border: none; box-shadow: 0 2px 8px rgba(52, 211, 153, .25); }
.stop .info { flex: 1 1 180px; min-width: 0; }
.stop .acts { margin-left: auto; }
.stop .addr { font-size: 15px; font-weight: 650; line-height: 1.3; letter-spacing: .1px; }
.stop .meta { font-size: 12px; color: var(--sf-muted); margin-top: 5px; display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.chip {
  background: var(--sf-teal-dim); color: var(--sf-aqua); border: 1px solid rgba(45, 212, 191, .25);
  border-radius: 20px; padding: 3px 10px; font-size: 11px; font-weight: 600; letter-spacing: .2px;
}
.chip.warn { background: var(--sf-warn-dim); color: var(--sf-warn); border-color: rgba(251, 191, 36, .25); }
.chip.last { background: rgba(0,0,0,.4); color: #fff; border: 1px dashed rgba(255,255,255,.5); }
.chip.first { background: var(--sf-ok-dim); color: var(--sf-ok); border: 1px solid rgba(52, 211, 153, .3); }
.chip.confirm { background: var(--sf-teal-dim); color: #b8f0e5; border-color: rgba(14, 124, 123, .4); }
.chip.eta { background: rgba(45, 212, 191, .10); color: var(--sf-aqua); border-color: rgba(45, 212, 191, .25); }
.chip.drive { background: rgba(45, 212, 191, .08); color: #9fe8da; border-color: rgba(45, 212, 191, .2); }
.chip.late { background: var(--sf-late-dim); color: var(--sf-late); border-color: rgba(248, 113, 113, .3); }
.drive-summary {
  display: flex; gap: 12px; align-items: center; justify-content: center;
  padding: 8px 16px; margin: 0 0 8px; font-size: 13px; color: var(--sf-muted);
  background: var(--sf-card); border: 1px solid var(--sf-line); border-radius: 12px;
}
.drive-summary[hidden] { display: none !important; }
.drive-summary strong { color: var(--sf-ink); font-weight: 600; }
.stop .acts { display: flex; gap: 2px; align-items: center; }
.stop .acts button:not(.pill) {
  background: none; border: none; font-size: 20px; padding: 10px 8px; cursor: pointer; color: var(--sf-ink);
  min-width: 44px; min-height: 44px; /* thumb-sized tap targets */
  -webkit-user-select: none; user-select: none;
}
/* pill buttons inside .acts keep a real button face (accent border, pill
   background from .pill/.pill.set-btn) plus the 44px thumb target the reset
   rule used to give them */
.stop .acts button.pill {
  min-width: 44px; min-height: 44px;
  padding: 10px 16px; font-size: 13px; cursor: pointer;
  -webkit-user-select: none; user-select: none;
}
.stop .drag {
  cursor: grab; color: var(--sf-muted); font-size: 18px; padding: 8px 4px; touch-action: none;
  min-height: 44px; display: flex; align-items: center;
  -webkit-user-select: none; user-select: none;
}
.stop.done { opacity: .55; }
.stop.done .addr { text-decoration: line-through; }
.stop.done .num { background: linear-gradient(135deg, #10b981, #059669); box-shadow: none; }
.check-btn { font-size: 24px !important; transition: transform .1s; }
.check-btn:active { transform: scale(1.15); }
.check-btn.on { color: var(--sf-ok); }
.confirm-btn.on { color: var(--sf-warn); }
li.stop.confirmed { border-left: 3px solid var(--sf-warn); }
.pill {
  background: none; border: 1px solid var(--sf-line-2); color: var(--sf-muted);
  border-radius: 20px; padding: 5px 12px; font-size: 11px; font-weight: 600; cursor: pointer;
  transition: border-color .15s, color .15s;
}
.pill.checkin.on { border-color: var(--sf-ok); color: var(--sf-ok); background: var(--sf-ok-dim); }
.pill.set-btn { border-color: var(--sf-teal); color: var(--sf-aqua); }
.return-row { border-style: dashed; opacity: .85; }
/* built-in beginning/ending rows: visually distinct from appointment stops */
li.endpoint-row { border-style: dashed; }
li.endpoint-row .num { color: var(--sf-aqua); }
/* endpoint rows: the set button is centered in the row; star/✕ stay pinned at
   the row's right edge. .acts wraps to its own full-width line so the
   centered button can't overlap the address label on 360px screens. */
.endpoint-row .acts {
  flex: 1 1 100%;
  margin-left: 0;
  margin-top: 2px;
  justify-content: center;
  position: relative;
}
.endpoint-row .star-btn,
.endpoint-row [data-act="clear-endpoint"] {
  position: absolute;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
}

/* time-window popup */
.win-times { display: flex; gap: 12px; margin: 12px 0 16px; }
.win-times label { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--sf-muted); }
.win-times input[type="time"] {
  font-size: 17px; padding: 10px; border-radius: 10px;
  border: 1px solid var(--sf-line); background: var(--sf-card-2); color: var(--sf-ink);
}
#winAddr { font-size: 14px; font-weight: 600; color: var(--sf-ink); margin: 0 0 4px; }

/* at-risk warning */
.risk-list { list-style: none; margin: 0 0 12px; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.risk-list li { background: var(--sf-card-2); border-radius: 10px; padding: 10px 12px; }
.risk-list .addr { font-size: 14px; font-weight: 600; }
.risk-list .meta { font-size: 12px; color: var(--sf-muted); margin-top: 4px; }

/* service-time settings */
.set-sec { border-top: 1px solid var(--sf-line); margin-top: 14px; padding-top: 12px; }
.set-sec h3 { margin: 0 0 8px; font-size: 15px; }
.svc-row { display: flex; align-items: center; gap: 8px; padding: 6px 0; }
.svc-row .svc-name { flex: 1; font-size: 13px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.svc-row .svc-name small { color: var(--sf-muted); }
.svc-row select, .set-row select {
  font-size: 16px; padding: 8px; border-radius: 10px; /* 16px: no iOS auto-zoom */
  border: 1px solid var(--sf-line); background: var(--sf-card-2); color: var(--sf-ink);
}
button.link { background: none; border: none; color: var(--sf-aqua); font-size: 13px; cursor: pointer; padding: 8px; }
#emptyHint { color: var(--sf-muted); font-size: 14px; text-align: center; padding: 18px 8px; margin: 0; }

/* Map */
#mapWrap { margin-bottom: 8px; }
#map { height: 300px; border-radius: 12px; border: 1px solid var(--sf-line); z-index: 1; }
.pin-num {
  background: var(--sf-teal); color: #fff; border-radius: 50%;
  width: 28px; height: 28px; display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 13px; border: 2px solid #fff;
}
.pin-num.last { background: #000; border-style: dashed; }
.pin-num.first { background: #0B3B33; border-style: solid; border-color: var(--sf-ok); }
.pin-num.done { background: var(--sf-ok); }
.you-dot {
  width: 18px; height: 18px; border-radius: 50%;
  background: #2f7bff; border: 2px solid #fff;
  box-shadow: 0 0 0 2px rgba(47,123,255,.35);
}
.pin-num.ret { background: linear-gradient(135deg, #2dd4bf, #0e7c7b); border-style: solid; border-color: #9fe8da; }

/* Action bar */
#actionBar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 20;
  display: flex; gap: 10px; padding: 12px 14px calc(12px + env(safe-area-inset-bottom));
  background: rgba(11, 27, 51, .92); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  border-top: 1px solid var(--sf-line);
  max-width: 640px; margin: 0 auto;
  box-shadow: 0 -8px 24px rgba(0, 0, 0, .3);
}
#actionBar .btn { flex: 1; flex-direction: column; gap: 3px; font-size: 13px; padding: 11px 6px; border-radius: 14px; }
#actionBar .btn.big { font-size: 22px; }
#actionBar .btn span { font-size: 12px; font-weight: 600; letter-spacing: .2px; }
#optimizeBtn.needs-rerun { animation: pulse 1.6s infinite; }
@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(45, 212, 191, .45); }
  50% { box-shadow: 0 0 0 8px rgba(45, 212, 191, 0); }
}

#originSearchInput {
  width: 100%; padding: 15px 16px; font-size: 16px; border-radius: var(--radius-s);
  border: 1px solid var(--sf-line); background: var(--sf-card-2); color: var(--sf-ink);
  transition: border-color .15s, box-shadow .15s;
}
#originSearchInput:focus {
  outline: none; border-color: var(--sf-teal);
  box-shadow: 0 0 0 3px var(--sf-teal-dim);
}
#originSearchInput::placeholder { color: var(--sf-faint); }
#originSuggestList {
  position: absolute; top: 100%; left: 0; right: 0; z-index: 30;
  list-style: none; margin: 6px 0 0; padding: 6px;
  background: var(--sf-card-2); border: 1px solid var(--sf-line); border-radius: var(--radius-s);
  max-height: 260px; overflow-y: auto;
  box-shadow: var(--shadow);
}
#originSuggestList[hidden] { display: none; }
#originSuggestList li { padding: 12px; border-radius: 8px; font-size: 15px; cursor: pointer; }
#originSuggestList li:active { background: var(--sf-teal); }
#originSuggestList li small { display: block; color: var(--sf-muted); font-size: 12px; }

/* Overlays / sheets */
#ocrOverlay, #settingsSheet, #legSheet, #winSheet, #riskSheet, #reoptSheet, #installGate, #originSheet, #devSheet, #apptSheet, #epSheet, #nickSheet, #setSheet, #addSavedSheet {
  position: fixed; inset: 0; z-index: 50; background: rgba(0,0,0,.6);
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
#installGate { z-index: 100; background: var(--sf-navy); }
#ocrOverlay[hidden], #settingsSheet[hidden], #legSheet[hidden], #winSheet[hidden], #riskSheet[hidden], #reoptSheet[hidden], #installGate[hidden], #originSheet[hidden], #devSheet[hidden], #apptSheet[hidden], #epSheet[hidden], #nickSheet[hidden], #setSheet[hidden], #addSavedSheet[hidden] { display: none; }
.ocr-box, .sheet {
  background: var(--sf-card); border: 1px solid var(--sf-line-2); border-radius: 20px;
  padding: 22px; width: 100%; max-width: 420px; max-height: 85vh; overflow-y: auto;
  box-shadow: var(--shadow);
  animation: sheet-in .22s ease-out;
}
@keyframes sheet-in {
  from { opacity: 0; transform: translateY(14px) scale(.98); }
  to { opacity: 1; transform: none; }
}
.ocr-box h3 { margin: 0 0 12px; }
.ocr-bar { height: 10px; background: var(--sf-card-2); border-radius: 6px; overflow: hidden; }
#ocrBarFill { height: 100%; width: 0; background: var(--sf-teal); transition: width .2s; }
#ocrStatus { color: var(--sf-muted); font-size: 13px; }
.sheet-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.sheet-head h2 { margin: 0; font-size: 18px; }
.set-row {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  padding: 12px 0; border-bottom: 1px solid var(--sf-line); font-size: 15px;
}
.set-row small { display: block; color: var(--sf-muted); font-size: 12px; }
.set-row input[type=text], .set-row input:not([type]) {
  width: 55%; padding: 10px; font-size: 16px; border-radius: 10px; /* 16px: no iOS auto-zoom */
  border: 1px solid var(--sf-line); background: var(--sf-card-2); color: var(--sf-ink);
}
.set-row input[type=checkbox] { width: 26px; height: 26px; accent-color: var(--sf-teal); }
.fine { color: var(--sf-muted); font-size: 12px; text-align: center; margin-top: 14px; }
#legList { display: flex; flex-direction: column; gap: 8px; }
.leg-btn { width: 100%; text-align: left; }

/* GPS dev-mode indicator: fixed pill, always on top, never intercepts taps */
#devBadge {
  position: fixed; top: calc(10px + env(safe-area-inset-top)); left: 50%; transform: translateX(-50%);
  z-index: 70; pointer-events: none;
  background: #f59e0b; color: #1a1005; font-weight: 800; font-size: 12px; letter-spacing: .08em;
  padding: 6px 14px; border-radius: 999px; box-shadow: 0 2px 12px rgba(0,0,0,.45);
  animation: devbadge-pulse 2s ease-in-out infinite;
}
#devBadge[hidden] { display: none; }
@keyframes devbadge-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: .72; }
}

/* Toast */
#toast {
  position: fixed; bottom: calc(100px + env(safe-area-inset-bottom)); left: 50%; transform: translateX(-50%); z-index: 60;
  background: var(--sf-card-2); border: 1px solid var(--sf-line); color: var(--sf-ink);
  padding: 12px 18px; border-radius: 24px; font-size: 14px; max-width: 90vw; text-align: center;
}
#toast[hidden] { display: none; }
#toast button { background: none; border: none; color: var(--sf-aqua); font-weight: 700; margin-left: 10px; font-size: 14px; }

/* Approximate-location banner (Issue 2: iOS Precise Location off).
 * Non-blocking warning bar pinned to the top. */
.precision-banner {
  position: sticky;
  top: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  background: var(--sf-warn-dim);
  border-bottom: 1px solid var(--sf-warn);
  color: var(--sf-ink);
  font-size: 13px;
  line-height: 1.4;
}
.precision-banner .icon-btn {
  margin-left: auto;
  flex-shrink: 0;
}
/* Subtle "enable location" hint overlaid on the map when GPS is unavailable. */
.location-hint {
  position: absolute;
  bottom: 12px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 500;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  background: rgba(11, 27, 51, 0.85);
  border: 1px solid var(--sf-line);
  border-radius: 10px;
  font-size: 13px;
  white-space: nowrap;
}
.location-hint .btn.small {
  padding: 4px 10px;
  font-size: 12px;
}
#mapWrap { position: relative; }
