* { box-sizing: border-box; margin: 0; -webkit-tap-highlight-color: transparent; }
/* hidden means hidden, whatever display rule the element has */
[hidden] { display: none !important; }
:root {
  --bar: #1b2a41;
  --bar-text: #e8eef7;
  --accent: #e0a100;
  --line: #d8dde4;
  --muted: #6b7686;
  --bg: #f4f6f8;
  --card: #fff;
  --text: #22293a;
  --waiting: #f5a623;
  --dispatched: #2b5bd7;
  --enroute: #1fa88a;
  --onscene: #1d7a34;
  --towing: #47a8e5;
  --completed: #8a94a3;
  --cancelled: #c0392b;
}
html { -webkit-text-size-adjust: 100%; }
body {
  font: 16px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  padding-bottom: env(safe-area-inset-bottom);
}
button { font: inherit; color: inherit; }
input { font: inherit; }

/* ---------- top bar ---------- */
#bar {
  position: sticky; top: 0; z-index: 5;
  background: var(--bar); color: var(--bar-text);
  display: flex; align-items: center; justify-content: center;
  min-height: 48px;
  padding: env(safe-area-inset-top) 12px 0;
  padding-left: max(12px, env(safe-area-inset-left));
  padding-right: max(12px, env(safe-area-inset-right));
}
#brand { font-weight: 700; letter-spacing: 1px; font-size: 15px; padding: 13px 0; }
#brand span { color: var(--accent); }
#back, #refresh {
  position: absolute; bottom: 0; height: 48px;
  background: none; border: 0; color: var(--bar-text); font-size: 17px; padding: 0 12px;
}
#back { left: max(0px, env(safe-area-inset-left)); }
#refresh { right: max(0px, env(safe-area-inset-right)); font-size: 22px; }
#gear { position: absolute; bottom: 0; height: 48px; background: none; border: 0; color: var(--bar-text);
  font-size: 22px; padding: 0 12px; right: calc(max(0px, env(safe-area-inset-right)) + 44px); }

section { padding: 12px; padding-left: max(12px, env(safe-area-inset-left));
  padding-right: max(12px, env(safe-area-inset-right)); }

/* ---------- sign in ---------- */
#signin-form { max-width: 320px; margin: 18vh auto 0; display: flex; flex-direction: column; gap: 12px; }
#signin-form label { font-weight: 600; text-align: center; }
#pin { font-size: 28px; letter-spacing: 8px; text-align: center; padding: 12px;
  border: 1px solid var(--line); border-radius: 10px; background: #fff; }
.error { color: var(--cancelled); text-align: center; min-height: 1.4em; }

button.primary {
  background: var(--accent); color: #1b2a41; font-weight: 700; border: 0;
  border-radius: 10px; padding: 14px; font-size: 17px;
}
button.link { background: none; border: 0; color: var(--muted); text-decoration: underline;
  display: block; margin: 24px auto 8px; font-size: 14px; }

/* ---------- lists ---------- */
#tabs { display: flex; gap: 6px; margin-bottom: 10px; overflow-x: auto; -webkit-overflow-scrolling: touch;
  scrollbar-width: none; padding-bottom: 2px; }
#tabs::-webkit-scrollbar { display: none; }
#tabs button {
  flex: 0 0 auto; padding: 9px 12px; border: 1px solid var(--line); border-radius: 9px;
  background: #fff; font-size: 15px; white-space: nowrap;
}
#tabs button.on { background: var(--bar); color: var(--bar-text); border-color: var(--bar); }
#search {
  width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px;
  background: #fff; margin-bottom: 10px; -webkit-appearance: none; appearance: none;
}
#home-hint {
  background: #fff7e0; border: 1px solid #f0d58a; border-radius: 10px;
  padding: 10px 36px 10px 12px; margin-bottom: 10px; font-size: 14px; position: relative;
}
#home-hint button { position: absolute; top: 4px; right: 6px; background: none; border: 0;
  font-size: 22px; color: var(--muted); }

.card {
  display: block; width: 100%; text-align: left;
  background: var(--card); border: 1px solid var(--line); border-left: 6px solid var(--line);
  border-radius: 10px; padding: 10px 12px; margin-bottom: 8px;
}
.card .top { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.card .num { font-weight: 700; }
.card .st { font-size: 13px; color: var(--muted); }
.card .veh { font-weight: 600; margin-top: 2px; }
.card .line { font-size: 14px; color: #3a4354; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card .bal { font-weight: 700; }
.card .notes { font-size: 13px; color: var(--muted); margin-top: 3px; white-space: pre-line;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.card .notes b { color: var(--text); font-weight: 600; }
.paid { color: var(--onscene); font-weight: 700; }
.empty { text-align: center; color: var(--muted); padding: 30px 0; }

.st-waiting { border-left-color: var(--waiting) !important; }
.st-dispatched { border-left-color: var(--dispatched) !important; }
.st-enroute { border-left-color: var(--enroute) !important; }
.st-onscene { border-left-color: var(--onscene) !important; }
.st-towing { border-left-color: var(--towing) !important; }
.st-completed { border-left-color: var(--completed) !important; }
.st-cancelled { border-left-color: var(--cancelled) !important; }

.pill { display: inline-block; color: #fff; border-radius: 99px; padding: 2px 10px; font-size: 13px;
  font-weight: 600; }
.bg-waiting { background: var(--waiting); }
.bg-dispatched { background: var(--dispatched); }
.bg-enroute { background: var(--enroute); }
.bg-onscene { background: var(--onscene); }
.bg-towing { background: var(--towing); }
.bg-completed { background: var(--completed); }
.bg-cancelled { background: var(--cancelled); }

/* ---------- one call ---------- */
.call-head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.call-head h1 { font-size: 22px; }
.emergency { color: var(--cancelled); font-weight: 700; font-size: 14px; }
.actions { display: flex; flex-direction: column; gap: 8px; margin-bottom: 14px; }
.actions .row { display: flex; gap: 8px; }
.actions .row button, .actions .row a { flex: 1; }
.btn {
  border: 1px solid var(--line); background: #fff; border-radius: 10px; padding: 12px;
  font-size: 16px; font-weight: 600;
}
.btn.go { background: var(--dispatched); border-color: var(--dispatched); color: #fff; font-size: 18px; padding: 15px; }
.btn.done { background: var(--onscene); border-color: var(--onscene); color: #fff; }
.btn.warn { color: var(--cancelled); }
.btn:disabled { opacity: .5; }

.box { background: var(--card); border: 1px solid var(--line); border-radius: 10px;
  padding: 10px 12px; margin-bottom: 10px; }
.box h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .5px; color: var(--muted);
  margin-bottom: 6px; }
.kv { display: flex; gap: 10px; padding: 3px 0; }
.kv b { flex: 0 0 92px; font-weight: 600; color: var(--muted); font-size: 14px; padding-top: 1px; }
.kv span { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.addr { padding: 4px 0 8px; }
.addr + .addr { border-top: 1px solid var(--line); padding-top: 8px; }
.addr .lbl { font-size: 13px; color: var(--muted); font-weight: 600; }
.addr .txt { margin: 2px 0 6px; }
.tap { display: inline-block; text-decoration: none; background: var(--bar); color: var(--bar-text);
  border-radius: 9px; padding: 9px 14px; font-weight: 600; font-size: 15px; margin-right: 6px; }
.tap.light { background: #fff; color: var(--bar); border: 1px solid var(--bar); }
button.tap { font-family: inherit; line-height: normal; cursor: pointer; }
.veh + .veh { border-top: 1px solid var(--line); margin-top: 6px; padding-top: 6px; }
.money { width: 100%; border-collapse: collapse; font-size: 15px; }
.money td { padding: 3px 0; vertical-align: top; }
.money td:last-child { text-align: right; white-space: nowrap; padding-left: 10px; }
.money tr.sum td { border-top: 1px solid var(--line); font-weight: 700; padding-top: 6px; }
.money tr.bal td { font-weight: 700; font-size: 17px; }
.money .ref { font-size: 12px; color: var(--muted); max-width: 58vw; overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap; }
.note { white-space: pre-wrap; }
.inote { font-size: 14px; padding: 4px 0; }
.inote + .inote { border-top: 1px solid var(--line); }
.inote small { color: var(--muted); display: block; }
.times { font-size: 14px; }

/* ---------- forms ---------- */
button.wide { width: 100%; margin-bottom: 10px; }
.btn.wide-btn { width: 100%; margin-top: 6px; font-size: 15px; }
.edit-btn { margin-left: auto; padding: 7px 16px; font-size: 15px; }
.veh-block { border-top: 1px solid var(--line); padding-top: 8px; margin-top: 8px; }
.veh-block:first-child { border-top: 0; padding-top: 0; margin-top: 0; }
.veh-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; font-size: 14px; }
#new-form .veh-block input, #new-form .veh-block select { margin-bottom: 8px; }
a.link-btn { display: block; text-align: center; text-decoration: none; color: var(--text); }
.form-title { font-size: 20px; margin: 2px 0 10px; }
#v-new input, #v-new select, #v-new textarea, #sheet input, #sheet select {
  display: block; width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 9px;
  background: #fff; font-size: 16px; margin-bottom: 8px; -webkit-appearance: none; appearance: none;
}
#v-new select, #sheet select {
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 18px) 55%, calc(100% - 12px) 55%; background-size: 6px 6px; background-repeat: no-repeat;
}
#v-new textarea { resize: vertical; }
#v-new label, #sheet label { display: block; font-size: 13px; font-weight: 600; color: var(--muted); }
#v-new label select, #sheet label input, #sheet label select { margin-top: 3px; color: var(--text); font-weight: 400; }
#v-new label.check { display: flex; align-items: center; gap: 8px; font-size: 16px; color: var(--text); font-weight: 400; padding: 4px 0; }
#v-new label.check input { width: 22px; height: 22px; margin: 0; -webkit-appearance: checkbox; appearance: auto; }
.grid3 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 8px; }
.grid3 input[name="year"] { grid-column: 1 / -1; }
.field-label { font-size: 13px; font-weight: 600; color: var(--muted); }
.eta-picker .eta-time { display: grid; grid-template-columns: 1fr 1fr 1.2fr; gap: 0 8px; }
.eta-picker .eta-day, .eta-picker .eta-text { margin-top: 3px; }
.eta-picker .eta-type { display: flex; gap: 8px; align-items: flex-start; }
.eta-picker .eta-type input { flex: 1; min-width: 0; }
.eta-picker .eta-clear { flex: none; margin-top: 3px; padding: 10px 14px; border: 1px solid var(--line); background: #fff;
  border-radius: 9px; font-size: 15px; font-weight: 600; color: var(--cancelled); }
.ac { position: relative; }
.ac-list { background: #fff; border: 1px solid var(--line); border-radius: 9px; margin: -4px 0 8px; overflow: hidden; }
.ac-list button { display: block; width: 100%; text-align: left; background: none; border: 0;
  padding: 11px 12px; font-size: 15px; border-bottom: 1px solid var(--line); }
.ac-list button:last-child { border-bottom: 0; }
.box .add { background: none; border: 1px dashed var(--line); border-radius: 9px; width: 100%;
  padding: 10px; margin-top: 8px; color: var(--dispatched); font-weight: 600; font-size: 15px; }
.box .pay-row { display: flex; gap: 8px; margin-top: 8px; }
.box .pay-row .btn { flex: 1; font-size: 15px; padding: 11px 8px; }
.photos { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.photos .ph { padding: 0; border: 0; background: #e6e9ee; border-radius: 6px; overflow: hidden; aspect-ratio: 1; }
.photos .ph img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo-waiting { font-size: 13px; color: var(--muted); margin: 6px 0 0; }
/* Status and times (Edit) */
.status-times .st-status { display: flex; align-items: center; gap: 10px; }
.status-times .st-status select { flex: 1; }
.status-times .st-times label { display: flex; align-items: center; gap: 10px; margin-top: 8px; }
.status-times .st-times label span { width: 84px; flex: none; color: var(--muted); font-size: 13px; }
.status-times .st-times input { flex: 1; min-width: 0; }
.status-times .st-hint { color: var(--muted); font-size: 13px; margin: 8px 0 0; }
.box .row .add { flex: 1; margin-top: 8px; }
/* the camera sheet */
.cam-view { display: block; width: 100%; max-height: 55vh; background: #000; border-radius: 10px; object-fit: cover; }
.cam-view.flash { opacity: .4; }
.cam-strip { display: flex; gap: 6px; overflow-x: auto; min-height: 56px; padding: 8px 0; }
.cam-strip img { height: 56px; width: 56px; object-fit: cover; border-radius: 6px; flex: none; }
.cam-bar { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.cam-bar .btn { flex: 1; }
.cam-shutter { flex: none; width: 68px; height: 68px; border-radius: 50%; border: 5px solid #fff; background: var(--cancelled); box-shadow: 0 0 0 2px var(--line); }
.cam-shutter:active { transform: scale(.94); }
.cam-shutter:disabled { opacity: .35; }
label.add { display: block; text-align: center; border: 1px dashed var(--line); border-radius: 9px;
  padding: 10px; margin-top: 8px; color: var(--dispatched); font-weight: 600; font-size: 15px; }
label.add input { display: none; }
.photo-full { display: block; width: 100%; border-radius: 8px; background: #000; margin-bottom: 8px; }
.photo-meta { color: var(--muted); font-size: 14px; margin: -4px 0 8px; }
.sig-row { display: flex; gap: 10px; align-items: center; width: 100%; text-align: left; background: none;
  border: 0; border-bottom: 1px solid var(--line); padding: 8px 0; }
.sig-row img { width: 96px; height: 40px; object-fit: contain; background: #fff; border: 1px solid var(--line); border-radius: 4px; }
.sig-row small { color: var(--muted); }
.sig-row.waiting { padding-left: 4px; }
.wait-dot { flex: 0 0 12px; height: 12px; border-radius: 50%; background: var(--waiting); margin: 0 6px 0 2px; }
.statement { font-size: 15px; line-height: 1.45; background: #fff; border: 1px solid var(--line); border-radius: 9px;
  padding: 10px 12px; margin-bottom: 10px; }
.pad-label { font-size: 13px; font-weight: 600; color: var(--muted); margin: 4px 0 3px; }
canvas.pad { display: block; width: 100%; height: 190px; background: #fff; border: 1px solid #9aa3b0; border-radius: 9px;
  touch-action: none; }
.sig-full { display: block; width: 100%; background: #fff; border: 1px solid var(--line); border-radius: 8px; margin-bottom: 6px; }
.hold { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-top: 8px;
  padding: 8px 10px; border-radius: 9px; background: #f4f6f8; font-size: 15px; }
.hold.live { background: #fff7e0; border: 1px solid #f0d58a; }
.hold small { color: var(--muted); }
.hold .btn { padding: 8px 12px; font-size: 14px; }
.hold-btns { display: flex; flex-direction: column; gap: 6px; }
.btn.goa { color: #7a4b00; }
#card-box { min-height: 90px; }
.subtabs { display: flex; gap: 6px; margin-bottom: 10px; }
.subtabs button { flex: 1; padding: 8px 4px; border: 1px solid var(--line); border-radius: 9px; background: #fff; font-size: 14px; }
.subtabs button.on { background: var(--dispatched); color: #fff; border-color: var(--dispatched); }
.rep-controls { display: flex; gap: 8px; margin-bottom: 10px; }
.rep-controls select, .rep-controls input { flex: 1; padding: 9px 10px; border: 1px solid var(--line); border-radius: 9px; background: #fff; font-size: 15px; }
.rep-cards { display: flex; gap: 8px; margin-bottom: 10px; }
.rep-cards div { flex: 1; background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; }
.rep-cards span { display: block; font-size: 12px; color: var(--muted); }
.rep-cards b { font-size: 17px; }
.sq-item .top { display: flex; justify-content: space-between; align-items: baseline; }
.row-inline { display: flex; gap: 8px; margin-top: 8px; }
.phone-row { display: flex; gap: 8px; align-items: flex-start; }
.contact-block + .contact-block { border-top: 1px solid var(--line); padding-top: 8px; margin-top: 2px; }
.contact-remove { flex: none; width: 40px; height: 44px; border: 1px solid var(--line); border-radius: 9px; background: #fff; color: var(--cancelled); font-size: 22px; line-height: 1; }
.contact.more { border-top: 1px solid var(--line); padding-top: 8px; margin-top: 8px; }
.bill { margin-bottom: 12px; }
.received { text-align: center; padding: 12px 4px 0; }
.received .check { width: 72px; height: 72px; line-height: 72px; margin: 0 auto 12px; border-radius: 50%;
  background: var(--onscene); color: #fff; font-size: 42px; font-weight: 700; }
.received h2 { margin: 0 0 8px; font-size: 22px; color: var(--onscene); }
.received .card-line { font-weight: 700; font-size: 17px; margin: 10px 0; }
.phone-row input { flex: 1; min-width: 0; }
.phone-row .paste-btn { flex: none; padding: 10px 14px; font-size: 15px; }
.row-inline input { flex: 1; min-width: 0; padding: 10px 12px; border: 1px solid var(--line); border-radius: 9px; font-size: 16px; }
.check-row { display: flex !important; align-items: center; gap: 8px; font-size: 16px !important; color: var(--text) !important; font-weight: 400 !important; margin-bottom: 8px; }
.check-row input { width: 22px; height: 22px; margin: 0 !important; -webkit-appearance: checkbox; appearance: auto; }
#v-settings input, #v-settings select, #v-settings textarea, #f-square input, #f-square select {
  display: block; width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 9px;
  background: #fff; font-size: 16px; margin: 3px 0 8px; -webkit-appearance: none; appearance: none; }
#v-settings label { display: block; font-size: 13px; font-weight: 600; color: var(--muted); }
/* Settings drawn from the registry (shared/settings-ui.js) */
.st-section { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; margin-bottom: 12px; }
.st-section h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); margin: 0 0 8px; }
.st-help { font-size: 13px; color: var(--muted); margin: -4px 0 10px; }
#v-settings .st-check { display: flex; align-items: center; gap: 8px; font-size: 16px; color: var(--text); font-weight: 400; padding: 4px 0 8px; }
#v-settings .st-check input { width: 22px; height: 22px; margin: 0; flex: none; -webkit-appearance: checkbox; appearance: auto; }
.st-group { border-top: 1px solid var(--line); padding-top: 10px; margin-top: 6px; }
.st-group-head { font-weight: 700; margin-bottom: 4px; }
.st-group-head small { color: var(--muted); font-weight: 400; }
.st-row { display: flex; gap: 6px; align-items: center; margin-bottom: 6px; }
.st-row input, .st-row select { margin: 0 !important; }
.st-row .st-name { flex: 2; min-width: 0; }
.st-row .st-extra, .st-row select { flex: 1; min-width: 0; }
.st-row.hidden-row .st-name { color: var(--muted); text-decoration: line-through; }
.st-move { flex: none; width: 34px; height: 40px; border: 1px solid var(--line); border-radius: 8px; background: #fff; font-size: 12px; }
.st-move:disabled { opacity: .3; }
#v-settings .st-hide { flex: none; display: flex; align-items: center; gap: 4px; font-size: 12px; color: var(--muted); font-weight: 400; }
#v-settings .st-hide input { width: 20px; height: 20px; -webkit-appearance: checkbox; appearance: auto; }
.st-add { display: flex; gap: 8px; margin-top: 8px; }
.st-add input { flex: 1; margin: 0 !important; }
.st-add-btn { flex: none; padding: 0 16px; border: 1px solid var(--line); border-radius: 9px; background: #fff; font-weight: 600; }
.st-list-error { color: var(--cancelled); font-size: 13px; min-height: 1em; margin: 6px 0 0; }
#v-settings label.check { display: flex; align-items: center; gap: 8px; font-size: 16px; color: var(--text); font-weight: 400; padding: 4px 0 8px; }
#v-settings label.check input { width: 22px; height: 22px; margin: 0; flex: none; -webkit-appearance: checkbox; appearance: auto; }
.money .x { background: none; border: 0; color: var(--cancelled); font-size: 20px; line-height: 1; padding: 0 0 0 10px; }

#sheet-back { position: fixed; inset: 0; background: rgba(20, 28, 45, .45); z-index: 20; }
#sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 21; background: var(--bg);
  border-radius: 16px 16px 0 0; max-height: 88vh; overflow-y: auto;
  padding: 14px max(14px, env(safe-area-inset-right)) calc(16px + env(safe-area-inset-bottom)) max(14px, env(safe-area-inset-left));
}
#sheet.photo-mode { touch-action: pan-y; }   /* sideways swipes belong to the photo viewer */
#sheet h1 { font-size: 19px; margin-bottom: 10px; display: flex; justify-content: space-between; align-items: center; }
#sheet h1 button { background: none; border: 0; font-size: 26px; color: var(--muted); line-height: 1; }
#sheet .actions { margin: 6px 0 0; }
#sheet .qr { display: block; width: 240px; height: 240px; margin: 6px auto 10px; background: #fff; border-radius: 8px; }
#sheet .due { font-size: 22px; font-weight: 700; margin-bottom: 8px; }
#sheet .link-url { font-size: 13px; color: var(--muted); word-break: break-all; margin-bottom: 10px; text-align: center; }
#sheet .or { text-align: center; color: var(--muted); font-size: 13px; margin: 10px 0; }

#toast {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(20px + env(safe-area-inset-bottom));
  background: #22293a; color: #fff; padding: 10px 16px; border-radius: 10px; font-size: 15px;
  max-width: 90vw; z-index: 30;
}
