/* ============================================
   Property Investor Calculator — Stylesheet
   Enhanced Design System v2.0
   ============================================ */

:root {
    /* ── Color Palette ── */
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --primary-light: #dbeafe;
    --primary-50: #eff6ff;
    --primary-100: #dbeafe;
    --primary-500: #3b82f6;
    --primary-600: #2563eb;
    --primary-700: #1d4ed8;
    --primary-900: #1e3a8a;
    --success: #16a34a;
    --success-bg: #dcfce7;
    --success-50: #f0fdf4;
    --success-500: #22c55e;
    --success-700: #15803d;
    --danger: #dc2626;
    --danger-bg: #fef2f2;
    --danger-50: #fef2f2;
    --danger-500: #ef4444;
    --danger-700: #b91c1c;
    --warning: #f59e0b;

    /* ── Neutral Scale ── */
    --neutral-50:  #f8fafc;
    --neutral-100: #f1f5f9;
    --neutral-200: #e2e8f0;
    --neutral-300: #cbd5e1;
    --neutral-400: #94a3b8;
    --neutral-500: #64748b;
    --neutral-600: #475569;
    --neutral-700: #334155;
    --neutral-800: #1e293b;
    --neutral-900: #0f172a;

    /* ── Surfaces ── */
    --bg: #f8fafc;
    --surface: #ffffff;
    --surface-raised: #ffffff;
    --text: #1e293b;
    --text-muted: #64748b;
    --border: #e2e8f0;
    --border-hover: #cbd5e1;

    /* ── Typography Scale (modular, 1.2 ratio) ── */
    --text-2xs:  0.6875rem; /* 11px  - badges, micro-labels */
    --text-xs:   0.75rem;   /* 12px  - captions, hints */
    --text-sm:   0.8125rem; /* 13px  - small labels, table cells */
    --text-md:   0.875rem;  /* 14px  - tabs, form labels, secondary text */
    --text-base: 1rem;      /* 16px  - body */
    --text-lg:   1.125rem;  /* 18px  - emphasized values */
    --text-xl:   1.25rem;   /* 20px  - card values */
    --text-2xl:  1.5rem;    /* 24px  - section headings */
    --text-3xl:  1.875rem;  /* 30px  - page titles */
    --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, monospace;
    --font-normal:  400;
    --font-medium:  500;
    --font-semibold: 600;
    --font-bold:    700;

    /* ── Line Heights ── */
    --leading-tight:   1.25;
    --leading-snug:    1.375;
    --leading-normal:  1.5;
    --leading-relaxed: 1.625;

    /* ── Letter Spacing ── */
    --tracking-tight:  -0.02em;
    --tracking-normal:  0;
    --tracking-wide:    0.03em;

    /* ── Spacing System (4px base) ── */
    --space-1:  0.25rem;   /* 4px */
    --space-2:  0.5rem;    /* 8px */
    --space-3:  0.75rem;   /* 12px */
    --space-4:  1rem;      /* 16px */
    --space-5:  1.25rem;   /* 20px */
    --space-6:  1.5rem;    /* 24px */
    --space-8:  2rem;      /* 32px */
    --space-10: 2.5rem;    /* 40px */
    --space-12: 3rem;      /* 48px */
    --space-16: 4rem;      /* 64px */

    /* ── Radius & Shadows ── */
    --radius: 8px;
    --radius-lg: 12px;
    --radius-full: 9999px;
    --shadow: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.08), 0 2px 4px -2px rgba(0,0,0,0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.08), 0 4px 6px -4px rgba(0,0,0,0.04);

    /* ── Animation / Motion ── */
    --duration-fast:   150ms;
    --duration-base:   250ms;
    --duration-slow:   350ms;
    --duration-slower: 500ms;
    --ease-in:     cubic-bezier(0.4, 0, 1, 1);
    --ease-out:    cubic-bezier(0, 0, 0.2, 1);
    --ease-in-out: cubic-bezier(0.4, 0, 0.2, 1);
    --ease-spring: cubic-bezier(0.68, -0.55, 0.265, 1.55);
    --transition: 200ms cubic-bezier(0.4, 0, 0.2, 1);

    /* ── Misc ── */
    --hover-row: #f1f5f9;
    --header-bg: linear-gradient(135deg, #1e40af 0%, #2563eb 50%, #3b82f6 100%);
    --input-bg: var(--surface);
    --portfolio-fieldset-bg: #f0f9ff;
    --portfolio-fieldset-border: #bae6fd;
    --portfolio-legend: #0369a1;
    --card-bg: var(--surface);
}

/* ── Dark Theme ──────────────────────────────────────────────── */
[data-theme="dark"] {
    --primary: #3b82f6;
    --primary-dark: #2563eb;
    --primary-light: rgba(59, 130, 246, 0.15);
    --primary-50: rgba(59, 130, 246, 0.08);
    --primary-100: rgba(59, 130, 246, 0.15);
    --primary-600: #3b82f6;
    --primary-700: #60a5fa;
    --success: #22c55e;
    --success-bg: rgba(34, 197, 94, 0.12);
    --danger: #ef4444;
    --danger-bg: rgba(239, 68, 68, 0.12);
    --warning: #f59e0b;
    --bg: #0f172a;
    --surface: #1e293b;
    --surface-raised: #273549;
    --text: #e2e8f0;
    --text-muted: #94a3b8;
    --border: #334155;
    --border-hover: #475569;
    --shadow: 0 1px 3px rgba(0,0,0,0.3), 0 1px 2px rgba(0,0,0,0.2);
    --shadow-md: 0 4px 6px rgba(0,0,0,0.3), 0 2px 4px rgba(0,0,0,0.2);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.4), 0 4px 6px -4px rgba(0,0,0,0.3);
    --hover-row: #273549;
    --header-bg: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
    --input-bg: #0f172a;
    --portfolio-fieldset-bg: rgba(3, 105, 161, 0.1);
    --portfolio-fieldset-border: #1e3a5f;
    --portfolio-legend: #38bdf8;
    --card-bg: var(--surface);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background: var(--bg); color: var(--text);
    line-height: var(--leading-relaxed); min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    font-size: var(--text-base);
}

h1, h2, h3, h4, h5 { letter-spacing: var(--tracking-tight); line-height: var(--leading-tight); font-weight: var(--font-bold); }
h1 { font-size: var(--text-3xl); }
h2 { font-size: var(--text-2xl); }
h3 { font-size: var(--text-xl); }
h4 { font-size: var(--text-lg); }
h5 { font-size: var(--text-base); font-weight: var(--font-semibold); }

/* ═══════════════════════════════════════════════════════════════════
   Header — Professional SaaS-style
   ═══════════════════════════════════════════════════════════════════ */
header {
    background: var(--header-bg);
    color: #fff;
    padding: 0 1.5rem;
    height: 56px;
    position: sticky; top: 0; z-index: 100;
    backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
    border-bottom: 1px solid rgba(255,255,255,0.08);
}
.header-inner {
    max-width: 1100px; margin: 0 auto;
    display: flex; justify-content: space-between; align-items: center;
    height: 100%;
}

/* Brand / Logo */
.header-brand {
    display: flex; align-items: center; gap: 0.6rem;
    text-decoration: none; color: #fff;
    transition: opacity 0.2s;
}
.header-brand:hover { opacity: 0.85; }
.header-logo-icon {
    width: 36px; height: 36px;
    display: flex; align-items: center; justify-content: center;
    background: rgba(255,255,255,0.15);
    border-radius: var(--radius);
    flex-shrink: 0;
}
.header-logo-icon svg { width: 20px; height: 20px; }
.header-brand-text { display: flex; flex-direction: column; line-height: 1.2; }
.header-brand-name { font-size: var(--text-base); font-weight: var(--font-bold); letter-spacing: var(--tracking-tight); }
.header-brand-tagline { font-size: var(--text-2xs); opacity: 0.65; font-weight: var(--font-normal); letter-spacing: var(--tracking-wide); }

/* Header actions (right side) */
.header-actions {
    display: flex; align-items: center; gap: 0.35rem;
}

/* Icon buttons (theme, info, admin) */
.header-icon-btn {
    width: 36px; height: 36px;
    display: inline-flex; align-items: center; justify-content: center;
    background: transparent;
    border: 1px solid transparent;
    border-radius: var(--radius);
    color: rgba(255,255,255,0.8);
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
    position: relative;
}
.header-icon-btn:hover {
    background: rgba(255,255,255,0.12);
    border-color: rgba(255,255,255,0.15);
    color: #fff;
}
.header-icon-btn svg { flex-shrink: 0; }

/* Sun/Moon icon visibility */
.icon-sun, .icon-moon { display: none; }
[data-theme="dark"] .icon-sun { display: block; }
[data-theme="light"] .icon-moon { display: block; }
html:not([data-theme]) .icon-moon { display: block; }

/* Header divider */
.header-divider {
    width: 1px; height: 24px;
    background: rgba(255,255,255,0.2);
    margin: 0 0.3rem;
}

/* Sign-in button (when logged out) */
.header-signin-btn {
    padding: 0.4rem 1rem;
    border: 1px solid rgba(255,255,255,0.3);
    border-radius: var(--radius);
    background: rgba(255,255,255,0.1);
    color: #fff; font-size: var(--text-sm); font-weight: var(--font-medium);
    cursor: pointer; text-decoration: none;
    transition: all 0.2s;
}
.header-signin-btn:hover {
    background: rgba(255,255,255,0.22);
    border-color: rgba(255,255,255,0.5);
}

/* User avatar */
.header-user { position: relative; }
.header-avatar {
    width: 34px; height: 34px;
    border-radius: 50%;
    background: linear-gradient(135deg, #60a5fa, #3b82f6);
    border: 2px solid rgba(255,255,255,0.3);
    display: flex; align-items: center; justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    padding: 0;
}
.header-avatar:hover {
    border-color: rgba(255,255,255,0.6);
    box-shadow: 0 0 0 3px rgba(59,130,246,0.3);
}
.avatar-initials {
    font-size: var(--text-xs); font-weight: var(--font-bold);
    color: #fff; letter-spacing: 0.02em;
    line-height: 1;
}

/* User dropdown */
.header-dropdown {
    position: absolute;
    top: calc(100% + 8px); right: 0;
    width: 260px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: 0 10px 40px rgba(0,0,0,0.2);
    opacity: 0; visibility: hidden;
    transform: translateY(-8px) scale(0.97);
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    z-index: 200;
    overflow: hidden;
}
.header-user.open .header-dropdown {
    opacity: 1; visibility: visible;
    transform: translateY(0) scale(1);
}
.dropdown-user-info {
    display: flex; align-items: center; gap: 0.75rem;
    padding: 1rem;
}
.dropdown-avatar {
    width: 40px; height: 40px; flex-shrink: 0;
    border-radius: 50%;
    background: linear-gradient(135deg, #60a5fa, #3b82f6);
    display: flex; align-items: center; justify-content: center;
}
.dropdown-avatar .avatar-initials { font-size: var(--text-md); }
.dropdown-user-details { display: flex; flex-direction: column; min-width: 0; }
.dropdown-user-name {
    font-size: var(--text-md); font-weight: var(--font-semibold);
    color: var(--text); white-space: nowrap;
    overflow: hidden; text-overflow: ellipsis;
}
.dropdown-user-email {
    font-size: var(--text-xs); color: var(--text-muted);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.dropdown-divider {
    height: 1px; background: var(--border); margin: 0;
}
.dropdown-item {
    display: flex; align-items: center; gap: 0.6rem;
    width: 100%; padding: 0.7rem 1rem;
    background: transparent; border: none;
    color: var(--text); font-size: var(--text-md);
    cursor: pointer; transition: background 0.15s;
    text-align: left;
}
.dropdown-item:hover {
    background: var(--primary-light);
}
.dropdown-item svg { color: var(--text-muted); flex-shrink: 0; }

/* Main */
main { max-width: 1100px; margin: 0 auto; padding: 1.75rem 1.25rem 3rem; }

/* Tabs — Pill Style */
.tabs {
    display: inline-flex; gap: 0.25rem; margin-bottom: 1.75rem;
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius-lg); padding: 0.3rem;
    box-shadow: var(--shadow); flex-wrap: wrap;
}
.tab {
    padding: 0.5rem 1.15rem; border: none; background: none; cursor: pointer;
    font-size: var(--text-md); font-weight: var(--font-medium); color: var(--text-muted);
    border-radius: var(--radius); transition: all var(--transition);
}
.tab:hover { color: var(--text); background: var(--hover-row); }
.tab.locked {
    opacity: 0.5; cursor: not-allowed; position: relative;
}
.tab.locked:hover { color: var(--text-muted); background: none; }
.tab.locked .lock-icon { margin-left: 0.15rem; opacity: 0.7; }
.tab-badge {
    font-size: 0.6rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em;
    background: var(--primary); color: #fff; padding: 0.1rem 0.4rem; border-radius: 999px;
    line-height: 1; margin-left: 0.25rem;
}
.tab.locked .tab-badge { background: var(--text-muted); }
.tab.active {
    color: #fff; background: var(--primary);
    box-shadow: 0 1px 3px rgba(37, 99, 235, 0.3);
}
.tab-content { display: none; animation: fadeIn 0.3s ease-out; }
.tab-content.active { display: block; }

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(4px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* Forms */
fieldset {
    border: 1px solid var(--border); border-radius: var(--radius-lg);
    padding: 1.25rem 1.5rem; margin-bottom: 1rem; background: var(--surface);
    box-shadow: var(--shadow);
}
legend { font-weight: var(--font-semibold); font-size: var(--text-md); color: var(--primary); padding: 0 0.5rem; }

/* Collapsible fieldset sections */
fieldset.collapsible {
    padding: 0; overflow: hidden;
}
fieldset.collapsible > details > summary {
    display: flex; align-items: center; gap: 0.5rem;
    padding: 0.85rem 1.25rem;
    font-weight: var(--font-semibold); font-size: var(--text-md); color: var(--primary);
    cursor: pointer; user-select: none;
    list-style: none; /* remove default triangle */
    transition: background 0.2s;
}
fieldset.collapsible > details > summary:hover {
    background: rgba(59, 130, 246, 0.04);
}
fieldset.collapsible > details > summary::-webkit-details-marker { display: none; }
fieldset.collapsible > details > summary::before {
    content: '\25B6'; /* right triangle */
    font-size: 0.7em; color: var(--text-muted);
    transition: transform 0.2s ease;
    display: inline-block; width: 1em; text-align: center;
}
fieldset.collapsible > details[open] > summary::before {
    transform: rotate(90deg);
}
fieldset.collapsible > details > .fieldset-body {
    padding: 0 1.5rem 1.25rem;
}
fieldset.collapsible > details > summary + .fieldset-body {
    animation: slideDown 0.2s ease;
}
@keyframes slideDown {
    from { opacity: 0; transform: translateY(-8px); }
    to { opacity: 1; transform: translateY(0); }
}

.form-grid {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 1rem;
}
.form-grid.align-end { align-items: end; grid-template-columns: repeat(3, 1fr); }
.form-group { display: flex; flex-direction: column; }
.form-group.span-3 { grid-column: span 3; }
.form-group label {
    font-size: var(--text-sm); font-weight: var(--font-medium); color: var(--text-muted);
    margin-bottom: 0.3rem; letter-spacing: 0.01em;
}
.advanced-section .form-group label {
    min-height: 2.6em; display: flex; align-items: flex-end;
    flex-wrap: wrap; font-size: var(--text-xs); line-height: var(--leading-snug);
}
.advanced-section .form-group label .hint {
    display: block; width: 100%; margin-left: 0; font-size: var(--text-2xs);
}
.hint { color: var(--text-muted); font-weight: var(--font-normal); margin-left: 0.3em; }
.stamp-duty-info, .mortgage-info { display: block; margin-top: 0.2rem; font-size: var(--text-xs); color: var(--primary); line-height: var(--leading-snug); }
.stamp-duty-info a, .mortgage-info a { color: var(--primary); text-decoration: underline; }
.mortgage-info.auto { color: var(--success); }
.mortgage-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 0.85rem; grid-column: 1 / -1; }
.mortgage-pair-label { grid-column: 1 / -1; font-size: var(--text-md); font-weight: var(--font-semibold); color: var(--text); margin: 0.3rem 0 -0.2rem 0; }

input[type="number"], input[type="text"], select {
    width: 100%; padding: 0.55rem 0.75rem; border: 1px solid var(--border);
    border-radius: var(--radius); font-size: var(--text-md); color: var(--text);
    background: var(--input-bg); transition: all var(--transition);
    font-family: inherit;
}
input:hover, select:hover { border-color: var(--border-hover); }
input:focus, select:focus {
    outline: none; border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
    background: var(--surface);
}

/* Buttons */
.form-actions { display: flex; gap: 0.75rem; margin-top: 0.5rem; flex-wrap: wrap; }
.button-help { display: block; margin-top: 0.4rem; font-size: var(--text-xs); color: var(--text-muted); line-height: var(--leading-normal); }

.btn-primary {
    padding: 0.6rem 1.5rem; background: linear-gradient(180deg, var(--primary), var(--primary-dark));
    color: #fff; border: none;
    border-radius: var(--radius); font-size: var(--text-md); font-weight: var(--font-semibold); cursor: pointer;
    transition: all var(--transition); box-shadow: 0 1px 2px rgba(0,0,0,0.1);
}
.btn-primary:hover {
    background: var(--primary-dark); transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(37, 99, 235, 0.25);
}
.btn-primary:active { transform: translateY(0); box-shadow: var(--shadow); }

.btn-secondary {
    padding: 0.55rem 1.25rem; background: var(--surface); color: var(--primary);
    border: 1px solid var(--border); border-radius: var(--radius); font-size: var(--text-md);
    font-weight: var(--font-medium); cursor: pointer; transition: all var(--transition);
}
.btn-secondary:hover { background: var(--primary); color: #fff; border-color: var(--primary); }

.btn-outline {
    padding: 0.6rem 1.5rem; background: var(--surface); color: var(--text-muted);
    border: 1px solid var(--border); border-radius: var(--radius); font-size: var(--text-md);
    cursor: pointer; transition: all 0.2s;
}
.btn-outline:hover { border-color: var(--text-muted); color: var(--text); }

.btn-danger {
    padding: 0.4rem 0.75rem; background: var(--danger); color: #fff; border: none;
    border-radius: var(--radius); font-size: var(--text-sm); cursor: pointer;
}
.btn-danger:hover { opacity: 0.85; }

.btn-sm {
    padding: 0.35rem 0.7rem; font-size: var(--text-sm);
}

/* Results */
.results-container { margin-top: 1.5rem; }
.hidden { display: none !important; }

.result-card {
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
    padding: 1.25rem 1.5rem; margin-bottom: 1rem; box-shadow: var(--shadow);
    transition: box-shadow var(--transition);
}
.result-card:hover { box-shadow: var(--shadow-md); }
.result-card h3 {
    font-size: var(--text-base); margin-bottom: 0.75rem; color: var(--text);
    border-bottom: 1px solid var(--border); padding-bottom: 0.5rem;
}
.result-card h3 small { color: var(--text-muted); font-weight: var(--font-normal); }
.result-card.highlight { border-left: 4px solid var(--primary); }

.result-grid {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 0.7rem;
}
.result-item { display: flex; flex-direction: column; }
.result-item .label { font-size: var(--text-xs); color: var(--text-muted); text-transform: uppercase; letter-spacing: var(--tracking-wide); font-weight: var(--font-medium); }
.result-item .value { font-size: var(--text-lg); font-weight: var(--font-bold); color: var(--text); font-variant-numeric: tabular-nums; font-family: var(--font-mono); }
.result-item .value.positive { color: var(--success); }
.result-item .value.negative { color: var(--danger); }
.result-content { font-size: var(--text-base); padding: 0.4rem 0; }

/* Summary Table (matching Excel layout) */
.summary-table {
.summary-table { width: 100%; border-collapse: collapse; font-size: var(--text-sm); }
}
.summary-table th, .summary-table td {
    padding: 0.5rem 0.75rem; border-bottom: 1px solid var(--border); text-align: right;
    font-variant-numeric: tabular-nums;
}
.summary-table th { background: var(--bg); font-weight: var(--font-semibold); color: var(--text-muted); font-size: var(--text-xs); text-transform: uppercase; letter-spacing: var(--tracking-wide); }
.summary-table th:first-child, .summary-table td:first-child { text-align: left; }
.summary-table tr.section-header td { font-weight: var(--font-semibold); color: var(--primary); background: var(--primary-light); border-bottom: none; padding-top: 0.6rem; }
.summary-table tr.total-row td { font-weight: var(--font-bold); border-top: 2px solid var(--border); }
.summary-table tr.highlight-row td { font-weight: var(--font-bold); font-size: var(--text-md); }
.summary-table tr.positive td { color: var(--success); }
.summary-table tr.negative td { color: var(--danger); }

/* Data Tables */
.data-table { width: 100%; border-collapse: collapse; font-size: var(--text-sm); }
.data-table thead { position: sticky; top: 0; z-index: 1; }
.data-table th, .data-table td {
    padding: 0.5rem 0.75rem; text-align: right; border-bottom: 1px solid var(--border);
    font-variant-numeric: tabular-nums;
}
.data-table th { background: var(--bg); font-weight: var(--font-semibold); color: var(--text-muted); font-size: var(--text-xs); text-transform: uppercase; letter-spacing: var(--tracking-wide); }
.data-table th:first-child, .data-table td:first-child { text-align: left; }
.data-table tbody tr:hover { background: var(--hover-row); }
.data-table tbody tr { transition: background var(--transition); }
.data-table tbody tr:nth-child(even) { background: var(--neutral-50); }
[data-theme="dark"] .data-table tbody tr:nth-child(even) { background: rgba(255,255,255,0.02); }
.data-table td { font-variant-numeric: tabular-nums; font-family: var(--font-mono); font-size: var(--text-sm); }

.table-scroll { overflow-x: auto; max-height: 500px; overflow-y: auto; }
.comparison th, .comparison td { min-width: 140px; white-space: nowrap; }

/* Blended rate info */
.blended-info { margin-top: 0.6rem; padding: 0.5rem 0.75rem; background: var(--primary-light); border-radius: var(--radius); font-size: var(--text-md); }

/* Expense bar chart */
.chart-container { margin-top: 0.85rem; }
.bar-row { display: flex; align-items: center; margin-bottom: 0.35rem; }
.bar-label { width: 120px; font-size: var(--text-xs); color: var(--text-muted); flex-shrink: 0; }
.bar-track { flex: 1; background: var(--bg); border-radius: 4px; height: 20px; overflow: hidden; }
.bar-fill { height: 100%; border-radius: 4px; background: var(--primary); transition: width 0.5s ease; min-width: 2px; }
.bar-value { width: 80px; text-align: right; font-size: var(--text-sm); font-weight: var(--font-medium); flex-shrink: 0; padding-left: 0.5rem; }

/* Portfolio */
.portfolio-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1rem; flex-wrap: wrap; gap: 0.75rem; }
.portfolio-header h2 { font-size: var(--text-xl); }
.portfolio-filter { display: flex; align-items: center; gap: 0.5rem; }
.portfolio-filter label { font-size: var(--text-md); color: var(--text-muted); white-space: nowrap; }
.portfolio-filter select { min-width: 200px; }

.empty-state { text-align: center; padding: 3rem 1rem; color: var(--text-muted); }

.property-cards { display: grid; gap: 1rem; margin-bottom: 1.5rem; }

.property-card {
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
    padding: 1.15rem 1.25rem; box-shadow: var(--shadow); transition: all var(--transition);
}
.property-card:hover { box-shadow: var(--shadow-md); }
.property-card-header {
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 0.75rem; padding-bottom: 0.5rem; border-bottom: 1px solid var(--border);
}
.property-card-header h4 { font-size: var(--text-base); color: var(--primary); }
.property-card-actions { display: flex; gap: 0.4rem; }
.property-card-body { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 0.5rem; }
.property-card .metric { display: flex; flex-direction: column; }
.property-card .metric .label { font-size: var(--text-xs); color: var(--text-muted); text-transform: uppercase; }
.property-card .metric .value { font-size: var(--text-md); font-weight: var(--font-semibold); }

/* Footer */
footer {
    text-align: center; padding: 1.5rem; color: var(--text-muted); font-size: var(--text-sm);
    border-top: 1px solid var(--border); margin-top: 2rem; background: var(--surface);
}
footer .disclaimer { font-style: italic; margin-top: 0.3rem; font-size: var(--text-xs); }

/* ── 30-Year Projection ──────────────────────────────────────────── */

/* Summary cards row */
.projection-summary {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 0.75rem; margin-bottom: 1.25rem;
}
.proj-card {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius-lg); padding: 1rem 1.15rem;
    display: flex; flex-direction: column; box-shadow: var(--shadow);
    transition: all var(--transition);
}
.proj-card:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }
.proj-card.accent {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    border: none; color: #fff;
}
.proj-card.accent .proj-card-label { color: rgba(255,255,255,0.8); }
.proj-card.accent .proj-card-value { color: #fff; }
.proj-card-label {
    font-size: var(--text-xs); font-weight: var(--font-semibold); text-transform: uppercase;
    letter-spacing: var(--tracking-wide); color: var(--text-muted); margin-bottom: 0.35rem;
}
.proj-card-value { font-size: var(--text-xl); font-weight: var(--font-bold); color: var(--text); font-variant-numeric: tabular-nums; font-family: var(--font-mono); }
.proj-card-value.positive { color: var(--success); }
.proj-card-value.negative { color: var(--danger); }

/* Projection donut row (single-property) */
.proj-donut-row {
    display: flex;
    justify-content: center;
    margin-bottom: 1rem;
}
.proj-donut-card {
    text-align: center;
    max-width: 380px;
    width: 100%;
}

/* Chart wrapper */
.chart-wrapper {
    position: relative; width: 100%; max-height: 380px;
    padding: 0.5rem 0;
}
.chart-wrapper canvas { width: 100% !important; max-height: 360px; }

/* Projection table colour helpers */
#projectionTable td.positive { color: var(--success); font-weight: var(--font-medium); }
#projectionTable td.negative { color: var(--danger); font-weight: var(--font-medium); }

/* Responsive */
@media (max-width: 768px) {
    .header-brand-tagline { display: none; }
    .header-brand-name { font-size: var(--text-md); }
    header { padding: 0 0.75rem; }
    #headerInfoBtn { display: none; }
    .tabs { width: 100%; display: flex; overflow-x: auto; white-space: nowrap; }
    .tab { flex: 1; text-align: center; font-size: var(--text-sm); padding: 0.5rem 0.75rem; }
    .form-grid { grid-template-columns: 1fr 1fr; gap: 0.75rem; }
    .form-group.span-3 { grid-column: span 2; }
    .result-grid { grid-template-columns: 1fr 1fr; }
    .portfolio-header { flex-direction: column; align-items: flex-start; }
    .property-card-body { grid-template-columns: 1fr 1fr; }
    main { padding: 1.25rem 0.75rem 2rem; }
}

/* ── Portfolio Projection ──────────────────────────────────────── */
#portfolioGrowthFieldset {
    background: var(--portfolio-fieldset-bg);
    border: 1px solid var(--portfolio-fieldset-border);
    border-radius: var(--radius-lg);
    padding: 1.25rem 1.5rem;
    margin-bottom: 1rem;
}
#portfolioGrowthFieldset legend {
    font-weight: var(--font-semibold);
    color: var(--portfolio-legend);
    font-size: var(--text-base);
}
#portfolioGrowthFieldset .form-grid {
    gap: 0.75rem 1.25rem;
}
#generatePortfolioBtn {
    margin-top: 0.75rem;
    background: #0369a1;
}
#generatePortfolioBtn:hover {
    background: #0284c7;
}

.port-property-summaries {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1rem;
    margin: 1.25rem 0;
}
.port-prop-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1rem 1.15rem;
    box-shadow: var(--shadow);
    transition: all var(--transition);
}
.port-prop-card:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }
/* Aligned two-line header: name + badge */
.port-prop-header {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    margin-bottom: 0.6rem;
    min-height: 2rem;
}
.port-prop-name {
    margin: 0;
    font-size: var(--text-sm);
    color: var(--text);
    line-height: var(--leading-snug);
    flex: 1;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.port-prop-card h4 {
    margin: 0 0 0.6rem;
    font-size: var(--text-md);
    color: var(--text);
}
.port-prop-metrics {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.3rem 0.75rem;
}
.port-prop-metrics > div {
    display: flex;
    justify-content: space-between;
    font-size: var(--text-xs);
}
.port-prop-metrics .label {
    color: var(--text-muted);
}
.port-prop-metrics .value {
    font-weight: var(--font-semibold);
    color: var(--text);
}
.port-prop-metrics .value.positive { color: var(--success); }
.port-prop-metrics .value.negative { color: var(--danger); }

/* ── Type Badges ─────────────────────────────────────────────── */
.port-badge {
    display: inline-block;
    padding: 0.1rem 0.4rem;
    border-radius: 4px;
    font-size: var(--text-2xs);
    font-weight: var(--font-bold);
    letter-spacing: 0.02em;
    text-transform: uppercase;
    white-space: nowrap;
    flex-shrink: 0;
    margin-top: 0.1rem;
}
.port-badge-inv {
    background: #dbeafe;
    color: #1d4ed8;
    border: 1px solid #93c5fd;
}
.port-badge-ppor {
    background: #dcfce7;
    color: #15803d;
    border: 1px solid #86efac;
}

/* Card title row (portfolio insights tab) */
.card-title-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex: 1;
    min-width: 0;
}
.card-title-row h3 {
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ── Portfolio Insights — Coming Soon Lock Screen ─────────────── */
.coming-soon-container {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    text-align: center; padding: 4rem 1.5rem 3rem; max-width: 540px; margin: 2rem auto;
}
.coming-soon-icon {
    width: 96px; height: 96px; border-radius: 50%;
    background: color-mix(in srgb, var(--primary) 10%, transparent);
    display: flex; align-items: center; justify-content: center;
    margin-bottom: 1.5rem;
    animation: gentlePulse 3s ease-in-out infinite;
}
@keyframes gentlePulse {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.05); opacity: 0.85; }
}
.coming-soon-title {
    font-size: 1.5rem; font-weight: var(--font-bold, 700); color: var(--text);
    margin: 0 0 0.25rem;
}
.coming-soon-subtitle {
    font-size: 1rem; font-weight: var(--font-semibold, 600);
    color: var(--primary); margin: 0 0 1rem; letter-spacing: 0.03em;
}
.coming-soon-desc {
    color: var(--text-muted); font-size: var(--text-md, 0.938rem);
    line-height: 1.6; margin: 0 0 1.5rem;
}
.coming-soon-features {
    display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem;
    width: 100%; margin-bottom: 2rem;
}
.coming-soon-feature {
    display: flex; align-items: center; gap: 0.5rem;
    padding: 0.6rem 0.85rem; border-radius: var(--radius, 8px);
    background: var(--card-bg, #fff); border: 1px solid var(--border, #e5e7eb);
    font-size: var(--text-sm, 0.813rem); color: var(--text);
}
.coming-soon-note {
    color: var(--text-muted); font-size: var(--text-sm, 0.813rem);
    font-style: italic; margin: 0;
}
@media (max-width: 480px) {
    .coming-soon-features { grid-template-columns: 1fr; }
    .coming-soon-container { padding: 2rem 1rem; }
}

/* ── Portfolio Insights Tab ───────────────────────────────────── */
.pa-section-title {
    font-size: var(--text-md);
    font-weight: var(--font-semibold);
    color: var(--text);
    margin: 1.25rem 0 0.5rem;
    padding-bottom: 0.25rem;
    border-bottom: 1px solid var(--border);
}
.pa-form-subtitle {
    font-size: var(--text-sm);
    font-weight: var(--font-semibold);
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: var(--tracking-wide);
    margin: 1rem 0 0.4rem;
}

/* ── Portfolio KPI Widgets ───────────────────────────────────── */
.port-kpi-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-bottom: 1.25rem;
}
.port-kpi-widget {
    border-radius: var(--radius-lg);
    padding: 1rem 1.15rem;
    box-shadow: var(--shadow);
    transition: all var(--transition);
}
.port-kpi-widget:hover { box-shadow: var(--shadow-md); }
.port-kpi-investment {
    background: linear-gradient(135deg, #eff6ff 0%, #dbeafe 100%);
    border: 1px solid #93c5fd;
}
.port-kpi-ppor {
    background: linear-gradient(135deg, #f0fdf4 0%, #dcfce7 100%);
    border: 1px solid #86efac;
}
.port-kpi-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border);
}
.port-kpi-icon {
    font-size: var(--text-lg);
}
.port-kpi-title {
    font-weight: var(--font-bold);
    font-size: var(--text-sm);
    flex: 1;
}
.port-kpi-investment .port-kpi-title { color: #1d4ed8; }
.port-kpi-ppor .port-kpi-title { color: #15803d; }
.port-kpi-count {
    background: rgba(128,128,128,0.15);
    border-radius: 50%;
    width: 1.4rem;
    height: 1.4rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: var(--font-bold);
    font-size: var(--text-xs);
}
.port-kpi-body {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.35rem 1rem;
}
.port-kpi-metric {
    display: flex;
    justify-content: space-between;
    font-size: var(--text-xs);
}
.port-kpi-metric .label {
    color: var(--text-muted);
}
.port-kpi-metric .value {
    font-weight: var(--font-semibold);
    color: var(--text);
}
.port-kpi-metric .value.positive { color: var(--success); }
.port-kpi-metric .value.negative { color: var(--danger); }

@media (max-width: 700px) {
    .port-kpi-row {
        grid-template-columns: 1fr;
    }
}

/* ═══════════════════════════════════════════════════════════════════
   ARI-STYLE PROJECTION (Projection 2.0 tab)
   ═══════════════════════════════════════════════════════════════════ */

/* KPI row */
.ari-kpi-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem;
    margin-bottom: 1.2rem;
}
.ari-kpi-card {
    flex: 1 1 120px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 0.7rem 0.85rem;
    text-align: center;
    min-width: 110px;
    transition: all var(--transition);
    box-shadow: var(--shadow);
}
.ari-kpi-card:hover { box-shadow: var(--shadow-md); }
.ari-kpi-card.positive { border-color: #5AD8A6; background: rgba(90,216,166,0.08); }
.ari-kpi-card.negative { border-color: #E8684A; background: rgba(232,104,74,0.08); }
.ari-kpi-label {
    font-size: var(--text-xs);
    font-weight: var(--font-semibold);
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: var(--tracking-wide);
    margin-bottom: 0.15rem;
}
.ari-kpi-value {
    font-size: var(--text-base);
    font-weight: var(--font-bold);
    color: var(--text);
    font-family: var(--font-mono);
    font-variant-numeric: tabular-nums;
}
.ari-kpi-card.positive .ari-kpi-value { color: var(--success); }
.ari-kpi-card.negative .ari-kpi-value { color: var(--danger); }

/* Two charts side by side */
.ari-charts-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-bottom: 1rem;
}
.ari-chart-half {
    min-width: 0;
}
@media (max-width: 800px) {
    .ari-charts-row {
        grid-template-columns: 1fr;
    }
}

/* Transposed ARI table */
.ari-table {
    font-size: var(--text-sm);
}
.ari-table th {
    text-align: center;
    white-space: nowrap;
    font-size: var(--text-xs);
    padding: 0.45rem 0.6rem;
}
.ari-table td {
    text-align: right;
    padding: 0.35rem 0.6rem;
    white-space: nowrap;
}
.ari-table .ari-metric {
    text-align: left;
    font-weight: var(--font-semibold);
    color: var(--text);
    min-width: 150px;
    position: sticky;
    left: 0;
    background: var(--surface);
    z-index: 1;
}
.ari-section-header td {
    background: var(--primary-dark) !important;
    color: #fff !important;
    font-weight: var(--font-bold);
    font-size: var(--text-sm);
    text-align: left !important;
    padding: 0.5rem 0.6rem;
    letter-spacing: 0.02em;
}
.ari-assumption td {
    color: var(--primary);
    font-weight: var(--font-semibold);
    font-size: var(--text-sm);
}
.ari-highlight td {
    background: var(--primary-light);
    font-weight: var(--font-bold);
}
.ari-cf-row td {
    line-height: var(--leading-snug);
    font-size: var(--text-xs);
    vertical-align: middle;
}

/* Dark mode overrides for chart backgrounds */
[data-theme="dark"] .chart-wrapper canvas {
    filter: none;
}
[data-theme="dark"] .ari-section-header td {
    background: #0f172a !important;
}
[data-theme="dark"] .port-kpi-count {
    background: rgba(255,255,255,0.12);
}
[data-theme="dark"] .proj-card.accent {
    background: linear-gradient(135deg, #3b82f6, #2563eb);
}
[data-theme="dark"] .blended-info {
    background: var(--primary-light);
}
[data-theme="dark"] .port-badge-inv {
    background: rgba(59,130,246,0.15);
    color: #60a5fa;
    border-color: #3b82f6;
}
[data-theme="dark"] .port-badge-ppor {
    background: rgba(34,197,94,0.15);
    color: #4ade80;
    border-color: #22c55e;
}
[data-theme="dark"] .port-kpi-investment {
    background: linear-gradient(135deg, rgba(30,58,138,0.3), rgba(30,64,175,0.15));
    border-color: #3b82f6;
}
[data-theme="dark"] .port-kpi-ppor {
    background: linear-gradient(135deg, rgba(20,83,45,0.3), rgba(22,101,52,0.15));
    border-color: #22c55e;
}
[data-theme="dark"] .port-kpi-investment .port-kpi-title { color: #60a5fa; }
[data-theme="dark"] .port-kpi-ppor .port-kpi-title { color: #4ade80; }
[data-theme="dark"] #generatePortfolioBtn {
    background: #0ea5e9;
}
[data-theme="dark"] #generatePortfolioBtn:hover {
    background: #38bdf8;
}
[data-theme="dark"] .summary-table tr.section-header td {
    background: var(--primary-light);
    color: var(--primary);
}

/* ── Glossary Tab ─────────────────────────────────── */
.glossary-group { margin-bottom: 1.5rem; }
.glossary-group:last-child { margin-bottom: 0; }
.glossary-heading {
    font-size: var(--text-base);
    font-weight: var(--font-bold);
    color: var(--primary);
    border-bottom: 2px solid var(--primary);
    padding-bottom: 0.4rem;
    margin-bottom: 0.75rem;
    letter-spacing: -0.01em;
}
.glossary-list { margin: 0; padding: 0; }
.glossary-list dt {
    font-weight: var(--font-semibold);
    font-size: var(--text-md);
    color: var(--text);
    margin-top: 0.6rem;
}
.glossary-list dd {
    margin: 0.15rem 0 0 1rem;
    font-size: var(--text-sm);
    color: var(--text-muted);
    line-height: var(--leading-normal);
}

/* ── Tab Icons ────────────────────────────────────── */
.tab {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
}
.tab-icon {
    flex-shrink: 0;
    opacity: 0.6;
    transition: opacity var(--transition);
}
.tab:hover .tab-icon,
.tab.active .tab-icon { opacity: 1; }

/* ── Locked Mortgage Pair ─────────────────────────── */
.mortgage-pair.locked {
    opacity: 0.45;
    pointer-events: none;
    position: relative;
}
.mortgage-pair.locked::after {
    content: '🔒 Not applicable — deposit source is Cash';
    display: block;
    font-size: var(--text-xs);
    color: var(--text-muted);
    margin-top: 0.35rem;
    font-style: italic;
}

/* ── Input with inline action button ──────────────── */
.input-with-action {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.input-with-action select {
    flex: 1;
}
.btn-icon-danger {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    padding: 0;
    border: 1px solid var(--danger);
    border-radius: var(--radius);
    background: transparent;
    color: var(--danger);
    cursor: pointer;
    flex-shrink: 0;
    transition: all var(--transition);
}
.btn-icon-danger:hover {
    background: var(--danger);
    color: #fff;
}
.btn-icon-danger svg {
    pointer-events: none;
}

/* ── Help Guide Button Bar ─────────────────────────── */
.section-help-bar {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 0.5rem;
}
.help-guide-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.4rem 0.85rem;
    font-size: var(--text-sm);
    font-weight: var(--font-medium);
    color: var(--primary);
    background: transparent;
    border: 1px solid var(--primary);
    border-radius: var(--radius);
    cursor: pointer;
    transition: all var(--transition);
}
.help-guide-btn:hover {
    background: var(--primary);
    color: #fff;
}
.help-guide-btn svg {
    flex-shrink: 0;
}

/* ── Guide Modal Content ──────────────────────────── */
.guide-steps {
    margin: 0.5rem 0 0 1.25rem;
    padding: 0;
    line-height: 1.8;
    color: var(--text);
}
.guide-steps li {
    margin-bottom: 0.25rem;
}
.guide-collapsed-hint {
    font-size: var(--text-xs);
    color: var(--text-muted);
    font-weight: normal;
    font-style: italic;
}
.guide-note {
    margin: 0.5rem 0 0;
    color: var(--text-secondary);
    line-height: 1.7;
}
.guide-tips {
    margin: 0.5rem 0 0 1.25rem;
    padding: 0;
    line-height: 1.8;
    color: var(--text);
}
.guide-tips li {
    margin-bottom: 0.35rem;
}

/* ── Glossary Modal ───────────────────────────────── */
.glossary-modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.25s ease, visibility 0.25s ease;
}
.glossary-modal-overlay.open {
    opacity: 1;
    visibility: visible;
}
.glossary-modal {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    width: min(90vw, 720px);
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    transform: translateY(12px) scale(0.97);
    transition: transform 0.25s ease;
}
.glossary-modal-overlay.open .glossary-modal {
    transform: translateY(0) scale(1);
}
.glossary-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}
.glossary-modal-header h2 {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: var(--text-lg);
    font-weight: var(--font-bold);
    margin: 0;
    color: var(--text);
}
.glossary-modal-close {
    background: none;
    border: none;
    font-size: var(--text-2xl);
    line-height: 1;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0.25rem 0.5rem;
    border-radius: var(--radius);
    transition: all var(--transition);
}
.glossary-modal-close:hover {
    background: var(--hover-row);
    color: var(--text);
}
.glossary-modal-body {
    padding: 1.25rem 1.5rem;
    overflow-y: auto;
    flex: 1;
}

/* ── Advanced Section (details/summary) ───────────── */
.advanced-section {
    margin-top: 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 0;
    overflow: hidden;
}
.advanced-section summary {
    cursor: pointer;
    font-weight: var(--font-semibold);
    font-size: var(--text-md);
    color: var(--primary);
    padding: 0.6rem 1rem;
    background: var(--primary-light);
    border-radius: var(--radius-lg);
    user-select: none;
    transition: background var(--transition);
}
.advanced-section summary:hover { opacity: 0.85; }
.advanced-section[open] summary {
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    margin-bottom: 0;
}
.advanced-section > .form-grid,
.advanced-section > p,
.advanced-section > div {
    padding: 0 0.75rem;
}
.advanced-section > .form-grid {
    padding-bottom: 0.75rem;
}
.advanced-section > p.hint {
    padding-top: 0;
    padding-bottom: 0;
}

/* ── Dashboard Tab ────────────────────────────────────── */
.dash-kpi-bar {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 0.75rem;
    margin-bottom: 0.75rem;
}
.dash-kpi {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 0.85rem 1rem;
    text-align: center;
    transition: all var(--transition);
    box-shadow: var(--shadow);
}
.dash-kpi:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }
.dash-kpi.accent {
    background: var(--primary-light);
    border-color: var(--primary);
}
.dash-kpi-label {
    display: block;
    font-size: var(--text-2xs);
    font-weight: var(--font-medium);
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: var(--tracking-wide);
    margin-bottom: 0.25rem;
    min-height: 2.2em;
    line-height: 1.1;
}
.dash-kpi-value {
    display: block;
    font-size: var(--text-lg);
    font-weight: var(--font-bold);
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-variant-numeric: tabular-nums;
    font-family: var(--font-mono);
}
.dash-kpi-value.positive { color: var(--success); }
.dash-kpi-value.negative { color: var(--danger); }

.dash-charts-row {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
    margin-bottom: 1rem;
}
.dash-chart-card {
    text-align: center;
}
.dash-chart-card .chart-wrapper-donut {
    max-width: 280px;
    margin: 0 auto;
}
@media (max-width: 900px) {
    .dash-charts-row { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 600px) {
    .dash-charts-row { grid-template-columns: 1fr; }
}

/* Portfolio allocation donut charts */
.port-allocation-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-bottom: 1rem;
}
.port-allocation-card {
    text-align: center;
}
.chart-wrapper-donut {
    max-width: 340px;
    margin: 0 auto;
}
@media (max-width: 700px) {
    .port-allocation-row { grid-template-columns: 1fr; }
}

/* ── Accessibility ───────────────────────────────────────────── */

/* Focus-visible for keyboard navigation (WCAG AA) */
:focus-visible {
    outline: 3px solid var(--primary);
    outline-offset: 2px;
    border-radius: var(--radius);
}
input:focus-visible, select:focus-visible {
    outline: none; /* Use box-shadow ring instead */
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.2);
}
.tab:focus-visible {
    outline: 2px solid #fff;
    outline-offset: -2px;
}

/* Skip to main content (screen reader) */
.skip-link {
    position: absolute; left: -9999px; top: auto;
    width: 1px; height: 1px; overflow: hidden;
    z-index: 999;
}
.skip-link:focus {
    position: fixed; top: var(--space-2); left: var(--space-2);
    width: auto; height: auto;
    padding: var(--space-2) var(--space-4);
    background: var(--primary); color: #fff;
    border-radius: var(--radius);
    font-size: var(--text-sm); font-weight: var(--font-semibold);
    z-index: 9999;
}

/* Reduced motion — disable animations for users who prefer it */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
    .tab-content { animation: none; }
    .proj-card:hover,
    .port-prop-card:hover,
    .dash-kpi:hover,
    .property-card:hover,
    .result-card:hover {
        transform: none;
    }
}

/* ── Mono font for all numeric table cells ───────────────────── */
.summary-table td {
    font-family: var(--font-mono);
    font-variant-numeric: tabular-nums;
}
.port-kpi-metric .value,
.port-prop-metrics .value {
    font-family: var(--font-mono);
    font-variant-numeric: tabular-nums;
}
