:root {
  --navy: #0B2A5B;
  --blue: #1565C0;
  --blue-dark: #0D47A1;
  --blue-light: #E6F0FB;
  --orange: #FF9800;
  --orange-hover: #FFA726;
  --orange-dark: #B85F00;
  --orange-light: #FFF1DC;
  --red-text: #9B1C1C;
  --red-light: #FDE8E8;
  --bg: #F2F6FB;
  --ink: #14213D;
  --muted: #5B6B82;
  --line: #D6E0EE;
  --radius: 10px;
}

* { box-sizing: border-box; }
html { font-size: 16px; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.4;
}
[hidden] { display: none !important; }
h1, h2 { margin: 0; }
.muted { color: var(--muted); font-size: .9rem; }

/* ---------- header ---------- */
.top {
  background: linear-gradient(135deg, var(--navy), var(--blue-dark));
  border-bottom: 5px solid var(--orange);
  color: #fff;
  display: flex;
  flex-wrap: wrap;
  gap: 12px 24px;
  align-items: center;
  justify-content: space-between;
  padding: 14px 24px;
}
.brand { display: flex; align-items: center; gap: 14px; }
.brand h1 { font-size: 1.5rem; letter-spacing: .2px; }
.brand p { margin: 0; color: #BBD3F2; font-size: .85rem; }
.top-actions { display: flex; flex-wrap: wrap; gap: 10px; }

/* ---------- buttons ---------- */
.btn {
  font: inherit;
  font-weight: 700;
  border: 2px solid transparent;
  border-radius: 8px;
  padding: 9px 16px;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1.2;
}
.btn:focus-visible, .qbtn:focus-visible, .tab:focus-visible, .link-btn:focus-visible,
input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 3px solid var(--orange);
  outline-offset: 2px;
}
.btn.primary { background: var(--orange); color: var(--navy); }
.btn.primary:hover { background: var(--orange-hover); }
.btn.secondary { background: var(--blue); color: #fff; }
.btn.secondary:hover { background: var(--blue-dark); }
.btn.ghost { background: transparent; color: #fff; border-color: rgba(255,255,255,.55); }
.btn.ghost:hover { background: rgba(255,255,255,.12); }
.btn.ghost-dark { background: #fff; color: var(--blue-dark); border-color: var(--line); }
.btn.ghost-dark:hover { background: var(--blue-light); }
.btn:disabled { opacity: .6; cursor: default; }

/* ---------- truck picker ---------- */
.truckbar {
  background: var(--navy);
  color: #fff;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  padding: 10px 20px;
}
.truckbar label { font-weight: 700; }
.truckbar select { width: auto; min-width: 200px; font-weight: 700; border: 2px solid var(--orange); }
.truckbar .muted { color: #BBD3F2; }
.sub-h { color: var(--navy); font-size: 1rem; margin: 18px 0 8px; }
.stock-table { width: 100%; border: 1px solid var(--line); border-radius: 8px; }
.stock-table th { background: var(--blue-light); color: var(--navy); padding: 7px 10px; position: static; font-size: .85rem; }
.stock-table th small { font-weight: 400; color: var(--muted); }
.stock-table td { padding: 6px 10px; }
.stock-table input[type=number] { width: 90px; text-align: right; margin-left: auto; display: block; }
.stock-table tr.current td:first-child { box-shadow: inset 4px 0 0 var(--orange); font-weight: 800; }
.trucks-table input[type=text] { width: 100%; }
.dlg-body { padding: 22px 24px; }
.add-truck { padding: 0; }
.grid label.check { flex-direction: row; align-items: center; gap: 8px; }
.tag-shop { display: inline-block; margin-left: 6px; padding: 1px 8px; border-radius: 999px; background: var(--orange-light); color: var(--orange-dark); font-size: .75rem; font-weight: 800; }
.badge.none { background: #EEF1F5; color: var(--muted); }
tbody tr.row-none { color: var(--muted); }
.per-truck { color: var(--muted); font-size: .8rem; }
.qty-total { font-weight: 800; font-size: 1.1rem; }
.truck-col { white-space: nowrap; }
.hide-truckcol .truck-col { display: none; }

/* ---------- tabs ---------- */
.tabs {
  background: #fff;
  border-bottom: 1px solid var(--line);
  display: flex;
  gap: 4px;
  padding: 0 20px;
  overflow-x: auto;
}
.tab {
  font: inherit;
  font-weight: 700;
  color: var(--muted);
  background: none;
  border: 0;
  border-bottom: 4px solid transparent;
  padding: 14px 18px 10px;
  cursor: pointer;
  white-space: nowrap;
}
.tab:hover { color: var(--blue-dark); }
.tab.active { color: var(--blue-dark); border-bottom-color: var(--orange); }
.pill {
  display: inline-block;
  min-width: 22px;
  padding: 1px 7px;
  margin-left: 4px;
  border-radius: 999px;
  background: var(--blue-light);
  color: var(--blue-dark);
  font-size: .8rem;
  text-align: center;
}
.pill.alert { background: var(--orange); color: var(--navy); }

/* ---------- layout ---------- */
main { max-width: 1280px; margin: 0 auto; padding: 20px; }

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}
.stat {
  background: #fff;
  border-radius: var(--radius);
  padding: 14px 18px;
  border: 1px solid var(--line);
  border-left: 6px solid var(--blue);
  display: flex;
  flex-direction: column;
}
.stat.orange { border-left-color: var(--orange); }
.stat-label { color: var(--muted); font-size: .85rem; font-weight: 600; text-transform: uppercase; letter-spacing: .5px; }
.stat-value { font-size: 1.8rem; font-weight: 800; color: var(--navy); }
.stat.warn { background: var(--orange-light); }

.panel {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}
.panel-head {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
}
.panel-head h2 { font-size: 1.25rem; color: var(--navy); }
.panel-head p { margin: 2px 0 0; }
.panel-actions { display: flex; gap: 10px; }

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  background: var(--blue-light);
}
.toolbar input[type=search] { flex: 1 1 260px; }
.check { display: inline-flex; gap: 6px; align-items: center; font-weight: 600; color: var(--navy); }
.check input { width: 18px; height: 18px; accent-color: var(--orange); }
#countText { margin-left: auto; }

input, select, textarea {
  font: inherit;
  color: var(--ink);
  background: #fff;
  border: 1.5px solid #B8C7DC;
  border-radius: 8px;
  padding: 8px 10px;
  width: 100%;
}
.toolbar select, .toolbar input[type=search], .panel-head input[type=search] { width: auto; min-width: 180px; }
.panel-head input[type=search] { flex: 0 1 260px; }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 10px 14px; text-align: left; vertical-align: middle; }
thead th {
  background: var(--navy);
  color: #fff;
  font-size: .8rem;
  text-transform: uppercase;
  letter-spacing: .6px;
  white-space: nowrap;
  position: sticky;
  top: 0;
}
th.sortable { cursor: pointer; user-select: none; }
th.sortable:hover { background: var(--blue-dark); }
th.sorted-asc::after { content: " ▲"; color: var(--orange); }
th.sorted-desc::after { content: " ▼"; color: var(--orange); }
tbody tr { border-bottom: 1px solid var(--line); }
tbody tr:nth-child(even) { background: #F8FAFD; }
tbody tr:hover { background: var(--blue-light); }
tbody tr.row-low { box-shadow: inset 5px 0 0 var(--orange); }
tbody tr.row-out { box-shadow: inset 5px 0 0 var(--red-text); }
tfoot td { font-weight: 800; background: var(--orange-light); border-top: 2px solid var(--orange); }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.name { font-weight: 700; color: var(--navy); }
.sub { color: var(--muted); font-size: .8rem; }
.actions { white-space: nowrap; text-align: right; }

.qty { display: inline-flex; align-items: center; gap: 8px; }
.qnum { min-width: 2.2em; text-align: center; font-weight: 800; font-size: 1.1rem; font-variant-numeric: tabular-nums; }
.qbtn {
  width: 34px; height: 34px;
  border-radius: 8px;
  border: 0;
  background: var(--blue);
  color: #fff;
  font-size: 1.25rem;
  font-weight: 800;
  line-height: 1;
  cursor: pointer;
}
.qbtn:hover { background: var(--blue-dark); }
.qbtn.plus { background: var(--orange); color: var(--navy); }
.qbtn.plus:hover { background: var(--orange-hover); }

.badge { display: inline-block; white-space: nowrap; padding: 3px 10px; border-radius: 999px; font-size: .8rem; font-weight: 800; }
.badge.ok { background: var(--blue-light); color: var(--blue-dark); }
.badge.low { background: var(--orange-light); color: var(--orange-dark); border: 1px solid var(--orange); }
.badge.out { background: var(--red-light); color: var(--red-text); }

.link-btn {
  font: inherit; font-weight: 700; font-size: .9rem;
  background: none; border: 0; padding: 6px 8px; cursor: pointer;
  color: var(--blue);
  border-radius: 6px;
}
.link-btn:hover { background: var(--blue-light); text-decoration: underline; }
.link-btn.danger { color: var(--red-text); }
.link-btn.danger:hover { background: var(--red-light); }
.link-btn.orange { color: var(--orange-dark); }
.link-btn.orange:hover { background: var(--orange-light); }

.delta-up { color: var(--blue-dark); font-weight: 800; }
.delta-down { color: var(--orange-dark); font-weight: 800; }

.empty { padding: 48px 20px; text-align: center; color: var(--muted); }
.empty strong { display: block; color: var(--navy); font-size: 1.15rem; margin-bottom: 6px; }
.hint { margin: 0; padding: 12px 18px; color: var(--muted); font-size: .85rem; border-top: 1px solid var(--line); }

/* ---------- dialogs ---------- */
dialog {
  border: 0;
  border-radius: 14px;
  padding: 0;
  width: min(640px, calc(100vw - 24px));
  max-height: calc(100vh - 24px);
  box-shadow: 0 20px 60px rgba(11, 42, 91, .45);
}
dialog::backdrop { background: rgba(11, 42, 91, .55); }
dialog form { padding: 22px 24px; }
dialog h2 { color: var(--navy); margin-bottom: 14px; padding-bottom: 10px; border-bottom: 4px solid var(--orange); }
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 16px; }
.grid label { display: flex; flex-direction: column; gap: 4px; font-weight: 700; font-size: .9rem; color: var(--navy); }
.grid label small { font-weight: 400; color: var(--muted); }
.span2 { grid-column: span 2; }
.preview {
  align-self: end;
  background: var(--blue-light);
  border-radius: 8px;
  padding: 10px 12px;
  font-weight: 700;
  color: var(--blue-dark);
}
.preview.bad { background: var(--red-light); color: var(--red-text); }
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }
.form-error { background: var(--red-light); color: var(--red-text); border-radius: 8px; padding: 9px 12px; font-weight: 600; margin: 14px 0 0; }

.toast {
  position: fixed;
  left: 50%; bottom: 24px;
  transform: translate(-50%, 20px);
  background: var(--navy);
  color: #fff;
  border-left: 6px solid var(--orange);
  padding: 12px 18px;
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0,0,0,.3);
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s, transform .2s;
  max-width: calc(100vw - 32px);
  z-index: 100;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.error { background: var(--red-text); border-left-color: #fff; }

/* ---------- small screens ---------- */
@media (max-width: 900px) { .hide-md { display: none; } }
@media (max-width: 640px) {
  .hide-sm { display: none; }
  .stats { grid-template-columns: 1fr 1fr; gap: 10px; }
  .stat { padding: 10px 12px; }
  .stat-value { font-size: 1.4rem; }
  .top { padding: 12px 14px; }
  main { padding: 12px; }
  th, td { padding: 9px 8px; }
  .grid { grid-template-columns: 1fr; }
  .span2 { grid-column: auto; }
  #countText { margin-left: 0; width: 100%; }
}

/* ---------- printing (restock list) ---------- */
@media print {
  body { background: #fff; }
  .truckbar, .top, .tabs, .stats, .btn, .link-btn, .actions, .actions-h, .toast, .panel-actions, .toolbar, .mainnav, .invbar, .no-print { display: none !important; }
  main { padding: 0; max-width: none; }
  .panel { border: 0; }
  thead th { background: #fff !important; color: #000 !important; border-bottom: 2px solid #000; position: static; }
  tbody tr { box-shadow: none !important; background: #fff !important; }
  .hide-sm, .hide-md { display: table-cell !important; }
  th.hide-sm, td.hide-sm, th.hide-md, td.hide-md { display: table-cell !important; }
}

/* ---------- barcode scanning ---------- */
.btn.scan { background: #fff; color: var(--blue-dark); }
.btn.scan:hover { background: var(--blue-light); }
.btn.scan svg { margin-right: 8px; }
.btn.small { padding: 7px 12px; font-size: .9rem; }
.with-btn { display: flex; gap: 8px; }
.with-btn input { flex: 1; min-width: 0; }

#scanDialog { width: min(720px, calc(100vw - 24px)); }
.scan-wrap { padding: 22px 24px; display: flex; flex-direction: column; gap: 12px; }
.scan-wrap h2 { margin-bottom: 2px; }
.video-box {
  position: relative;
  background: var(--navy);
  border-radius: 12px;
  overflow: hidden;
  aspect-ratio: 16 / 9;
  border: 3px solid var(--orange);
}
.video-box video { width: 100%; height: 100%; object-fit: cover; display: block; }
.aim {
  position: absolute; inset: 22% 14%;
  border: 2px dashed rgba(255,255,255,.75);
  border-radius: 10px;
  pointer-events: none;
}
.aim i {
  position: absolute; left: 6px; right: 6px; top: 50%;
  height: 3px; background: var(--orange); border-radius: 2px;
  box-shadow: 0 0 10px var(--orange);
  animation: sweep 2.2s ease-in-out infinite alternate;
}
@keyframes sweep { from { top: 12%; } to { top: 88%; } }
@media (prefers-reduced-motion: reduce) { .aim i { animation: none; } }
.scan-status { margin: 0; font-weight: 600; color: var(--blue-dark); min-height: 1.4em; }
.scan-status.bad { color: var(--red-text); }
.manual { display: flex; flex-direction: column; gap: 4px; font-weight: 700; font-size: .9rem; color: var(--navy); }
.note-box {
  background: var(--orange-light);
  border: 1.5px solid var(--orange);
  border-radius: 10px;
  padding: 12px 14px;
}
.note-box p { margin: 0 0 10px; }
.note-box.found { background: var(--blue-light); border-color: var(--blue); }
.note-box .row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 8px; }
.note-box .row select { width: auto; flex: 1 1 180px; }
code { background: #fff; border-radius: 4px; padding: 1px 6px; font-weight: 700; }
.recent { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; max-height: 190px; overflow-y: auto; }
.recent li { background: var(--bg); border-radius: 8px; padding: 6px 10px; display: flex; gap: 8px; align-items: center; }
.recent li.bad { background: var(--red-light); color: var(--red-text); font-weight: 600; }
.recent .link-btn { margin-left: auto; }
#s_camera { width: auto; }

/* ---------- part photos ---------- */
.photo-row { display: flex; gap: 14px; align-items: center; margin-bottom: 14px; }
.photo-box {
  flex: 0 0 auto; padding: 0; border: 2px solid var(--orange); border-radius: 10px;
  background: var(--navy); cursor: zoom-in; overflow: hidden; display: block;
}
.photo-box img { display: block; width: 220px; height: 124px; object-fit: cover; }
.photo-side { flex: 1; min-width: 0; }
.photo-side p { margin: 0 0 8px; }
.photo-side .row { display: flex; flex-wrap: wrap; gap: 8px; }
.itemcell { display: flex; align-items: center; gap: 10px; }
.thumb { width: 44px; height: 44px; object-fit: cover; border-radius: 8px; border: 2px solid var(--line); cursor: zoom-in; flex: 0 0 auto; }
.thumb:hover { border-color: var(--orange); }
.shot { display: block; width: 100%; max-width: 360px; border-radius: 8px; border: 2px solid var(--orange); margin: 0 0 10px; cursor: zoom-in; }
#photoDialog { width: min(1000px, calc(100vw - 24px)); }
.photo-view { padding: 14px; max-height: calc(100vh - 120px); overflow: auto; }
.photo-view img { display: block; max-width: 100%; margin: 0 auto; cursor: zoom-in; border-radius: 8px; }
.photo-view.zoomed img { max-width: none; cursor: zoom-out; }
.photo-actions { padding: 0 18px 16px; align-items: center; justify-content: space-between; margin-top: 0; }
@media (max-width: 640px) { .photo-row { flex-direction: column; align-items: stretch; } .photo-box img { width: 100%; height: auto; aspect-ratio: 16/9; } }
.photo-scan { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.photo-scan .muted { flex: 1 1 220px; }

/* =========================================================
   Power Systems Pro
   ========================================================= */
body:not(.can-office) [data-office] { display: none !important; }
body:not(.can-admin) [data-admin] { display: none !important; }

.userbox { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.userbox #whoami { color: #fff; margin-right: 6px; }
.userbox .role { display: inline-block; margin-left: 4px; padding: 1px 8px; border-radius: 999px; background: var(--orange); color: var(--navy); font-size: .75rem; font-weight: 800; text-transform: capitalize; }

.mainnav { background: #fff; border-bottom: 1px solid var(--line); display: flex; gap: 2px; padding: 0 16px; overflow-x: auto; position: sticky; top: 0; z-index: 5; }
.mainnav button { font: inherit; font-weight: 800; color: var(--muted); background: none; border: 0; border-bottom: 4px solid transparent; padding: 14px 16px 10px; cursor: pointer; white-space: nowrap; }
.mainnav button:hover { color: var(--blue-dark); }
.mainnav button.active { color: var(--navy); border-bottom-color: var(--orange); }
.mainnav button:focus-visible { outline: 3px solid var(--orange); outline-offset: -3px; }

.invbar { background: var(--navy); padding: 12px 20px 2px; }

main.pro > * + * { margin-top: 16px; }
.pagehead { display: flex; flex-wrap: wrap; gap: 10px 16px; align-items: flex-end; justify-content: space-between; }
.pagehead h2 { color: var(--navy); font-size: 1.5rem; display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.pagehead p { margin: 4px 0 0; }
.row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.row select { width: auto; }
.back { color: var(--blue); font-weight: 700; text-decoration: none; font-size: .9rem; }
.back:hover { text-decoration: underline; }
.weeklabel { color: var(--navy); margin: 0 6px; }
.btn.danger { color: var(--red-text); }
.btn.wide { width: 100%; margin-top: 16px; padding: 12px; }
label.inline { display: inline-flex; gap: 8px; align-items: center; font-weight: 700; color: var(--navy); }
label.inline input { width: auto; }
.pre { white-space: pre-wrap; }
.empty.small { padding: 18px; }
.clickrows tbody tr { cursor: pointer; }
ul.plain { list-style: none; padding: 0; margin: 0 0 8px; display: flex; flex-direction: column; gap: 6px; }
.prio { display: inline-block; padding: 1px 8px; border-radius: 999px; background: var(--red-light); color: var(--red-text); font-size: .72rem; font-weight: 800; text-transform: uppercase; letter-spacing: .4px; }
tr.grouprow td { background: var(--blue-light) !important; color: var(--navy); font-weight: 800; font-size: .85rem; padding: 6px 14px; }
th.cb, td.cb { width: 36px; }
td.cb input, th.cb input { width: 18px; height: 18px; accent-color: var(--orange); }

.panel.pad { padding: 16px 18px; }
.panel.pad h3, .settings h3 { color: var(--navy); font-size: .95rem; text-transform: uppercase; letter-spacing: .5px; margin: 16px 0 6px; }
.panel.pad h3:first-child { margin-top: 0; }
.panel.pad p { margin: 0 0 8px; }
.panel.pad textarea { margin-bottom: 8px; }
.settings h3 small { text-transform: none; letter-spacing: 0; font-weight: 400; color: var(--muted); }
.settings .stock-table { margin-bottom: 8px; }
.settings .stock-table input { width: 100%; }
.settings .checks { display: flex; flex-direction: column; gap: 6px; justify-content: center; }

/* status badges */
.wobadge { display: inline-block; white-space: nowrap; padding: 3px 10px; border-radius: 999px; font-size: .78rem; font-weight: 800; background: #EEF1F5; color: var(--muted); }
.wobadge.st-scheduled { background: var(--blue-light); color: var(--blue-dark); }
.wobadge.st-in_progress { background: var(--orange); color: var(--navy); }
.wobadge.st-on_hold { background: var(--red-light); color: var(--red-text); }
.wobadge.st-completed { background: #E3F4E8; color: #1E6B35; }
.wobadge.st-invoiced { background: var(--navy); color: #fff; }
.wobadge.st-canceled { background: #EEF1F5; color: var(--muted); text-decoration: line-through; }

/* schedule */
.week { display: grid; grid-template-columns: repeat(7, minmax(140px, 1fr)); gap: 8px; overflow-x: auto; }
.day { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 8px; min-height: 160px; display: flex; flex-direction: column; gap: 6px; }
.day.today { border: 2px solid var(--orange); }
.dayhead { font-weight: 800; color: var(--muted); text-transform: uppercase; font-size: .8rem; letter-spacing: .5px; }
.dayhead span { color: var(--navy); font-size: 1.15rem; margin-left: 4px; }
.dayempty { color: var(--line); text-align: center; margin-top: 20px; }
.wocard { font: inherit; text-align: left; display: flex; flex-direction: column; gap: 1px; width: 100%; background: var(--blue-light); border: 0; border-left: 5px solid var(--blue); border-radius: 8px; padding: 7px 9px; cursor: pointer; color: var(--ink); }
.wocard:hover { filter: brightness(.97); box-shadow: 0 2px 8px rgba(11,42,91,.15); }
.wocard:focus-visible { outline: 3px solid var(--orange); }
.wocard.st-in_progress { border-left-color: var(--orange); background: var(--orange-light); }
.wocard.st-completed, .wocard.st-invoiced { border-left-color: #2E8B57; background: #EEF8F1; }
.wocard.st-on_hold { border-left-color: var(--red-text); background: var(--red-light); }
.wocard.st-new { border-left-color: var(--muted); background: #F4F6F9; }
.wocard.pr-emergency { box-shadow: inset 0 0 0 2px var(--red-text); }
.wc-top { font-size: .8rem; color: var(--muted); }
.wc-top b { color: var(--navy); }
.wc-cust { font-weight: 800; color: var(--navy); }
.wc-title { font-size: .9rem; }
.wc-sub { font-size: .78rem; color: var(--muted); }
.wc-sub.warn { color: var(--red-text); font-weight: 700; }
.twocol { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; }
.cardlist { padding: 12px; display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 8px; }

/* work order page */
.wogrid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; }
.totals { margin-left: auto; max-width: 420px; }
.totals td { padding: 8px 16px; }
.totals tr.grand td { font-size: 1.25rem; font-weight: 800; color: var(--navy); border-top: 3px solid var(--orange); }
.totals tr.sub td { color: var(--muted); font-size: .85rem; }
.totals tbody tr:nth-child(even) { background: transparent; }

/* dialogs */
dialog.wide { width: min(820px, calc(100vw - 24px)); }
fieldset.multi { border: 1.5px solid #B8C7DC; border-radius: 8px; padding: 8px 12px; margin: 0; display: flex; flex-wrap: wrap; gap: 6px 18px; }
fieldset.multi legend { font-weight: 700; font-size: .9rem; color: var(--navy); padding: 0 4px; }
fieldset.multi legend small { font-weight: 400; color: var(--muted); }
fieldset.multi label.check { font-weight: 600; }
.grid.one { grid-template-columns: 1fr; }
#partDialog { width: min(700px, calc(100vw - 24px)); }
.pd-list { margin-top: 12px; max-height: 300px; overflow-y: auto; border: 1px solid var(--line); border-radius: 8px; }
.pd-item { font: inherit; width: 100%; display: flex; justify-content: space-between; gap: 10px; align-items: center; text-align: left; background: #fff; border: 0; border-bottom: 1px solid var(--line); padding: 9px 12px; cursor: pointer; color: var(--ink); }
.pd-item:hover { background: var(--blue-light); }
.pd-item.picked { background: var(--orange-light); box-shadow: inset 5px 0 0 var(--orange); }
.pd-item.none { color: var(--muted); }
.pd-qty { white-space: nowrap; font-weight: 700; color: var(--blue-dark); }
.pd-item.none .pd-qty { color: var(--muted); }

/* sign in */
.auth { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; background: linear-gradient(135deg, var(--navy), var(--blue-dark)); }
.auth-card { background: #fff; border-radius: 16px; padding: 28px; width: min(440px, 100%); border-top: 6px solid var(--orange); box-shadow: 0 20px 60px rgba(0,0,0,.35); }
.auth-brand { display: flex; gap: 14px; align-items: center; margin-bottom: 18px; }
.auth-brand h1 { color: var(--navy); font-size: 1.35rem; }
.auth-brand p { margin: 2px 0 0; color: var(--muted); }
.auth-card h2 { color: var(--navy); font-size: 1.15rem; margin-bottom: 10px; }

@media (max-width: 900px) {
  .twocol, .wogrid { grid-template-columns: 1fr; }
  .week { grid-template-columns: repeat(7, 160px); }
}

/* printed work order / invoice */
#printArea { display: none; }
@media print {
  body.printing > *:not(#printArea) { display: none !important; }
  body.printing #printArea { display: block; font-size: 11pt; color: #000; }
  #printArea h1 { font-size: 18pt; margin: 0; }
  #printArea h2 { font-size: 14pt; margin: 0; text-align: right; }
  #printArea h3 { font-size: 10pt; text-transform: uppercase; margin: 14px 0 4px; }
  #printArea p { margin: 0 0 6px; }
  .pr-head { display: flex; justify-content: space-between; border-bottom: 3px solid #000; padding-bottom: 8px; }
  .pr-doc p { text-align: right; }
  .pr-cols { display: flex; gap: 24px; }
  .pr-cols > div { flex: 1; }
  .pr-lines { margin-top: 14px; }
  .pr-lines th { background: #fff !important; color: #000 !important; border-bottom: 2px solid #000; }
  .pr-lines td, .pr-lines th { padding: 5px 8px; }
  .pr-lines tfoot td { background: #fff; border-top: 1px solid #000; }
  .pr-lines tr.grand td { font-weight: 800; font-size: 13pt; }
  .pr-sign { display: flex; gap: 40px; margin-top: 40px; }
  .pr-sign div { flex: 1; border-top: 1px solid #000; padding-top: 4px; }
  .pr-sign div:last-child { flex: 0 0 160px; }
  .pr-foot { margin-top: 20px; text-align: center; }
}

/* mileage */
tr.current-row td { background: var(--orange-light); }
#view-mileage .pagehead input[type=date] { width: auto; }

/* photos */
.pgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; padding: 12px 18px 16px; }
.gd-grid .pgrid { padding: 12px 0; }
.pcard { margin: 0; background: var(--bg); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; display: flex; flex-direction: column; }
.pcard img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; cursor: zoom-in; display: block; background: var(--navy); }
.pcard figcaption { padding: 6px 8px 4px; display: flex; flex-direction: column; gap: 2px; font-size: .85rem; }
.pcard .pcap { font-weight: 700; color: var(--navy); }
.pcard .link-btn { padding: 4px 6px; font-size: .8rem; }
h3.pday { color: var(--navy); font-size: .95rem; margin: 14px 18px 0; }
#galleryDialog { width: min(900px, calc(100vw - 24px)); }
.pprev { display: flex; flex-wrap: wrap; gap: 6px; }
.pprev img { width: 84px; height: 64px; object-fit: cover; border-radius: 6px; border: 1px solid var(--line); }
.eqlist li { display: flex; gap: 10px; align-items: flex-start; }
.eqlist .link-btn { padding: 2px 0; font-size: .85rem; }

/* ---------- maintenance checklist ---------- */
.cl h3 { margin-top: 0; }
.cl-eq { display: flex; flex-direction: column; gap: 4px; font-weight: 700; font-size: .9rem; color: var(--navy); margin-bottom: 14px; max-width: 520px; }
.cl-head { margin-bottom: 14px; }
.cl-hours { display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: flex-end; padding: 12px 14px; background: var(--orange-light); border: 1px solid var(--orange); border-radius: var(--radius); }
.cl-hours label { display: flex; flex-direction: column; gap: 4px; font-weight: 800; color: var(--orange-dark); }
.cl-hours input { width: 160px; font-size: 1.1rem; font-weight: 700; }
.cl-hours span { padding-bottom: 10px; }
.cl-bad { color: var(--red-text); font-weight: 700; font-size: .9rem; }
.cl-sections { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; align-items: start; }
.cl-sec-head { display: flex; justify-content: space-between; align-items: center; }
.cl-item { display: flex; flex-wrap: wrap; gap: 6px 12px; align-items: center; justify-content: space-between; padding: 9px 0; border-top: 1px solid var(--line); }
.cl-item:first-of-type { border-top: 0; }
.cl-item .check { font-weight: 600; align-items: flex-start; flex: 1 1 220px; }
.cl-item .check input { flex: none; margin-top: 1px; width: 22px; height: 22px; }
.cl-val { display: inline-flex; gap: 6px; align-items: center; font-weight: 700; color: var(--navy); white-space: nowrap; }
.cl-val input { width: 90px; }
.cl-parts td { vertical-align: middle; }
.cl-parts label { display: flex; gap: 8px; align-items: center; font-weight: 700; color: var(--navy); white-space: nowrap; }
.cl-parts label.check input { width: 22px; height: 22px; }
.cl-parts input[data-pf=qty] { width: 70px; }
.cl-parts input[data-pf=type] { width: 170px; }
.cl-warn { margin: 16px 0 0; padding: 10px 12px; border-radius: var(--radius); background: var(--blue-light); color: var(--navy); font-weight: 800; text-align: center; }
.hours-hist table { width: 100%; font-size: .9rem; margin-top: 6px; }
.hours-hist td { padding: 4px 6px; border-top: 1px solid var(--line); }
@media (max-width: 900px) { .cl-sections { grid-template-columns: 1fr; } }
@media (max-width: 640px) { .cl-parts tr { display: grid; gap: 6px; padding: 6px 0; } .cl-parts td { border: 0; padding: 2px 0; } }
.nowrap { white-space: nowrap; }

/* ---------- map ---------- */
.mp-bar { display: flex; flex-wrap: wrap; gap: 10px 18px; align-items: center; }
.mp-bar > label { display: flex; flex-direction: row; gap: 8px; align-items: center; font-weight: 700; color: var(--navy); white-space: nowrap; margin: 0; }
.mp-bar select { width: auto; }
.mp-legend { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-left: auto; }
.mp-chip { display: inline-flex; flex-direction: row; gap: 6px; align-items: center; font-weight: 600; cursor: pointer; white-space: nowrap; margin: 0; }
.mp-chip input { width: auto; margin: 0; }
.mp-chip b { color: var(--navy); }
.mp-pin { display: inline-block; width: 16px; height: 16px; border-radius: 50%; border: 2px solid #fff; box-shadow: 0 0 0 1px rgba(0,0,0,.35); flex: none; vertical-align: -3px; }
.mp-pin.mp-approx { border-style: dashed; opacity: .8; }
.mp-overdue { background: #d32f2f; }
.mp-due { background: #f7941d; }
.mp-ready { background: #1e6fd9; }
.mp-scheduled { background: #2e9e44; }
.mp-cluster { width: 36px; height: 36px; border-radius: 50%; display: flex; align-items: center; justify-content: center; border: 3px solid #fff; box-shadow: 0 1px 4px rgba(0,0,0,.4); }
.mp-cluster span { color: #fff; font-weight: 800; font-size: 13px; }
.mp-geo { margin: 0 0 12px; padding: 10px 14px; border-radius: var(--radius); background: var(--blue-light); color: var(--navy); font-size: .92rem; display: flex; flex-wrap: wrap; gap: 6px 12px; align-items: center; }
.mp-geo.busy { background: var(--orange-light); }
.mp-wrap { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 16px; margin-bottom: 16px; }
.mp-map { height: calc(100vh - 290px); min-height: 460px; border-radius: var(--radius); overflow: hidden; border: 1px solid var(--line); background: #e8eef5; }
.mp-side { margin: 0; display: flex; flex-direction: column; max-height: calc(100vh - 290px); min-height: 460px; }
.mp-side-head { display: flex; justify-content: space-between; align-items: baseline; padding: 12px 14px; border-bottom: 1px solid var(--line); }
#mpList { overflow-y: auto; flex: 1; }
.mp-row { display: flex; gap: 10px; align-items: flex-start; width: 100%; text-align: left; padding: 10px 14px; border: 0; border-bottom: 1px solid var(--line); background: none; cursor: pointer; font: inherit; color: inherit; }
.mp-row:hover { background: var(--blue-light); }
.mp-row .mp-pin { margin-top: 2px; }
.mp-pop { font: 14px/1.45 system-ui, sans-serif; }
.mp-pop .mp-cust { margin: 6px 0 2px; font-weight: 700; }
.mp-acts { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 10px; }
@media (max-width: 900px) { .mp-wrap { grid-template-columns: 1fr; } .mp-map { height: 60vh; min-height: 340px; } .mp-side { max-height: none; min-height: 0; } .mp-legend { margin-left: 0; } }
