:root {
  --bg: #f0f4f8;
  --surface: #ffffff;
  --border: #dce3eb;
  --text: #1a2332;
  --muted: #5a6a7a;
  --primary: #1d4ed8;
  --primary-dark: #1e3a8a;
  --primary-light: #e8efff;
  --success: #1a7a4c;
  --success-bg: #e6f7ee;
  --warn: #b45309;
  --warn-bg: #fef3c7;
  --danger: #c0392b;
  --danger-bg: #fdecea;
  --info: #3b5bdb;
  --info-bg: #edf2ff;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(26,35,50,.08), 0 4px 12px rgba(26,35,50,.04);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.45;
  font-size: 15px;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--primary); }
.app { display: flex; flex-direction: column; min-height: 100vh; }
.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 1rem;
  display: flex; align-items: center; gap: .75rem;
  height: 56px; position: sticky; top: 0; z-index: 40;
  box-shadow: var(--shadow);
}
.brand { display: flex; align-items: center; gap: .6rem; font-weight: 700; font-size: 1.05rem; white-space: nowrap; }
.brand-mark {
  width: 36px; height: 36px; object-fit: contain; display: block;
}
.auth-card .brand { flex-direction: column; }
.auth-card .brand-mark { width: 96px; height: 96px; }
.nav { display: flex; gap: .25rem; flex: 1; overflow-x: auto; padding: .25rem 0; }
.nav-btn {
  border: none; background: transparent; padding: .45rem .85rem;
  border-radius: 8px; cursor: pointer; color: var(--muted); font-weight: 560;
  white-space: nowrap; transition: .15s;
}
.nav-btn:hover { background: var(--bg); color: var(--text); }
.nav-btn.active { background: var(--primary-light); color: var(--primary); }
.main { flex: 1; padding: 1.25rem; max-width: 1400px; width: 100%; margin: 0 auto; }
.panel { display: none; }
.panel.active { display: block; }
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.1rem 1.25rem;
}
.card + .card { margin-top: 1rem; }
.row { display: flex; gap: .75rem; flex-wrap: wrap; align-items: center; }
.row.spread { justify-content: space-between; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem; }
@media (max-width: 900px) {
  .grid-3, .grid-4 { grid-template-columns: 1fr 1fr; }
  .grid-2 { grid-template-columns: 1fr; }
}
@media (max-width: 560px) {
  .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .main { padding: .75rem; }
  .topbar { padding: 0 .5rem; }
}
h1 { font-size: 1.45rem; font-weight: 700; }
h2 { font-size: 1.15rem; font-weight: 650; margin-bottom: .75rem; }
h3 { font-size: 1rem; font-weight: 650; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.tiny { font-size: .78rem; }
.mt-1 { margin-top: .5rem; }
.mt-2 { margin-top: 1rem; }
.mb-1 { margin-bottom: .5rem; }
.mb-2 { margin-bottom: 1rem; }
.gap-1 { gap: .5rem; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  padding: .5rem .9rem; border-radius: 8px; cursor: pointer; font-weight: 560;
  transition: .15s; white-space: nowrap;
}
.btn:hover { background: var(--bg); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-dark); }
.btn-danger { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-danger:hover { background: #a93226; }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-ghost:hover { background: var(--bg); }
.btn-sm { padding: .3rem .6rem; font-size: .85rem; }
.btn-complete { background: var(--success); color: #fff; border-color: var(--success); }
.btn-complete:hover { background: #166534; }
.btn-icon { padding: .35rem .5rem; }
label { display: block; font-size: .82rem; font-weight: 600; color: var(--muted); margin-bottom: .3rem; }
.field { margin-bottom: .85rem; }
.field input, .field select, .field textarea,
input[type="text"], input[type="email"], input[type="tel"], input[type="date"],
input[type="time"], input[type="number"], input[type="search"], select, textarea {
  width: 100%; padding: .55rem .7rem; border: 1px solid var(--border);
  border-radius: 8px; background: #fff; outline: none; transition: border .15s;
}
input:focus, select:focus, textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(29,78,216,.15); }
textarea { min-height: 80px; resize: vertical; }
.search-box { position: relative; flex: 1; min-width: 180px; }
.search-box input { padding-left: 2rem; }
.search-box::before {
  content: "\2315"; position: absolute; left: .65rem; top: 50%; transform: translateY(-50%);
  color: var(--muted); font-size: 1rem; pointer-events: none;
}
.badge {
  display: inline-flex; align-items: center; padding: .15rem .55rem;
  border-radius: 999px; font-size: .75rem; font-weight: 650; letter-spacing: .01em;
}
.badge-scheduled { background: var(--info-bg); color: var(--info); }
.badge-in-progress { background: var(--warn-bg); color: var(--warn); }
.badge-completed { background: var(--success-bg); color: var(--success); }
.badge-canceled { background: #eee; color: #666; }
.badge-quote_submitted { background: #e0e7ff; color: #3730a3; }
.badge-emergency { background: var(--danger-bg); color: var(--danger); }
.badge-maintenance { background: var(--primary-light); color: var(--primary); }
.badge-repair { background: #fce7f3; color: #9d174d; }
.badge-installation { background: #ede9fe; color: #5b21b6; }
.badge-inspection { background: #ecfdf5; color: #047857; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: .65rem .75rem; border-bottom: 1px solid var(--border); vertical-align: top; }
th { font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 650; background: #fafbfc; }
tr:hover td { background: #f8fafc; }
.clickable { cursor: pointer; }
.list-item {
  padding: .85rem 1rem; border-bottom: 1px solid var(--border);
  display: flex; gap: .75rem; align-items: flex-start; cursor: pointer; transition: .1s;
}
.list-item:hover { background: #f8fafc; }
.list-item:last-child { border-bottom: none; }
.list-item-side { display: flex; flex-direction: column; align-items: flex-end; gap: .4rem; flex-shrink: 0; }
.list-item-actions { display: flex; flex-direction: column; align-items: flex-end; gap: .35rem; }
.list-item.is-completed { background: #f7fbf8; }
.list-item.is-completed:hover { background: #eef8f2; }
.chip-actions { margin-top: .3rem; }
.dash-completed { margin-top: 1rem; padding-top: .85rem; border-top: 1px solid var(--border); }
.dash-completed h3 { margin: 0 0 .5rem; font-size: .95rem; }
.sched-section-head { padding: .85rem 1rem .5rem; border-bottom: 1px solid var(--border); background: #f7fbf8; }
.sched-section-head h2 { margin: 0; font-size: 1rem; }
.empty { text-align: center; padding: 2.5rem 1rem; color: var(--muted); }
.empty-icon { font-size: 2rem; margin-bottom: .5rem; opacity: .5; }
.stat {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1rem 1.15rem; box-shadow: var(--shadow);
}
.stat-val { font-size: 1.75rem; font-weight: 750; line-height: 1.1; }
.stat-label { font-size: .82rem; color: var(--muted); margin-top: .2rem; }
.cal-nav { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; margin-bottom: 1rem; }
.week-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: .5rem; }
@media (max-width: 800px) { .week-grid { grid-template-columns: 1fr; } }
.day-col {
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px;
  min-height: 140px; overflow: hidden;
}
.day-col.today { border-color: var(--primary); box-shadow: 0 0 0 2px rgba(29,78,216,.2); }
.day-head {
  padding: .5rem .65rem; background: #f7f9fb; border-bottom: 1px solid var(--border);
  font-weight: 650; font-size: .85rem; display: flex; justify-content: space-between;
}
.day-head .dow { color: var(--muted); font-weight: 560; }
.day-body { padding: .4rem; display: flex; flex-direction: column; gap: .35rem; min-height: 100px; }
.appt-chip {
  padding: .4rem .5rem; border-radius: 6px; font-size: .78rem; cursor: pointer;
  border-left: 3px solid var(--primary); background: var(--primary-light);
  line-height: 1.3;
}
.appt-chip:hover { filter: brightness(.97); }
.appt-chip.status-in-progress { border-color: var(--warn); background: var(--warn-bg); }
.appt-chip.status-completed { border-color: var(--success); background: var(--success-bg); }
.appt-chip.status-canceled { border-color: #999; background: #f0f0f0; opacity: .7; }
.appt-chip.svc-emergency { border-color: var(--danger); background: var(--danger-bg); }
.dispatch {
  overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface); box-shadow: var(--shadow);
}
.dispatch-table { display: grid; min-width: max-content; }
.dispatch-head, .dispatch-row {
  display: grid; grid-template-columns: 70px repeat(var(--tech-cols, 10), minmax(170px, 1fr));
}
.dispatch-head > div, .dispatch-row > div {
  border-bottom: 1px solid var(--border); border-right: 1px solid var(--border);
  padding: .4rem;
}
.dispatch-head > div {
  background: #f7f9fb; font-weight: 650; font-size: .8rem; position: sticky; top: 0; z-index: 2;
  text-align: center; padding: .6rem .4rem;
}
.dispatch-head .time-col, .dispatch-row .time-col {
  position: sticky; left: 0; background: #f7f9fb; z-index: 3; font-size: .75rem;
  color: var(--muted); font-weight: 600; text-align: right; padding-right: .5rem;
}
.dispatch-head .time-col { z-index: 4; }
.dispatch-row .time-col { background: #fafbfc; }
.dispatch-cell { min-height: 48px; position: relative; }
.dispatch-cell .appt-chip { margin-bottom: .25rem; font-size: .72rem; }
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(26,35,50,.45); z-index: 100;
  display: flex; align-items: flex-start; justify-content: center; padding: 2rem 1rem;
  overflow-y: auto; opacity: 0; pointer-events: none; transition: opacity .15s;
}
.modal-backdrop.open { opacity: 1; pointer-events: auto; }
.modal {
  background: var(--surface); border-radius: 12px; width: 100%; max-width: 560px;
  box-shadow: 0 20px 50px rgba(0,0,0,.2); transform: translateY(12px); transition: .15s;
}
.modal-backdrop.open .modal { transform: none; }
.modal.wide { max-width: 720px; }
.modal-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 1rem 1.25rem; border-bottom: 1px solid var(--border);
}
.modal-body { padding: 1.25rem; }
.modal-foot {
  padding: .85rem 1.25rem; border-top: 1px solid var(--border);
  display: flex; justify-content: flex-end; gap: .5rem; flex-wrap: wrap;
}
.toast-wrap {
  position: fixed; bottom: 1.25rem; right: 1.25rem; z-index: 200;
  display: flex; flex-direction: column; gap: .5rem; pointer-events: none;
}
.toast {
  background: #1a2332; color: #fff; padding: .7rem 1rem; border-radius: 8px;
  box-shadow: var(--shadow); font-size: .9rem; pointer-events: auto;
  animation: slideIn .2s ease;
}

.toast-with-undo { display: flex; align-items: center; gap: .75rem; }
.toast-undo {
  background: transparent; color: #fff; border: 1px solid rgba(255,255,255,.55);
  border-radius: 6px; padding: .3rem .7rem; font-weight: 700; cursor: pointer;
  min-height: 2.5rem; min-width: 3.25rem;
}
@media (max-width: 640px) {
  .toast-wrap { left: .75rem; right: .75rem; bottom: calc(1rem + env(safe-area-inset-bottom, 0px)); }
}
.photo-cell, .exp-thumb-wrap { position: relative; display: block; }
.exp-thumb-wrap { display: inline-block; }
.item-x, .photo-x, .exp-x, .seg-del, .sess-del, .miles-clear {
  flex-shrink: 0; min-width: 2.25rem; min-height: 2.25rem;
}
.photo-x, .exp-x {
  position: absolute; top: 2px; right: 2px; z-index: 2;
  background: rgba(20, 24, 32, .88); color: #fff; border: 0; border-radius: 4px;
  width: 2.25rem; height: 2.25rem; line-height: 1; padding: 0; font-size: 1rem;
}
.rd-group-title { display: flex; align-items: center; gap: .4rem; flex-wrap: wrap; }
.rd-group-title .rd-group-x { margin-left: auto; }
.job-phase-log-row { display: flex; align-items: flex-start; justify-content: space-between; gap: .4rem; }
.tech-session-list .sess-row { display: flex; align-items: center; justify-content: space-between; gap: .35rem; }
.miles-clear[hidden] { display: none !important; }

@media (pointer: coarse), (max-width: 640px) {
  .ck-remove, .ck-del, .wd-del, .q-del, .fl-del, .trip-del, .trip-tech-del,
  .photo-x, .exp-x, .rd-group-x, .seg-del, .sess-del, .miles-clear, .eq-sec-del,
  [data-rd-del], [data-tech-remove], .pay-del, .exp-del, #rSigClear, #aMilesClear {
    min-width: 2.75rem;
    min-height: 2.75rem;
  }
}
@keyframes slideIn { from { transform: translateY(12px); opacity: 0; } }
.banner {
  background: var(--warn-bg); border: 1px solid #fcd34d; color: #92400e;
  padding: .75rem 1rem; border-radius: 8px; font-size: .9rem; margin-bottom: 1rem;
  display: flex; gap: .75rem; align-items: flex-start;
}
.banner strong { display: block; }
.warn-box {
  background: var(--danger-bg); border: 1px solid #f5c6cb; color: var(--danger);
  padding: .6rem .8rem; border-radius: 8px; font-size: .88rem; margin-top: .5rem;
}
.tech-pill {
  display: inline-block; padding: .1rem .45rem; border-radius: 4px;
  background: #eef2f7; font-size: .75rem; font-weight: 600;
}
.detail-section { margin-top: 1.25rem; }
.detail-section h3 { margin-bottom: .6rem; padding-bottom: .4rem; border-bottom: 1px solid var(--border); }
.equip-card {
  border: 1px solid var(--border); border-radius: 8px; padding: .75rem;
  margin-bottom: .5rem; background: #fafbfc;
}
.filters { display: flex; gap: .5rem; flex-wrap: wrap; align-items: flex-end; margin-bottom: 1rem; }
.filters .field { margin: 0; min-width: 140px; }
.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.tabs { display: flex; gap: .25rem; background: var(--bg); padding: .25rem; border-radius: 8px; }
.tab {
  border: none; background: transparent; padding: .4rem .85rem; border-radius: 6px;
  cursor: pointer; font-weight: 560; color: var(--muted);
}
.tab.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.tech-list { display: flex; flex-direction: column; gap: .4rem; }
.tech-row {
  display: flex; gap: .5rem; align-items: center;
  padding: .5rem .65rem; background: #fafbfc; border: 1px solid var(--border); border-radius: 8px;
}
.tech-row input { flex: 1; }

.badge-field-hvac { background: #e0ecff; color: #1d4ed8; }
.badge-field-plumbing { background: #dff7f3; color: #0f766e; }
.badge-field-misc { background: #f1f5f9; color: #475569; }
.badge-call-regular { background: #f1f5f9; color: #334155; }
.badge-call-after { background: #1e293b; color: #fff; }
.badge-call-holiday { background: #fef3c7; color: #92400e; }
.badge-call-pm { background: #dcfce7; color: #166534; }
.badge-pm-progress { background: #fff; color: #166534; border: 1px solid #86efac; }
.hidden { display: none !important; }
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 1rem; }
.stat-sub { font-size: .8rem; color: var(--muted); margin-top: .15rem; }
.price-box { border: 1px solid var(--border); border-radius: 8px; padding: .75rem; margin-bottom: .85rem; background: #f8faff; }
.price-box h3 { font-size: .95rem; margin: 0 0 .5rem; }
.rate-info { font-size: .85rem; color: var(--primary-dark); margin-bottom: .6rem; display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.price-breakdown { font-size: .9rem; background: #fff; border: 1px dashed #bfd0f5; border-radius: 6px; padding: .5rem .65rem; margin-top: .25rem; }
.price-breakdown strong { font-size: 1rem; }
.check-inline { display: flex; align-items: center; gap: .4rem; font-weight: 500; margin: .25rem 0 .5rem; cursor: pointer; }
.check-inline input { width: 18px; height: 18px; }
.rate-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: .75rem; }
.chip-tags { display: flex; gap: .2rem; flex-wrap: wrap; margin-top: .25rem; }
.chip-tags .badge { font-size: .64rem; padding: .05rem .35rem; border-radius: 4px; }
.appt-chip.conflict { outline: 2px solid var(--danger); outline-offset: -2px; }
.conflict-flag { color: var(--danger); font-weight: 700; font-size: .7rem; }
.pm-box { border: 1px solid var(--border); border-radius: 8px; margin-bottom: .85rem; background: #fafbfc; }
.pm-box-head { padding: .65rem .75rem; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; gap: .5rem; flex-wrap: wrap; }
.progress-bar { height: 6px; background: #e2e8f0; border-radius: 3px; overflow: hidden; margin: .5rem .75rem 0; }
.progress-bar > span { display: block; height: 100%; background: var(--success); transition: width .2s; }
.ck-list { padding: .25rem 0; }
.ck-item { display: grid; grid-template-columns: auto 1fr auto; gap: .6rem; align-items: start; padding: .5rem .75rem; border-bottom: 1px solid #edf1f5; }
.ck-item:last-child { border-bottom: none; }
.ck-item input[type="checkbox"] { width: 20px; height: 20px; margin-top: 1px; accent-color: var(--success); cursor: pointer; }
.ck-item.done .ck-text { color: var(--muted); }
.ck-item.done { background: #f3fbf5; }
.ck-text { font-size: .9rem; cursor: pointer; }
.ck-item input.ck-note { width: 100%; margin-top: .3rem; padding: .3rem .5rem; font-size: .82rem; }
.ck-add { display: flex; gap: .5rem; padding: .6rem .75rem; border-top: 1px solid var(--border); }
.tpl-row { display: flex; gap: .35rem; align-items: center; padding: .35rem .5rem; background: #fafbfc; border: 1px solid var(--border); border-radius: 8px; }
.tpl-row .num { width: 1.6rem; text-align: right; color: var(--muted); font-size: .8rem; }
.tpl-row input { flex: 1; }

/* ───── shared / multi-user additions ───── */
.auth-screen { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; padding: 1rem; background: var(--bg); z-index: 50; }
.auth-card { width: 100%; max-width: 380px; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 1.5rem; box-shadow: 0 10px 30px rgba(15,30,60,.08); }
.auth-card .brand { justify-content: center; margin-bottom: 1rem; font-size: 1.15rem; }
.auth-card h1 { font-size: 1.15rem; text-align: center; margin: 0 0 1rem; }
.auth-card .btn { width: 100%; justify-content: center; }
.auth-msg { min-height: 1.2em; font-size: .85rem; margin: .5rem 0; }
.auth-msg.err { color: var(--danger, #c0392b); }
.auth-msg.ok { color: #1e7d45; }
.link-btn { background: none; border: none; color: var(--primary); cursor: pointer; padding: 0; font: inherit; font-size: .85rem; }
.app.hidden-app, .auth-screen.hidden { display: none; }
.user-box { display: flex; align-items: center; gap: .5rem; margin-left: auto; font-size: .85rem; }
.user-box .role-pill { font-size: .7rem; padding: .1rem .45rem; border-radius: 99px; background: var(--primary-light); color: var(--primary); text-transform: uppercase; letter-spacing: .03em; }
.sync-dot { width: 8px; height: 8px; border-radius: 50%; background: #2ecc71; display: inline-block; }
.sync-dot.busy { background: #f1c40f; }
.sync-dot.off { background: #e74c3c; }
body.role-technician .admin-only { display: none !important; }
.btn.toggle-on { background: var(--primary); color: #fff; border-color: var(--primary); }
.user-row { display: grid; grid-template-columns: 1.4fr 1fr 1fr auto auto; gap: .5rem; align-items: center; padding: .5rem 0; border-bottom: 1px solid var(--border); }
.user-row:last-child { border-bottom: none; }
@media (max-width: 720px) {
  .user-box .user-name { display: none; }
  .user-row { grid-template-columns: 1fr 1fr; }
  .modal-foot { flex-wrap: wrap; }
  .filters .field { min-width: 0; flex: 1 1 45%; }
}
@media (max-width: 560px) { .topbar #brandName { display: none; } .topbar { gap: .4rem; } }
@media (max-width: 720px) {
  .topbar { flex-wrap: wrap; height: auto; padding-top: .4rem; padding-bottom: .25rem; row-gap: .2rem; }
  .topbar .nav { order: 3; flex: 1 1 100%; }
  .topbar .nav-btn { padding: .4rem .6rem; }
}

/* ── buildings & units ── */
.section-head { margin-bottom: .6rem; padding-bottom: .4rem; border-bottom: 1px solid var(--border); }
.bldg-card {
  border: 1px solid var(--border); border-left: 4px solid var(--primary); border-radius: 8px;
  padding: .75rem; margin-bottom: .75rem; background: var(--surface);
}
.bldg-head { display: flex; justify-content: space-between; align-items: flex-start; gap: .75rem; flex-wrap: wrap; }
.bldg-actions { flex-shrink: 0; }
.bldg-toolbar { flex-wrap: wrap; align-items: center; }
.bldg-toggle-area {
  display: flex; align-items: flex-start; gap: .55rem; flex: 1; min-width: 0;
  min-height: 44px; margin: -.35rem; padding: .35rem .4rem; cursor: pointer;
  border-radius: 8px; color: inherit;
}
.bldg-toggle-area:hover { background: var(--primary-light, #eef4ff); }
.bldg-toggle-area:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.bldg-chevron {
  flex: 0 0 1.15rem; width: 1.15rem; height: 1.15rem; margin-top: .2rem;
  background: currentColor; color: var(--muted);
  clip-path: polygon(20% 35%, 50% 70%, 80% 35%);
  transition: transform .15s ease;
}
.bldg-card.is-collapsed .bldg-chevron { transform: rotate(-90deg); }
.bldg-toggle-text { min-width: 0; flex: 1; }
.bldg-toggle-text strong { display: block; overflow-wrap: anywhere; }
.bldg-card.is-collapsed .unit-list { display: none; }
.equip-card.unit-match { outline: 2px solid var(--primary); outline-offset: 1px; }
.unit-list { margin-top: .6rem; display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: .5rem; }
.unit-list .equip-card { margin-bottom: 0; }
.unit-head strong { min-width: 0; overflow-wrap: anywhere; }
.filter-pill {
  display: inline-block; padding: .1rem .45rem; border-radius: 4px;
  background: var(--primary-light); color: var(--primary-dark); font-size: .78rem; font-weight: 600;
}
.belt-pill { background: #fff3e0; color: #8a4b00; }
.refrig-pill { background: #e3f2fd; color: #0d47a1; }
.unit-name { font-size: 1.02rem; overflow-wrap: anywhere; }
.unit-type { margin-top: .1rem; }
.job-place { overflow-wrap: anywhere; }
.chip-place { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 560px) {
  .unit-list { grid-template-columns: 1fr; }
  .bldg-actions { width: 100%; }
  .bldg-actions .btn { flex: 1 1 0; min-height: 44px; }
  .section-head .btn { padding-left: .6rem; padding-right: .6rem; min-height: 44px; }
  .bldg-toolbar .btn { min-height: 44px; }
  .bldg-toggle-area { min-height: 48px; }
}

/* ── Attachable checklists (Heating / Cooling / …) ── */
.ck-attach-bar { display: flex; flex-wrap: wrap; gap: .4rem; padding: .55rem .75rem; border-bottom: 1px solid var(--border); background: #fff; }
.ck-group { border-top: 1px solid var(--border); }
.ck-group:first-of-type { border-top: none; }
.ck-group-head { display: flex; justify-content: space-between; align-items: center; gap: .5rem; flex-wrap: wrap; padding: .55rem .75rem; background: #f1f5f9; }
.progress-bar + .ck-group { border-top: none; }

/* ── Photos ── */
.photo-box, .quote-box { border: 1px solid var(--border); border-radius: 8px; padding: .65rem .75rem; margin-bottom: .85rem; background: #fafbfc; }
.photo-head, .quote-head, .doc-bar, .readings-head { display: flex; justify-content: space-between; align-items: center; gap: .5rem; flex-wrap: wrap; }
.photo-btn { margin: 0; color: var(--text); font-weight: 560; font-size: inherit; cursor: pointer; }
.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: .45rem; margin-top: .5rem; }
.photo-thumb { padding: 0; border: 1px solid var(--border); border-radius: 6px; overflow: hidden; aspect-ratio: 1; background: #e5e9ef; cursor: zoom-in; width: 100%; }
.photo-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo-viewer { position: fixed; inset: 0; z-index: 1000; background: rgba(10,15,25,.92); display: flex; flex-direction: column; }
.pv-bar { display: flex; justify-content: space-between; align-items: center; gap: .5rem; flex-wrap: wrap; padding: .6rem .8rem; color: #e5e7eb; font-size: .85rem; }
.pv-img { flex: 1; display: flex; align-items: center; justify-content: center; min-height: 0; padding: .5rem; color: #cbd5e1; }
.pv-img img { max-width: 100%; max-height: 100%; object-fit: contain; border-radius: 4px; }
.badge-photos { background: #f1f5f9; color: #334155; border: 1px solid #cbd5e1; }

/* ── Repair quote ── */
.quote-total { font-weight: 700; font-size: 1.05rem; }
.quote-lines { margin-top: .5rem; display: flex; flex-direction: column; gap: .35rem; }
.ql { display: grid; grid-template-columns: 84px 1fr 64px 96px 86px auto; gap: .35rem; align-items: center; }
.ql input, .ql select { padding: .4rem .5rem; font-size: .88rem; }
.ql-total { text-align: right; font-weight: 600; font-size: .88rem; }
.ql-head span:nth-child(5) { text-align: right; }
.quote-actions { flex-wrap: wrap; }
.badge-quote-draft { background: #f1f5f9; color: #475569; }
.badge-quote-presented { background: var(--info-bg); color: var(--info); }
.badge-quote-approved { background: var(--success-bg); color: var(--success); }
.badge-quote-declined { background: var(--danger-bg); color: var(--danger); }
.badge-quote-submitted { background: #e0e7ff; color: #3730a3; }
.doc-bar { border: 1px solid var(--border); border-radius: 8px; padding: .55rem .75rem; margin-bottom: .85rem; background: #fff; }
@media (max-width: 640px) {
  .ql { grid-template-columns: 1fr 1fr auto; grid-template-areas: "kind kind del" "desc desc desc" "qty price total"; background: #fff; border: 1px solid var(--border); border-radius: 6px; padding: .4rem; }
  .ql > :nth-child(1) { grid-area: kind; } .ql > :nth-child(2) { grid-area: desc; } .ql > :nth-child(3) { grid-area: qty; }
  .ql > :nth-child(4) { grid-area: price; } .ql > :nth-child(5) { grid-area: total; } .ql > :nth-child(6) { grid-area: del; }
  .ql-head { display: none; }
}

/* ── Electrical readings ── */
.readings-box { border: 1px solid var(--border); border-radius: 8px; padding: .65rem .75rem; background: #fafbfc; margin-bottom: .5rem; }
.reading-group { margin-top: .6rem; }
.reading-group-head { display: flex; justify-content: space-between; align-items: center; gap: .5rem; }
.reading-row { display: grid; grid-template-columns: 1fr auto; gap: .35rem; align-items: start; background: #fff; border: 1px solid var(--border); border-radius: 6px; padding: .45rem; margin-top: .4rem; }
.reading-fields { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: .35rem .5rem; }
.reading-fields .rf { margin: 0; font-size: .72rem; }
.reading-fields .rf span { display: block; margin-bottom: .15rem; }
.reading-fields input, .reading-fields select { padding: .35rem .45rem; font-size: .88rem; }
.reading-fields .rf-notes { grid-column: 1 / -1; }
.reading-empty { margin: .3rem 0 0; }
.readings .reading-line { margin-top: .2rem; }
.reading-kind { font-weight: 600; color: var(--muted); margin-right: .2rem; }
.reading-pill { display: inline-block; background: #fff7ed; color: #9a3412; border: 1px solid #fed7aa; border-radius: 999px; padding: .05rem .5rem; margin: .1rem .1rem 0 0; font-size: .78rem; }

/* ── Quote line labels (shown on phones) ── */
.ql-f { display: contents; }
.ql-lbl { display: none; }
@media (max-width: 640px) {
  .ql-f { display: flex; flex-direction: column; gap: .1rem; margin: 0; min-width: 0; }
  .ql-lbl { display: block; font-size: .7rem; font-weight: 600; color: var(--muted); }
  .ql-f input { width: 100%; }
  .ql-total::before { content: "Line total"; display: block; font-size: .7rem; font-weight: 600; color: var(--muted); }
}

/* ── Quote signatures ── */
.sig-overlay { position: fixed; inset: 0; z-index: 1100; background: rgba(10,15,25,.6); display: flex; align-items: center; justify-content: center; padding: .75rem; }
.sig-card { background: #fff; border-radius: 12px; box-shadow: 0 10px 40px rgba(0,0,0,.3); padding: 1rem; width: min(640px, 100%); max-height: 100%; overflow: auto; }
.sig-card h3 { margin: 0 0 .35rem; }
.sig-pad-wrap { position: relative; margin: .25rem 0 .5rem; }
#sigCanvas { display: block; width: 100%; height: 190px; background: #fff; border: 2px dashed #94a3b8; border-radius: 8px; touch-action: none; cursor: crosshair; }
.sig-x { position: absolute; left: .75rem; bottom: .5rem; font-size: .75rem; color: #94a3b8; pointer-events: none; border-top: 1px solid #cbd5e1; width: calc(100% - 1.5rem); padding-top: .15rem; }
.sig-actions { align-items: center; }
.sig-box { border: 1px solid var(--border); border-left: 4px solid var(--success); border-radius: 8px; background: #fff; padding: .5rem .65rem; margin-top: .5rem; }
.sig-box.sig-declined { border-left-color: var(--danger); }
.sig-head { display: flex; flex-wrap: wrap; gap: .25rem .6rem; align-items: baseline; }
.sig-img { display: block; max-width: 260px; max-height: 90px; margin-top: .35rem; background: #fff; }
.sig-img-sm { max-width: 140px; max-height: 50px; margin: 0; }
.sig-history { margin-top: .4rem; }
.sig-hist-row { display: flex; gap: .5rem; align-items: center; padding: .3rem 0; border-top: 1px dashed var(--border); opacity: .85; }
#receiptSigBox { flex-basis: 100%; }
#receiptSigBox .sig-box { margin-top: .15rem; }
#receiptSigBox .rsig-hint { margin: .4rem 0 .35rem; }

.share-btns { display: flex; flex-direction: column; gap: .45rem; margin-top: .6rem; }
.share-btns .btn { justify-content: center; }

/* ── Billing mode ── */
.badge-billing-non_billable { background: #e0f2fe; color: #075985; border: 1px solid #7dd3fc; }
.badge-billing-charity { background: #fdf2f8; color: #9d174d; border: 1px solid #f9a8d4; }
.badge-expenses { background: #fff7ed; color: #9a3412; border: 1px solid #fdba74; }
.nocharge-note { display: inline-block; margin-top: .35rem; padding: .35rem .5rem; border-radius: 6px; background: #e0f2fe; color: #075985; font-weight: 600; font-size: .85rem; }
.nocharge-note.charity { background: #fdf2f8; color: #9d174d; }
.price-box.no-charge .price-breakdown { opacity: .7; }
.nocharge-price { color: var(--muted); }
h2 .badge { font-size: .7rem; vertical-align: middle; }

/* ── Supplies / job expenses (internal) ── */
.expense-box { border: 1px dashed #fdba74; border-radius: 8px; padding: .65rem .75rem; margin-bottom: .85rem; background: #fffaf3; }
.exp-head { display: flex; justify-content: space-between; align-items: center; gap: .5rem; flex-wrap: wrap; margin-bottom: .4rem; }
.internal-tag { font-size: .72rem; font-weight: 600; color: #9a3412; background: #ffedd5; border-radius: 999px; padding: .1rem .5rem; }
.exp-list { display: flex; flex-direction: column; gap: .35rem; }
.exp-row { display: flex; justify-content: space-between; gap: .5rem; align-items: flex-start; background: #fff; border: 1px solid var(--border); border-radius: 6px; padding: .4rem .55rem; }
.exp-main { min-width: 0; flex: 1; }
.exp-receipts { display: flex; gap: .3rem; flex-wrap: wrap; margin-top: .3rem; }
.exp-thumb { width: 52px; height: 52px; padding: 0; border: 1px solid var(--border); border-radius: 4px; overflow: hidden; background: #e5e9ef; cursor: zoom-in; }
.exp-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.exp-summary { margin: .5rem 0; padding: .35rem .5rem; background: #fff; border-radius: 6px; border: 1px solid var(--border); }
.exp-profit { color: var(--success); }
.exp-profit.neg { color: var(--danger); }
.exp-form { border-top: 1px solid #fed7aa; padding-top: .5rem; }
.exp-form.editing { background: #fff; border: 1px solid #fdba74; border-radius: 6px; padding: .5rem; }
.exp-grid { display: grid; grid-template-columns: 2fr 1fr 1fr; gap: .4rem; }
@media (max-width: 640px) { .exp-grid { grid-template-columns: 1fr 1fr; } .exp-grid > :first-child { grid-column: 1 / -1; } }

.exp-tax { margin: .45rem 0; padding: .5rem .6rem; background: #f8fafc; border: 1px solid var(--border); border-radius: 8px; }
.exp-tax-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .4rem; margin-top: .35rem; }
.exp-tax-total { font-weight: 700; font-size: 1.05em; padding-top: .15rem; }
.exp-tax-line { margin-top: .15rem; }
@media (max-width: 640px) { .exp-tax-grid { grid-template-columns: 1fr; } }


/* ── Charity & job costs summary ── */
.cost-totals { margin-bottom: .5rem; }
.cost-table { width: 100%; border-collapse: collapse; font-size: .85rem; }
.cost-table th, .cost-table td { padding: .35rem .45rem; border-bottom: 1px solid var(--border); text-align: right; white-space: nowrap; }
.cost-table th:first-child, .cost-table td:first-child { text-align: left; }
.cost-table tfoot td { font-weight: 700; border-top: 2px solid var(--border); }

/* ───── Maps & mileage ───── */
.addr-link { background: none; border: 0; padding: .15rem 0; margin: 0; font: inherit; color: var(--primary, #1f5fbf); text-align: left; cursor: pointer; text-decoration: underline; text-decoration-style: dotted; text-underline-offset: 3px; min-height: 32px; }
.addr-link:hover { text-decoration-style: solid; }
.job-addr { margin: -.35rem 0 .75rem; font-size: .9rem; }
.mile-box { border: 1px dashed #93c5fd; border-radius: 8px; padding: .65rem .75rem; margin-bottom: .85rem; background: #f5f9ff; }
.mile-box h3 { margin: 0 0 .5rem; font-size: 1rem; }
.mile-box .field { max-width: 220px; margin-bottom: .4rem; }
.warn-text { color: #b45309; }
.map-sheet { position: fixed; inset: 0; z-index: 1000; background: rgba(10,15,25,.55); display: flex; align-items: flex-end; justify-content: center; }
.ms-card { background: var(--surface, #fff); width: 100%; max-width: 640px; max-height: 94vh; overflow-y: auto; border-radius: 14px 14px 0 0; padding: .85rem 1rem calc(1rem + env(safe-area-inset-bottom)); box-shadow: 0 -10px 40px rgba(0,0,0,.25); }
@media (min-width: 700px) { .map-sheet { align-items: center; } .ms-card { border-radius: 14px; } }
.ms-head { display: flex; justify-content: space-between; align-items: flex-start; gap: .5rem; margin-bottom: .6rem; }
.ms-addr { font-size: 1rem; line-height: 1.35; }
.ms-map { height: 260px; border-radius: 10px; overflow: hidden; background: #e5e7eb; position: relative; z-index: 0; }
.ms-map-msg { padding: 1rem; }
.ms-dir { margin: .7rem 0; flex-wrap: wrap; }
.ms-dir .btn { flex: 1 1 180px; text-align: center; text-decoration: none; justify-content: center; }
.ms-miles { margin: .35rem 0; }
.ms-mi { display: flex; gap: 1.5rem; flex-wrap: wrap; }
.ms-big { font-size: 1.5rem; font-weight: 700; }
.ms-start { margin: .5rem 0; }
.ms-start .row, .ms-log .row { flex-wrap: wrap; }
.ms-log { margin: .5rem 0; }
.ms-log .btn { margin: .15rem 0; }
.ms-foot { margin: .75rem 0 0; }
.mile-rates { border: 1px solid var(--border, #e5e7eb); border-radius: 8px; padding: .5rem .65rem; }
.mile-rates summary { cursor: pointer; }
.mile-rate-row { flex-wrap: wrap; align-items: flex-end; margin: .35rem 0; }
.mile-rates input { width: auto; max-width: 150px; }

/* ── Optional unit detail sections (add / remove per unit) ── */
.eq-sec { border: 1px solid var(--border); border-radius: 8px; padding: .55rem .75rem .15rem; background: #fafbfc; margin-bottom: .6rem; }
.eq-sec[hidden], .readings-box[hidden] { display: none; }
.eq-sec-head { display: flex; justify-content: space-between; align-items: center; gap: .5rem; margin-bottom: .45rem; }
.eq-sec-head strong { font-size: .9rem; }
.eq-sec-del { flex-shrink: 0; min-width: 2rem; }
.eq-add { margin: .25rem 0 .5rem; }
.eq-add-label { margin-bottom: .35rem; }
.eq-add-chips { display: flex; flex-wrap: wrap; gap: .4rem; }
.eq-add-chip { border-style: dashed; }
.unit-parts { overflow-wrap: anywhere; }
.part-kind { font-weight: 600; }
/* compressors / condenser fans: count + one amp row each */
.counted-count input { max-width: 8rem; }
.counted-rows { margin: -.15rem 0 .5rem; }
.counted-row { display: grid; grid-template-columns: 2rem 1fr 1fr; gap: .35rem .5rem; align-items: end; padding: .3rem 0; border-top: 1px dashed var(--border); }
.counted-rows.one-field .counted-row { grid-template-columns: 2rem minmax(0, 12rem); }
.counted-row .rf { margin: 0; font-size: .72rem; }
.counted-row .rf span { display: block; margin-bottom: .15rem; }
.counted-row input { padding: .4rem .5rem; font-size: .95rem; width: 100%; }
.counted-label { font-weight: 600; font-size: .8rem; color: var(--muted, #6b7280); padding-bottom: .45rem; }

/* ── v11: readings recorded on jobs ── */
.rd-box[hidden] { display: none; }
.rd-box > .rd-group, .rd-box > .rd-unit, .rd-box > .rd-more, .pm-box > .rd-unit { margin: .55rem .75rem; }
.rd-inline { margin-top: .45rem; }
.rd-group { background: #fff; border: 1px solid #fed7aa; border-left: 3px solid #f97316; border-radius: 6px; padding: .45rem .55rem; margin-top: .4rem; }
.rd-group-title { font-weight: 650; font-size: .82rem; margin-bottom: .25rem; }
.rd-group .counted-rows { margin: 0; }
.rd-group .counted-row:first-child { border-top: none; }
.rd-group .reading-group { margin-top: .35rem; }
.rd-group .reading-row { background: #fffdfa; }
.rd-press { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.rd-temp { grid-template-columns: minmax(0, 14rem); }
.rd-hint { margin: .25rem 0 0; }
.rd-unit { margin-bottom: .4rem; }
.rd-unit select { width: 100%; }
.rd-more > summary { cursor: pointer; font-weight: 600; font-size: .88rem; padding: .2rem 0; }
.job-readings { color: #9a3412; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.unit-readings { border-top: 1px dashed var(--border); padding-top: .35rem; }
.reading-hist { margin-top: .35rem; }
.reading-hist > summary { cursor: pointer; font-size: .8rem; color: var(--muted); }
.reading-hist-row { font-size: .78rem; padding: .2rem 0; border-top: 1px solid #f1f3f6; }
.eq-readings-hint { margin: -.2rem 0 .6rem; }
@media (min-width: 640px) { .rd-press { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.rd-group .reading-row > .reading-fields, .rd-group .rf { min-width: 0; }
.rd-group .reading-fields { grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); }
.rd-group input, .rd-group select { min-width: 0; width: 100%; box-sizing: border-box; }

/* ── v12: refrigerant weights (lb + oz) ── */
.wt-inputs { display: flex; gap: .5rem; }
.wt-part { display: flex; align-items: center; gap: .3rem; flex: 1 1 0; min-width: 0; margin: 0; font-weight: 400; }
.wt-part input { min-width: 0; width: 100%; box-sizing: border-box; }
.wt-part span { font-size: .85rem; color: var(--muted, #6b7280); }
.eq-charge .tiny { margin: .25rem 0 0; }
.rd-wt { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr) minmax(0, 1fr); gap: .4rem; align-items: end; margin-top: .45rem; }
.rd-wt-label { font-size: .78rem; font-weight: 600; padding-bottom: .5rem; }
.rd-wt .rf { margin: 0; font-size: .72rem; }
.rd-wt .rf span { display: block; margin-bottom: .15rem; }
.wt-part input, .rd-wt input { color: var(--text); font-weight: 400; }

/* ── v13: refrigerant charge / added / recovered per compressor ── */
.comp-charges { margin: -.35rem 0 .6rem; }
.comp-charge-head { margin-bottom: .3rem; }
.comp-charge-row { display: grid; grid-template-columns: 4.2rem minmax(0, 1fr) minmax(0, 1fr); gap: .5rem; align-items: center; padding: .25rem 0; border-top: 1px dashed var(--border); }
.comp-charge-label { font-weight: 600; font-size: .82rem; color: var(--muted); }
.counted-row.with-wt .rd-wts { grid-column: 2 / -1; }
.rd-wts .rd-wt:first-of-type { margin-top: .1rem; }
.rd-charge { margin-top: .15rem; }
.comp-charge-line { margin-top: .25rem; display: flex; flex-wrap: wrap; gap: .3rem; }
.charge-pill { background: #eef6ff; }

/* v14: data plate amps on the unit + plate hints on job readings */
.comp-charge-row .plate-amps { grid-column: 2 / -1; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: .5rem; }
.fan-plate-row .wt-part { grid-column: 2; }
.rf .rd-plate { display: block; margin-top: .15rem; font-size: .68rem; color: var(--muted, #64748b); }
.rf.over-plate input { border-color: #f59e0b; background: var(--warn-bg); }
.rf.over-plate .rd-plate { color: var(--warn); font-weight: 600; }
.rf.over-plate .rd-plate::after { content: ' · above plate'; }
/* v14: customer receipt letterhead */
.lh-box { border: 1px solid var(--border); border-radius: 10px; padding: .6rem .7rem; margin: .5rem 0; }
.lh-box summary { cursor: pointer; font-weight: 600; }
.lh-logo-row { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; }
.lh-logo-prev { max-height: 48px; max-width: 180px; background: #fff; border: 1px solid var(--border); border-radius: 6px; padding: 2px; }
.lh-note { margin-top: .25rem; }
#rLhNote { flex-basis: 100%; }

/* v15: heating fuel type */
.heat-pill { background: #fff1e6; color: #9a3412; }
.badge-heat { background: #fff7ed; color: #9a3412; border: 1px solid #fdba74; }
.heat-pick { padding: .55rem .75rem; border-bottom: 1px solid var(--border); background: #fffaf5; display: flex; flex-direction: column; gap: .35rem; }
.heat-pick label { font-weight: 600; font-size: .85rem; }
.heat-pick select { width: 100%; min-height: 44px; }
.heat-prompt { background: #fef3c7; color: #92400e; border: 1px solid #fcd34d; border-radius: 6px; padding: .35rem .5rem; font-size: .82rem; }
.heat-pick label.heat-save { display: flex; align-items: center; gap: .5rem; font-weight: 500; font-size: .82rem; }
.heat-pick label.heat-save input { width: 1.15rem; height: 1.15rem; flex: none; }
.tpl-row.has-fuel { flex-wrap: wrap; }
.tpl-row.has-fuel input { min-width: 0; }
.tpl-row .tpl-fuel { flex: 1 1 100%; margin-left: 1.95rem; max-width: calc(100% - 1.95rem); }
.tpl-fuel-hint { margin: 0 0 .4rem; }

/* v16 multi-tech + clock */
.tech-box { border: 1px solid var(--border); border-radius: 8px; padding: .75rem; margin-bottom: .85rem; background: #f7faf7; }
.tech-box h3 { font-size: .95rem; margin: 0 0 .5rem; }
.tech-row { display: flex; flex-wrap: wrap; gap: .5rem .75rem; align-items: center; padding: .45rem 0; border-top: 1px solid #e3ebe3; }
.tech-row:first-of-type { border-top: 0; }
.tech-row-main { flex: 1 1 140px; display: flex; flex-wrap: wrap; gap: .35rem .5rem; align-items: baseline; }
.tech-row-hours { display: flex; flex-direction: column; gap: .15rem; }
.tech-row-hours input { width: 5.5rem; }
.tech-row-actions { display: flex; gap: .35rem; flex-wrap: wrap; }
.tech-timer { color: #0a7a3e; font-weight: 650; font-variant-numeric: tabular-nums; }
.dispatch-allday .time-col { background: #eef6ff; font-weight: 650; }
#aTechAdd { min-width: 10rem; }

/* v17 PM frequency */
.pm-freq-pill { background: #e8f0ff; }
.pm-due-pill { background: #e9f7ef; }
.pm-due-pill.pm-due-overdue { background: #fde8e8; color: #8a1f1f; }
#ePmWindowWrap[style*="display: none"] { display: none !important; }

/* CO reading amber / alarm flags */
.rf.co-warn input { border-color: #f59e0b; background: var(--warn-bg, #fffbeb); }
.rf.co-warn::after { content: ' ⚠'; color: #d97706; font-weight: 700; }
.rf.co-alarm input { border-color: #ef4444; background: #fef2f2; }
.rf.co-alarm::after { content: ' ⚠ ALARM'; color: #dc2626; font-weight: 700; }


/* v20: autosave + clocked-in banner */
.clock-chip {
  border: 1px solid #86efac; background: #ecfdf3; color: #14532d;
  font-weight: 700; font-size: .75rem; padding: .2rem .55rem; border-radius: 99px;
  cursor: pointer; white-space: nowrap;
}
.clock-chip:hover, .clock-chip:focus { background: #d1fae5; }
.clock-banner {
  position: sticky; top: 56px; z-index: 39;
  background: #ecfdf3; border-bottom: 1px solid #86efac; color: #14532d;
  padding: .5rem .9rem; display: flex; flex-direction: column; gap: .4rem;
}
.clock-banner.hidden { display: none !important; }
.clock-banner-row { display: flex; flex-wrap: wrap; gap: .35rem .75rem; align-items: center; justify-content: space-between; }
.clock-banner-row.is-you strong { font-weight: 750; }
.job-draft-status[data-kind="ok"] { color: #166534; }
.job-draft-status[data-kind="busy"] { color: #a16207; }
.job-draft-status[data-kind="warn"] { color: #b45309; }
.badge-clocked { background: #ecfdf3; color: #14532d; border: 1px solid #86efac; }
.unit-ck-hist { border: 1px solid #d8e8d8; border-radius: 8px; padding: .5rem .65rem; background: #f7fbf7; }
.unit-ck-row {
  display: flex; flex-wrap: wrap; gap: .25rem .6rem; align-items: baseline;
  width: 100%; text-align: left; border: 0; background: transparent;
  padding: .3rem 0; border-top: 1px solid #e3ebe3; cursor: pointer; font: inherit;
}
.unit-ck-row:first-of-type { border-top: 0; }
.unit-ck-row:hover { color: var(--primary); }
@media (max-width: 720px) {
  .clock-banner { top: 0; }
}

/* v25: filter lines on units, Filter change / Unit monitoring jobs */
.unit-filters { border-top: 1px dashed var(--border); padding-top: .45rem; }
.filter-lines { display: flex; flex-wrap: wrap; gap: .25rem; margin-top: .3rem; }
.filter-line-pill { background: #ecfdf5; color: #065f46; }
.filter-line-pill.freq-daily { background: #fef9c3; color: #854d0e; }
.filter-line-pill.freq-biweekly { background: #e0f2fe; color: #075985; }
.filter-line-pill.freq-monthly { background: #f3e8ff; color: #6b21a8; }
.fl-row { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1.4fr) 70px minmax(0, 1.3fr) auto; gap: .5rem; align-items: end; padding: .55rem; border: 1px solid var(--border); border-radius: 8px; background: #fafbfc; margin-bottom: .45rem; }
.fl-row .field { margin: 0; }
.fl-row .fl-del { margin-bottom: .2rem; }
@media (max-width: 640px) {
  .fl-row { grid-template-columns: 1fr 1fr; }
  .fl-row .fl-label { grid-column: 1 / -1; }
  .fl-row .fl-freq { grid-column: 1 / 2; }
  .fl-row .fl-del { justify-self: end; }
}
.kind-box .kind-body { padding: .65rem .75rem; }
.filter-job-table td, .filter-job-table th { font-size: .85rem; }
.badge-kind-filter { background: #ecfdf5; color: #065f46; border: 1px solid #a7f3d0; }
.badge-kind-monitor { background: #eef2ff; color: #3730a3; border: 1px solid #c7d2fe; }
.badge-kind-scheduled { background: #dbeafe; color: #1e40af; border: 1px solid #bfdbfe; }
.badge-kind-nonscheduled { background: #f1f5f9; color: #334155; border: 1px solid #cbd5e1; }
.badge-replacement { background: #fef3c7; color: #92400e; }
.job-kind-field select { max-width: 360px; }

/* v26: dedicated Inside pre-filter row on unit cards */
.pf-row { margin-top: .35rem; padding: .5rem .55rem; border: 1px solid var(--border); border-radius: 8px; background: #fff; }
.pf-row.is-on { border-color: #fde68a; background: #fffbeb; }
.pf-toggle { margin: 0 0 .35rem; font-weight: 650; }
.pf-fields { display: grid; grid-template-columns: minmax(0, 1.4fr) 64px minmax(0, 1.3fr); gap: .4rem; }
.pf-f { display: flex; flex-direction: column; gap: .1rem; margin: 0; font-weight: 500; }
.pf-f input, .pf-f select { padding: .35rem .45rem; font-size: .85rem; min-height: 34px; }
.pf-row:not(.is-on) .pf-fields { opacity: .7; }
.pf-note { margin-top: .3rem; }
@media (max-width: 380px) { .pf-fields { grid-template-columns: 1fr 64px; } .pf-fields .pf-f:last-child { grid-column: 1 / -1; } }
.filter-job-table .fj-bldg td { background: #f1f5f9; font-weight: 650; }

/* v27: Unit filters = the unit's existing filter info, each size with its own frequency */
.uf-box { margin-top: .45rem; padding: .5rem .55rem; border: 1px solid var(--border); border-radius: 8px; background: #fff; }
.uf-row { display: flex; justify-content: space-between; align-items: center; gap: .5rem; padding: .35rem 0; border-top: 1px dashed var(--border); }
.uf-row:first-of-type { border-top: none; }
.uf-row .uf-size { min-width: 0; overflow-wrap: anywhere; font-size: .9rem; }
.uf-row select { width: auto; max-width: 52%; padding: .3rem .45rem; font-size: .85rem; min-height: 34px; }
.uf-row.is-set select { border-color: #86efac; background: #f0fdf4; }
/* v28: save status on inline filter fields + Filter changes in Edit unit */
.save-status { min-height: 1em; margin-top: .2rem; font-weight: 600; }
.save-status.is-busy { color: #6b7280; }
.save-status.is-ok { color: #15803d; }
.save-status.is-err { color: #b91c1c; }
.eq-fc { margin-top: .75rem; padding: .6rem; border: 1px solid var(--border); border-radius: 10px; background: #f8fafc; }
.eq-fc .uf-row { display: flex; align-items: center; justify-content: space-between; gap: .5rem; padding: .3rem 0; }

/* v29: Area serviced on unit cards (inline, with Saved ✓) */
.unit-area { display: flex; flex-wrap: wrap; align-items: flex-end; gap: .35rem .6rem; padding: .45rem .55rem; border: 1px solid var(--border); border-radius: 8px; background: #fff; }
.unit-area .area-f { display: flex; flex-direction: column; gap: .1rem; margin: 0; flex: 1 1 160px; font-weight: 500; }
.unit-area .area-in { padding: .35rem .45rem; font-size: .85rem; min-height: 34px; width: 100%; }
.unit-area .area-status { margin: 0 0 .15rem; min-height: 1em; }

/* ── v31: weekly report ── */
.nav-badge { display: inline-block; margin-left: .3rem; padding: 0 .4rem; border-radius: 999px; background: #d64545; color: #fff; font-size: .68rem; font-weight: 700; line-height: 1.3rem; vertical-align: middle; }
.nav-badge.hidden { display: none; }
.report-banner { display: flex; align-items: center; justify-content: space-between; gap: .75rem; flex-wrap: wrap; margin-bottom: 1rem; padding: .75rem 1rem; border-radius: var(--radius); background: var(--primary-light); border: 1px solid var(--border); }
.report-banner.hidden { display: none; }
.rpt-tiles .stat-val { font-size: 1.45rem; }
.rpt-delta { font-size: .76rem; color: var(--muted); }
.rpt-delta.up { color: #1f8a4c; }
.rpt-delta.down { color: #c0392b; }
.rpt-table td, .rpt-table th { white-space: nowrap; }
.rpt-table td:first-child { white-space: normal; }
.rpt-bar { display: block; height: 4px; border-radius: 2px; margin-top: 3px; }
.rpt-bar.b { background: var(--primary); }
.rpt-bar.c { background: #1f8a4c; }
#panel-reports h3 { font-size: .95rem; margin: .5rem 0 .35rem; }
.pay-box { margin-top: 1rem; }
@media (max-width: 640px) { .rpt-tiles { grid-template-columns: 1fr 1fr; } .rpt-tiles .stat-val { font-size: 1.15rem; } }
@media print {
  body.printing-report .topbar, body.printing-report .clock-banner, body.printing-report .no-print, body.printing-report .toast-wrap { display: none !important; }
  body.printing-report .panel:not(#panel-reports) { display: none !important; }
  body.printing-report #panel-reports { display: block !important; }
  body.printing-report details { display: block; }
  body.printing-report details > *:not(summary) { display: block; }
  body.printing-report .card, body.printing-report .stat { box-shadow: none; break-inside: avoid; }
  body.printing-report .grid-2 { display: block; }
  body.printing-report .grid-2 > .card { margin-bottom: .75rem; }
}
@media (min-width: 900px) { .rpt-tiles { grid-template-columns: repeat(5, 1fr); } }

/* v32: multiple trips on one job */
.trip-box { border: 1px solid var(--border, #d7dde5); border-radius: 12px; padding: .75rem; margin: .75rem 0; background: var(--card, #fff); }
.trip-box h3 { margin: 0 0 .5rem; font-size: 1rem; }
.trip-card { border: 1px solid var(--border, #d7dde5); border-left: 4px solid #2563eb; border-radius: 10px; padding: .6rem .7rem; margin-bottom: .6rem; background: rgba(37, 99, 235, .03); }
.trip-card.trip-first { border-left-color: #64748b; background: transparent; }
.trip-head { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; margin-bottom: .35rem; }
.trip-purpose-1 { margin-left: auto; display: inline-flex; align-items: center; gap: .35rem; }
.trip-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .5rem; }
.trip-grid .field { margin-bottom: .35rem; }
.trip-techs { display: flex; flex-direction: column; gap: .35rem; margin: .35rem 0 .5rem; }
.trip-tech-row { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; padding: .35rem .5rem; border-radius: 8px; background: rgba(100, 116, 139, .08); }
.trip-tech-row strong { min-width: 6rem; }
.trip-tech-row label { display: inline-flex; align-items: center; gap: .25rem; }
.trip-tech-row input[type=time] { width: 7.2rem; }
.trip-tech-row input[type=number] { width: 4.8rem; }
.trip-tech-add { max-width: 16rem; }
.trip-sum { margin-top: .35rem; padding-top: .35rem; border-top: 1px dashed var(--border, #d7dde5); }
.trip-totals { align-self: center; }
.trip-map .btn { width: 100%; }
.job-trips-line { color: #1d4ed8; }
@media (max-width: 640px) {
  .trip-grid { grid-template-columns: 1fr 1fr; }
  .trip-tech-row strong { min-width: 100%; }
  .trip-tech-row input[type=time] { width: 6.6rem; }
  .trip-purpose-1 { margin-left: 0; width: 100%; }
  .trip-purpose-1 select { flex: 1; }
  .trip-tech-add { max-width: 100%; width: 100%; }
}

/* v34 — English / Spanish switch ("¿Habla español? Haga clic aquí") */
.translator-link { display: inline-flex; align-items: center; gap: .3rem; color: var(--primary); border: 1px solid var(--border); border-radius: 99px; padding: .25rem .65rem; font-size: .8rem; font-weight: 600; text-decoration: none; white-space: nowrap; }
.translator-link:hover, .translator-link:focus-visible { background: var(--primary-light, #eef4ff); }
.lang-toggle { display: inline-flex; align-items: center; gap: .3rem; background: none; border: 1px solid var(--border); color: var(--primary); border-radius: 99px; padding: .25rem .65rem; font: inherit; font-size: .8rem; font-weight: 600; cursor: pointer; white-space: nowrap; }
.lang-toggle::before { content: "🌐"; font-size: .85em; }
.lang-toggle:hover, .lang-toggle:focus-visible { background: var(--primary-light); }
.auth-lang { display: flex; justify-content: flex-end; margin: -.5rem -.5rem .5rem 0; }
.auth-card .auth-lang .btn, .auth-card .lang-toggle { width: auto; }
@media (max-width: 560px) { .topbar-lang .lang-toggle { padding: .2rem .45rem; font-size: .72rem; } }


/* v36: per-unit filter checklist + multi-day work-day log */
.fc-toolbar { display: flex; align-items: center; gap: .4rem; flex-wrap: wrap; margin: .15rem 0 .5rem; }
.fc-toolbar .btn:disabled { opacity: .45; cursor: default; }
.filter-progress { margin-left: auto; font-size: .85rem; font-weight: 650; color: #0f766e; background: #ecfdf5; border: 1px solid #a7f3d0; border-radius: 999px; padding: .15rem .55rem; }
.filter-progress.is-done { background: #d1fae5; color: #065f46; }
.filter-check-table td, .filter-check-table th { vertical-align: middle; }
.filter-check-table tr.fc-done td { background: #f0fdf4; }
.fc-toggle { display: inline-flex; gap: 0; border: 1px solid var(--border, #d7dde5); border-radius: 8px; overflow: hidden; }
.fc-btn { border-radius: 0 !important; margin: 0; border: 0 !important; background: #fff; color: #475569; font-weight: 600; }
.fc-btn.is-on { background: #0f766e; color: #fff; }
.fc-btn[data-fc-done="0"].is-on { background: #64748b; color: #fff; }
.work-day-log { margin: .5rem 0 .35rem; padding: .5rem .55rem; border: 1px dashed #cbd5e1; border-radius: 10px; background: #f8fafc; }
.work-day-log .table-wrap { overflow-x: auto; }
.work-day-table { min-width: 760px; }
.work-day-head { display: flex; align-items: baseline; gap: .5rem; flex-wrap: wrap; margin-bottom: .35rem; }
.work-day-table { width: 100%; border-collapse: collapse; }
.work-day-table th, .work-day-table td { padding: .2rem .25rem; vertical-align: middle; font-size: .82rem; }
.work-day-table input, .work-day-table select { min-height: 32px; width: 100%; font-size: .82rem; }
.work-day-table input[type="date"] { min-width: 8.5rem; }
.work-day-table input[type="time"] { min-width: 6rem; }
.work-day-table input[type="number"] { min-width: 4.5rem; }
.work-day-table input[type="text"] { min-width: 6rem; }

#reportModeTabs { margin: 0 0 .85rem; width: fit-content; }
.daily-layout { display: grid; gap: 1rem; }
@media (min-width: 900px) { .daily-layout { grid-template-columns: 280px 1fr; align-items: start; } }
.daily-cal { padding: .75rem; }
.daily-cal-head { display: flex; align-items: center; justify-content: space-between; gap: .5rem; margin-bottom: .5rem; }
.daily-cal-head h3 { margin: 0; font-size: .95rem; }
.daily-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; text-align: center; }
.daily-grid .dow { font-size: .68rem; color: var(--muted); padding: .2rem 0; }
.daily-day-btn { appearance: none; border: 1px solid transparent; background: transparent; border-radius: 6px; padding: .35rem 0; font: inherit; cursor: pointer; color: var(--text); position: relative; }
.daily-day-btn:hover { background: var(--primary-light); }
.daily-day-btn.today { font-weight: 700; }
.daily-day-btn.selected { border-color: var(--primary); background: var(--primary-light); }
.daily-day-btn.has-data::after { content: ''; display: block; width: 5px; height: 5px; border-radius: 50%; background: var(--primary); margin: 2px auto 0; }
.daily-day-btn.empty-day { color: var(--muted); }
.daily-day-btn:disabled { opacity: .35; cursor: default; }
.daily-list { list-style: none; margin: .75rem 0 0; padding: 0; max-height: 16rem; overflow: auto; }
.daily-list button { width: 100%; text-align: left; appearance: none; border: 0; background: transparent; font: inherit; padding: .35rem .25rem; border-radius: 6px; cursor: pointer; color: var(--text); }
.daily-list button:hover, .daily-list button.selected { background: var(--primary-light); }
.daily-list .muted { color: var(--muted); }
.daily-note { font-size: .82rem; color: var(--muted); margin: .25rem 0 .75rem; }

.job-phase-bar { margin: .85rem 0 1rem; padding: .7rem .8rem; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
#modal .job-phase-bar { margin: 0; border-radius: 0; border-left: 0; border-right: 0; border-top: 0; padding: .55rem 1.25rem .65rem; }
.job-phase-head { display: flex; align-items: baseline; justify-content: space-between; gap: .5rem; margin-bottom: .5rem; }
.job-phase-head strong { font-size: .92rem; }
.job-phase-btns { display: flex; flex-wrap: wrap; gap: .35rem; }
.job-phase-btn { appearance: none; border: 1px solid var(--border); background: var(--bg); color: var(--text); border-radius: 999px; padding: .38rem .7rem; font: inherit; font-size: .85rem; cursor: pointer; }
.job-phase-btn:hover { border-color: var(--primary); }
.job-phase-btn.active { background: var(--primary); color: #fff; border-color: var(--primary); font-weight: 650; }
.job-phase-btn:disabled { opacity: .45; cursor: default; }
.badge-phase { border: 1px solid var(--border); }
.badge-phase-onsite { background: #ecfdf3; color: #14532d; border-color: #86efac; }
.badge-phase-traveling { background: #eff6ff; color: #1e3a8a; border-color: #93c5fd; }
.badge-phase-parts_run { background: #fff7ed; color: #9a3412; border-color: #fdba74; }
.badge-phase-return_needed { background: #fefce8; color: #854d0e; border-color: #fde047; }
.rd-unit-row, .rd-unit-actions { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.rd-unit-row .rd-unit-sel { flex: 1; min-width: 8rem; }
.rd-remove-unit { white-space: nowrap; }
.phase-sheet-back { position: fixed; inset: 0; z-index: 1200; background: rgba(15,23,42,.45); display: flex; align-items: center; justify-content: center; padding: 1rem; }
.phase-sheet { background: var(--surface); border-radius: 12px; padding: 1.1rem 1.2rem; width: min(420px, 100%); box-shadow: var(--shadow); }
.phase-sheet h3 { margin: 0 0 .35rem; }


/* v41: status timer is the clock */
.clock-chip.is-running, .clock-banner.is-running {
  background: #dcfce7;
  border-color: #4ade80;
  box-shadow: 0 0 0 2px rgba(22, 163, 74, .12);
}
.clock-chip.is-running { animation: clockPulse 2s ease-in-out infinite; }
@keyframes clockPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(22, 163, 74, .35); }
  50% { box-shadow: 0 0 0 6px rgba(22, 163, 74, 0); }
}
.clock-elapsed, .job-phase-elapsed { font-variant-numeric: tabular-nums; font-weight: 750; }
.clock-elapsed-lg { display: inline-block; margin-left: .35rem; font-size: 1.05rem; color: #14532d; }
.job-phase-head { flex-wrap: wrap; }
.job-phase-log { margin-top: .65rem; border-top: 1px dashed var(--border); padding-top: .5rem; }
.job-phase-log-head { display: flex; justify-content: space-between; gap: .5rem; align-items: baseline; margin-bottom: .3rem; }
.job-phase-log-row { display: flex; flex-wrap: wrap; justify-content: space-between; gap: .25rem .6rem; align-items: baseline; padding: .2rem 0; }
.job-phase-log-row.is-open { font-weight: 650; color: #14532d; }
.tech-session-list { flex-basis: 100%; }


/* v42: automatic miles tracking on Traveling / Parts run */
.miles-tracking {
  display: inline-block;
  margin-left: .4rem;
  padding: .1rem .45rem;
  border-radius: 999px;
  font-size: .75rem;
  font-weight: 700;
  letter-spacing: .01em;
  background: #eff6ff;
  color: #1e3a8a;
  border: 1px solid #93c5fd;
}
.miles-tracking.is-on { background: #dbeafe; }
.miles-tracking.is-off { background: #fff7ed; color: #9a3412; border-color: #fdba74; font-weight: 650; }

/* Inline + New customer on the ticket form */
.cust-pick-row { display: flex; gap: .5rem; align-items: stretch; }
.cust-pick-row select { flex: 1; min-width: 0; }
.cust-pick-row #aNewCust { flex: 0 0 auto; align-self: stretch; }
.new-cust-box {
  margin-top: .6rem;
  padding: .75rem .85rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--primary-light);
}
.new-cust-box .new-cust-head { font-weight: 650; margin-bottom: .55rem; color: var(--text); }
.new-cust-box .field:last-of-type { margin-bottom: .5rem; }
@media (max-width: 560px) {
  .cust-pick-row { flex-direction: column; }
  .cust-pick-row #aNewCust { width: 100%; }
}

.dash-still-open { margin-bottom: .85rem; padding: .7rem .8rem; border: 1px solid var(--warn); border-radius: 8px; background: var(--warn-bg); }
.dispatch-still-open { background: var(--warn-bg); }
.dispatch-still-open .time-col { color: var(--warn); font-weight: 650; }

.rcpt-group { margin: 1rem 0 1.5rem; }
.rcpt-group-h { font-size: 1.05rem; margin: 0 0 .5rem; }
.rcpt-row { display: flex; gap: .75rem; align-items: flex-start; justify-content: space-between; flex-wrap: wrap; }

/* Per-work-order sections */
.job-sec-head { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.job-sec-head .job-sec-x,
h3 .job-sec-x,
.pm-box-head .job-sec-x,
.photo-head .job-sec-x,
.exp-head .job-sec-x,
.quote-head .job-sec-x,
.job-phase-head .job-sec-x { margin-left: auto; }
.job-sec-add { margin: .85rem 0 .25rem; }
.job-sec-add-row { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
html[data-pricing-ui="off"] .pricing-ui,
html[data-miles-ui="off"] .miles-ui { display: none !important; }
@media (pointer: coarse), (max-width: 640px) {
  .job-sec-x { min-width: 2.75rem; min-height: 2.75rem; }
}


.btn-quote-submit { background: #4338ca; color: #fff; border-color: #4338ca; min-height: 44px; }
.btn-quote-submit:hover { background: #3730a3; }
.btn-sm.btn-quote-submit { min-height: 44px; }
.rq-ticket-note { background: #eef2ff; border: 1px solid #c7d2fe; border-radius: 10px; padding: .75rem 1rem; margin: 0 0 1rem; }
.rq-ticket-note-actions { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: .6rem; }
.rq-ticket-note-actions .btn { min-height: 44px; }
.list-item.is-quotesubmitted { border-left: 3px solid #4338ca; }
.job-sec-flash { outline: 3px solid #4338ca; outline-offset: 2px; transition: outline-color .3s; }

#sigPad #sigDate, #sigPad #sigName { min-height: 44px; }

button[hidden], .btn[hidden] { display: none !important; }
