:root {
  --bg: #f4f6f8; --panel: #fff; --ink: #1b2430; --muted: #5d6b7a; --line: #dde3ea;
  --brand: #0b5cad; --brand-2: #e8f1fb; --ok: #1f8a4c; --warn: #b7791f; --bad: #c53030;
  --radius: 10px; --shadow: 0 1px 2px rgba(0,0,0,.06), 0 2px 8px rgba(0,0,0,.04);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; color: var(--ink);
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); font-size: 15px; line-height: 1.45; }
a { color: var(--brand); }
h1, h2, h3 { margin: 0 0 .5em; line-height: 1.2; }
h1 { font-size: 1.5rem; } h2 { font-size: 1.2rem; } h3 { font-size: 1.02rem; }
.muted { color: var(--muted); } .small { font-size: .85rem; }
.right { text-align: right; } .nowrap { white-space: nowrap; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.grow { flex: 1; }
.grid { display: grid; gap: 12px; }
.g2 { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.g3 { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
.g4 { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }

/* layout */
.app { display: grid; grid-template-columns: 220px 1fr; min-height: 100vh; }
.side { background: #0f2a44; color: #cfe0f1; padding: 16px 10px; position: sticky; top: 0; height: 100vh; overflow: auto; }
.side .brand { color: #fff; font-weight: 700; padding: 4px 10px 16px; font-size: 1.05rem; }
.side a { display: flex; justify-content: space-between; color: #cfe0f1; text-decoration: none; padding: 9px 10px; border-radius: 8px; margin-bottom: 2px; }
.side a:hover { background: rgba(255,255,255,.07); }
.side a.active { background: #1c4a75; color: #fff; }
.side .count { background: var(--bad); color: #fff; border-radius: 10px; padding: 0 7px; font-size: .78rem; }
.main { padding: 22px; max-width: 1400px; width: 100%; }
.topbar { display: none; }
@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .side { position: fixed; inset: 0 30% 0 0; z-index: 50; transform: translateX(-100%); transition: transform .2s; height: 100%; }
  .side.open { transform: none; }
  .topbar { display: flex; background: #0f2a44; color: #fff; padding: 10px 14px; gap: 12px; align-items: center; position: sticky; top: 0; z-index: 40; }
  .topbar button { background: none; border: 0; color: #fff; font-size: 1.4rem; padding: 0 4px; }
  .main { padding: 14px; }
}

/* components */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); margin-bottom: 14px; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; }
.stat b { display: block; font-size: 1.6rem; }
.btn, button { font: inherit; cursor: pointer; border-radius: 8px; border: 1px solid var(--line); background: #fff; padding: 8px 14px; color: var(--ink); }
.btn.primary, button.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.ok, button.ok { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn.bad, button.bad { background: #fff; border-color: var(--bad); color: var(--bad); }
.btn.small, button.small { padding: 4px 10px; font-size: .85rem; }
button:disabled { opacity: .55; cursor: default; }
a.btn { text-decoration: none; display: inline-block; }
label { display: block; font-size: .82rem; color: var(--muted); margin-bottom: 3px; font-weight: 600; }
input, select, textarea { font: inherit; width: 100%; padding: 8px 10px; border: 1px solid #c9d2dc; border-radius: 8px; background: #fff; color: var(--ink); }
textarea { min-height: 80px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid #9cc3ec; border-color: var(--brand); }
.field { margin-bottom: 10px; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 8px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: .78rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); }
tr.click { cursor: pointer; } tr.click:hover td { background: #f7fafd; }
.table-wrap { overflow-x: auto; }
.badge { display: inline-block; padding: 1px 8px; border-radius: 10px; font-size: .78rem; font-weight: 600; background: #eef1f4; color: #39485a; white-space: nowrap; }
.b-New { background: #fde8e8; color: #9b2c2c; } .b-Assigned, .b-Scheduled { background: #e8f1fb; color: #0b4f94; }
.b-Awaiting-Approval, .b-Sent, .b-Unpaid { background: #fff4e0; color: #8a5a00; }
.b-Approved, .b-In-Progress { background: #e6f6ec; color: #1f6b3e; } .b-Completed, .b-Paid, .b-Active { background: #dff3e6; color: #17603a; }
.b-Cancelled, .b-Declined, .b-Void { background: #eee; color: #666; }
.b-Emergency { background: var(--bad); color: #fff; } .b-High { background: #fde3cf; color: #9c4300; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 14px; flex-wrap: wrap; }
.tabs button { border: 0; border-bottom: 2px solid transparent; border-radius: 0; background: none; padding: 8px 12px; color: var(--muted); }
.tabs button.active { border-color: var(--brand); color: var(--brand); font-weight: 600; }
.notice { padding: 10px 12px; border-radius: 8px; background: var(--brand-2); border: 1px solid #c5dbf2; margin-bottom: 12px; }
.notice.warn { background: #fff7e6; border-color: #f2d49b; }
.notice.bad { background: #fdecec; border-color: #f3b7b7; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 4px 14px; }
.kv dt { color: var(--muted); font-size: .85rem; } .kv dd { margin: 0; font-weight: 500; }
.thumb { width: 100%; max-height: 220px; object-fit: contain; border-radius: 8px; border: 1px solid var(--line); background: #fafafa; }
.empty { padding: 26px; text-align: center; color: var(--muted); }
.toast { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); background: #1b2430; color: #fff; padding: 10px 18px; border-radius: 8px; z-index: 100; box-shadow: 0 6px 20px rgba(0,0,0,.2); }
.toast.err { background: var(--bad); }
dialog { border: 0; border-radius: 12px; padding: 0; width: min(760px, 96vw); max-height: 92vh; box-shadow: 0 20px 60px rgba(0,0,0,.3); }
dialog::backdrop { background: rgba(15,30,50,.45); }
dialog .dlg-head { padding: 14px 18px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; position: sticky; top: 0; background: #fff; z-index: 2; }
dialog .dlg-body { padding: 16px 18px; }
dialog .dlg-foot { padding: 12px 18px; border-top: 1px solid var(--line); display: flex; gap: 8px; justify-content: flex-end; position: sticky; bottom: 0; background: #fff; }
.spinner { display: inline-block; width: 16px; height: 16px; border: 2px solid #c9d2dc; border-top-color: var(--brand); border-radius: 50%; animation: spin .8s linear infinite; vertical-align: middle; }
@keyframes spin { to { transform: rotate(360deg); } }

/* scanner */
.scan-drop { border: 2px dashed #a9bccf; border-radius: 12px; padding: 26px; text-align: center; background: #f8fbfe; }
.review-field.ai input { background: #f3f9ff; }
.review-field .conf { font-size: .72rem; color: var(--muted); }

/* dispatch board */
.board { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(230px, 1fr); gap: 10px; overflow-x: auto; padding-bottom: 8px; }
.lane { background: #eaeff4; border-radius: 10px; padding: 8px; min-height: 360px; }
.lane h3 { font-size: .92rem; margin: 2px 4px 8px; display: flex; justify-content: space-between; }
.lane.drag-over { background: #d6e6f7; outline: 2px dashed var(--brand); }
.job { background: #fff; border: 1px solid var(--line); border-left: 4px solid var(--brand); border-radius: 8px; padding: 8px 9px; margin-bottom: 8px; cursor: grab; font-size: .86rem; }
.job.p-Emergency { border-left-color: var(--bad); } .job.p-High { border-left-color: #dd6b20; } .job.p-Low { border-left-color: #a0aec0; }
.job .t { font-weight: 600; }
.job.dragging { opacity: .5; }

/* estimate options */
.options { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.option { border: 2px solid var(--line); border-radius: 12px; padding: 14px; background: #fff; }
.option.chosen { border-color: var(--ok); background: #f3fbf6; }
.option .price { font-size: 1.5rem; font-weight: 700; }
.sigpad { border: 2px solid #9fb3c8; border-radius: 10px; background: #fff; width: 100%; height: 180px; touch-action: none; display: block; }

/* bars */
.bar { height: 10px; background: var(--brand); border-radius: 5px; }
.barrow { display: grid; grid-template-columns: 90px 1fr 110px; gap: 8px; align-items: center; margin-bottom: 6px; font-size: .86rem; }

/* print */
.print-only { display: none; }
@media print {
  .side, .topbar, .no-print, .tabs, button, .btn { display: none !important; }
  .app { display: block; } .main { padding: 0; }
  .card { box-shadow: none; border: 0; padding: 0; }
  .print-only { display: block; }
  body { background: #fff; font-size: 12px; }
  a { color: inherit; text-decoration: none; }
}

/* login */
.login { max-width: 380px; margin: 9vh auto; }
.hero { background: linear-gradient(135deg, #0f2a44, #0b5cad); color: #fff; padding: 56px 20px; text-align: center; }
.hero h1 { font-size: 2rem; }
.tiles { max-width: 980px; margin: -30px auto 40px; padding: 0 16px; display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.tile { background: #fff; border-radius: 12px; padding: 22px; box-shadow: 0 6px 24px rgba(0,0,0,.08); text-decoration: none; color: inherit; display: block; }
.tile:hover { outline: 2px solid var(--brand); }
