:root {
  --bg: #0f172a;
  --panel: #1e293b;
  --panel-2: #273449;
  --text: #e2e8f0;
  --muted: #94a3b8;
  --accent: #38bdf8;
  --green: #22c55e;
  --amber: #f59e0b;
  --red: #ef4444;
  --line: #334155;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
}
.app { max-width: 720px; margin: 0 auto; padding: 12px 12px 96px; }
.loading { color: var(--muted); text-align: center; padding: 40px; }

h1, h2, h3 { margin: 0 0 8px; }
button {
  font: inherit; color: var(--text); background: var(--panel-2);
  border: 1px solid var(--line); border-radius: 10px; padding: 10px 14px; cursor: pointer;
}
button.primary { background: var(--accent); color: #04263b; border-color: transparent; font-weight: 700; }
button.danger { background: transparent; border-color: var(--red); color: #fecaca; }
button.ghost { background: transparent; }
button:disabled { opacity: .5; }
input, select {
  font: inherit; color: var(--text); background: #0b1424;
  border: 1px solid var(--line); border-radius: 10px; padding: 10px;
}
label { display: block; color: var(--muted); font-size: 13px; margin: 8px 0 4px; }
[hidden] { display: none !important; }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 14px; margin: 10px 0; }
.row { display: flex; gap: 10px; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.spread { justify-content: space-between; }
.muted { color: var(--muted); }
.pill { font-size: 12px; padding: 2px 8px; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); }
.pill.green { color: #052e16; background: var(--green); border-color: transparent; }
.pill.amber { color: #3b2706; background: var(--amber); border-color: transparent; }
.pill.red { color: #450a0a; background: var(--red); border-color: transparent; }
.right { margin-left: auto; }
.stack > * + * { margin-top: 8px; }

/* shift bar */
.shift-bar {
  position: sticky; top: 0; z-index: 10; display: flex; gap: 8px; align-items: center;
  background: #0b1424; border-bottom: 1px solid var(--line); padding: 8px 12px;
}
.shift-bar .state { font-weight: 700; }
.shift-bar .right { display: flex; gap: 6px; }
.net-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--green); }
.net-dot.off { background: var(--red); }
.queue-badge { font-size: 12px; color: var(--amber); }

/* stops */
.stop { display: flex; gap: 12px; align-items: flex-start; }
.seq { width: 30px; height: 30px; border-radius: 50%; background: var(--panel-2); display: grid; place-items: center; font-weight: 700; flex: 0 0 auto; }
.addr { color: var(--muted); font-size: 14px; }

/* delivery note */
.pallet-head { font-weight: 700; border-bottom: 1px solid var(--line); padding-bottom: 6px; margin-bottom: 6px; }
.item { padding: 8px; border: 1px solid var(--line); border-radius: 10px; margin: 6px 0; background: var(--panel-2); }
.item.confirmed { opacity: .6; }
.item .qty { display: flex; gap: 8px; align-items: center; }
.item .name { font-weight: 600; }
.shortfall { color: var(--red); font-size: 12px; }
.confirm-toggle { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 14px; }

/* mis-delivery guard */
.guard { text-align: center; padding: 24px 14px; }
.guard .big { font-size: 26px; font-weight: 800; margin: 8px 0; }
.guard .addr { font-size: 18px; color: var(--text); }

/* signature */
canvas.sig { width: 100%; height: 180px; background: #fff; border-radius: 10px; touch-action: none; }

/* sticky action bar */
.actions { position: fixed; left: 0; right: 0; bottom: 0; padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
  background: linear-gradient(180deg, transparent, #0b1424 30%); display: flex; gap: 10px; }
.actions .app-inner { max-width: 720px; margin: 0 auto; width: 100%; display: flex; gap: 10px; }

/* toast */
.toast { position: fixed; left: 50%; bottom: 84px; transform: translateX(-50%);
  background: #0b1424; border: 1px solid var(--amber); color: #fde68a; padding: 10px 14px;
  border-radius: 10px; max-width: 90%; z-index: 30; }

/* map */
.map { height: 180px; border-radius: 12px; overflow: hidden; background: #0b1424; position: relative; border: 1px solid var(--line); }
.map svg { width: 100%; height: 100%; }
.back { background: transparent; border: none; color: var(--accent); padding: 6px 0; }
