:root {
  --paper: #eef1f4;
  --surface: #ffffff;
  --ink: #17212b;
  --muted: #586878;
  --line: #d3dbe3;
  --accent: #1e5aa8;
  --accent-dark: #164884;
  --danger: #b3261e;
  --ok: #1f6b3a;
  --tone: #35506e;
  --tone-bg: #e3eaf2;
  --soft: #f4f6f8;
  --soft2: #f0f3f6;
  --soft3: #eef1f4;
  --line-strong: #b7c2cd;
  --on-accent: #fff;
  --radius: 6px;
  color-scheme: light;
  font-family: "Avenir Next", "Segoe UI", Roboto, "Helvetica Neue", Arial, system-ui, sans-serif;
  color: var(--ink);
  background: var(--paper);
}

* { box-sizing: border-box; }
body { margin: 0; line-height: 1.45; font-size: 16px; }
main { max-width: 1180px; margin: 0 auto; padding: 1.5rem 1rem 4rem; }
a { color: var(--accent); }
a:hover { color: var(--accent-dark); }
h1 { font-size: 1.6rem; margin: 0; letter-spacing: -0.01em; }
h2 { font-size: 1.3rem; margin: 0; }
h3 { font-size: 1rem; margin: 1.5rem 0 0.5rem; }
.sub { color: var(--muted); margin: 0.35rem 0 1rem; }
.sr { position: absolute; left: -9999px; }
.count { font-weight: 500; color: var(--muted); margin-left: 0.25rem; }

:focus-visible { outline: 3px solid #7fb0ea; outline-offset: 2px; }

/* top bar */
.topbar {
  background: var(--header-bg, var(--ink));
  color: var(--header-ink, #fff);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 1.5rem;
  padding: 0.7rem 1rem;
}
.topbar a { color: var(--header-link, #dfe7ef); text-decoration: none; }
.topbar a:hover, .topbar a[aria-current="page"] { color: var(--header-ink, #fff); }
.topbar a[aria-current="page"] { text-decoration: underline; text-underline-offset: 6px; }
.brand { display: flex; align-items: center; gap: 0.65rem; font-weight: 700; font-size: 1.05rem; color: var(--header-ink, #fff) !important; margin-right: auto; }
.brand-logo { display: block; height: 34px; width: auto; max-width: 220px; object-fit: contain; }
.topbar nav { display: flex; flex-wrap: wrap; gap: 0.4rem 1.25rem; align-items: center; }
.linkbtn { background: none; border: 0; color: var(--header-link, #dfe7ef); font: inherit; cursor: pointer; padding: 0; }
.linkbtn:hover { color: var(--header-ink, #fff); }

/* layout bits */
.section-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.75rem; }
section + section { margin-top: 3rem; }
.narrow { max-width: 420px; margin: 2rem auto; }
.narrow.wide { max-width: 760px; }
.empty { background: var(--surface); border: 1px dashed var(--line); border-radius: var(--radius); padding: 1.5rem; color: var(--muted); }
.inline { display: inline; margin: 0; }

.flash { padding: 0.7rem 1rem; border-radius: var(--radius); margin: 0 0 1rem; background: #e5f1e9; color: var(--ok); border: 1px solid #b9d9c4; }
.flash.error { background: #fbe4e2; color: var(--danger); border-color: #f0b8b4; }

/* buttons */
.btn {
  display: inline-block; background: var(--accent); color: var(--on-accent, #fff); border: 1px solid var(--accent);
  border-radius: var(--radius); padding: 0.55rem 1rem; font: inherit; font-weight: 600;
  text-decoration: none; cursor: pointer;
}
.btn:hover { background: var(--accent-dark); color: var(--on-accent, #fff); }
.btn.secondary { background: var(--surface); color: var(--ink); border-color: var(--line); }
.btn.secondary:hover { background: var(--soft); color: var(--ink); }
.btn.danger { background: var(--surface); color: var(--danger); border-color: #e3aaa6; }
.btn.danger:hover { background: #fbe4e2; color: var(--danger); }
.btn.small { padding: 0.25rem 0.6rem; font-size: 0.85rem; }

/* forms */
label { display: block; font-weight: 600; font-size: 0.92rem; }
input, select, textarea {
  display: block; width: 100%; margin-top: 0.3rem; padding: 0.6rem 0.7rem; font: inherit; font-weight: 400;
  color: var(--ink); background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--radius);
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); }
textarea { min-height: 7rem; resize: vertical; line-height: 1.4; }
.grid-form label.span-2 { grid-column: 1 / -1; }
.muted { color: var(--muted); }
.namelink { color: inherit; text-decoration: none; }
.namelink:hover strong, .namelink:focus-visible strong { color: var(--accent); text-decoration: underline; }

/* permit detail page */
.backlink { display: inline-block; margin-bottom: 0.75rem; font-weight: 600; text-decoration: none; }
.backlink:hover { text-decoration: underline; }

.hero {
  display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-start; gap: 1rem 1.5rem;
  background: var(--surface); border: 1px solid var(--line); border-left: 6px solid var(--tone);
  border-radius: var(--radius); padding: 1.25rem 1.5rem;
}
.eyebrow { margin: 0 0 0.25rem; color: var(--muted); font-size: 0.9rem; font-weight: 600; }
.hero h1 { font-size: 1.9rem; }
.address { display: flex; align-items: center; flex-wrap: wrap; gap: 0.4rem; margin: 0.6rem 0 0; }
.address .icon { color: var(--muted); flex: none; }
.maplink { font-size: 0.9rem; margin-left: 0.35rem; }
.hero-side { display: flex; align-items: center; flex-wrap: wrap; gap: 0.75rem; }
.pill.big { font-size: 1rem; padding: 0.3rem 0.95rem; }

.callout { margin: 1rem 0 0; padding: 0.8rem 1rem; border-radius: var(--radius); font-weight: 600;
  background: #fadadd; color: #9b1c25; border: 1px solid #f0b8b4; }

.progress { margin-top: 1rem; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 1.25rem 1.25rem 1rem; }
.steps { list-style: none; margin: 0; padding: 0; display: flex; }
.steps li { flex: 1 1 0; min-width: 0; }
.steps li { position: relative; display: flex; flex-direction: column; align-items: center; gap: 0.45rem;
  text-align: center; color: var(--muted); font-size: 0.9rem; }
.steps li::before { content: ""; position: absolute; top: 15px; left: -50%; width: 100%; height: 3px;
  background: var(--line); z-index: 0; }
.steps li:first-child::before { display: none; }
.steps .dot { position: relative; z-index: 1; width: 32px; height: 32px; border-radius: 50%; display: grid;
  place-items: center; background: var(--surface); border: 2px solid var(--line); font-weight: 700; font-size: 0.85rem; }
.steps li.done { color: var(--ink); }
.steps li.done::before, .steps li.current::before { background: var(--accent); }
.steps li.done .dot { background: var(--accent); border-color: var(--accent); color: var(--on-accent, #fff); }
.steps li.current { color: var(--ink); font-weight: 700; }
.steps li.current .dot { border-color: var(--accent); color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft, #d9e7f8); }
.statusform { display: flex; align-items: center; justify-content: flex-end; gap: 0.6rem; margin: 1rem 0 0;
  padding-top: 0.9rem; border-top: 1px solid var(--line); }
.progress > .statusform:first-child { margin-top: 0; padding-top: 0; border-top: 0; }
.statusform label { font-size: 0.9rem; color: var(--muted); }
.statusform select { width: auto; margin: 0; }

.detail-cols { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: 1rem;
  margin-top: 1rem; align-items: start; }
.stack-col { display: grid; gap: 1rem; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.1rem 1.25rem 1.25rem; }
.card h2 { display: flex; justify-content: space-between; align-items: baseline; font-size: 1rem;
  margin: 0 0 0.9rem; padding-bottom: 0.6rem; border-bottom: 1px solid var(--line); }
.card h2 a { font-size: 0.85rem; font-weight: 600; }

.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 1rem 1.5rem; margin: 0; }
.facts dt { color: var(--muted); font-size: 0.85rem; }
.facts dd { margin: 0.15rem 0 0; font-weight: 600; font-size: 1.05rem; overflow-wrap: anywhere; }
.facts .permitno { font-size: 1.3rem; letter-spacing: 0.01em; font-variant-numeric: tabular-nums; }
.facts .none { color: var(--muted); font-weight: 400; font-size: 1rem; }

.ledger { margin: 0; }
.ledger > div { display: flex; justify-content: space-between; gap: 1rem; padding: 0.5rem 0; border-bottom: 1px dashed var(--line); }
.ledger dt { color: var(--muted); }
.ledger dd { margin: 0; font-weight: 600; font-variant-numeric: tabular-nums; }
.ledger .total { border-bottom: 0; border-top: 2px solid var(--ink); margin-top: 0.35rem; padding-top: 0.75rem; align-items: baseline; }
.ledger .total dt { color: var(--ink); font-weight: 700; }
.ledger .total dd { font-size: 1.4rem; font-weight: 700; }
.payrow { display: flex; justify-content: space-between; align-items: center; margin: 1rem 0 0; font-weight: 600; }

.notes-empty { margin: 0 0 0.5rem; color: var(--muted); }

/* notes timeline (Trello-style entries) */
.note-form { margin: 0 0 1.25rem; }
.note-form textarea { height: 2.75rem; min-height: 0; margin: 0; resize: none; }
.note-form textarea:focus, .note-form textarea:not(:placeholder-shown) { height: 6.5rem; resize: vertical; }
.note-form .note-actions { display: none; align-items: center; flex-wrap: wrap; gap: 0.4rem 0.75rem; margin-top: 0.5rem; }
.note-form:focus-within .note-actions, .note-form textarea:not(:placeholder-shown) ~ .note-actions { display: flex; }
.hint { color: var(--muted); font-size: 0.85rem; }
.note-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 1.1rem; }
.note { display: grid; grid-template-columns: 36px minmax(0, 1fr); gap: 0.75rem; }
.avatar { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center;
  background: var(--accent); color: var(--on-accent, #fff); font-weight: 700; font-size: 0.95rem; }
.note-meta { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0.1rem 0.6rem; margin-bottom: 0.3rem; }
.note-meta time { color: var(--muted); font-size: 0.85rem; }
.note-body { background: var(--soft); border: 1px solid var(--line); border-radius: 8px; padding: 0.65rem 0.85rem;
  white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.5; }
.note-tools { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0.2rem 1rem; margin-top: 0.35rem; font-size: 0.85rem; }
.note-tools summary { cursor: pointer; color: var(--accent); font-weight: 600; list-style: none; }
.note-tools summary::-webkit-details-marker { display: none; }
.note-tools summary:hover { text-decoration: underline; }
.note-tools details[open] { flex: 1 1 100%; }
.note-tools .linkbtn { color: var(--danger); font-weight: 600; font-size: 0.85rem; }
.note-tools .linkbtn:hover { text-decoration: underline; color: var(--danger); }
.note-edit-form { margin-top: 0.5rem; }
.note-meta .muted { font-size: 0.85rem; }
.note-edit-form textarea { min-height: 5rem; margin: 0 0 0.5rem; font-size: 1rem; }

@media (max-width: 760px) {
  .detail-cols { grid-template-columns: 1fr; }
  .hero { padding: 1rem 1.1rem; }
  .hero h1 { font-size: 1.5rem; }
  .steps { display: grid; grid-template-columns: repeat(3, 1fr); row-gap: 1rem; }
  .steps li::before { display: none; }
  .statusform { justify-content: flex-start; flex-wrap: wrap; }
}
.stacked { display: grid; gap: 1rem; margin-top: 1rem; }
.grid-form { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1rem 1.25rem; margin-top: 1.25rem;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.25rem; }
.form-actions { grid-column: 1 / -1; display: flex; gap: 0.6rem; }
.bad input, .bad select, .bad textarea { border-color: var(--danger); }
.field-error { display: block; color: var(--danger); font-weight: 500; font-size: 0.85rem; margin-top: 0.25rem; }
.danger-zone { margin-top: 1.5rem; }
.yearpick label { display: flex; align-items: center; gap: 0.5rem; }
.yearpick select { width: auto; margin: 0; }
.search { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; margin-bottom: 1rem; }
.search input { width: min(360px, 100%); margin: 0; }
.yearjump { display: flex; gap: 1rem; margin-bottom: 1rem; }

/* tables */
.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 0.65rem 0.8rem; text-align: left; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: 0.82rem; font-weight: 600; color: var(--muted); white-space: nowrap; }
tbody tr:last-child td { border-bottom: 0; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.actions { text-align: right; white-space: nowrap; }
tr.stripe td:first-child { box-shadow: inset 5px 0 0 var(--tone); white-space: nowrap; }
table.mini { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
table.mini th, table.mini td { padding: 0.45rem 0.7rem; }

/* fixed column widths so every month's table lines up */
table.permits { table-layout: fixed; min-width: 960px; }
table.permits th:nth-child(1) { width: 118px; }
table.permits th:nth-child(2) { width: 15%; }
table.permits th:nth-child(4) { width: 105px; }
table.permits th:nth-child(5) { width: 105px; }
table.permits th:nth-child(6) { width: 120px; }
table.permits th:nth-child(7) { width: 105px; }
table.permits th:nth-child(8) { width: 145px; }
table.permits th:nth-child(9) { width: 60px; }
table.permits td { overflow-wrap: anywhere; }

/* status / payment colours */
.s-applied     { --tone: #35506e; --tone-bg: #e3eaf2; }
.s-issued      { --tone: #1e4f8f; --tone-bg: #d9e7f8; }
.s-rough       { --tone: #7a5200; --tone-bg: #fbebc8; }
.s-insulation  { --tone: #8c4310; --tone-bg: #fbe0cc; }
.s-final       { --tone: #0f5f5a; --tone-bg: #d4f0ee; }
.s-closed      { --tone: #555b61; --tone-bg: #e8eaec; }
.s-needs-input { --tone: #9b1c25; --tone-bg: #fadadd; }
.p-not-paid    { --tone: #9b1c25; --tone-bg: #fadadd; }
.p-partial     { --tone: #7a5200; --tone-bg: #fbebc8; }
.p-paid        { --tone: #1f6b3a; --tone-bg: #dcf0e2; }

.pill {
  display: inline-block; padding: 0.12rem 0.65rem; border-radius: 999px; font-size: 0.85rem; font-weight: 600;
  background: var(--tone-bg); color: var(--tone); white-space: nowrap;
}
.status-select {
  display: inline-block; width: auto; margin: 0; padding: 0.3rem 0.5rem; font-weight: 600; font-size: 0.9rem;
  background: var(--tone-bg); color: var(--tone); border-color: transparent;
}

/* report */
.report h3 { color: var(--ink); }
.figures { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 0.75rem; margin-top: 1rem; }
.figures dl { margin: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 0.75rem 0.9rem; }
.figures dt { color: var(--muted); font-size: 0.85rem; }
.figures dd { margin: 0.15rem 0 0; font-size: 1.5rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.figures .money dd { font-size: 1.3rem; }
.figures .flag { border-color: #e3aaa6; }
.figures .flag dd { color: var(--danger); }
.chart { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 0.75rem; overflow-x: auto; }
.chart svg { display: block; width: 100%; min-width: 520px; height: auto; }
.chart .axis { stroke: var(--line); stroke-width: 1; }
.chart .bar { fill: var(--accent); }
.chart .val { font-size: 11px; fill: var(--ink); font-variant-numeric: tabular-nums; }
.chart .mon { font-size: 11px; fill: var(--muted); }
.breakdowns { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 0 2rem; align-items: start; }

/* archive */
.year { margin-top: 2.5rem; }
.year-head { border-bottom: 2px solid var(--ink); padding-bottom: 0.4rem; margin-bottom: 1rem; }
.year-head p { margin: 0.2rem 0 0; color: var(--muted); }
.month { margin-top: 1.5rem; }
.month h3 { margin: 0; font-size: 1.1rem; }

/* phones: turn table rows into stacked cards */
@media (max-width: 760px) {
  .grid-form { grid-template-columns: 1fr; }
  .figures { grid-template-columns: repeat(2, 1fr); }
  .figures .money dd { font-size: 1.1rem; }
  table.permits { table-layout: auto; min-width: 0; }
  table.stack thead { position: absolute; left: -9999px; }
  table.stack, table.stack tbody, table.stack tr, table.stack td { display: block; width: 100%; }
  table.stack tr { border-bottom: 1px solid var(--line); border-left: 5px solid var(--tone); padding: 0.5rem 0; }
  table.stack tr:last-child { border-bottom: 0; }
  table.stack td { border: 0; padding: 0.2rem 0.8rem; display: flex; justify-content: space-between; align-items: center; gap: 1rem; text-align: right; }
  table.stack td::before { content: attr(data-label); color: var(--muted); font-size: 0.85rem; text-align: left; }
  table.stack td.actions::before { content: none; }
  tr.stripe td:first-child { box-shadow: none; }
}

@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto !important; transition: none !important; animation: none !important; }
}

/* dashboard: needs attention */
.attention-cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 1rem; margin-top: 1rem; align-items: start; }
.attention .card h3 { margin: 0 0 0.7rem; font-size: 1rem; }
.alerts { list-style: none; margin: 0; padding: 0; }
.alerts li { display: flex; justify-content: space-between; align-items: center; gap: 0.75rem;
  padding: 0.6rem 0; border-top: 1px solid var(--line); }
.alerts li:first-child { border-top: 0; padding-top: 0; }
.alert-main { display: grid; min-width: 0; color: inherit; text-decoration: none; }
.alert-main strong { overflow-wrap: anywhere; }
.alert-main:hover strong, .alert-main:focus-visible strong { color: var(--accent); text-decoration: underline; }
.alert-sub { color: var(--muted); font-size: 0.85rem; overflow-wrap: anywhere; }
.alert-side { display: flex; flex-direction: column; align-items: flex-end; gap: 0.25rem; flex: none; font-size: 0.85rem; }
.alert-date { color: var(--muted); }
.rel { display: inline-block; padding: 0.1rem 0.6rem; border-radius: 999px; font-weight: 600; font-size: 0.8rem;
  background: #e8eaec; color: #555b61; white-space: nowrap; }
.rel.soon { background: #fbebc8; color: #7a5200; }
.rel.late { background: #fadadd; color: #9b1c25; }

/* permit page: time in status */
.instatus { margin-right: auto; color: var(--muted); font-size: 0.95rem; }
.instatus strong { color: var(--ink); }
.instatus.stuck { color: #9b1c25; font-weight: 600; }
.instatus.stuck strong { color: inherit; }

/* attachments */
.upload-form { display: grid; gap: 0.5rem; margin: 0 0 1rem; }
.upload-form input[type="file"] { padding: 0.45rem; margin: 0; font-size: 0.9rem; }
.upload-form .btn { justify-self: start; }
.upload-form .hint { margin: 0; }
.file-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.9rem; }
.file { display: grid; grid-template-columns: 56px minmax(0, 1fr) auto; gap: 0.7rem; align-items: center; }
.file-thumb { width: 56px; height: 56px; border-radius: 6px; overflow: hidden; background: var(--soft2);
  border: 1px solid var(--line); display: grid; place-items: center; text-decoration: none; }
.file-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.file-thumb .ext { font-size: 0.72rem; font-weight: 700; color: var(--accent); letter-spacing: 0.03em; }
.file-info { display: grid; min-width: 0; }
.file-name { font-weight: 600; overflow-wrap: anywhere; text-decoration: none; }
.file-name:hover { text-decoration: underline; }
.file-meta { color: var(--muted); font-size: 0.8rem; }
.file .linkbtn { color: var(--danger); font-size: 0.85rem; font-weight: 600; }
.file .linkbtn:hover { text-decoration: underline; color: var(--danger); }

@media (max-width: 760px) {
  .instatus { flex: 1 1 100%; margin-right: 0; }
  .alerts li { align-items: flex-start; }
}

/* ===== accounts, settings, users ===== */
.who { color: var(--header-muted, #9fb1c3); font-size: 0.9rem; }
.btn-row { display: flex; flex-wrap: wrap; gap: 0.6rem; }
.inline-flex { display: flex; align-items: center; gap: 0.6rem; margin: 0; }
.inline-block { display: inline-block; margin-top: 0.6rem; }
.linkbtn.plain { color: var(--accent); font-weight: 600; font-size: 0.9rem; }
.small { font-size: 0.9rem; }
.settings-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 1rem; align-items: start; margin-top: 1rem; }
.settings .card h3 { font-size: 1rem; margin: 1.25rem 0 0.4rem; }
.settings .card p { margin: 0 0 0.9rem; }
.recovery { margin-top: 1rem; border-color: #e3c48a; background: #fffaf0; }
.codes { list-style: none; margin: 0.75rem 0 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 0.5rem;
  font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 1.05rem; }
.secretkey { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 1.15rem; letter-spacing: 0.06em; overflow-wrap: anywhere;
  background: var(--soft); border: 1px solid var(--line); border-radius: 6px; padding: 0.6rem 0.8rem; margin: 0.5rem 0; }
.howto { padding-left: 1.2rem; margin: 0 0 1rem; display: grid; gap: 0.7rem; }
.userlist td, .userlist th { vertical-align: middle; }
.adduser { margin-top: 1.5rem; }

/* ===== form sections ===== */
.form-stack { display: grid; gap: 1rem; margin-top: 1.25rem; }
fieldset.fs { margin: 0; min-width: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 0.5rem 1.25rem 1.25rem; }
fieldset.fs legend { font-weight: 700; padding: 0 0.4rem; margin-left: -0.4rem; }
.fields { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1rem 1.25rem; }
.fields .span-2, .fields .form-actions { grid-column: 1 / -1; }
.card.fields { padding: 1.25rem; }
.check { display: flex; align-items: center; gap: 0.5rem; font-weight: 600; }
.check input { width: auto; margin: 0; }
.static-field { display: grid; gap: 0.3rem; align-content: start; }
.static-field .static-label { font-weight: 600; font-size: 0.92rem; }
.static-field small { color: var(--muted); }
.callout.warn { background: #fff4d6; color: #6b4a00; border-color: #ecd28b; font-weight: 500; }
table.permits.flex { table-layout: auto; min-width: 0; }

/* ===== permit page: contacts, inspections, payments, history ===== */
.mini-form { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 0.6rem 0.75rem; align-items: end; margin: 0 0 1rem; }
.mini-form label { font-size: 0.85rem; }
.mini-form input, .mini-form select { padding: 0.45rem 0.55rem; font-size: 0.95rem; }
.mini-form .btn { justify-self: start; }

.contacts { margin: 0; display: grid; gap: 0.9rem; }
.contacts dt { color: var(--muted); font-size: 0.85rem; }
.contacts dd { margin: 0.15rem 0 0; display: grid; gap: 0.15rem; font-weight: 600; overflow-wrap: anywhere; }
a.tel { white-space: nowrap; }

.insp-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.9rem; }
.insp { border: 1px solid var(--line); border-radius: 8px; padding: 0.7rem 0.85rem; }
.insp-main { display: flex; flex-wrap: wrap; align-items: center; gap: 0.3rem 0.7rem; }
.insp-when { color: var(--muted); font-size: 0.9rem; }
.insp-note { flex-basis: 100%; font-size: 0.9rem; }
.insp-tools { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 0.5rem 1rem; margin-top: 0.65rem; font-size: 0.85rem; }
.insp-result { display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem; flex: 1 1 100%; margin: 0; }
.insp-result input { flex: 1 1 180px; width: auto; margin: 0; padding: 0.4rem 0.55rem; }
.insp-tools summary { cursor: pointer; color: var(--accent); font-weight: 600; list-style: none; }
.insp-tools summary::-webkit-details-marker { display: none; }
.insp-tools summary:hover { text-decoration: underline; }
.insp-tools details[open] { flex: 1 1 100%; }
.insp-tools details .mini-form { margin: 0.6rem 0 0; }
.insp-tools .linkbtn { color: var(--danger); font-weight: 600; font-size: 0.85rem; }
.insp-tools .linkbtn:hover { text-decoration: underline; color: var(--danger); }
.btn.pass { background: #1f6b3a; border-color: #1f6b3a; }
.btn.pass:hover { background: #17542d; border-color: #17542d; }
.btn.fail { background: var(--danger); border-color: var(--danger); }
.btn.fail:hover { background: #8f1e18; border-color: #8f1e18; }
.r-scheduled { --tone: #1e4f8f; --tone-bg: #d9e7f8; }
.r-passed    { --tone: #1f6b3a; --tone-bg: #dcf0e2; }
.r-failed    { --tone: #9b1c25; --tone-bg: #fadadd; }
.r-canceled  { --tone: #555b61; --tone-bg: #e8eaec; }

.ledger.received { margin-top: 0.9rem; }
.ledger .due dt { color: var(--ink); font-weight: 700; }
.ledger .owed { color: #9b1c25; font-size: 1.2rem; }
.ledger .clear { color: #1f6b3a; font-size: 1.2rem; }

.pay-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.7rem; }
.pay-list li { display: flex; justify-content: space-between; align-items: center; gap: 0.75rem; padding-top: 0.7rem; border-top: 1px solid var(--line); }
.pay-list li:first-child { border-top: 0; padding-top: 0; }
.pay-main { display: grid; min-width: 0; }
.pay-main strong { font-variant-numeric: tabular-nums; font-size: 1.05rem; }
.pay-meta { color: var(--muted); font-size: 0.85rem; overflow-wrap: anywhere; }
.pay-list .linkbtn { color: var(--danger); font-weight: 600; font-size: 0.85rem; }
.pay-list .linkbtn:hover { text-decoration: underline; color: var(--danger); }

.camera-form { margin: -0.4rem 0 1rem; }
.camera-btn { cursor: pointer; }

.activity { display: grid; grid-template-columns: 36px minmax(0, 1fr); gap: 0.75rem; align-items: start; }
.act-dot { justify-self: center; width: 10px; height: 10px; border-radius: 50%; background: #9aa8b5; margin-top: 0.45rem; }
.act-status { background: var(--accent); }
.act-payment { background: #1f6b3a; }
.act-inspection { background: #8c4310; }
.act-text { display: block; font-size: 0.92rem; overflow-wrap: anywhere; }
.act-meta { display: block; color: var(--muted); font-size: 0.8rem; }

/* ===== reports ===== */
.reports h2 { margin: 2rem 0 0.75rem; }
.exports { margin: 0.75rem 0 0; }
table.mini tfoot td { font-weight: 700; border-top: 2px solid var(--ink); border-bottom: 0; }
table.owing .alert-sub { margin-top: 0.1rem; }

@media (max-width: 760px) {
  .fields { grid-template-columns: 1fr; }
  .inline-flex { flex-wrap: wrap; }
}

.static-field .pill { justify-self: start; }

/* ===== work types page ===== */
.wt-add { display: flex; flex-wrap: wrap; align-items: end; gap: 0.75rem; }
.wt-add label { flex: 1 1 240px; }
.wt-table td, .wt-table th { vertical-align: middle; }
.wt-order { display: flex; gap: 0.3rem; margin: 0; }
.iconbtn { width: 2rem; height: 2rem; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); color: var(--ink);
  font: inherit; font-size: 1rem; cursor: pointer; line-height: 1; }
.iconbtn:hover:not(:disabled) { background: var(--soft); border-color: var(--line-strong); }
.iconbtn:disabled { opacity: 0.35; cursor: default; }
.is-hidden strong { color: var(--muted); font-weight: 600; }
.wt-actions { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 0.3rem 1rem; }
.wt-rename summary { cursor: pointer; color: var(--accent); font-weight: 600; font-size: 0.9rem; list-style: none; }
.wt-rename summary::-webkit-details-marker { display: none; }
.wt-rename summary:hover { text-decoration: underline; }
.wt-rename[open] { flex: 1 1 100%; }
.wt-rename form { display: flex; gap: 0.5rem; margin-top: 0.5rem; }
.wt-rename input { margin: 0; }
.linkbtn.danger-link { color: var(--danger); font-weight: 600; font-size: 0.9rem; }
.linkbtn.danger-link:hover { text-decoration: underline; color: var(--danger); }

/* ===== email, backups, scheduled tasks ===== */
.flash { white-space: pre-line; }
.admin-links { display: grid; gap: 0.5rem; margin-bottom: 0.5rem; }
.admin-links .btn { text-align: center; }
.form-sub { grid-column: 1 / -1; margin: 0.75rem 0 0 !important; padding-top: 0.9rem; border-top: 1px solid var(--line); font-size: 1rem; }
.guide { margin-top: 1rem; border-top: 1px solid var(--line); padding-top: 0.75rem; }
.guide summary { cursor: pointer; color: var(--accent); font-weight: 600; }
.guide ol { padding-left: 1.2rem; display: grid; gap: 0.7rem; margin: 0.75rem 0 0; }
.guide p { margin: 0.6rem 0 0; }
.guide code { background: var(--soft2); padding: 0.05rem 0.35rem; border-radius: 4px; font-size: 0.9em; }
.copybox { margin-top: 0.4rem; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 0.85rem; }
.statuslist { margin: 0 0 1rem; display: grid; gap: 0.5rem; }
.statuslist > div { display: flex; justify-content: space-between; gap: 1rem; padding: 0.35rem 0; border-bottom: 1px dashed var(--line); }
.statuslist dt { color: var(--muted); }
.statuslist dd { margin: 0; font-weight: 600; text-align: right; }
.plain-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.35rem; }
.plain-list li { display: flex; justify-content: space-between; gap: 1rem; font-size: 0.92rem; }
.sched { display: grid; gap: 0.9rem; }
.sched-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.5rem 1rem; }
.sched-row .check { flex: 1 1 220px; }
.sched-row input[type="time"] { width: auto; margin: 0; }
.sched .btn { justify-self: start; }
.task-status { display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: 0.7rem 0; border-top: 1px solid var(--line); }
.task-status:first-of-type { border-top: 0; padding-top: 0; }
.task-log { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.9rem; }
.task-log li { border-top: 1px solid var(--line); padding-top: 0.8rem; }
.task-log li:first-child { border-top: 0; padding-top: 0; }
.log-head { display: flex; flex-wrap: wrap; align-items: center; gap: 0.3rem 0.7rem; }
.log-msg { margin-top: 0.3rem; font-size: 0.88rem; color: var(--muted); white-space: pre-line; overflow-wrap: anywhere; }
.settings .card form.fields { margin-top: 0.25rem; }

/* settings cards are narrow, so keep their forms in one column */
.settings .card .fields { grid-template-columns: 1fr; }
.settings .card .fields .span-2, .settings .card .fields .form-actions { grid-column: auto; }

.task-status .btn { white-space: nowrap; }
.sched + .hint, .sched .btn { margin-top: 0.25rem; }

/* ===== white-label: sign-in page, footer, branding settings ===== */
.login-card { text-align: left; }
.login-brand { text-align: center; margin-bottom: 1.25rem; }
.login-logo { display: inline-block; max-width: 260px; max-height: 90px; width: auto; height: auto; object-fit: contain; }
.login-name { margin: 0; font-size: 1.5rem; font-weight: 700; letter-spacing: -0.01em; }
.login-tagline { margin: 0.25rem 0 0; color: var(--muted); }
.login-message { margin-top: 0.5rem; }
.site-footer { max-width: 1180px; margin: 0 auto; padding: 1.5rem 1rem 2.5rem; text-align: center; color: var(--muted); font-size: 0.88rem;
  border-top: 1px solid var(--line); }
.site-footer p { margin: 0.15rem 0; }
.site-footer a { color: var(--muted); }
.brand-preview { border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; background: var(--surface); }
.bp-header { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.4rem 1rem; padding: 0.7rem 1rem;
  background: var(--header-bg); color: var(--header-ink); }
.bp-name { font-weight: 700; display: flex; align-items: center; gap: 0.6rem; }
.bp-logo { display: block; height: 28px; width: auto; max-width: 160px; object-fit: contain; }
.bp-nav { font-size: 0.85rem; color: var(--header-link); white-space: nowrap; }
.bp-body { padding: 1rem; display: flex; flex-wrap: wrap; align-items: center; gap: 1rem; }
.bp-link { color: var(--accent); font-weight: 600; }
.color-row { display: flex; align-items: center; gap: 0.6rem; }
.color-row input[type="color"] { width: 3.2rem; height: 2.4rem; padding: 0.15rem; margin: 0; cursor: pointer; }
.color-row .hint { margin: 0; }
.current-logo { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; padding: 0.7rem; border: 1px solid var(--line); border-radius: var(--radius);
  background: repeating-conic-gradient(var(--soft2) 0% 25%, var(--surface) 0% 50%) 0 0 / 16px 16px; }
.current-logo img { max-height: 56px; max-width: 220px; width: auto; height: auto; }
.radio-list { display: grid; gap: 0.4rem; }
.radio-list label { display: flex; align-items: center; gap: 0.5rem; font-weight: 500; }
.radio-list input { width: auto; margin: 0; }
.brand-actions { margin-top: 1.25rem; }
.brand-form .card textarea { min-height: 4.5rem; }

/* inspection email option on the schedule forms */
.mini-form .notify-check, .mini-form .notify-hint { grid-column: 1 / -1; margin: 0; }
.mini-form .notify-check { font-weight: 500; font-size: 0.9rem; }

/* ===== inspection result: partial ===== */
.r-partial { --tone: #7a5200; --tone-bg: #fbebc8; }
.btn.partial { background: #8a5a00; border-color: #8a5a00; }
.btn.partial:hover { background: #6e4800; border-color: #6e4800; }

/* ===== permit steps settings ===== */
.step-add { display: flex; flex-wrap: wrap; align-items: end; gap: 0.75rem; }
.step-add label { flex: 1 1 200px; }
.step-add input[type="color"], .step-edit-form input[type="color"] { width: 3.2rem; height: 2.4rem; padding: 0.15rem; margin: 0.3rem 0 0; cursor: pointer; }
.step-list { list-style: none; margin: 1rem 0; padding: 0; display: grid; gap: 0.5rem; }
.step-item { display: flex; flex-wrap: wrap; align-items: center; gap: 0.6rem 0.9rem; background: var(--surface);
  border: 1px solid var(--line); border-left: 6px solid var(--tone); border-radius: 8px; padding: 0.6rem 0.8rem; }
.step-item.is-hidden { opacity: 0.65; }
.step-item.dragging { opacity: 0.7; box-shadow: 0 6px 18px rgba(23, 33, 43, 0.25); background: var(--soft); }
.drag-handle { cursor: grab; touch-action: none; user-select: none; -webkit-user-select: none; color: var(--muted);
  font-size: 1.25rem; letter-spacing: -3px; padding: 0.35rem 0.5rem; margin: -0.35rem 0 -0.35rem -0.3rem; border-radius: 6px; }
.drag-handle:hover { background: var(--soft3); color: var(--ink); }
.step-main { flex: 1 1 240px; min-width: 0; display: grid; gap: 0.25rem; }
.step-meta { color: var(--muted); font-size: 0.85rem; }
.step-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem 1rem; margin-left: auto; }
.step-edit[open] { flex: 1 1 100%; }
.step-edit-form { display: flex; flex-wrap: wrap; align-items: end; gap: 0.6rem 0.9rem; margin-top: 0.6rem; width: 100%; }
.step-edit-form label { flex: 1 1 160px; margin: 0; }
.step-edit-form .hint { display: block; }
.steps-help ul { margin: 0; padding-left: 1.2rem; display: grid; gap: 0.45rem; }
.is-dragging-list { user-select: none; }
.step-main .pill { justify-self: start; }

/* ===== permit types, exempt ===== */
.type-tabs { display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem; margin: 1rem 0; }
.type-tab { display: inline-flex; align-items: center; gap: 0.4rem; padding: 0.45rem 0.9rem; border: 1px solid var(--line); border-radius: 999px;
  background: var(--surface); color: var(--ink); text-decoration: none; font-weight: 600; }
.type-tab:hover { border-color: var(--accent); }
.type-tab.current { background: var(--accent); border-color: var(--accent); color: var(--on-accent, #fff); }
.type-tab.current .count { color: var(--on-accent, #fff); opacity: 0.85; }
.type-tab.is-hidden { opacity: 0.6; border-style: dashed; }
.type-add { flex: 1 1 100%; }
.type-add summary { display: inline-block; cursor: pointer; color: var(--accent); font-weight: 600; padding: 0.4rem 0.2rem; }
.type-add[open] summary { margin-bottom: 0.4rem; }
.type-add .step-add { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 0.9rem; }
.type-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.6rem 1rem; }
.type-head h2 { margin: 0; border: 0; padding: 0; }
.type-card .hint { margin: 0.4rem 0 0; }
.muted-line { display: block; color: var(--muted); font-size: 0.82rem; }
.p-exempt { --tone: #4a3b80; --tone-bg: #e9e4f7; }
.exempt-box { background: #f6f4fc; border: 1px solid #d9d2f0; border-radius: 8px; padding: 0.7rem 0.9rem; }
.exempt-box.invalid { border-color: var(--bad, #9b1c25); }
.exempt-box .check { margin: 0; font-weight: 500; }
.exempt-box .hint { display: block; margin: 0.3rem 0 0 1.6rem; }
input:disabled { background: var(--soft3); color: #7a8794; cursor: not-allowed; }

/* ===== filtering lists by permit type ===== */
.type-filter { display: flex; flex-wrap: wrap; gap: 0.4rem; margin: 0 0 1rem; }
.scope { display: inline-block; vertical-align: middle; margin-left: 0.4rem; padding: 0.15rem 0.7rem; border-radius: 999px;
  background: var(--accent-soft, #d9e7f8); color: var(--accent); font-size: 0.85rem; font-weight: 700; letter-spacing: 0; }

/* ===== address lookup ===== */
.addr-field { position: relative; }
.addr-suggest { position: absolute; z-index: 30; left: 0; right: 0; top: 100%; margin: 2px 0 0; padding: 0; list-style: none;
  background: var(--surface); border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 8px 22px rgba(23, 33, 43, 0.18); overflow: hidden; }
.addr-suggest[hidden] { display: none; }
.addr-suggest li { padding: 0.55rem 0.8rem; cursor: pointer; font-weight: 500; line-height: 1.3; }
.addr-suggest li + li { border-top: 1px solid var(--soft3); }
.addr-suggest li[aria-selected="true"], .addr-suggest li:hover { background: var(--accent-soft, #d9e7f8); }
.addr-suggest .addr-main { display: block; color: var(--ink); }
.addr-suggest .addr-sub { display: block; color: var(--muted); font-size: 0.85rem; font-weight: 400; }
.addr-suggest li.addr-note { cursor: default; font-size: 0.8rem; font-weight: 400; color: var(--muted); background: var(--soft); }
.addr-suggest li.addr-note:hover { background: var(--soft); }
.addr-suggest li.addr-error { color: var(--bad, #9b1c25); cursor: default; font-weight: 500; }
.narrow-input { max-width: 8rem; }
.hint.block { display: block; margin-top: 0.2rem; font-weight: 400; }
.radio-list label > span { display: block; }
.test-card { margin-top: 1rem; }
.test-form { display: flex; flex-wrap: wrap; align-items: end; gap: 0.7rem; }
.test-form label { flex: 1 1 260px; margin: 0; }
.radio-list label { align-items: flex-start; }
.radio-list label input[type="radio"] { margin-top: 0.3rem; }
label .hint { font-weight: 400; }

/* ===== clients ===== */
.client-field { position: relative; }
.add-client { margin: 0 0 1rem; }
.add-client > summary { cursor: pointer; color: var(--accent); font-weight: 600; }
.add-client[open] > summary { margin-bottom: 0.7rem; }
.client-permits-h { margin: 1.4rem 0 0.6rem; font-size: 1.1rem; }
.client-page .card { margin-bottom: 1rem; }
.step-add .span-all { flex: 1 1 100%; margin: 0; }

/* ===== clients table: its own column layout (it used to inherit the permits list's fixed widths) ===== */
table.permits.clients { table-layout: fixed; min-width: 640px; }
table.permits.clients th:nth-child(n) { width: auto; }
table.permits.clients col[data-col="name"] { width: 28%; }
table.permits.clients col[data-col="phone"] { width: 20%; }
table.permits.clients col[data-col="email"] { width: 40%; }
table.permits.clients col[data-col="permits"] { width: 12%; }
table.permits.clients td { overflow-wrap: break-word; word-break: normal; }       /* wrap at spaces; break a word only if it can't fit */
table.permits.clients td[data-label="Email"] { overflow-wrap: anywhere; }         /* long email addresses may wrap anywhere */
table.permits.clients td[data-label="Phone"] { white-space: nowrap; }
table.permits.clients th { position: relative; }
.col-resizer { position: absolute; top: 0; right: -5px; width: 11px; height: 100%; cursor: col-resize; touch-action: none; z-index: 2; }
.col-resizer::after { content: ""; position: absolute; left: 5px; top: 22%; height: 56%; width: 2px; border-radius: 1px; background: var(--line); }
.col-resizer:hover::after, .col-resizer.dragging::after { background: var(--accent); }
.resize-hint { margin: 0 0 0.5rem; }
body.is-col-resizing { cursor: col-resize; user-select: none; -webkit-user-select: none; }
@media (max-width: 640px) {
  table.permits.clients { table-layout: auto; min-width: 0; }
  .col-resizer, .resize-hint { display: none; }
  table.permits.clients td[data-label="Phone"] { white-space: normal; }
  table.permits.clients td::before { flex: none; white-space: nowrap; }         /* a field label never breaks mid-word */
  table.permits.clients td { min-width: 0; }
  table.permits.clients td:empty { display: none; }                              /* skip fields with nothing in them */
}

/* ===== text messages ===== */
.sms-to { margin: 0 0 0.7rem; }
.sms-consent, .sms-composer { display: grid; gap: 0.6rem; }
.sms-composer textarea { min-height: 5rem; }
.sms-send-row { display: flex; align-items: center; justify-content: space-between; gap: 0.7rem; flex-wrap: wrap; }
.sms-optout { margin-top: 0.6rem; display: flex; align-items: center; gap: 0.7rem; flex-wrap: wrap; }
.sms-history { list-style: none; margin: 1rem 0 0; padding: 0; display: grid; gap: 0.5rem; }
.sms-msg { max-width: 92%; padding: 0.55rem 0.8rem; border-radius: 12px; display: grid; gap: 0.2rem; border: 1px solid var(--line); background: var(--surface); }
.sms-out { justify-self: end; background: var(--accent-soft, #d9e7f8); border-color: transparent; }
.sms-in { justify-self: start; }
.sms-body { white-space: pre-wrap; overflow-wrap: anywhere; }
.sms-meta { font-size: 0.78rem; color: var(--muted); overflow-wrap: anywhere; }
.sms-checklist ol { margin: 0; padding-left: 1.2rem; display: grid; gap: 0.45rem; }
.webhook-url { width: 100%; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 0.85rem; }
.sms-ok-box { flex: 1 1 100%; background: #f6f4fc; border: 1px solid #d9d2f0; border-radius: 8px; padding: 0.7rem 0.9rem; }
.sms-ok-box .check { margin: 0; font-weight: 500; }
.sms-ok-box .hint { display: block; margin: 0.3rem 0 0 1.6rem; }
.sms-how { display: block; margin: 0.5rem 0 0 1.6rem; font-weight: 500; }
.sms-consent .btn { justify-self: start; }

/* Photo and video gallery on a permit */
.media-head { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; flex-wrap: wrap; margin: 1rem 0 0.6rem; }
.media-head h3, .media-subhead { margin: 0; font-size: 1rem; }
.media-subhead { margin: 1.2rem 0 0.6rem; }
.media-grid { list-style: none; margin: 0 0 0.5rem; padding: 0; display: grid; gap: 0.8rem;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.media-item { min-width: 0; }
.media-thumb { display: grid; place-items: center; aspect-ratio: 1; border-radius: 8px; overflow: hidden; background: var(--soft2);
  border: 1px solid var(--line); text-decoration: none; position: relative; }
.media-thumb:hover, .media-thumb:focus-visible { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft, #d9e7f8); outline: none; }
.media-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.media-thumb .ext { font-size: 0.78rem; font-weight: 700; color: var(--accent); letter-spacing: 0.03em; }
.media-video { display: grid; place-items: center; gap: 0.35rem; width: 100%; height: 100%; background: #26323f; }
.media-video .ext { color: #dfe7ef; }
.media-cap { display: grid; gap: 0.1rem; padding: 0.35rem 0.1rem 0; font-size: 0.85rem; }
.media-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.media-actions { display: flex; gap: 0.8rem; align-items: center; }
.media-actions a { font-size: 0.85rem; font-weight: 600; }
.media-actions .linkbtn { color: var(--danger); font-size: 0.85rem; font-weight: 600; }
.media-actions .linkbtn:hover { text-decoration: underline; color: var(--danger); }
.media-save { margin: 1rem 0 1.5rem; }

/* Lightbox viewer */
body.lb-open { overflow: hidden; }
.lb { position: fixed; inset: 0; z-index: 1000; background: rgba(8, 12, 17, 0.94); display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto; color: #fff; }
.lb[hidden] { display: none; }
.lb-top { display: flex; align-items: center; gap: 0.75rem; padding: 0.6rem 0.9rem; background: rgba(0, 0, 0, 0.35); }
.lb-count { font-size: 0.85rem; color: #c3ced9; white-space: nowrap; }
.lb-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.lb-btn { background: rgba(255, 255, 255, 0.12); color: #fff; border: 1px solid rgba(255, 255, 255, 0.28); border-radius: 6px;
  padding: 0.4rem 0.8rem; font: inherit; font-size: 0.9rem; font-weight: 600; cursor: pointer; text-decoration: none; white-space: nowrap; }
.lb-btn:hover, .lb-btn:focus-visible { background: rgba(255, 255, 255, 0.24); color: #fff; outline: 2px solid #fff; outline-offset: 1px; }
.lb-stage { position: relative; display: grid; place-items: center; min-height: 0; padding: 0.5rem 3.6rem; }
.lb-media { max-width: 100%; max-height: 100%; object-fit: contain; display: block; border-radius: 2px; }
.lb-media.loading { opacity: 0.25; }
.lb-note { padding: 0.6rem 0.9rem 0.8rem; text-align: center; color: #c3ced9; font-size: 0.85rem; min-height: 1.2rem; }
.lb-error { color: #ffd4d0; text-align: center; max-width: 28rem; }
.lb-nav { position: absolute; top: 50%; transform: translateY(-50%); width: 2.8rem; height: 4rem; border: 0; border-radius: 6px;
  background: rgba(255, 255, 255, 0.1); color: #fff; font-size: 1.8rem; line-height: 1; cursor: pointer; }
.lb-nav:hover, .lb-nav:focus-visible { background: rgba(255, 255, 255, 0.25); outline: 2px solid #fff; }
.lb-prev { left: 0.4rem; }
.lb-next { right: 0.4rem; }
.lb-single .lb-nav { display: none; }
@media (max-width: 600px) {
  .lb-stage { padding: 0.25rem 0.25rem; }
  .lb-nav { width: 2.4rem; height: 3.2rem; background: rgba(0, 0, 0, 0.45); }
  .lb-name { font-size: 0.9rem; }
}

/* Settings cards: collapse arrow + drag handle (see app.js) */
.card-head { display: flex; align-items: center; gap: 0.5rem; }
.card-head-main { flex: 1; min-width: 0; display: flex; align-items: baseline; justify-content: space-between; gap: 0.5rem; cursor: pointer; }
.card-grip, .card-toggle { flex: none; width: 1.9rem; height: 1.9rem; display: grid; place-items: center; padding: 0; border: 1px solid transparent;
  border-radius: 6px; background: none; color: var(--muted); cursor: pointer; }
.card-grip { cursor: grab; touch-action: none; }
.card-grip:hover, .card-toggle:hover { background: var(--soft3); color: var(--ink); }
.card-grip:focus-visible, .card-toggle:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.card-toggle::before { content: ""; width: 0.5rem; height: 0.5rem; border: solid currentColor; border-width: 0 2px 2px 0;
  transform: translateY(-2px) rotate(45deg); transition: transform 0.15s; }
.card.is-collapsed .card-toggle::before { transform: translateX(-1px) rotate(-45deg); }
.card.is-collapsed > :not(h2) { display: none; }
.card.is-collapsed > h2 { margin-bottom: 0; padding-bottom: 0; border-bottom: 0; }
.card.is-dragging { opacity: 0.6; outline: 2px dashed var(--accent); outline-offset: 2px; box-shadow: 0 8px 22px rgba(23, 33, 43, 0.18); }
body.is-card-dragging, body.is-card-dragging * { cursor: grabbing !important; user-select: none; }
.layout-bar { display: flex; flex-wrap: wrap; gap: 0.4rem 1rem; margin: 0.75rem 0 -0.25rem; font-size: 0.85rem; }
.layout-bar button { background: none; border: 0; padding: 0; font: inherit; color: var(--accent); cursor: pointer; text-decoration: underline; }
.layout-bar .layout-note { color: var(--muted); }

/* Photos settings: services that expand to show their credentials */
.svc-list { display: grid; gap: 0.4rem; }
.svc-row { display: flex; align-items: flex-start; gap: 0.6rem; }
.svc-row > input[type="radio"] { width: auto; margin: 0.55rem 0 0; flex: none; }
.svc-none { padding: 0.35rem 0; font-weight: 500; }
.svc { flex: 1; min-width: 0; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); }
.svc > summary { list-style: none; display: flex; align-items: center; gap: 0.6rem; padding: 0.45rem 0.7rem; cursor: pointer; border-radius: 8px; }
.svc > summary::-webkit-details-marker { display: none; }
.svc > summary::after { content: ""; margin-left: auto; width: 0.45rem; height: 0.45rem; border: solid var(--muted); border-width: 0 2px 2px 0;
  transform: translateY(-2px) rotate(45deg); transition: transform 0.15s; }
.svc[open] > summary::after { transform: translateY(1px) rotate(-135deg); }
.svc > summary:hover { background: var(--soft); }
.svc > summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.svc-body { padding: 0.4rem 0.8rem 0.9rem; border-top: 1px solid var(--line); }
.card-grip[hidden] { display: none; }

/* ===== v2.3.0: light / dark theme ===== */
.theme-toggle { display: inline-flex; align-items: center; justify-content: center; width: 2.1rem; height: 2.1rem; padding: 0;
  background: transparent; color: var(--header-link, #dfe7ef); border: 1px solid currentColor; border-radius: 50%; cursor: pointer; opacity: 0.85; }
.theme-toggle:hover, .theme-toggle:focus-visible { opacity: 1; color: var(--header-ink, #fff); }
.theme-toggle svg { width: 1.1rem; height: 1.1rem; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.theme-toggle svg { display: none; }
html[data-theme-pref="auto"] .theme-toggle .i-auto, html:not([data-theme-pref]) .theme-toggle .i-auto,
html[data-theme-pref="light"] .theme-toggle .i-sun, html[data-theme-pref="dark"] .theme-toggle .i-moon { display: block; }
.theme-float { position: fixed; top: 0.75rem; right: 0.75rem; z-index: 50; color: var(--ink); background: var(--surface); }
.theme-float:hover, .theme-float:focus-visible { color: var(--ink); }

html[data-theme="dark"] {
  color-scheme: dark;
  --paper: #11171d;
  --surface: #1a222b;
  --ink: #e6ebf0;
  --muted: #9dadbc;
  --line: #2f3b47;
  --line-strong: #4a5967;
  --soft: #212b35;
  --soft2: #26323f;
  --soft3: #2b3845;
  --danger: #ff8a80;
  --ok: #6fd18d;
  --tone: #b6c6d8;
  --tone-bg: #26323f;
}
html[data-theme="dark"] :focus-visible { outline-color: #8fbcf0; }
html[data-theme="dark"] .topbar { border-bottom: 1px solid rgba(255, 255, 255, 0.12); }
html[data-theme="dark"] .flash { background: #17301f; border-color: #2b5a39; }
html[data-theme="dark"] .flash.error { background: #3a1b19; border-color: #7a3430; }
html[data-theme="dark"] .btn.danger { border-color: #7a3430; }
html[data-theme="dark"] .btn.danger:hover { background: #3a1b19; }
html[data-theme="dark"] .figures .flag { border-color: #7a3430; }
html[data-theme="dark"] .recovery { border-color: #6b5420; background: #2a2414; }
html[data-theme="dark"] .callout.warn { background: #2e2810; color: #f0d98a; border-color: #6b5420; }
html[data-theme="dark"] .exempt-box, html[data-theme="dark"] .sms-ok-box { background: #251f3a; border-color: #4a3f78; }
html[data-theme="dark"] .exempt-box.invalid { border-color: #ff8a80; }
html[data-theme="dark"] input:disabled { background: var(--soft3); color: #7f8f9e; }
html[data-theme="dark"] .rel { background: var(--soft3); color: #c3ced9; }
html[data-theme="dark"] .rel.soon { background: #3a3012; color: #f0cf7a; }
html[data-theme="dark"] .rel.late { background: #3d1c1f; color: #ff9d96; }
html[data-theme="dark"] .instatus.stuck, html[data-theme="dark"] .ledger .owed { color: #ff9d96; }
html[data-theme="dark"] .ledger .clear { color: #6fd18d; }
html[data-theme="dark"] .act-dot { background: #6d7d8c; }
html[data-theme="dark"] .act-payment { background: #4fb774; }
html[data-theme="dark"] .act-inspection { background: #e08a4f; }
html[data-theme="dark"] .btn.pass { background: #2b8a4f; border-color: #2b8a4f; color: #fff; }
html[data-theme="dark"] .btn.pass:hover { background: #34a05d; border-color: #34a05d; }
html[data-theme="dark"] .btn.partial { background: #a8730a; border-color: #a8730a; color: #fff; }
html[data-theme="dark"] .btn.partial:hover { background: #c28510; border-color: #c28510; }
html[data-theme="dark"] .btn.fail { color: #fff; }
html[data-theme="dark"] .step-item.dragging { box-shadow: 0 6px 18px rgba(0, 0, 0, 0.6); }
html[data-theme="dark"] .addr-suggest, html[data-theme="dark"] .card.is-dragging { box-shadow: 0 8px 22px rgba(0, 0, 0, 0.6); }
html[data-theme="dark"] .addr-suggest li + li { border-top-color: var(--line); }

/* status colors in dark mode (brand step colors are added by the generated theme stylesheet) */
html[data-theme="dark"] .s-applied     { --tone: #b6c6d8; --tone-bg: #26323f; }
html[data-theme="dark"] .s-issued      { --tone: #9cc4f5; --tone-bg: #1c2f48; }
html[data-theme="dark"] .s-rough       { --tone: #f0cf7a; --tone-bg: #3a3012; }
html[data-theme="dark"] .s-insulation  { --tone: #f2b48a; --tone-bg: #3d2514; }
html[data-theme="dark"] .s-final       { --tone: #7fdcd5; --tone-bg: #12332f; }
html[data-theme="dark"] .s-closed      { --tone: #b4bcc4; --tone-bg: #2a3036; }
html[data-theme="dark"] .s-needs-input, html[data-theme="dark"] .p-not-paid, html[data-theme="dark"] .r-failed { --tone: #ff9d96; --tone-bg: #3d1c1f; }
html[data-theme="dark"] .p-partial, html[data-theme="dark"] .r-partial { --tone: #f0cf7a; --tone-bg: #3a3012; }
html[data-theme="dark"] .p-paid, html[data-theme="dark"] .r-passed { --tone: #7fdc9d; --tone-bg: #16311f; }
html[data-theme="dark"] .p-exempt { --tone: #c4b6f0; --tone-bg: #2c2548; }
html[data-theme="dark"] .r-scheduled { --tone: #9cc4f5; --tone-bg: #1c2f48; }
html[data-theme="dark"] .r-canceled { --tone: #b4bcc4; --tone-bg: #2a3036; }

/* ===== v2.3.2: header search ===== */
.hsearch { margin: 0; }
.hsearch input { width: 11rem; max-width: 100%; padding: 0.35rem 0.7rem; margin: 0; font: inherit; font-size: 0.9rem; border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.35); background: rgba(255, 255, 255, 0.12); color: var(--header-ink, #fff); transition: width 0.15s; }
.hsearch input::placeholder { color: var(--header-muted, #9fb1c3); }
.hsearch input:focus { width: 16rem; background: rgba(255, 255, 255, 0.2); outline-color: #fff; }
.search-clients { display: flex; flex-wrap: wrap; gap: 0.3rem 1rem; align-items: baseline; margin: 0 0 1rem; font-size: 0.95rem; }
@media (max-width: 700px) { .hsearch { order: 5; flex: 1 1 100%; } .hsearch input, .hsearch input:focus { width: 100%; } }

/* ===== v2.3.3: upload progress ===== */
.upload-progress { margin: 0.5rem 0 0.8rem; }
.upload-progress[hidden] { display: none; }
.up-bar { height: 10px; border-radius: 999px; background: var(--soft3); overflow: hidden; border: 1px solid var(--line); }
.up-bar span { display: block; height: 100%; width: 0; background: var(--accent); transition: width 0.15s linear; }
.up-text { margin: 0.35rem 0 0; font-size: 0.88rem; color: var(--muted); }
.upload-progress.is-error .up-bar span { background: var(--danger); }
.upload-progress.is-error .up-text { color: var(--danger); font-weight: 600; }

/* ===== v2.5.0: client link ===== */
.share-main { max-width: 760px; margin: 0 auto; padding: 1.5rem 1rem 3rem; }
.share-brand { text-align: center; margin-bottom: 1rem; }
.share-hero { text-align: center; margin-bottom: 1rem; }
.share-hero h1 { font-size: 1.8rem; }
.share-hero .eyebrow { margin: 0 0 0.25rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; font-size: 0.8rem; font-weight: 700; }
.share-main .card { margin-bottom: 1rem; }
.share-list { list-style: none; margin: 0.6rem 0 0; padding: 0; display: grid; gap: 0.5rem; }
.share-contact { text-align: center; color: var(--muted); }
.sharepage .theme-float { position: fixed; }
.share-new { flex-wrap: wrap; margin: 0.6rem 0; }
.share-row { border-top: 1px solid var(--line); padding: 0.7rem 0 0.2rem; margin-top: 0.7rem; display: grid; gap: 0.4rem; }
.share-row input[type="text"] { width: 100%; font-size: 0.85rem; }
.share-row.is-off { opacity: 0.7; }
.share-row .hint { margin: 0; }

/* ===== v2.6.0: photo tags and captions ===== */
.media-item[hidden] { display: none; }
.tag-pick { display: inline-flex; align-items: center; gap: 0.35rem; font-size: 0.9rem; font-weight: 600; margin: 0; }
.tag-pick select { width: auto; margin: 0; padding: 0.25rem 0.4rem; }
.media-filter { display: flex; flex-wrap: wrap; gap: 0.4rem; margin: 0.4rem 0 0.8rem; }
.media-filter button { font: inherit; font-size: 0.85rem; font-weight: 600; padding: 0.25rem 0.8rem; border-radius: 999px; cursor: pointer;
  background: var(--surface); color: var(--ink); border: 1px solid var(--line-strong); }
.media-filter button[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--on-accent, #fff); }
.tag-badge { display: inline-block; align-self: start; font-size: 0.72rem; font-weight: 800; letter-spacing: 0.05em; text-transform: uppercase;
  padding: 0.1rem 0.5rem; border-radius: 999px; background: var(--tone-bg); color: var(--tone); }
.tag-badge.t-before { --tone: #7a5200; --tone-bg: #fbebc8; }
.tag-badge.t-during { --tone: #1e4f8f; --tone-bg: #d9e7f8; }
.tag-badge.t-after { --tone: #1f6b3a; --tone-bg: #dcf0e2; }
html[data-theme="dark"] .tag-badge.t-before { --tone: #f0cf7a; --tone-bg: #3a3012; }
html[data-theme="dark"] .tag-badge.t-during { --tone: #9cc4f5; --tone-bg: #1c2f48; }
html[data-theme="dark"] .tag-badge.t-after { --tone: #7fdc9d; --tone-bg: #16311f; }
.media-caption { font-size: 0.85rem; color: var(--muted); overflow-wrap: anywhere; }
.media-edit { font-size: 0.85rem; }
.media-edit summary { cursor: pointer; color: var(--accent); font-weight: 600; }
.media-meta-form { display: grid; gap: 0.35rem; margin-top: 0.35rem; }
.media-meta-form select, .media-meta-form input { width: 100%; margin: 0; }

/* ===== v2.7.0: home-screen app ===== */
.howto-list { margin: 0.5rem 0 0.8rem; padding-left: 1.2rem; display: grid; gap: 0.35rem; }
.btn[hidden] { display: none; }
@media (display-mode: standalone) { .topbar { padding-top: max(0.6rem, env(safe-area-inset-top)); } main { padding-bottom: max(4rem, env(safe-area-inset-bottom)); } }

.media-cap .media-actions { display: flex; flex-wrap: wrap; gap: 0.15rem 0.8rem; align-items: baseline; }
.media-cap .media-actions form { display: inline; }
