:root {
  --navy: #14202E;
  --navy-2: #1C2C3E;
  --navy-line: #33445A;
  --muted-on-navy: #B8C2CE;
  --bg: #F5F6F8;
  --card: #FFFFFF;
  --line: #E3E7EC;
  --line-2: #C9D2DC;
  --text: #14202E;
  --text-2: #33404F;
  --muted: #5B6675;
  --teal: #0F5C5A;
  --teal-dark: #0B4544;
  --blue: #1D4F86;
  --blue-bg: #E4EEF8;
  --amber: #F2B33D;
  --amber-bg: #FDF1D8;
  --amber-text: #8A5A00;
  --green: #1E7A4C;
  --green-bg: #E5F2EB;
  --green-text: #14532F;
  --red-bg: #FBE7E4;
  --red-text: #8E2A23;
  --chip: #EEF2F5;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font-family: Manrope, system-ui, -apple-system, sans-serif;
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
a { color: var(--teal); }
button, input, select, textarea { font-family: inherit; font-size: 16px; }
.loading { padding: 40px; text-align: center; color: var(--muted); }

.screen { min-height: 100vh; display: flex; flex-direction: column; max-width: 560px; margin: 0 auto; background: var(--bg); }

/* header */
.top {
  background: var(--navy); color: #fff;
  padding: calc(14px + var(--safe-top)) 16px 14px;
  position: sticky; top: 0; z-index: 5;
}
.top-row { display: flex; align-items: center; gap: 8px; min-height: 44px; }
.top h1 { margin: 0; font-size: 22px; font-weight: 800; flex: 1; }
.top .sub { font-size: 13px; color: var(--muted-on-navy); font-weight: 600; }
.icon-btn {
  width: 44px; height: 44px; border-radius: 12px; border: none; background: transparent; color: #fff;
  display: inline-flex; align-items: center; justify-content: center; cursor: pointer; text-decoration: none; flex-shrink: 0;
}
.progress { margin-top: 12px; }
.progress-label { display: flex; justify-content: space-between; font-size: 14px; font-weight: 600; margin-bottom: 8px; }
.progress-label span:last-child { color: var(--muted-on-navy); }
.bar { height: 8px; border-radius: 4px; background: var(--navy-line); overflow: hidden; }
.bar > div { height: 100%; background: var(--amber); border-radius: 4px; transition: width .3s; }

/* body */
.content { flex: 1; padding: 16px 16px calc(96px + var(--safe-bottom)); display: flex; flex-direction: column; gap: 12px; }
.section-label { font-size: 12px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin-top: 6px; }
.empty { text-align: center; color: var(--muted); padding: 32px 12px; line-height: 1.5; }
.empty strong { color: var(--text); display: block; font-size: 17px; margin-bottom: 6px; }

.card {
  background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 14px;
  display: flex; flex-direction: column; gap: 10px; text-decoration: none; color: var(--text);
}
a.card:active { background: #FAFBFC; }
.card.next { border: 2px solid var(--teal); }
.card.done { opacity: .72; }
.card-head { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; }
.card-title { font-size: 16px; font-weight: 700; }
.card-sub { font-size: 13px; color: var(--muted); margin-top: 2px; }
.row { display: flex; gap: 12px; align-items: flex-start; }
.num {
  width: 28px; height: 28px; border-radius: 14px; background: var(--navy); color: #fff; font-size: 13px; font-weight: 800;
  display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.num.ok { background: var(--green); }
.num.bad { background: var(--red-text); }
.eyebrow { font-size: 12px; font-weight: 800; color: var(--teal); }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { font-size: 12px; font-weight: 600; background: var(--chip); color: var(--text-2); border-radius: 6px; padding: 4px 8px; }
.chip.blue { background: var(--blue-bg); color: var(--blue); font-weight: 700; }
.chip.red { background: var(--red-bg); color: var(--red-text); font-weight: 700; }
.pill { font-size: 12px; font-weight: 700; border-radius: 6px; padding: 4px 8px; white-space: nowrap; }
.pill.todo { background: var(--amber-bg); color: var(--amber-text); }
.pill.ok { background: var(--green-bg); color: var(--green-text); }
.pill.bad { background: var(--red-bg); color: var(--red-text); }

/* buttons */
.btn {
  height: 52px; border-radius: 26px; border: none; background: var(--teal); color: #fff; font-weight: 800; font-size: 16px;
  display: flex; align-items: center; justify-content: center; gap: 8px; cursor: pointer; text-decoration: none; padding: 0 20px; width: 100%;
  text-align: center; line-height: 1.15;
}
.btn.small { padding: 0 12px; }
.btn:active { background: var(--teal-dark); }
.btn:disabled { background: var(--line-2); color: #fff; cursor: default; }
.btn.outline { background: #fff; color: var(--teal); border: 2px solid var(--teal); }
.btn.green { background: var(--green); }
.btn.small { height: 44px; border-radius: 12px; font-size: 15px; }
.btn.ghost { background: #fff; color: var(--text); border: 1px solid var(--line-2); }
.btn.blue { background: var(--blue); }
.btn.danger-text { background: none; color: var(--red-text); height: 44px; }
.btn-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.link-btn { background: none; border: none; color: var(--teal); font-weight: 700; font-size: 15px; padding: 12px; cursor: pointer; text-align: center; text-decoration: none; }

.dock {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 6;
  background: #fff; border-top: 1px solid var(--line);
  padding: 10px 16px calc(10px + var(--safe-bottom));
}
.dock-inner { max-width: 528px; margin: 0 auto; display: flex; flex-direction: column; gap: 8px; }

/* tab bar */
.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 6; background: #fff; border-top: 1px solid var(--line);
  padding-bottom: var(--safe-bottom);
}
.tabs-inner { max-width: 560px; margin: 0 auto; display: grid; grid-template-columns: repeat(4, 1fr); }
.tab {
  display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 0 6px; min-height: 56px;
  color: var(--muted); text-decoration: none; font-size: 11px; font-weight: 700;
}
.tab.on { color: var(--teal); }

/* stop screen */
.stop-title { margin: 0; font-size: 22px; font-weight: 800; }
.notes-box { border: 1px solid var(--navy); border-radius: 12px; overflow: hidden; }
.notes-box > div:first-child { background: var(--navy); color: #fff; padding: 10px 14px; font-size: 14px; font-weight: 800; }
.notes-box > div:last-child { background: #fff; padding: 12px 14px; font-size: 14px; line-height: 1.5; white-space: pre-line; }

.steps { display: flex; flex-direction: column; }
.step { display: flex; gap: 12px; }
.step-rail { display: flex; flex-direction: column; align-items: center; }
.step-dot {
  width: 28px; height: 28px; border-radius: 14px; border: 2px solid var(--line-2); color: var(--muted);
  font-size: 13px; font-weight: 800; display: flex; align-items: center; justify-content: center; background: #fff;
}
.step-dot.on { border-color: var(--teal); color: var(--teal); }
.step-dot.ok { border-color: var(--green); background: var(--green); color: #fff; }
.step-line { width: 2px; flex: 1; background: var(--line-2); min-height: 14px; }
.step-body { flex: 1; padding: 3px 0 18px; display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.step-title { font-size: 15px; font-weight: 700; }
.step-note { font-size: 13px; color: var(--muted); }
.step-note.ok { color: var(--green); font-weight: 600; }

.units { display: flex; flex-direction: column; background: #fff; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.unit {
  display: flex; align-items: center; gap: 12px; padding: 12px 14px; border: none; border-bottom: 1px solid var(--chip);
  background: #fff; text-align: left; width: 100%; cursor: pointer; color: var(--text); min-height: 56px;
}
.unit:last-child { border-bottom: none; }
.unit .box {
  width: 26px; height: 26px; border-radius: 8px; border: 2px solid var(--line-2); flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; color: #fff;
}
.unit.on .box { background: var(--green); border-color: var(--green); }
.unit-main { flex: 1; min-width: 0; }
.unit-title { font-size: 15px; font-weight: 700; }
.unit-sub { font-size: 12px; color: var(--muted); margin-top: 1px; }
.unit-qty { font-size: 13px; font-weight: 800; color: var(--text-2); }

.field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 700; color: var(--text-2); }
.field input, .field select, .field textarea {
  border: 1px solid var(--line-2); border-radius: 10px; padding: 10px 12px; font-weight: 500; color: var(--text); background: #fff; min-height: 44px;
}
.field textarea { min-height: 80px; resize: vertical; }
.seg { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.seg button {
  height: 44px; border-radius: 10px; border: 1px solid var(--line-2); background: #fff; font-weight: 700; color: var(--text-2); cursor: pointer;
}
.seg button.on { background: var(--navy); border-color: var(--navy); color: #fff; }

.problem { background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 14px; display: flex; flex-direction: column; gap: 8px; }
.reason-list { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.reason-list button {
  min-height: 48px; border-radius: 10px; border: 1px solid var(--line-2); background: #fff; font-weight: 700; color: var(--text); cursor: pointer; padding: 6px;
}

.result { border-radius: 14px; padding: 14px; display: flex; flex-direction: column; gap: 6px; }
.result.ok { background: var(--green-bg); border: 2px solid var(--green); color: var(--green-text); }
.result.bad { background: var(--red-bg); border: 2px solid var(--red-text); color: var(--red-text); }
.result strong { font-size: 16px; }

.contact { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 12px 0; border-bottom: 1px solid var(--chip); }
.contact:last-child { border-bottom: none; }
.contact a { text-decoration: none; font-weight: 700; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; font-size: 14px; }
.kv dt { color: var(--muted); font-weight: 600; }
.kv dd { margin: 0; font-weight: 600; }

.check-row { display: flex; align-items: center; gap: 12px; padding: 12px 14px; background: #fff; border: 1px solid var(--line); border-radius: 14px; cursor: pointer; }
.check-row input { width: 22px; height: 22px; accent-color: var(--teal); }

/* map */
.map {
  position: relative; height: 230px; border-radius: 14px; overflow: hidden; flex-shrink: 0;
  border: 1px solid var(--line); background: #E6EBE6; isolation: isolate; z-index: 0;
}
.map-msg { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: var(--muted); font-size: 14px; padding: 16px; text-align: center; }
.map-note {
  position: absolute; left: 8px; top: 8px; z-index: 500; background: rgba(20,32,46,.88); color: #fff;
  font-size: 12px; font-weight: 700; padding: 6px 10px; border-radius: 8px;
}
.map-note[hidden] { display: none; }
.pin {
  width: 30px; height: 30px; border-radius: 15px; background: var(--navy); color: #fff; border: 3px solid #fff;
  box-shadow: 0 1px 4px rgba(0,0,0,.35); font: 800 13px Manrope, system-ui, sans-serif;
  display: flex; align-items: center; justify-content: center; box-sizing: border-box;
}
.pin.next { background: var(--amber); color: var(--navy); transform: scale(1.15); }
.pin.done { background: var(--green); }
.pin.bad { background: var(--red-text); }
.pin.off { background: #9AA6B3; opacity: .8; }
.leaflet-popup-content { font-family: Manrope, system-ui, sans-serif; font-size: 14px; line-height: 1.4; }
.leaflet-popup-content a { font-weight: 700; }

.dist { font-size: 13px; font-weight: 700; color: var(--blue); }

/* auth */
.auth { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; background: var(--navy); }
.auth form { width: 100%; max-width: 360px; background: #fff; border-radius: 18px; padding: 24px; display: flex; flex-direction: column; gap: 14px; }
.auth h1 { margin: 0; font-size: 24px; font-weight: 800; }
.auth p { margin: 0; color: var(--muted); line-height: 1.45; font-size: 14px; }
.error { color: var(--red-text); font-weight: 700; font-size: 14px; }

#toast {
  position: fixed; left: 50%; bottom: calc(90px + var(--safe-bottom)); transform: translateX(-50%) translateY(20px);
  background: var(--navy); color: #fff; padding: 12px 18px; border-radius: 12px; font-weight: 700; font-size: 14px;
  opacity: 0; pointer-events: none; transition: all .2s; z-index: 20; max-width: 90vw; text-align: center;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

@media (min-width: 600px) {
  .screen { border-left: 1px solid var(--line); border-right: 1px solid var(--line); }
}
