/* ==========================================================================
   City Summon design system
   One stylesheet shared by the public site, portal, CAD, MDT and admin.
   Brand colors are placeholders: change the tokens below once branding is final.
   ========================================================================== */

:root {
    /* Brand */
    --brand: #0f2742;          /* deep navy */
    --brand-600: #163a61;
    --brand-contrast: #ffffff;
    --accent: #f97316;         /* safety orange */
    --accent-600: #ea580c;
    --accent-contrast: #111827;

    /* Neutrals (light theme) */
    --bg: #f4f6f9;
    --surface: #ffffff;
    --surface-2: #eef1f5;
    --border: #d8dee6;
    --text: #1b2430;
    --text-muted: #5b6676;

    /* Status */
    --success: #15803d;  --success-bg: #e7f6ec;
    --warning: #b45309;  --warning-bg: #fdf3e2;
    --danger:  #b91c1c;  --danger-bg:  #fdeaea;
    --info:    #1d4ed8;  --info-bg:    #e8efff;

    /* Shape & type */
    --radius: 10px;
    --radius-sm: 6px;
    --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .10);
    --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    --focus: 0 0 0 3px rgba(249, 115, 22, .45);

    --topbar-h: 56px;
    --sidebar-w: 232px;

    color-scheme: light;
}

/* Dark theme: follows the device unless the user picked one (data-theme on <html>). */
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --bg: #0b1320; --surface: #121c2b; --surface-2: #192536; --border: #2a3a50;
        --text: #e6ebf2; --text-muted: #9aa8bb;
        --brand-600: #2a5486;
        --success-bg: #0f2a1b; --warning-bg: #2e2110; --danger-bg: #301416; --info-bg: #13213f;
        --success: #4ade80; --warning: #fbbf24; --danger: #f87171; --info: #93b4ff;
        color-scheme: dark;
    }
}
:root[data-theme="dark"] {
    --bg: #0b1320; --surface: #121c2b; --surface-2: #192536; --border: #2a3a50;
    --text: #e6ebf2; --text-muted: #9aa8bb;
    --brand-600: #2a5486;
    --success-bg: #0f2a1b; --warning-bg: #2e2110; --danger-bg: #301416; --info-bg: #13213f;
    --success: #4ade80; --warning: #fbbf24; --danger: #f87171; --info: #93b4ff;
    color-scheme: dark;
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 16px/1.55 var(--font); color: var(--text); background: var(--bg); }
img, svg { max-width: 100%; }
/* The hidden attribute always wins, even over components that set their own display. */
[hidden] { display: none !important; }
a { color: var(--brand-600); }
:root[data-theme="dark"] a, .app a:not(.btn):not(.nav-link) { color: inherit; }
h1, h2, h3, h4, h5 { line-height: 1.25; margin: 0 0 .5em; }
h1, .h1 { font-size: 1.9rem; } h2, .h2 { font-size: 1.5rem; } h3, .h3 { font-size: 1.25rem; }
.h4 { font-size: 1.1rem; } .h5 { font-size: 1rem; }
p { margin: 0 0 1em; }
code, pre { font-family: var(--mono); font-size: .9em; }
pre.code, pre.debug { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: .75rem 1rem; overflow-x: auto; white-space: pre-wrap; word-break: break-all; }
:focus-visible { outline: none; box-shadow: var(--focus); border-radius: 4px; }
.skip-link { position: absolute; left: -999px; top: 0; background: var(--accent); color: var(--accent-contrast); padding: .5rem 1rem; z-index: 100; }
.skip-link:focus { left: 1rem; }

/* ---------- Utilities ---------- */
.container { width: 100%; max-width: 1120px; margin: 0 auto; padding: 0 1.25rem; }
.muted { color: var(--text-muted); }
.small { font-size: .875rem; }
.text-center { text-align: center; }
.text-accent { color: var(--accent); }
.text-warning { color: var(--warning); }
.mt-3 { margin-top: 1rem; } .mt-4 { margin-top: 1.5rem; }
.grid { display: grid; gap: 1rem; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(min(260px, 100%), 1fr)); }
.grid-4 { grid-template-columns: repeat(auto-fit, minmax(min(170px, 100%), 1fr)); }

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
    min-height: 42px; padding: .5rem 1.1rem; border-radius: var(--radius-sm);
    border: 1px solid transparent; font: 600 .95rem/1 var(--font); text-decoration: none;
    cursor: pointer; transition: background-color .15s, border-color .15s, color .15s;
    background: var(--surface-2); color: var(--text);
}
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--brand); color: var(--brand-contrast); }
.btn-primary:hover { background: var(--brand-600); }
:root[data-theme="dark"] .btn-primary { background: var(--brand-600); }
.btn-accent { background: var(--accent); color: var(--accent-contrast); }
.btn-accent:hover { background: var(--accent-600); }
.btn-outline { background: transparent; border-color: var(--border); color: var(--text); }
.btn-outline:hover { background: var(--surface-2); }
.btn-outline-light { background: transparent; border-color: rgba(255,255,255,.55); color: #fff; }
.btn-outline-light:hover { background: rgba(255,255,255,.1); }
.btn-ghost { background: transparent; color: inherit; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-sm { min-height: 34px; padding: .35rem .75rem; font-size: .85rem; }
.btn-lg { min-height: 52px; padding: .75rem 1.5rem; font-size: 1.05rem; }
.btn-block { width: 100%; }

/* ---------- Forms ---------- */
.form { display: grid; gap: 1rem; }
.field { display: grid; gap: .35rem; }
.field label { font-weight: 600; font-size: .92rem; }
.field input, .field select, .field textarea {
    width: 100%; min-height: 44px; padding: .55rem .75rem; font: inherit; color: var(--text);
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm);
}
.field input:focus, .field select:focus, .field textarea:focus { outline: none; border-color: var(--accent); box-shadow: var(--focus); }
.field .hint { margin: 0; font-size: .82rem; color: var(--text-muted); }
.field.has-error input { border-color: var(--danger); }
.field .error { margin: 0; font-size: .82rem; color: var(--danger); }

/* ---------- Cards, tables, badges, alerts ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.25rem; }
.card-header { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: .75rem; }
.card-header h2 { margin: 0; }
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: .92rem; }
.table th, .table td { text-align: left; padding: .6rem .75rem; border-bottom: 1px solid var(--border); }
.table th { font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--text-muted); }
.badge { display: inline-block; padding: .15rem .5rem; border-radius: 999px; font-size: .75rem; font-weight: 700; background: var(--surface-2); color: var(--text-muted); }
.badge-accent { background: var(--accent); color: var(--accent-contrast); }
.badge-success { background: var(--success-bg); color: var(--success); }
.badge-warning { background: var(--warning-bg); color: var(--warning); }
.badge-danger { background: var(--danger-bg); color: var(--danger); }
.alert { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; padding: .8rem 1rem; border-radius: var(--radius-sm); margin-bottom: 1rem; border: 1px solid transparent; }
.alert-success { background: var(--success-bg); color: var(--success); border-color: currentColor; }
.alert-error   { background: var(--danger-bg);  color: var(--danger);  border-color: currentColor; }
.alert-info    { background: var(--info-bg);    color: var(--info);    border-color: currentColor; }
.alert-warning { background: var(--warning-bg); color: var(--warning); border-color: currentColor; }
.alert a { color: inherit; font-weight: 700; }
.alert-close { background: none; border: 0; font-size: 1.3rem; line-height: 1; cursor: pointer; color: inherit; padding: 0 .25rem; }

.stat { display: grid; gap: .25rem; }
.stat-label { font-size: .85rem; color: var(--text-muted); }
.stat-value { font-size: 2rem; font-weight: 800; }
.kv { display: grid; grid-template-columns: fit-content(45%) minmax(0, 1fr); gap: .4rem 1rem; margin: 0; }
.kv dt { color: var(--text-muted); } .kv dd { margin: 0; font-weight: 600; }

.checklist { list-style: none; padding: 0; margin: 0; display: grid; gap: .4rem; }
.checklist li::before { content: "✓"; color: var(--accent); font-weight: 800; margin-right: .5rem; }
.roadmap { margin: 0; padding-left: 1.25rem; display: grid; gap: .3rem; }
.roadmap .is-done { color: var(--success); font-weight: 700; }
.roadmap .is-done::after { content: " ✓"; }

/* System / installer checks */
.check-list { list-style: none; padding: 0; margin: 0; border: 1px solid var(--border); border-radius: var(--radius-sm); }
.check-list li { display: grid; grid-template-columns: 1.5rem minmax(0, 1fr) minmax(0, 1.2fr); gap: .5rem; align-items: center; padding: .5rem .75rem; border-bottom: 1px solid var(--border); font-size: .9rem; }
.check-list li:last-child { border-bottom: 0; }
.check-icon { font-weight: 800; text-align: center; }
.check-detail { color: var(--text-muted); font-size: .85rem; }
.check-list .is-ok .check-icon { color: var(--success); }
.check-list .is-fail { background: var(--danger-bg); } .check-list .is-fail .check-icon { color: var(--danger); }
.check-list .is-warn .check-icon { color: var(--warning); }
@media (max-width: 640px) { .check-list li { grid-template-columns: 1.5rem minmax(0, 1fr); } .check-detail { grid-column: 2; } }

/* ---------- Public site ---------- */
.site-header { background: var(--brand); color: #fff; }
.site-header-inner { display: flex; align-items: center; justify-content: space-between; gap: 1rem; min-height: 64px; flex-wrap: wrap; }
.site-brand { color: #fff; text-decoration: none; }
.site-nav { display: flex; align-items: center; gap: 1.1rem; flex-wrap: wrap; }
.site-nav a:not(.btn) { color: #fff; text-decoration: none; font-weight: 600; opacity: .9; }
.site-nav a:not(.btn):hover { opacity: 1; text-decoration: underline; }
.site-nav .btn-outline { color: #fff; border-color: rgba(255,255,255,.55); }
.hero { background: linear-gradient(135deg, var(--brand) 0%, #1c4a7a 100%); color: #fff; padding: 4.5rem 0 4rem; }
.hero-title { font-size: clamp(2.1rem, 5vw, 3.3rem); font-weight: 800; }
.hero-lead { font-size: 1.15rem; max-width: 40rem; opacity: .92; }
.hero-actions { display: flex; flex-wrap: wrap; gap: .75rem; margin: 1.5rem 0 .75rem; }
.hero-note { opacity: .75; }
.eyebrow { text-transform: uppercase; letter-spacing: .12em; font-size: .8rem; font-weight: 700; color: var(--accent); margin-bottom: .5rem; }
.section { padding: 3.5rem 0; }
.section-alt { background: var(--surface-2); }
.section-title { font-size: 1.7rem; margin-bottom: 1.25rem; }
.service-card h3 { color: inherit; }
.site-footer { border-top: 1px solid var(--border); padding: 1.5rem 0; font-size: .9rem; }
.site-footer-inner { display: flex; justify-content: space-between; flex-wrap: wrap; gap: .5rem; }
.site-footer p { margin: 0; }

/* Logo */
.logo { display: inline-flex; align-items: center; gap: .55rem; font-size: 1.15rem; color: inherit; }
.logo-mark { width: 32px; height: 32px; color: var(--brand); flex: none; }
.site-header .logo-mark, .app-topbar .logo-mark { color: rgba(255,255,255,.12); }
.logo-text strong { color: var(--accent); font-weight: 800; }

/* ---------- Auth pages ---------- */
.auth-wrap { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 2rem 1rem; gap: 1rem; }
.auth-brand { text-decoration: none; color: var(--text); margin-bottom: .5rem; }
.auth-card { width: 100%; max-width: 420px; }
.auth-card-wide { max-width: 760px; }
.auth-wrap > .alert { width: 100%; max-width: 420px; }
.auth-footer { font-size: .85rem; }
.error-code { font-size: 3.5rem; font-weight: 800; color: var(--accent); margin: 0; }

/* ---------- App shell (admin, CAD, MDT, portal) ---------- */
.app-shell { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); grid-template-rows: var(--topbar-h) 1fr; min-height: 100vh; }
.app-shell.no-sidebar { grid-template-columns: minmax(0, 1fr); }
.app-topbar { grid-column: 1 / -1; display: flex; align-items: center; gap: 1rem; padding: 0 1rem; background: var(--brand); color: #fff; position: sticky; top: 0; z-index: 10; }
.app-brand { display: flex; align-items: center; gap: .75rem; color: #fff; text-decoration: none; }
.app-name { font-size: .8rem; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; padding: .15rem .5rem; border: 1px solid rgba(255,255,255,.35); border-radius: 999px; }
.app-switcher { display: flex; gap: .25rem; margin-left: 1rem; }
.app-switcher a { color: rgba(255,255,255,.8); text-decoration: none; font-size: .88rem; font-weight: 600; padding: .35rem .7rem; border-radius: var(--radius-sm); }
.app-switcher a:hover { background: rgba(255,255,255,.1); color: #fff; }
.app-switcher a.is-active { background: rgba(255,255,255,.16); color: #fff; }
.app-user { margin-left: auto; display: flex; align-items: center; gap: .75rem; }
.app-user form { margin: 0; }
.app-user .btn-outline { color: #fff; border-color: rgba(255,255,255,.45); }
.app-user .btn-outline:hover { background: rgba(255,255,255,.1); }
.app-user-name { font-size: .9rem; font-weight: 600; color: #fff !important; text-decoration: none; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 14rem; }
.app-user-name:hover, .app-user-name[aria-current] { text-decoration: underline; }
.fs-toggle { display: inline-flex; align-items: center; justify-content: center; }
.fs-toggle .fs-exit, .fs-toggle[aria-pressed="true"] .fs-enter { display: none; }
.fs-toggle[aria-pressed="true"] .fs-exit { display: block; }
.app-sidebar { background: var(--surface); border-right: 1px solid var(--border); padding: 1rem .75rem; }
.app-sidebar nav { display: grid; gap: .15rem; position: sticky; top: calc(var(--topbar-h) + 1rem); }
.nav-link { display: flex; align-items: center; justify-content: space-between; padding: .5rem .75rem; border-radius: var(--radius-sm); color: var(--text); text-decoration: none; font-weight: 600; font-size: .93rem; }
.nav-link:hover { background: var(--surface-2); }
.nav-link.is-active { background: var(--brand); color: #fff; }
:root[data-theme="dark"] .nav-link.is-active { background: var(--brand-600); }
.nav-link.is-disabled { color: var(--text-muted); cursor: default; font-weight: 500; }
.nav-link.is-disabled:hover { background: none; }
.app-main { padding: 1.5rem; min-width: 0; }
.page-header { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: .75rem; margin-bottom: 1.25rem; }
.page-header h1 { margin: 0; font-size: 1.6rem; }

@media (max-width: 860px) {
    .app-shell { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto auto 1fr; }
    .app-topbar { flex-wrap: wrap; padding: .5rem 1rem; }
    .app-switcher { order: 3; width: 100%; margin: 0; overflow-x: auto; }
    .app-user-name { max-width: 8rem; }
    .app-sidebar { border-right: 0; border-bottom: 1px solid var(--border); padding: .5rem; }
    .app-sidebar nav { position: static; display: flex; overflow-x: auto; }
    .nav-link { white-space: nowrap; }
    .nav-link.is-disabled { display: none; }
    .app-main { padding: 1rem; }
}

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

/* Toasts */
.toast-host { position: fixed; right: 1rem; bottom: 1rem; z-index: 50; display: grid; gap: .5rem; max-width: min(92vw, 380px); }
.toast-host .alert { margin: 0; box-shadow: var(--shadow); }

/* ---------- Phase 1: accounts & admin ---------- */
.narrow { max-width: 640px; }
.stack { display: grid; gap: 1rem; align-content: start; }
.stack form { margin: 0; }
.align-start { align-items: start; }
.grid-sidebar { grid-template-columns: minmax(0, 2fr) minmax(min(260px, 100%), 1fr); }
@media (max-width: 960px) { .grid-sidebar { grid-template-columns: minmax(0, 1fr); } }
.nowrap { white-space: nowrap; }
.label, .field .label { font-weight: 600; font-size: .92rem; }
.label-row { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; }
.breadcrumb { margin: 0 0 .15rem; font-size: .85rem; color: var(--text-muted); }
.breadcrumb a { color: inherit; }
.auth-card-mid { max-width: 560px; }
.auth-wrap > .alert { max-width: 560px; }
fieldset.form { border: 0; padding: 0; margin: 0; min-width: 0; }

/* Honeypot field: hidden from people, visible to naive bots */
.hp { position: absolute !important; left: -10000px; width: 1px; height: 1px; overflow: hidden; }

/* Checkboxes with text */
.check { display: flex; gap: .6rem; align-items: flex-start; cursor: pointer; font-size: .95rem; }
.check input { width: 1.15rem; height: 1.15rem; margin-top: .2rem; flex: none; accent-color: var(--brand-600); }
.check-setting { padding: .75rem; border: 1px solid var(--border); border-radius: var(--radius-sm); }
.role-groups { display: grid; gap: .75rem; }
.role-group { display: grid; gap: .45rem; }
.role-group p { margin: 0; text-transform: uppercase; letter-spacing: .05em; font-size: .75rem; }

/* 2FA */
.input-code { font: 600 1.5rem/1 var(--mono) !important; letter-spacing: .3em; text-align: center; }
.secret-key { font: 700 1.25rem/1.4 var(--mono); letter-spacing: .08em; background: var(--surface-2); border: 1px dashed var(--border); border-radius: var(--radius-sm); padding: .75rem 1rem; text-align: center; word-break: break-all; user-select: all; }
.steps { padding-left: 1.25rem; display: grid; gap: 1.25rem; margin: 0; }
.steps ul { padding-left: 1.1rem; margin: .5rem 0; display: grid; gap: .35rem; }
.recovery-codes { list-style: none; padding: 0; margin: 1rem 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .5rem; }
.recovery-codes code { display: block; text-align: center; font-size: 1.05rem; padding: .5rem; background: var(--surface-2); border-radius: var(--radius-sm); }
.button-row { display: flex; gap: .75rem; flex-wrap: wrap; }
.form-inline-card { align-content: end; }
.temp-password { border-color: var(--accent); }

/* Lists & tables */
.filters { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(170px, 100%), 1fr)); gap: .75rem 1rem; align-items: end; }
.filters-actions { display: flex; gap: .5rem; }
.table-hover tbody tr:hover { background: var(--surface-2); }
.table a { color: inherit; }
.pagination { display: flex; align-items: center; justify-content: center; gap: 1rem; padding-top: 1rem; }
.matrix td, .matrix th { vertical-align: middle; }
.matrix input { width: 1.15rem; height: 1.15rem; accent-color: var(--brand-600); }
.matrix thead th { position: sticky; top: 0; background: var(--surface); }
.activity { list-style: none; padding: 0; margin: 0; display: grid; gap: .5rem; }
.activity li { display: grid; gap: .1rem; }
details summary { cursor: pointer; color: var(--brand-600); }
:root[data-theme="dark"] details summary { color: var(--text); }

@media print {
    .app-topbar, .app-sidebar, .button-row, .alert-close { display: none !important; }
    .app-shell { display: block; }
    body { background: #fff; color: #000; }
    .card { box-shadow: none; border: 1px solid #999; }
}

/* ---------- Phase 2: catalog, maps, public pages ---------- */
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); border: 0; }
.text-right { text-align: right; }
.prewrap { white-space: pre-wrap; }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(min(240px, 100%), 1fr)); }
.narrow-wide { max-width: 860px; }
.card-flush { padding: 0; overflow: hidden; }
.card-link { text-decoration: none; color: inherit; transition: border-color .15s, transform .15s; display: grid; gap: .4rem; align-content: start; }
.card-link:hover { border-color: var(--accent); transform: translateY(-1px); }
.badges { display: flex; flex-wrap: wrap; gap: .35rem; }
.search-row { display: flex; gap: .5rem; flex-wrap: wrap; }
.search-row input { flex: 1 1 260px; min-height: 42px; padding: .5rem .75rem; font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); }
.check-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(200px, 100%), 1fr)); gap: .45rem 1rem; }
.input-prefix { display: flex; align-items: stretch; }
.input-prefix span { display: grid; place-items: center; padding: 0 .65rem; background: var(--surface-2); border: 1px solid var(--border); border-right: 0; border-radius: var(--radius-sm) 0 0 var(--radius-sm); color: var(--text-muted); }
.input-prefix input { border-radius: 0 var(--radius-sm) var(--radius-sm) 0 !important; min-height: 44px; padding: .55rem .75rem; font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border); width: 100%; }
.code-input { width: 100%; font: .85rem/1.4 var(--mono); padding: .5rem; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); color: var(--text); }
.swatch { display: inline-block; width: .9rem; height: .9rem; border-radius: 3px; vertical-align: middle; background: var(--border); border: 1px solid rgba(0,0,0,.15); }
.service-line-title { display: flex; align-items: center; gap: .6rem; }
.service-line-title h2 { margin: 0; }

/* Sidebar groups */
.nav-heading { display: block; margin: .9rem .75rem .25rem; font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--text-muted); }
@media (max-width: 860px) { .nav-heading { display: none; } }

/* Tabs */
.tabs { display: flex; gap: .25rem; flex-wrap: wrap; border-bottom: 1px solid var(--border); }
.tabs a { padding: .5rem .8rem; text-decoration: none; color: var(--text-muted); font-weight: 600; font-size: .92rem; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs a.is-active { color: var(--text); border-bottom-color: var(--accent); }

/* Maps */
.map { width: 100%; height: 360px; background: var(--surface-2); z-index: 0; }
.map-lg { height: min(70vh, 620px); }
.map-help { padding: .75rem 1rem; border-top: 1px solid var(--border); }
.map-help p { margin: 0 0 .5rem; }
.leaflet-container { font: inherit; }
.leaflet-popup-content { font-size: .9rem; }

/* Intake question builder */
.intake-builder { display: grid; gap: .6rem; }
.intake-row { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: .6rem; background: var(--surface-2); }
.intake-row-main { display: grid; grid-template-columns: 1.6rem minmax(0, 1fr) 11rem auto auto; gap: .5rem; align-items: center; }
.intake-row input[type="text"], .intake-row select, .intake-row textarea { width: 100%; min-height: 38px; padding: .4rem .6rem; font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); }
.intake-num { font-weight: 800; color: var(--text-muted); text-align: center; }
.intake-required { font-size: .85rem; white-space: nowrap; }
.intake-actions { display: flex; }
.intake-options { margin: .5rem 0 0 2.1rem; display: grid; gap: .25rem; }
@media (max-width: 760px) { .intake-row-main { grid-template-columns: 1.6rem minmax(0, 1fr); } .intake-row-main > :nth-child(n+3) { grid-column: 2; } }

/* Public pages */
.page-hero { background: linear-gradient(135deg, var(--brand) 0%, #1c4a7a 100%); color: #fff; padding: 3rem 0 2.5rem; }
.page-hero h1 { font-size: clamp(1.8rem, 4vw, 2.6rem); margin: 0; }
.page-hero .hero-lead { margin: .5rem 0 0; }
.flash-container:empty { display: none; }
.flash-container .alert { margin-top: 1rem; }
.service-card { position: relative; overflow: hidden; padding-top: 1.6rem; }
.service-card-bar { position: absolute; top: 0; left: 0; right: 0; height: 5px; background: var(--accent); }
.service-card h3 a { color: inherit; text-decoration: none; }
.service-card h3 a:hover { text-decoration: underline; }
.cta-row { display: flex; justify-content: space-between; align-items: center; gap: 1.5rem; flex-wrap: wrap; }
.cta-row p { margin: 0; }
.prose { max-width: 760px; }
.prose h2 { font-size: 1.2rem; margin-top: 1.75rem; }
.site-footer a { color: inherit; }

/* Phase 6: dashboard, location notes */
.dash-today .stat-value { color: var(--text); }
.premise-note.is-hazard { border-left: 5px solid var(--danger); }
.premise-note.is-expired { opacity: .6; }
.premise-note .card-header form { margin: 0; }

/* ---------- Responsive hardening: nothing may make a page wider than the screen ---------- */
body { overflow-wrap: break-word; }
.app-shell > *, .cad-grid > *, .grid > *, .kv > *, .filters > * { min-width: 0; }
.kv dt { overflow-wrap: break-word; } .kv dd { overflow-wrap: anywhere; }
.card-header { flex-wrap: wrap; }
.page-header > * { min-width: 0; }
.table-wrap { max-width: 100%; -webkit-overflow-scrolling: touch; }

/* iPhone Safari zooms in when a tapped field's text is under 16px; keep fields at 16px on touch screens. */
@media (pointer: coarse) {
    input, select, textarea { font-size: max(16px, 1em) !important; }
}

/* Tablets and phones: top bar wraps neatly; the section menu scrolls sideways inside its own row. */
@media (max-width: 860px) {
    .app-topbar { gap: .5rem; padding: .5rem .75rem; min-height: var(--topbar-h); }
    .app-user { gap: .4rem; }
    .app-user-name { max-width: 7rem; }
    .app-sidebar { overflow: hidden; }
    .app-sidebar nav { scrollbar-width: none; -webkit-overflow-scrolling: touch; }
    .app-sidebar nav::-webkit-scrollbar { display: none; }
}

/* Phones */
@media (max-width: 480px) {
    .app-main { padding: .75rem; }
    .card:not(.card-flush) { padding: 1rem; }
    h1, .h1 { font-size: 1.5rem; }
    .page-header h1 { font-size: 1.35rem; }
    .logo { font-size: 1rem; }
    .logo-mark { width: 28px; height: 28px; }
    .app-name { font-size: .7rem; padding: .1rem .4rem; }
    .btn-lg { padding: .7rem 1.1rem; font-size: 1rem; }
    .hero { padding: 2.5rem 0 2rem; }
    .section { padding: 2.25rem 0; }
    .container { padding: 0 1rem; }
    .auth-wrap { padding: 1.25rem .75rem; }
}

/* ---------- Consumer home page ---------- */
.hero-compact { padding: 3rem 0 2.5rem; }
.hero-compact .hero-title { max-width: 24ch; }
.hero-note a { color: #fff; }
.section-tight { padding: 2rem 0 1.5rem; }
.help-chips { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: .5rem; }
.help-chips li { padding: .5rem .9rem; border-radius: 999px; background: var(--surface); border: 1px solid var(--border); font-weight: 600; }
.help-chips li::before { content: "✓"; color: var(--accent); font-weight: 800; margin-right: .4rem; }
.coverage-layout { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(min(300px, 100%), 1fr); gap: 1rem; align-items: start; }
.coverage-map { height: min(60vh, 460px); }
.company-band { display: flex; justify-content: space-between; align-items: center; gap: 1.5rem; flex-wrap: wrap; }
.company-band > div { flex: 1 1 320px; }
.company-band p { margin: 0; }
@media (max-width: 860px) {
    .coverage-layout { grid-template-columns: minmax(0, 1fr); }
    .coverage-map { height: 320px; }
}
@media (max-width: 480px) {
    .hero-compact { padding: 2rem 0 1.75rem; }
    .hero-actions .btn { flex: 1 1 100%; }
    .site-nav { gap: .75rem; font-size: .92rem; }
    .company-band .btn { width: 100%; }
}
@media (max-width: 480px) {
    .site-header-inner { min-height: 56px; flex-wrap: nowrap; }
    .site-nav a[href$="#coverage"] { display: none; } /* the map is on the home page itself */
    .site-nav .btn { white-space: nowrap; }
}
@media (max-width: 860px) {
    .app-topbar { position: static; } /* don't pin a tall bar over content on small screens */
}
@media (max-width: 480px) {
    .app-brand { gap: .5rem; }
    .app-user-name { font-size: 0; max-width: none; } /* name becomes an icon; still a link to My account */
    .app-user-name::before { content: "👤"; font-size: 1.15rem; }
    .app-switcher a { padding: .3rem .55rem; }
}
@media (max-width: 480px) {
    .site-nav { flex-wrap: nowrap; }
}
@media (max-width: 360px) {
    .site-nav { gap: .5rem; font-size: .85rem; }
    .site-header .logo-text { font-size: .95rem; }
    .site-header .logo-mark { width: 24px; height: 24px; }
}

/* ------------------------------------------------------------------ payments & billing */
.section-sm { padding: 1.5rem 0 2.5rem; }
.text-danger { color: var(--danger); }
.check { display: flex; gap: .5rem; align-items: center; }
.kv-tight dt, .kv-tight dd { padding-top: .2rem; padding-bottom: .2rem; }
.pay-panel { display: grid; gap: 1rem; min-width: 0; }
.pay-head { display: flex; flex-wrap: wrap; gap: .5rem 1rem; align-items: center; justify-content: space-between; }
.pay-totals { display: flex; flex-wrap: wrap; gap: .25rem 1.25rem; font-size: .95rem; }
.pay-totals-lg { font-size: 1.15rem; }
.pay-owing strong { color: var(--danger); }
.pay-section { display: grid; gap: .6rem; min-width: 0; }
.pay-h { margin: 0; font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; color: var(--text-muted); }
.pay-items { display: grid; gap: .4rem; }
.pay-item { display: grid; grid-template-columns: minmax(0, 1fr) 4.5rem 6.5rem auto; gap: .4rem; align-items: center; }
.pay-item-ro { grid-template-columns: minmax(0, 1fr) auto; padding: .35rem 0; border-bottom: 1px solid var(--border); }
.pay-row { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.pay-row input { flex: 1 1 8rem; min-width: 0; }
.pay-items-total { margin: 0; color: var(--text-muted); }
.pay-payments, .pay-receipts { list-style: none; margin: 0; padding: 0; display: grid; gap: .4rem; }
.pay-payments li, .pay-receipts li { display: flex; flex-wrap: wrap; gap: .25rem .75rem; justify-content: space-between; align-items: baseline; padding: .4rem 0; border-bottom: 1px solid var(--border); }
.pay-tabs { display: flex; gap: .25rem; flex-wrap: wrap; border-bottom: 1px solid var(--border); }
.pay-tabs button { background: none; border: 0; border-bottom: 2px solid transparent; padding: .5rem .8rem; font: inherit; font-weight: 600; color: var(--text-muted); cursor: pointer; min-height: 44px; }
.pay-tabs button.is-active { color: var(--text); border-bottom-color: var(--accent); }
.pay-tab-body { display: grid; gap: .75rem; padding-top: .5rem; }
.pay-card-form { display: grid; gap: .75rem; }
.pay-card-element { min-height: 3rem; }
.pay-error { color: var(--danger); margin: 0; font-weight: 600; }
.pay-page { max-width: 1000px; margin: 0 auto; }
.billing-payment { padding: .75rem 0; border-bottom: 1px solid var(--border); }
.billing-payment:last-child { border-bottom: 0; }
.billing-payment-head { display: flex; flex-wrap: wrap; gap: .25rem 1rem; align-items: baseline; }
.billing-history { list-style: none; padding: 0; margin: 0; display: grid; gap: .3rem; }
.billing-lines { display: grid; gap: .4rem; }
.billing-line { display: grid; grid-template-columns: minmax(0, 1fr) 5rem 7rem; gap: .5rem; }
.form-inline { display: flex; flex-wrap: wrap; gap: .5rem; align-items: end; }
.form-inline .field { flex: 1 1 8rem; min-width: 0; }
.mdt-invoice-summary { display: grid; gap: .6rem; }
@media (max-width: 480px) {
    .pay-item { grid-template-columns: minmax(0, 1fr) 3.5rem 5.5rem auto; }
    .billing-line { grid-template-columns: minmax(0, 1fr) 3.5rem 5.5rem; }
}
@media print {
    .app-topbar, .app-sidebar, .site-header, .site-footer, [data-print], [data-pay-form] { display: none !important; }
}
.pay-qr-box { display: grid; justify-items: center; gap: .25rem; text-align: center; }
.pay-qr { display: block; max-width: 100%; height: auto; background: #fff; border-radius: 8px; image-rendering: pixelated; }
[data-qr] .pay-qr { max-width: 220px; }

.list-plain { list-style: none; margin: 0; padding: 0; display: grid; gap: .5rem; }
