:root {
  --bg: #f4f6f7;
  --card: #ffffff;
  --ink: #1b2428;
  --muted: #5f6d73;
  --line: #e1e6e8;
  --brand: #0f5f6b;
  --brand-ink: #ffffff;
  --brand-soft: #e2f0f1;
  --warn: #9a5b00;
  --warn-soft: #fff3dc;
  --bad: #b3261e;
  --bad-soft: #fde8e6;
  --good: #1e7a3c;
  --good-soft: #e3f4e8;
  --pin-green: #0F9D58;
  --pin-yellow: #F2B600;
  --pin-blue: #0288D1;
  --pin-red: #FF5252;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(0,0,0,.06), 0 1px 8px rgba(0,0,0,.04);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1416;
    --card: #182024;
    --ink: #e8eef0;
    --muted: #9aa9af;
    --line: #26323a;
    --brand: #5cc2cf;
    --brand-ink: #0b1c1f;
    --brand-soft: #173238;
    --warn: #f3c46b;
    --warn-soft: #3a2d12;
    --bad: #ff8a80;
    --bad-soft: #3d1b19;
    --good: #7fd69a;
    --good-soft: #15301f;
    --shadow: none;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
html, body { margin: 0; background: var(--bg); color: var(--ink); }
body {
  font: 16px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  padding-top: env(safe-area-inset-top);
  -webkit-text-size-adjust: 100%;
}
a { color: var(--brand); text-decoration: none; }
button { font: inherit; color: inherit; }

header#top {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 8px;
  padding: 10px 16px; min-height: 52px;
  background: var(--bg); border-bottom: 1px solid var(--line);
}
#top h1 { font-size: 18px; margin: 0; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.icon-btn { background: none; border: 0; font-size: 30px; line-height: 1; padding: 0 8px 4px 0; color: var(--brand); }
.pill {
  border: 1px solid var(--line); background: var(--card); border-radius: 999px;
  padding: 5px 10px; font-size: 13px; color: var(--muted); white-space: nowrap;
}
.pill .dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; vertical-align: 1px; }

main { padding: 12px 16px calc(84px + env(safe-area-inset-bottom)); max-width: 640px; margin: 0 auto; }

nav#tabs {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 10;
  display: flex; background: var(--card); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
nav#tabs a { flex: 1; text-align: center; padding: 8px 0 7px; font-size: 12px; color: var(--muted); }
nav#tabs a .ti { display: block; font-size: 20px; line-height: 24px; }
nav#tabs a.on { color: var(--brand); font-weight: 600; }

.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); border: 1px solid var(--line); padding: 14px; margin-bottom: 12px; }
.card.tight { padding: 0; overflow: hidden; }
.row { display: flex; align-items: center; gap: 10px; }
.grow { flex: 1; min-width: 0; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.h2 { font-size: 13px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); margin: 18px 4px 8px; }
.big { font-size: 22px; font-weight: 700; }
.ellipsis { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid var(--line); background: var(--card); border-radius: 12px;
  padding: 10px 14px; min-height: 44px; font-weight: 600; color: var(--brand); cursor: pointer;
}
.btn.primary { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); }
.btn.block { display: flex; width: 100%; }
.btn.sm { min-height: 36px; padding: 6px 12px; font-size: 14px; }
.btn:disabled { opacity: .5; }
.btns { display: flex; gap: 8px; flex-wrap: wrap; }
.btns > .btn { flex: 1; }

.dot { width: 12px; height: 12px; border-radius: 50%; flex: none; display: inline-block; }
.c-green { background: var(--pin-green); } .c-yellow { background: var(--pin-yellow); }
.c-blue { background: var(--pin-blue); } .c-red { background: var(--pin-red); } .c-other { background: var(--muted); }

.chip { display: inline-block; border-radius: 999px; padding: 2px 9px; font-size: 12px; font-weight: 600; background: var(--brand-soft); color: var(--brand); white-space: nowrap; }
.chip.warn { background: var(--warn-soft); color: var(--warn); }
.chip.bad { background: var(--bad-soft); color: var(--bad); }
.chip.good { background: var(--good-soft); color: var(--good); }
.chip.plain { background: transparent; border: 1px solid var(--line); color: var(--muted); }

.list > * { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-top: 1px solid var(--line); color: inherit; }
.list > *:first-child { border-top: 0; }

.route .meta { margin-top: 4px; }
.stop { border-left: 3px solid var(--brand-soft); margin: 0 0 12px; padding: 0; }
.stop-head { display: flex; align-items: center; gap: 10px; padding: 12px 14px 6px; }
.stop-num { width: 30px; height: 30px; border-radius: 50%; background: var(--brand); color: var(--brand-ink); display: grid; place-items: center; font-weight: 700; flex: none; }
.stop.done .stop-num { background: var(--good); }
.doc { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-top: 1px solid var(--line); }
.doc .name { font-weight: 600; }
.doc a { color: var(--ink); }
.pending { border-color: var(--warn); }
.pending .h { color: var(--warn); font-weight: 700; }

.tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.tile { background: var(--bg); border-radius: 10px; padding: 10px; text-align: center; }
.tile .v { font-size: 20px; font-weight: 700; }
.tile .k { font-size: 12px; color: var(--muted); }
.bars { display: flex; align-items: flex-end; gap: 6px; height: 120px; margin-top: 14px; }
.bar { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; }
.bar .b { width: 100%; max-width: 34px; background: var(--brand); border-radius: 6px 6px 2px 2px; min-height: 2px; }
.bar.partial .b { opacity: .45; }
.bar .n { font-size: 12px; font-weight: 600; margin-bottom: 3px; }
.bar .m { font-size: 11px; color: var(--muted); margin-top: 4px; }

.visit { padding: 12px 14px; border-top: 1px solid var(--line); }
.visit:first-child { border-top: 0; }

label.f { display: block; font-size: 13px; font-weight: 600; color: var(--muted); margin: 12px 0 6px; }
input[type=text], input[type=email], input[type=password], input[type=search], textarea {
  width: 100%; font: inherit; font-size: 16px; color: var(--ink); background: var(--card);
  border: 1px solid var(--line); border-radius: 12px; padding: 11px 12px;
}
textarea { min-height: 76px; resize: vertical; }
input:focus, textarea:focus { outline: 2px solid var(--brand); outline-offset: -1px; }
.seg { display: flex; gap: 6px; }
.seg button { flex: 1; border: 1px solid var(--line); background: var(--card); border-radius: 12px; padding: 10px 6px; min-height: 44px; font-size: 14px; font-weight: 600; }
.seg button.on { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); }
.outcomes { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.outcomes button { border: 1px solid var(--line); background: var(--card); border-radius: 12px; min-height: 56px; padding: 8px; font-weight: 600; font-size: 15px; }
.outcomes button.on { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); }

.chips { display: flex; gap: 6px; overflow-x: auto; padding: 2px 0 10px; scrollbar-width: none; }
.chips button { flex: none; border: 1px solid var(--line); background: var(--card); border-radius: 999px; padding: 6px 12px; font-size: 14px; }
.chips button.on { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); }

.sheet-wrap { position: fixed; inset: 0; z-index: 20; background: rgba(0,0,0,.4); display: flex; align-items: flex-end; justify-content: center; }
.sheet { background: var(--bg); width: 100%; max-width: 640px; border-radius: 18px 18px 0 0; padding: 16px 16px calc(16px + env(safe-area-inset-bottom)); max-height: 92vh; overflow-y: auto; }
.sheet h2 { margin: 0 0 2px; font-size: 18px; }

#toast { position: fixed; left: 16px; right: 16px; bottom: calc(80px + env(safe-area-inset-bottom)); z-index: 30; background: var(--ink); color: var(--bg); border-radius: 12px; padding: 12px 14px; text-align: center; font-weight: 600; max-width: 520px; margin: 0 auto; }

.login { max-width: 380px; margin: 8vh auto 0; }
.login .logo { width: 72px; height: 72px; border-radius: 18px; display: block; margin: 0 auto 14px; }
.err { color: var(--bad); font-size: 14px; margin-top: 10px; }
.empty { text-align: center; color: var(--muted); padding: 28px 12px; }
.banner { background: var(--brand-soft); color: var(--brand); border-radius: 12px; padding: 10px 14px; margin-bottom: 12px; font-weight: 600; display: flex; align-items: center; gap: 10px; }
