:root {
  --accent: #0e7490;
  --accent-ink: #ffffff;
  --bg: #f4f6f8;
  --surface: #ffffff;
  --text: #15202b;
  --muted: #5b6875;
  --line: #e1e6eb;
  --danger: #c62828;
  --folder: #f2b33d;
  --report: #0e7490;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --accent: #22a3c4;
    --bg: #0f1418;
    --surface: #182027;
    --text: #e8edf1;
    --muted: #93a1ad;
    --line: #26313a;
    --danger: #ef6b6b;
    --report: #5cc4dd;
  }
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html, body { margin: 0; }

/* App shell: header and zone bar stay put, only <main> scrolls. The page itself never
   scrolls, so phone browsers can't drag the bars around when the toolbar hides or bounces. */
html, body { height: 100%; overflow: hidden; }

body {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

button { font: inherit; color: inherit; }

.bar {
  flex: none;
  z-index: 1;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: calc(env(safe-area-inset-top) + 10px) 16px 10px;
  background: var(--accent);
  color: var(--accent-ink);
  min-height: 60px;
}

.bar-text { min-width: 0; }

.bar h1 {
  margin: 0;
  font-size: 1.3rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.crumbs {
  font-size: 0.8rem;
  opacity: 0.85;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.crumbs a { color: inherit; }

.subtitle { font-size: 0.85rem; opacity: 0.85; }

.bar-text { flex: 1; }
.icon-btn.end { margin-left: 0; margin-right: -8px; }

.icon-btn {
  flex: none;
  width: 40px;
  height: 40px;
  margin-left: -8px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  display: grid;
  place-items: center;
}
.icon-btn svg { width: 26px; height: 26px; }
.icon-btn:active { background: rgb(255 255 255 / 0.18); }

main {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding: 12px max(12px, calc((100% - 720px) / 2)) calc(env(safe-area-inset-bottom) + 96px);
}

.list {
  list-style: none;
  margin: 0;
  padding: 0;
  background: var(--surface);
  border-radius: 12px;
  overflow: hidden;
}
.list:empty { display: none; }

.row {
  display: flex;
  align-items: center;
  border-bottom: 1px solid var(--line);
}
.row:last-child { border-bottom: 0; }

.row-open {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 4px 14px 16px;
  border: 0;
  background: transparent;
  text-align: left;
  color: inherit;
  text-decoration: none;
}
.row-open:active, .row-more:active { background: var(--line); }

.ico { flex: none; width: 28px; height: 28px; }
.ico.folder { fill: var(--folder); }
.ico.report { color: var(--report); }

.row-text { min-width: 0; display: flex; flex-direction: column; }

.row-name, .row-detail {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.row-detail { font-size: 0.85rem; color: var(--muted); }

.section-title {
  margin: 22px 4px 8px;
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}
.list + .list { margin-top: 12px; }

.row-more {
  flex: none;
  width: 48px;
  align-self: stretch;
  border: 0;
  background: transparent;
  display: grid;
  place-items: center;
}
.row-more svg { width: 20px; height: 20px; fill: var(--muted); }
.row-action {
  flex: none;
  align-self: center;
  margin-right: 4px;
  padding: 7px 12px;
  border: 1px solid var(--accent);
  border-radius: 999px;
  background: transparent;
  color: var(--accent);
  font: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  white-space: nowrap;
}
.row-action:active { background: var(--line); }
.ico.status { width: 26px; height: 26px; flex: none; }
.ico.status.sent { color: #b26a00; }
.ico.status.approved { color: #2e7d32; }
.ico.status.progress { color: var(--accent); }
.ico.status.done { color: var(--muted); }
.ico.status.declined { color: var(--danger); }

.empty {
  text-align: center;
  color: var(--muted);
  margin-top: 48px;
  padding: 0 24px;
}

.fab {
  position: fixed;
  right: 16px;
  bottom: calc(env(safe-area-inset-bottom) + 20px);
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 20px 14px 16px;
  border: 0;
  border-radius: 28px;
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 600;
  box-shadow: 0 4px 14px rgb(0 0 0 / 0.25);
}
.fab svg { width: 22px; height: 22px; }
.fab:active { filter: brightness(0.92); }

dialog {
  width: min(92vw, 420px);
  border: 0;
  border-radius: 16px;
  padding: 20px;
  background: var(--surface);
  color: var(--text);
}
dialog::backdrop { background: rgb(0 0 0 / 0.45); }
dialog h2 { margin: 0 0 14px; font-size: 1.15rem; }
dialog p { margin: 0 0 16px; color: var(--muted); }

.field {
  display: block;
  width: 100%;
  padding: 12px;
  font: inherit;
  font-size: 16px; /* keeps iOS from zooming in */
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg);
  color: var(--text);
}
.field:focus { outline: 2px solid var(--accent); border-color: transparent; }

textarea.field { resize: vertical; min-height: 4.5em; }
select.field { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 32px; }

.label { display: block; margin: 14px 0 6px; font-size: 0.9rem; font-weight: 600; }
h2 + .label { margin-top: 0; }
label[for="finding-issue"] { margin-top: 18px; }
.optional { font-weight: 400; color: var(--muted); }
.error { color: var(--danger); margin: 8px 0 0; font-size: 0.9rem; }

.actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 18px;
}

.btn {
  padding: 10px 18px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  font-weight: 600;
  color: var(--accent);
}
.btn.primary { background: var(--accent); color: var(--accent-ink); }
.btn.danger { background: var(--danger); color: #fff; }
.btn.danger-text { color: var(--danger); }
.btn.outline { flex: 1; text-align: center; border: 1.5px solid var(--accent); padding: 11px 12px; }
.btn.start { margin-right: auto; padding-left: 4px; }

/* Full-screen form on phones */
dialog.full {
  width: 100%;
  max-width: 560px;
  max-height: 100dvh;
  height: 100dvh;
  margin: 0 auto;
  border-radius: 0;
  padding: calc(env(safe-area-inset-top) + 16px) 16px calc(env(safe-area-inset-bottom) + 16px);
  overflow-y: auto;
}
@media (min-width: 600px) {
  dialog.full { height: auto; max-height: 92dvh; margin: auto; border-radius: 16px; }
}

.photo-preview {
  margin-bottom: 10px;
  border-radius: 12px;
  overflow: hidden;
  background: var(--bg);
}
.photo-preview img { display: block; width: 100%; max-height: 45vh; object-fit: contain; }
.photo-buttons { display: flex; gap: 10px; }

/* Findings */
.cards { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.card {
  border-radius: 12px;
  overflow: hidden;
  background: var(--surface);
}
.card-main {
  display: block;
  width: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  text-align: left;
}
.card-main:active { filter: brightness(0.96); }
.card-photo { display: block; width: 100%; aspect-ratio: 4 / 3; object-fit: cover; background: var(--line); }
.card-body { padding: 12px 14px 14px; }
.card-issue { font-weight: 600; }
.card-zone { margin-top: 2px; font-size: 0.9rem; color: var(--muted); }
.card-note { margin-top: 6px; white-space: pre-wrap; overflow-wrap: anywhere; }

.sheet {
  margin: auto auto 0;
  width: 100%;
  max-width: 520px;
  border-radius: 16px 16px 0 0;
  padding: 16px 8px calc(env(safe-area-inset-bottom) + 8px);
}
.sheet h2 {
  padding: 0 12px;
  font-size: 0.95rem;
  color: var(--muted);
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.sheet-item {
  display: block;
  width: 100%;
  padding: 14px 12px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  text-align: left;
  font-size: 1.05rem;
}
.sheet-item:active { background: var(--line); }
.sheet-item.danger { color: var(--danger); }

/* Zone controls at the bottom of a report */
body.in-report main { padding-bottom: 24px; }
body:not(.in-report) .zone-panel { display: none; }

.zone-panel {
  flex: none;
  z-index: 1;
  padding: 10px 12px calc(env(safe-area-inset-bottom) + 12px);
  background: var(--surface);
  border-top: 1px solid var(--line);
  box-shadow: 0 -4px 14px rgb(0 0 0 / 0.08);
}
.zone-row, .add-finding { max-width: 560px; margin: 0 auto; }
.zone-row { display: flex; align-items: center; gap: 8px; }
.zone-step {
  flex: none;
  width: 52px;
  height: 52px;
  border: 1.5px solid var(--line);
  border-radius: 12px;
  background: var(--bg);
  color: var(--accent);
  display: grid;
  place-items: center;
}
.zone-step svg { width: 26px; height: 26px; }
.zone-step:disabled { color: var(--line); }
.zone-step:active:not(:disabled) { background: var(--line); }
.zone-current {
  flex: 1;
  min-width: 0;
  height: 52px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
.zone-current:active { background: var(--line); }
.zone-caption { font-size: 0.75rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.zone-value { font-size: 1.35rem; font-weight: 700; line-height: 1.2; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
.add-finding {
  display: flex;
  width: 100%;
  margin-top: 10px;
  padding: 14px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 1.05rem;
}
.add-finding svg { width: 22px; height: 22px; }

.zone-group .section-title { margin-top: 18px; }
.zone-group:first-child .section-title { margin-top: 4px; }
.zone-group.current .section-title { color: var(--accent); }

/* Location box: coordinates with Map / Copy */
.loc-box, .coords-row {
  display: flex;
  align-items: center;
  gap: 10px;
}
.loc-box {
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg);
}
.card .loc-box { margin: 0 14px 14px; }
.loc-text { flex: 1; min-width: 0; }
.loc-coords { font-variant-numeric: tabular-nums; font-weight: 600; user-select: text; -webkit-user-select: text; }
.loc-details, .coords-label { font-size: 0.82rem; color: var(--muted); }
.loc-actions { flex: none; display: flex; gap: 6px; }
.btn.small { flex: none; padding: 7px 12px; font-size: 0.9rem; text-decoration: none; }

.coords-list { list-style: none; margin: 12px 0 0; padding: 0; }
.coords-row { padding: 12px 0; border-bottom: 1px solid var(--line); }
.hint { margin: 8px 0 0; font-size: 0.85rem; color: var(--muted); }

/* Report toolbar */
.toolbar { display: flex; gap: 8px; margin: 0 0 10px; }
.toolbar .btn { display: inline-flex; align-items: center; gap: 6px; background: var(--surface); }
.toolbar svg { width: 18px; height: 18px; }
#pdf-dialog .actions { flex-wrap: wrap; align-items: center; }
#pdf-dialog .actions a.btn { text-decoration: none; }
#pdf-text { overflow-wrap: anywhere; }

/* Company card (home screen) */
.company-card {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  margin-bottom: 14px;
  padding: 12px 14px;
  border: 0;
  border-radius: 12px;
  background: var(--surface);
  text-align: left;
}
.company-card:active { background: var(--line); }
.company-logo-box {
  flex: none;
  width: 64px;
  height: 44px;
  border-radius: 8px;
  background: #fff;
  border: 1px solid var(--line);
  display: grid;
  place-items: center;
  overflow: hidden;
}
.company-logo-box.empty { border-style: dashed; background: var(--bg); margin: 0; padding: 0; }
.company-logo-box img { max-width: 100%; max-height: 100%; object-fit: contain; }

.logo-preview {
  height: 120px;
  margin-bottom: 10px;
  border: 1px dashed var(--line);
  border-radius: 12px;
  background: #fff;
  display: grid;
  place-items: center;
  color: #5b6875;
  overflow: hidden;
}
.logo-preview img { max-width: 90%; max-height: 100px; object-fit: contain; }

/* Property photo (top-level folders) */
.property-photo {
  margin-bottom: 14px;
  border-radius: 12px;
  overflow: hidden;
  background: var(--surface);
}
.property-photo img { display: block; width: 100%; max-height: 260px; object-fit: cover; }
.property-photo-body { padding: 12px 14px; }
.property-photo-label { font-weight: 600; }
.property-photo-hint { font-size: 0.85rem; color: var(--muted); }
.property-photo-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.property-photo-actions .btn.danger-text { margin-left: auto; }

.version { text-align: center; color: var(--muted); font-size: 0.75rem; margin-top: 32px; }

.toast {
  position: fixed;
  left: 12px;
  right: 12px;
  top: calc(env(safe-area-inset-top) + 12px);
  z-index: 10;
  padding: 12px 14px;
  border-radius: 10px;
  background: var(--danger);
  color: #fff;
  font-size: 0.9rem;
  box-shadow: 0 4px 14px rgb(0 0 0 / 0.25);
}
.company-card .row-detail { white-space: normal; }

/* Troubleshooting disclaimer on the finding form */
.disclaimer-box {
  margin-top: 14px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg);
}
.disclaimer-box.on { border-color: var(--accent); }
.check { display: flex; align-items: center; gap: 10px; font-weight: 600; }
.check input { width: 22px; height: 22px; accent-color: var(--accent); flex: none; }
.disclaimer-text { margin: 8px 0 10px; font-size: 0.9rem; font-style: italic; color: var(--muted); }
.disclaimer-box:not(.on) .disclaimer-text { opacity: 0.6; }
#disclaimer-dialog .hint { margin: 0 0 10px; }
.card-disclaimer { margin-top: 6px; font-size: 0.9rem; font-style: italic; color: var(--muted); }

/* Accent color swatches */
.swatches { display: flex; flex-wrap: wrap; gap: 10px; }
.swatch {
  position: relative;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 2px solid var(--surface);
  border-radius: 50%;
  box-shadow: 0 0 0 1px var(--line);
  cursor: pointer;
}
.swatch.on { box-shadow: 0 0 0 2px var(--text); }
.swatch.custom {
  display: grid;
  place-items: center;
  overflow: hidden;
  background: conic-gradient(#e53935, #fdd835, #43a047, #1e88e5, #8e24aa, #e53935);
}
.swatch.custom input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; border: 0; padding: 0; cursor: pointer; }

/* Backup and restore */
.backup-icon { color: var(--accent); background: var(--bg); }
.backup-icon svg { width: 28px; height: 28px; }
.row-detail.warn { color: var(--danger); }
.btn.wide { display: block; width: 100%; margin-top: 10px; text-align: center; padding: 13px; }
.backup-last { margin: 12px 0 4px; font-weight: 600; color: var(--text); }
#backup-dialog .hint { margin: 0; }
#backup-dialog .hint + .hint, #backup-dialog label + .hint { margin-top: 12px; }
.sheet h2 { white-space: normal; }
.toast.ok { background: #2e7d32; }

/* ---------- Issues and prices ---------- */
#issues-view > .hint { margin: 0 4px 4px; }
.group-head { display: flex; align-items: center; justify-content: space-between; }
.group-head .section-title { flex: 1; min-width: 0; }
.group-head .row-more { width: 44px; height: 40px; margin-top: 12px; }
.issue-row { display: flex; align-items: center; border-bottom: 1px solid var(--line); }
.issue-row:last-child { border-bottom: 0; }
.issue-toggle { flex: none; display: grid; place-items: center; width: 52px; align-self: stretch; }
.issue-toggle input { width: 22px; height: 22px; accent-color: var(--accent); }
.issue-main {
  flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px;
  padding: 13px 16px 13px 0; border: 0; background: transparent; color: inherit; text-align: left; font: inherit;
}
.issue-main:active { background: var(--line); }
.issue-name { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.issue-price { flex: none; font-variant-numeric: tabular-nums; font-weight: 600; }
.issue-price.none { font-weight: 400; color: var(--muted); font-size: 0.85rem; }
.issue-row.off .issue-name, .issue-row.off .issue-price { opacity: 0.45; }
.add-issue { margin: 8px 0 0; }
.issues-footer { margin-top: 24px; }

/* ---------- Repair estimate ---------- */
.report-estimate { align-items: flex-start; margin-top: 16px; }
.report-estimate .hint { font-weight: 400; margin: 2px 0 0; display: inline-block; }
.estimate-bar {
  display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; width: 100%;
  margin: 0 0 10px; padding: 12px 16px; border: 0; border-left: 4px solid var(--accent); border-radius: 12px;
  background: var(--surface); color: inherit; text-align: left; font: inherit;
}
.estimate-bar:active { background: var(--line); }
.estimate-caption { font-size: 0.8rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); }
.estimate-total { margin-left: auto; font-size: 1.25rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.estimate-detail { flex-basis: 100%; font-size: 0.85rem; color: var(--muted); }
.estimate-detail.warn, .hint.warn { color: var(--danger); }
.card-price { margin-top: 4px; font-weight: 600; font-variant-numeric: tabular-nums; }
.card-price.none { font-weight: 400; color: var(--danger); font-size: 0.85rem; }
.estimate-lines { list-style: none; margin: 8px 0 0; padding: 0; }
.estimate-lines li { display: flex; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.estimate-lines .line-text { flex: 1; min-width: 0; }
.estimate-lines .line-detail { display: block; font-size: 0.85rem; color: var(--muted); }
.estimate-lines .line-amount { flex: none; font-weight: 600; font-variant-numeric: tabular-nums; }
.estimate-lines .line-amount.none { font-weight: 400; color: var(--danger); font-size: 0.85rem; }
.estimate-sum { display: flex; justify-content: space-between; padding: 12px 0 0; font-weight: 700; font-size: 1.15rem; }
#estimate-dialog .hint { margin-top: 8px; }

/* ---------- More photos on a finding ---------- */
.thumbs { list-style: none; margin: 10px 0 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: 8px; }
.thumbs li { position: relative; }
.thumbs img { display: block; width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 8px; background: var(--line); }
.thumb-remove {
  position: absolute; top: 4px; right: 4px; width: 28px; height: 28px; border-radius: 50%;
  border: 0; background: rgba(0, 0, 0, 0.6); color: #fff; font-size: 18px; line-height: 28px; padding: 0;
}
.more-buttons { margin-top: 10px; flex-wrap: wrap; }
.card-main { position: relative; }
.photo-count {
  position: absolute; top: 8px; right: 8px; padding: 3px 9px; border-radius: 999px;
  background: rgba(0, 0, 0, 0.62); color: #fff; font-size: 0.8rem; font-weight: 600;
}
#pdf-dialog .actions .btn.outline { flex: none; }

/* ---------- Property profile ---------- */
#profile-view .section-title:first-child { margin-top: 4px; }
.profile-hint { margin: 0 4px 4px; }
.issue-tag {
  flex: none; padding: 2px 8px; border-radius: 999px; font-size: 0.72rem; font-weight: 600;
  background: var(--accent); color: var(--accent-ink);
}
.issue-tag.own { background: transparent; color: var(--accent); border: 1px solid var(--accent); }
#issue-dialog .btn.start + .btn.start { margin-left: 0; }
.disclaimer-enabled { margin: 0 0 12px; }

.subdivision-group { margin-top: 4px; }
.subdivision-group > summary {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  list-style: none;
  padding: 6px 0;
  margin-bottom: 4px;
  min-height: 32px;
}
.subdivision-group > summary::-webkit-details-marker { display: none; }
.subdivision-group > summary::before {
  content: '';
  width: 7px;
  height: 7px;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(-45deg);
  transition: transform 0.15s;
  flex: none;
  margin: 0 3px;
}
.subdivision-group[open] > summary::before { transform: rotate(45deg); }
.subdivision-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text, inherit); }
.subdivision-count { font-weight: 500; text-transform: none; letter-spacing: 0; }

.search-box { position: relative; margin: 4px 0 10px; }
.search-box svg { position: absolute; left: 12px; top: 50%; width: 20px; height: 20px; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.search-box .field { padding-left: 40px; }
.scope-chips { display: flex; gap: 8px; margin: 0 0 6px; flex-wrap: wrap; }
.scope-chip { border: 1px solid var(--line); background: var(--surface); color: var(--text); border-radius: 999px; padding: 7px 14px; font: inherit; font-size: 0.9rem; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.scope-chip.on { background: var(--accent); border-color: var(--accent); color: #fff; }
#search-results mark { background: #fde68a; color: inherit; border-radius: 2px; padding: 0 1px; }
.result-photo { width: 40px; height: 40px; object-fit: cover; border-radius: 8px; flex: none; }
.cards > li.flash { outline: 3px solid var(--accent); outline-offset: 2px; transition: outline-color 0.4s; }
#search-results .row-detail { white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

/* Signature */
@font-face { font-family: 'Great Vibes'; src: url('fonts/great-vibes.woff2') format('woff2'); font-display: swap; }
@font-face { font-family: 'Dancing Script'; src: url('fonts/dancing-script.woff2') format('woff2'); font-display: swap; }
@font-face { font-family: 'Homemade Apple'; src: url('fonts/homemade-apple.woff2') format('woff2'); font-display: swap; }
.sig-tabs { display: flex; gap: 4px; padding: 4px; margin-bottom: 12px; background: var(--bg); border-radius: 10px; }
.sig-tab { flex: 1; border: 0; background: none; padding: 8px; border-radius: 8px; font: inherit; font-weight: 600; color: var(--muted); }
.sig-tab.on { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgb(0 0 0 / 0.12); }
.sig-styles { display: grid; gap: 8px; margin-top: 10px; }
.sig-style { display: block; width: 100%; height: 64px; padding: 0 14px; text-align: left; border: 1.5px solid var(--line); border-radius: 12px; background: #fff; color: #14213d; font-size: 30px; line-height: 64px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sig-style.on { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent) inset; }
.signature-enabled { margin: 0 0 12px; }
.signature-preview {
  display: grid; place-items: center; width: 100%; height: 96px; margin-bottom: 10px;
  border: 1px dashed var(--line); border-radius: 12px; background: #fff; color: #5b6875; font: inherit; overflow: hidden;
}
.signature-preview img { max-width: 92%; max-height: 84px; object-fit: contain; }
#settings-signature-box img { max-width: 100%; max-height: 100%; object-fit: contain; }
#settings-signature-box:has(img:not([hidden])) svg { display: none; }
dialog.sigpad { width: min(96vw, 640px); }
.sigpad-wrap { position: relative; height: min(46vh, 240px); border: 1px solid var(--line); border-radius: 12px; background: #fff; overflow: hidden; touch-action: none; }
#sigpad-canvas { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; }
.sigpad-hint { position: absolute; left: 0; right: 0; top: 40%; text-align: center; color: #9aa5b1; pointer-events: none; }
.sigpad-line { position: absolute; left: 7%; right: 7%; bottom: 26%; border-bottom: 1.5px solid #c3ccd5; pointer-events: none; }
#signature-dialog { max-height: 94dvh; overflow-y: auto; }
#signature-dialog .photo-buttons .btn { flex: 1; min-width: 0; padding-left: 8px; padding-right: 8px; }
.sig-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 10px; margin-top: 12px; }
.sig-grid .sig-wide { grid-column: 1 / -1; }
.sig-grid .field { min-width: 0; width: 100%; }
#signature-dialog .hint { margin-bottom: 10px; }
#signature-dialog .photo-buttons .btn { font-size: 0.95rem; }

/* Zone status marks */
.add-row { display: flex; gap: 8px; max-width: 560px; margin: 10px auto 0; align-items: stretch; }
.add-row .add-finding { flex: 1; min-width: 0; margin: 0; padding-left: 8px; padding-right: 8px; }
.add-row .add-finding span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mark-btn { flex: none; width: 56px; border-radius: 12px; background: #fff; display: grid; place-items: center; border: 2.5px solid; }
.mark-btn svg { width: 28px; height: 28px; }
.mark-btn.ok { color: #1f9d55; border-color: #1f9d55; }
.mark-btn.fail { color: #d32f2f; border-color: #d32f2f; }
.mark-btn:active { filter: brightness(0.92); }
.mark-btn:disabled { opacity: 0.5; }
.card-photo.mark { object-fit: contain; background: #fff; padding: 12px 0; }

/* No double-tap zoom anywhere; pinch zoom is blocked in app.js and the viewport meta. */
html, body { touch-action: pan-x pan-y; }
button, a, input, select, textarea, label { touch-action: manipulation; }

/* Zones fold up in a report */
details.zone-group > summary {
  display: grid;
  grid-template-columns: auto 1fr auto;
  grid-template-areas: "chev title status" ". sum sum";
  align-items: center;
  column-gap: 8px;
  list-style: none;
  cursor: pointer;
  padding: 8px 4px;
  margin-left: 0;
  margin-right: 0;
  border-radius: 10px;
}
details.zone-group > summary::-webkit-details-marker { display: none; }
details.zone-group > summary::before {
  grid-area: chev;
  content: '';
  width: 7px;
  height: 7px;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(-45deg);
  transition: transform 0.15s;
  margin: 0 3px;
}
details.zone-group[open] > summary::before { transform: rotate(45deg); }
details.zone-group:not([open]) > summary { background: var(--surface); margin-bottom: 8px; padding: 12px 10px; }
.zone-title { grid-area: title; min-width: 0; }
.zone-status { grid-area: status; display: flex; }
.zone-mark { display: grid; place-items: center; width: 24px; height: 24px; border-radius: 6px; border: 2px solid; background: #fff; }
.zone-mark svg { width: 16px; height: 16px; }
.zone-mark.ok { color: #1f9d55; }
.zone-mark.fail { color: #d32f2f; }
.zone-summary { grid-area: sum; font-weight: 400; text-transform: none; letter-spacing: 0; color: var(--muted); font-size: 0.85rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
details.zone-group[open] > summary .zone-summary { display: none; }
details.zone-group[open] > summary { grid-template-areas: "chev title status"; }
details.zone-group:not([open]) + details.zone-group { margin-top: 0; }
details.zone-group:not([open]) > .section-title { margin-top: 0; }
#finding-groups > details.zone-group:first-child > .section-title { margin-top: 4px; }

/* Controllers on the property profile */
.controller-loc { display: flex; gap: 8px; align-items: center; }
.controller-loc .field { flex: 1; min-width: 0; }
.controller-loc .btn { flex: none; white-space: nowrap; }
.controller-loc-status { margin: 4px 0 0; min-height: 1em; }
.controller-loc-status a { color: var(--accent); }
#controller-list:empty { display: none; }
#controller-dialog select.field { width: 100%; }
.controller-photo { margin: 4px 0 8px; }
.controller-photo img { display: block; width: 100%; max-height: 220px; object-fit: cover; border-radius: 12px; margin-bottom: 8px; background: var(--bg, #f3f4f6); }
.controller-photo-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.controller-photo-actions .danger-text { margin-left: auto; }
.row-open img.ico.thumb { width: 40px; height: 40px; border-radius: 8px; object-fit: cover; }

/* Estimate discount */
.estimate-subrow { display: flex; justify-content: space-between; padding: 12px 0 0; color: var(--muted); font-variant-numeric: tabular-nums; }
.estimate-discount { display: flex; width: 100%; justify-content: space-between; gap: 10px; padding: 10px 0; margin: 0; border: 0; border-bottom: 1px solid var(--line); background: none; font: inherit; color: var(--accent); text-align: left; cursor: pointer; }
.estimate-discount.has { color: inherit; }
.estimate-discount.has .line-amount { color: var(--ok, #1a7f37); }
.segmented { display: flex; gap: 0; margin: 12px 0 4px; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.segmented label { flex: 1; }
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented span { display: block; padding: 10px 8px; text-align: center; font-weight: 600; cursor: pointer; }
.segmented input:checked + span { background: var(--accent); color: #fff; }
.segmented input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: -4px; }

/* Export settings */
.template-options { display: grid; gap: 8px; margin: 12px 0 16px; }
.template-option { display: flex; gap: 12px; align-items: flex-start; padding: 12px; border: 1px solid var(--line); border-radius: 12px; cursor: pointer; }
.template-option input { width: 20px; height: 20px; margin-top: 2px; accent-color: var(--accent); flex: none; }
.template-option .hint { display: block; margin: 2px 0 0; font-weight: 400; }
.template-option:has(input:checked) { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset; }
#export-dialog .check { margin: 10px 0; align-items: flex-start; }
#export-dialog .check .hint { font-weight: 400; margin: 0; }
#export-dialog .check.sub { margin-left: 32px; }
#export-dialog .check input:disabled + span { opacity: .5; }

/* Online approval status on a report */
.approval-card { border: 1px solid var(--line); }
.approval-card[data-status="approved"] { border-color: #2e7d32; }
.approval-card[data-status="approved"] .backup-icon { color: #2e7d32; }
.approval-card[data-status="declined"] .backup-icon { color: var(--danger); }
.approval-card[data-status="sent"] .backup-icon { color: #b26a00; }

/* Approvals dashboard: rows wrap so the status line is readable */
#approvals-list .row-name, #approvals-list .row-detail { white-space: normal; overflow: visible; }
