/* IceBlue Driver v43 — big, lazy, Ajman water van style */
.day-end-grid { display: flex; flex-direction: column; gap: 8px; }
.day-end-row { display: flex; justify-content: space-between; gap: 12px; font-size: 15px; padding: 6px 0; border-bottom: 1px solid #e2e8f0; }
.day-end-row strong { color: var(--navy); }
.day-end-stop { padding: 8px 0; border-bottom: 1px solid #f1f5f9; font-size: 13px; color: var(--muted); }
.day-end-stop strong { display: block; color: var(--text); font-size: 14px; margin-bottom: 2px; }
.history-panel { margin-top: 12px; }
.history-card {
  display: block; width: 100%; text-align: left; margin: 0 0 8px;
  padding: 12px 14px; border-radius: 12px; border: 2px solid #bae6fd;
  background: #fff; font: inherit; cursor: pointer;
}
.history-card strong { display: block; color: var(--navy); font-size: 15px; margin-bottom: 4px; }
.history-card span { display: block; font-size: 12px; color: var(--muted); line-height: 1.4; }
:root {
  --navy: #0c4a6e;
  --navy2: #075985;
  --sky: #e0f2fe;
  --bg: #f0f9ff;
  --card: #fff;
  --text: #0f172a;
  --muted: #64748b;
  --green: #059669;
  --blue: #0284c7;
  --orange: #ea580c;
  --red: #dc2626;
  --safe-b: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: Inter, "Segoe UI", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
}

#app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100dvh;
  background: var(--bg);
  position: relative;
  padding-bottom: calc(72px + var(--safe-b));
}

.top-header {
  background: linear-gradient(160deg, var(--navy) 0%, var(--navy2) 100%);
  border-radius: 0 0 20px 20px;
  padding: 14px 16px 16px;
  padding-top: calc(12px + env(safe-area-inset-top, 0px));
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: #fff;
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand-logo {
  width: 40px; height: 40px; border-radius: 12px;
  object-fit: cover; flex-shrink: 0;
  box-shadow: 0 2px 10px rgba(0,0,0,0.25);
  border: 2px solid rgba(125, 211, 252, 0.55);
  background: #fff;
}
.brand-text { min-width: 0; }
.brand-main { font-size: 20px; font-weight: 900; letter-spacing: -0.02em; color: #7dd3fc; line-height: 1.1; }
.brand-sub { font-size: 11px; font-weight: 700; color: #bae6fd; margin-top: 2px; }
.ver-badge {
  font-size: 11px; font-weight: 800; color: #bae6fd;
  background: rgba(255,255,255,0.12); padding: 6px 10px; border-radius: 999px;
}

.main { padding: 14px 14px 24px; }
.screen[hidden] { display: none !important; }
.driver-title { margin: 0 0 12px; font-size: 24px; font-weight: 900; color: var(--navy); }
.hint-line { font-size: 13px; color: var(--muted); font-weight: 600; margin: 0 0 14px; line-height: 1.4; }

.stats-row {
  display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 10px;
}
.stat-card {
  background: var(--card); border-radius: 16px; padding: 16px 12px;
  text-align: center; box-shadow: 0 2px 10px rgba(12,74,110,0.06);
  border: 1px solid #bae6fd;
}
.stat-card.cash { border-color: #86efac; background: #f0fdf4; }
.stat-card .lbl { font-size: 12px; color: var(--muted); margin-bottom: 8px; font-weight: 700; text-transform: uppercase; letter-spacing: .03em; }
.stat-card .val { font-size: 36px; font-weight: 900; line-height: 1; color: var(--navy); }
.stat-card .val.g { color: var(--green); }
.stat-card .val.sm { font-size: 18px; padding-top: 8px; }

.mega-btn {
  display: block; width: 100%; border: none; border-radius: 16px;
  padding: 18px 16px; margin-bottom: 10px;
  font-size: 17px; font-weight: 900; cursor: pointer;
  letter-spacing: 0.01em;
}
.mega-btn.primary { background: var(--blue); color: #fff; }
.mega-btn.deliver { background: var(--green); color: #fff; font-size: 19px; padding: 22px 16px; }
.mega-btn.soft { background: #fff; color: var(--navy); border: 2px solid #7dd3fc; }
.mega-btn.danger { background: #fef2f2; color: var(--red); border: 2px solid #fecaca; }
.mega-btn:active { transform: scale(0.98); }
.mega-btn:disabled { opacity: 0.5; }

.banner {
  margin: 10px 14px 0; padding: 12px 14px; border-radius: 12px;
  font-weight: 700; font-size: 14px;
  background: #e0f2fe; color: var(--navy);
}
.banner.ok { background: #d1fae5; color: #065f46; }
.banner.err { background: #fee2e2; color: #991b1b; }

.bottom-nav {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: 0; width: 100%; max-width: 480px;
  display: grid; grid-template-columns: repeat(4, 1fr);
  background: #fff; border-top: 1px solid #bae6fd;
  padding: 6px 4px calc(6px + var(--safe-b));
  z-index: 50; box-shadow: 0 -4px 20px rgba(12,74,110,0.08);
}
.nav-item {
  border: none; background: transparent; padding: 8px 4px;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  font-size: 11px; font-weight: 600; color: var(--muted); cursor: pointer;
}
.nav-item.active { color: var(--blue); }
.nav-svg {
  width: 22px; height: 22px; fill: currentColor; opacity: 0.9;
}

.big-label { display: block; font-size: 13px; font-weight: 800; color: var(--muted); margin: 12px 0 6px; }
.big-input, .form-panel input, .form-panel select, .form-panel textarea {
  width: 100%; padding: 14px 14px; border: 2px solid #bae6fd; border-radius: 12px;
  font-size: 17px; font-weight: 600; background: #fff; color: var(--text);
}
.search-bar { margin-bottom: 12px; }

.pick-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; max-height: 40vh; overflow-y: auto; }
.pick-card, .cust-card {
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
  width: 100%; text-align: left; border: 2px solid #e0f2fe; background: #fff;
  border-radius: 14px; padding: 14px; cursor: pointer; font: inherit;
}
.pick-card strong, .cust-card strong { display: block; font-size: 16px; font-weight: 900; }
.pick-card span, .order-date { display: block; font-size: 12px; color: var(--muted); margin-top: 4px; font-weight: 600; }
.due-tag { color: var(--red); font-size: 12px; font-weight: 800; font-style: normal; }
.due { font-size: 16px; font-weight: 900; color: var(--green); }
.due.red { color: var(--red); }

.picked-box {
  background: #ecfdf5; border: 2px solid #6ee7b7; border-radius: 14px;
  padding: 14px; margin-bottom: 12px;
}
.picked-name { font-size: 18px; font-weight: 900; }
.picked-meta { font-size: 13px; color: var(--muted); margin-top: 4px; font-weight: 600; }
.linkish { border: none; background: none; color: var(--blue); font-weight: 800; padding: 8px 0 0; cursor: pointer; }

.step-title { font-size: 14px; font-weight: 900; margin: 16px 0 10px; color: var(--navy); }
.stepper {
  display: grid; grid-template-columns: 72px 1fr 72px; gap: 10px; align-items: center;
  margin-bottom: 8px;
}
.step-btn {
  height: 64px; border: none; border-radius: 16px; background: var(--navy); color: #fff;
  font-size: 28px; font-weight: 900; cursor: pointer;
}
.step-val {
  text-align: center; font-size: 42px; font-weight: 900; color: var(--navy);
  background: #fff; border: 2px solid #bae6fd; border-radius: 16px; padding: 10px;
}

.pay-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 8px;
}
.pay-btn {
  border: 2px solid #bae6fd; background: #fff; border-radius: 14px;
  padding: 16px 8px; font-size: 15px; font-weight: 900; cursor: pointer; color: var(--text);
}
.pay-btn.active { background: var(--blue); border-color: var(--blue); color: #fff; }

.sub-head {
  display: flex; align-items: center; gap: 10px; margin-bottom: 12px;
}
.sub-head h2 { margin: 0; font-size: 20px; font-weight: 900; flex: 1; }
.back {
  width: 44px; height: 44px; border-radius: 12px; border: none;
  background: #e0f2fe; color: var(--navy); font-size: 20px; font-weight: 900; cursor: pointer;
}

.detail-block {
  background: #fff; border: 1px solid #bae6fd; border-radius: 16px;
  padding: 16px; margin-bottom: 12px; font-size: 15px; line-height: 1.5;
}
.meta-line { color: var(--muted); margin-top: 6px; font-weight: 600; }
.map-link { display: inline-block; margin: 10px 0; color: var(--blue); font-weight: 800; }
.no-pin { color: var(--orange); font-weight: 700; }
.r { color: var(--red); }
.g { color: var(--green); }
.empty { text-align: center; padding: 24px; color: var(--muted); font-weight: 700; }

.form-panel { background: #fff; border-radius: 16px; padding: 14px; border: 1px solid #bae6fd; }
.form-panel label { display: block; font-size: 12px; font-weight: 800; color: var(--muted); margin: 10px 0 6px; }
.screen-form {
  display: flex;
  flex-direction: column;
  min-height: calc(100dvh - 120px);
}
.form-scroll {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 24px;
}
.form-bottom-spacer { height: 100px; }
.form-save-bar {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(64px + var(--safe-b));
  width: 100%;
  max-width: 480px;
  z-index: 5000;
  background: #fff;
  border-top: 1px solid #bae6fd;
  box-shadow: 0 -6px 20px rgba(12, 74, 110, 0.12);
  padding: 10px 14px calc(10px + var(--safe-b));
}
.form-save-bar .mega-btn { margin-bottom: 0; }
/* Keep Leaflet inside the box — never over Save / nav */
.map-block {
  position: relative;
  z-index: 0;
  isolation: isolate;
  margin: 10px 0;
  border-radius: 14px;
  overflow: hidden;
  border: 2px solid #bae6fd;
  background: #e2e8f0;
}
.loc-map {
  height: 220px;
  min-height: 220px;
  max-height: 220px;
  width: 100%;
  position: relative;
  z-index: 0;
  overflow: hidden !important;
  background: #e2e8f0;
}
.loc-map .leaflet-container {
  width: 100% !important;
  height: 220px !important;
  max-height: 220px !important;
  z-index: 0 !important;
  font: inherit;
}
.loc-map .leaflet-pane,
.loc-map .leaflet-map-pane,
.loc-map .leaflet-tile-pane,
.loc-map .leaflet-overlay-pane,
.loc-map .leaflet-shadow-pane,
.loc-map .leaflet-marker-pane,
.loc-map .leaflet-tooltip-pane,
.loc-map .leaflet-popup-pane {
  z-index: auto !important;
}
.loc-map .leaflet-control-container { z-index: 2 !important; }
.loc-map .leaflet-top,
.loc-map .leaflet-bottom { z-index: 2 !important; }
.loc-gps-btn {
  width: 100%; border: none; border-radius: 12px; padding: 14px;
  background: var(--navy); color: #fff; font-weight: 700; font-size: 15px; cursor: pointer; margin: 8px 0;
}
.loc-preview-box {
  position: relative;
  z-index: 1;
  margin: 10px 0 14px;
  background: #f0f9ff;
  border: 1px solid #7dd3fc;
  border-radius: 12px;
  padding: 12px 14px;
}
.loc-preview-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  margin-bottom: 6px;
}
.loc-preview {
  font-size: 14px;
  font-weight: 600;
  color: var(--navy);
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-word;
  overflow-wrap: anywhere;
  max-height: none;
}
.loc-coords {
  margin-top: 8px;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.loc-results {
  position: relative;
  z-index: 10;
  background: #fff;
  border: 1px solid #bae6fd;
  border-radius: 12px;
  margin: 6px 0;
  max-height: 160px;
  overflow-y: auto;
}
.loc-results button {
  display: block; width: 100%; text-align: left; border: none; border-bottom: 1px solid #f1f5f9;
  background: #fff; padding: 12px; font-size: 13px; font-weight: 600; cursor: pointer;
  white-space: normal; word-break: break-word; line-height: 1.35;
}

.modal {
  position: fixed; inset: 0; background: rgba(15,23,42,0.45); z-index: 100;
  display: grid; place-items: center; padding: 20px;
}
.modal[hidden] { display: none !important; }
.modal-box {
  width: min(400px, 100%); background: #fff; border-radius: 18px; padding: 20px;
  box-shadow: 0 20px 50px rgba(0,0,0,0.2);
}
.modal-box h3 { margin: 0 0 12px; font-size: 18px; font-weight: 900; color: var(--navy); }
.modal-foot { display: flex; gap: 10px; justify-content: flex-end; margin-top: 16px; }
.invoice-box { max-height: 90dvh; overflow-y: auto; }
.invoice-body {
  background: #f8fafc; border: 1px solid #e2e8f0; border-radius: 12px;
  padding: 14px 16px; font-size: 14px; line-height: 1.55; font-weight: 500; color: var(--text);
  white-space: pre-wrap; word-break: break-word;
}
.invoice-body .inv-line { display: flex; justify-content: space-between; gap: 12px; padding: 4px 0; border-bottom: 1px solid #e2e8f0; }
.invoice-body .inv-line:last-child { border-bottom: none; }
.invoice-body .inv-title { font-weight: 700; color: var(--navy); margin-bottom: 10px; font-size: 15px; }
.invoice-body .inv-foot { margin-top: 12px; font-size: 12px; color: var(--muted); font-weight: 600; }
.invoice-actions {
  display: flex; flex-direction: column; gap: 8px; margin-top: 14px;
}
.invoice-actions a, .invoice-actions button { text-align: center; width: 100%; }
.btn-ghost, .btn-ok {
  border: none; border-radius: 12px; padding: 12px 18px; font-weight: 800; font-size: 14px; cursor: pointer;
}
.btn-ghost { background: #f1f5f9; color: var(--text); }
.btn-ok { background: var(--blue); color: #fff; }

/* Collection route cards */
.route-card {
  display: flex; gap: 12px; background: #fff; border: 2px solid #bae6fd;
  border-radius: 16px; padding: 14px; margin-bottom: 10px;
}
.route-card.done { opacity: 0.55; border-color: #bbf7d0; background: #f0fdf4; }
.route-no {
  width: 40px; height: 40px; border-radius: 12px; background: var(--navy); color: #fff;
  font-weight: 900; font-size: 18px; display: grid; place-items: center; flex-shrink: 0;
}
.route-body { flex: 1; min-width: 0; }
.route-body strong { font-size: 16px; font-weight: 900; }
.route-actions { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.btn-map, .btn-go {
  border: none; border-radius: 10px; padding: 10px 14px; font-weight: 800; font-size: 13px; cursor: pointer;
  text-decoration: none; display: inline-block;
}
.btn-map { background: #e0f2fe; color: var(--navy); }
.btn-go { background: var(--green); color: #fff; }
.badge-done { font-size: 12px; font-weight: 800; color: var(--green); padding: 10px 0; }

.ib-ref {
  display: inline-block; margin-left: 6px; padding: 2px 8px; border-radius: 999px;
  background: #0c4a6e; color: #7dd3fc; font-size: 11px; font-weight: 900; letter-spacing: 0.03em;
  vertical-align: middle;
}
.ib-ref.big {
  display: inline-block; margin: 8px 0; margin-left: 0; padding: 6px 12px; font-size: 14px;
}

.proof-block {
  background: #fff; border: 2px dashed #7dd3fc; border-radius: 14px;
  padding: 12px; margin-bottom: 10px;
}
.proof-label {
  display: block; font-size: 14px; font-weight: 800; color: var(--navy); cursor: pointer;
}
.proof-label input[type="file"] {
  display: block; width: 100%; margin-top: 8px; font-size: 13px;
}
.proof-preview {
  display: block; width: 100%; max-height: 160px; object-fit: cover;
  border-radius: 10px; margin-top: 10px; border: 1px solid #bae6fd;
}
.pay-grid { grid-template-columns: 1fr 1fr; }
.pay-grid .pay-btn:nth-child(5) { grid-column: 1 / -1; }

.contact-row {
  display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 14px 0 8px;
}
.btn-call, .btn-wa, .btn-map, .btn-go {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 12px 14px; border-radius: 10px; font-weight: 600; font-size: 13px;
  text-decoration: none; border: none; cursor: pointer; letter-spacing: 0.01em;
}
.btn-call { background: #0c4a6e; color: #fff; }
.btn-wa { background: #0f766e; color: #fff; }
.btn-map { background: #e2e8f0; color: #0f172a; }
.btn-go { background: #0369a1; color: #fff; }
.btn-call.sm, .btn-wa.sm, .btn-map.sm {
  padding: 10px 12px; min-width: 48px; font-size: 12px;
}
.contact-row .btn-call, .contact-row .btn-wa {
  padding: 14px; font-size: 14px; font-weight: 600;
}
.cust-card-wrap {
  display: flex; gap: 8px; align-items: stretch; margin-bottom: 8px;
}
.cust-card-wrap .cust-card { flex: 1; margin: 0; }
.cust-quick {
  display: flex; flex-direction: column; gap: 6px; justify-content: center;
}
