/* VOICE  a working tool for people on foot: big targets, short words, nothing decorative
   IDEA   a canvasser's street map with numbered stops, like a transit line drawn over the city
   PICTURE the live map is the picture; route stops are numbered stations on one cobalt line
   COLOUR white ground, near-black ink, cobalt #1240e0 for action, outcome colours on pins only
   TYPE   the phone's own system font, so it reads like a native app; tabular numbers
   LAYOUT phone: full-bleed map + bottom tabs + bottom sheets; tablet: rail, list panel, map */

:root {
  color-scheme: light dark;
  --brand: #1240e0; --brand-2: #0c30b0; --brand-soft: #e8eeff; --on-brand: #fff;
  --bg: #ffffff; --surface: #f4f6fb; --surface-2: #e8ecf5; --line: #dde3ef;
  --ink: #0b1220; --ink-2: #48536a; --ink-3: #6f7a92;
  --ok: #0b7a3e; --warn: #b86a00; --bad: #d12b2b; --due: #f29d12; --late: #e4002b;
  --shadow: 0 6px 24px rgba(10, 16, 35, .16), 0 1px 3px rgba(10, 16, 35, .12);
  --tabh: 62px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --brand: #4d74ff; --brand-2: #3a62f0; --brand-soft: #16214a;
    --bg: #0a0d18; --surface: #121829; --surface-2: #1b2338; --line: #263049;
    --ink: #e9edf7; --ink-2: #a9b3c8; --ink-3: #8390a8;
    --ok: #3cc47d; --warn: #f2a541; --bad: #ff6b6b;
    --shadow: 0 6px 24px rgba(0, 0, 0, .5);
  }
}

* { box-sizing: border-box; min-width: 0; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 16px/1.45 var(--font); -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent; overscroll-behavior: none; overflow: hidden;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--brand); }
h1, h2, h3, h4 { text-wrap: balance; }
[hidden] { display: none !important; }
.ic { flex: none; display: block; }
.muted { color: var(--ink-2); }
.hint { font-size: 13px; color: var(--ink-3); margin: 6px 0; }
.center { text-align: center; }
.nowrap { white-space: nowrap; }
.warn { color: var(--warn); font-weight: 600; font-size: 14px; }
.note { background: var(--brand-soft); padding: 10px 12px; border-radius: 12px; font-size: 14px; }
.approve-note { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 0 0 12px; }
:focus-visible { outline: 3px solid color-mix(in srgb, var(--brand) 55%, transparent); outline-offset: 2px; }

/* ---------- shell ---------- */
#app { position: fixed; inset: 0; display: grid; grid-template-rows: minmax(0, 1fr) auto; grid-template-columns: minmax(0, 1fr); }
#mapwrap { grid-row: 1; grid-column: 1; position: relative; overflow: hidden; background: #e9edf3; }
#map { position: absolute; inset: 0; }
#panel { grid-row: 1; grid-column: 1; z-index: 4; background: var(--bg); overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; }
body[data-tab=map] #panel { display: none; }
#tabs {
  grid-row: 2; grid-column: 1; z-index: 6; display: grid; grid-template-columns: repeat(5, minmax(0, 1fr));
  background: var(--bg); border-top: 1px solid var(--line); padding-bottom: var(--safe-b);
}
.tab {
  position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  min-height: var(--tabh); border: 0; background: none; color: var(--ink-3); font-size: 11.5px; font-weight: 600; padding: 6px 2px;
}
.tab.on { color: var(--brand); }
.tab .badge {
  position: absolute; top: 6px; left: calc(50% + 6px); min-width: 19px; height: 19px; padding: 0 5px; border-radius: 10px;
  background: var(--late); color: #fff; font-size: 11px; line-height: 19px; text-align: center; font-weight: 700;
}
#appbar {
  position: sticky; top: 0; z-index: 3; display: flex; align-items: center; gap: 10px;
  padding: calc(8px + var(--safe-t)) 16px 8px; background: var(--bg); border-bottom: 1px solid var(--line);
}
#coName { flex: 1; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.panel-in { padding: 14px 16px calc(28px + var(--safe-b)); max-width: 760px; margin: 0 auto; }
.panel-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin: 4px 0 12px; }
.panel-head h1 { font-size: clamp(26px, 7vw, 32px); line-height: 1.08; letter-spacing: -.02em; margin: 0 0 4px; }
.panel-head p { margin: 0; }
.finding { font-size: 15px; color: var(--ink-2); margin: 0; }

.sync-pill {
  display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: var(--bg);
  border-radius: 99px; padding: 4px 10px; font-size: 12.5px; font-weight: 600; color: var(--ink-2); white-space: nowrap;
}
.sync-pill i { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); }
.sync-pill.saving i { background: var(--due); }
.sync-pill.offline i { background: var(--ink-3); }
.sync-pill.error i { background: var(--bad); }
.sync-pill.demo i { background: var(--brand); }
.me-btn { position: relative; border: 0; background: none; padding: 0; line-height: 0; border-radius: 50%; }
.me-btn::after { content: ""; position: absolute; right: -1px; bottom: -1px; width: 11px; height: 11px; border-radius: 50%; border: 2px solid var(--bg); background: var(--ok); }
.me-btn[data-tone=saving]::after { background: var(--due); }
.me-btn[data-tone=offline]::after { background: var(--ink-3); }
.me-btn[data-tone=error]::after { background: var(--bad); }
.me-btn[data-tone=demo]::after { background: var(--brand); }

/* ---------- controls ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 0 16px;
  border-radius: 12px; border: 1px solid var(--line); background: var(--bg); color: var(--ink);
  font-weight: 650; font-size: 15px; text-decoration: none; white-space: nowrap; transition: background .15s, transform .1s;
}
.btn:active { transform: scale(.98); }
.btn:hover { background: var(--surface); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--on-brand); }
.btn.primary:hover { background: var(--brand-2); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.danger { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn.danger-ghost { color: var(--bad); border-color: transparent; background: transparent; }
.btn.block { display: flex; width: 100%; }
.btn.sm { min-height: 36px; padding: 0 12px; font-size: 14px; border-radius: 10px; }
.btn.lg { min-height: 54px; font-size: 17px; }
.btn:disabled, .act:disabled { opacity: .45; cursor: default; transform: none; }
.btn .clip { overflow: hidden; text-overflow: ellipsis; }
.icon-btn {
  display: inline-grid; place-items: center; width: 44px; height: 44px; border-radius: 50%;
  border: 1px solid var(--line); background: var(--bg); color: var(--ink); flex: none;
}
.icon-btn.ghost { border-color: transparent; background: transparent; }
.icon-btn.sm { width: 36px; height: 36px; }
.icon-btn.on { background: var(--brand-soft); color: var(--brand); border-color: transparent; }
.icon-btn:disabled { opacity: .3; }
.link { background: none; border: 0; color: var(--brand); font-weight: 650; padding: 10px 0; font-size: 15px; }
.link.subtle { color: var(--ink-3); font-weight: 500; }

label { display: block; font-weight: 650; font-size: 14px; color: var(--ink-2); margin: 16px 0 6px; }
.input {
  display: block; width: 100%; min-height: 46px; padding: 10px 12px; font-size: 16px;
  border: 1px solid var(--line); border-radius: 12px; background: var(--bg); color: var(--ink);
}
textarea.input { resize: vertical; min-height: 80px; }
select.input { appearance: none; -webkit-appearance: none; padding-right: 34px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%236f7a92' stroke-width='2' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center; }
.input.inline { display: inline-block; width: auto; min-height: 38px; font-size: 15px; padding: 6px 30px 6px 10px; }
.input:disabled { opacity: .6; }
.two { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 10px; }
@media (max-width: 380px) { .two { grid-template-columns: minmax(0, 1fr); } }
.switch { display: flex; align-items: center; gap: 12px; font-weight: 500; color: var(--ink); margin: 14px 0; font-size: 15px; }
.switch input { appearance: none; -webkit-appearance: none; flex: none; width: 46px; height: 28px; border-radius: 14px; background: var(--surface-2); position: relative; transition: background .15s; margin: 0; }
.switch input::after { content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.3); transition: transform .15s; }
.switch input:checked { background: var(--brand); }
.switch input:checked::after { transform: translateX(18px); }
.switch.sm { margin: 0; font-size: 14px; }
.seg { display: flex; gap: 3px; padding: 3px; border-radius: 12px; background: var(--surface-2); margin: 6px 0; }
.seg button { flex: 1; min-height: 40px; border: 0; border-radius: 9px; background: transparent; font-weight: 650; color: var(--ink-2); font-size: 14.5px; padding: 4px 8px; line-height: 1.15; }
.seg button small { display: block; font-size: 11.5px; font-weight: 500; color: var(--ink-3); }
.seg button.on { background: var(--bg); color: var(--ink); box-shadow: 0 1px 3px rgba(10,16,35,.15); }
.seg button:disabled { opacity: .5; }
.seg.sm { margin: 0; }
.seg.sm button { min-height: 34px; padding: 2px 12px; }

.chips { display: flex; gap: 8px; }
.chips.wrap { flex-wrap: wrap; }
.scroll-x { overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch; padding-bottom: 2px; }
.scroll-x::-webkit-scrollbar { display: none; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; min-height: 36px; padding: 0 14px; border-radius: 99px; margin: 0;
  border: 1px solid var(--line); background: var(--bg); color: var(--ink); font-weight: 650; font-size: 14px; white-space: nowrap; flex: none;
}
.chip b { font-weight: 700; color: var(--ink-3); font-size: 12.5px; }
.chip.on { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.chip.on b { color: inherit; opacity: .75; }
.chip.check { cursor: pointer; padding-left: 10px; }
.chip.check input { margin: 0; accent-color: var(--brand); width: 18px; height: 18px; }
.dot { display: inline-block; flex: none; width: 10px; height: 10px; border-radius: 50%; background: var(--c); }
.pill { position: relative; display: inline-flex; align-items: center; gap: 6px; padding: 2px 9px 2px 7px; border-radius: 99px; font-size: 12.5px; font-weight: 650; white-space: nowrap; isolation: isolate; }
.pill::before { content: ""; position: absolute; inset: 0; border-radius: inherit; background: var(--c); opacity: .14; z-index: -1; }
.pill i { width: 8px; height: 8px; border-radius: 50%; background: var(--c); }
.av { display: inline-grid; place-items: center; flex: none; width: var(--s); height: var(--s); border-radius: 50%; background: var(--c); color: #fff; font-weight: 700; font-size: calc(var(--s) * .38); letter-spacing: .02em; vertical-align: middle; }
.spin { display: inline-block; width: 16px; height: 16px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; vertical-align: -3px; }
@keyframes spin { to { transform: rotate(360deg); } }
.bar { height: 8px; border-radius: 4px; background: var(--surface-2); overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--brand); border-radius: 4px; transition: width .3s; }

/* ---------- map overlay ---------- */
.map-top { position: absolute; z-index: 3; top: calc(10px + var(--safe-t)); left: 10px; right: 10px; display: grid; gap: 8px; pointer-events: none; }
.map-top > * { pointer-events: auto; }
.searchbar { display: flex; align-items: center; gap: 8px; background: var(--bg); border-radius: 14px; box-shadow: var(--shadow); padding: 4px 5px 4px 14px; color: var(--ink-3); }
.searchbar input { flex: 1; border: 0; background: transparent; outline: none; min-height: 42px; font-size: 16px; color: var(--ink); }
.searchbar.flat { box-shadow: none; border: 1px solid var(--line); flex: 1; }
.search-results { background: var(--bg); border-radius: 14px; box-shadow: var(--shadow); max-height: 52vh; overflow: auto; }
.sr { display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; padding: 12px 14px; border: 0; border-bottom: 1px solid var(--line); background: none; color: var(--ink); }
.sr small { display: block; color: var(--ink-3); font-size: 13px; }
.sr.addr { color: var(--brand); }
.sr.muted { color: var(--ink-2); }
#mapChips .chip { box-shadow: 0 1px 4px rgba(10,16,35,.18); border-color: transparent; }
#mapChips .chip.on { border-color: var(--ink); }
.map-side { position: absolute; z-index: 2; right: 10px; top: calc(118px + var(--safe-t)); display: grid; gap: 10px; }
.fab-sm { display: grid; place-items: center; width: 46px; height: 46px; border-radius: 50%; border: 0; background: var(--bg); color: var(--ink); box-shadow: var(--shadow); }
.fab { position: absolute; z-index: 2; right: 14px; bottom: 16px; display: grid; place-items: center; width: 60px; height: 60px; border-radius: 50%; border: 0; background: var(--brand); color: #fff; box-shadow: 0 8px 22px rgba(18,64,224,.45); }
.map-note { position: absolute; z-index: 2; left: 10px; right: 84px; bottom: 16px; display: flex; align-items: center; gap: 8px; background: var(--bg); color: var(--ink); border-radius: 12px; padding: 8px 6px 8px 12px; box-shadow: var(--shadow); font-size: 13.5px; }
.map-note span { flex: 1; }
.map-error { position: absolute; inset: 0; display: grid; place-items: center; padding: 32px; text-align: center; color: var(--ink-2); }
.draw-bar { position: absolute; z-index: 5; top: calc(10px + var(--safe-t)); left: 10px; right: 10px; display: grid; gap: 10px; background: #0b1220; color: #fff; border-radius: 14px; padding: 12px 14px; box-shadow: var(--shadow); }
.draw-bar small { display: block; color: #b9c3d9; font-size: 13.5px; }
.draw-btns { display: flex; gap: 8px; }
.draw-btns .btn { flex: 1; background: #1c2540; color: #fff; border-color: #2c3758; }
.draw-btns .btn.primary { background: var(--brand); border-color: var(--brand); }
body.drawing .map-top, body.drawing .map-side, body.drawing .fab, body.drawing .map-note { display: none; }
.rt-pin { display: grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; border: 2.5px solid #fff; background: var(--brand); color: #fff; font: 700 13px/1 var(--font); box-shadow: 0 2px 6px rgba(0,0,0,.35); padding: 0; }
.rt-pin.done { background: #7a8497; }
.rt-pin.next { width: 34px; height: 34px; background: #0b1220; font-size: 15px; box-shadow: 0 0 0 5px rgba(18,64,224,.35), 0 2px 6px rgba(0,0,0,.4); }
.far .rt-pin, .far .rt-pin.next { width: 14px; height: 14px; font-size: 0; border-width: 2px; box-shadow: 0 1px 3px rgba(0,0,0,.35); }
.far .rt-pin svg { display: none; }
.far .terr-tag { font-size: 11px; }
.me-dot { width: 18px; height: 18px; border-radius: 50%; background: #2a7fff; border: 3px solid #fff; box-shadow: 0 0 0 7px rgba(42,127,255,.22), 0 1px 4px rgba(0,0,0,.35); }
.terr-tag { padding: 3px 9px; border-radius: 99px; background: #fff; color: var(--c); border: 1.5px solid var(--c); font: 700 12px/1.2 var(--font); white-space: nowrap; pointer-events: none; opacity: .92; }
.maplibregl-ctrl-attrib { font-size: 10px; }
.maplibregl-ctrl-bottom-left, .maplibregl-ctrl-bottom-right { z-index: 1; }

/* ---------- layers: sheets, cards, dialogs ---------- */
#layers { position: fixed; inset: 0; z-index: 50; pointer-events: none; }
.layer { position: absolute; inset: 0; pointer-events: none; }
.scrim { position: absolute; inset: 0; background: rgba(8,12,24,.4); opacity: 0; transition: opacity .2s; pointer-events: auto; }
.layer.open .scrim { opacity: 1; }
.layer.closing .scrim, .layer.closing .sheet { pointer-events: none; }
.layer-peek .scrim { display: none; }
.sheet {
  position: absolute; left: 0; right: 0; bottom: 0; max-height: 92dvh; display: flex; flex-direction: column;
  background: var(--bg); border-radius: 20px 20px 0 0; box-shadow: var(--shadow); pointer-events: auto;
  transform: translateY(105%); transition: transform .24s cubic-bezier(.2,.8,.2,1); padding-bottom: var(--safe-b);
}
.layer.open .sheet { transform: none; }
.grab { width: 40px; height: 5px; border-radius: 3px; background: var(--line); margin: 8px auto 0; flex: none; }
.sh-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 10px 2px 18px; flex: none; }
.sh-head h2 { font-size: 20px; line-height: 1.2; margin: 0; letter-spacing: -.01em; }
.sh-body { overflow: auto; padding: 4px 18px 20px; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }
.sh-foot { display: flex; gap: 10px; padding: 12px 18px; border-top: 1px solid var(--line); background: var(--bg); flex: none; }
.sh-foot .btn { flex: 1; }
.sh-foot .btn.danger-ghost { flex: 0 0 auto; }
.layer-peek .sheet { left: 8px; right: 8px; bottom: calc(var(--tabh) + var(--safe-b) + 8px); border-radius: 18px; padding-bottom: 0; max-height: 70dvh; }
.layer-peek .sh-body { padding: 14px 14px 14px; }
.layer-dialog .sheet { left: 50%; right: auto; top: 50%; bottom: auto; width: min(420px, calc(100% - 32px)); border-radius: 18px; opacity: 0; transform: translate(-50%, -46%); transition: transform .18s, opacity .18s; padding-bottom: 0; }
.layer-dialog.open .sheet { transform: translate(-50%, -50%); opacity: 1; }
.layer-dialog .sh-head { padding-top: 16px; }
.layer-dialog .sh-head .icon-btn { display: none; }

/* business card */
.card-head { display: flex; align-items: flex-start; gap: 8px; }
.card-title { flex: 1; text-align: left; border: 0; background: none; padding: 2px 0 0; color: var(--ink); }
.card-title h3 { margin: 0; font-size: 19px; line-height: 1.2; letter-spacing: -.01em; }
.card-title p { margin: 3px 0 0; font-size: 14px; }
.card-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; font-size: 13.5px; margin: 10px 0 6px; }
.due-line, .last-note { display: flex; align-items: flex-start; gap: 6px; margin: 6px 0; font-size: 14px; color: var(--ink-2); }
.due-line .ic, .last-note .ic { margin-top: 2px; }
.due-line.today { color: var(--warn); font-weight: 650; }
.due-line.late { color: var(--bad); font-weight: 650; }
.qo-row { display: flex; gap: 6px; margin: 10px -14px 10px; padding: 0 14px; }
.qo { display: inline-flex; align-items: center; gap: 6px; flex: none; min-height: 36px; padding: 0 12px 0 10px; border-radius: 99px; border: 1px solid var(--line); background: var(--bg); font-weight: 650; font-size: 13.5px; white-space: nowrap; }
.qo i { width: 10px; height: 10px; border-radius: 50%; background: var(--c); }
.card-actions { display: grid; grid-template-columns: 1.6fr 1fr 1fr 44px; gap: 6px; }
.card-actions .btn { padding: 0 8px; font-size: 14.5px; }

/* visit sheet */
.visit-biz b { display: block; font-size: 17px; }
.visit-biz span { font-size: 14px; }
.gps { display: flex; align-items: flex-start; gap: 8px; margin: 10px 0 14px; padding: 9px 12px; border-radius: 12px; background: var(--surface); font-size: 14px; color: var(--ink-2); }
.gps .ic { margin-top: 1px; }
.gps.ok { color: var(--ok); font-weight: 650; }
.gps.far { color: var(--warn); }
.ogrid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.obtn { position: relative; isolation: isolate; display: flex; align-items: center; gap: 10px; min-height: 54px; padding: 8px 12px; border-radius: 14px; border: 1.5px solid var(--line); background: var(--bg); text-align: left; font-weight: 650; font-size: 15px; line-height: 1.2; }
.obtn i { flex: none; width: 14px; height: 14px; border-radius: 50%; background: var(--c); }
.obtn.on { border-color: var(--c); box-shadow: inset 0 0 0 1.5px var(--c); }
.obtn.on::before { content: ""; position: absolute; inset: 0; border-radius: inherit; background: var(--c); opacity: .1; z-index: -1; }
.photo-btn { display: flex; align-items: center; justify-content: center; gap: 8px; min-height: 48px; margin-top: 16px; border: 1.5px dashed var(--line); border-radius: 12px; color: var(--ink-2); cursor: pointer; }
.photo-prev { display: block; max-width: 100%; max-height: 220px; border-radius: 12px; margin-top: 10px; }
.photo-full { display: block; width: 100%; border-radius: 12px; }
.loc-line { flex-wrap: wrap; }
.loc-line .link { padding: 0; font-size: 14px; margin-left: auto; }
.loc-line { display: flex; gap: 8px; align-items: flex-start; font-size: 14px; color: var(--ink-2); background: var(--surface); padding: 10px 12px; border-radius: 12px; margin: 6px 0 0; }

/* business detail */
.biz-top p { margin: 0; font-size: 14.5px; }
.action-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; margin: 14px 0; }
.act { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; min-height: 68px; padding: 8px 4px; border-radius: 14px; border: 0; background: var(--surface); color: var(--ink); font-weight: 650; font-size: 12.5px; text-decoration: none; text-align: center; }
.act.primary { background: var(--brand); color: #fff; }
.follow-box { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 14px; background: var(--surface); border-left: 4px solid var(--brand); }
.follow-box > div { flex: 1; }
.follow-box small { display: block; color: var(--bad); font-weight: 650; }
.follow-box.today { border-left-color: var(--due); }
.follow-box.late { border-left-color: var(--late); }
.block { margin-top: 20px; }
.block h3 { font-size: 17px; margin: 0 0 10px; letter-spacing: -.01em; }
.block h4 { font-size: 13px; font-weight: 700; color: var(--ink-3); margin: 0 0 6px; }
.kv { display: grid; grid-template-columns: 20px minmax(96px, 34%) minmax(0, 1fr); align-items: center; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--line); font-size: 15px; color: var(--ink-3); }
.kv.top { align-items: start; }
.kv > span:last-child, .kv > a { color: var(--ink); overflow-wrap: anywhere; }
.kv .k { font-size: 13.5px; }
.kv a { color: var(--brand); text-decoration: none; font-weight: 600; }
.biz-notes { white-space: pre-wrap; background: var(--surface); padding: 10px 12px; border-radius: 12px; font-size: 15px; }
.row-btns { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.timeline { list-style: none; padding: 0; margin: 0; }
.timeline li { border-left: 3px solid var(--c); padding: 2px 0 14px 14px; margin-left: 4px; }
.timeline p { margin: 4px 0; font-size: 15px; }
.tl-head { display: flex; align-items: center; gap: 8px; }
.tl-head b { flex: none; }
.tl-head .muted { flex: 1; font-size: 13px; }
.tl-by { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--ink-2); }
.timeline small { display: flex; align-items: center; gap: 5px; margin-top: 4px; font-size: 13px; }
.flag { color: var(--warn); font-weight: 600; }
.thumb { display: block; width: 96px; height: 72px; margin-top: 8px; border: 0; border-radius: 10px; background: var(--surface-2) center / cover no-repeat; }
.thumb.missing { opacity: .4; }

/* lists */
.rows { list-style: none; padding: 0; margin: 0; }
.row { display: flex; align-items: center; gap: 8px; border-bottom: 1px solid var(--line); }
.row-main { flex: 1; display: grid; gap: 4px; padding: 12px 0; text-align: left; border: 0; background: none; color: var(--ink); }
.row-main.static { cursor: default; }
.row-title { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.row-title b { font-size: 16px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: flex; align-items: center; gap: 8px; }
.row-sub { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; font-size: 13px; }
.row-note { font-size: 14px; color: var(--ink-2); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.row-btns.wrap { flex-wrap: wrap; justify-content: flex-end; margin: 0; }
.row .row-btns { margin: 0; }
.who { display: inline-flex; align-items: center; gap: 6px; }
.when { font-size: 13.5px; font-weight: 650; color: var(--ink-2); white-space: nowrap; }
.when.late { color: var(--bad); }
.when.today { color: var(--warn); }
.group h2 { display: flex; align-items: center; gap: 8px; font-size: 15px; margin: 22px 0 2px; }
.group h2 span { font-size: 12px; background: var(--surface-2); color: var(--ink-2); border-radius: 99px; padding: 1px 8px; }
.group h2.late { color: var(--bad); }
.group h2.today { color: var(--warn); }
.list-tools { display: flex; gap: 8px; margin: 4px 0 10px; }
.list-tools .searchbar { padding-left: 12px; }
.list-tools .searchbar input { min-height: 40px; }
.panel-in > .chips { margin-bottom: 4px; }
.empty { text-align: center; padding: 36px 8px; }
.empty h3 { font-size: 20px; margin: 0 0 6px; }
.empty p { color: var(--ink-2); margin: 0 auto; max-width: 34ch; }
.empty-actions { display: grid; gap: 8px; max-width: 340px; margin: 18px auto 6px; }
.empty-inline { color: var(--ink-2); padding: 12px 0; }

/* route */
.route-sum { background: var(--surface); border-radius: 16px; padding: 14px; display: grid; gap: 12px; }
.rs-figs { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.rs-figs b { display: block; font-size: clamp(20px, 6vw, 26px); font-weight: 800; letter-spacing: -.02em; font-variant-numeric: tabular-nums; line-height: 1.1; white-space: nowrap; }
.rs-figs b span { color: var(--ink-3); font-weight: 700; }
.rs-figs small { display: block; color: var(--ink-3); font-size: 12.5px; }
.rs-ctrl { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; }
.rs-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.done-msg { margin: 0; }
.rs-links { margin: 0; font-size: 14px; color: var(--ink-3); }
.rs-links a { font-weight: 600; text-decoration: none; }
.rs-links .link { padding: 0; font-size: 14px; }
.done-msg { display: flex; align-items: center; gap: 6px; color: var(--ok); font-weight: 700; }
.stops { list-style: none; padding: 0; margin: 14px 0 0; }
.stops li { display: grid; grid-template-columns: 30px minmax(0, 1fr) auto; gap: 10px; align-items: start; padding: 12px 0; border-bottom: 1px solid var(--line); }
.stops .num { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; background: var(--brand-soft); color: var(--brand); font-weight: 800; font-size: 14px; margin-top: 2px; }
.stops li.next .num { background: var(--brand); color: #fff; }
.stops li.done .num { background: var(--ok); color: #fff; }
.stops li.done .stop-main { opacity: .6; }
.stop-main { display: grid; gap: 3px; text-align: left; border: 0; background: none; padding: 0; color: var(--ink); }
.stop-main b { font-size: 16px; }
.stop-main small { color: var(--ink-3); font-size: 13px; }
.stop-main .leg { color: var(--brand); font-weight: 650; }
.stop-sub { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.due-dot { font-size: 11.5px; font-weight: 700; color: var(--warn); }
.due-dot.late { color: var(--bad); }
.stop-btns { display: flex; gap: 0; }
.route-foot { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.route-foot .btn { flex: 1 1 140px; }

/* team */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(150px, 45%), 1fr)); gap: 8px; margin: 12px 0 4px; }
.kpi { background: var(--surface); border-radius: 14px; padding: 12px 14px; }
.kpi small { display: block; color: var(--ink-3); font-size: 13px; font-weight: 650; }
.kpi b { display: block; font-size: clamp(26px, 7vw, 34px); font-weight: 800; letter-spacing: -.02em; font-variant-numeric: tabular-nums; line-height: 1.15; }
.kpi span { font-size: 12.5px; color: var(--ink-2); }
.hbars { display: grid; gap: 10px; }
.hbar { display: grid; grid-template-columns: minmax(96px, 36%) minmax(0, 1fr) auto; gap: 10px; align-items: center; }
.hbar .lbl { font-size: 14px; line-height: 1.2; }
.hbar .lbl small { display: block; color: var(--ink-3); font-size: 12px; }
.track { height: 12px; border-radius: 6px; background: var(--surface-2); overflow: hidden; }
.track i { display: block; height: 100%; border-radius: 6px; background: var(--c); }
.val { font-weight: 700; font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; font-size: 14.5px; }
.val small { color: var(--ink-3); font-weight: 600; margin-left: 6px; font-size: 12px; }
.hours { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 4px; height: 160px; }
.hcol { display: grid; grid-template-rows: minmax(0, 1fr) auto; gap: 4px; text-align: center; }
.hcol small { font-size: 11px; color: var(--ink-3); white-space: nowrap; }
.hstack { display: flex; align-items: flex-end; height: 100%; }
.hn { display: flex; flex-direction: column; justify-content: flex-end; width: 100%; min-height: 2px; background: var(--surface-2); border-radius: 5px 5px 2px 2px; overflow: hidden; }
.ht { display: block; width: 100%; background: var(--brand); }
.hcol.best small { color: var(--brand); font-weight: 800; }
.hcol.best .hn { box-shadow: 0 0 0 2px var(--brand); }
.legend-inline { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px; font-size: 13px; color: var(--ink-2); margin: 10px 0 0; }
.sw { display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-right: -8px; background: var(--c); vertical-align: -1px; }
.row-title .sw { margin-right: 0; }
.sw.grey { background: var(--surface-2); }
.sw.brand { background: var(--brand); }
.scroll { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 15px; }
.table th { text-align: left; font-size: 12.5px; color: var(--ink-3); font-weight: 700; padding: 6px 6px; border-bottom: 1px solid var(--line); }
.table td { padding: 10px 6px; border-bottom: 1px solid var(--line); }
.table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.rank { display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; background: var(--surface-2); font-size: 12px; }
@media (max-width: 600px) {
  .stack thead { display: none; }
  .stack tr { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); padding: 10px 0; border-bottom: 1px solid var(--line); }
  .stack td { border: 0; padding: 2px 0; text-align: left; }
  .stack td:first-child { grid-column: 1 / -1; padding-bottom: 6px; }
  .stack td.num { display: grid; text-align: left; font-weight: 700; }
  .stack td.num::before { content: attr(data-l); font-size: 11.5px; font-weight: 600; color: var(--ink-3); }
}
.feed { list-style: none; padding: 0; margin: 0; }
.feed li { display: grid; grid-template-columns: 62px 24px minmax(0, 1fr); gap: 10px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--line); }
.feed .t { font-size: 12.5px; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.feed-main { display: grid; text-align: left; border: 0; background: none; padding: 0; color: var(--ink); }
.feed-main b { font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.feed-main span { font-size: 13px; color: var(--ink-2); }
.tool-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 8px; }
.tool-grid label.btn { margin: 0; color: var(--ink); font-size: 15px; }
.tools { padding-bottom: 8px; }

/* settings, account, sheets content */
.me-card { display: flex; align-items: center; gap: 14px; margin: 6px 0 12px; }
.me-card b { display: block; font-size: 18px; }
.me-card span, .me-card small { display: block; }
.menu { display: grid; }
.menu button { display: flex; align-items: center; gap: 14px; min-height: 54px; border: 0; border-bottom: 1px solid var(--line); background: none; font-weight: 650; font-size: 16px; text-align: left; color: var(--ink); padding: 0 2px; }
.sync-box { background: var(--surface); border-radius: 14px; padding: 12px 14px; margin: 12px 0; }
.sync-box p { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; margin: 0 0 10px; }
.sync-box p small { width: 100%; color: var(--ink-3); }
.sync-box.error p { color: var(--bad); }
.sync-box.offline p { color: var(--ink-2); }
.fails { list-style: none; padding: 0; margin: 0 0 10px; }
.fails li { display: grid; gap: 4px; padding: 8px 0; border-top: 1px solid var(--line); }
.fails small { color: var(--ink-3); }
.fails span { display: flex; gap: 6px; }
.out-list { list-style: none; padding: 0; margin: 0; }
.out-list li { display: grid; grid-template-columns: 44px minmax(0, 1fr) auto; gap: 8px; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--line); }
.out-list input[type=color] { width: 44px; height: 44px; border: 0; padding: 0; background: none; border-radius: 10px; }
.out-list select { grid-column: 1 / -1; }
.out-list .flags { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 6px 14px; }
.out-list .flags label { display: inline-flex; align-items: center; gap: 6px; margin: 0; font-weight: 600; font-size: 14px; color: var(--ink); }
.out-list .flags input { accent-color: var(--brand); width: 18px; height: 18px; }
.ord { display: flex; }
.copy-row { display: flex; gap: 8px; }
.copy-row .input { flex: 1; }
.steps { padding-left: 22px; margin: 6px 0 12px; }
.steps li { margin: 6px 0; }
.invite { margin-top: 20px; padding: 14px; background: var(--surface); border-radius: 14px; }
.legend { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px 12px; font-size: 14px; }
.legend li { display: flex; align-items: center; gap: 8px; }
.ring { display: inline-block; flex: none; width: 14px; height: 14px; border-radius: 50%; border: 2.5px solid var(--due); }
.ring.late { border-color: var(--late); }
.swatches { display: flex; flex-wrap: wrap; gap: 10px; }
.swatch { width: 38px; height: 38px; border-radius: 50%; border: 3px solid var(--bg); background: var(--c); box-shadow: 0 0 0 1px var(--line); }
.swatch.on { box-shadow: 0 0 0 3px var(--ink); }
.dr-head { display: flex; justify-content: space-between; align-items: center; margin: 16px 0 6px; }
.dr-list { border: 1px solid var(--line); border-radius: 12px; max-height: 46dvh; overflow: auto; }
.dr { display: flex; align-items: flex-start; gap: 12px; margin: 0; padding: 10px 12px; border-bottom: 1px solid var(--line); font-weight: 500; color: var(--ink); font-size: 15px; cursor: pointer; }
.dr input { margin-top: 3px; width: 18px; height: 18px; accent-color: var(--brand); flex: none; }
.dr small { display: block; color: var(--ink-3); font-size: 13px; }
.dr.old { opacity: .55; cursor: default; }
.msg { min-height: 1.4em; font-size: 14.5px; margin: 10px 0 0; }
.msg.good { color: var(--ok); }
.msg.bad { color: var(--bad); }

/* toasts */
#toasts { position: fixed; z-index: 90; left: 50%; transform: translateX(-50%); bottom: calc(var(--tabh) + var(--safe-b) + 14px); display: grid; gap: 8px; width: min(480px, calc(100% - 24px)); pointer-events: none; }
.toast { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 14px; border-radius: 12px; background: #0b1220; color: #fff; font-size: 15px; box-shadow: var(--shadow); opacity: 0; transform: translateY(8px); transition: opacity .2s, transform .2s; pointer-events: auto; }
.toast.in { opacity: 1; transform: none; }
.toast button { border: 0; background: none; color: #9fb4ff; font-weight: 700; min-height: 36px; padding: 0 4px; white-space: nowrap; }

/* sign-in */
#gate { position: fixed; inset: 0; overflow: auto; background: var(--brand); }
.auth { min-height: 100%; display: grid; place-items: center; padding: calc(24px + var(--safe-t)) 18px calc(24px + var(--safe-b)); }
.auth-card { width: min(420px, 100%); background: var(--bg); border-radius: 22px; padding: 24px 22px; box-shadow: 0 20px 50px rgba(0,0,0,.25); }
.auth-card h2 { font-size: 24px; margin: 18px 0 6px; }
.brand { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; }
.brand b { display: block; font-size: 20px; }
.brand small { color: var(--ink-3); }
.auth-card form .btn { margin-top: 18px; }
.auth-card .link { display: block; margin: 6px auto 0; }

/* ---------- tablet and desktop ---------- */
@media (min-width: 900px) {
  :root { --tabh: 0px; }
  #app { grid-template-columns: 84px minmax(360px, 420px) minmax(0, 1fr); grid-template-rows: minmax(0, 1fr); }
  #tabs { grid-row: 1; grid-column: 1; display: flex; flex-direction: column; gap: 4px; padding: calc(12px + var(--safe-t)) 0 12px; border-top: 0; border-right: 1px solid var(--line); }
  .tab { min-height: 70px; font-size: 12px; }
  .tab.on::before { content: ""; position: absolute; left: 0; top: 14px; bottom: 14px; width: 3px; border-radius: 0 3px 3px 0; background: var(--brand); }
  .tab .badge { top: 8px; left: calc(50% + 8px); }
  #panel, body[data-tab=map] #panel { grid-row: 1; grid-column: 2; display: block; border-right: 1px solid var(--line); }
  #mapwrap { grid-row: 1; grid-column: 3; }
  .layer-sheet .sheet { left: auto; top: 0; bottom: 0; width: min(460px, 100%); max-height: none; border-radius: 0; transform: translateX(105%); padding-top: var(--safe-t); }
  .layer-sheet.wide .sheet { width: min(560px, 100%); }
  .layer-sheet.open .sheet { transform: none; }
  .layer-sheet .grab { display: none; }
  .layer-peek .sheet { left: auto; right: 16px; bottom: 16px; width: 410px; }
  .fab { right: 20px; bottom: 22px; }
  .map-side { right: 16px; }
  .map-top { left: 16px; right: 16px; max-width: 640px; }
  #toasts { left: auto; right: 24px; transform: none; bottom: 24px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}
