:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-2: #f0f2f5;
  --border: #dfe3e8;
  --text: #1c2430;
  --muted: #5f6b7a;
  --accent: #d9631e;
  --accent-ink: #ffffff;
  --accent-soft: #fbeadf;
  --ok: #1f7a4d;
  --warn: #a15c00;
  --bad: #b3261e;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 1px 3px rgba(16, 24, 40, .06);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #11151b;
    --surface: #181e26;
    --surface-2: #202833;
    --border: #2d3744;
    --text: #e6eaf0;
    --muted: #9aa6b5;
    --accent: #f0813f;
    --accent-ink: #1a0d04;
    --accent-soft: #3a2416;
    --ok: #4cc28a;
    --warn: #e0a64a;
    --bad: #f07a72;
    --shadow: none;
  }
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
}
.wrap { max-width: 1180px; margin: 0 auto; padding: 0 16px; }
h1, h2, h3 { line-height: 1.25; margin: 0; }
h2 { font-size: 1.15rem; display: flex; align-items: center; gap: 10px; }
h3 { font-size: 1rem; }
.muted { color: var(--muted); }
small { color: var(--muted); }

.topbar { background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 10; }
.topbar-inner { display: flex; align-items: center; justify-content: space-between; height: 56px; gap: 16px; }
.brand { display: flex; align-items: center; gap: 8px; font-size: 1.1rem; }
.brand b { color: var(--accent); }
.brand svg { width: 24px; height: 24px; fill: var(--accent); }
.topnav { display: flex; gap: 18px; overflow-x: auto; }
.topnav a { color: var(--muted); text-decoration: none; font-weight: 500; white-space: nowrap; }
.topnav a:hover { color: var(--text); }

.hero { padding: 32px 0 20px; max-width: 760px; }
.hero h1 { font-size: clamp(1.6rem, 3.5vw, 2.2rem); letter-spacing: -.01em; }
.hero p { color: var(--muted); margin: 10px 0 0; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  margin-bottom: 20px;
  display: flex; flex-direction: column; gap: 14px;
}
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.grid-2 > *, .acct-grid > * { min-width: 0; } /* let wide tables scroll inside their column */
section.grid-2 > .card { margin-bottom: 0; }
section.grid-2 { margin-bottom: 20px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.step {
  display: inline-grid; place-items: center; min-width: 26px; height: 26px; padding: 0 6px;
  border-radius: 99px; background: var(--accent); color: var(--accent-ink); font-size: .8rem; font-weight: 700;
}
.step.alt { background: var(--surface-2); color: var(--muted); border: 1px solid var(--border); }

.dropzone {
  border: 2px dashed var(--border); border-radius: var(--radius); padding: 28px 16px;
  display: flex; flex-direction: column; align-items: center; gap: 8px; text-align: center;
  cursor: pointer; background: var(--surface-2); transition: border-color .15s, background .15s;
}
.dropzone:hover, .dropzone.over, .dropzone:focus-visible { border-color: var(--accent); background: var(--accent-soft); outline: none; }
.dropzone svg { width: 32px; height: 32px; stroke: var(--accent); fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.plan-preview { max-height: 220px; width: 100%; object-fit: contain; border-radius: 8px; border: 1px solid var(--border); background: #fff; }

.field { display: flex; flex-direction: column; gap: 4px; font-size: .85rem; color: var(--muted); font-weight: 500; }
.field.grow { flex: 1; }
.field.check { flex-direction: row; align-items: center; gap: 8px; color: var(--text); }
input, select, textarea {
  font: inherit; color: var(--text); background: var(--surface);
  border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; width: 100%; min-width: 0;
}
input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--accent); }
input[type="range"] { padding: 0; accent-color: var(--accent); }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }
textarea { resize: vertical; }
.field-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; }
.field-grid.wide { grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); }

.btn {
  font: inherit; font-weight: 600; cursor: pointer; border-radius: 8px; padding: 9px 16px;
  border: 1px solid var(--border); background: var(--surface-2); color: var(--text);
}
.btn:hover:not(:disabled) { border-color: var(--accent); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.primary:hover:not(:disabled) { filter: brightness(1.05); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.small { padding: 5px 12px; font-size: .85rem; }
.btn.icon { padding: 2px 8px; border: none; background: none; color: var(--muted); font-size: 1.1rem; }
.btn.icon:hover { color: var(--bad); }

.status { margin: 0; min-height: 1.2em; font-size: .9rem; color: var(--muted); }
.status.error { color: var(--bad); }
.status.ok { color: var(--ok); }
.status.busy::before {
  content: ""; display: inline-block; width: 12px; height: 12px; margin-right: 8px; vertical-align: -1px;
  border: 2px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.badge { font-size: .78rem; font-weight: 600; padding: 3px 10px; border-radius: 99px; background: var(--surface-2); border: 1px solid var(--border); }
.badge.high { color: var(--ok); }
.badge.medium { color: var(--warn); }
.badge.low { color: var(--bad); }
.ai-summary { margin: 0; padding: 12px 14px; background: var(--accent-soft); border-radius: 8px; }

.tables { gap: 20px; }
.table-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.table-scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th { text-align: left; font-weight: 600; color: var(--muted); font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; }
th, td { padding: 6px 8px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.edit-table input, .edit-table select { padding: 5px 8px; }
.edit-table td.num input { text-align: right; width: 80px; }
.prices-table td.num input { width: 100px; }

.assumptions { background: var(--surface-2); border-radius: 8px; padding: 10px 14px; }
.assumptions summary { cursor: pointer; font-weight: 600; }
.assumptions ul { margin: 8px 0 0; padding-left: 20px; color: var(--muted); }

.cladding { display: flex; }
.toggles { border: 1px solid var(--border); border-radius: 8px; padding: 10px 14px; margin: 0; }
.toggles legend { font-size: .85rem; color: var(--muted); font-weight: 500; padding: 0 4px; }
.chip-row { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 5px 12px; border-radius: 99px; border: 1px solid var(--border); cursor: pointer; font-size: .88rem; user-select: none; }
.chip:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }

.kpis { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.kpi { background: var(--surface-2); border-radius: 10px; padding: 14px 16px; display: flex; flex-direction: column; gap: 2px; }
.kpi span { color: var(--muted); font-size: .85rem; }
.kpi b { font-size: 1.5rem; font-variant-numeric: tabular-nums; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kpi:first-child b { color: var(--accent); }
.summary-table tbody tr { cursor: pointer; }
.summary-table tbody tr:hover td { background: var(--surface-2); }
.summary-table tfoot th { color: var(--text); font-size: .95rem; text-transform: none; border-bottom: none; }
.share { display: inline-flex; align-items: center; gap: 8px; justify-content: flex-end; width: 100%; }
.share i { display: inline-block; height: 8px; border-radius: 4px; background: var(--accent); opacity: .8; }

.details-list { display: flex; flex-direction: column; gap: 8px; }
.cat { border: 1px solid var(--border); border-radius: 10px; }
.cat > summary { display: flex; justify-content: space-between; gap: 12px; padding: 12px 14px; cursor: pointer; font-weight: 600; list-style: none; }
.cat > summary::-webkit-details-marker { display: none; }
.cat > summary::before { content: "▸"; color: var(--muted); margin-right: 4px; transition: transform .15s; }
.cat[open] > summary::before { transform: rotate(90deg); }
.cat > summary .name { flex: 1; }
.cat .table-scroll { padding: 0 14px 12px; }
.cat td .note { display: block; color: var(--muted); font-size: .8rem; }

.disclaimer { font-size: .82rem; color: var(--muted); margin: 0; }
.insights { border-top: 1px solid var(--border); padding-top: 16px; display: flex; flex-direction: column; gap: 10px; }
.insights-row { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; }
.insight-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.insight-block { background: var(--surface-2); border-radius: 10px; padding: 14px 16px; }
.insight-block h4 { margin: 0 0 8px; font-size: .95rem; }
.insight-block ul { margin: 0; padding-left: 18px; }
.insight-block li { margin-bottom: 6px; }
.tip b { display: block; }
.tip .save { color: var(--ok); font-weight: 600; font-size: .85rem; }

.location-info:empty, .gc-rates:empty { display: none; }
.location-info { padding: 10px 14px; background: var(--accent-soft); border-radius: 8px; }
.gc-rates { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; }
.gc-rates .kpi b { font-size: 1.15rem; }
.gc-rates .kpi small { white-space: normal; }
.summary-table tfoot td, .summary-table tfoot th { border-bottom: 1px solid var(--border); }
.summary-table tfoot .grand th { font-size: 1.05rem; color: var(--accent); border-bottom: none; }
.cat h4 { margin: 8px 0 4px; font-size: .85rem; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
.price-head { margin: 16px 0 6px; }

.prices-summary { display: flex; align-items: center; justify-content: space-between; gap: 12px; cursor: pointer; list-style: none; flex-wrap: wrap; }
.prices-summary::-webkit-details-marker { display: none; }
.prices-toolbar { display: flex; gap: 12px; margin: 14px 0 8px; }
.prices-toolbar input { max-width: 320px; }
.footer { color: var(--muted); font-size: .85rem; padding: 10px 16px 40px; }

@media (max-width: 820px) {
  .grid-2, .insight-grid { grid-template-columns: minmax(0, 1fr); }
  .kpis { grid-template-columns: 1fr; }
  .topnav { gap: 14px; font-size: .92rem; }
  .brand span { display: none; }
}

@media print {
  .topbar, #reminders, #directory, #subs .btn, #payments .btn, #start, #options, #prices, #township .btn, #projects .table-scroll, #projects .muted, .actions, .insights-row, .footer, .hero { display: none !important; }
  body { background: #fff; color: #000; }
  .card { box-shadow: none; border: none; padding: 0; }
  .cat { break-inside: avoid; }
  .cat > .table-scroll { display: block !important; }
}

/* Township tracker */
.actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
#township h3 { margin-top: 22px; }
#township .edit-table input[type="date"] { min-width: 130px; }
#township .edit-table td:first-child input { min-width: 200px; }
#township .table-scroll + .btn, #township .table-scroll + .actions { margin-top: 8px; }
.alerts { display: grid; gap: 6px; margin: 12px 0; }
.alerts:empty { display: none; }
.alert { padding: 8px 12px; border-radius: 8px; border: 1px solid var(--border); border-left: 4px solid var(--muted); background: var(--surface-2); font-size: .92rem; }
.alert.error { border-left-color: var(--bad); }
.alert.warn { border-left-color: var(--warn); }
.alert.info { border-left-color: var(--ok); }
select.st-passed, select.st-closed, select.st-resolved, select.st-issued, select.st-confirmed, select.st-done { color: var(--ok); font-weight: 600; }
select.st-failed, select.st-expired, select.st-open { color: var(--bad); font-weight: 600; }
select.st-scheduled, select.st-applied, select.st-asked, select.st-working { color: var(--warn); font-weight: 600; }

/* Projects */
#projectsTable tr.active td { background: var(--surface-2); }
#projectsTable td { vertical-align: middle; }
.pill { font-size: .78rem; font-weight: 600; padding: 2px 9px; border-radius: 99px; border: 1px solid var(--border); white-space: nowrap; }
.pill.st-won, .pill.st-complete { color: var(--ok); }
.pill.st-building { color: var(--warn); }
.pill.st-lost { color: var(--muted); }
#projectsTable .bad { color: var(--bad); font-weight: 600; }
#projectsTable .warn { color: var(--warn); font-weight: 600; }

/* Reminders & subs */
.reminder-list { display: grid; gap: 8px; margin: 12px 0; }
.reminder { display: flex; gap: 10px 14px; align-items: center; justify-content: space-between; flex-wrap: wrap;
  padding: 10px 12px; border: 1px solid var(--border); border-left: 4px solid var(--muted); border-radius: 8px; background: var(--surface-2); }
.reminder.error { border-left-color: var(--bad); }
.reminder.warn { border-left-color: var(--warn); }
.reminder.info { border-left-color: var(--ok); }
.reminder .r-text { flex: 1 1 320px; font-size: .93rem; }
.reminder .r-proj { display: block; font-size: .78rem; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
.reminder .actions .btn { text-decoration: none; }
.reminder-empty { padding: 12px; color: var(--muted); }
.email-settings { margin-top: 8px; }
.email-settings summary { cursor: pointer; font-weight: 600; }
.email-settings .insights-row { margin-top: 10px; }
#subsTable td:first-child input { min-width: 150px; }
#subsTable input[type="date"] { min-width: 125px; }
#subsTable td.num input { width: 95px; }
#subsTable .vs { display: block; font-size: .75rem; color: var(--muted); text-align: right; white-space: nowrap; }
#subsTable .vs.over { color: var(--bad); }
#subsTable .vs.under { color: var(--ok); }
#subsTable .row-actions { display: flex; gap: 4px; }
#subsTable .row-actions a.btn { text-decoration: none; }
#subsTable [data-f="company"] { min-width: 170px; }
#subsTable [data-f="phone"] { min-width: 120px; }
#subsTable [data-f="email"] { min-width: 190px; }
#subsTable [data-f="notes"] { min-width: 180px; }
#subsTable select { min-width: 165px; }
#township > .btn, #subs > .actions, #township > .actions { align-self: flex-start; justify-self: start; width: auto; }

/* Subcontractor directory */
#dirTable [data-f="business"] { min-width: 180px; }
#dirTable [data-f="contact"] { min-width: 150px; }
#dirTable [data-f="phone"] { min-width: 120px; }
#dirTable [data-f="email"] { min-width: 190px; }
#dirTable [data-f="address"] { min-width: 190px; }
#dirTable [data-f="notes"] { min-width: 170px; }
#dirTable select { min-width: 150px; }
#dirTable input[type="date"] { min-width: 130px; }
.avail-cell { min-width: 220px; font-size: .85rem; }
.avail { display: block; }
.avail.free { color: var(--ok); font-weight: 600; }
.avail.busy { color: var(--bad); }
.jobs { display: flex; flex-wrap: wrap; gap: 4px; margin: 4px 0; }
.chip-sm { font-size: .75rem; padding: 1px 7px; border-radius: 99px; background: var(--surface-2); border: 1px solid var(--border); white-space: nowrap; }
.linkish { background: none; border: 0; padding: 2px 0; color: var(--accent); font: inherit; font-size: .78rem; font-weight: 600; cursor: pointer; }
.linkish:hover { text-decoration: underline; }
.dir-detail td { background: var(--surface-2); }
.timeoff { display: grid; gap: 6px; justify-items: start; }
.timeoff-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.timeoff-row input:not([type="date"]) { min-width: 220px; }
#subsTable .vs.linked { color: var(--ok); text-align: left; }
#subsTable .link-note, #subsTable .warn-note { display: block; }
#subsTable .warn-note .vs { text-align: left; white-space: normal; max-width: 220px; }
.dir-filter .field { min-width: 140px; }

/* Contract & payments */
.pay-badge { display: inline-block; font-size: .8rem; font-weight: 700; padding: 2px 10px; border-radius: 99px; border: 1px solid var(--border); white-space: nowrap; }
.pay-badge.paid { color: var(--ok); border-color: var(--ok); }
.pay-badge.unpaid { color: var(--warn); border-color: var(--warn); }
.pay-badge.partial { color: var(--warn); border-color: var(--warn); }
.pay-badge.overdue { color: #fff; background: var(--bad); border-color: var(--bad); }
#billKpis .ok { color: var(--ok); }
#billKpis .bad, #projectsTable .num .bad { color: var(--bad); font-weight: 600; }
#billNotes:empty { display: none; }
#payments > .btn, #payments > .actions { align-self: flex-start; }
#drawsTable [data-f="name"] { min-width: 220px; }
#drawsTable td.num input { width: 80px; }
#coTable [data-f="description"] { min-width: 260px; }
#coTable [data-f="number"] { width: 80px; }
#coTable td.num input, #paymentsTable td.num input { width: 110px; }
#coTable select { min-width: 120px; }
#paymentsTable select { min-width: 190px; }
#paymentsTable [data-f="note"] { min-width: 220px; }
select.st-approved { color: var(--ok); font-weight: 600; }
select.st-proposed { color: var(--warn); font-weight: 600; }
select.st-rejected { color: var(--muted); }

/* Accounts */
.topbar-right { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
#accountBtn { max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sync { font-size: .82rem; color: var(--muted); white-space: nowrap; }
.sync.saving { color: var(--muted); }
.sync.error, .sync.offline { color: var(--bad); font-weight: 600; }
.notices { display: flex; flex-direction: column; gap: 8px; margin-top: 16px; }
.notices:empty { display: none; }
.notice { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 14px; border-radius: 8px; background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--accent); }
.notice.ok { border-left-color: var(--ok); }
.notice.warn { border-left-color: var(--warn); }
.notice.error { border-left-color: var(--bad); }
.linklike { font: inherit; color: var(--accent); background: none; border: none; padding: 0; cursor: pointer; text-decoration: underline; font-weight: 600; }
.guest-note { margin: 0; padding: 10px 14px; background: var(--accent-soft); border-radius: 8px; }
.acct-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.acct-block { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; }
.acct-block p { margin: 0; }
.acct-block details { margin-top: 4px; }
.acct-block summary { cursor: pointer; font-weight: 600; }
.acct-block .note { display: block; color: var(--muted); font-size: .8rem; }
#account .warn { color: var(--warn); font-weight: 600; }
.btn.danger { color: var(--bad); border-color: var(--bad); }
.auth-dialog { border: 1px solid var(--border); border-radius: var(--radius); padding: 0; width: min(420px, calc(100vw - 32px)); background: var(--surface); color: var(--text); box-shadow: 0 10px 40px rgba(0, 0, 0, .25); }
.auth-dialog::backdrop { background: rgba(16, 24, 40, .45); }
.auth-dialog form { display: flex; flex-direction: column; gap: 12px; padding: 22px; }
[hidden] { display: none !important; }
.auth-dialog #authIntro { margin: 0; }
.auth-actions { display: flex; gap: 10px; }
.auth-links { margin: 0; font-size: .9rem; color: var(--muted); }
@media (max-width: 820px) {
  .acct-grid { grid-template-columns: 1fr; }
  .sync { display: none; }
}
a.btn { display: inline-block; text-decoration: none; align-self: flex-start; }
#account a:not(.btn) { color: var(--accent); }

/* Construction progress */
.build-progress { display: flex; flex-direction: column; gap: 8px; padding: 14px 16px; background: var(--surface-2); border-radius: 10px; }
.bp-head { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.bp-head b { font-size: 1.1rem; }
.bp-bar { display: flex; height: 18px; border-radius: 9px; overflow: hidden; background: var(--border); gap: 2px; }
.bp-bar > span { position: relative; background: var(--surface); min-width: 2px; }
.bp-bar i { display: block; height: 100%; }
.bp-bar i.done { background: var(--ok); }
.bp-bar i.working { background: var(--warn); }
.bp-bar.mini { height: 8px; border-radius: 4px; gap: 0; width: 80px; background: var(--surface-2); border: 1px solid var(--border); }
.bp-legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: .82rem; align-items: center; }
.bp-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 5px; vertical-align: -1px; background: var(--surface); border: 1px solid var(--border); }
.bp-legend i.done { background: var(--ok); border-color: var(--ok); }
.bp-legend i.working { background: var(--warn); border-color: var(--warn); }
.built-cell { display: flex; align-items: center; gap: 6px; font-size: .85rem; white-space: nowrap; }
.status-cell { display: flex; flex-direction: column; gap: 4px; }
.pct-input { display: flex; align-items: center; gap: 4px; font-size: .8rem; color: var(--muted); white-space: nowrap; }
.pct-input input { width: 64px; padding: 4px 6px; }
#projectsTable .note { display: block; color: var(--muted); font-size: .8rem; font-weight: 400; }

/* Plans and billing */
.plan-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; max-width: 720px; }
.plan-card { border: 1px solid var(--border); border-radius: 10px; padding: 16px; display: flex; flex-direction: column; gap: 8px; background: var(--surface); }
.plan-card.best { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.plan-card h4 { margin: 0; font-size: 1rem; }
.plan-price b { font-size: 1.6rem; }
.plan-price { color: var(--muted); }
.plan-card ul { margin: 0; padding-left: 18px; font-size: .9rem; }
.plan-card .btn { margin-top: auto; }
.interval-toggle { display: inline-flex; gap: 6px; }
.interval-toggle .btn.on { background: var(--accent-soft); border-color: var(--accent); }
.interval-toggle .save { font-size: .75rem; color: var(--ok); font-weight: 700; margin-left: 4px; }
.account-type { border: none; padding: 0; margin: 0; flex-direction: row; flex-wrap: wrap; gap: 6px 18px; }
.account-type legend { padding: 0; margin-bottom: 4px; width: 100%; }
.account-type label { display: flex; align-items: center; gap: 6px; color: var(--text); font-weight: 500; }
.account-type input { width: auto; }
.acct-block > small { color: var(--muted); }
.sync.readonly { color: var(--bad); font-weight: 600; }
.topnav { scrollbar-width: none; }
.topnav::-webkit-scrollbar { display: none; }

/* 3D view */
:root { --sky: #dbe9f4; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --sky: #1d2836; } }
.model-view { position: relative; height: 440px; border-radius: 10px; overflow: hidden; background: var(--sky); border: 1px solid var(--border); touch-action: none; }
.model-view canvas { display: block; width: 100%; height: 100%; cursor: grab; }
.model-view canvas:active { cursor: grabbing; }
.model-msg { margin: 0; padding: 24px; color: var(--muted); }
.small-print { font-size: .85rem; margin: 0; }
#model3d .step { min-width: 34px; }
@media (max-width: 820px) { .model-view { height: 320px; } }
.layout-fields { display: flex; flex-direction: column; gap: 8px; padding: 12px 14px; background: var(--surface-2); border-radius: 10px; }
.layout-fields h3 small { font-weight: 400; font-size: .85rem; }
.model-source { display: flex; flex-direction: column; gap: 10px; }
.drawings-upload { display: flex; flex-direction: column; gap: 6px; padding: 12px 14px; border: 1px dashed var(--border); border-radius: 10px; }
.drawings-upload p { margin: 0; }
.drawings-upload label.btn { display: inline-flex; align-items: center; }
.source-switch { display: flex; flex-wrap: wrap; gap: 6px 16px; align-items: center; font-weight: 500; }
.source-switch label { display: flex; align-items: center; gap: 6px; }
.source-switch input, .match-what input { width: auto; }
.model-compare { display: grid; grid-template-columns: 1fr; gap: 12px; }
.model-compare.with-thumbs { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
.drawing-thumbs { display: flex; flex-direction: column; gap: 8px; max-height: 440px; overflow-y: auto; }
.drawing-thumbs figure { margin: 0; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; background: #fff; }
.drawing-thumbs img { display: block; width: 100%; height: auto; cursor: zoom-in; }
.drawing-thumbs figcaption { font-size: .8rem; color: #555; padding: 4px 8px; }
.model-notes { margin: 0; padding-left: 18px; color: var(--muted); font-size: .88rem; }
.match-box { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; padding: 10px 14px; border-radius: 10px; background: var(--accent-soft); }
.match-what { display: flex; flex-wrap: wrap; gap: 6px 14px; align-items: center; width: 100%; }
.match-what label { display: flex; align-items: center; gap: 5px; font-size: .9rem; }
@media (max-width: 820px) { .model-compare.with-thumbs { grid-template-columns: 1fr; } .drawing-thumbs { flex-direction: row; overflow-x: auto; max-height: none; } .drawing-thumbs figure { min-width: 160px; } }
.layout-fields.dim { opacity: .55; }

/* Privacy policy and terms pages */
a.brand { color: inherit; text-decoration: none; }
.legal { max-width: 760px; padding-top: 28px; padding-bottom: 24px; }
.legal h1 { font-size: 1.7rem; margin-bottom: 4px; }
.legal h2 { font-size: 1.15rem; margin: 28px 0 8px; }
.legal h3 { font-size: 1rem; margin: 16px 0 6px; }
.legal p, .legal li { line-height: 1.6; }
.legal ul { padding-left: 22px; }
.legal li { margin: 4px 0; }
.legal a, .footer a { color: var(--accent); }
.legal code { background: var(--surface-2); padding: 1px 5px; border-radius: 4px; }
.legal .callout { background: var(--accent-soft); border-radius: var(--radius); padding: 12px 14px; }
mark.fill { background: #fff3a6; color: #3a2a00; padding: 0 3px; border-radius: 3px; }
.auth-legal { font-size: .85rem; margin: 4px 0 0; }
.auth-legal a { color: var(--accent); }

/* Scanned notes & documents */
.step-icon { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.scan-pick { align-items: center; }
.scan-review { border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; margin: 10px 0 4px; background: var(--surface-2); display: grid; gap: 10px; }
.scan-review h4 { margin: 4px 0 0; }
.scan-head { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.scan-head p { flex-basis: 100%; margin: 4px 0 0; }
.pill.conf-low { color: var(--bad); }
.pill.conf-medium { color: var(--warn); }
.pill.conf-high { color: var(--ok); }
.scan-unclear { border-left: 3px solid var(--warn); padding: 6px 10px; background: var(--surface); border-radius: 6px; }
.scan-unclear ul { margin: 4px 0 0; padding-left: 18px; }
.scan-changes { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.scan-changes label { display: flex; gap: 10px; align-items: flex-start; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; cursor: pointer; }
.scan-changes input { margin-top: 3px; }
.scan-changes label:has(input:checked) { border-color: var(--accent); }
.transcript { white-space: pre-wrap; font: .85rem/1.45 ui-monospace, Consolas, monospace; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 10px; max-height: 320px; overflow: auto; margin: 6px 0 0; }
.docs-head { margin-top: 18px; }
.chip.on { border-color: var(--accent); background: var(--accent-soft); }
button.chip { background: none; color: inherit; font: inherit; font-size: .88rem; }
.doc-list { display: grid; gap: 10px; margin-top: 8px; }
.doc { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 12px; border: 1px solid var(--border); border-radius: var(--radius); padding: 10px; align-items: start; }
.doc-files { display: flex; gap: 6px; flex-wrap: wrap; max-width: 220px; }
.doc-files img { width: 64px; height: 64px; object-fit: cover; border-radius: 6px; border: 1px solid var(--border); display: block; }
.doc-pdf { width: 64px; height: 64px; display: grid; place-items: center; text-align: center; border: 1px solid var(--border); border-radius: 6px; font-size: .75rem; font-weight: 700; text-decoration: none; color: var(--text); overflow: hidden; padding: 2px; }
.doc-pdf small { font-weight: 400; word-break: break-all; }
.doc-body h4 { margin: 0; }
.doc-body p { margin: 2px 0; }
.doc-body ul { margin: 4px 0; padding-left: 18px; }
.doc-link { margin: 0 0 8px; }
p.small, .small { font-size: .85rem; }
@media (max-width: 600px) {
  .doc { grid-template-columns: minmax(0, 1fr) auto; }
  .doc-files { grid-column: 1 / -1; max-width: none; }
}
@media print { #scan { display: none !important; } }
.scan-review .field-grid { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
@media (max-width: 600px) { .scan-review .field-grid { grid-template-columns: minmax(0, 1fr); } }

/* Views: the jobs dashboard, the open job's tabs, shared pages (views.js) */
.off { display: none !important; }
.topnav a.on { color: var(--accent); font-weight: 600; }
body.signed-in .hero { display: none; }
body.signed-in #projects { margin-top: 20px; }
body[data-view="job"] h2 > .step { display: none; }
.topnav .short { display: none; }
.job-bar { margin: 20px 0 16px; }
.job-bar-top { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.job-back { color: var(--muted); text-decoration: none; font-weight: 500; white-space: nowrap; }
.job-back:hover { color: var(--text); }
.job-title { flex: 1; min-width: 0; }
.job-title h2 { margin: 0; font-size: 1.45rem; letter-spacing: -.01em; overflow-wrap: anywhere; }
.job-title .muted { font-size: .9rem; }
.job-details { margin: 8px 0 0; }
.job-details > summary { cursor: pointer; color: var(--muted); font-size: .9rem; width: max-content; }
.job-details[open] { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 16px; }
.job-details .insights-row { margin-top: 10px; }
.job-tabs { display: flex; gap: 4px; margin-top: 14px; border-bottom: 1px solid var(--border); overflow-x: auto; scrollbar-width: none; }
.job-tabs a { padding: 10px 14px; color: var(--muted); text-decoration: none; font-weight: 600; white-space: nowrap; border-bottom: 3px solid transparent; margin-bottom: -1px; }
.job-tabs a:hover { color: var(--text); }
.job-tabs a.on { color: var(--accent); border-bottom-color: var(--accent); }
.stepper { display: flex; gap: 6px; list-style: none; padding: 0; margin: 14px 0 0; overflow-x: auto; scrollbar-width: none; counter-reset: step; }
.stepper li { flex: 1; min-width: max-content; }
.stepper a { display: flex; align-items: center; gap: 8px; padding: 8px 12px; border-radius: 99px; color: var(--muted); text-decoration: none; font-weight: 500; font-size: .92rem; background: var(--surface-2); counter-increment: step; }
.stepper a::before { content: counter(step); display: grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; border: 1.5px solid currentColor; font-size: .78rem; font-weight: 700; flex: none; }
.stepper a.on { background: var(--accent); color: var(--accent-ink); }
.stepper a.on::before { border-color: var(--accent-ink); }
.step-nav { display: flex; justify-content: space-between; gap: 12px; margin: 4px 0 24px; }
.step-nav #stepNext { margin-left: auto; }
@media (max-width: 820px) {
  .stepper a { padding: 6px 10px; }
  .topnav .long { display: none; }
  .topnav .short { display: inline; }
  #navAccount { display: none; } /* the name button opens the account */
  .job-tabs a { padding: 10px 10px; }
}

/* Jobs list on a phone: one card per job instead of a wide table */
@media (max-width: 640px) {
  #projectsTable thead { display: none; }
  #projectsTable, #projectsTable tbody { display: block; }
  #projectsTable tbody tr { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px 12px; padding: 14px 4px; border-bottom: 1px solid var(--border); }
  #projectsTable td { border: 0; padding: 0; text-align: left; }
  #projectsTable td[data-label]::before { content: attr(data-label); display: block; font-size: .7rem; font-weight: 600; letter-spacing: .03em; text-transform: uppercase; color: var(--muted); }
  #projectsTable .pc-name { grid-column: 1 / 3; }
  #projectsTable .pc-status { grid-column: 3; justify-self: end; }
  #projectsTable .pc-addr { grid-column: 1 / -1; color: var(--muted); font-size: .9rem; margin-top: -6px; }
  #projectsTable .pc-hide { display: none; }
  #projectsTable .pc-open { grid-column: 1 / -1; }
  #projectsTable .pc-open .btn { width: 100%; }
  #projectsTable tbody tr.active td { background: transparent; }
}
