@view-transition {
    navigation: auto;
}

:root {
    --bg: #fafafa;
    --fg: #111;
    --muted: #666;
    --border: #e5e5e5;
    --surface: #fff;
    --accent: #111;
    --accent-fg: #fff;
    --radius: 8px;
    --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
    --shadow-sm: rgba(0, 0, 0, 0.12);
    --shadow-md: rgba(0, 0, 0, 0.16);
    --shadow-ring: rgba(0, 0, 0, 0.04);
    --topbar-bg: rgba(250, 250, 250, 0.85);
    --hover-overlay: rgba(0, 0, 0, 0.04);
    --search-border: rgba(0, 0, 0, 0.06);
    --search-divider: rgba(0, 0, 0, 0.10);
    --focus-ring: rgba(17, 17, 17, 0.08);
    --label-shadow: #fff;
}


* { box-sizing: border-box; margin: 0; }

body {
    font-family: var(--font);
    color: var(--fg);
    background: var(--bg);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

.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;
}

/* ---- Focus ---- */

:focus-visible {
    outline: 2px solid var(--fg);
    outline-offset: 2px;
}

input:focus-visible {
    outline: none;
    border-color: var(--fg);
    box-shadow: 0 0 0 3px var(--focus-ring);
}

/* ---- Topbar ---- */

.topbar {
    position: sticky;
    top: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    gap: 1.5rem;
    height: 56px;
    padding: 0 24px;
    background: var(--topbar-bg);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
    view-transition-name: topbar;
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 32px;
}

.user-menu {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* ---- Topbar Icon Buttons (shared) ---- */

.topbar-icon-btn {
    display: grid;
    place-items: center;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--fg);
    cursor: pointer;
    transition: border-color 0.15s;
}

.topbar-icon-btn:hover { border-color: var(--fg); }


.brand {
    text-decoration: none;
    color: var(--fg);
    font-weight: 700;
    font-size: 0.875rem;
    letter-spacing: 0.06em;
}

.topbar-nav {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    overflow-x: auto;
    scrollbar-width: none;
}
.topbar-nav::-webkit-scrollbar { display: none; }

.nav-link {
    text-decoration: none;
    color: var(--muted);
    font-size: 0.875rem;
    font-weight: 500;
    padding: 0.375rem 0.625rem;
    border-radius: 6px;
    transition: color 0.15s, background 0.15s;
}

.nav-link:hover {
    color: var(--fg);
    background: var(--hover-overlay);
}

.nav-link.active {
    color: var(--fg);
}

/* ---- User Menu ---- */

.user-dropdown {
    position: fixed;
    inset: unset;
    top: 52px;
    right: 1.25rem;
    min-width: 180px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.5rem;
    box-shadow: 0 4px 16px var(--shadow-sm);
    margin: 0;
}

.user-dropdown .dropdown-links {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.user-dropdown .dropdown-links .btn {
    text-align: center;
    font-size: 0.8125rem;
    padding: 0.5rem 0.75rem;
}

.user-badge {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.375rem 0.25rem;
    margin-bottom: 0.375rem;
    font-size: 0.8125rem;
    color: var(--muted);
    border-bottom: 1px solid var(--border);
}

.user-badge .badge-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #22c55e;
    flex-shrink: 0;
}

/* ---- Layout ---- */

.page {
    width: min(960px, 100% - 2rem);
    margin: 3rem auto;
    view-transition-name: main-content;
}

::view-transition-old(main-content) {
    animation: 200ms ease-out both fade-out;
}

::view-transition-new(main-content) {
    animation: 200ms ease-in 60ms both fade-in;
}

@keyframes fade-out {
    to { opacity: 0; transform: translateY(-8px); }
}

@keyframes fade-in {
    from { opacity: 0; transform: translateY(8px); }
}

/* Reverse transition (e.g. property page → explore map) */
html:active-view-transition-type(back) ::view-transition-old(main-content) {
    animation: 200ms ease-out both fade-out-reverse;
}

html:active-view-transition-type(back) ::view-transition-new(main-content) {
    animation: 200ms ease-in 60ms both fade-in-reverse;
}

@keyframes fade-out-reverse {
    to { opacity: 0; transform: translateY(8px); }
}

@keyframes fade-in-reverse {
    from { opacity: 0; transform: translateY(-8px); }
}

/* ---- Hero ---- */

.hero {
    padding: 2.5rem 0;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.eyebrow {
    margin: 0 0 0.5rem;
    text-transform: uppercase;
    letter-spacing: 2px;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--muted);
}

h1 {
    margin: 0;
    font-size: clamp(1.75rem, 4vw, 3rem);
    font-weight: 700;
    line-height: 1.15;
    letter-spacing: -0.02em;
}

.subtitle {
    max-width: 52ch;
    margin-top: 0.75rem;
    color: var(--muted);
    font-size: 1.125rem;
}

.cta-row {
    display: flex;
    gap: 12px;
    margin-top: 1.5rem;
    flex-wrap: wrap;
    justify-content: center;
}

/* ---- Buttons ---- */

.btn {
    display: inline-block;
    text-decoration: none;
    border-radius: var(--radius);
    padding: 10px 20px;
    font-size: 0.875rem;
    font-weight: 600;
    font-family: var(--font);
    transition: opacity 0.15s;
    cursor: pointer;
    border: none;
}

.btn:hover { opacity: 0.8; }

.btn-primary {
    background: var(--accent);
    color: var(--accent-fg);
}

.btn-secondary {
    background: transparent;
    color: var(--fg);
    border: 1px solid var(--border);
}

.btn-secondary:hover {
    background: var(--fg);
    color: var(--accent-fg);
    opacity: 1;
}

/* ---- Features grid (home) ---- */

.features {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(220px, 100%), 1fr));
    gap: 16px;
    margin-top: 1rem;
}

.feature {
    background: var(--surface);
    padding: 24px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.feature-icon {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--accent);
    color: var(--accent-fg);
    border-radius: var(--radius);
    margin-bottom: 0.75rem;
}

.feature h3 {
    font-size: 1.125rem;
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.feature p {
    font-size: 0.875rem;
    color: var(--muted);
    line-height: 1.5;
}

/* ---- Stats row (home) ---- */

.stats-row {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: clamp(1.5rem, 6vw, 80px);
    margin-top: 2.5rem;
    padding: 1.5rem 0;
    border-top: 1px solid var(--border);
}

.stat { text-align: center; }

.stat-number {
    font-size: 1.75rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.stat-label {
    font-size: 0.8125rem;
    color: var(--muted);
    font-weight: 500;
    margin-top: 0.125rem;
}

a.feature-link {
    text-decoration: none;
    color: inherit;
    transition: background 0.15s;
    cursor: pointer;
}

a.feature-link:hover {
    background: var(--bg);
}

/* ---- Auth ---- */

.page-auth {
    width: 100%;
    margin: 0;
    view-transition-name: main-content;
}

.auth-layout {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(320px, 100%), 1fr));
    min-height: calc(100vh - 3.5rem);
}

.auth-left {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 3rem 2rem;
}

.auth-form {
    width: 100%;
    max-width: 360px;
}

.auth-heading {
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    margin-bottom: 0.375rem;
}

.auth-subheading {
    color: var(--muted);
    font-size: 0.9375rem;
    margin-bottom: 2rem;
}

.auth-section-title {
    font-size: 0.9375rem;
    font-weight: 600;
    letter-spacing: -0.01em;
    margin-bottom: 1rem;
}

.auth-divider {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin: 1.5rem 0;
    color: var(--muted);
    font-size: 0.75rem;
    text-transform: lowercase;
    letter-spacing: 0.03em;
}

.auth-divider::before,
.auth-divider::after {
    content: "";
    flex: 1;
    height: 1px;
    background: var(--border);
}

.auth-right {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 3rem;
    background: var(--surface);
    border-left: 1px solid var(--border);
}

.auth-hero-content {
    max-width: 380px;
}

.auth-hero-eyebrow {
    text-transform: uppercase;
    letter-spacing: 2px;
    font-size: 0.6875rem;
    font-weight: 600;
    color: var(--muted);
    margin-bottom: 1rem;
}

.auth-hero-title {
    font-size: 1.75rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    line-height: 1.2;
    margin-bottom: 1rem;
}

.auth-hero-text {
    color: var(--muted);
    font-size: 1rem;
    line-height: 1.6;
}

.auth-disabled-msg {
    color: var(--muted);
    font-size: 0.875rem;
}


.otp-group {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.125rem;
}

.otp-digit {
    width: 2.75rem;
    height: 3rem;
    text-align: center;
    font-size: 1.25rem;
    font-weight: 600;
    font-family: var(--font);
    color: var(--fg);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    transition: border-color 0.15s, box-shadow 0.15s;
    caret-color: transparent;
}

.otp-digit:focus {
    outline: none;
    border-color: var(--fg);
    box-shadow: 0 0 0 3px var(--focus-ring);
}

.otp-digit.filled {
    border-color: var(--fg);
}

.form-field {
    margin-bottom: 1.125rem;
}

.form-label {
    display: block;
    font-size: 0.8125rem;
    font-weight: 500;
    margin-bottom: 0.375rem;
    color: var(--fg);
    letter-spacing: -0.01em;
}

.form-input {
    width: 100%;
    padding: 0.5625rem 0.75rem;
    font-size: 0.875rem;
    font-family: var(--font);
    color: var(--fg);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    transition: border-color 0.15s, box-shadow 0.15s;
    line-height: 1.5;
}

.form-input::placeholder {
    color: var(--muted);
    opacity: 0.7;
}

.form-input:focus {
    outline: none;
    border-color: var(--fg);
    box-shadow: 0 0 0 3px var(--focus-ring);
}

.form-error {
    font-size: 0.75rem;
    color: #ef4444;
    margin-top: 0.3125rem;
}

.form-alert {
    padding: 0.5625rem 0.75rem;
    border-radius: var(--radius);
    font-size: 0.8125rem;
    line-height: 1.5;
    margin-bottom: 1rem;
}

.form-alert-error {
    background: rgba(239, 68, 68, 0.06);
    color: #dc2626;
    border: 1px solid rgba(239, 68, 68, 0.15);
}

.form-submit {
    width: 100%;
    padding: 0.625rem 1rem;
    margin-top: 0.25rem;
    font-size: 0.875rem;
    line-height: 1.5;
    letter-spacing: -0.01em;
}

.form-submit:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.form-footer {
    margin-top: 1.25rem;
    font-size: 0.8125rem;
    color: var(--muted);
}

.form-footer a {
    color: var(--fg);
    text-decoration: underline;
    text-underline-offset: 2px;
    text-decoration-color: var(--border);
    transition: text-decoration-color 0.15s;
}

.form-footer a:hover {
    text-decoration-color: var(--fg);
}

.verify-instructions {
    font-size: 0.875rem;
    color: var(--muted);
    line-height: 1.6;
    margin-bottom: 1.25rem;
}

/* ---- Explore (full-bleed map) ---- */

.page-explore {
    width: 100%;
    margin: 0;
    position: relative;
    view-transition-name: main-content;
}

.explore-overlay {
    position: absolute;
    top: 0;
    left: 0;
    z-index: 10;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    padding: 0.75rem;
    width: 380px;
    max-width: calc(100% - 1.5rem);
    pointer-events: none;
}

.explore-overlay > * {
    pointer-events: auto;
}

.explore-search {
    position: relative;
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: 0 1px 4px var(--shadow-sm), 0 0 0 1px var(--shadow-ring);
    transition: box-shadow 0.15s;
}

.explore-search:focus-within {
    box-shadow: 0 2px 8px var(--shadow-md), 0 0 0 1px var(--search-border);
}

.explore-search input {
    width: 100%;
    min-height: 2.75rem;
    padding: 0.75rem 2rem 0.75rem 2.25rem;
    border: none;
    border-radius: var(--radius);
    background: transparent;
    font-size: 0.875rem;
    font-family: var(--font);
    line-height: 1.5;
    color: var(--fg);
    outline: none;
    -webkit-appearance: none;
    appearance: none;
}

.explore-search input::placeholder { color: var(--muted); }

.explore-search .search-icon {
    position: absolute;
    left: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    align-items: center;
    color: var(--muted);
    pointer-events: none;
    z-index: 1;
}

.search-clear {
    display: none;
    position: absolute;
    right: 0.5rem;
    top: 50%;
    transform: translateY(-50%);
    padding: 0.25rem;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--muted);
    border-radius: 4px;
    line-height: 0;
    z-index: 1;
}

.search-clear:hover { color: var(--fg); }

.explore-search:has(input:not(:placeholder-shown)) .search-clear { display: block; }

.explore-search:has(.search-results.open) {
    border-radius: var(--radius) var(--radius) 0 0;
    box-shadow: none;
    border: 1px solid var(--search-border);
    border-bottom: none;
}

.explore-search:has(.search-results.open) input {
    border-radius: var(--radius) var(--radius) 0 0;
}

.explore-search .search-results {
    display: none;
    position: absolute;
    top: 100%;
    left: -1px;
    right: -1px;
    background: var(--surface);
    border-radius: 0 0 var(--radius) var(--radius);
    border: 1px solid var(--search-border);
    border-top: none;
    box-shadow: 0 4px 12px var(--shadow-sm);
    max-height: 260px;
    overflow-y: auto;
    z-index: 50;
}

.explore-search .search-results::before {
    content: '';
    display: block;
    height: 0;
    margin: 0 0.75rem;
    border-top: 0.5px solid var(--search-divider);
}

.explore-search .search-results.open { display: block; }

.search-result-item {
    padding: 0.5rem 0.75rem;
    cursor: pointer;
    font-size: 0.8125rem;
    border-bottom: 1px solid var(--border);
}

.search-result-item:last-child { border-bottom: none; }
.search-result-item:hover,
.search-result-item.active,
.search-result-item[aria-selected="true"] { background: var(--bg); }

.search-results-empty {
    padding: 0.75rem;
    font-size: 0.8125rem;
    color: var(--muted);
    text-align: center;
}

/* ---- Address line component (shared: search results + detail header) ---- */

.addr-primary {
    line-height: 1.3;
    font-weight: 500;
}

.addr-secondary {
    font-size: 0.6875em;
    color: var(--muted);
    line-height: 1.3;
    margin-top: 0.125rem;
}

.search-results-label {
    padding: 0.375rem 0.75rem 0.125rem;
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--muted);
}

/* ---- Explore panel (detail sidebar) ---- */

.explore-panel {
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: 0 1px 4px var(--shadow-sm), 0 0 0 1px var(--shadow-ring);
    max-height: calc(100vh - 56px - 60px - 1.5rem);
    overflow-y: auto;
    overscroll-behavior: contain;
    transition: opacity 0.15s;
}

.explore-overlay:has(.search-results.open) .explore-panel {
    opacity: 0.7;
    pointer-events: none;
}

.explore-panel.loading .detail-skeleton {
    opacity: 1;
}

.explore-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    padding: 1.5rem 1rem;
    text-align: center;
    color: var(--muted);
}

.explore-empty-icon {
    font-size: 1.5rem;
    opacity: 0.5;
}

.explore-empty p {
    font-size: 0.8125rem;
    line-height: 1.5;
    max-width: 28ch;
}

/* ---- Map ---- */

#map {
    height: calc(100vh - 56px);
    width: 100%;
    z-index: 1;
}

/* Mapbox permanent label popup (explore page) */
.map-label-popup .mapboxgl-popup-content {
    background: transparent;
    border: none;
    box-shadow: none;
    font-family: var(--font);
    font-size: 0.8125rem;
    font-weight: 700;
    color: var(--fg);
    text-shadow: 0 0 4px var(--label-shadow), 0 0 4px var(--label-shadow), 0 0 4px var(--label-shadow);
    padding: 0;
    white-space: nowrap;
}

.map-label-popup .mapboxgl-popup-tip { display: none; }

.layer-switch-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 29px;
    height: 29px;
    padding: 0;
    border: none;
    background: #fff;
    color: #333;
    cursor: pointer;
    border-radius: 4px;
}

.layer-switch-btn:hover { background: #f0f0f0; }
.layer-switch-btn.active {
    background: var(--accent);
    color: var(--accent-fg);
}

/* Price label markers (portfolio + future use) */
.price-marker {
    background: var(--accent);
    color: var(--accent-fg);
    padding: 3px 8px;
    border-radius: 999px;
    font-family: var(--font);
    font-size: 0.6875rem;
    font-weight: 600;
    letter-spacing: 0.01em;
    white-space: nowrap;
    box-shadow: 0 2px 6px var(--shadow-sm);
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
    line-height: 1.4;
}

.price-marker:hover {
    transform: scale(1.12);
    box-shadow: 0 4px 12px var(--shadow-md);
}

/* Isochrone legend (explore page) */
.isochrone-legend {
    position: absolute;
    bottom: 40px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 6px 14px;
    font-family: var(--font);
    font-size: 0.75rem;
    color: var(--fg);
    display: flex;
    align-items: center;
    gap: 6px;
    box-shadow: 0 2px 8px var(--shadow-sm);
    z-index: 10;
    white-space: nowrap;
}

.iso-swatch {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 2px;
    vertical-align: middle;
}


/* ---- Explore layout expand/collapse ---- */

.explore-layout {
    position: relative;
    width: 100%;
}

/* ---- Property Detail (unified component) ---- */

.property-detail {
    padding: 1rem;
}

.property-detail--full {
    width: min(720px, 100% - 2rem);
    margin: 0 auto;
    padding: 1.5rem 0;
}

.property-detail--sidebar .property-detail__full-only { display: none; }

.property-detail--full .property-detail__sidebar-only { display: none; }

.property-detail--full .property-detail__full-only { display: block; }

.property-detail__header {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.property-detail__header-text { flex: 1; min-width: 0; }

.property-detail__name {
    font-weight: 600;
    font-size: 1rem;
}

.property-detail--full .property-detail__name {
    font-size: clamp(1.25rem, 3vw, 1.75rem);
    font-weight: 700;
}

.property-detail__subtitle {
    color: var(--muted);
    font-size: 0.875rem;
    margin-top: 0.125rem;
}

.property-detail__header-actions {
    display: flex;
    gap: 0.25rem;
    flex-shrink: 0;
}

.map-link-btn {
    display: grid;
    place-items: center;
    width: 28px;
    height: 28px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--surface);
    color: var(--muted);
    cursor: pointer;
    transition: color 0.15s, border-color 0.15s;
}

.map-link-btn:hover { color: var(--fg); border-color: var(--fg); }


/* ---- Detail Card (legacy compat) ---- */

.detail-card {
    padding: 1rem;
}

.detail-header {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
    font-size: 1rem;
}

.detail-header-text { flex: 1; min-width: 0; }

.detail-header .addr-primary {
    font-weight: 600;
}

.copy-btn {
    flex-shrink: 0;
    display: grid;
    place-items: center;
    width: 28px;
    height: 28px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--surface);
    color: var(--muted);
    cursor: pointer;
    transition: color 0.15s, border-color 0.15s;
}

.copy-btn:hover { color: var(--fg); border-color: var(--fg); }
.copy-btn .check-icon { display: none; }
.copy-btn.copied .copy-icon { display: none; }
.copy-btn.copied .check-icon { display: block; }
.copy-btn.copied { color: #22c55e; border-color: #22c55e; }

.detail-table {
    width: 100%;
    border-collapse: collapse;
}

.detail-table tr + tr td {
    border-top: 1px solid var(--border);
}

.detail-label {
    padding: 10px 0.75rem 10px 0;
    font-size: 0.8125rem;
    color: var(--muted);
    white-space: nowrap;
    width: 1%;
}

.detail-value {
    padding: 10px 0;
    font-size: 0.8125rem;
}

.detail-value a {
    color: var(--fg);
    text-decoration: underline;
    text-underline-offset: 2px;
}

.detail-value a:hover { text-decoration-color: var(--muted); }

.detail-section {
    border-top: 1px solid var(--border);
    margin-top: 0.25rem;
}

.detail-section-header {
    display: flex;
    align-items: center;
    padding: 0.5rem 0;
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--muted);
    cursor: pointer;
    list-style: none;
    user-select: none;
}

.detail-section-header::-webkit-details-marker { display: none; }

.detail-section-header::after {
    content: "+";
    margin-left: auto;
    font-size: 0.875rem;
    font-weight: 400;
    color: var(--muted);
    transition: transform 0.15s;
}

details.detail-section[open] > .detail-section-header::after {
    content: "\2212";
}

.detail-section .detail-table {
    margin-bottom: 0.25rem;
}

.detail-variants {
    font-size: 0.8125rem;
    color: var(--muted);
    line-height: 1.5;
    padding: 0 0 0.375rem;
}

.detail-actions {
    display: flex;
    gap: 0.5rem;
    border-top: 1px solid var(--border);
    padding-top: 0.75rem;
    margin-top: 0.5rem;
}

.save-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    flex: 1;
    justify-content: center;
    padding: 0.5rem 1rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--surface);
    color: var(--fg);
    font-size: 0.8125rem;
    font-weight: 500;
    line-height: normal;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
    text-decoration: none;
}

.save-btn:hover { background: var(--bg); border-color: var(--fg); }
.save-btn:disabled { cursor: default; opacity: 0.7; }
.save-btn--saved { color: #22c55e; border-color: #22c55e; }
.save-btn--just-saved { animation: save-pop 0.3s ease; }
.save-btn--saved:hover { background: var(--surface); border-color: #22c55e; }
.save-btn--loading { opacity: 0.6; }
.save-btn--error { color: #ef4444; border-color: #ef4444; animation: save-shake 0.4s ease; }
.save-btn--error:hover { background: var(--surface); border-color: #ef4444; }

.portfolio-signup-nudge {
    font-size: 0.8rem;
    color: var(--muted);
    text-align: center;
    padding: 0.5rem 0 0;
}
.portfolio-signup-nudge a {
    color: var(--accent, #2563eb);
    text-decoration: underline;
}

@keyframes save-pop {
    0% { transform: scale(1); }
    50% { transform: scale(1.04); }
    100% { transform: scale(1); }
}

@keyframes save-shake {
    0%, 100% { transform: translateX(0); }
    20% { transform: translateX(-4px); }
    40% { transform: translateX(4px); }
    60% { transform: translateX(-3px); }
    80% { transform: translateX(2px); }
}

/* ---- Detail skeleton (loading state) ---- */

.detail-skeleton {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    padding: 1rem;
}

.skel-line {
    height: 0.75rem;
    background: var(--border);
    border-radius: 4px;
    animation: shimmer 1.5s infinite;
}

.skel-line:nth-child(1) { width: 60%; height: 1rem; }
.skel-line:nth-child(2) { width: 35%; }
.skel-line:nth-child(3) { width: 80%; }
.skel-line:nth-child(4) { width: 50%; }
.skel-line:nth-child(5) { width: 70%; }

@keyframes shimmer {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

/* ---- Sign-out ---- */

.sign-out-wrap {
    text-align: center;
    padding: 4rem 1rem;
}

.sign-out-wrap h1 {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
}

.sign-out-wrap p {
    color: var(--muted);
}

/* ---- Mobile nav toggle + dropdown ---- */

.topbar-toggle {
    display: none;
    background: none;
    border: none;
    padding: 0.375rem;
    cursor: pointer;
    color: var(--fg);
    line-height: 0;
}

.nav-dropdown {
    position: fixed;
    inset: unset;
    top: 52px;
    left: 1.25rem;
    min-width: 160px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.5rem;
    box-shadow: 0 4px 16px var(--shadow-sm);
    margin: 0;
    display: none;
    flex-direction: column;
    gap: 0.125rem;
}

.nav-dropdown:popover-open { display: flex; }

.nav-dropdown .nav-link {
    padding-block: 0.5rem;
}


/* ---- Pricing ---- */

/* Pricing layout */
.pricing {
    padding-bottom: 2rem;
}

.pricing-header {
    text-align: center;
    margin-bottom: 3rem;
}

.pricing-eyebrow {
    font-size: 0.8125rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--muted);
    margin-bottom: 0.75rem;
}

.pricing-header h1 {
    font-size: 2.25rem;
    font-weight: 700;
    letter-spacing: -0.03em;
    line-height: 1.15;
    margin-bottom: 0.75rem;
}

.pricing-subtitle {
    color: var(--muted);
    font-size: 1.0625rem;
    line-height: 1.5;
}

/* Card grid */
.pricing-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(260px, 100%), 1fr));
    gap: 16px;
}

/* Cards */
.pricing-card {
    position: relative;
    display: flex;
    flex-direction: column;
    background: var(--surface);
    padding: 0;
    border: 1px solid var(--border);
    border-radius: 12px;
    overflow: hidden;
    transition: transform 0.2s, box-shadow 0.2s;
}

.pricing-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 24px var(--shadow-sm);
}

.pricing-card-body {
    padding: 2rem 1.75rem 0;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.pricing-card-top {
    padding-bottom: 1.5rem;
}

/* Featured card */
.pricing-card--featured {
    background: var(--bg);
    border-width: 2px;
    border-color: var(--accent);
}

.pricing-badge {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: var(--accent);
    color: var(--accent-fg);
    font-size: 0.6875rem;
    font-weight: 600;
    padding: 0.25rem 0.625rem;
    border-radius: 999px;
    white-space: nowrap;
    letter-spacing: 0.02em;
    text-transform: uppercase;
}

/* Plan name */
.pricing-plan-name {
    display: block;
    font-size: 0.9375rem;
    font-weight: 600;
    margin-bottom: 1rem;
}

/* Price */
.pricing-price {
    display: flex;
    align-items: flex-start;
    gap: 0;
    margin-bottom: 0.75rem;
}

.pricing-currency {
    font-size: 1.25rem;
    font-weight: 600;
    line-height: 1;
    margin-top: 0.375rem;
    margin-right: 0.125rem;
    color: var(--muted);
}

.pricing-amount {
    font-size: 3.5rem;
    font-weight: 700;
    letter-spacing: -0.04em;
    line-height: 1;
}

.pricing-amount--label {
    font-size: 3.5rem;
    letter-spacing: -0.04em;
}

.pricing-period {
    font-size: 0.875rem;
    color: var(--muted);
    align-self: flex-end;
    margin-bottom: 0.375rem;
    margin-left: 0.25rem;
}

.pricing-description {
    font-size: 0.875rem;
    color: var(--muted);
    line-height: 1.5;
}

/* Divider */
.pricing-divider {
    height: 1px;
    background: var(--border);
    margin-bottom: 1.5rem;
}

/* Features */
.pricing-features {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    flex: 1;
}

.pricing-features li {
    font-size: 0.875rem;
    display: flex;
    align-items: center;
    gap: 0.625rem;
    line-height: 1.4;
}

.pricing-check {
    flex-shrink: 0;
    color: var(--muted);
}

.pricing-card--featured .pricing-check {
    color: var(--fg);
}

/* Card footer / buttons */
.pricing-card-footer {
    padding: 1.75rem 1.75rem 2rem;
    margin-top: auto;
}

.pricing-card-footer form {
    margin: 0;
}

.pricing-btn {
    display: block;
    width: 100%;
    text-align: center;
    padding: 0.75rem 1.25rem;
    font-size: 0.875rem;
    font-weight: 500;
    font-family: var(--font);
    border-radius: var(--radius);
    text-decoration: none;
    cursor: pointer;
    border: none;
    transition: all 0.15s ease;
}

.pricing-btn--primary {
    background: var(--accent);
    color: var(--accent-fg);
}

.pricing-btn--primary:hover {
    opacity: 0.85;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px var(--shadow-sm);
}

.pricing-btn--outline {
    background: transparent;
    color: var(--fg);
    box-shadow: inset 0 0 0 1px var(--border);
}

.pricing-btn--outline:hover {
    box-shadow: inset 0 0 0 1px var(--fg);
}

.pricing-btn--current,
.pricing-btn--disabled {
    background: transparent;
    color: var(--muted);
    box-shadow: inset 0 0 0 1px var(--border);
    cursor: default;
}

.pricing-btn--current:hover,
.pricing-btn--disabled:hover {
    box-shadow: inset 0 0 0 1px var(--muted);
}


/* ---- Property Page ---- */

.page-property {
    width: min(720px, 100% - 2rem);
}

/* Property hero with map backdrop */
.property-hero {
    position: relative;
    border-radius: var(--radius);
    margin-bottom: 1.5rem;
    overflow: hidden;
}

.property-hero.has-map {
    margin-bottom: 0;
}

.property-hero.has-map {
    border-radius: 0;
}

.property-hero.has-map .property-hero-text {
    position: relative;
    z-index: 1;
    padding: 0.75rem 0;
    background: rgba(255, 255, 255, 0.75);
    backdrop-filter: blur(4px);
}

.property-hero:not(.has-map) .property-hero-text {
    padding-bottom: 0.5rem;
}

.property-hero h1 {
    font-size: clamp(1.25rem, 3vw, 1.75rem);
}

.property-hero .subtitle {
    margin-top: 0.25rem;
}

.map-open-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    z-index: 500;
    display: grid;
    place-items: center;
    width: 28px;
    height: 28px;
    border-radius: 6px;
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--muted);
    text-decoration: none;
    cursor: pointer;
    transition: color 0.15s, border-color 0.15s;
    box-shadow: 0 1px 3px var(--shadow-sm);
}

.map-open-btn:hover {
    color: var(--fg);
    border-color: var(--fg);
}

.property-empty {
    text-align: center;
    color: var(--muted);
    padding: 3rem 1rem;
    font-size: 0.9375rem;
}

.detail-as-of {
    color: var(--muted);
    font-size: 0.75rem;
}

/* ---- Source colors ---- */

:root {
    --source-attom: #c0533e;
    --source-smarty: #2563eb;
    --source-socrata: #16a34a;
    --source-nc-onemap: #7c3aed;
    --source-arcgis: #b45309;
    --source-spatialest: #0e7490;
    --source-other: #6b7280;
}


.source-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem 0.75rem;
    padding: 0.25rem 0 0.375rem;
}

.source-legend__item {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    font-size: 0.6875rem;
    color: var(--muted);
}

.source-values {
    display: flex;
    flex-wrap: wrap;
    gap: 0.125rem 0.75rem;
}

.source-value {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    font-size: 0.8125rem;
}

.source-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    flex-shrink: 0;
}

.source-name {
    font-size: 0.6875rem;
    color: var(--muted);
}

.source--attom    .source-dot { background: var(--source-attom); }
.source--smarty   .source-dot { background: var(--source-smarty); }
.source--socrata  .source-dot { background: var(--source-socrata); }
.source--nc-onemap .source-dot { background: var(--source-nc-onemap); }
.source--arcgis   .source-dot { background: var(--source-arcgis); }
.source--spatialest .source-dot { background: var(--source-spatialest); }
.source--other    .source-dot { background: var(--source-other); }

/* ---- Valuation ---- */

.valuation-section {
    margin-top: 1.5rem;
    margin-bottom: 1rem;
    border-top: 1px solid var(--border);
    padding-top: 0.75rem;
}

.valuation-title {
    font-size: 0.8125rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--muted);
    margin-bottom: 0.25rem;
}

.valuation-summary { display: flex; gap: 1.5rem; padding: 0.75rem 0; flex-wrap: wrap; }
.valuation-stat-value { font-size: 1.25rem; font-weight: 700; }
.valuation-stat-label { font-size: 0.75rem; color: var(--muted); }
.valuation-chart-wrap { position: relative; margin: 0.5rem 0 0.75rem; }

/* ---- Detail card address link ---- */

a.detail-link {
    color: inherit;
    text-decoration: none;
}

a.detail-link:hover {
    text-decoration: none;
    background: var(--bg);
    border-color: var(--fg);
}

/* ---- Portfolio Dashboard ---- */

.page-portfolio {
    width: min(960px, 100% - 2rem);
}

.portfolio-header {
    margin-bottom: 1.5rem;
}

.portfolio-header h1 {
    font-size: clamp(1.5rem, 3vw, 2rem);
}

.portfolio-summary {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-top: 0.375rem;
    font-size: 0.875rem;
    color: var(--muted);
}

.portfolio-summary-sep {
    color: var(--border);
}

.portfolio-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.portfolio-control {
    display: flex;
    align-items: center;
    gap: 0.375rem;
}

.portfolio-control label {
    font-size: 0.75rem;
    color: var(--muted);
}

.portfolio-control select {
    font-size: 0.75rem;
    font-family: var(--font);
    padding: 0.25rem 0.5rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--fg);
    cursor: pointer;
}

.portfolio-control select:focus {
    outline: 2px solid var(--focus-ring);
    outline-offset: 1px;
}

#portfolio-map {
    height: 280px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 1rem;
}

.portfolio-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1rem;
}

.portfolio-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transition: background-color 0.15s ease, box-shadow 0.15s ease;
}

.portfolio-card-thumb {
    width: 100%;
    height: 120px;
    object-fit: cover;
    display: block;
}

.portfolio-card-body {
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    min-width: 0;
    flex: 1;
}

.portfolio-card--linked:hover {
    border-color: var(--muted);
}

.portfolio-card--linked {
    cursor: pointer;
}

.portfolio-card--linked:focus-visible {
    outline: 2px solid var(--focus-ring);
    outline-offset: -2px;
}

.portfolio-card-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.portfolio-card-name {
    font-weight: 600;
    font-size: 0.875rem;
    color: var(--fg);
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.portfolio-card-subtitle {
    font-size: 0.8125rem;
    color: var(--muted);
}

.portfolio-card-stats {
    display: flex;
    gap: 1.25rem;
    margin-top: 0.375rem;
}

.portfolio-card-stat {
    display: flex;
    flex-direction: column;
}

.portfolio-card-stat-value {
    font-size: 0.875rem;
    font-weight: 600;
}

.portfolio-card-stat-label {
    font-size: 0.6875rem;
    color: var(--muted);
}

.portfolio-card-footer {
    font-size: 0.75rem;
    color: var(--muted);
    margin-top: auto;
    padding: 0.5rem 1rem;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.portfolio-card-link {
    color: var(--muted);
    font-size: 0.75rem;
    text-decoration: underline;
    text-underline-offset: 2px;
}
.portfolio-card-link:hover { color: var(--fg); }

.portfolio-card-remove {
    background: none;
    border: none;
    color: var(--muted);
    font-family: var(--font);
    font-size: 0.75rem;
    cursor: pointer;
    padding: 0;
    text-decoration: underline;
    text-underline-offset: 2px;
}

.portfolio-card-remove:hover {
    color: var(--fg);
}

.portfolio-card-footer--no-date {
    justify-content: flex-end;
}


/* ---- Comparable Sales Page ---- */

.page-comps {
    width: min(960px, 100% - 2rem);
}

.comps-header {
    margin-bottom: 1rem;
}

.comps-back {
    font-size: 0.8125rem;
    color: var(--muted);
    text-decoration: none;
}

.comps-back:hover { color: var(--fg); }

.comps-header h1 {
    font-size: clamp(1.25rem, 3vw, 1.75rem);
    margin-top: 0.25rem;
}

.comps-header .subtitle {
    margin-top: 0.125rem;
}

#comps-map {
    height: 400px;
    width: 100%;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    margin-bottom: 1rem;
    z-index: 1;
}

.comps-controls {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.comps-control {
    display: flex;
    align-items: center;
    gap: 0.375rem;
}

.comps-control label {
    font-size: 0.75rem;
    color: var(--muted);
}

.comps-control select,
.comps-control input {
    font-size: 0.75rem;
    font-family: var(--font);
    padding: 0.25rem 0.5rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--fg);
}

.comps-control input { width: 5rem; }

.comps-stats {
    display: flex;
    gap: 1.5rem;
    padding: 0.75rem 0;
    flex-wrap: wrap;
    border-bottom: 1px solid var(--border);
    margin-bottom: 0.5rem;
}

.comps-stat-value { font-size: 1.125rem; font-weight: 700; }
.comps-stat-label { font-size: 0.75rem; color: var(--muted); }

.comps-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8125rem;
}

.comps-table th {
    text-align: left;
    padding: 0.5rem 0.5rem;
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--muted);
    border-bottom: 1px solid var(--border);
    user-select: none;
}

.comps-table th.sortable { cursor: pointer; }
.comps-table th.sortable:hover { color: var(--fg); }
.comps-table th.sort-asc::after { content: " \25B2"; font-size: 0.5rem; }
.comps-table th.sort-desc::after { content: " \25BC"; font-size: 0.5rem; }

.comps-table td {
    padding: 0.375rem 0.5rem;
    border-bottom: 1px solid var(--border);
}

.comps-table tr.hidden { display: none; }

.comps-table tbody tr:hover {
    background: var(--hover-overlay);
}

.valuation-links {
    display: flex;
    gap: 1.25rem;
    margin-top: 0.25rem;
}

.comps-link {
    display: inline-block;
    font-size: 0.8125rem;
    color: var(--muted);
    text-decoration: none;
}

.comps-link:hover {
    color: var(--fg);
    text-decoration: underline;
}

/* ---- Analysis Page ---- */

.page-analysis {
    width: min(1280px, 100%);
    padding: 0 clamp(1rem, 3vw, 5rem);
}

.analysis-back {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--muted);
    font-size: 0.8125rem;
    font-weight: 500;
    text-decoration: none;
    margin-bottom: 0.75rem;
}
.analysis-back:hover { color: var(--fg); }
.analysis-back svg { flex-shrink: 0; }

.analysis-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.analysis-header-left {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.analysis-header h1 {
    font-size: 1.375rem;
    font-weight: 700;
    letter-spacing: -0.5px;
}

.analysis-subtitle {
    font-size: 0.875rem;
    color: var(--muted);
}

/* Scenario Tabs */
.scenario-tabs-container {
    display: flex;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 4px;
    margin-bottom: 1rem;
}

.scenario-tab {
    display: flex;
    flex-direction: column;
    align-items: center;
    flex: 1;
    border-radius: 6px;
    padding: 10px 16px;
    text-decoration: none;
    color: var(--muted);
    gap: 2px;
    transition: background 0.15s, color 0.15s;
}

.scenario-tab.active {
    background: var(--fg);
    color: var(--bg);
}

.scenario-tab-name {
    font-size: 0.8125rem;
    font-weight: 500;
}

.scenario-tab.active .scenario-tab-name { font-weight: 600; }

.scenario-tab-irr {
    font-size: 0.6875rem;
    font-weight: 500;
    opacity: 0.7;
}

/* Slider Cards */
.slider-cards {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    margin-bottom: 1.5rem;
}

.slider-card {
    flex: 1 1 min(260px, 100%);
    display: flex;
    flex-direction: column;
    gap: 12px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
}

.slider-card-title {
    font-size: 0.875rem;
    font-weight: 700;
}

.slider-row {
    display: flex;
    align-items: center;
    gap: 12px;
}

.slider-label {
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--muted);
    width: clamp(60px, 15vw, 110px);
    flex-shrink: 0;
}

.slider-track-wrap {
    flex: 1;
    display: flex;
    align-items: center;
    height: 20px;
}

/* Range slider styling */
.slider-input {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 4px;
    border-radius: 2px;
    background: var(--border);
    outline: none;
}

.slider-input::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--surface);
    border: 1px solid var(--border);
    box-shadow: 0 1px 4px rgba(0,0,0,0.1);
    cursor: pointer;
    margin-top: -4px;
}

.slider-input::-moz-range-thumb {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--surface);
    border: 1px solid var(--border);
    box-shadow: 0 1px 4px rgba(0,0,0,0.1);
    cursor: pointer;
}

.slider-input::-webkit-slider-runnable-track {
    height: 4px;
    border-radius: 2px;
}

.slider-input::-moz-range-progress {
    height: 4px;
    border-radius: 2px;
    background: #22c55e;
}

.slider-value {
    font-size: 0.875rem;
    font-weight: 700;
    white-space: nowrap;
    min-width: 75px;
    text-align: right;
}

/* Analysis Main (stacked cards) */
.analysis-main {
    display: flex;
    flex-direction: column;
    gap: 20px;
    max-width: 640px;
}

/* P&L Card */
.pnl-card {
    display: flex;
    flex-direction: column;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    width: 100%;
    min-width: 0;
}

.pnl-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
}

.pnl-title-group {
    display: flex;
    align-items: center;
    gap: 10px;
}

.pnl-title-group svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

.pnl-title-text {
    font-size: 0.9375rem;
    font-weight: 600;
}

.pnl-year-badge {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 4px 10px;
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--muted);
}

.pnl-divider {
    height: 1px;
    background: var(--border);
}

.pnl-body-top {
    padding: 4px 20px 0;
}

.pnl-body-bottom {
    padding: 12px 20px 20px;
}

.pnl-section-label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--muted);
    text-transform: uppercase;
    padding: 12px 0 4px;
    display: block;
}

.pnl-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
}

.pnl-row-label {
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--muted);
}

.pnl-row-value {
    font-size: 0.8125rem;
    font-weight: 500;
    font-variant-numeric: tabular-nums;
}

.pnl-row-value.negative { color: #ef4444; }

/* Inline slider in P&L row (Gross Rental Income) */
.pnl-row-slider {
    gap: 12px;
}

.pnl-row-slider .pnl-row-label {
    flex-shrink: 0;
    white-space: nowrap;
}

.pnl-row-slider .pnl-row-value {
    flex-shrink: 0;
    width: 70px;
    text-align: right;
}

.pnl-slider-wrap {
    flex: 1;
    position: relative;
    min-width: 0;
    display: flex;
    align-items: center;
}

.pnl-slider-tooltip {
    position: absolute;
    bottom: calc(100% + 4px);
    left: 0;
    font-size: 0.75rem;
    font-weight: 600;
    color: #fff;
    background: #111;
    border-radius: 6px;
    padding: 3px 10px;
    white-space: nowrap;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.15s;
    transform: translateX(-50%);
}

.pnl-slider-wrap.active .pnl-slider-tooltip {
    opacity: 1;
}

.pnl-row-slider .slider-input {
    width: 100%;
}

/* Financing box embedded in P&L */
.pnl-financing-box {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px 14px;
    margin: 0 0 12px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.pnl-financing-row {
    display: flex;
    align-items: center;
    gap: 12px;
}

.pnl-financing-label {
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--muted);
    width: 100px;
    flex-shrink: 0;
}

.pnl-financing-row .slider-input {
    flex: 1;
    min-width: 0;
}

.pnl-financing-value {
    font-size: 0.8125rem;
    font-weight: 600;
    white-space: nowrap;
    min-width: 70px;
    text-align: right;
}

.pnl-subtotal {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 0;
    border-top: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
}

.pnl-subtotal-label {
    font-size: 0.8125rem;
    font-weight: 700;
}

.pnl-subtotal-value {
    font-size: 0.8125rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.pnl-subtotal-value.negative { color: #ef4444; }

.pnl-section-header.pnl-section-expandable {
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    user-select: none;
}

.pnl-section-expandable .pnl-section-label {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 12px 0 4px;
}

.pnl-section-total {
    font-size: 0.8125rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    transition: opacity 0.2s ease;
}

.pnl-section-total.negative { color: #ef4444; }

.pnl-section-expandable.expanded .pnl-section-total {
    opacity: 0;
}

.pnl-section-collapsible {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.25s ease, overflow 0s 0.25s;
}

.pnl-section-expandable.expanded + .pnl-section-collapsible {
    max-height: 800px;
    overflow: visible;
    transition: max-height 0.25s ease, overflow 0s 0s;
}

.pnl-row-expandable {
    cursor: pointer;
    user-select: none;
}

.pnl-row-expandable .pnl-row-label {
    display: flex;
    align-items: center;
    gap: 6px;
}

.pnl-expand-icon {
    transition: transform 0.2s ease;
    flex-shrink: 0;
    color: var(--text-tertiary);
}

.pnl-section-expandable.expanded .pnl-expand-icon,
.pnl-row-expandable.expanded .pnl-expand-icon {
    transform: rotate(45deg);
}

.pnl-details-collapsible {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.25s ease, overflow 0s 0.25s;
}

.pnl-row-expandable.expanded + .pnl-details-collapsible {
    max-height: 400px;
    overflow: visible;
    transition: max-height 0.25s ease, overflow 0s 0s;
}

/* P&L Highlights */
.pnl-highlight {
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-radius: 6px;
    padding: 12px 16px;
    width: 100%;
}

.pnl-highlight.positive {
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
}

.pnl-highlight.dark {
    background: var(--fg);
}

.pnl-highlight-label {
    display: flex;
    align-items: center;
    gap: 8px;
}

.pnl-highlight-label svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

.pnl-highlight.positive .pnl-highlight-label svg,
.pnl-highlight.positive .pnl-highlight-label span {
    color: #15803d;
}

.pnl-highlight.positive .pnl-highlight-label span {
    font-size: 0.8125rem;
    font-weight: 600;
}

.pnl-highlight.positive .pnl-highlight-value {
    font-size: 0.9375rem;
    font-weight: 700;
    color: #15803d;
}

.pnl-highlight.dark .pnl-highlight-label svg,
.pnl-highlight.dark .pnl-highlight-label span {
    color: var(--bg);
}

.pnl-highlight.dark .pnl-highlight-label span {
    font-size: 0.8125rem;
    font-weight: 600;
}

.pnl-highlight.dark .pnl-highlight-value {
    font-size: 0.9375rem;
    font-weight: 700;
    color: #22c55e;
}

.pnl-highlight.muted {
    background: var(--bg);
    border: 1px solid var(--border);
}

.pnl-highlight.muted .pnl-highlight-label svg,
.pnl-highlight.muted .pnl-highlight-label span {
    color: var(--muted);
}

.pnl-highlight.muted .pnl-highlight-label span {
    font-size: 0.8125rem;
    font-weight: 600;
}

.pnl-highlight.muted .pnl-highlight-value {
    font-size: 0.9375rem;
    font-weight: 700;
}

.pnl-highlight.accent {
    background: #eff6ff;
    border: 1px solid #bfdbfe;
}

.pnl-highlight.accent .pnl-highlight-label svg,
.pnl-highlight.accent .pnl-highlight-label span {
    color: #1e40af;
}

.pnl-highlight.accent .pnl-highlight-label span {
    font-size: 0.8125rem;
    font-weight: 600;
}

.pnl-highlight.accent .pnl-highlight-value {
    font-size: 0.9375rem;
    font-weight: 700;
    color: #1d4ed8;
}

.pnl-spacer { height: 16px; }
.pnl-spacer-sm { height: 8px; }
.pnl-spacer-md { height: 12px; }

.pnl-metrics-divider {
    height: 1px;
    background: var(--border);
}

.pnl-metrics {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    justify-content: space-between;
}

.pnl-metric {
    display: flex;
    flex-direction: column;
    align-items: center;
    flex: 1;
    min-width: 60px;
    gap: 2px;
}

.pnl-metric-value {
    font-size: 1rem;
    font-weight: 700;
}

.pnl-metric-label {
    font-size: 0.6875rem;
    font-weight: 500;
    color: var(--muted);
    text-align: center;
}


.analysis-save-btn {
    flex-shrink: 0;
}

/* ---- Analysis toolbar (share/export/print) ---- */

.analysis-toolbar {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-shrink: 0;
}

.analysis-toolbar .btn {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    font-size: 0.8125rem;
    padding: 0.375rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--fg);
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
    white-space: nowrap;
}

.analysis-toolbar .btn:hover {
    border-color: var(--fg);
    background: var(--hover-overlay);
}

.analysis-toolbar .btn svg {
    flex-shrink: 0;
}

/* Saved scenarios bar */
.saved-scenarios-bar {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1.25rem;
    padding: 0.625rem 0.875rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow-x: auto;
}

.saved-scenarios-label {
    font-size: 0.6875rem;
    font-weight: 600;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    white-space: nowrap;
}

.saved-scenarios-pills {
    display: flex;
    gap: 0.5rem;
}

.saved-scenario-pill {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.3125rem 0.625rem;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 100px;
    text-decoration: none;
    color: inherit;
    font-size: 0.75rem;
    white-space: nowrap;
    transition: border-color 0.15s;
}

.saved-scenario-pill:hover {
    border-color: var(--fg);
}

.saved-scenario-pill-name {
    font-weight: 600;
}

.saved-scenario-pill-stat {
    color: var(--muted);
}

/* ---- Scenario Pages ---- */

.page-scenarios {
    width: min(960px, 100% - 2rem);
}

.page-scenario-detail {
    width: min(1100px, 100% - 2rem);
}

.scenario-back {
    font-size: 0.8125rem;
    color: var(--muted);
    text-decoration: none;
}
.scenario-back:hover { color: var(--fg); }

.scenario-list-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin: 0.375rem 0 1.5rem;
}

.scenario-list-header h1 {
    font-size: clamp(1.25rem, 3vw, 1.75rem);
}

/* Scenario cards grid */
.scenario-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1px;
    background: var(--border);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}

.scenario-card {
    background: var(--surface);
    padding: 1rem 1.25rem;
    cursor: pointer;
    transition: background 0.15s;
    text-decoration: none;
    color: inherit;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}
.scenario-card:hover { background: var(--bg); }

.scenario-card-name {
    font-weight: 600;
    font-size: 0.875rem;
}

.scenario-card-stats {
    display: flex;
    gap: 1.25rem;
}

.scenario-card-stat { display: flex; flex-direction: column; }

.scenario-card-stat-value {
    font-size: 0.875rem;
    font-weight: 600;
}

.scenario-card-stat-value--accent { color: var(--positive, #16a34a); }

.scenario-card-stat-label {
    font-size: 0.6875rem;
    color: var(--muted);
}

.scenario-card-meta {
    font-size: 0.6875rem;
    color: var(--muted);
}

/* Detail page header */
.scenario-header {
    margin-bottom: 1.5rem;
}

.scenario-title-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-top: 0.375rem;
}

.scenario-name-input {
    font-size: clamp(1.25rem, 3vw, 1.75rem);
    font-weight: 700;
    letter-spacing: -0.02em;
    background: none;
    border: none;
    border-bottom: 1px dashed var(--border);
    color: var(--fg);
    font-family: var(--font);
    padding: 0 0 2px;
    width: 20ch;
}
.scenario-name-input:focus {
    outline: none;
    border-bottom-color: var(--fg);
}

.scenario-meta {
    font-size: 0.8125rem;
    color: var(--muted);
    margin-top: 0.25rem;
}

/* Two-column layout */
.scenario-layout {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(320px, 100%), 1fr));
    gap: 32px;
    align-items: start;
}

/* Input panel */
.input-panel {
    position: sticky;
    top: calc(56px + 1rem);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    overflow: hidden;
    max-height: calc(100vh - 56px - 2rem);
    overflow-y: auto;
}

.input-section {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border);
}
.input-section:last-child { border-bottom: none; }

.input-section-title {
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--muted);
    margin-bottom: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.input-section-toggle {
    cursor: pointer;
    user-select: none;
    list-style: none;
}
.input-section-toggle::-webkit-details-marker { display: none; }
.input-section-toggle::after {
    content: "+";
    font-size: 0.875rem;
    font-weight: 400;
    color: var(--muted);
}
details.input-section[open] > .input-section-toggle::after {
    content: "\2212";
}

.input-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem 0.75rem;
}
.input-grid .full { grid-column: 1 / -1; }

.input-group {
    display: flex;
    flex-direction: column;
    gap: 0.1875rem;
}

.input-group label {
    font-size: 0.6875rem;
    color: var(--muted);
    font-weight: 500;
}

.input-group input,
.input-group select {
    font-size: 0.8125rem;
    font-family: var(--font);
    padding: 0.375rem 0.5rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--bg);
    color: var(--fg);
    width: 100%;
}

.input-group input:focus {
    outline: none;
    border-color: var(--fg);
    box-shadow: 0 0 0 3px var(--focus-ring);
}

.input-suffix {
    position: relative;
}
.input-suffix input { padding-right: 2rem; }
.input-suffix::after {
    position: absolute;
    right: 0.5rem;
    bottom: 0.4375rem;
    font-size: 0.75rem;
    color: var(--muted);
    pointer-events: none;
}
.input-suffix--pct::after { content: "%"; }
.input-suffix--yr::after { content: "yr"; }
.input-suffix--mo::after { content: "/mo"; }

/* Results panel */
.results-panel {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.results-panel {
    max-width: none;
}

/* KPI row */
.kpi-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(120px, 100%), 1fr));
    gap: 1px;
    background: var(--border);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}

.kpi-card {
    background: var(--surface);
    padding: 16px;
}

.kpi-value {
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}
.kpi-value--positive { color: var(--positive, #16a34a); }
.kpi-value--negative { color: var(--negative, #dc2626); }

.kpi-label {
    font-size: 0.75rem;
    color: var(--muted);
    margin-top: 0.125rem;
}

/* Chart */
.chart-section {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    overflow: hidden;
}

.chart-tabs {
    display: flex;
    border-bottom: 1px solid var(--border);
}

.chart-tab {
    padding: 0.5rem 1rem;
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--muted);
    cursor: pointer;
    border: none;
    background: none;
    font-family: var(--font);
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
}
.chart-tab:hover { color: var(--fg); }
.chart-tab.active {
    color: var(--fg);
    border-bottom-color: var(--fg);
}

.chart-canvas {
    height: 240px;
    padding: 1rem;
    position: relative;
}

/* Projection table */
.projection-table-wrap {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}

.projection-table-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.625rem 1rem;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}

.projection-table-title {
    font-size: 0.8125rem;
    font-weight: 600;
}

.projection-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.75rem;
}

.projection-table th {
    text-align: right;
    padding: 0.4375rem 0.625rem;
    font-size: 0.625rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--muted);
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}
.projection-table th:first-child { text-align: left; }

.projection-table td {
    padding: 0.375rem 0.625rem;
    text-align: right;
    border-bottom: 1px solid var(--border);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.projection-table td:first-child {
    text-align: left;
    font-weight: 600;
    color: var(--muted);
}

.projection-table tbody tr:hover {
    background: var(--hover-overlay);
}

.projection-table .row-positive { color: var(--positive, #16a34a); }
.projection-table .row-negative { color: var(--negative, #dc2626); }

.scenario-delete-btn {
    width: 100%;
    text-align: center;
    color: var(--muted);
    font-size: 0.75rem;
}
.scenario-delete-btn:hover {
    color: #dc2626;
    border-color: #dc2626;
    background: transparent;
    opacity: 1;
}



