:root {
  --bg: #0b1220;
  --card: #18223a;
  --ink: #e8eef7;
  --muted: #9aa7bd;
  --line: #2c3854;
  --brand: #3b82f6;
  --brand-dark: #1e40af;
  --pay: #fbbf24;
  --pay-bg: #3a2c10;
  --paid: #60a5fa;
  --paid-bg: #0c1a2e;
  --call: #2563eb;
  --nav: #6366f1;
  --danger: #f87171;
  --radius: 16px;
  --shadow: 0 2px 12px rgba(0, 0, 0, .45);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 18px;
  line-height: 1.4;
  padding-bottom: env(safe-area-inset-bottom);
}
.hidden { display: none !important; }

/* ---------- Top bar ---------- */
#topbar {
  position: sticky; top: 0; z-index: 50;
  background: var(--brand-dark); color: #fff;
  box-shadow: var(--shadow);
  padding-top: env(safe-area-inset-top);
}
.bar-inner { display: flex; align-items: center; gap: 10px; padding: 12px 14px; }
.title-block { display: flex; flex-direction: column; line-height: 1.1; flex: 1; min-width: 0; }
.title-block strong { font-size: 19px; }
.title-block .sub { font-size: 12px; opacity: .85; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.icon-btn {
  background: rgba(255,255,255,.15); color: #fff; border: 0;
  width: 44px; height: 44px; border-radius: 12px; font-size: 22px; cursor: pointer;
}
.chip {
  background: var(--brand); color: #fff; font-weight: 800;
  padding: 8px 12px; border-radius: 999px; font-size: 16px; white-space: nowrap;
}
.menu { display: flex; flex-direction: column; background: #0f1e3a; }
.menu button {
  text-align: left; background: transparent; color: #fff; border: 0;
  border-top: 1px solid rgba(255,255,255,.12);
  padding: 16px 18px; font-size: 17px; cursor: pointer;
}
.menu button:active { background: rgba(0,0,0,.3); }

/* ---------- Layout ---------- */
main { padding: 14px; max-width: 720px; margin: 0 auto; }
.card {
  background: var(--card); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 18px; margin-bottom: 14px;
  border: 1px solid var(--line);
}
.progress-row { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; color: var(--muted); font-weight: 600; }
.bar { height: 8px; background: var(--line); border-radius: 999px; overflow: hidden; margin-bottom: 14px; }
.bar > span { display: block; height: 100%; background: var(--brand); }

/* ---------- Stop card ---------- */
.stop-head { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.seq { background: var(--brand); color: #fff; font-weight: 800; border-radius: 10px; padding: 2px 10px; font-size: 16px; }
.order-no { color: var(--muted); font-size: 14px; }
.name { font-size: 26px; font-weight: 800; margin: 6px 0 2px; }
.badges { display: flex; gap: 6px; flex-wrap: wrap; margin: 6px 0; }
.badge { background: #29304a; color: #c7d2fe; border-radius: 8px; padding: 3px 9px; font-size: 13px; font-weight: 700; }
.address { font-size: 20px; font-weight: 600; margin: 8px 0 2px; }
.district { color: var(--muted); font-size: 15px; }
.notes-block { margin-top: 12px; }
.label { font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 700; margin-bottom: 4px; }
.pdf-note { background: #0f1830; border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; font-size: 16px; white-space: pre-wrap; color: var(--ink); }

/* money */
.money { display: flex; align-items: center; gap: 12px; margin: 14px 0; padding: 14px; border-radius: 12px; border: 1px solid var(--line); }
.money.collect { background: var(--pay-bg); border-color: #5a4015; }
.money.paid { background: var(--paid-bg); border-color: #1e3a5f; }
.money .amt { font-size: 30px; font-weight: 900; }
.money.collect .amt { color: var(--pay); }
.money.paid .amt { color: var(--paid); }
.money .lbl { font-size: 14px; font-weight: 700; }
.money.collect .lbl { color: var(--pay); }
.money.paid .lbl { color: var(--paid); }
.taken-line { font-size: 14px; color: var(--muted); margin-top: 2px; }

textarea.note-edit {
  width: 100%; min-height: 70px; border: 1px solid var(--line); border-radius: 10px;
  padding: 10px 12px; font-size: 16px; font-family: inherit; resize: vertical;
  background: #0f172a; color: var(--ink);
}
textarea.note-edit::placeholder { color: var(--muted); }

/* ---------- Buttons ---------- */
.btn-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 14px; }
.btn {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  border: 0; border-radius: 14px; padding: 16px; font-size: 18px; font-weight: 700;
  cursor: pointer; color: #fff; min-height: 56px; text-decoration: none;
}
.btn:active { transform: translateY(1px); }
.btn.call { background: var(--call); }
.btn.waze { background: #05c8f7; color: #03222b; }
.btn.sms { background: #0ea5e9; }

.app-version {
  position: fixed; right: 8px; bottom: 6px; z-index: 40;
  font-size: 11px; color: var(--muted); opacity: .6;
  pointer-events: none; user-select: none;
}
.btn.nav { background: var(--nav); }
.btn.deliver { background: #1d4ed8; grid-column: 1 / -1; }
.btn.skip { background: transparent; color: var(--muted); border: 2px solid var(--line); }
.btn.confirm { background: #d97706; }
.btn.secondary { background: transparent; color: #93c5fd; border: 2px solid var(--brand); }
.btn.wide { grid-column: 1 / -1; }
.btn.lg { font-size: 20px; }
.btn.hero { min-height: 84px; font-size: 24px; font-weight: 800; box-shadow: 0 4px 16px rgba(59,130,246,.30); }
.btn:disabled { opacity: .5; }

/* ---------- Upcoming list ---------- */
.up-title { margin: 18px 4px 8px; color: var(--muted); font-weight: 700; }
.stop-row {
  display: flex; align-items: center; gap: 12px; background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px; box-shadow: var(--shadow); padding: 12px 14px; margin-bottom: 8px; cursor: pointer;
}
.stop-row.done { opacity: .5; }
.stop-row .rseq { background: var(--line); color: var(--ink); font-weight: 800; border-radius: 8px; padding: 2px 9px; min-width: 30px; text-align: center; }
.stop-row.done .rseq { background: var(--paid-bg); color: var(--paid); }
.stop-row .rmain { flex: 1; min-width: 0; }
.stop-row .rname { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stop-row .raddr { font-size: 14px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stop-row .ramt { font-weight: 800; white-space: nowrap; color: var(--pay); }
.stop-row .ramt.paid { color: var(--paid); font-size: 13px; }

/* ---------- Forms / generic ---------- */
h2.view-title { margin: 4px 4px 14px; font-size: 22px; }
input[type=email], input[type=password], input[type=number], input[type=text] {
  width: 100%; border: 1px solid var(--line); border-radius: 10px; padding: 14px; font-size: 17px; margin-bottom: 12px;
  background: #0f172a; color: var(--ink);
}
input::placeholder { color: var(--muted); }
.muted { color: var(--muted); }
.center { text-align: center; }
.spacer { height: 8px; }
.dropzone {
  border: 2px dashed var(--brand); border-radius: var(--radius); padding: 30px 18px;
  text-align: center; color: #93c5fd; background: #0c1a2e; cursor: pointer;
}
.banner { padding: 12px 14px; border-radius: 10px; margin-bottom: 12px; font-size: 15px; border: 1px solid transparent; }
.banner.warn { background: #3a2c10; color: #fcd34d; border-color: #5a4015; }
.banner.ok { background: var(--paid-bg); color: #93c5fd; border-color: #1e3a5f; }
.banner.err { background: #3b1216; color: #fca5a5; border-color: #5b1d22; }
.kv { display: flex; justify-content: space-between; padding: 10px 0; border-bottom: 1px solid var(--line); }
.kv:last-child { border-bottom: 0; }
.kv .v { font-weight: 700; }
.big-total { font-size: 40px; font-weight: 900; color: #60a5fa; }
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
  background: #334155; color: #fff; padding: 12px 18px; border-radius: 999px;
  box-shadow: var(--shadow); z-index: 100; font-size: 15px; max-width: 90%;
  border: 1px solid var(--line);
}
