/* Rental Investment Analyzer — "institutional report" design system.
   Navy masthead, oxblood for losses, individually-carded metrics with soft
   rounded corners, Source Serif 4 / Source Sans 3 / Source Code Pro. */

:root {
    --bg: #FAFAF8;
    --surface: #FFFFFF;
    --surface-muted: #F3F2EE;
    --border: #E3E2DC;
    --border-strong: #CBC9C0;
    --text: #1A1D22;
    --text-muted: #5B616B;
    --text-faint: #8B909A;
    --brand: #1B3A6B;
    --brand-dark: #12274A;
    --brand-tint: #E9EEF6;
    --positive: #1F6D45;
    --positive-tint: #E7F1EB;
    --negative: #7A2331;
    --negative-tint: #F3E7E9;
    --warning: #8A5A22;
    --warning-tint: #F2E8D8;
    --radius-sm: 9px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --shadow-sm: 0 1px 2px rgba(26, 29, 34, 0.04);
    --shadow-md: 0 1px 2px rgba(26, 29, 34, 0.03), 0 8px 20px rgba(26, 29, 34, 0.05);
    --font: "Source Sans 3", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    --font-display: "Source Serif 4", Georgia, "Times New Roman", serif;
    --font-mono: "Source Code Pro", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    color-scheme: light;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #10151C;
        --surface: #171D26;
        --surface-muted: #1D2430;
        --border: #2B3340;
        --border-strong: #3B4658;
        --text: #E8EAED;
        --text-muted: #A3AAB6;
        --text-faint: #6E7684;
        --brand: #7FA1D6;
        --brand-dark: #A6C1E6;
        --brand-tint: #1C2A3E;
        --positive: #5FBB8A;
        --positive-tint: #16281F;
        --negative: #E28A82;
        --negative-tint: #2E1B1A;
        --warning: #E0B268;
        --warning-tint: #2E2416;
        --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
        --shadow-md: 0 1px 2px rgba(0, 0, 0, 0.3), 0 10px 24px rgba(0, 0, 0, 0.4);
        color-scheme: dark;
    }
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    font-family: var(--font);
    font-size: 15px;
    line-height: 1.55;
    color: var(--text);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { margin: 0 0 0.3rem; line-height: 1.2; font-family: var(--font-display); font-weight: 600; text-wrap: balance; }
h1 { font-size: clamp(1.7rem, 1.25rem + 1.8vw, 2.5rem); }
h2 { font-size: 1.4rem; }
h3 { font-size: 1.05rem; }
p { margin: 0 0 0.5rem; color: var(--text-muted); }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
small { color: var(--text-muted); font-size: 0.82rem; }
code { background: var(--surface-muted); border: 1px solid var(--border); border-radius: 4px; padding: 0.05rem 0.35rem; font-size: 0.85em; font-family: var(--font-mono); }

.sr-only {
    position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}

.shell { max-width: 1180px; margin: 0 auto; padding: 0 1.25rem; }

.eyebrow {
    display: inline-block;
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--brand);
    margin-bottom: 0.5rem;
}

/* Buttons */
.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    background: var(--brand);
    color: #fff;
    border: 1px solid var(--brand);
    padding: 0.65rem 1.2rem;
    border-radius: var(--radius-sm);
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease, transform 0.05s ease;
}
.button:hover { background: var(--brand-dark); border-color: var(--brand-dark); text-decoration: none; }
.button:active { transform: translateY(1px); }
.button-secondary { background: transparent; color: var(--brand); border-color: var(--border-strong); }
.button-secondary:hover { background: var(--brand-tint); border-color: var(--brand); }
.button-small { padding: 0.45rem 0.9rem; font-size: 0.82rem; }
.button-large { padding: 0.85rem 1.7rem; font-size: 0.98rem; }

/* Header — navy masthead */
.site-header {
    background: var(--brand);
    position: sticky;
    top: 0;
    z-index: 40;
}
.header-inner { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 0.8rem 1.25rem; }
.brand { display: flex; align-items: center; gap: 0.65rem; color: #fff; }
.brand:hover { text-decoration: none; }
.brand-mark {
    display: flex; align-items: center; justify-content: center;
    width: 26px; height: 26px; border-radius: 7px;
    border: 1px solid #fff;
    color: #fff; font-family: var(--font-display); font-weight: 600; font-size: 0.85rem; flex-shrink: 0;
}
.brand strong { display: block; font-family: var(--font-display); font-size: 0.95rem; font-weight: 600; }
.brand small { display: block; font-size: 0.7rem; color: rgba(255,255,255,0.68); }
.site-header nav { display: flex; align-items: center; gap: 1.1rem; }
.site-header nav > a:not(.button) { color: rgba(255,255,255,0.78); font-weight: 500; font-size: 0.88rem; }
.site-header nav > a:not(.button):hover { color: #fff; }
.site-header .button { background: #fff; border-color: #fff; color: var(--brand); }
.site-header .button:hover { background: var(--brand-tint); border-color: var(--brand-tint); }

main { min-height: 60vh; }

/* Flash / alerts */
.alert { border-radius: var(--radius-sm); padding: 0.8rem 1rem; margin: 1rem 0 0; font-size: 0.9rem; border: 1px solid transparent; border-left-width: 3px; }
.alert-success { background: var(--positive-tint); color: var(--positive); border-color: var(--positive); }
.alert-error { background: var(--negative-tint); color: var(--negative); border-color: var(--negative); }

/* Hero */
.hero { padding: 3.25rem 0 2.75rem; }
.hero-grid { display: grid; grid-template-columns: 1.4fr 1fr; gap: 2.25rem; align-items: center; }
.hero h1 { max-width: 19ch; }
.hero p { max-width: 46ch; font-size: 1rem; }
.hero-actions { display: flex; gap: 0.75rem; margin-top: 1.4rem; flex-wrap: wrap; }
.hero-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.6rem;
    box-shadow: var(--shadow-md);
}
.hero-card-label { font-size: 0.72rem; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-faint); }
.hero-card strong { display: block; font-family: var(--font-display); font-size: 1.2rem; font-weight: 600; margin: 0.4rem 0 0.6rem; }

/* Content sections */
.content-section { padding: 2.5rem 0; }
.content-section.compact { padding-top: 0; padding-bottom: 3.25rem; }
.section-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; margin-bottom: 1.25rem; flex-wrap: wrap; }
.result-heading { align-items: center; }

/* Feature grid (home) — individual soft cards */
.feature-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem; }
.feature-grid article { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 1.3rem; box-shadow: var(--shadow-sm); }
.feature-grid span { color: var(--brand); font-weight: 700; font-size: 0.78rem; }
.feature-grid h3 { margin-top: 0.5rem; }
.feature-grid p { font-size: 0.87rem; margin-bottom: 0; }

/* Setup / empty states */
.setup-card, .empty-state {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
}
.setup-card { display: flex; gap: 1rem; align-items: flex-start; border-left: 3px solid var(--warning); background: var(--warning-tint); }
.setup-icon {
    flex-shrink: 0; width: 32px; height: 32px; border-radius: 50%;
    background: var(--warning); color: #fff; font-weight: 700;
    display: flex; align-items: center; justify-content: center;
}
.setup-card h3 { color: var(--warning); margin-bottom: 0.3rem; }
.empty-state { text-align: center; padding: 2.75rem 1.5rem; border-style: dashed; }
.empty-state h3 { margin-bottom: 0.3rem; }
.empty-state .button { margin-top: 0.9rem; }

/* Auth (request-access / verify-access / unlock) */
.auth-card {
    max-width: 480px; margin: 0 auto;
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
    padding: 2rem; box-shadow: var(--shadow-md);
}
.auth-card h1 { font-size: 1.6rem; }
.auth-card > p { margin-bottom: 1.5rem; }
.auth-form { display: flex; flex-direction: column; gap: 1.1rem; }
.auth-form .button { margin-top: 0.4rem; }
.auth-footnote { margin: 1.5rem 0 0; text-align: center; font-size: 0.88rem; }

/* Search bar */
.search-bar { display: flex; gap: 0.6rem; margin-bottom: 1.5rem; flex-wrap: wrap; align-items: center; }
.search-bar input {
    flex: 1 1 260px;
    padding: 0.65rem 0.9rem;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--text);
    font-size: 0.92rem;
}
.search-bar input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-tint); }
.clear-link { font-size: 0.85rem; color: var(--text-muted); }

/* Scenario list — individual soft cards */
.scenario-list { display: flex; flex-direction: column; gap: 0.6rem; }
.scenario-row {
    display: flex; align-items: center; gap: 1rem;
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
    padding: 1rem 1.25rem; color: var(--text); box-shadow: var(--shadow-sm);
    transition: box-shadow 0.15s ease, border-color 0.15s ease, transform 0.05s ease;
}
.scenario-row:hover { border-color: var(--brand); box-shadow: var(--shadow-md); text-decoration: none; }
.scenario-row:active { transform: translateY(1px); }
.scenario-main { display: flex; flex-direction: column; gap: 0.15rem; flex: 1 1 auto; min-width: 0; }
.scenario-main strong { font-family: var(--font-display); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.scenario-metric { display: flex; flex-direction: column; align-items: flex-end; gap: 0.15rem; min-width: 96px; }
.scenario-metric strong { font-family: var(--font-mono); font-size: 1.02rem; }
.arrow { color: var(--text-faint); font-size: 1.1rem; }

.positive { color: var(--positive); }
.negative { color: var(--negative); }

/* Footer — bookends the navy masthead */
.site-footer { background: var(--brand); padding: 1.6rem 0; margin-top: 3rem; }
.footer-inner { display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap; font-size: 0.82rem; }
.footer-inner p { margin: 0; color: rgba(255,255,255,0.72); }

/* ===== Analysis page ===== */
.analysis-header { background: var(--surface); border-bottom: 1px solid var(--border); padding: 1.75rem 0; }
.breadcrumb { display: flex; align-items: center; gap: 0.4rem; font-size: 0.8rem; color: var(--text-faint); margin-bottom: 0.7rem; }
.breadcrumb span { color: var(--text-faint); }
.analysis-title-row { display: flex; justify-content: space-between; align-items: flex-end; gap: 1rem; flex-wrap: wrap; }
.scenario-id { font-size: 0.85rem; }
.copy-button {
    border: 1px solid var(--border-strong); background: var(--surface-muted); color: var(--text);
    font-family: var(--font-mono);
    font-size: 0.78rem; padding: 0.15rem 0.5rem; border-radius: 6px; cursor: pointer;
}
.copy-button:hover { border-color: var(--brand); color: var(--brand); }
.copy-button.copied { border-color: var(--positive); color: var(--positive); }

.analysis-layout { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 1.75rem; padding: 2rem 1.25rem; align-items: start; }

.input-panel, .preview-panel, .result-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.6rem;
    box-shadow: var(--shadow-md);
}
.input-panel { min-width: 0; }
.panel-heading { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; margin-bottom: 1rem; }
.autosave-note { font-size: 0.76rem; color: var(--text-faint); background: var(--surface-muted); border: 1px solid var(--border); padding: 0.28rem 0.65rem; border-radius: 999px; white-space: nowrap; }

.section-nav {
    display: flex; flex-wrap: wrap; gap: 0.4rem;
    margin-bottom: 1.3rem; padding-bottom: 1.3rem; border-bottom: 1px solid var(--border);
}
.section-nav a {
    font-size: 0.78rem; font-weight: 600; color: var(--text-muted);
    background: var(--surface-muted); border: 1px solid var(--border);
    padding: 0.35rem 0.75rem; border-radius: 999px;
}
.section-nav a:hover { color: var(--brand); border-color: var(--brand); text-decoration: none; }
.section-nav a.is-active { color: #fff; border-color: var(--brand); background: var(--brand); }
.section-nav-results { color: var(--brand) !important; border-color: var(--brand) !important; }

.required-legend {
    display: flex; gap: 0.6rem; align-items: flex-start;
    background: var(--surface-muted); border: 1px solid var(--border); border-left: 3px solid var(--negative);
    border-radius: var(--radius-sm); padding: 0.75rem 0.95rem; margin-bottom: 1.6rem;
    font-size: 0.85rem; color: var(--text-muted);
}
.required-legend .required-mark { color: var(--negative); font-weight: 700; }

fieldset { border: 0; padding: 0; margin: 0 0 2.2rem; scroll-margin-top: 5.5rem; }
fieldset:last-of-type { margin-bottom: 0.5rem; }
legend {
    display: flex; align-items: baseline; gap: 0.65rem;
    font-family: var(--font-display); font-weight: 600; font-size: 1.1rem; color: var(--text);
    padding: 0; margin-bottom: 1.1rem; width: 100%;
    border-bottom: 1px solid var(--border); padding-bottom: 0.7rem;
}
legend span {
    color: var(--brand);
    font-size: 0.78rem; font-weight: 600; flex-shrink: 0;
}

.field-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; }
.field { display: flex; flex-direction: column; gap: 0.35rem; min-width: 0; }
.field-wide { grid-column: 1 / -1; }
.field-label { font-size: 0.8rem; font-weight: 600; color: var(--text-muted); display: flex; align-items: center; gap: 0.25rem; }
.field-required .field-label { color: var(--text); }
.required-mark { color: var(--negative); font-weight: 700; }
.input-wrap { position: relative; display: flex; align-items: center; }
.input-wrap input {
    width: 100%;
    padding: 0.6rem 0.75rem;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    background: var(--surface-muted);
    color: var(--text);
    font-family: var(--font-mono);
    font-size: 0.9rem;
    font-variant-numeric: tabular-nums;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.input-wrap input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-tint); background: var(--surface); }
.field-required .input-wrap input { border-color: color-mix(in srgb, var(--brand) 45%, var(--border-strong)); }
.field-invalid .input-wrap input { border-color: var(--negative); background: var(--negative-tint); }
.input-suffix {
    position: absolute; right: 0.75rem; font-family: var(--font-mono); font-size: 0.78rem; color: var(--text-faint);
    pointer-events: none; background: transparent;
}
.input-wrap input[type="number"] { padding-right: 2.2rem; }
.field-error { font-size: 0.78rem; color: var(--negative); font-weight: 600; }
.field-help { font-size: 0.78rem; color: var(--text-faint); }

.submit-bar {
    display: flex; align-items: center; justify-content: space-between; gap: 1rem;
    flex-wrap: wrap; margin-top: 1.6rem; padding-top: 1.6rem; border-top: 1px solid var(--border);
    position: sticky; bottom: 0; background: var(--surface);
}
.submit-bar strong { display: block; font-family: var(--font-display); font-size: 0.95rem; }
.submit-bar small { display: block; }

/* Live preview */
.preview-panel { position: sticky; top: 5.5rem; display: flex; flex-direction: column; gap: 0.9rem; }
.preview-address { font-family: var(--font-display); font-weight: 600; font-size: 0.94rem; word-break: break-word; }
.preview-primary {
    background: var(--brand-tint); border-radius: var(--radius-md); padding: 1rem;
    display: flex; flex-direction: column; gap: 0.2rem;
}
.preview-primary strong { font-family: var(--font-mono); font-size: 1.65rem; color: var(--brand-dark); font-variant-numeric: tabular-nums; }
.preview-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem; }
.preview-grid > div {
    background: var(--surface-muted); border: 1px solid var(--border); border-radius: var(--radius-sm);
    padding: 0.65rem 0.75rem; display: flex; flex-direction: column; gap: 0.15rem;
}
.preview-grid strong { font-family: var(--font-mono); font-size: 1rem; font-variant-numeric: tabular-nums; }
.preview-note { font-size: 0.76rem; margin: 0; }

/* Results */
.results-section { padding: 2.5rem 0 4rem; scroll-margin-top: 4.5rem; }

.status-pill {
    display: inline-flex;
    align-items: center;
    font-size: 0.8rem; font-weight: 600;
    padding: 0.45rem 1rem;
    border-radius: 999px;
}
.status-pill::before { content: ""; display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: currentColor; margin-right: 0.5rem; }
.status-good { background: var(--positive-tint); color: var(--positive); }
.status-bad { background: var(--negative-tint); color: var(--negative); }

/* Metric cards — individual soft cards, each with a target caption */
.metric-cards { display: grid; grid-template-columns: repeat(5, 1fr); gap: 0.9rem; margin-bottom: 1.6rem; }
.metric-card {
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
    padding: 1.1rem; display: flex; flex-direction: column; gap: 0.3rem; box-shadow: var(--shadow-sm);
}
.metric-card small { font-size: 0.74rem; font-weight: 600; color: var(--text-muted); }
.metric-card strong { font-family: var(--font-mono); font-size: 1.35rem; font-variant-numeric: tabular-nums; }
.metric-card span { font-size: 0.75rem; color: var(--text-faint); }

.result-grid.two-column { display: grid; grid-template-columns: 1fr 1fr; gap: 1.25rem; margin-bottom: 1.25rem; }
.result-card.full-width { margin-bottom: 1.25rem; }
.card-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; margin-bottom: 1.1rem; }
.card-heading h3 { font-size: 1.05rem; }
.card-heading p { font-size: 0.82rem; margin: 0.2rem 0 0; }

.data-table { display: flex; flex-direction: column; }
.data-row {
    display: flex; align-items: center; justify-content: space-between; gap: 1rem;
    padding: 0.6rem 0; border-bottom: 1px solid var(--border); font-size: 0.88rem;
}
.data-row:last-child { border-bottom: 0; }
.data-row span { color: var(--text-muted); }
.data-row strong { font-family: var(--font-mono); font-variant-numeric: tabular-nums; font-weight: 600; }
.data-row.data-total { border-bottom: 2px solid var(--text); }
.data-row.data-total span { color: var(--text); font-weight: 700; }
.data-row.data-total strong { font-size: 0.98rem; }
.top-space { margin-top: 1rem; }

.limit-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0.8rem; margin-bottom: 0.5rem; }
.limit-grid > div {
    background: var(--surface-muted); border: 1px solid var(--border); border-radius: var(--radius-sm);
    padding: 0.75rem; display: flex; flex-direction: column; gap: 0.2rem;
}
.limit-grid strong { font-family: var(--font-mono); font-size: 1.05rem; font-variant-numeric: tabular-nums; }

.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; font-size: 0.85rem; white-space: nowrap; }
table th, table td { text-align: right; padding: 0.6rem 0.7rem; border-bottom: 1px solid var(--border); font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
table thead th { text-align: right; color: var(--text-faint); font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.04em; font-weight: 600; font-family: var(--font); border-bottom: 1px solid var(--text); }
table tbody th { text-align: left; font-family: var(--font-display); font-weight: 600; color: var(--text); }
.sensitivity-table thead th:first-child, .sensitivity-table tbody th { text-align: left; }
table tr.selected-year { background: var(--brand-tint); }
table tr.selected-year th, table tr.selected-year td { font-weight: 700; }
.heat-positive { background: var(--positive-tint); color: var(--positive); font-weight: 600; }
.heat-negative { background: var(--negative-tint); color: var(--negative); font-weight: 600; }

/* Responsive */
@media (max-width: 1080px) {
    .metric-cards { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 960px) {
    .analysis-layout { grid-template-columns: 1fr; }
    .preview-panel { position: static; order: -1; }
    .feature-grid { grid-template-columns: repeat(2, 1fr); }
    .hero-grid { grid-template-columns: 1fr; }
    .result-grid.two-column { grid-template-columns: 1fr; }
}

@media (max-width: 720px) {
    .metric-cards { grid-template-columns: repeat(2, 1fr); }
    .field-grid { grid-template-columns: repeat(2, 1fr); }
    .limit-grid { grid-template-columns: 1fr; }
    .hide-mobile { display: none; }
    .scenario-row { flex-wrap: wrap; }
    .header-inner nav a:not(.button) { display: none; }
}

@media (max-width: 520px) {
    .shell { padding: 0 1rem; }
    .analysis-layout { padding: 1.5rem 1rem; }
    .field-grid { grid-template-columns: 1fr; }
    .metric-cards { grid-template-columns: 1fr 1fr; }
    .feature-grid { grid-template-columns: 1fr; }
    .input-panel, .preview-panel, .result-card { padding: 1.15rem; }
    .analysis-title-row { flex-direction: column; align-items: flex-start; }
    .submit-bar { flex-direction: column; align-items: stretch; }
    .submit-bar .button { width: 100%; }
}
