:root {
  --ink: #0d1b2a;
  --muted: #5a6777;
  --line: #dbe2ea;
  --grey: #e9edf2;
  --blue: #1652d9;
  --navy: #0f2b5b;
  --green: #138a3e;
  --green-l: #e3f5e9;
  --orange: #d9480f;
  --orange-l: #fff0e6;
  --yellow: #ffd21f;
  --card-h: 240px;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --shadow: 0 2px 12px rgba(0, 0, 0, 0.2);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--ink);
  -webkit-tap-highlight-color: transparent;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #e6eaee; overscroll-behavior: none; }
button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; touch-action: manipulation; padding: 0; }
button:disabled { opacity: 0.35; }
[hidden] { display: none !important; }
#map { position: fixed; inset: 0; }
.maplibregl-ctrl-attrib { display: none; }

/* ---------- top bar ---------- */
#top {
  position: fixed; z-index: 5; top: calc(8px + var(--safe-t)); left: calc(8px + var(--safe-l)); right: 8px;
  display: flex; gap: 8px; align-items: center; pointer-events: none;
}
#top > * { pointer-events: auto; }
.pill {
  flex: 1; min-width: 0; height: 52px; display: flex; align-items: center; gap: 10px;
  background: #fff; border-radius: 16px; padding: 0 14px; box-shadow: var(--shadow);
  font-weight: 800; font-size: 16px; white-space: nowrap;
}
.bar { flex: 1; min-width: 30px; height: 10px; border-radius: 5px; background: var(--grey); overflow: hidden; }
.bar i { display: block; height: 100%; width: 0; background: var(--green); transition: width 0.4s; }
.dot { width: 14px; height: 14px; border-radius: 50%; background: #aab3bd; flex: none; }
.dot.ok { background: #22c55e; }
.dot.weak { background: #f59e0b; }
.dot.off { background: #ef4444; }
.sync { font-size: 13px; color: var(--orange); }
.fab {
  width: 60px; height: 60px; border-radius: 18px; background: #fff; box-shadow: var(--shadow);
  display: grid; place-items: center; flex: none;
}
.fab.sm { width: 52px; height: 52px; border-radius: 16px; }
.fab svg { width: 28px; height: 28px; }
.fab:active, .act:active, .chip:active { transform: scale(0.96); }

/* ---------- right side ---------- */
#side {
  position: fixed; z-index: 5; right: 10px; bottom: calc(var(--card-h) + 12px);
  display: flex; flex-direction: column; gap: 12px; align-items: flex-end;
}
.mode { width: 84px; height: 72px; border-radius: 20px; font-weight: 900; font-size: 16px; letter-spacing: 0.02em; }
.mode.auto { background: var(--blue); color: #fff; }
.mode.manuel { background: #fff; color: var(--blue); box-shadow: var(--shadow), inset 0 0 0 3px var(--blue); }
.mode.nogps { background: #7b8794; display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1.1; }
.mode small { font-size: 11px; font-weight: 800; letter-spacing: 0; }
#bRecenter { color: var(--blue); }

/* ---------- bottom card ---------- */
.card {
  position: fixed; z-index: 6; left: 0; right: 0; bottom: 0; background: #fff;
  border-radius: 22px 22px 0 0; box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.18);
  padding: 12px 14px calc(12px + var(--safe-b));
}
.row { display: flex; gap: 10px; align-items: center; }
.meta { font-size: 15px; font-weight: 700; color: var(--muted); min-height: 24px; }
.meta .muted { font-weight: 600; }
.meta .dist { margin-left: auto; color: var(--ink); font-size: 22px; font-weight: 900; }
#cStreet { margin: 2px 0 6px; font-size: 26px; line-height: 1.15; font-weight: 900; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#cStreet.long { font-size: 21px; letter-spacing: -0.01em; }
.commune { margin: -4px 0 6px; color: var(--orange); font-weight: 800; font-size: 15px; }
.chips {
  display: flex; gap: 8px; overflow-x: auto; padding: 2px 2px 8px; margin: 0 -2px;
  scrollbar-width: none; -webkit-overflow-scrolling: touch;
}
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; min-width: 60px; height: 56px; padding: 0 12px; border-radius: 14px;
  border: 2px solid var(--line); background: #fff; font-size: 22px; font-weight: 900;
  display: inline-flex; align-items: center; justify-content: center; gap: 4px;
}
.chip small { font-size: 13px; font-weight: 800; color: var(--muted); }
.chip.tgt { background: var(--yellow); border-color: var(--ink); box-shadow: 0 0 0 2px var(--ink) inset; }
.chip.done { background: var(--green-l); border-color: #b7e2c6; color: #2f7449; }
.chip.done::before { content: "✓"; font-size: 15px; }
.chip.skip, .chip.missed { background: var(--orange-l); border-color: #ffc9a8; color: var(--orange); }
.chip.missed::before { content: "!"; font-size: 15px; }
.chip.dim { opacity: 0.45; }
.next { font-size: 16px; color: var(--muted); margin: 0 0 10px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.next b { color: var(--ink); }
.act { height: 66px; border-radius: 16px; font-size: 21px; font-weight: 900; padding: 0 10px; }
.act.prev { flex: 0 0 72px; background: var(--grey); }
.act.prev.wide { flex: 1; }
.act.done { flex: 1; background: var(--green); color: #fff; }
.act.skip { flex: 0 0 124px; background: var(--orange-l); color: var(--orange); box-shadow: inset 0 0 0 2px #ffc9a8; }
.act.blue { background: var(--blue); color: #fff; }
.act.plain { background: var(--grey); }
.card.finished #cStreet { white-space: normal; }

/* ---------- address sheet ---------- */
.sheet { z-index: 7; }
.sheet h2 { margin: 2px 56px 4px 0; font-size: 24px; line-height: 1.2; }
.sheet .sub { color: var(--muted); font-size: 16px; margin-bottom: 6px; }
.sheet .grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 10px; }
.sheet .grid .act { height: 62px; font-size: 18px; }
.close { position: absolute; right: 10px; top: 10px; width: 48px; height: 48px; font-size: 28px; line-height: 1; border-radius: 14px; background: var(--grey); }
.warn { color: var(--orange); font-weight: 800; }

/* ---------- banner, toast ---------- */
.banner {
  position: fixed; z-index: 8; left: calc(10px + var(--safe-l)); right: 10px; top: calc(70px + var(--safe-t));
  background: var(--orange); color: #fff; border-radius: 16px; padding: 12px 14px; box-shadow: var(--shadow);
  font-weight: 800; font-size: 17px; display: flex; flex-wrap: wrap; gap: 8px; align-items: center;
}
.banner.info { background: var(--navy); }
.banner .txt { flex: 1 1 100%; }
.banner button { background: rgba(255, 255, 255, 0.22); color: #fff; border-radius: 12px; height: 48px; padding: 0 18px; font-weight: 900; font-size: 17px; }
.toast {
  position: fixed; z-index: 30; left: 50%; transform: translateX(-50%); bottom: calc(var(--card-h) + 16px);
  max-width: calc(100vw - 32px); background: rgba(13, 27, 42, 0.94); color: #fff; padding: 12px 18px;
  border-radius: 14px; font-weight: 800; font-size: 17px; text-align: center; pointer-events: none;
}

/* ---------- popovers ---------- */
.pop {
  position: fixed; z-index: 9; top: calc(68px + var(--safe-t)); right: 8px; min-width: 250px;
  background: #fff; border-radius: 18px; box-shadow: 0 8px 28px rgba(0, 0, 0, 0.28); padding: 8px;
  display: flex; flex-direction: column;
}
.pop button, .pop .opt {
  height: 58px; padding: 0 16px; border-radius: 12px; text-align: left; font-size: 19px; font-weight: 800;
  display: flex; align-items: center; gap: 12px;
}
.pop .opt.on { background: #e8efff; color: var(--blue); }
.pop .chk input { width: 26px; height: 26px; accent-color: var(--blue); }
.pop .who { padding: 10px 16px 6px; color: var(--muted); font-weight: 700; }
.small { font-size: 12px; color: var(--muted); padding: 6px 16px 4px; margin: 0; }

/* ---------- full pages ---------- */
.page { position: fixed; inset: 0; z-index: 20; background: #fff; display: flex; flex-direction: column; padding-top: var(--safe-t); }
.pagebar { display: flex; gap: 10px; align-items: center; padding: 8px 10px; border-bottom: 1px solid var(--line); }
.back { width: 56px; height: 56px; flex: none; font-size: 28px; border-radius: 14px; background: var(--grey); }
.pagebar input { flex: 1; min-width: 0; height: 56px; font-size: 20px; border: 2px solid var(--line); border-radius: 14px; padding: 0 14px; outline: none; }
.pagebar input:focus { border-color: var(--blue); }
.pagebar h2 { margin: 0; font-size: 21px; }
.list { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; padding-bottom: calc(24px + var(--safe-b)); }
.item { display: block; width: 100%; text-align: left; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.item b { font-size: 19px; }
.item .sub { color: var(--muted); font-size: 15px; margin-top: 3px; }
.pad { padding: 16px; font-size: 17px; color: var(--muted); }
.tag { display: inline-block; font-size: 13px; font-weight: 800; padding: 2px 8px; border-radius: 8px; margin-left: 6px; vertical-align: 2px; background: var(--grey); color: var(--muted); }
.tag.done { background: var(--green-l); color: var(--green); }
.tag.skip, .tag.missed { background: var(--orange-l); color: var(--orange); }
.tag.cur { background: var(--yellow); color: var(--ink); }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; padding: 14px 16px; }
.stats div { background: var(--grey); border-radius: 14px; padding: 10px; text-align: center; font-size: 14px; color: var(--muted); font-weight: 700; }
.stats b { display: block; font-size: 24px; color: var(--ink); }
.h3 { margin: 16px 16px 6px; font-size: 17px; }
.sec { display: flex; justify-content: space-between; gap: 10px; padding: 10px 16px; border-bottom: 1px solid var(--line); font-size: 16px; }
.sec span:last-child { color: var(--muted); text-align: right; }

/* ---------- all addresses ---------- */
.pbtn { margin-left: auto; height: 48px; padding: 0 14px; border-radius: 12px; background: var(--blue); color: #fff; font-weight: 800; font-size: 16px; flex: none; }
.secnav { display: flex; gap: 6px; overflow-x: auto; padding: 8px 10px; border-bottom: 1px solid var(--line); scrollbar-width: none; flex: none; }
.secnav::-webkit-scrollbar { display: none; }
.secnav button { flex: none; height: 40px; padding: 0 12px; border-radius: 10px; background: var(--grey); font-weight: 800; display: inline-flex; align-items: center; gap: 6px; }
.sw { display: inline-block; width: 14px; height: 14px; border-radius: 4px; flex: none; }
.sech { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 20px; scroll-margin-top: 8px; }
.sech small { color: var(--muted); font-weight: 600; font-size: 14px; }
.arow { padding: 10px 16px 12px; border-bottom: 1px solid var(--line); }
.arow.cur { background: #fff8db; }
.aname { display: block; text-align: left; font-weight: 800; font-size: 17px; margin-bottom: 8px; }
.aname small { color: var(--orange); font-weight: 700; }
.nums { display: flex; flex-wrap: wrap; gap: 6px; }
.num { min-width: 46px; height: 42px; padding: 0 9px; border-radius: 10px; border: 2px solid var(--line); background: #fff; font-weight: 800; font-size: 16px; }
.num small { font-size: 11px; color: var(--muted); margin-left: 2px; }
.num.approx { border-style: dashed; }
.num.tgt { background: var(--yellow); border-color: var(--ink); }
.num.done { background: var(--green-l); border-color: #b7e2c6; color: #2f7449; }
.num.skip, .num.missed { background: var(--orange-l); border-color: #ffc9a8; color: var(--orange); }

/* ---------- parcels ---------- */
.colisline { margin: -2px 0 8px; font-size: 16px; font-weight: 800; color: #92400e; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chip .pk { font-style: normal; font-size: 15px; }
.colisrow { display: flex; align-items: center; gap: 10px; margin: 8px 0 2px; font-size: 17px; }
.colisrow span { flex: 1; }
.cbtn { width: 48px; height: 44px; border-radius: 12px; background: var(--grey); font-size: 24px; font-weight: 900; flex: none; }
.tag.colis { background: #fef3c7; color: #92400e; }
.tabs { display: flex; gap: 6px; padding: 8px 10px; border-bottom: 1px solid var(--line); flex: none; }
.tabs button { flex: 1; height: 46px; border-radius: 12px; background: var(--grey); font-weight: 800; font-size: 17px; }
.tabs button.on { background: var(--blue); color: #fff; }
.tabbody { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.qbar { padding: 10px; border-bottom: 1px solid var(--line); flex: none; }
.qbar input { width: 100%; height: 54px; font-size: 20px; border: 2px solid var(--line); border-radius: 14px; padding: 0 14px; outline: none; }
.qbar input:focus { border-color: var(--blue); }
.crow, .lrow { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.ctext { flex: 1; min-width: 0; }
.ctext b { font-size: 18px; }
.cnum { min-width: 24px; text-align: center; font-weight: 900; font-size: 19px; }
.delivered { opacity: 0.45; }
.floor { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 18px; }
.floor small { color: var(--muted); font-weight: 600; font-size: 14px; }
.fl { display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 10px; background: var(--navy); color: #fff; font-weight: 900; }
.lnum { width: 30px; text-align: right; color: var(--muted); font-weight: 800; flex: none; }

/* ---------- test mode ---------- */
.testbar {
  position: fixed; z-index: 5; top: calc(68px + var(--safe-t)); left: calc(8px + var(--safe-l)); right: 8px;
  display: flex; gap: 6px; align-items: center; padding: 6px; border-radius: 14px;
  background: #6d28d9; color: #fff; box-shadow: var(--shadow);
}
.testbar .tl { font-weight: 900; letter-spacing: 0.06em; padding: 0 6px; }
.testbar button { height: 44px; min-width: 44px; padding: 0 9px; border-radius: 10px; background: rgba(255, 255, 255, 0.18); color: #fff; font-weight: 800; font-size: 15px; white-space: nowrap; }
.testbar button.on { background: #fff; color: #6d28d9; }
.testbar #tExit { margin-left: auto; }
body.test .banner { top: calc(126px + var(--safe-t)); }

/* ---------- move point ---------- */
.cross { position: fixed; z-index: 9; left: 50%; top: 50%; width: 56px; height: 56px; margin: -28px 0 0 -28px; pointer-events: none; }
.cross::before, .cross::after { content: ""; position: absolute; background: var(--orange); box-shadow: 0 0 0 2px #fff; }
.cross::before { left: 26px; top: 0; width: 4px; height: 56px; }
.cross::after { top: 26px; left: 0; height: 4px; width: 56px; }
.movebar { z-index: 10; }
.movebar p { margin: 4px 0 12px; font-size: 18px; }
.link { display: block; margin: 12px auto 0; color: var(--blue); font-weight: 800; font-size: 17px; padding: 8px; }

/* ---------- dialog ---------- */
.dialog { position: fixed; inset: 0; z-index: 35; background: rgba(0, 0, 0, 0.45); }
.dialog .card { z-index: 36; }
#dTxt { font-size: 19px; line-height: 1.4; margin: 6px 0 14px; }

/* ---------- my position ---------- */
.me { width: 48px; height: 48px; pointer-events: none; }
.me svg { width: 100%; height: 100%; filter: drop-shadow(0 1px 3px rgba(0, 0, 0, 0.55)); }

/* ---------- boot ---------- */
.boot { position: fixed; inset: 0; z-index: 50; background: #fff; display: grid; place-content: center; text-align: center; padding: 20px; font-size: 18px; }
.boot .act { margin-top: 10px; width: 220px; }
.spin { width: 46px; height: 46px; margin: 0 auto; border: 5px solid var(--grey); border-top-color: var(--blue); border-radius: 50%; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- landscape phone in a car holder ---------- */
@media (orientation: landscape) and (max-height: 560px) {
  .card.main, .sheet, .movebar, .dialog .card {
    top: 0; right: auto; width: min(420px, 48vw); border-radius: 0 22px 22px 0;
    padding: calc(10px + var(--safe-t)) 14px calc(10px + var(--safe-b)) calc(14px + var(--safe-l));
    display: flex; flex-direction: column; overflow-y: auto;
  }
  .card.main .actions, .sheet .grid { margin-top: auto; }
  #top, .testbar { left: calc(min(420px, 48vw) + 8px); }
  #side { bottom: calc(12px + var(--safe-b)); }
  .banner { left: calc(min(420px, 48vw) + 10px); }
  .toast { bottom: 20px; left: calc(50% + min(210px, 24vw)); }
  .act { height: 60px; }
  .chip { height: 52px; }
}

/* ---------- login ---------- */
body.login { overflow: auto; background: var(--navy); min-height: 100%; display: grid; place-items: center; padding: 20px; }
.login-box { width: min(420px, 100%); background: #fff; border-radius: 24px; padding: 28px 22px; display: flex; flex-direction: column; gap: 16px; }
.login-box img { display: block; margin: 0 auto; }
.login-box h1 { margin: 0; text-align: center; font-size: 28px; }
.login-box label { display: flex; flex-direction: column; gap: 6px; font-weight: 800; font-size: 17px; }
.login-box input { height: 58px; font-size: 20px; border: 2px solid var(--line); border-radius: 14px; padding: 0 14px; outline: none; }
.login-box input:focus { border-color: var(--blue); }
.login-box .err { margin: 0; min-height: 1.3em; color: #c92a2a; font-weight: 800; }
.login-box .act { width: 100%; }
