:root {
  --bg: #14171c; --panel: #1d2128; --panel2: #252a33; --line: #323843;
  --text: #e6e8eb; --muted: #9aa3ae; --accent: #f5a524; --accent-ink: #1a1300;
  --ok: #3ccf7a; --warn: #f5a524; --bad: #ef5b5b; --info: #5aa9ff;
  --radius: 12px; --tap: 48px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body { padding-bottom: env(safe-area-inset-bottom); -webkit-tap-highlight-color: transparent; }
a { color: var(--accent); }
.boot { padding: 40px; text-align: center; color: var(--muted); }
.muted { color: var(--muted); } .small { font-size: 13px; }
h2 { font-size: 17px; margin: 0 0 12px; } h3 { font-size: 15px; margin: 0 0 10px; }

/* header */
.top { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 10px;
  padding: calc(10px + env(safe-area-inset-top)) 14px 10px; background: #0f1215; border-bottom: 1px solid var(--line); }
.top .brand { color: var(--text); font-weight: 700; text-decoration: none; white-space: nowrap; }
.top .title { color: var(--muted); flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.top nav { display: flex; gap: 4px; }
.top nav a, .top .back { color: var(--text); text-decoration: none; padding: 8px 12px; border-radius: 8px; background: var(--panel); }
.top .back { font-size: 22px; line-height: 1; padding: 6px 12px; }
main { max-width: 900px; margin: 0 auto; padding: 14px; display: grid; gap: 14px; }

/* cards */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; }
.card.warn { border-color: var(--warn); background: #2a2414; }
.row { display: flex; gap: 8px; align-items: center; }
.row > * { flex: 1; } .row > button, .row > .shrink { flex: 0 0 auto; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
@media (max-width: 520px) { .grid2, .grid3 { grid-template-columns: 1fr 1fr; } }
.span2 { grid-column: span 2; }

/* forms */
label { display: grid; gap: 4px; font-size: 13px; color: var(--muted); }
input, select, textarea, button { font: inherit; color: var(--text); }
input, select, textarea {
  width: 100%; min-height: var(--tap); padding: 10px 12px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--panel2); font-size: 16px; }
textarea { min-height: 110px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
input.mono, .mono { font-family: ui-monospace, Consolas, monospace; letter-spacing: .5px; }
input.big { font-size: 22px; font-weight: 700; text-transform: uppercase; }
button { min-height: var(--tap); padding: 0 16px; border-radius: 10px; border: 0; cursor: pointer;
  background: var(--accent); color: var(--accent-ink); font-weight: 650; }
button.ghost { background: var(--panel2); color: var(--text); border: 1px solid var(--line); }
button.danger { background: transparent; color: var(--bad); border: 1px solid var(--bad); }
button:disabled { opacity: .5; cursor: default; }
button.icon { min-height: 40px; width: 40px; padding: 0; background: transparent; color: var(--muted); font-size: 18px; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; }

/* tabs & chips */
.tabs { display: flex; gap: 6px; margin-bottom: 10px; }
.tabs button { background: var(--panel2); color: var(--muted); border: 1px solid var(--line); min-height: 40px; }
.tabs button.on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.chip { min-height: 36px; padding: 0 12px; border-radius: 18px; background: var(--panel2); color: var(--text);
  border: 1px solid var(--line); font-weight: 500; font-size: 14px; }
.badge { display: inline-block; padding: 2px 8px; border-radius: 10px; font-size: 12px; font-weight: 650;
  background: var(--panel2); color: var(--muted); border: 1px solid var(--line); white-space: nowrap; }
.badge.open { color: var(--info); border-color: var(--info); }
.badge.in_progress { color: var(--accent); border-color: var(--accent); }
.badge.waiting_parts { color: #c084fc; border-color: #c084fc; }
.badge.complete { color: var(--ok); border-color: var(--ok); }
.badge.alert { color: var(--accent-ink); background: var(--warn); border-color: var(--warn); }

/* job list */
.list { display: grid; gap: 8px; margin-top: 10px; }
.job-row { display: grid; grid-template-columns: 1fr auto; gap: 4px 10px; padding: 12px; border-radius: 10px;
  background: var(--panel2); border: 1px solid var(--line); text-decoration: none; color: var(--text); }
.job-row .num { font-weight: 750; font-size: 17px; }
.job-row .sub { color: var(--muted); font-size: 14px; }
.job-row .right { text-align: right; display: grid; gap: 4px; justify-items: end; }
.mini-progress { width: 80px; height: 6px; border-radius: 3px; background: var(--line); overflow: hidden; }
.mini-progress > div { height: 100%; background: var(--ok); }

/* job header */
.job-head { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; }
.job-head > div:first-child { flex: 1 1 auto; min-width: 0; }
.job-head > div:last-child { flex: 0 1 40%; }
.job-head .num { font-size: 26px; font-weight: 800; letter-spacing: .5px; white-space: nowrap; }
.job-head a.phone { display: inline-block; margin-top: 6px; font-size: 17px; text-decoration: none; white-space: nowrap; }
.sync { font-size: 12px; color: var(--muted); }

/* checklist */
.progress { height: 10px; background: var(--line); border-radius: 5px; overflow: hidden; }
.progress > div { height: 100%; background: var(--ok); transition: width .3s; }
.tasks { list-style: none; padding: 0; margin: 10px 0; display: grid; gap: 6px; }
.task { display: grid; grid-template-columns: 1fr auto auto; align-items: center; gap: 2px;
  background: var(--panel2); border: 1px solid var(--line); border-radius: 10px; padding: 4px 4px 4px 10px; }
.task label { display: flex; align-items: center; gap: 12px; color: var(--text); font-size: 16px; min-height: 52px; cursor: pointer; }
.task input[type=checkbox] { width: 28px; height: 28px; min-height: 0; flex: 0 0 28px; accent-color: var(--ok); }
.task .meta { grid-column: 1 / -1; padding: 0 0 6px 40px; font-size: 12px; color: var(--muted); display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.task .meta:empty { display: none; }
.task .note { width: 100%; color: var(--text); font-size: 13px; }
.task.done .desc { color: var(--muted); text-decoration: line-through; text-decoration-color: var(--ok); }
.task.removed { opacity: .55; } .task.removed .desc { text-decoration: line-through; }
.tag { font-size: 11px; padding: 1px 6px; border-radius: 6px; border: 1px solid currentColor; }
.tag.rule { color: var(--info); } .tag.changed { color: var(--warn); } .tag.removed { color: var(--bad); } .tag.manual { color: var(--muted); }

/* docs & photos */
.docs { display: grid; gap: 6px; }
.doc { display: flex; align-items: center; gap: 10px; padding: 12px; border-radius: 10px; background: var(--panel2);
  border: 1px solid var(--line); color: var(--text); text-decoration: none; }
.doc .ico { font-size: 22px; } .doc .t { flex: 1; font-weight: 600; } .doc .s { font-size: 12px; color: var(--muted); }
.photos { display: grid; grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); gap: 6px; }
.photos img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 8px; background: var(--panel2); cursor: pointer; }
.add-photo { aspect-ratio: 1; display: grid; place-items: center; border: 2px dashed var(--line); border-radius: 8px;
  color: var(--muted); font-size: 13px; text-align: center; cursor: pointer; }
.add-photo input { display: none; }
.lightbox { position: fixed; inset: 0; z-index: 50; background: rgba(0,0,0,.92); display: grid; grid-template-rows: 1fr auto; }
.lightbox img { max-width: 100%; max-height: 100%; margin: auto; object-fit: contain; }
.lightbox .bar { display: flex; gap: 8px; padding: 12px; justify-content: space-between; align-items: center; }

/* banner, toasts */
.changes ul { margin: 6px 0 10px; padding-left: 20px; }
#toasts { position: fixed; left: 0; right: 0; bottom: calc(14px + env(safe-area-inset-bottom)); display: grid; justify-items: center; gap: 6px; z-index: 60; pointer-events: none; }
.toast { background: #000; color: #fff; border: 1px solid var(--line); padding: 10px 16px; border-radius: 10px; max-width: 92vw; box-shadow: 0 6px 20px rgba(0,0,0,.4); }
.toast.error { border-color: var(--bad); } .toast.ok { border-color: var(--ok); }

/* login */
.login { max-width: 380px; margin: 12vh auto; display: grid; gap: 12px; }

/* settings tables */
.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
.tbl td, .tbl th { padding: 8px 6px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }

/* ---------------------------------------------------------- repair order printout */
.print-tools { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; align-items: center; padding: 6px 0 2px; }
.pt-opt { display: flex; align-items: center; gap: 6px; color: var(--text); font-size: 14px; }
.pt-opt input { width: 20px; min-height: 0; height: 20px; }
.ro-wrap { overflow-x: auto; padding-bottom: 20px; }
.ro {
  --ink: #111; --rule: #1f2937; --soft: #6b7280; --band: #1f2937; --tint: #f3f4f6;
  width: 210mm; min-height: 297mm; margin: 0 auto; padding: 12mm; background: #fff; color: var(--ink);
  font: 9.5pt/1.35 "Segoe UI", Roboto, Helvetica, Arial, sans-serif; box-shadow: 0 10px 40px rgba(0,0,0,.45);
  -webkit-print-color-adjust: exact; print-color-adjust: exact;
}
.ro * { box-sizing: border-box; }
.ro-head { display: flex; justify-content: space-between; align-items: stretch; gap: 16px; padding-bottom: 8px; border-bottom: 3px solid var(--band); }
.ro-biz { display: flex; gap: 12px; align-items: center; min-width: 0; }
.ro-logo { max-height: 22mm; max-width: 55mm; object-fit: contain; }
.ro-bizname { font-size: 16pt; font-weight: 800; letter-spacing: .3px; text-transform: uppercase; }
.ro-contact { font-size: 8.5pt; color: var(--soft); }
.ro-id { text-align: right; display: flex; flex-direction: column; align-items: flex-end; justify-content: space-between; border: 2px solid var(--band); padding: 6px 10px; min-width: 62mm; }
.ro-title { background: var(--band); color: #fff; font-weight: 800; font-size: 9pt; letter-spacing: 2px; padding: 2px 8px; margin: -6px -10px 4px; align-self: stretch; text-align: center; }
.ro-num { font-size: 22pt; font-weight: 800; letter-spacing: 1px; line-height: 1.1; }
.ro-barcode { fill: #000; margin-top: 4px; max-width: 100%; }

.ro-cols { display: grid; grid-template-columns: 1fr 1.25fr; gap: 8px; margin-top: 8px; }
.ro-box { border: 1.5px solid var(--rule); padding: 0 8px 6px; }
.ro-label { background: var(--band); color: #fff; font-size: 7.5pt; font-weight: 700; letter-spacing: 1.5px; text-transform: uppercase; margin: 0 -8px 6px; padding: 2px 8px; }
.kv { display: flex; flex-direction: column; border-bottom: 1px solid #d1d5db; padding: 2px 0 3px; min-width: 0; }
.kv span { font-size: 6.5pt; color: var(--soft); text-transform: uppercase; letter-spacing: .8px; }
.kv b { font-weight: 600; font-size: 10pt; min-height: 1.3em; overflow-wrap: anywhere; }
.kv.big b { font-size: 14pt; font-weight: 800; letter-spacing: 1px; }
.kv.mono b { font-family: Consolas, "Courier New", monospace; letter-spacing: 1.5px; }
.kv-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.ro table { width: 100%; border-collapse: collapse; }
.ro-strip { margin-top: 8px; table-layout: fixed; }
.ro-strip th { background: var(--tint); font-size: 6.5pt; text-transform: uppercase; letter-spacing: .8px; color: #374151; text-align: left; }
.ro-strip th, .ro-strip td { border: 1px solid var(--rule); padding: 3px 6px; }
.ro-strip td { font-weight: 600; height: 7mm; }

.ro-ops { margin-top: 8px; border: 1.5px solid var(--rule); }
.ro-ops thead th { background: var(--band); color: #fff; font-size: 7.5pt; text-transform: uppercase; letter-spacing: 1px; padding: 4px 6px; text-align: left; }
.ro-ops td { border-top: 1px solid #9ca3af; padding: 5px 6px; vertical-align: top; }
.ro-ops tbody tr:nth-child(even) td { background: #fafafa; }
.ro-ops .c-no { width: 10mm; font-weight: 700; color: var(--soft); text-align: center; }
.ro-ops .c-qty { width: 12mm; text-align: center; }
.ro-ops .c-chk { width: 13mm; text-align: center; }
.ro-ops .c-tech { width: 32mm; font-size: 8pt; color: #374151; }
.ro-ops tr.blank td { height: 9mm; }
.op-desc { font-weight: 600; }
.op-tag { display: inline-block; margin-top: 2px; font-size: 6.5pt; font-weight: 700; text-transform: uppercase; letter-spacing: .8px; border: 1px solid var(--ink); padding: 0 4px; }
.op-note { margin-top: 2px; font-size: 8.5pt; color: #374151; font-style: italic; }
.ro .box { display: inline-block; width: 4.5mm; height: 4.5mm; border: 1.5px solid var(--ink); line-height: 4mm; font-weight: 900; font-size: 9pt; }
.ro.no-ticks .box { color: transparent; }
.ro.no-ticks .tick-info { visibility: hidden; }
.ro-summary { text-align: right; font-size: 8pt; color: var(--soft); padding: 2px 2px 0; }

.ro-notes-box { margin-top: 8px; }
.ro-notes { min-height: 28mm; white-space: pre-wrap; font-size: 9.5pt; }
.ro-notes.empty, .ro-notes { background-image: repeating-linear-gradient(transparent 0 6.6mm, #d1d5db 6.6mm calc(6.6mm + 1px)); line-height: 6.6mm; }
.ro-refs { margin-top: 6px; font-size: 8.5pt; display: flex; flex-wrap: wrap; gap: 4px 18px; }

.ro-sigs { display: grid; grid-template-columns: 1.6fr 1fr 1fr; gap: 8px; margin-top: 10px; }
.sig { border: 1.5px solid var(--rule); padding: 0 8px 6px; display: flex; flex-direction: column; break-inside: avoid; }
.sig .ro-label { margin-bottom: 4px; }
.sig p { margin: 0 0 4px; font-size: 7pt; color: #374151; line-height: 1.3; flex: 1; }
.sig-space { flex: 1; min-height: 12mm; }
.sig-line { display: flex; justify-content: space-between; border-top: 1px solid var(--ink); padding-top: 2px; margin-top: 12mm; font-size: 6.5pt; color: var(--soft); text-transform: uppercase; letter-spacing: .8px; }
.sig-cust .sig-line { margin-top: 8mm; }
.ro-foot { margin-top: 8px; padding-top: 4px; border-top: 1px solid #d1d5db; font-size: 7pt; color: var(--soft); text-align: center; }

.ro-photos { break-before: page; page-break-before: always; padding-top: 12mm; }
.ro-head-sm { align-items: baseline; margin-bottom: 8px; }
.ro-head-sm .ro-bizname { font-size: 12pt; } .ro-head-sm .ro-num { font-size: 12pt; }
.ro-photo-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6mm; }
.ro-photo-grid figure { margin: 0; break-inside: avoid; }
.ro-photo-grid img { width: 100%; height: 70mm; object-fit: cover; border: 1px solid #9ca3af; }
.ro-photo-grid figcaption { font-size: 7.5pt; color: var(--soft); margin-top: 2px; }

@media print {
  html, body { background: #fff !important; }
  .top, .print-tools, #toasts { display: none !important; }
  main { padding: 0 !important; max-width: none !important; display: block !important; }
  .ro-wrap { overflow: visible; padding: 0; }
  .ro { width: auto; min-height: 0; padding: 0; margin: 0; box-shadow: none; }
  @page { size: A4; margin: 10mm; }
}

/* ---------------------------------------------------------- modal, doc rows, misc */
.ghost-btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: var(--tap); padding: 0 16px;
  border-radius: 10px; background: var(--panel2); color: var(--text); border: 1px solid var(--line); font-weight: 650; cursor: pointer; white-space: nowrap; }
.doc { padding: 0 4px 0 0; }
.doc-link { flex: 1; display: flex; align-items: center; gap: 10px; padding: 12px; color: var(--text); text-decoration: none; min-width: 0; }
.logo-prev { min-height: var(--tap); display: flex; align-items: center; }
.logo-prev img { max-height: 60px; max-width: 200px; background: #fff; padding: 4px; border-radius: 6px; }
.modal { position: fixed; inset: 0; z-index: 55; background: rgba(0,0,0,.7); display: grid; place-items: center; padding: 14px; overflow-y: auto; }
.modal-card { width: min(560px, 100%); background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; display: grid; gap: 4px; }
.check-row { display: flex !important; align-items: center; gap: 10px; color: var(--text) !important; font-size: 15px !important; margin-top: 12px; }
.check-row input { width: 24px; height: 24px; min-height: 0; flex: 0 0 24px; }
.rule-fields { border-left: 3px solid var(--accent); padding: 8px 0 4px 12px; margin-top: 6px; }
.ro-ops thead th.c-no, .ro-ops thead th.c-tech { color: #fff; font-size: 7.5pt; }

/* quiet "saved" confirmation on the field itself */
input.saved, select.saved, textarea.saved { border-color: var(--ok) !important; box-shadow: 0 0 0 3px rgba(60,207,122,.28); transition: box-shadow .3s, border-color .3s; }

/* photo tiles with delete */
.photos .ph { position: relative; }
.photos .ph img { display: block; }
.ph-del { position: absolute; top: 4px; right: 4px; min-height: 0; width: 34px; height: 34px; padding: 0; border-radius: 50%;
  background: rgba(0,0,0,.65); color: #fff; font-size: 16px; border: 1px solid rgba(255,255,255,.25); }

/* make the hidden attribute always win */
[hidden] { display: none !important; }

/* ---------------------------------------------------------- calendar */
.top nav a { min-width: 40px; text-align: center; }
.sub.booked { color: var(--accent); font-weight: 600; }
.cal-head { padding: 10px 12px; }
.cal-nav { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.cal-nav button { min-height: 40px; padding: 0 14px; }
.cal-title { margin: 0 8px; flex: 1; font-size: 16px; white-space: nowrap; }
.cal-nav select { width: auto; min-height: 40px; }
.cal-week { display: grid; gap: 8px; }
.cal-day { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 8px; display: flex; flex-direction: column; gap: 6px; min-height: 80px; transition: background .15s, border-color .15s; }
.cal-day.today { border-color: var(--accent); box-shadow: inset 0 3px 0 var(--accent); }
.cal-dhead { display: flex; justify-content: space-between; align-items: baseline; font-size: 14px; color: var(--muted); }
.cal-dhead b { color: var(--text); font-size: 17px; }
.cal-day.today .cal-dhead b { color: var(--accent); }
.cal-list { display: grid; gap: 6px; }
.cal-add { min-height: 34px; background: transparent; color: var(--muted); border: 1px dashed var(--line); font-weight: 500; font-size: 13px; }
.cal-add:hover { color: var(--text); border-color: var(--muted); }
.cal-job { display: block; background: var(--panel2); border: 1px solid var(--line); border-left: 4px solid var(--info); border-radius: 8px; padding: 6px 8px; color: var(--text); text-decoration: none; cursor: grab; }
.cal-job.st-in_progress { border-left-color: var(--accent); }
.cal-job.st-waiting_parts { border-left-color: #c084fc; }
.cal-job.st-complete { border-left-color: var(--ok); opacity: .7; }
.cal-job.dragging { opacity: .4; }
.cj-top { display: flex; justify-content: space-between; gap: 6px; font-size: 14px; }
.cj-time { color: var(--accent); font-weight: 700; font-size: 12px; }
.cj-sub { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cj-foot { display: flex; align-items: center; gap: 6px; margin-top: 4px; }
.cj-tech { font-size: 10px; font-weight: 800; background: var(--line); color: var(--text); border-radius: 10px; padding: 1px 6px; }
.cj-tech.none { background: transparent; color: var(--muted); }
.cj-foot .mini-progress { flex: 1; width: auto; height: 4px; display: block; }
.cj-foot .mini-progress > span { display: block; height: 100%; background: var(--ok); }
.cj-count { font-size: 11px; color: var(--muted); }
.drop-hover { background: #26303a !important; border-color: var(--accent) !important; }
.cal-unbooked-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 6px; }
@media (min-width: 900px) {
  main:has(.cal-week) { max-width: 1400px; }
  .cal-week { grid-template-columns: repeat(7, minmax(0, 1fr)); }
  .cal-day { min-height: 340px; }
  .cal-day.quiet { opacity: .6; }
}
@media (max-width: 899px) { .cal-day.quiet { display: none; } }
@media (max-width: 520px) {
  .top { gap: 6px; padding-left: 10px; padding-right: 10px; }
  .top .title { display: none; }
  .top .brand { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; font-size: 15px; }
  .top nav a { padding: 8px 10px; min-width: 0; }
}
/* multi-day bookings */
.cj-span { font-size: 11px; font-weight: 700; color: #1a1300; background: var(--accent); border-radius: 8px; padding: 0 6px; white-space: nowrap; }
.cal-job.multi { background: linear-gradient(90deg, rgba(245,165,36,.10), var(--panel2) 60%); }
.cal-job.cont { border-left-style: dashed; }
/* keep job cards inside their day column */
.cal-day, .cal-list { min-width: 0; }
.cal-job { min-width: 0; overflow: hidden; }
.cj-top { align-items: center; min-width: 0; }
.cj-top b { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cj-top .cj-span, .cj-top .cj-time { flex: 0 0 auto; }
/* rego row */
.rego-row select { width: 92px; }
.rego-info { margin: 6px 0 0; }
.rego-info .ok { color: var(--ok); } .rego-info .warn { color: var(--warn); } .rego-info .bad { color: var(--bad); font-weight: 700; }
.ro .kv-row3 { grid-template-columns: 1.4fr 1fr 1fr; }
