:root {
  --accent: #c0392b;
  --accent-dark: #96281b;
  --ink: #1f2430;
  --muted: #6b7280;
  --border: #e4e2df;
  --bg: #faf9f7;
  --overdue: #c0392b;
  --due-soon: #b8860b;
  --upcoming: #2e7d32;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
}

button:focus-visible,
select:focus-visible,
input:focus-visible,
textarea:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.hidden { display: none !important; }
.muted { color: var(--muted); font-weight: normal; }

/* Passcode gate */
.gate {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(160deg, #2b2b2b, #1a1a1a);
}
.gate-card {
  background: #fff;
  padding: 2.5rem 2rem;
  border-radius: 10px;
  width: 320px;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0,0,0,0.35);
}
.gate-card h1 { margin: 0 0 0.25rem; color: var(--accent); }
.gate-card p { margin: 0 0 1.25rem; }
.gate-card form { display: flex; flex-direction: column; gap: 0.75rem; }
.gate-card input {
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 1rem;
}
.gate-card button {
  padding: 0.6rem;
  border: none;
  border-radius: 6px;
  background: var(--accent);
  color: #fff;
  font-size: 1rem;
  cursor: pointer;
}
.gate-card button:hover { background: var(--accent-dark); }
.error { color: var(--accent); font-size: 0.9rem; }

/* App shell */
.topbar {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  padding: 0.85rem 1.5rem;
  background: #fff;
  border-bottom: 1px solid var(--border);
}
.brand { font-weight: 700; font-size: 1.1rem; flex-shrink: 0; white-space: nowrap; }
/* wrap rather than scroll: an overflowing tab bar clips silently on macOS,
   where the scrollbar stays invisible until you happen to scroll it */
.tabs { display: flex; flex-wrap: wrap; gap: 0.25rem; flex: 1; min-width: 0; overflow-x: auto; }
.tab-btn { flex-shrink: 0; }
.notif-wrap, #logout-btn, .whoami { flex-shrink: 0; }
.tab-btn {
  border: none;
  background: transparent;
  padding: 0.5rem 0.9rem;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.95rem;
  color: var(--muted);
  min-height: 2.75rem;
}
.tab-btn.active { background: var(--accent); color: #fff; }
.link-btn {
  border: none;
  background: transparent;
  color: var(--accent);
  cursor: pointer;
  font-size: 0.9rem;
  padding: 0.45rem 0.6rem;
  min-height: 2.75rem;
  display: inline-flex;
  align-items: center;
}
.link-btn:hover { text-decoration: underline; }

/* Notifications */
.notif-wrap { position: relative; }
.bell-btn {
  border: none;
  background: transparent;
  font-size: 1.1rem;
  cursor: pointer;
  position: relative;
  padding: 0.45rem 0.6rem;
  min-width: 2.5rem;
  min-height: 2.5rem;
}
.notif-badge {
  position: absolute;
  top: -2px;
  right: -2px;
  background: var(--accent);
  color: #fff;
  border-radius: 999px;
  font-size: 0.65rem;
  padding: 0.05rem 0.35rem;
  font-weight: 700;
}
.notif-panel {
  position: absolute;
  top: 110%;
  right: 0;
  width: 340px;
  max-height: 420px;
  overflow: auto;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 12px 32px rgba(0,0,0,0.15);
  z-index: 60;
}
.notif-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
}
.notif-list { padding: 0.4rem; }
.notif-item {
  padding: 0.6rem 0.75rem;
  border-radius: 8px;
  font-size: 0.85rem;
  cursor: pointer;
  margin-bottom: 0.2rem;
}
.notif-item:hover { background: var(--bg); }
.notif-item.unread { background: #fdf1ee; }
.notif-item-time { font-size: 0.72rem; color: var(--muted); margin-top: 0.2rem; }
.notif-empty { padding: 1rem; color: var(--muted); font-size: 0.85rem; text-align: center; }

main { padding: 1.5rem; max-width: 1100px; margin: 0 auto; }

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}
.panel-header-actions {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}
.panel-header-actions select {
  padding: 0.45rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.88rem;
  min-height: 2.75rem;
}
.primary-btn {
  border: none;
  background: var(--accent);
  color: #fff;
  padding: 0.55rem 1rem;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.9rem;
  min-height: 2.75rem;
}
.primary-btn:hover { background: var(--accent-dark); }
.secondary-btn {
  border: 1px solid var(--border);
  background: #fff;
  padding: 0.4rem 0.75rem;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.85rem;
  min-height: 2.75rem;
}
.secondary-btn:hover { border-color: var(--accent); color: var(--accent); }

.empty-note { color: var(--muted); font-size: 0.85rem; font-style: italic; }

/* Deficiencies */
.deficiency-row {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.75rem 1rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 0.6rem;
}
.deficiency-row-main { flex: 1; }
.deficiency-row-desc { font-weight: 600; }
.deficiency-row-meta { font-size: 0.82rem; margin-top: 0.15rem; }
.status-badge {
  display: inline-block;
  padding: 0.15rem 0.6rem;
  border-radius: 10px;
  font-size: 0.78rem;
  color: #fff;
  white-space: nowrap;
}
.status-badge.open { background: var(--overdue); }
.status-badge.in_progress { background: var(--due-soon); }
.status-badge.fixed { background: var(--upcoming); }
.status-badge.invoiced { background: #5b6b7a; margin-left: 0.3rem; }
.status-badge.new { background: #3b6fd6; margin-right: 0.4rem; }

/* Team */
.team-row {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.75rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.6rem;
}
.team-name { font-weight: 600; }

.whoami {
  font-size: 0.82rem;
  color: var(--muted);
  white-space: nowrap;
}


/* Deficiency detail */
.updates-thread { border-top: 1px solid var(--border); margin-top: 1rem; padding-top: 0.75rem; }
.update-item { padding: 0.5rem 0; border-bottom: 1px solid #f0efec; font-size: 0.88rem; }
.update-item-author { font-weight: 600; }
.update-item-time { color: var(--muted); font-size: 0.75rem; }
.update-item-body { margin-top: 0.2rem; white-space: pre-wrap; }

/* Clients — the merged customer file, equipment list and due-date view */
.due-filter { display: flex; gap: 0.6rem; flex-wrap: wrap; margin-bottom: 1.1rem; }
.due-chip {
  display: flex;
  align-items: baseline;
  gap: 0.45rem;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.45rem 1rem;
  cursor: pointer;
  font-size: 0.85rem;
  color: var(--muted);
  min-height: 2.5rem;
}
.due-chip:hover { border-color: var(--accent); }
.due-chip-n { font-weight: 700; font-size: 1.05rem; color: var(--ink); font-variant-numeric: tabular-nums; }
.due-chip.overdue .due-chip-n { color: var(--overdue); }
.due-chip.due_soon .due-chip-n { color: var(--due-soon); }
.due-chip.active { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); color: var(--ink); }

.client-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1rem 1.25rem;
  margin-bottom: 1rem;
}
.client-card-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; }
.client-card-id { min-width: 0; }
.client-card-actions { display: flex; gap: 0.75rem; flex-shrink: 0; }
.client-name { font-weight: 700; font-size: 1.05rem; }
.client-deficiency-summary { margin-top: 0.4rem; display: flex; flex-wrap: wrap; gap: 0.4rem; align-items: center; }
.client-chip {
  display: inline-block;
  padding: 0.15rem 0.6rem;
  border-radius: 10px;
  font-size: 0.78rem;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--muted);
  white-space: nowrap;
}
.client-chip.warn { color: var(--overdue); border-color: var(--overdue); }
.equip-row-actions { white-space: nowrap; }
.equipment-table { width: 100%; border-collapse: collapse; margin-top: 0.75rem; font-size: 0.85rem; }
.equipment-table th {
  text-align: left;
  color: var(--muted);
  font-weight: 600;
  padding: 0.3rem 0.5rem;
  border-bottom: 1px solid var(--border);
}
.equipment-table td { padding: 0.4rem 0.5rem; border-bottom: 1px solid #f0efec; }
.due-badge {
  display: inline-block;
  padding: 0.1rem 0.5rem;
  border-radius: 10px;
  font-size: 0.78rem;
  color: #fff;
}
.due-badge.overdue { background: var(--overdue); }
.due-badge.due_soon { background: var(--due-soon); }
.due-badge.upcoming { background: var(--upcoming); }
.equip-type-tag { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.03em; }
.issue-detail-row td { background: var(--bg); padding: 0.6rem 0.75rem; }
.issue-detail-item { padding: 0.25rem 0; font-size: 0.85rem; }
.issue-detail-item .status-badge { margin-right: 0.5rem; }
.issue-detail-desc { font-weight: 500; }

/* Invoices */
.invoice-row {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.75rem 1rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 0.6rem;
}
.invoice-row-main { flex: 1; }
.invoice-row-client { font-weight: 600; }
.invoice-row-total { font-weight: 600; }

/* Modal */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.4);
  display: flex; align-items: center; justify-content: center;
  z-index: 50;
}
.modal {
  background: #fff;
  border-radius: 10px;
  padding: 1.5rem;
  width: 560px;
  max-width: 94vw;
  max-height: 88vh;
  overflow: auto;
}
.modal.modal-wide { width: 720px; }
.modal h2 { margin-top: 0; }
.form-row { display: flex; flex-direction: column; gap: 0.3rem; margin-bottom: 0.85rem; }
.form-row label { font-size: 0.85rem; color: var(--muted); }
.form-row input, .form-row select, .form-row textarea {
  padding: 0.5rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.95rem;
  font-family: inherit;
}
.form-row input,
.form-row select {
  min-height: 2.75rem;
}
.form-row-inline { display: flex; gap: 0.6rem; }
.form-row-inline .form-row { flex: 1; }
.modal-actions { display: flex; justify-content: flex-end; gap: 0.6rem; margin-top: 1rem; }
.line-item-row { display: flex; gap: 0.5rem; align-items: center; margin-bottom: 0.5rem; }
.line-item-row .li-desc { flex: 1 1 auto; min-width: 0; }
.line-item-row .li-qty { flex: 0 0 56px; width: 56px; min-width: 0; }
.line-item-row .li-price { flex: 0 0 80px; width: 80px; min-width: 0; }
.line-item-row .li-remove { flex: 0 0 auto; }
.deficiency-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  border: 1px dashed var(--accent);
  color: var(--accent);
  border-radius: 14px;
  padding: 0.2rem 0.6rem;
  font-size: 0.8rem;
  cursor: pointer;
  margin: 0.2rem 0.3rem 0.2rem 0;
  background: #fff;
}
.invoice-total { text-align: right; font-weight: 700; margin-top: 0.5rem; }

/* Print */
.print-invoice { padding: 2rem; }
.print-invoice h1 { color: var(--accent); }
.print-table { width: 100%; border-collapse: collapse; margin-top: 1.5rem; }
.print-table th, .print-table td { text-align: left; padding: 0.5rem; border-bottom: 1px solid #ddd; }
.print-total { text-align: right; font-size: 1.1rem; font-weight: 700; margin-top: 1rem; }

@media print {
  #gate, .topbar, main, .modal-backdrop { display: none !important; }
  .print-invoice { display: block !important; }
  .pricing-research-header { display: none !important; }
}

/* Pricing research document — a full-page read, not a modal */
.pricing-research-backdrop {
  position: fixed;
  inset: 0;
  background: var(--bg);
  z-index: 70;
  overflow-y: auto;
}
.pricing-research-doc {
  max-width: 760px;
  margin: 0 auto;
  padding: 2rem 1.5rem 4rem;
}
.pricing-research-header {
  position: sticky;
  top: 0;
  background: var(--bg);
  padding: 1rem 0;
  margin-bottom: 1rem;
  display: flex;
  justify-content: space-between;
  gap: 0.6rem;
  border-bottom: 1px solid var(--border);
}
.pricing-research-content h1 { margin-top: 0; }
.pricing-research-content h2 {
  margin-top: 2rem;
  padding-bottom: 0.4rem;
  border-bottom: 1px solid var(--border);
}
.pricing-research-intro { font-size: 1rem; line-height: 1.6; }
.research-service-block {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1.1rem 1.25rem;
  margin-bottom: 1rem;
}
.research-service-title { display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap; margin-bottom: 0.3rem; }
.research-service-title strong { font-size: 1.05rem; }
.research-service-range { font-size: 0.95rem; margin-bottom: 0.4rem; }
.research-service-note { font-size: 0.9rem; margin-bottom: 0.5rem; }
.research-source-link { display: block; font-size: 0.88rem; margin-bottom: 0.2rem; }
.research-legend { display: flex; gap: 1rem; flex-wrap: wrap; margin: 0.75rem 0 1.5rem; font-size: 0.85rem; }
.research-legend-item { display: flex; align-items: center; gap: 0.4rem; }

@media (max-width: 800px) {
}

/* Role / identity */
.whoami {
  font-size: 0.85rem;
  color: var(--muted);
  padding: 0.3rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  flex-shrink: 0;
  white-space: nowrap;
}

/* Deficiency select + bulk toolbar */
.deficiency-select { flex-shrink: 0; width: 16px; height: 16px; cursor: pointer; }
.bulk-toolbar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.6rem 0.9rem;
  margin-bottom: 0.75rem;
  font-size: 0.88rem;
}
#bulk-count { color: var(--muted); }

/* Pricing */
.pricing-subtitle { margin-top: -0.5rem; margin-bottom: 1rem; font-size: 0.85rem; }
.pricing-row {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.75rem 1rem;
  display: flex;
  align-items: center;
  gap: 1.25rem;
  flex-wrap: wrap;
  margin-bottom: 0.6rem;
}
.pricing-row-main { flex: 1 1 220px; min-width: 180px; }
.pricing-row-label { font-weight: 600; }
.pricing-row-unit { font-size: 0.8rem; }
.pricing-row-your { display: flex; flex-direction: column; gap: 0.2rem; flex: 0 0 110px; }
.pricing-mini-label { font-size: 0.72rem; color: var(--muted); }
.pricing-your-price {
  padding: 0.4rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.9rem;
  width: 100%;
}
.pricing-row-benchmark { flex: 0 0 210px; }
.pricing-benchmark-range { font-size: 0.85rem; }
.pricing-benchmark-delta {
  display: inline-block;
  margin-top: 0.25rem;
  padding: 0.12rem 0.6rem;
  border-radius: 10px;
  font-size: 0.75rem;
  color: #fff;
  white-space: nowrap;
}
.pricing-benchmark-delta.below { background: var(--due-soon); }
.pricing-benchmark-delta.above { background: var(--due-soon); }
.pricing-benchmark-delta.within { background: var(--upcoming); }
.pricing-benchmark-delta.unknown { background: var(--muted); }
.pricing-row-actions { display: flex; flex-direction: column; align-items: flex-end; gap: 0.25rem; flex: 0 0 150px; }

.estimate-builder {
  margin-top: 2rem;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1.25rem;
}
.estimate-builder .form-row-inline { align-items: center; }
.estimate-builder .form-row-inline select {
  flex: 1;
  padding: 0.5rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.9rem;
}
.pricing-methodology-footer {
  margin-top: 1.25rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 0.85rem;
}
.methodology-source-list { padding-left: 1.1rem; margin: 0.4rem 0 1rem; }
.methodology-source-item { margin-bottom: 0.5rem; }
.methodology-confidence {
  display: inline-block;
  margin-left: 0.4rem;
  padding: 0.05rem 0.5rem;
  border-radius: 8px;
  font-size: 0.72rem;
  color: #fff;
}
.methodology-confidence.solid { background: var(--upcoming); }
.methodology-confidence.reasonable { background: var(--due-soon); }
.methodology-confidence.low { background: var(--overdue); }

/* Messages */
.messages-thread {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1rem;
  min-height: 320px;
  max-height: 55vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}
.message-bubble {
  max-width: 70%;
  padding: 0.5rem 0.8rem;
  border-radius: 10px;
  font-size: 0.9rem;
  white-space: pre-wrap;
}
.message-bubble.mine {
  align-self: flex-end;
  background: var(--accent);
  color: #fff;
}
.message-bubble.theirs {
  align-self: flex-start;
  background: var(--bg);
  border: 1px solid var(--border);
}
.message-meta { font-size: 0.72rem; opacity: 0.75; margin-bottom: 0.2rem; }
.messages-compose {
  display: flex;
  gap: 0.6rem;
  margin-top: 0.75rem;
}
.messages-compose textarea {
  flex: 1;
  padding: 0.5rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-family: inherit;
  font-size: 0.9rem;
  resize: vertical;
}
#messages-worker-select {
  padding: 0.45rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.88rem;
  min-height: 2.75rem;
}

/* ==========================================================================
   v7 — field capture, quote CRM, automation, insights
   ========================================================================== */

:root {
  --chart-blue: #2f6fb5;
  --chart-orange: #c2691a;
  --card: #ffffff;
  --grid: #eceae7;
}

.required-star { color: var(--accent); font-weight: 700; }
.field-help { font-size: 0.78rem; margin-top: 0.2rem; }
.checkbox-inline { display: flex; align-items: center; gap: 0.4rem; font-weight: normal; }

/* ---------- sub-navigation (Settings) ---------- */
.subtabs { display: flex; gap: 0.25rem; flex-wrap: wrap; }
.subtab-btn {
  padding: 0.4rem 0.8rem;
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 6px;
  font-size: 0.85rem;
  cursor: pointer;
  color: var(--ink);
  min-height: 2.75rem;
}
.subtab-btn.active { background: var(--ink); color: #fff; border-color: var(--ink); }
.settings-panel { margin-top: 0.5rem; }

/* ---------- field capture ---------- */
.field-intro { margin-top: -0.5rem; margin-bottom: 1rem; font-size: 0.88rem; max-width: 62ch; }
.field-capture-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1.25rem;
  max-width: 640px;
}
.field-photo-label { display: block; font-size: 0.85rem; font-weight: 600; margin-bottom: 0.35rem; }
.photo-dropzone {
  border: 1px dashed var(--border);
  border-radius: 8px;
  padding: 1rem;
  text-align: center;
  background: var(--bg);
}
.photo-hint { font-size: 0.78rem; margin: 0.5rem 0 0; }
.photo-previews { display: flex; flex-direction: column; gap: 0.6rem; margin-top: 0.75rem; }
.photo-preview {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.6rem;
  background: #fff;
}
.photo-preview img { width: 84px; height: 84px; object-fit: cover; border-radius: 6px; flex-shrink: 0; }
.photo-preview-meta { flex: 1; font-size: 0.8rem; min-width: 0; }
.photo-preview-meta input {
  width: 100%;
  margin-top: 0.35rem;
  padding: 0.35rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: 5px;
  font-size: 0.82rem;
}
.auto-field-row { background: var(--bg); border-radius: 6px; padding: 0.5rem 0.6rem; }
.auto-chip {
  font-size: 0.66rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: var(--chart-blue);
  color: #fff;
  border-radius: 4px;
  padding: 0.1rem 0.32rem;
  margin-left: 0.3rem;
  vertical-align: middle;
}
.auto-field-value { font-size: 0.85rem; }
.field-recent { margin-top: 1.5rem; max-width: 640px; }
.field-recent-title { font-size: 0.95rem; margin-bottom: 0.5rem; }
.field-recent-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.6rem 0.8rem;
  margin-bottom: 0.5rem;
  font-size: 0.88rem;
  cursor: pointer;
}
.field-recent-row:hover { border-color: var(--accent); }
.field-recent-desc { font-weight: 600; }

/* field report shown inside a deficiency */
.field-report-block {
  border-top: 1px solid var(--border);
  margin-top: 1rem;
  padding-top: 0.75rem;
}
.field-photos { display: flex; gap: 0.6rem; flex-wrap: wrap; margin: 0.6rem 0; }
.field-photo { margin: 0; width: 130px; }
.field-photo img {
  width: 130px;
  height: 100px;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid var(--border);
  cursor: zoom-in;
  display: block;
}
.field-photo figcaption { font-size: 0.72rem; margin-top: 0.25rem; line-height: 1.3; }
.field-values { display: grid; grid-template-columns: 1fr 1fr; gap: 0.3rem 1rem; font-size: 0.85rem; }
.field-value-row { display: flex; gap: 0.4rem; justify-content: space-between; border-bottom: 1px solid #f2f1ee; padding: 0.2rem 0; }
.field-value-label { flex-shrink: 0; }
.field-value-text { text-align: right; font-weight: 500; word-break: break-word; }
.photo-lightbox {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.85);
  z-index: 200;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  cursor: zoom-out;
  padding: 2rem;
}
.photo-lightbox img { max-width: 92vw; max-height: 80vh; border-radius: 8px; }
.photo-lightbox-meta { color: #fff; font-size: 0.85rem; }

/* ---------- form builder ---------- */
.form-builder-actions { display: flex; align-items: center; gap: 0.75rem; margin-top: 0.75rem; }

/* ---------- automations ---------- */
.provider-note {
  background: #fff7ed;
  border: 1px solid #f3d9b5;
  border-radius: 8px;
  padding: 0.9rem 1.1rem;
  margin-bottom: 1rem;
  font-size: 0.87rem;
  line-height: 1.5;
  max-width: 78ch;
}
.provider-note.connected { background: #eef7ee; border-color: #cbe3cb; }
.provider-note p { margin: 0.4rem 0 0; }
.automation-row {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1rem 1.15rem;
  margin-bottom: 0.9rem;
}
.automation-head { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; }
.automation-toggle { display: flex; align-items: center; gap: 0.5rem; cursor: pointer; }
.automation-label { font-weight: 600; }
.automation-audience {
  font-size: 0.72rem;
  border-radius: 4px;
  padding: 0.14rem 0.42rem;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--muted);
  white-space: nowrap;
}
.automation-audience.customer { border-color: var(--chart-blue); color: var(--chart-blue); }
.automation-audience.technician { border-color: var(--chart-orange); color: var(--chart-orange); }
.automation-desc { font-size: 0.85rem; margin: 0.25rem 0 0.6rem; }
.automation-controls { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 0.6rem; margin-bottom: 0.5rem; }
.automation-row input[type="text"],
.automation-row input[type="number"],
.automation-row select,
.automation-row textarea {
  width: 100%;
  padding: 0.4rem 0.55rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-family: inherit;
  font-size: 0.88rem;
}
.automation-row textarea { resize: vertical; white-space: pre-wrap; }
.automation-footer { display: flex; align-items: center; gap: 0.75rem; flex-wrap: wrap; }
.automation-vars { font-size: 0.74rem; flex: 1; min-width: 200px; word-break: break-word; }

/* ---------- outbox ---------- */
.outbox-row {
  display: flex;
  gap: 1rem;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.8rem 1rem;
  margin-bottom: 0.6rem;
}
.outbox-main { flex: 1; min-width: 0; }
.outbox-to { font-size: 0.85rem; color: var(--muted); }
.outbox-subject { font-weight: 600; margin: 0.15rem 0; }
.outbox-body { font-size: 0.86rem; white-space: pre-wrap; line-height: 1.45; }
.outbox-note { font-size: 0.76rem; margin-top: 0.4rem; font-style: italic; }
.outbox-side { flex-shrink: 0; text-align: right; display: flex; flex-direction: column; align-items: flex-end; gap: 0.3rem; }
.outbox-status {
  font-size: 0.72rem;
  font-weight: 600;
  border-radius: 4px;
  padding: 0.16rem 0.45rem;
  color: #fff;
  white-space: nowrap;
}
.outbox-status.ready { background: var(--chart-orange); }
.outbox-status.queued { background: #6b7c8d; }
.outbox-status.sent { background: var(--upcoming); }
.outbox-status.cancelled { background: #a8a49e; }
.outbox-when { font-size: 0.75rem; }
.outbox-actions { display: flex; gap: 0.4rem; }

/* ---------- quotes ---------- */
.quotes-summary, .stat-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 0.75rem;
  margin-bottom: 1rem;
}
.stat-tile {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.85rem 1rem;
}
.stat-tile.accent { border-color: var(--chart-orange); box-shadow: inset 3px 0 0 var(--chart-orange); }
.stat-tile.warn { border-color: var(--due-soon); box-shadow: inset 3px 0 0 var(--due-soon); }
.stat-tile.danger { border-color: var(--overdue); box-shadow: inset 3px 0 0 var(--overdue); }
.stat-label { font-size: 0.76rem; color: var(--muted); line-height: 1.3; }
.stat-value { font-size: 1.6rem; font-weight: 650; margin: 0.15rem 0 0.1rem; letter-spacing: -0.01em; }
.stat-sub { font-size: 0.76rem; }

.unquoted-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  background: #fff7ed;
  border: 1px solid #f3d9b5;
  border-radius: 8px;
  padding: 0.75rem 1rem;
  margin-bottom: 1rem;
  font-size: 0.9rem;
}
.unquoted-list { max-height: 340px; overflow-y: auto; }
.unquoted-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.55rem 0;
  border-bottom: 1px solid #f0efec;
  font-size: 0.88rem;
}

.quote-row {
  display: flex;
  align-items: center;
  gap: 1rem;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.75rem 1rem;
  margin-bottom: 0.6rem;
}
.quote-row-main { flex: 1; min-width: 0; }
.quote-row-title { font-weight: 600; }
.quote-row-meta { font-size: 0.8rem; margin-top: 0.1rem; }
.quote-row-chase { display: flex; gap: 0.4rem; flex-wrap: wrap; margin-top: 0.35rem; }
.quote-row-chase span {
  font-size: 0.72rem;
  border-radius: 4px;
  padding: 0.12rem 0.4rem;
  border: 1px solid var(--border);
  color: var(--muted);
}
.chase-wait { border-color: var(--chart-orange) !important; color: var(--chart-orange) !important; }
.chase-wait.stale { background: var(--overdue); border-color: var(--overdue) !important; color: #fff !important; }
.chase-sent { border-color: var(--chart-blue) !important; color: var(--chart-blue) !important; }
.quote-row-total { font-weight: 650; white-space: nowrap; }
.quote-row-actions { display: flex; gap: 0.4rem; align-items: center; flex-shrink: 0; }
.quote-badge {
  font-size: 0.7rem;
  font-weight: 600;
  border-radius: 4px;
  padding: 0.16rem 0.45rem;
  color: #fff;
  white-space: nowrap;
  margin-left: 0.3rem;
}
.quote-badge.draft { background: #8a8783; }
.quote-badge.sent { background: var(--chart-orange); }
.quote-badge.approved { background: var(--upcoming); }
.quote-badge.declined { background: var(--overdue); }
.quote-badge.expired { background: #6b7c8d; }

.sev-badge {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  border-radius: 4px;
  padding: 0.14rem 0.4rem;
  color: #fff;
  margin-right: 0.3rem;
  white-space: nowrap;
}
.sev-badge.impairment { background: #7b1fa2; }
.sev-badge.critical { background: var(--overdue); }
.sev-badge.overdue { background: var(--overdue); }

.quote-table { width: 100%; border-collapse: collapse; font-size: 0.86rem; margin-top: 0.5rem; }
.quote-table th {
  text-align: left;
  padding: 0.4rem 0.5rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.74rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--muted);
}
.quote-table td { padding: 0.4rem 0.5rem; border-bottom: 1px solid #f2f1ee; }
.worker-table td:first-child { font-weight: 500; }
.cell-warn { color: var(--overdue); font-weight: 600; }

.quote-timeline { border-top: 1px solid var(--border); margin-top: 1rem; padding-top: 0.75rem; }
.timeline-item { display: flex; gap: 0.6rem; align-items: flex-start; padding: 0.35rem 0; font-size: 0.86rem; }
.timeline-dot {
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--muted); flex-shrink: 0; margin-top: 0.35rem;
}
.timeline-dot.created, .timeline-dot.queued { background: #8a8783; }
.timeline-dot.sent { background: var(--chart-blue); }
.timeline-dot.followup, .timeline-dot.ready { background: var(--chart-orange); }
.timeline-dot.approved { background: var(--upcoming); }
.timeline-dot.declined, .timeline-dot.expired { background: var(--overdue); }
.timeline-dot.invoiced { background: #5b6b7a; }
.timeline-time { font-size: 0.74rem; }

.quote-edit-row {
  display: grid;
  grid-template-columns: 1fr 110px 80px 100px 28px;
  gap: 0.4rem;
  margin-bottom: 0.4rem;
}
.quote-edit-row input, .quote-edit-row select {
  padding: 0.4rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.86rem;
  min-width: 0;
}

.estimate-reasoning {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.8rem 1rem;
  font-size: 0.86rem;
  margin: 0.75rem 0;
}
.estimate-reasoning ol { margin: 0.5rem 0; padding-left: 1.2rem; line-height: 1.5; }
.estimate-reasoning li { margin-bottom: 0.3rem; }
.estimate-similar { font-size: 0.85rem; margin-bottom: 0.75rem; }

/* ---------- parts catalog + cost basis ---------- */
.cost-settings-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 0.75rem; }
.cost-settings-grid input {
  width: 100%;
  padding: 0.45rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.9rem;
}
.part-row {
  display: grid;
  grid-template-columns: 130px 1fr 130px 90px 90px 28px;
  gap: 0.4rem;
  align-items: center;
  margin-bottom: 0.35rem;
}
.part-row input {
  padding: 0.35rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: 5px;
  font-size: 0.84rem;
  min-width: 0;
}
.part-row-header {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--muted);
  padding-bottom: 0.3rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 0.5rem;
}

/* ---------- insights ---------- */
.insight-section { margin-bottom: 1.75rem; }
.insight-section-title { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); margin: 0 0 0.6rem; }
.chart-grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(360px, 1fr)); gap: 1rem; margin-bottom: 1.75rem; }
.chart-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1rem 1.15rem;
}
.chart-head { display: flex; align-items: baseline; justify-content: space-between; gap: 0.75rem; margin-bottom: 0.75rem; flex-wrap: wrap; }
.chart-head h3 { margin: 0; font-size: 0.98rem; }
.chart-legend { display: flex; gap: 0.75rem; font-size: 0.78rem; color: var(--muted); }
.legend-item { display: flex; align-items: center; gap: 0.3rem; }
.legend-swatch { width: 10px; height: 10px; border-radius: 2px; display: inline-block; }
.chart-svg { width: 100%; height: auto; display: block; }
.chart-grid { stroke: var(--grid); stroke-width: 1; }
.chart-axis-text { font-size: 11px; fill: var(--muted); font-family: inherit; }
.chart-value-label { font-size: 11px; fill: var(--ink); font-family: inherit; font-weight: 600; }
.chart-table { margin-top: 0.75rem; font-size: 0.82rem; }
.chart-table summary { cursor: pointer; color: var(--muted); font-size: 0.8rem; }

.ranked-bars { display: flex; flex-direction: column; gap: 0.5rem; }
.ranked-row { display: grid; grid-template-columns: 130px 1fr auto; gap: 0.6rem; align-items: center; font-size: 0.85rem; }
.ranked-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ranked-track { background: var(--bg); border-radius: 4px; height: 18px; overflow: hidden; }
.ranked-fill { background: var(--chart-blue); height: 100%; border-radius: 0 4px 4px 0; min-width: 2px; }
.ranked-value { font-weight: 600; white-space: nowrap; }

.stale-list, .wip-list { display: flex; flex-direction: column; gap: 0.4rem; max-height: 340px; overflow-y: auto; }
.stale-row, .wip-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.5rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.85rem;
  cursor: pointer;
  background: #fff;
}
.stale-row:hover, .wip-row:hover { border-color: var(--accent); }
.stale-right { display: flex; align-items: center; gap: 0.6rem; flex-shrink: 0; }
.stale-days {
  font-weight: 700;
  color: var(--chart-orange);
  border: 1px solid var(--chart-orange);
  border-radius: 4px;
  padding: 0.1rem 0.35rem;
  font-size: 0.78rem;
}
.stale-days.stale { background: var(--overdue); border-color: var(--overdue); color: #fff; }
.stale-amount { font-weight: 600; white-space: nowrap; }
.wip-main { flex: 1; min-width: 0; }
.wip-side { display: flex; align-items: center; gap: 0.35rem; flex-shrink: 0; flex-wrap: wrap; justify-content: flex-end; }
.wip-amount { font-weight: 600; white-space: nowrap; font-size: 0.82rem; }

/* Wide tables scroll inside their own box rather than the page */
.insight-section table, .quote-table { display: table; }
.insight-section { overflow-x: auto; }

@media (max-width: 700px) {
  .field-capture-card { padding: 0.9rem; }
  .field-values { grid-template-columns: 1fr; }

  /* A job card is a desktop three-column row. On a phone that squeezed the
     description into ~150px — "Panel on / battery / backup, / AC power /
     fault." — one job per screenful with two thirds of the width empty.
     Stack it: the description gets the full width, the badges and the button
     sit under it. */
  .deficiency-row { flex-wrap: wrap; gap: 0.5rem; padding: 0.85rem; }
  .deficiency-row-main { flex: 1 0 100%; min-width: 0; }
  .deficiency-row-desc { font-size: 1rem; line-height: 1.35; }
  .deficiency-row-status { display: flex; flex-wrap: wrap; gap: 0.25rem; }
  .deficiency-row .link-btn { margin-left: auto; padding: 0.45rem 0.6rem; }

  .quote-row { flex-wrap: wrap; }
  .quote-row-actions { width: 100%; justify-content: flex-end; }
  .quote-edit-row { grid-template-columns: 1fr 1fr; }
  .part-row { grid-template-columns: 1fr 1fr; }
  .part-row-header { display: none; }
  .outbox-row { flex-direction: column; }
  .outbox-side { align-items: flex-start; text-align: left; }
  .ranked-row { grid-template-columns: 100px 1fr auto; }

  .client-card { padding: 0.9rem; }
  .client-card-header { flex-direction: column; }
  .client-card-actions {
    width: 100%;
    flex-wrap: wrap;
    gap: 0.4rem;
  }
  .client-card-actions .link-btn,
  .equip-row-actions .link-btn {
    min-height: 2.5rem;
  }
  .equipment-table {
    display: block;
    width: 100%;
    margin-top: 0.9rem;
  }
  .equipment-table thead { display: none; }
  .equipment-table tbody { display: block; }
  .equipment-table tr:not(.issue-detail-row) {
    display: block;
    padding: 0.75rem 0;
    border-top: 1px solid var(--border);
  }
  .equipment-table tr:not(.issue-detail-row):first-child {
    padding-top: 0;
    border-top: none;
  }
  .equipment-table tr:not(.issue-detail-row) td {
    display: block;
    padding: 0.2rem 0;
    border-bottom: none;
  }
  .equipment-table tr:not(.issue-detail-row) td::before {
    display: block;
    margin-bottom: 0.1rem;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--muted);
  }
  .equipment-table tr:not(.issue-detail-row) td:nth-child(1)::before { content: "Equipment"; }
  .equipment-table tr:not(.issue-detail-row) td:nth-child(2)::before { content: "Inspection interval"; }
  .equipment-table tr:not(.issue-detail-row) td:nth-child(3)::before { content: "Last service"; }
  .equipment-table tr:not(.issue-detail-row) td:nth-child(4)::before { content: "Next due"; }
  .equipment-table tr:not(.issue-detail-row) td:nth-child(5)::before { content: "Unbilled issues"; }
  .equipment-table tr:not(.issue-detail-row) td:nth-child(6)::before { content: "Actions"; }
  .equip-row-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    white-space: normal;
  }
  .issue-detail-row td {
    display: block;
    border-top: 1px dashed var(--border);
  }
}

/* Paired fields sit side by side on a desktop, but a technician filling this
   in one-handed on a phone gets two ~150px controls. Stack them instead. */
@media (max-width: 560px) {
  .form-row-inline { flex-direction: column; gap: 0.4rem; }
  .modal { padding: 1.1rem; }
  .panel-header { flex-wrap: wrap; gap: 0.5rem; }
  .panel-header-actions { flex-wrap: wrap; }
  .messages-compose { flex-direction: column; }
  .messages-compose button,
  #messages-worker-select { width: 100%; }
  .modal-actions { flex-direction: column-reverse; }
  .modal-actions button { width: 100%; }
}

/* ==========================================================================
   v8 — customers, drill-downs, grouped outbox, template chips, email setup
   ========================================================================== */

.section-intro { margin-top: -0.5rem; margin-bottom: 1rem; font-size: 0.88rem; }
.scroll-x { overflow-x: auto; }
#customer-search {
  padding: 0.45rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.88rem;
  min-width: 180px;
}

/* ---------- customers ---------- */
.cust-detail-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; margin-bottom: 1rem; }
.cust-stat-row { grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); }
.cust-sec { margin: 1.6rem 0 0.4rem; font-size: 0.95rem; }
.cust-notes { background: var(--bg); border-radius: 6px; padding: 0.7rem 0.9rem; font-size: 0.88rem; }
.cust-notes p { margin: 0.3rem 0 0; white-space: pre-wrap; }

/* ---------- drill-downs ---------- */
.stat-tile.drillable { cursor: pointer; transition: border-color 0.12s, transform 0.12s; }
.stat-tile.drillable:hover { border-color: var(--accent); transform: translateY(-1px); }
.stat-tile.drillable:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.drill-hint {
  font-size: 0.7rem;
  color: var(--accent);
  margin-top: 0.35rem;
  opacity: 0;
  transition: opacity 0.12s;
}
.stat-tile.drillable:hover .drill-hint,
.stat-tile.drillable:focus-visible .drill-hint { opacity: 1; }
.drill-count { font-size: 0.8rem; margin-bottom: 0.3rem; }
.drill-table tfoot td { border-top: 2px solid var(--border); border-bottom: none; }
tr.drill-clickable { cursor: pointer; }
tr.drill-clickable:hover td { background: var(--bg); }
.cell-drill { cursor: pointer; text-decoration: underline dotted var(--border); text-underline-offset: 3px; }
.cell-drill:hover { color: var(--accent); text-decoration-color: var(--accent); }
.ranked-row.drillable-row { cursor: pointer; }
.ranked-row.drillable-row:hover .ranked-fill { background: var(--accent); }
.ranked-row.drillable-row:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.chart-hit { cursor: pointer; }
.chart-hit:hover { fill: rgba(0,0,0,0.035); }

/* ---------- grouped outbox ---------- */
.crumbs { display: flex; align-items: center; gap: 0.4rem; flex-wrap: wrap; margin-bottom: 0.9rem; font-size: 0.85rem; }
.crumb-btn {
  background: none; border: none; padding: 0;
  color: var(--accent); cursor: pointer; font-size: 0.85rem; font-family: inherit;
}
.crumb-btn:hover { text-decoration: underline; }
.crumb-sep { color: var(--muted); }
.crumb-current { font-weight: 600; }
.ob-group {
  display: flex;
  align-items: center;
  gap: 1rem;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.8rem 1rem;
  margin-bottom: 0.6rem;
  cursor: pointer;
}
.ob-group:hover { border-color: var(--accent); }
.ob-group-main { flex: 1 1 170px; min-width: 0; }
.ob-group-name { font-weight: 640; }
.ob-group-sub { font-size: 0.8rem; margin-top: 0.1rem; }
.ob-progress { flex: 1 1 160px; min-width: 130px; }
.ob-bar { display: flex; height: 8px; border-radius: 4px; overflow: hidden; background: var(--bg); gap: 2px; }
.ob-seg.sent { background: var(--upcoming); }
.ob-seg.ready { background: var(--chart-orange); }
.ob-seg.queued { background: #8f9aa6; }
.ob-seg.cancelled { background: #cfcbc5; }
.ob-bar-legend { font-size: 0.72rem; margin-top: 0.25rem; }
.ob-next { font-size: 0.8rem; flex: 0 0 auto; white-space: nowrap; }
.ob-job-head {
  display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem;
  background: var(--bg); border: 1px solid var(--border); border-radius: 8px;
  padding: 0.75rem 1rem; margin-bottom: 0.8rem;
}
.ob-rule { font-weight: 600; color: var(--ink); }

/* ---------- automations: collapsed rows + placeholder chips ---------- */
.automation-head { cursor: pointer; }
.automation-summary { font-size: 0.8rem; margin-top: 0.2rem; }
.automation-row.collapsed .automation-desc,
.automation-row.collapsed .automation-controls,
.automation-row.collapsed .automation-subject-row,
.automation-row.collapsed .chip-editor,
.automation-row.collapsed .ph-picker,
.automation-row.collapsed .automation-footer,
.automation-row.collapsed .form-row { display: none; }
.automation-row.collapsed { padding: 0.7rem 1.15rem; }
.automation-row.collapsed .automation-summary { display: block; }
.automation-head::after {
  content: "▾";
  color: var(--muted);
  font-size: 0.8rem;
  margin-left: 0.5rem;
  transition: transform 0.15s;
}
.automation-row.collapsed .automation-head::after { transform: rotate(-90deg); display: inline-block; }

.chip-editor {
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.6rem 0.7rem;
  min-height: 8rem;
  font-family: inherit;
  font-size: 0.88rem;
  line-height: 1.75;
  white-space: pre-wrap;
  background: #fff;
  overflow-wrap: anywhere;
}
.chip-editor:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.ph-chip {
  display: inline-block;
  background: #e7eef7;
  border: 1px solid #c3d4e8;
  color: #23527c;
  border-radius: 4px;
  padding: 0.02em 0.4em;
  margin: 0 0.05em;
  font-size: 0.84em;
  white-space: nowrap;
  user-select: all;
}
.ph-picker { display: flex; flex-wrap: wrap; gap: 0.35rem; align-items: center; margin-top: 0.5rem; }
.ph-picker-label { font-size: 0.76rem; }
.ph-insert {
  background: #f1f5fa;
  border: 1px dashed #b9cbe0;
  color: #23527c;
  border-radius: 4px;
  padding: 0.15rem 0.45rem;
  font-size: 0.76rem;
  cursor: pointer;
  font-family: inherit;
}
.ph-insert:hover { background: #e2ebf5; border-style: solid; }

/* ---------- form builder drag ---------- */

/* ---------- email delivery ---------- */
.lock-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1.3rem 1.4rem;
  max-width: 26rem;
}
.lock-card h3 { margin-top: 0; }
.lock-card input {
  width: 100%;
  padding: 0.5rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.95rem;
}
#email-config input { width: 100%; padding: 0.45rem 0.6rem; border: 1px solid var(--border); border-radius: 6px; font-size: 0.9rem; }
.delivery-ok { color: var(--upcoming); font-size: 0.88rem; margin-top: 0.5rem; }
.delivery-fail { color: var(--overdue); font-size: 0.88rem; margin-top: 0.5rem; }

.add-service-row { align-items: center; gap: 0.5rem; margin-top: 0.6rem; flex-wrap: wrap; }
.add-service-row select {
  flex: 1 1 200px;
  padding: 0.4rem 0.55rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.86rem;
  min-width: 0;
}
.complete-hint { font-size: 0.83rem; background: var(--bg); border-radius: 6px; padding: 0.6rem 0.75rem; }

@media (max-width: 700px) {
  .cust-stat { align-items: flex-start; min-width: 0; }
  .ob-group { flex-wrap: wrap; }
  .ob-progress, .ob-next { width: 100%; }
  .cust-detail-head { flex-direction: column; }
}

/* Pricing research — confidence chips and layout for the rewritten document */
.methodology-confidence {
  font-size: 0.68rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em;
  border-radius: 4px; padding: 0.12rem 0.42rem; color: #fff; white-space: nowrap;
}
.methodology-confidence.solid { background: #2e7d32; }
.methodology-confidence.reasonable { background: #8a681f; }
.methodology-confidence.none { background: #6b7077; }
.research-sources-label { font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.08em; margin: 0.6rem 0 0.25rem; }
.research-limits { font-size: 0.9rem; color: var(--muted); line-height: 1.6; }
.research-limits li { margin-bottom: 0.35rem; }

/* ==========================================================================
   v9 — one Work page, technician-first mobile
   ========================================================================== */

.worktab-btn {
  padding: 0.45rem 0.9rem;
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 6px;
  font-size: 0.88rem;
  cursor: pointer;
  color: var(--ink);
  font-family: inherit;
}
.worktab-btn.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.work-panel { margin-top: 0.25rem; }

/* Pipeline strip — the left-to-right story of a job */
.pipeline-strip {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.9rem 1.1rem;
  margin-bottom: 1.1rem;
}
.pipeline-intro { font-size: 0.84rem; color: var(--muted); margin-bottom: 0.7rem; }
.pipeline-stages { display: flex; align-items: stretch; gap: 0.5rem; flex-wrap: wrap; }
.pipeline-arrow { display: flex; align-items: center; color: var(--muted); font-size: 1.1rem; }
.pipeline-stage {
  flex: 1 1 130px;
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  text-align: left;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.6rem 0.75rem;
  cursor: pointer;
  font-family: inherit;
  color: var(--ink);
}
.pipeline-stage:hover { border-color: var(--accent); }
.pipeline-stage.warn { background: #fff7ed; border-color: #f3d9b5; }
.pipeline-n { font-size: 1.5rem; font-weight: 680; line-height: 1.1; font-variant-numeric: tabular-nums; }
.pipeline-label { font-size: 0.76rem; color: var(--muted); }
.pipeline-action { font-size: 0.75rem; color: var(--accent); margin-top: 0.15rem; }
.pipeline-stage.warn .pipeline-n { color: var(--accent); }

/* The three stages of one job, shown inside every detail view */
.job-trail {
  display: flex; align-items: center; gap: 0.4rem; flex-wrap: wrap;
  margin: -0.4rem 0 0.9rem; font-size: 0.78rem;
}
.trail-step {
  border: 1px solid var(--border); border-radius: 4px; padding: 0.15rem 0.45rem;
  color: var(--muted); background: var(--bg); white-space: nowrap;
}
.trail-step.done { border-color: var(--upcoming); color: var(--upcoming); background: #f2f8f2; }
/* the stage you are looking at right now - the only one that isn't a link */
.trail-step.active { font-weight: 650; box-shadow: inset 0 0 0 1px currentColor; }
.trail-step[role="button"] { cursor: pointer; }
.trail-step[role="button"]:hover { border-color: var(--accent); color: var(--accent); }
.trail-sep { color: var(--border); }

/* ---------- technician view: fewer things, bigger targets ---------- */
body.role-tech .tabs { gap: 0.4rem; }
body.role-tech .tab-btn { font-size: 0.95rem; padding: 0.5rem 0.9rem; }
body.role-tech .field-capture-card { max-width: 720px; }
/* The tab and the panel already say "My Jobs"; the sub-panel's own
   "Deficiencies" heading underneath is the same screen named twice. */
body.role-tech #work-deficiencies > .panel-header > h2 { display: none; }

/* The owner has 11 tabs. Below roughly 1700px they no longer fit beside the
   brand and the sign-out cluster, and the two on the end (Settings, Messages)
   were being clipped out of sight with nothing on screen to say so. Give the
   tabs their own full-width row instead — the same shape the phone layout
   below already uses, so it can never clip again at any width or tab count. */
@media (max-width: 1700px) {
  .topbar { flex-wrap: wrap; row-gap: 0.6rem; }
  .tabs { order: 3; width: 100%; }
}

@media (max-width: 1100px) {
  body:not(.role-tech) .topbar {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, auto));
    align-items: center;
    gap: 0.75rem;
  }
  body:not(.role-tech) .brand,
  body:not(.role-tech) .tabs {
    grid-column: 1 / -1;
  }
  body:not(.role-tech) .tabs {
    order: 0;
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 0.45rem;
    overflow: visible;
  }
  body:not(.role-tech) .tab-btn {
    width: 100%;
    min-width: 0;
    padding: 0.6rem 0.45rem;
    text-align: center;
  }
  body:not(.role-tech) .whoami { justify-self: start; }
  body:not(.role-tech) .notif-wrap { justify-self: center; }
  body:not(.role-tech) #logout-btn { justify-self: end; }
}

@media (max-width: 700px) {
  .topbar { flex-wrap: wrap; gap: 0.6rem; padding: 0.7rem 0.9rem; }
  .brand { font-size: 1rem; }
  .tabs { order: 3; width: 100%; }
  .pipeline-stages { flex-direction: column; }
  .pipeline-arrow { display: none; }
  .worktab-btn { flex: 1; text-align: center; }
  #work-subtabs { width: 100%; }

  /* On a phone a technician gets thumb-sized targets and no horizontal scroll */
  body.role-tech .tab-btn {
    flex: 1;
    min-width: 0;
    text-align: center;
    padding: 0.65rem 0.4rem;
    font-size: 0.9rem;
  }
  body.role-tech .tabs { overflow-x: visible; }
  body.role-tech .field-capture-card { padding: 0.85rem; }
  body.role-tech #field-photo-btn { width: 100%; padding: 0.85rem; font-size: 1rem; }
  body.role-tech #field-submit { width: 100%; padding: 0.85rem; font-size: 1rem; }
  body.role-tech .modal-actions { flex-direction: column-reverse; }
  body.role-tech .modal-actions button { width: 100%; }

  body:not(.role-tech) .topbar {
    grid-template-columns: repeat(2, minmax(0, auto));
    column-gap: 0.6rem;
  }
  body:not(.role-tech) .tabs { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  body:not(.role-tech) .whoami {
    min-height: 2.5rem;
    display: inline-flex;
    align-items: center;
  }
  body:not(.role-tech) .bell-btn,
  body:not(.role-tech) #logout-btn,
  body:not(.role-tech) .subtab-btn,
  body:not(.role-tech) .worktab-btn {
    min-height: 2.75rem;
  }
}

/* Demo clock — impossible to confuse a simulated date with today */
.demo-clock-banner {
  background: #7b1fa2;
  color: #fff;
  font-size: 0.76rem;
  font-weight: 600;
  padding: 0.28rem 0.6rem;
  border-radius: 5px;
  white-space: nowrap;
  flex-shrink: 0;
}
.demo-clock-state {
  display: flex; gap: 1.5rem; flex-wrap: wrap;
  background: var(--bg); border: 1px solid var(--border); border-radius: 8px;
  padding: 0.75rem 1rem; margin: 0.9rem 0;
}
.demo-clock-state > div { display: flex; flex-direction: column; gap: 0.1rem; font-size: 0.9rem; }
.demo-clock-state span { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.04em; }
.clock-shifted { color: #7b1fa2; }
.demo-clock-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; align-items: center; margin-bottom: 0.9rem; }
.demo-clock-run { display: flex; gap: 0.75rem; align-items: center; flex-wrap: wrap; }
.demo-clock-steps { margin-top: 1rem; padding-left: 1.2rem; font-size: 0.86rem; line-height: 1.6; }
.demo-clock-steps li { margin-bottom: 0.25rem; }

/* ---------- technician on a phone: a real bottom tab bar ----------
   Three thumb-sized destinations pinned to the bottom, which is where a
   technician's hand already is. Owners on desktop keep the top nav. */
@media (max-width: 700px) {
  body.role-tech .topbar {
    flex-wrap: nowrap;
    gap: 0.5rem;
    padding: 0.6rem 0.85rem;
    align-items: center;
  }
  body.role-tech .brand {
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 0.95rem;
  }
  body.role-tech .brand .muted { display: none; }
  body.role-tech .whoami { display: none; }
  body.role-tech #logout-btn { font-size: 0.8rem; }

  body.role-tech .tabs {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 60;
    width: auto;
    order: 0;
    background: #fff;
    border-top: 1px solid var(--border);
    box-shadow: 0 -2px 10px rgba(0,0,0,0.06);
    padding: 0.3rem 0.4rem calc(0.3rem + env(safe-area-inset-bottom));
    gap: 0.2rem;
    overflow: visible;
  }
  body.role-tech .tabs .tab-btn {
    flex: 1 1 0;
    min-width: 0;
    border: none;
    background: none;
    border-radius: 8px;
    padding: 0.6rem 0.2rem;
    font-size: 0.78rem;
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--muted);
  }
  body.role-tech .tabs .tab-btn.active {
    background: #fdf1ee;
    color: var(--accent);
    font-weight: 650;
  }
  body.role-tech main { padding-bottom: 4.5rem; }
  body.role-tech .notif-panel { right: -60px; }
}

/* Whether a part number the technician typed exists in the catalog. Answered
   on the phone, at the point of typing, rather than days later in the office. */
.part-check:empty { display: none; }
.part-check.part-ok { color: var(--upcoming); }
.part-check.part-miss { color: var(--overdue); }

/* Settings → Field Report: the required-answer checklist that replaced the
   53-control form builder */
.required-list { display: flex; flex-direction: column; gap: 0.4rem; margin: 1rem 0; }
.required-row {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.7rem 1rem;
  cursor: pointer;
}
.required-row:hover { border-color: var(--accent); }
.required-row:has(.required-check:disabled) { cursor: default; opacity: 0.72; }
.required-row:has(.required-check:disabled):hover { border-color: var(--border); }
.required-check { flex-shrink: 0; width: 1.05rem; height: 1.05rem; }
.required-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.required-label { font-weight: 600; }
.required-help { font-size: 0.8rem; }
.required-state { font-size: 0.8rem; flex-shrink: 0; white-space: nowrap; }

/* Insights: the headline numbers stay, the detail sits behind one button */
.insights-more-btn { margin: 1.5rem 0; }

/* A request that failed has to say so. Sits above modals so it can explain a
   Save that didn't take without discarding what was typed. */
.request-problem {
  position: fixed;
  left: 50%;
  bottom: 1.5rem;
  transform: translateX(-50%);
  z-index: 200;
  max-width: min(34rem, calc(100vw - 2rem));
  background: var(--accent);
  color: #fff;
  padding: 0.85rem 1.25rem;
  border-radius: 8px;
  font-size: 0.9rem;
  line-height: 1.4;
  box-shadow: 0 10px 30px rgba(0,0,0,0.25);
}

/* An empty parts catalog is the silent cause of generic estimates — say so. */
.parts-empty-warning {
  border-left: 3px solid var(--due-soon);
  background: #fdf8ec;
  padding: 0.85rem 1.1rem;
  margin-bottom: 1rem;
  border-radius: 0 6px 6px 0;
  font-size: 0.88rem;
  line-height: 1.45;
}

/* A refused field report has to be impossible to miss — a technician holding a
   phone in a boiler room gets one chance to understand why Submit did nothing. */
#field-error:not(.hidden) {
  display: block;
  background: var(--accent);
  color: #fff;
  padding: 0.75rem 1rem;
  border-radius: 8px;
  font-size: 0.95rem;
  font-weight: 600;
  margin: 0.75rem 0;
}
.field-missing input,
.field-missing select,
.field-missing textarea,
.photo-dropzone.field-missing {
  border-color: var(--accent) !important;
  box-shadow: 0 0 0 2px rgba(192, 57, 43, 0.18);
}
