/* ═══════════════════════════════════════════════════════════════════════════ */
/* ─── DoorVault - Main Stylesheet ────────────────────────────────────────── */
/* ═══════════════════════════════════════════════════════════════════════════ */

:root {
    /* Layout */
    --sidebar-width: 228px;
    --sidebar-collapsed: 64px;
    --topbar-height: 52px;

    /* Brand */
    --accent: #d4a843;
    --accent-hover: #e0b854;
    --accent-muted: rgba(212, 168, 67, 0.10);
    --accent-subtle: rgba(212, 168, 67, 0.05);

    /* Surfaces — deeper, more contrast */
    --bg-dark: #090b0f;
    --bg-card: #111318;
    --bg-elevated: #181b24;
    --bg-sidebar: #0c0e14;
    --bg-input: #0e1016;

    /* Text */
    --text-primary: #e8eaf0;
    --text-secondary: #8b8fa3;
    --text-muted: #505569;

    /* Borders */
    --border-color: rgba(255, 255, 255, 0.06);
    --border-subtle: rgba(255, 255, 255, 0.035);

    /* Status — "Financial" palette (default): refined, sophisticated tones */
    --success: #0d9668;
    --danger: #dc4a4a;
    --warning: #d4940a;
    --info: #2d8fd4;

    /* Deal verdict / metric colors (bright for dark backgrounds) */
    --color-good: #34d399;
    --color-pass: #86cb4a;
    --color-warn: #f0a030;
    --color-bad: #ef6b6b;
    --color-info: #38bdf8;

    /* RGB components for alpha compositing — use as rgba(var(--color-good-rgb), 0.3) */
    --color-good-rgb: 52, 211, 153;
    --color-pass-rgb: 134, 203, 74;
    --color-warn-rgb: 240, 160, 48;
    --color-bad-rgb: 239, 107, 107;
    --color-info-rgb: 56, 189, 248;
    --success-rgb: 13, 150, 104;
    --danger-rgb: 220, 74, 74;
    --warning-rgb: 212, 148, 10;

    /* Spacing scale (4px base) */
    --space-1: 4px;
    --space-2: 8px;
    --space-3: 12px;
    --space-4: 16px;
    --space-5: 20px;
    --space-6: 24px;
    --space-8: 32px;
    --space-10: 40px;

    /* Radius */
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;
    --radius-xl: 18px;

    /* Transitions */
    --transition-fast: 0.15s ease;
    --transition-normal: 0.2s ease;
    --transition-smooth: 0.3s cubic-bezier(0.4, 0, 0.2, 1);

    /* Aliases (backward-compat for templates using legacy names) */
    --card-bg: var(--bg-card);
    --bg: var(--bg-dark);
    --text: var(--text-primary);
    --surface: var(--bg-elevated);
    --surface-hover: var(--bg-elevated);
    --border: var(--border-color);
}

/* ═══════════════════════════════════════════════════════════════════════════ */
/* ─── Light Theme Overrides ──────────────────────────────────────────────── */
/* ═══════════════════════════════════════════════════════════════════════════ */

[data-theme="light"] {
    --accent: #b8860b;
    --accent-hover: #9a7209;
    --accent-muted: rgba(184, 134, 11, 0.10);
    --accent-subtle: rgba(184, 134, 11, 0.05);

    --bg-dark: #f5f7f9;
    --bg-card: #ffffff;
    --bg-elevated: #f0f2f5;
    --bg-sidebar: #fafbfc;
    --bg-input: #f5f7f9;

    --text-primary: #1a1d24;
    --text-secondary: #57606a;
    --text-muted: #8c959f;

    --border-color: rgba(0, 0, 0, 0.13);
    --border-subtle: rgba(0, 0, 0, 0.07);

    /* Status — "Financial" palette light mode: deeper, readable on white */
    --success: #0a7a55;
    --danger: #b83b3b;
    --warning: #a07008;
    --info: #1a6fb0;

    /* Deal verdict / metric colors (darkened for white backgrounds) */
    --color-good: #0a7a55;
    --color-pass: #4a7c12;
    --color-warn: #a07008;
    --color-bad: #b83b3b;
    --color-info: #1a6fb0;

    --color-good-rgb: 10, 122, 85;
    --color-pass-rgb: 74, 124, 18;
    --color-warn-rgb: 160, 112, 8;
    --color-bad-rgb: 184, 59, 59;
    --color-info-rgb: 26, 111, 176;
    --success-rgb: 10, 122, 85;
    --danger-rgb: 184, 59, 59;
    --warning-rgb: 160, 112, 8;

    /* Aliases (backward-compat) */
    --card-bg: var(--bg-card);
    --bg: var(--bg-dark);
    --text: var(--text-primary);
    --surface: var(--bg-elevated);
    --surface-hover: var(--bg-elevated);
    --border: var(--border-color);
}

[data-theme="light"] .topbar {
    background: rgba(250, 251, 252, 0.90);
}

[data-theme="light"] .sidebar {
    border-right-color: rgba(0, 0, 0, 0.06);
}

[data-theme="light"] .table-custom tbody tr:hover,
[data-theme="light"] .table-dark-custom tbody tr:hover,
[data-theme="light"] .table tbody tr:hover {
    background: rgba(201, 168, 76, 0.06);
}
[data-theme="light"] .table-custom thead th,
[data-theme="light"] .table-dark-custom thead th,
[data-theme="light"] .table thead th {
    border-bottom-color: rgba(201, 168, 76, 0.35);
    color: var(--text-secondary);
}
[data-theme="light"] .table-custom tbody td,
[data-theme="light"] .table-dark-custom tbody td,
[data-theme="light"] .table tbody td {
    border-bottom-color: rgba(0, 0, 0, 0.06);
}
[data-theme="light"] .table-custom tfoot td,
[data-theme="light"] .table-dark-custom tfoot td,
[data-theme="light"] .table tfoot td {
    background: rgba(201, 168, 76, 0.04);
    border-top-color: rgba(201, 168, 76, 0.3);
}

[data-theme="light"] .activity-item:hover {
    background: rgba(0, 0, 0, 0.015);
}

[data-theme="light"] .knox-msg.assistant .knox-bubble {
    background: rgba(0, 0, 0, 0.03);
    border-color: var(--border-color);
}

[data-theme="light"] .knox-panel-input {
    background: rgba(0, 0, 0, 0.02);
}

[data-theme="light"] .knox-panel-input input {
    background: rgba(0, 0, 0, 0.03);
}

[data-theme="light"] .knox-panel-input input:focus {
    background: rgba(0, 0, 0, 0.05);
}

[data-theme="light"] .knox-palette {
    box-shadow: 0 24px 64px rgba(0, 0, 0, 0.15);
}

[data-theme="light"] .knox-panel {
    box-shadow: -8px 0 32px rgba(0, 0, 0, 0.1);
}

[data-theme="light"] .knox-gauge-popover {
    background: #fff;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
}

[data-theme="light"] .knox-gauge-bar-track {
    background: rgba(0, 0, 0, 0.06);
}

[data-theme="light"] .form-control:focus,
[data-theme="light"] .form-select:focus {
    background: var(--bg-card) !important;
}

[data-theme="light"] .login-card {
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.08);
}

[data-theme="light"] .skeleton,
[data-theme="light"] .skeleton-text,
[data-theme="light"] .skeleton-chart-inner,
[data-theme="light"] .skeleton-table-row .skeleton-cell {
    background: linear-gradient(90deg, #e8edf2 25%, #f0f4f8 50%, #e8edf2 75%);
    background-size: 800px 100%;
    animation: shimmer 1.8s ease-in-out infinite;
}

[data-theme="light"] .skeleton-card .skeleton-icon {
    background: linear-gradient(90deg, #dde3ea 25%, #e8edf2 50%, #dde3ea 75%);
    background-size: 800px 100%;
    animation: shimmer 1.8s ease-in-out infinite;
}

[data-theme="light"] .notification-dropdown {
    background: var(--bg-card) !important;
    border-color: var(--border-color) !important;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.10) !important;
}

[data-theme="light"] .dropdown-item {
    color: var(--text-primary);
}

[data-theme="light"] .dropdown-item:hover {
    background: var(--bg-elevated);
}

[data-theme="light"] .search-results {
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.10);
}

[data-theme="light"] .mobile-bottom-nav {
    background: var(--bg-card);
    border-top-color: var(--border-color);
}

[data-theme="light"] .sidebar.show {
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.12);
}

[data-theme="light"] .kpi-card,
[data-theme="light"] .card-custom,
[data-theme="light"] .hero-metric {
    border-color: rgba(0, 0, 0, 0.06);
}

[data-theme="light"] .hero-metric::before {
    opacity: 0.3;
}

/* ═══════════════════════════════════════════════════════════════════════════ */
/* ─── Color Palette: Earth (Burnt Orange / Sage Green / Gold) ────────────── */
/* ═══════════════════════════════════════════════════════════════════════════ */

/* Dark theme + earth palette */
[data-palette="earth"] {
    --success: #818865;
    --danger: #8B4729;
    --warning: #BB8D3F;
    --info: #7a9ec4;

    --color-good: #9aad72;
    --color-pass: #a8b077;
    --color-warn: #d4a84d;
    --color-bad: #a85a3a;
    --color-info: #7a9ec4;

    --color-good-rgb: 154, 173, 114;
    --color-pass-rgb: 168, 176, 119;
    --color-warn-rgb: 212, 168, 77;
    --color-bad-rgb: 168, 90, 58;
    --color-info-rgb: 122, 158, 196;
    --success-rgb: 129, 136, 101;
    --danger-rgb: 139, 71, 41;
    --warning-rgb: 187, 141, 63;
}

/* Light theme + earth palette */
[data-theme="light"][data-palette="earth"] {
    --success: #6a7050;
    --danger: #703820;
    --warning: #8a6830;
    --info: #5a7e9e;

    --color-good: #6a7050;
    --color-pass: #787f5a;
    --color-warn: #8a6830;
    --color-bad: #703820;
    --color-info: #5a7e9e;

    --color-good-rgb: 106, 112, 80;
    --color-pass-rgb: 120, 127, 90;
    --color-warn-rgb: 138, 104, 48;
    --color-bad-rgb: 112, 56, 32;
    --color-info-rgb: 90, 126, 158;
    --success-rgb: 106, 112, 80;
    --danger-rgb: 112, 56, 32;
    --warning-rgb: 138, 104, 48;
}

/* ═══════════════════════════════════════════════════════════════════════════ */
/* ─── Color Palette: Classic (Original Tailwind-bright colors) ──────────── */
/* ═══════════════════════════════════════════════════════════════════════════ */

/* Dark theme + classic palette */
[data-palette="classic"] {
    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
    --info: #3b82f6;

    --color-good: #4ade80;
    --color-pass: #a3e635;
    --color-warn: #fbbf24;
    --color-bad: #f87171;
    --color-info: #60a5fa;

    --color-good-rgb: 74, 222, 128;
    --color-pass-rgb: 163, 230, 53;
    --color-warn-rgb: 251, 191, 36;
    --color-bad-rgb: 248, 113, 113;
    --color-info-rgb: 96, 165, 250;
    --success-rgb: 16, 185, 129;
    --danger-rgb: 239, 68, 68;
    --warning-rgb: 245, 158, 11;
}

/* Light theme + classic palette */
[data-theme="light"][data-palette="classic"] {
    --success: #15803d;
    --danger: #cf222e;
    --warning: #9a6700;
    --info: #0969da;

    --color-good: #16a34a;
    --color-pass: #4d7c0f;
    --color-warn: #b45309;
    --color-bad: #dc2626;
    --color-info: #0969da;

    --color-good-rgb: 22, 163, 74;
    --color-pass-rgb: 77, 124, 15;
    --color-warn-rgb: 180, 83, 9;
    --color-bad-rgb: 220, 38, 38;
    --color-info-rgb: 9, 105, 218;
    --success-rgb: 21, 128, 61;
    --danger-rgb: 207, 34, 46;
    --warning-rgb: 154, 103, 0;
}

/* ═══════════════════════════════════════════════════════════════════════════ */
/* ─── Color Palette: Ocean (Teal / Pink / Purple — CVD-friendly) ────────── */
/* ═══════════════════════════════════════════════════════════════════════════ */

/* Dark theme + ocean palette */
[data-palette="ocean"] {
    --success: #0ea5e9;
    --danger: #f472b6;
    --warning: #a78bfa;
    --info: #22d3ee;

    --color-good: #2dd4bf;
    --color-pass: #38bdf8;
    --color-warn: #c084fc;
    --color-bad: #fb7185;
    --color-info: #67e8f9;

    --color-good-rgb: 45, 212, 191;
    --color-pass-rgb: 56, 189, 248;
    --color-warn-rgb: 192, 132, 252;
    --color-bad-rgb: 251, 113, 133;
    --color-info-rgb: 103, 232, 249;
    --success-rgb: 14, 165, 233;
    --danger-rgb: 244, 114, 182;
    --warning-rgb: 167, 139, 250;
}

/* Light theme + ocean palette */
[data-theme="light"][data-palette="ocean"] {
    --success: #0369a1;
    --danger: #be185d;
    --warning: #6d28d9;
    --info: #0891b2;

    --color-good: #0a7d72;
    --color-pass: #0284c7;
    --color-warn: #7c3aed;
    --color-bad: #be123c;
    --color-info: #047e8f;

    --color-good-rgb: 10, 125, 114;
    --color-pass-rgb: 2, 132, 199;
    --color-warn-rgb: 124, 58, 237;
    --color-bad-rgb: 190, 18, 60;
    --color-info-rgb: 4, 126, 143;
    --success-rgb: 3, 105, 161;
    --danger-rgb: 190, 24, 93;
    --warning-rgb: 109, 40, 217;
}

/* ═══════════════════════════════════════════════════════════════════════════ */
/* ─── Color Palette: Midnight (High-Contrast Neon — Bloomberg-inspired) ─── */
/* ═══════════════════════════════════════════════════════════════════════════ */

/* Dark theme + midnight palette */
[data-palette="midnight"] {
    --success: #00e676;
    --danger: #ff1744;
    --warning: #ffea00;
    --info: #00b0ff;

    --color-good: #69f0ae;
    --color-pass: #b2ff59;
    --color-warn: #e6d85a;
    --color-bad: #ff6b6b;
    --color-info: #40c4ff;

    --color-good-rgb: 105, 240, 174;
    --color-pass-rgb: 178, 255, 89;
    --color-warn-rgb: 230, 216, 90;
    --color-bad-rgb: 255, 107, 107;
    --color-info-rgb: 64, 196, 255;
    --success-rgb: 0, 230, 118;
    --danger-rgb: 255, 23, 68;
    --warning-rgb: 255, 234, 0;
}

/* Light theme + midnight palette */
[data-theme="light"][data-palette="midnight"] {
    --success: #00894e;
    --danger: #c62828;
    --warning: #9e7c00;
    --info: #0277bd;

    --color-good: #2e7d32;
    --color-pass: #558b2f;
    --color-warn: #8a5d00;
    --color-bad: #d32f2f;
    --color-info: #0288d1;

    --color-good-rgb: 46, 125, 50;
    --color-pass-rgb: 85, 139, 47;
    --color-warn-rgb: 138, 93, 0;
    --color-bad-rgb: 211, 47, 47;
    --color-info-rgb: 2, 136, 209;
    --success-rgb: 0, 137, 78;
    --danger-rgb: 198, 40, 40;
    --warning-rgb: 158, 124, 0;
}

/* ═══════════════════════════════════════════════════════════════════════════ */
/* ─── Color Palette: Slate (Muted Blue-Gray — Enterprise/Institutional) ─── */
/* ═══════════════════════════════════════════════════════════════════════════ */

/* Dark theme + slate palette */
[data-palette="slate"] {
    --success: #4c9a8a;
    --danger: #c75c5c;
    --warning: #c9a050;
    --info: #6b8db5;

    --color-good: #6ec5a8;
    --color-pass: #89b88a;
    --color-warn: #ddb86a;
    --color-bad: #e07878;
    --color-info: #7caad4;

    --color-good-rgb: 110, 197, 168;
    --color-pass-rgb: 137, 184, 138;
    --color-warn-rgb: 221, 184, 106;
    --color-bad-rgb: 224, 120, 120;
    --color-info-rgb: 124, 170, 212;
    --success-rgb: 76, 154, 138;
    --danger-rgb: 199, 92, 92;
    --warning-rgb: 201, 160, 80;
}

/* Light theme + slate palette */
[data-theme="light"][data-palette="slate"] {
    --success: #2d6a5a;
    --danger: #993d3d;
    --warning: #8a6d30;
    --info: #4a6b8a;

    --color-good: #2e7a5e;
    --color-pass: #5a8a5b;
    --color-warn: #8a6828;
    --color-bad: #a84848;
    --color-info: #4a7da8;

    --color-good-rgb: 46, 122, 94;
    --color-pass-rgb: 90, 138, 91;
    --color-warn-rgb: 138, 104, 40;
    --color-bad-rgb: 168, 72, 72;
    --color-info-rgb: 74, 125, 168;
    --success-rgb: 45, 106, 90;
    --danger-rgb: 153, 61, 61;
    --warning-rgb: 138, 109, 48;
}

/* ═══════════════════════════════════════════════════════════════════════════ */
/* ─── Palette-Aware Utility Classes ─────────────────────────────────────── */
/* ═══════════════════════════════════════════════════════════════════════════ */
/* Use these instead of hardcoded rgba() colors so palettes apply correctly */

/* Text colors */
.text-good  { color: var(--color-good) !important; }
.text-bad   { color: var(--color-bad) !important; }
.text-warn  { color: var(--color-warn) !important; }
.text-pass  { color: var(--color-pass) !important; }
.text-info-c { color: var(--color-info) !important; }

/* Border colors (with alpha) */
.border-good  { border-color: rgba(var(--color-good-rgb), 0.3) !important; }
.border-bad   { border-color: rgba(var(--color-bad-rgb), 0.3) !important; }
.border-warn  { border-color: rgba(var(--color-warn-rgb), 0.3) !important; }
.border-info-c { border-color: rgba(var(--color-info-rgb), 0.3) !important; }

/* Background tints (subtle) */
.bg-good-subtle  { background: rgba(var(--color-good-rgb), 0.12) !important; }
.bg-bad-subtle   { background: rgba(var(--color-bad-rgb), 0.12) !important; }
.bg-warn-subtle  { background: rgba(var(--color-warn-rgb), 0.12) !important; }
.bg-info-subtle  { background: rgba(var(--color-info-rgb), 0.12) !important; }

/* Badge combos (background + text) */
.badge-good  { background: rgba(var(--color-good-rgb), 0.15); color: var(--color-good); }
.badge-bad   { background: rgba(var(--color-bad-rgb), 0.15); color: var(--color-bad); }
.badge-warn  { background: rgba(var(--color-warn-rgb), 0.15); color: var(--color-warn); }
.badge-info-c { background: rgba(var(--color-info-rgb), 0.15); color: var(--color-info); }

/* Card accent borders (left or top) */
.card-accent-good  { border-left: 3px solid rgba(var(--color-good-rgb), 0.5) !important; }
.card-accent-bad   { border-left: 3px solid rgba(var(--color-bad-rgb), 0.5) !important; }
.card-accent-warn  { border-left: 3px solid rgba(var(--color-warn-rgb), 0.5) !important; }
.card-accent-info  { border-left: 3px solid rgba(var(--color-info-rgb), 0.5) !important; }

/* ═══════════════════════════════════════════════════════════════════════════ */
/* ─── Basic / Expert View Mode ────────────────────────────────────────────── */
/* ═══════════════════════════════════════════════════════════════════════════ */

/* Hide expert-only elements when in basic mode */
body.view-basic [data-view="expert"] { display: none !important; }
/* High specificity overrides for skeleton/real-content loading system */
body.view-basic.content-loaded [data-view="expert"],
body.view-basic.content-loaded .real-content[data-view="expert"],
body.view-basic.content-loaded .real-content.row[data-view="expert"],
body.view-basic.content-loaded .real-content.kpi-grid[data-view="expert"] { display: none !important; }

/* Hide basic-only elements when in expert mode */
body.view-expert [data-view="basic"] { display: none !important; }
body.view-expert.content-loaded [data-view="basic"],
body.view-expert.content-loaded .real-content[data-view="basic"],
body.view-expert.content-loaded .real-content.row[data-view="basic"],
body.view-expert.content-loaded .real-content.kpi-grid[data-view="basic"] { display: none !important; }

/* "More fields" nudge label — shown only in basic mode inside expert sections */
body.view-expert .view-basic-nudge { display: none !important; }

/* View mode toggle in sidebar */
.view-mode-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 4px 8px;
    margin: 0 4px;
    border-radius: var(--radius-sm);
    background: var(--bg-subtle);
    cursor: pointer;
    font-size: 0.68rem;
    font-weight: 500;
    color: var(--text-secondary);
    transition: all var(--transition-fast);
    user-select: none;
    border: 1px solid var(--border-subtle);
    white-space: nowrap;
}
.view-mode-toggle:hover {
    background: var(--accent-subtle);
    border-color: var(--accent-muted);
    color: var(--text-primary);
}
.view-mode-toggle .view-mode-label {
    letter-spacing: 0.3px;
    text-transform: uppercase;
}
.view-mode-toggle .view-mode-indicator {
    width: 28px;
    height: 14px;
    border-radius: 7px;
    background: var(--border-subtle);
    position: relative;
    transition: background var(--transition-fast);
    flex-shrink: 0;
}
.view-mode-toggle .view-mode-indicator::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--text-secondary);
    transition: all var(--transition-fast);
}
body.view-expert .view-mode-toggle .view-mode-indicator {
    background: var(--accent);
}
body.view-expert .view-mode-toggle .view-mode-indicator::after {
    left: 16px;
    background: #fff;
}
body.view-expert .view-mode-toggle .view-mode-label {
    color: var(--accent);
}

/* Basic mode sidebar — flat nav nudge link */
.sidebar-basic-nudge {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--border-subtle);
}
.sidebar-nudge-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 16px;
    font-size: 0.72rem;
    color: var(--accent) !important;
    opacity: 0.7;
    transition: opacity var(--transition-fast);
    text-decoration: none;
}
.sidebar-nudge-link:hover {
    opacity: 1;
    text-decoration: none;
}

/* Boundary nudge banner for expert features accessed in basic mode */
.expert-nudge-banner {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    margin-bottom: 16px;
    border-radius: var(--radius-md);
    background: var(--accent-subtle);
    border: 1px solid var(--accent-muted);
    font-size: 0.8rem;
    color: var(--text-primary);
}
.expert-nudge-banner > i {
    color: var(--accent);
    font-size: 1rem;
    flex-shrink: 0;
}
.expert-nudge-banner > span {
    flex: 1;
    min-width: 0;
}
.expert-nudge-banner .btn {
    flex-shrink: 0;
}

/* ─── Modal Backdrop ──────────────────────────────────────────────────────── */
.modal-backdrop {
    background: rgba(0, 0, 0, 0.7) !important;
}
[data-theme="light"] .modal-backdrop {
    background: rgba(0, 0, 0, 0.5) !important;
}

/* ─── Educational Info Tooltips ───────────────────────────────────────────── */
.info-tooltip {
    color: var(--text-muted);
    font-size: 0.75rem;
    cursor: help;
    opacity: 0.5;
    transition: opacity 0.15s ease, color 0.15s ease;
    vertical-align: middle;
    margin-left: 4px;
}
.info-tooltip:hover {
    opacity: 1;
    color: var(--accent);
}

[data-theme="light"] .sidebar-user-avatar {
    background: var(--accent-muted);
    color: var(--accent);
}

[data-theme="light"] .equity-highlight {
    border-color: rgba(0, 0, 0, 0.05);
    background: rgba(0, 0, 0, 0.01);
}

[data-theme="light"] .btn-ghost {
    color: var(--text-secondary);
    border-color: rgba(0, 0, 0, 0.12);
}

[data-theme="light"] .btn-ghost:hover {
    background: rgba(0, 0, 0, 0.06);
    color: var(--text-primary);
    border-color: rgba(0, 0, 0, 0.18);
}

[data-theme="light"] .btn-accent {
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
}

[data-theme="light"] .btn-accent:hover {
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.18);
}

[data-theme="light"] .card-custom {
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.10), 0 1px 2px rgba(0, 0, 0, 0.06);
    border-color: rgba(0, 0, 0, 0.13);
}

[data-theme="light"] .card-custom:hover {
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.10), 0 2px 6px rgba(0, 0, 0, 0.06);
}

[data-theme="light"] .card-custom .card-header {
    border-bottom-color: rgba(0, 0, 0, 0.08);
    background: rgba(0, 0, 0, 0.02);
}

[data-theme="light"] .kpi-card {
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.10), 0 1px 2px rgba(0, 0, 0, 0.06);
}

[data-theme="light"] .badge {
    border: 1px solid rgba(0, 0, 0, 0.06);
}

[data-theme="light"] .sidebar a {
    color: var(--text-secondary);
}

[data-theme="light"] .sidebar a:hover {
    background: rgba(0, 0, 0, 0.04);
    color: var(--text-primary);
}

[data-theme="light"] .sidebar a.active {
    color: var(--accent);
    background: var(--accent-muted);
}

[data-theme="light"] .form-control,
[data-theme="light"] .form-select {
    border-color: rgba(0, 0, 0, 0.15);
    background: #fff;
}

/* table-dark-custom light overrides now handled in unified block above */

/* ─── Modal Global Styling ───────────────────────────────────────────────── */

.modal-content {
    background: var(--bg-card) !important;
    color: var(--text-primary) !important;
    border: 1px solid var(--border-color) !important;
    border-radius: var(--radius-lg);
    box-shadow: 0 24px 80px rgba(0, 0, 0, 0.5);
}
.modal-header, .modal-footer {
    border-color: var(--border-color) !important;
}

/* ─── Light mode: Bootstrap overrides ────────────────────────────────────── */

/* Modal content inherits theme */
[data-theme="light"] .modal-content {
    background: var(--bg-card) !important;
    color: var(--text-primary) !important;
    border-color: rgba(0, 0, 0, 0.12) !important;
    box-shadow: 0 24px 80px rgba(0, 0, 0, 0.15);
}
[data-theme="light"] .modal-header,
[data-theme="light"] .modal-footer {
    border-color: rgba(0, 0, 0, 0.08) !important;
}
[data-theme="light"] .btn-close {
    filter: none;
}

/* Bootstrap bg-dark override for cards inside light mode */
[data-theme="light"] .card {
    background: var(--bg-card);
    color: var(--text-primary);
}

/* Tables in light mode — gold accent consistent with dark mode */
[data-theme="light"] .table,
[data-theme="light"] .table-custom,
[data-theme="light"] .table-dark-custom,
[data-theme="light"] table {
    color: var(--text-primary);
}
[data-theme="light"] .table-custom thead th,
[data-theme="light"] .table thead th {
    background: transparent !important;
    color: var(--text-secondary);
    border-bottom: 2px solid rgba(201, 168, 76, 0.35) !important;
    border-top: none !important;
}
[data-theme="light"] .table-custom tbody td,
[data-theme="light"] .table tbody td {
    border-bottom-color: rgba(0, 0, 0, 0.06);
    border-top: none;
}
[data-theme="light"] .table-custom tbody tr:hover,
[data-theme="light"] .table tbody tr:hover {
    background: rgba(201, 168, 76, 0.06) !important;
}
[data-theme="light"] .table-custom tfoot td,
[data-theme="light"] .table tfoot td {
    background: rgba(201, 168, 76, 0.04);
    border-top: 2px solid rgba(201, 168, 76, 0.3);
}

/* Neutralize Bootstrap .table-dark in light mode */
[data-theme="light"] .table-dark,
[data-theme="light"] .table-dark th,
[data-theme="light"] .table-dark td,
[data-theme="light"] .table-dark thead,
[data-theme="light"] .table-dark tbody,
[data-theme="light"] .table-dark tfoot,
[data-theme="light"] .table-dark tr {
    background-color: transparent !important;
    color: var(--text-primary) !important;
    --bs-table-bg: transparent;
    --bs-table-color: var(--text-primary);
    --bs-table-border-color: rgba(0, 0, 0, 0.06);
    --bs-table-striped-bg: transparent;
    --bs-table-hover-bg: rgba(201, 168, 76, 0.06);
}
[data-theme="light"] .table-dark thead th {
    background: transparent !important;
    color: var(--text-secondary) !important;
    border-bottom: 2px solid rgba(201, 168, 76, 0.35) !important;
}
[data-theme="light"] .table-dark tbody tr:hover {
    background: rgba(201, 168, 76, 0.06) !important;
}
[data-theme="light"] .table-dark tfoot tr {
    background: rgba(201, 168, 76, 0.04) !important;
}

/* btn-accent contrast in light mode — darker gold with dark text */
[data-theme="light"] .btn-accent {
    background: #9a7209 !important;
    border-color: #9a7209 !important;
    color: #fff !important;
}
[data-theme="light"] .btn-accent:hover {
    background: #836108 !important;
    border-color: #836108 !important;
    color: #fff !important;
}
[data-theme="light"] .btn-outline-accent {
    color: #7a5e07;
    border-color: #b8860b;
}
[data-theme="light"] .btn-outline-accent:hover {
    background: #b8860b;
    color: #fff;
}
[data-theme="light"] .btn-outline-accent.active {
    background: #b8860b;
    color: #fff;
}

/* Badge colors in light mode */
[data-theme="light"] .badge-income {
    background: rgba(26, 127, 55, 0.12) !important;
    color: #1a7f37 !important;
}
[data-theme="light"] .badge-expense {
    background: rgba(207, 34, 46, 0.10) !important;
    color: #cf222e !important;
}
[data-theme="light"] .badge-equity {
    background: rgba(184, 134, 11, 0.12) !important;
    color: #7a5e07 !important;
}

/* Input group addons */
[data-theme="light"] .input-group-text {
    background: rgba(0, 0, 0, 0.03);
    border-color: rgba(0, 0, 0, 0.15);
    color: var(--text-secondary);
}

/* Property card hover in light mode */
[data-theme="light"] .property-card {
    border-color: rgba(0, 0, 0, 0.10);
}
[data-theme="light"] .property-card:hover {
    border-color: var(--accent);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

/* ─── Theme toggle ───────────────────────────────────────────────────────── */

#themeToggle i {
    transition: transform var(--transition-fast);
}

#themeToggle:hover i {
    transform: rotate(15deg);
}

/* ═══════════════════════════════════════════════════════════════════════════ */
/* ─── Base Reset & Typography ────────────────────────────────────────────── */
/* ═══════════════════════════════════════════════════════════════════════════ */

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

html {
    scroll-behavior: smooth;
    overflow-x: clip;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg-dark);
    color: var(--text-primary);
    overflow-x: clip;
    width: 100%;
    touch-action: pan-y;  /* Prevent horizontal scroll on iOS Safari — overflow-x:hidden is unreliable on iOS */
    font-size: 14px;
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    letter-spacing: -0.006em;
}

/* ═══════════════════════════════════════════════════════════════════════════ */
/* ─── Sidebar ────────────────────────────────────────────────────────────── */
/* ═══════════════════════════════════════════════════════════════════════════ */

.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border-subtle);
    display: flex;
    flex-direction: column;
    z-index: 1000;
    transition: width var(--transition-smooth), transform var(--transition-smooth);
}

.sidebar-brand {
    padding: 10px 16px;
    height: var(--topbar-height);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.sidebar-brand-link {
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    height: 100%;
}

.sidebar-logo-full {
    height: 40px;
    width: auto;
    object-fit: contain;
    display: block;
}

.sidebar-logo-icon {
    height: 32px;
    width: 32px;
    object-fit: contain;
    display: none;
}

.sidebar-nav {
    list-style: none;
    padding: var(--space-2) 0;
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
}

.sidebar-nav .nav-section {
    padding: var(--space-5) var(--space-5) var(--space-1);
    font-size: 0.6rem;
    font-weight: 600;
    color: var(--text-muted);
    letter-spacing: 1.2px;
    text-transform: uppercase;
    white-space: nowrap;
    overflow: hidden;
}

.sidebar-nav .nav-section:first-child {
    padding-top: var(--space-3);
}

/* Collapsible sidebar sections */
.nav-section-toggle {
    cursor: pointer;
    display: flex !important;
    justify-content: space-between;
    align-items: center;
    user-select: none;
}
.nav-section-toggle:hover { color: var(--text-secondary); }
.sidebar-section-links { overflow: hidden; transition: max-height 0.25s ease; }
.sidebar-section-links.collapsed { max-height: 0 !important; overflow: hidden; }

/* Collapsible sidebar groups (Bootstrap collapse) */
.sidebar-group { position: relative; }

/* Split parent row: navigable link + separate chevron toggle.
   Must look identical to .sidebar-nav a (Dashboard/Properties). */
.sidebar-parent-row {
    display: flex;
    align-items: center;
    margin: 1px var(--space-2);
    border-radius: var(--radius-sm);
    border-left: 2px solid transparent;
    transition: all var(--transition-fast);
}
.sidebar-parent-row:hover { background: var(--accent-subtle); }
.sidebar-parent-row.active { background: var(--accent-muted); border-left-color: var(--accent); }
/* Override .sidebar-nav a styles on the link inside parent-row */
.sidebar-nav .sidebar-parent-row a.sidebar-parent-link {
    margin: 0;
    padding: 6px 0 6px var(--space-4);
    border-left: none;
    border-radius: 0;
    background: none !important;
    flex: 1;
    min-width: 0;
}
.sidebar-parent-row.active .sidebar-parent-link { color: var(--accent); font-weight: 500; }
.sidebar-parent-link:hover { color: var(--text-primary); text-decoration: none; }
.sidebar-chevron-btn {
    background: none;
    border: none;
    padding: 6px 10px;
    color: var(--text-muted);
    cursor: pointer;
    transition: color var(--transition-fast);
    flex-shrink: 0;
    line-height: 1;
}
.sidebar-chevron-btn:hover { color: var(--text-primary); }
.sidebar-chevron-btn .sidebar-chevron { opacity: 0.5; }
.sidebar-chevron-btn[aria-expanded="true"] .sidebar-chevron { transform: rotate(180deg); }
.sidebar-chevron-btn:hover .sidebar-chevron { opacity: 0.8; }

/* Legacy single-element parent (kept for backwards compat) */
.sidebar-parent {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: 6px var(--space-4);
    margin: 1px var(--space-2);
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.8rem;
    font-weight: 450;
    transition: all var(--transition-fast);
    border-radius: var(--radius-sm);
    border-left: 2px solid transparent;
    white-space: nowrap;
    overflow: hidden;
    position: relative;
    cursor: pointer;
}
.sidebar-parent:hover { color: var(--text-primary); background: var(--accent-subtle); }
.sidebar-parent.active { color: var(--accent); background: var(--accent-muted); border-left-color: var(--accent); font-weight: 500; }
.sidebar-parent i:first-child { font-size: 1rem; width: 18px; text-align: center; flex-shrink: 0; opacity: 0.7; }
.sidebar-parent.active i:first-child { opacity: 1; }
.sidebar-chevron {
    font-size: 0.55rem;
    margin-left: auto;
    transition: transform 0.25s ease;
    opacity: 0.5;
    flex-shrink: 0;
}
.sidebar-parent[aria-expanded="true"] .sidebar-chevron { transform: rotate(180deg); }
.sidebar-parent:hover .sidebar-chevron { opacity: 0.8; }

/* Submenu items */
.sidebar-submenu {
    list-style: none;
    padding: 0;
    margin: 0;
}
.sidebar-submenu li a {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px var(--space-4) 4px 28px;
    margin: 0 var(--space-2);
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.74rem;
    font-weight: 400;
    transition: all var(--transition-fast);
    border-radius: var(--radius-sm);
    border-left: 2px solid transparent;
    white-space: nowrap;
    overflow: hidden;
    position: relative;
}
.sidebar-submenu li a i {
    font-size: 0.72rem;
    width: 16px;
    text-align: center;
    flex-shrink: 0;
    opacity: 0.45;
}
.sidebar-submenu li a:hover { color: var(--text-primary); background: var(--accent-subtle); }
.sidebar-submenu li a:hover i { opacity: 0.7; }
.sidebar-submenu li a.active { color: var(--accent); background: var(--accent-muted); border-left-color: var(--accent); font-weight: 500; }
.sidebar-submenu li a.active i { opacity: 1; color: var(--accent); }

.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: 7px var(--space-4);
    margin: 1px var(--space-2);
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.85rem;
    font-weight: 450;
    transition: all var(--transition-fast);
    border-radius: var(--radius-sm);
    border-left: 2px solid transparent;
    white-space: nowrap;
    overflow: hidden;
    position: relative;
}

.sidebar-nav a:hover {
    color: var(--text-primary);
    background: var(--accent-subtle);
}

.sidebar-nav a.active {
    color: var(--accent);
    background: var(--accent-muted);
    border-left-color: var(--accent);
    font-weight: 500;
}

.sidebar-nav a i {
    font-size: 1.05rem;
    width: 20px;
    text-align: center;
    flex-shrink: 0;
    opacity: 0.7;
}

.sidebar-nav a.active i {
    opacity: 1;
}

.sidebar-nav a:hover i {
    opacity: 0.9;
}

/* Sidebar notification badge */
.sidebar-badge {
    margin-left: auto;
    background: var(--danger);
    color: #fff;
    font-size: 0.6rem;
    font-weight: 600;
    padding: 1px 6px;
    border-radius: 10px;
    min-width: 18px;
    text-align: center;
    line-height: 1.4;
}

/* ─── Page Tab Navigation (grouped page tabs) ─────────────────────────── */

.page-tab-nav {
    margin: -8px 0 20px 0;
    border-bottom: 1px solid var(--border-subtle);
    overflow: hidden;
    position: relative;
    display: flex;
    align-items: stretch;
}
.page-tab-arrow {
    background: var(--body-bg);
    border: none;
    color: var(--text-muted);
    padding: 0 6px;
    cursor: pointer;
    font-size: 0.8rem;
    z-index: 2;
    flex-shrink: 0;
    border-bottom: 1px solid var(--border-subtle);
    transition: color 0.15s;
}
.page-tab-arrow:hover { color: var(--accent); }
.page-tab-nav::after {
    content: '';
    position: absolute;
    right: 0;
    top: 0;
    bottom: 1px;
    width: 40px;
    background: linear-gradient(to right, transparent, var(--body-bg));
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s;
}
.page-tab-nav.has-overflow::after {
    opacity: 1;
}
.page-tab-nav::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 1px;
    width: 40px;
    background: linear-gradient(to left, transparent, var(--body-bg));
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s;
    z-index: 1;
}
.page-tab-nav.has-overflow-left::before { opacity: 1; }
.page-tab-scroll {
    display: flex;
    gap: 0;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding-bottom: 1px;
    flex-wrap: nowrap;
}
.page-tab-scroll::-webkit-scrollbar { display: none; }
.page-tab {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 16px;
    font-size: 0.82rem;
    font-weight: 450;
    color: var(--text-secondary);
    text-decoration: none;
    white-space: nowrap;
    border-bottom: 2px solid transparent;
    transition: color 0.15s ease, border-color 0.15s ease;
    position: relative;
    bottom: -1px;
}
.page-tab:hover {
    color: var(--text-primary);
    text-decoration: none;
}
.page-tab.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
    font-weight: 500;
}
.page-tab i {
    font-size: 0.9rem;
    opacity: 0.7;
}
.page-tab.active i {
    opacity: 1;
}

/* ─── Tab Star (favorite toggle) ───────────────────────────────────────── */
.btn-tab-star {
    background: none; border: none; cursor: pointer; padding: 0 0 0 4px;
    color: var(--text-muted); font-size: 0.7rem; opacity: 0;
    transition: opacity 0.15s ease, color 0.15s ease;
    line-height: 1;
}
.page-tab:hover .btn-tab-star { opacity: 0.6; }
.btn-tab-star:hover { opacity: 1 !important; color: var(--accent); }
.btn-tab-star.starred { opacity: 1; color: var(--accent); }
.btn-tab-star.starred i::before { content: "\f588"; }

/* ─── Settings Tab Nav (scrollable with category dividers) ────────────── */
/* Settings vertical sidebar (desktop) */
.settings-sidebar {
    position: sticky;
    top: 80px;
    padding-right: 1rem;
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
}
.settings-sidebar-group {
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--accent);
    padding: 12px 12px 4px;
    margin-top: 4px;
}
.settings-sidebar-group:first-child { margin-top: 0; padding-top: 4px; }
.settings-sidebar-link {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 0.82rem;
    color: var(--text-secondary);
    text-decoration: none;
    transition: background 0.15s, color 0.15s;
    cursor: pointer;
}
.settings-sidebar-link i { font-size: 0.9rem; width: 18px; text-align: center; }
.settings-sidebar-link:hover { background: rgba(255,255,255,0.05); color: var(--text-primary); }
.settings-sidebar-link.active {
    background: rgba(201, 168, 76, 0.12);
    color: var(--accent) !important;
    font-weight: 600;
}
.settings-tab-arrow {
    background: var(--bg-dark);
    border: none;
    color: var(--text-muted);
    padding: 0 6px;
    cursor: pointer;
    font-size: 0.8rem;
    z-index: 2;
    flex-shrink: 0;
    border-bottom: 1px solid var(--border-subtle);
    transition: color 0.15s;
}
.settings-tab-arrow:hover { color: var(--accent); }

/* Skeleton loading animation */
.skeleton {
    background: linear-gradient(90deg, var(--card-bg) 25%, rgba(255,255,255,0.08) 50%, var(--card-bg) 75%);
    background-size: 200% 100%;
    animation: skeleton-shimmer 1.5s ease-in-out infinite;
    border-radius: 4px;
}
.skeleton-text {
    height: 1em;
    margin-bottom: 0.5em;
    border-radius: 4px;
}
.skeleton-card {
    height: 120px;
    border-radius: 8px;
}
.skeleton-kpi {
    height: 80px;
    border-radius: 8px;
}
@keyframes skeleton-shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* ─── Inline-Style Utility Classes ────────────────────────────────────── */
/* Color utilities */
.text-accent       { color: var(--accent) !important; }
.text-secondary-var { color: var(--text-secondary) !important; }
.text-primary-var  { color: var(--text-primary) !important; }
.text-muted-var    { color: var(--text-muted) !important; }
.text-success-var  { color: var(--success) !important; }
.text-danger-var   { color: var(--danger) !important; }
.text-info-var     { color: var(--info) !important; }
.text-warning-var  { color: var(--warning) !important; }

/* Override Bootstrap semantic colors to use palette variables */
.text-success { color: var(--success) !important; }
.text-danger  { color: var(--danger) !important; }
.text-warning { color: var(--warning) !important; }
.text-info    { color: var(--info) !important; }

/* Override Bootstrap's RGB vars so bg-success/bg-danger + bg-opacity-* combos
   use palette colors instead of Bootstrap's hardcoded values */
:root,
[data-palette] {
    --bs-success-rgb: var(--success-rgb);
    --bs-danger-rgb: var(--danger-rgb);
    --bs-warning-rgb: var(--warning-rgb);
    --bs-info-rgb: var(--color-info-rgb);
}
/* Solid bg- overrides for badges WITHOUT bg-opacity-* */
.bg-success:not([class*="bg-opacity"]) { background-color: var(--success) !important; }
.bg-danger:not([class*="bg-opacity"])  { background-color: var(--danger) !important; }
.bg-warning:not([class*="bg-opacity"]) { background-color: var(--warning) !important; }
.bg-info:not([class*="bg-opacity"])    { background-color: var(--info) !important; }

/* Palette-aware card hover & interactive option styles */
.palette-option {
    transition: all 0.2s ease;
}
.palette-option:hover {
    border-color: rgba(var(--color-info-rgb), 0.4) !important;
    background: rgba(255, 255, 255, 0.03) !important;
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
}
.palette-option:active {
    transform: translateY(0);
    box-shadow: none;
}
.palette-option.palette-active:hover {
    border-color: var(--accent) !important;
    background: var(--accent-subtle) !important;
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(212, 168, 67, 0.15);
}

/* (card-custom hover enhancement applied in main .card-custom block below) */

/* Settings interactive items (view mode cards, layout cards, etc.) */
.dl-option {
    transition: all 0.2s ease;
}
.dl-option:hover {
    border-color: rgba(var(--color-info-rgb), 0.3) !important;
    background: rgba(255, 255, 255, 0.03) !important;
    transform: translateY(-1px);
}

/* Badge contrast improvements — ensure minimum opacity for readability */
.badge.bg-opacity-25 {
    --bs-bg-opacity: 0.18;
    font-weight: 600;
    letter-spacing: 0.01em;
}
.badge.bg-opacity-75 {
    font-weight: 600;
    color: #fff !important;
}
[data-theme="light"] .badge.bg-opacity-25 {
    --bs-bg-opacity: 0.15;
}
[data-theme="light"] .badge.bg-opacity-75 {
    color: #fff !important;
}

/* Font-size scale (rem) */
.fs-4xs  { font-size: 0.6rem !important; }
.fs-3xs  { font-size: 0.65rem !important; }
.fs-2xs  { font-size: 0.7rem !important; }
.fs-2xs-plus { font-size: 0.72rem !important; }
.fs-xxs  { font-size: 0.75rem !important; }
.fs-078  { font-size: 0.78rem !important; }
.fs-080  { font-size: 0.8rem !important; }
.fs-082  { font-size: 0.82rem !important; }
.fs-085  { font-size: 0.85rem !important; }
.fs-088  { font-size: 0.88rem !important; }
.fs-090  { font-size: 0.9rem !important; }

/* Layout utilities */
.clickable   { cursor: pointer !important; }
.min-w-0     { min-width: 0 !important; }
.w-auto      { width: auto !important; }
.border-none { border: none !important; }
.bg-transparent { background: transparent !important; }
.tracking-wide { letter-spacing: 0.05em !important; }

/* Scroll containers */
.scroll-y-200 { max-height: 200px; overflow-y: auto; }
.scroll-y-300 { max-height: 300px; overflow-y: auto; }
.scroll-y-400 { max-height: 400px; overflow-y: auto; }

/* Common composite patterns */
.input-dark {
    background: var(--bg-surface);
    border-color: var(--border-color);
    color: var(--text-primary);
}
.select-dark {
    background: var(--bg-card);
    color: var(--text);
    border-color: rgba(255,255,255,0.1);
    font-size: .75rem;
}
.card-subtle {
    background: rgba(255,255,255,0.02);
    border: 1px solid var(--border);
}
.border-border { border-color: var(--border) !important; }
.border-border-color { border-color: var(--border-color) !important; }

@media (max-width: 767.98px) {
    .page-tab-nav { margin: -4px 0 16px 0; }
    .page-tab {
        padding: 8px 10px;
        font-size: 0.75rem;
    }
    .page-tab > i { display: none; }
    .btn-tab-star { opacity: 0.5; font-size: 0.65rem; padding: 2px 0 0 3px; }
    .btn-tab-star.starred { opacity: 1; }
}

/* ─── Sidebar Favorites ────────────────────────────────────────────────── */
.nav-section-favorites {
    display: flex; align-items: center; justify-content: space-between;
}
.nav-section-favorites span { font-size: 0.65rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-muted); font-weight: 600; }
.btn-fav-edit {
    background: none; border: none; cursor: pointer; padding: 2px 4px;
    color: var(--text-muted); font-size: 0.7rem; opacity: 0;
    transition: opacity 0.15s ease;
}
.nav-section-favorites:hover .btn-fav-edit { opacity: 0.6; }
.btn-fav-edit:hover { opacity: 1 !important; color: var(--accent); }
.btn-fav-edit.active { opacity: 1; color: var(--accent); }

.sidebar-favorites {
    list-style: none; padding: 0; margin: 0;
}
.fav-item {
    display: flex; align-items: center; position: relative;
}
.fav-item a {
    display: flex; align-items: center; gap: 10px; flex: 1;
    padding: 8px 16px; font-size: 0.82rem; font-weight: 400;
    color: var(--text-secondary); text-decoration: none;
    transition: color 0.15s ease, background 0.15s ease;
    border-radius: 6px; margin: 0 8px;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.fav-item a:hover { color: var(--text-primary); background: rgba(255,255,255,0.04); }
.fav-item a.active { color: var(--accent); background: rgba(201,168,76,0.08); font-weight: 500; }
.fav-item a i { font-size: 0.9rem; opacity: 0.7; flex-shrink: 0; }
.fav-item a span { overflow: hidden; text-overflow: ellipsis; }

.btn-fav-remove {
    background: none; border: none; cursor: pointer; padding: 4px 8px;
    color: var(--text-muted); font-size: 0.7rem; opacity: 0;
    transition: opacity 0.15s ease, color 0.15s ease;
    position: absolute; right: 8px;
}
.fav-item:hover .btn-fav-remove { opacity: 0.5; }
.btn-fav-remove:hover { opacity: 1 !important; color: var(--danger); }

/* Drag reorder mode */
.sidebar-favorites.reorder-mode .fav-item { cursor: grab; }
.sidebar-favorites.reorder-mode .fav-item.dragging { opacity: 0.4; }
.sidebar-favorites.reorder-mode .fav-item a { pointer-events: none; }
.sidebar-favorites.reorder-mode .btn-fav-remove { display: none; }
.fav-item.drag-over-above { box-shadow: 0 -2px 0 0 var(--accent); }
.fav-item.drag-over-below { box-shadow: 0 2px 0 0 var(--accent); }

/* ─── Sidebar Footer ────────────────────────────────────────────────────── */

.sidebar-footer {
    padding: var(--space-3) var(--space-4);
    border-top: 1px solid var(--border-subtle);
}

.sidebar-footer-actions {
    display: flex;
    gap: var(--space-1);
    margin-bottom: var(--space-3);
    padding-bottom: var(--space-3);
    border-bottom: 1px solid var(--border-subtle);
}

.sidebar-footer-btn {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    background: transparent;
    border: none;
    cursor: pointer;
    transition: all var(--transition-fast);
    text-decoration: none;
    font-size: 0.95rem;
}

.sidebar-footer-btn:hover {
    color: var(--text-primary);
    background: var(--accent-subtle);
}

.sidebar-footer-btn.active {
    color: var(--accent);
    background: var(--accent-muted);
}

.sidebar-user {
    display: flex;
    align-items: center;
    gap: var(--space-3);
}

.sidebar-user-avatar {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent-muted), rgba(212, 168, 67, 0.2));
    color: var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 700;
    flex-shrink: 0;
    letter-spacing: 0;
}

.sidebar-user-info {
    flex: 1;
    min-width: 0;
}

.sidebar-user-name {
    display: block;
    font-size: 0.78rem;
    font-weight: 500;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.3;
}

.sidebar-user-role {
    display: block;
    font-size: 0.6rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 500;
}

.sidebar-logout-form {
    margin: 0;
}

/* ─── Amount & Transaction Badge Colors ────────────────────────────────── */
.amount-positive { color: var(--color-good) !important; }
.amount-negative { color: var(--color-bad) !important; }
.badge-income { background: rgba(var(--color-good-rgb), 0.15); color: var(--color-good); }
.badge-expense { background: rgba(var(--color-bad-rgb), 0.15); color: var(--color-bad); }
.badge-equity { background: rgba(var(--color-info-rgb), 0.15); color: var(--color-info); }
/* Light theme inherits from palette variables — no hardcoded overrides needed */

/* ─── Knox Activity Gauge (sidebar bottom) ─────────────────────────────── */

.knox-gauge {
    position: relative;
    padding: 10px 14px 12px;
    border-top: 1px solid var(--border-subtle);
    cursor: pointer;
    transition: background 0.15s ease;
    flex-shrink: 0;
}

.knox-gauge:hover {
    background: var(--accent-subtle, rgba(201, 168, 76, 0.06));
}

.knox-gauge-bar-track {
    width: 100%;
    height: 4px;
    background: var(--bg-input, rgba(255,255,255,0.06));
    border-radius: 2px;
    overflow: hidden;
    margin-bottom: 6px;
}

.knox-gauge-bar-fill {
    height: 100%;
    border-radius: 2px;
    background: var(--accent, #c9a84c);
    transition: width 0.6s ease, background-color 0.3s ease;
    width: 0%;
}

.knox-gauge-bar-fill.gauge-amber {
    background: var(--warning);
}

.knox-gauge-bar-fill.gauge-red {
    background: var(--danger);
}

.knox-gauge-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.knox-gauge-label {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 0.68rem;
    font-weight: 600;
    color: var(--text-muted);
    letter-spacing: 0.3px;
}

.knox-gauge-label i {
    font-size: 0.75rem;
    color: var(--accent, #c9a84c);
}

.knox-gauge-text {
    font-size: 0.62rem;
    color: var(--text-secondary);
    font-variant-numeric: tabular-nums;
    padding-left: 20px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Popover */
.knox-gauge-popover {
    display: none;
    position: absolute;
    bottom: calc(100% + 8px);
    left: 10px;
    right: 10px;
    background: var(--bg-card, #161b22);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md, 8px);
    padding: 14px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.35);
    z-index: 100;
    animation: knoxGaugePopIn 0.15s ease;
}

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

.knox-gauge-popover.show {
    display: block;
}

.knox-gauge-popover-title {
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--accent, #c9a84c);
    margin-bottom: 10px;
    letter-spacing: 0.3px;
}

.knox-gauge-popover-stats {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px 12px;
    margin-bottom: 10px;
}

.knox-gauge-popover-stats .gauge-stat {
    display: flex;
    flex-direction: column;
}

.knox-gauge-popover-stats .gauge-stat-value {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-primary);
    font-variant-numeric: tabular-nums;
    line-height: 1.2;
}

.knox-gauge-popover-stats .gauge-stat-label {
    font-size: 0.6rem;
    color: var(--text-muted);
    letter-spacing: 0.2px;
}

.knox-gauge-popover-time {
    padding: 8px 0;
    border-top: 1px solid var(--border-subtle);
    font-size: 0.72rem;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 6px;
    line-height: 1.4;
}

.knox-gauge-popover-time i {
    color: var(--accent, #c9a84c);
    font-size: 0.85rem;
    flex-shrink: 0;
}

.knox-gauge-popover-time .time-value {
    font-weight: 700;
    color: var(--accent, #c9a84c);
}

.knox-gauge-popover-reset {
    font-size: 0.58rem;
    color: var(--text-muted);
    margin-top: 4px;
}

.knox-gauge-popover-cta {
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid var(--border-subtle);
}

.knox-gauge-popover-cta a {
    display: block;
    text-align: center;
    font-size: 0.68rem;
    font-weight: 600;
    color: var(--accent, #c9a84c);
    text-decoration: none;
    padding: 6px 10px;
    border: 1px solid var(--accent, #c9a84c);
    border-radius: var(--radius-sm, 6px);
    transition: all 0.15s ease;
}

.knox-gauge-popover-cta a:hover {
    background: var(--accent, #c9a84c);
    color: #0d1117;
}

/* Mobile adjustments — popover above bottom nav */
@media (max-width: 767.98px) {
    .knox-gauge-popover {
        left: 4px;
        right: 4px;
        bottom: calc(100% + 12px);
    }
}

/* ═══════════════════════════════════════════════════════════════════════════ */
/* ─── Main Content ───────────────────────────────────────────────────────── */
/* ═══════════════════════════════════════════════════════════════════════════ */

.main-content {
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    transition: margin-left var(--transition-smooth);
}

/* ─── Topbar ─────────────────────────────────────────────────────────────── */

.topbar {
    height: var(--topbar-height);
    display: flex;
    align-items: center;
    padding: 0 var(--space-6);
    border-bottom: 1px solid var(--border-subtle);
    background: rgba(9, 11, 15, 0.80);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    position: sticky;
    top: 0;
    z-index: 100;
    gap: var(--space-3);
    overflow: visible;
    justify-content: space-between;
}

/* ─── Search Box (replaced by Knox command trigger) ──────────────────────── */

/* ─── Topbar Right ───────────────────────────────────────────────────────── */

/* Tablet-only items: hidden on desktop, shown via media query */
.topbar-show-tablet { display: none !important; }

.topbar-right {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    flex-shrink: 0;
    margin-left: auto;
    z-index: 1;
}

.topbar-icon-btn {
    width: 34px;
    height: 34px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    padding: 0;
    transition: all var(--transition-fast);
}

.topbar-icon-btn:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.04);
}

.topbar-icon-btn i {
    font-size: 1.1rem;
}

.topbar-notification-dot {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 10px;
    height: 10px;
    background: var(--danger);
    border-radius: 50%;
    border: 2px solid var(--bg-dark);
    animation: notif-pulse 2s ease-in-out infinite;
    box-shadow: 0 0 6px rgba(var(--danger-rgb), 0.6);
}

@keyframes notif-pulse {
    0%, 100% { transform: scale(1); opacity: 1; box-shadow: 0 0 6px rgba(var(--danger-rgb), 0.6); }
    50% { transform: scale(1.3); opacity: 0.85; box-shadow: 0 0 10px rgba(var(--danger-rgb), 0.8); }
}

.topbar-date {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 500;
    letter-spacing: 0.01em;
}

.notification-dropdown {
    width: 340px;
    background: var(--bg-elevated) !important;
    border: 1px solid var(--border-color) !important;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.35) !important;
    border-radius: var(--radius-md) !important;
}

/* ─── Flash Messages ─────────────────────────────────────────────────────── */

.flash-container {
    padding: var(--space-4) var(--space-6) 0;
}

/* ═══════════════════════════════════════════════════════════════════════════ */
/* ─── Page Content ───────────────────────────────────────────────────────── */
/* ═══════════════════════════════════════════════════════════════════════════ */

.page-content {
    padding: var(--space-6);
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-6);
    flex-wrap: wrap;
    gap: var(--space-3);
}

.page-header h1 {
    font-size: 1.3rem;
    font-weight: 600;
    color: var(--text-primary);
    letter-spacing: -0.025em;
}

.page-header .breadcrumb {
    font-size: 0.78rem;
    margin: 0;
}

/* ═══════════════════════════════════════════════════════════════════════════ */
/* ─── Cards ──────────────────────────────────────────────────────────────── */
/* ═══════════════════════════════════════════════════════════════════════════ */

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: var(--space-5);
    transition: all var(--transition-fast);
    position: relative;
    overflow: hidden;
}

.stat-card:hover {
    border-color: rgba(255, 255, 255, 0.08);
    background: var(--bg-elevated);
}

.stat-card .stat-icon {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    margin-bottom: var(--space-3);
}

.stat-card .stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    line-height: 1.15;
    letter-spacing: -0.03em;
}

.stat-card .stat-label {
    font-size: 0.72rem;
    color: var(--text-muted);
    margin-top: var(--space-1);
    font-weight: 500;
    letter-spacing: 0.01em;
}

.card-custom {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    overflow: hidden;
    transition: border-color var(--transition-fast), box-shadow var(--transition-normal);
}

.card-custom:hover {
    border-color: rgba(255, 255, 255, 0.10);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
}

.card-custom .card-header {
    background: transparent;
    border-bottom: 1px solid var(--border-subtle);
    padding: 0 var(--space-5);
    font-weight: 600;
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    gap: var(--space-2);
    min-height: 52px;
}

/* First child (title) takes available space, everything else goes right */
.card-custom .card-header > :first-child {
    flex: 1;
    min-width: 0;
}

.card-header-title {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--text-primary);
}

.card-header-title i {
    opacity: 0.5;
    font-size: 0.95rem;
}

.card-header-meta {
    font-size: 0.7rem;
    font-weight: 500;
    color: var(--text-muted);
}

.card-header-accent {
    border-bottom-color: rgba(212, 168, 67, 0.15);
}

.card-custom .card-body {
    padding: var(--space-5);
}

/* ═══════════════════════════════════════════════════════════════════════════ */
/* ─── Masonry Layout System ─────────────────────────────────────────────── */
/* ═══════════════════════════════════════════════════════════════════════════ */

/* Base masonry: auto-flowing 2-column grid (like Pinterest) */
.dv-masonry {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
    align-items: start;
}

/* Full-width item inside masonry grid */
.dv-masonry > .dv-full {
    grid-column: 1 / -1;
}

/* 3-column variant for wider layouts */
.dv-masonry-3 {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
    align-items: start;
}
.dv-masonry-3 > .dv-full {
    grid-column: 1 / -1;
}
.dv-masonry-3 > .dv-span-2 {
    grid-column: span 2;
}

/* Responsive: collapse to single column on tablet/mobile */
@media (max-width: 991.98px) {
    .dv-masonry,
    .dv-masonry-3 {
        grid-template-columns: minmax(0, 1fr);
        max-width: 100%;
        overflow: hidden;
    }
    .dv-masonry > *,
    .dv-masonry-3 > * {
        min-width: 0;
        max-width: 100%;
    }
    .dv-masonry-3 > .dv-span-2 {
        grid-column: 1;
    }
}

/* Equal-height cards in masonry — match height when both expanded, collapse independently */
.dv-masonry.dv-equal {
    align-items: start;
}
/* Equal-height cards in masonry — stretch to match tallest in row */
.dv-masonry.dv-equal > * {
    align-self: stretch;
}
.dv-masonry.dv-equal .card-collapsible,
.dv-masonry.dv-equal .card-custom {
    height: 100%;
    display: flex;
    flex-direction: column;
}
/* Collapse body flex behavior for card-collapsible AND card-custom */
.dv-masonry.dv-equal .card-collapsible .collapse,
.dv-masonry.dv-equal .card-collapsible .collapsing,
.dv-masonry.dv-equal .card-custom .collapse,
.dv-masonry.dv-equal .card-custom .collapsing,
.dv-masonry.dv-equal .card-custom .card-collapse-body {
    flex: 1;
}
/* When collapsed, allow card to shrink independently */
.dv-masonry.dv-equal .card-collapsible .collapse:not(.show),
.dv-masonry.dv-equal .card-custom .collapse:not(.show) {
    flex: 0;
}
/* When a card is collapsed, let its wrapper shrink instead of stretching to match sibling */
.dv-masonry.dv-equal > *:has(.collapse:not(.show)) {
    align-self: start;
}
.dv-masonry.dv-equal > *:has(.collapse:not(.show)) .card-custom,
.dv-masonry.dv-equal > *:has(.collapse:not(.show)) .card-collapsible {
    height: auto;
}

/* ─── Card / Sidebar Organization Tree ────────────────────────────────────── */
.card-org-tree {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 520px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 4px 0;
}
.card-org-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-radius: 10px;
    background: var(--surface-2, var(--bg-elevated));
    border: 1.5px solid var(--border-color);
    cursor: grab;
    font-size: 0.85rem;
    font-weight: 500;
    min-height: 48px;
    touch-action: none;
    transition: border-color 0.15s, box-shadow 0.15s, transform 0.1s;
    user-select: none;
}
.card-org-item:hover { border-color: var(--accent); box-shadow: 0 2px 8px rgba(201,168,76,0.10); }
.card-org-item:active { cursor: grabbing; transform: scale(1.01); }
.card-org-item.sortable-ghost {
    background: rgba(201,168,76,0.08);
    border-color: var(--accent);
    border-style: dashed;
    opacity: 0.7;
}
.card-org-item.item-hidden { opacity: 0.4; }
.card-org-item.item-hidden .item-label { text-decoration: line-through; color: var(--text-muted); }
.card-org-item .drag-handle {
    color: var(--text-muted);
    flex-shrink: 0;
    font-size: 1.1rem;
    padding: 2px;
    min-width: 20px;
    text-align: center;
    opacity: 0.5;
}
.card-org-item:hover .drag-handle { opacity: 1; }
.card-org-item .item-icon {
    color: var(--accent);
    flex-shrink: 0;
    width: 22px;
    text-align: center;
    font-size: 0.95rem;
}
.card-org-item .item-label { flex: 1; color: var(--text-primary); }
.card-org-item .item-actions {
    display: flex;
    gap: 4px;
    align-items: center;
}
.card-org-item .item-actions .btn-visibility {
    background: none;
    border: 1px solid var(--border-color);
    color: var(--accent);
    padding: 0;
    width: 32px; height: 32px;
    font-size: 0.85rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    transition: all 0.15s;
}
.card-org-item .item-actions .btn-visibility:hover {
    background: rgba(201,168,76,0.12);
    border-color: var(--accent);
}
.card-org-item.item-hidden .btn-visibility {
    color: var(--text-muted);
    opacity: 0.5;
}
/* Section wrappers for collapsible groups */
.card-org-section { margin-bottom: 2px; }
.vc-section-children { padding-bottom: 4px; }

/* Toast notifications */
.hierarchy-toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    padding: 10px 24px;
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 500;
    z-index: 9999;
    color: #fff;
    box-shadow: 0 4px 16px rgba(0,0,0,0.4);
    animation: toastIn 0.3s ease;
}
.hierarchy-toast.toast-success { background: var(--success); }
.hierarchy-toast.toast-danger, .hierarchy-toast.toast-error { background: var(--danger); }
.hierarchy-toast.toast-info { background: var(--info); }
.hierarchy-toast.toast-warning { background: var(--warning); }
@keyframes toastIn { from { opacity:0; transform:translateX(-50%) translateY(10px); } to { opacity:1; transform:translateX(-50%) translateY(0); } }
.card-org-divider {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 14px;
    cursor: grab;
    font-size: 0.75rem;
    color: var(--text-muted);
    min-height: 36px;
    touch-action: none;
}
.card-org-divider::before,
.card-org-divider::after {
    content: '';
    flex: 1;
    border-top: 1px dashed var(--border-color);
}
.card-org-divider .divider-label {
    cursor: text;
    min-width: 40px;
    text-align: center;
}
.card-org-divider .item-actions {
    display: flex;
    gap: 4px;
}
.card-org-divider .item-actions button {
    min-width: 32px;
    min-height: 32px;
}
/* Mobile: always show actions, bigger touch targets */
@media (max-width: 767.98px) {
    .card-org-item { padding: 12px 12px; gap: 8px; font-size: 0.85rem; }
    .card-org-item .drag-handle { font-size: 1.1rem; }
    .card-org-tree { max-height: none; }
}

/* Sortable.js drag-and-drop styles */
.sortable-ghost { opacity: 0.4; background: var(--accent-muted) !important; }
.sortable-chosen { background: rgba(201, 168, 76, 0.08) !important; box-shadow: 0 0 0 2px var(--accent); }
.sortable-drag { box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3); }

/* ═══════════════════════════════════════════════════════════════════════════ */
/* ─── Tables ─────────────────────────────────────────────────────────────── */
/* ═══════════════════════════════════════════════════════════════════════════ */

/* ─── Unified Table Style ─────────────────────────────────────────────────── */
/* Applies to .table-custom and also overrides Bootstrap .table / .table-dark */

.table-custom,
.table-dark-custom {
    width: 100%;
    color: var(--text-primary);
    font-size: 0.84rem;
    border-collapse: separate;
    border-spacing: 0;
}

.table-custom thead th,
.table-dark-custom thead th {
    background: transparent;
    color: var(--text-muted);
    font-weight: 600;
    font-size: 0.68rem;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    padding: 10px var(--space-4);
    border-bottom: 2px solid rgba(201, 168, 76, 0.25);
    border-top: none;
    white-space: nowrap;
}

.table-custom tbody td,
.table-dark-custom tbody td {
    padding: 10px var(--space-4);
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
    border-top: none;
    vertical-align: middle;
    color: var(--text-primary);
    background: transparent;
}

.table-custom tbody tr,
.table-dark-custom tbody tr {
    transition: background 0.15s ease;
}

.table-custom tbody tr:hover,
.table-dark-custom tbody tr:hover {
    background: rgba(201, 168, 76, 0.04);
}

.table-custom tbody tr:last-child td,
.table-dark-custom tbody tr:last-child td {
    border-bottom: none;
}

.table-custom tfoot td,
.table-dark-custom tfoot td {
    padding: 10px var(--space-4);
    border-top: 2px solid rgba(201, 168, 76, 0.2);
    border-bottom: none;
    vertical-align: middle;
    font-weight: 600;
    color: var(--text-primary);
    background: rgba(201, 168, 76, 0.03);
}

/* ─── Override Bootstrap .table-dark to match our design ─────────────────── */
.table.table-dark,
.table.table-dark thead,
.table.table-dark tbody,
.table.table-dark tfoot,
.table.table-dark tr,
.table.table-dark th,
.table.table-dark td {
    background-color: transparent !important;
    color: var(--text-primary) !important;
    --bs-table-bg: transparent;
    --bs-table-striped-bg: transparent;
    --bs-table-hover-bg: rgba(201, 168, 76, 0.04);
    --bs-table-border-color: rgba(255, 255, 255, 0.03);
}

.table.table-dark thead th {
    color: var(--text-muted) !important;
    font-weight: 600;
    font-size: 0.68rem;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    padding: 10px var(--space-4);
    border-bottom: 2px solid rgba(201, 168, 76, 0.25) !important;
    border-top: none !important;
    white-space: nowrap;
}

.table.table-dark tbody td {
    padding: 10px var(--space-4);
    border-bottom: 1px solid rgba(255, 255, 255, 0.03) !important;
    border-top: none !important;
    vertical-align: middle;
}

.table.table-dark tbody tr:hover {
    background: rgba(201, 168, 76, 0.04) !important;
}

.table.table-dark tbody tr:last-child td {
    border-bottom: none !important;
}

.table.table-dark tfoot td {
    border-top: 2px solid rgba(201, 168, 76, 0.2) !important;
    border-bottom: none !important;
    font-weight: 600;
    background: rgba(201, 168, 76, 0.03) !important;
}

/* ─── Also style plain .table (non-dark) inside our app ──────────────────── */
.table:not(.table-dark) thead th {
    background: transparent;
    color: var(--text-muted);
    font-weight: 600;
    font-size: 0.68rem;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    border-bottom: 2px solid rgba(201, 168, 76, 0.25);
    border-top: none;
    white-space: nowrap;
}

.table:not(.table-dark) tbody td {
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
    border-top: none;
    vertical-align: middle;
}

.table:not(.table-dark) tbody tr:hover {
    background: rgba(201, 168, 76, 0.04);
}

.table:not(.table-dark) tbody tr:last-child td {
    border-bottom: none;
}

.table:not(.table-dark) tfoot td {
    border-top: 2px solid rgba(201, 168, 76, 0.2);
    border-bottom: none;
    font-weight: 600;
    background: rgba(201, 168, 76, 0.03);
}

/* Schedule E sticky columns */
.schedule-e-table .schedule-e-sticky {
    position: sticky;
    left: 0;
    z-index: 1;
    background: var(--bg-card);
}
.schedule-e-table thead .schedule-e-sticky { background: var(--bg-elevated); }

.amount-positive, .table-custom tbody td.amount-positive,
.table-dark-custom tbody td.amount-positive { color: var(--color-good) !important; font-weight: 600; }
.amount-negative, .table-custom tbody td.amount-negative,
.table-dark-custom tbody td.amount-negative { color: var(--color-bad) !important; font-weight: 600; }

/* ═══════════════════════════════════════════════════════════════════════════ */
/* ─── Property Cards ─────────────────────────────────────────────────────── */
/* ═══════════════════════════════════════════════════════════════════════════ */

.property-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: var(--space-5);
    transition: all var(--transition-fast);
    cursor: pointer;
    text-decoration: none;
    color: inherit;
    display: flex;
    flex-direction: column;
    height: 100%;
}

.property-card:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
    border-color: rgba(212, 168, 67, 0.2);
    color: inherit;
}

.property-card .property-state {
    display: inline-block;
    background: var(--accent-muted);
    color: var(--accent);
    padding: 2px 8px;
    border-radius: var(--radius-sm);
    font-size: 0.63rem;
    font-weight: 600;
    letter-spacing: 0.3px;
}

.property-card .property-type-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: var(--radius-sm);
    font-size: 0.63rem;
    font-weight: 600;
}

.property-card .property-type-badge.rental {
    background: rgba(var(--color-info-rgb), 0.10);
    color: var(--info);
}

.property-card .property-type-badge.section8 {
    background: rgba(var(--success-rgb), 0.10);
    color: var(--success);
}

.property-card h5 {
    font-size: 0.88rem;
    font-weight: 600;
    margin: var(--space-3) 0 var(--space-1);
    letter-spacing: -0.01em;
}

.property-card .property-address {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-bottom: var(--space-3);
}

.property-card .property-stats {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-2);
}

.property-card .property-stat {
    font-size: 0.68rem;
    color: var(--text-muted);
}

.property-card .property-stat span {
    display: block;
    font-size: 0.83rem;
    font-weight: 600;
    color: var(--text-primary);
}

/* ═══════════════════════════════════════════════════════════════════════════ */
/* ─── Buttons ────────────────────────────────────────────────────────────── */
/* ═══════════════════════════════════════════════════════════════════════════ */

.btn-accent {
    background: var(--accent);
    color: #000;
    font-weight: 600;
    border: none;
    border-radius: var(--radius-sm);
    transition: all var(--transition-fast);
    font-size: 0.8rem;
}

.btn-accent:hover {
    background: var(--accent-hover);
    color: #000;
    box-shadow: 0 2px 12px rgba(212, 168, 67, 0.25);
}

.btn-outline-accent {
    border: 1px solid rgba(212, 168, 67, 0.35);
    color: var(--accent);
    background: transparent;
    border-radius: var(--radius-sm);
    transition: all var(--transition-fast);
    font-size: 0.8rem;
}

.btn-outline-accent:hover {
    background: var(--accent);
    color: #000;
    border-color: var(--accent);
}

/* Ghost button - subtle, borderless */
.btn-ghost {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    border-radius: var(--radius-sm);
    transition: all var(--transition-fast);
    font-size: 0.78rem;
    font-weight: 500;
}

.btn-ghost:hover {
    background: rgba(255, 255, 255, 0.04);
    color: var(--text-primary);
    border-color: rgba(255, 255, 255, 0.10);
}

/* ═══════════════════════════════════════════════════════════════════════════ */
/* ─── Forms ──────────────────────────────────────────────────────────────── */
/* ═══════════════════════════════════════════════════════════════════════════ */

.form-control, .form-select {
    background: var(--bg-input) !important;
    border: 1px solid var(--border-color) !important;
    color: var(--text-primary) !important;
    border-radius: var(--radius-sm);
    padding: 8px 14px;
    font-size: 0.8rem;
    transition: all var(--transition-fast);
}

.form-control:focus, .form-select:focus {
    border-color: rgba(212, 168, 67, 0.35) !important;
    box-shadow: 0 0 0 3px rgba(212, 168, 67, 0.06) !important;
    background: var(--bg-dark) !important;
}

.form-label {
    font-size: 0.72rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: var(--space-1);
    letter-spacing: 0.01em;
}

/* ═══════════════════════════════════════════════════════════════════════════ */
/* ─── Badges ─────────────────────────────────────────────────────────────── */
/* ═══════════════════════════════════════════════════════════════════════════ */

.badge-income { background: rgba(var(--success-rgb), 0.10); color: var(--success); }
.badge-expense { background: rgba(var(--danger-rgb), 0.10); color: var(--danger); }
.badge-equity { background: rgba(var(--color-info-rgb), 0.10); color: var(--info); }
.badge-financing { background: rgba(var(--warning-rgb), 0.10); color: var(--warning); }
.badge-transfer { background: rgba(107, 114, 128, 0.12); color: var(--text-secondary); }

/* Standardized tag/badge colors */
.badge-state { background: rgba(255,255,255,0.1); color: var(--text-secondary); }
.badge-active { background: rgba(var(--success-rgb),0.15); color: var(--success); }
.badge-vacant { background: rgba(var(--danger-rgb),0.15); color: var(--danger); }
.badge-pending { background: rgba(var(--warning-rgb),0.15); color: var(--warning); }
.badge-paid-off { background: rgba(var(--success-rgb),0.15); color: var(--success); }
.badge-financed { background: rgba(var(--color-info-rgb),0.15); color: var(--info); }
.badge-dscr { background: rgba(142,68,173,0.15); color: #8e44ad; }
.badge-section8 { background: rgba(212,168,67,0.15); color: #D4A843; }
.badge-rental { background: rgba(var(--color-info-rgb),0.15); color: var(--info); }

/* ═══════════════════════════════════════════════════════════════════════════ */
/* ─── Login Page ─────────────────────────────────────────────────────────── */
/* ═══════════════════════════════════════════════════════════════════════════ */

.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-dark);
    position: relative;
}

.login-page::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: radial-gradient(ellipse at 50% 0%, rgba(212, 168, 67, 0.03) 0%, transparent 60%);
}

.login-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    padding: var(--space-10);
    width: 100%;
    max-width: 400px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    position: relative;
    z-index: 1;
}

.login-card .logo {
    text-align: center;
    margin-bottom: var(--space-8);
}

.login-card .logo i { font-size: 2.5rem; color: var(--accent); }
.login-card .logo h2 {
    font-size: 1.3rem;
    margin-top: var(--space-3);
    font-weight: 700;
    letter-spacing: -0.02em;
}
.login-card .logo p { color: var(--text-muted); font-size: 0.8rem; }

/* ═══════════════════════════════════════════════════════════════════════════ */
/* ─── Document Browser ───────────────────────────────────────────────────── */
/* ═══════════════════════════════════════════════════════════════════════════ */

.file-item {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-3) var(--space-4);
    border-bottom: 1px solid var(--border-subtle);
    transition: background var(--transition-fast);
    text-decoration: none;
    color: var(--text-primary);
}

.file-item:hover { background: var(--accent-subtle); color: var(--text-primary); }

.file-icon {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.05rem;
    flex-shrink: 0;
}

.file-icon.folder { background: var(--accent-muted); color: var(--accent); }
.file-icon.pdf { background: rgba(var(--danger-rgb), 0.08); color: var(--danger); }
.file-icon.image { background: rgba(var(--color-info-rgb), 0.08); color: var(--info); }
.file-icon.doc { background: rgba(var(--success-rgb), 0.08); color: var(--success); }
.file-icon.other { background: rgba(107, 114, 128, 0.08); color: var(--text-muted); }

.file-info { flex: 1; min-width: 0; }
.file-info .file-name { font-size: 0.83rem; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.file-info .file-meta { font-size: 0.68rem; color: var(--text-muted); }

/* ═══════════════════════════════════════════════════════════════════════════ */
/* ─── Detail Sections ────────────────────────────────────────────────────── */
/* ═══════════════════════════════════════════════════════════════════════════ */

.detail-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: var(--space-4);
}

.detail-item label,
.detail-item .detail-label {
    display: block;
    font-size: 0.63rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.6px;
    margin-bottom: 2px;
}

.detail-item .value,
.detail-item .detail-value {
    font-size: 0.88rem;
    font-weight: 500;
}

/* Portal / website links — constrain to card width */
.portal-link {
    font-size: 0.82rem;
    max-width: 100%;
    overflow: hidden;
}
.portal-link-text {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
    word-break: break-all;
    line-height: 1.3;
}

/* ═══════════════════════════════════════════════════════════════════════════ */
/* ─── Property Health Score ─────────────────────────────────────────────── */
/* ═══════════════════════════════════════════════════════════════════════════ */
.health-ring {
    width: 80px; height: 80px; border-radius: 50%;
    background: conic-gradient(var(--color) calc(var(--pct) * 1%), var(--border-color) 0);
    display: flex; align-items: center; justify-content: center;
    position: relative; flex-shrink: 0;
}
.health-ring::before {
    content: ''; width: 64px; height: 64px; border-radius: 50%;
    background: var(--bg-card); position: absolute;
}
.health-ring span {
    position: relative; z-index: 1; font-size: 1.1rem; font-weight: 700;
}

.health-ring-sm {
    width: 36px; height: 36px; border-radius: 50%;
    background: conic-gradient(var(--color) calc(var(--pct) * 1%), var(--border-color) 0);
    display: flex; align-items: center; justify-content: center;
    position: relative; flex-shrink: 0;
}
.health-ring-sm::before {
    content: ''; width: 28px; height: 28px; border-radius: 50%;
    background: var(--bg-card); position: absolute;
}
.health-ring-sm span {
    position: relative; z-index: 1; font-size: 0.6rem; font-weight: 700;
}

/* Mini ring in property header — compact clickable health indicator */
.health-mini-ring {
    width: 32px; height: 32px; border-radius: 50%;
    background: conic-gradient(var(--ring-color, var(--color-good)) calc(var(--ring-pct, 0) * 1%), var(--health-track, var(--border-color)) 0);
    display: inline-flex; align-items: center; justify-content: center;
    position: relative; flex-shrink: 0; border: none; cursor: pointer;
    padding: 0; margin: 0; transition: transform 0.15s;
    vertical-align: middle; outline: none; -webkit-appearance: none; appearance: none;
    background-color: transparent;
}
.health-mini-ring::before {
    content: ''; width: 24px; height: 24px; border-radius: 50%;
    background: var(--bg-card); position: absolute;
}
.health-mini-ring span {
    position: relative; z-index: 1; font-size: 0.5rem; font-weight: 700;
    color: var(--ring-color, var(--color-good)); line-height: 1;
}
.health-mini-ring:hover {
    transform: scale(1.15);
}

/* Floating health card popover */
.health-floater {
    position: absolute;
    top: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    width: 420px;
    max-width: 90vw;
    background: var(--bg-card, #1a1a2e);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 1rem;
    box-shadow: 0 8px 32px rgba(0,0,0,0.5);
    z-index: 1050;
}
.health-floater::before {
    content: '';
    position: absolute;
    top: -6px;
    left: 50%;
    transform: translateX(-50%) rotate(45deg);
    width: 12px;
    height: 12px;
    background: var(--bg-card, #1a1a2e);
    border-left: 1px solid var(--border-color);
    border-top: 1px solid var(--border-color);
}
@media (max-width: 575px) {
    .health-floater {
        position: fixed;
        top: 60px;
        bottom: auto;
        left: 8px;
        right: 8px;
        transform: none;
        width: 100%;
        max-width: 100%;
        border-radius: 16px 16px 0 0;
        max-height: 60vh;
        overflow-y: auto;
    }
    .health-floater::before { display: none; }
}

.health-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg, 12px);
    padding: 1rem;
}

.health-category-pill {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 500;
    background: rgba(255,255,255,0.04);
    border: 1px solid var(--border-color);
    cursor: default;
    transition: background 0.15s;
}
.health-category-pill:hover {
    background: rgba(255,255,255,0.08);
}
.health-category-pill.complete {
    border-color: rgba(var(--success-rgb), 0.3);
    color: var(--success);
}
.health-category-pill.partial {
    border-color: rgba(var(--warning-rgb), 0.3);
    color: var(--warning);
}
.health-category-pill.missing {
    border-color: rgba(var(--danger-rgb), 0.3);
    color: var(--danger);
}

.health-next-step {
    background: rgba(201, 168, 76, 0.06);
    border: 1px solid rgba(201, 168, 76, 0.15);
    border-radius: 8px;
    padding: 10px 14px;
    font-size: 0.85rem;
}

/* Health checklist drawer */
.health-checklist-category {
    border-bottom: 1px solid var(--border-color);
    padding: 12px 0;
}
.health-checklist-category:last-child { border-bottom: none; }

.health-checklist-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 0;
    font-size: 0.82rem;
}
.health-checklist-item .done { color: var(--success); }
.health-checklist-item .missing { color: var(--danger); }

.health-mini-bar {
    height: 4px;
    border-radius: 2px;
    background: var(--border-color);
    flex-grow: 1;
    overflow: hidden;
}
.health-mini-bar-fill {
    height: 100%;
    border-radius: 2px;
    transition: width 0.3s ease;
}

/* ═══════════════════════════════════════════════════════════════════════════ */
/* ─── Pagination ─────────────────────────────────────────────────────────── */
/* ═══════════════════════════════════════════════════════════════════════════ */

.pagination .page-link {
    background: var(--bg-card);
    border-color: var(--border-color);
    color: var(--text-primary);
    font-size: 0.8rem;
    border-radius: var(--radius-sm);
}

.pagination .page-link:hover {
    background: var(--accent-muted);
    border-color: rgba(212, 168, 67, 0.2);
}

.pagination .page-item.active .page-link {
    background: var(--accent);
    border-color: var(--accent);
    color: #000;
}

/* ═══════════════════════════════════════════════════════════════════════════ */
/* ─── Charts ─────────────────────────────────────────────────────────────── */
/* ═══════════════════════════════════════════════════════════════════════════ */

.chart-container {
    position: relative;
    height: 280px;
}

/* ═══════════════════════════════════════════════════════════════════════════ */
/* ─── Filter Bar ─────────────────────────────────────────────────────────── */
/* ═══════════════════════════════════════════════════════════════════════════ */

.filter-bar {
    display: flex;
    gap: var(--space-2);
    flex-wrap: wrap;
    margin-bottom: var(--space-5);
    align-items: end;
}

.filter-bar .form-select {
    width: auto;
    min-width: 140px;
    font-size: 0.75rem;
    padding: 6px 10px;
}

.filter-bar .form-label {
    font-size: 0.63rem;
    margin-bottom: 2px;
}

/* ═══════════════════════════════════════════════════════════════════════════ */
/* ─── Tabs ───────────────────────────────────────────────────────────────── */
/* ═══════════════════════════════════════════════════════════════════════════ */

.nav-tabs-custom {
    border-bottom: 1px solid var(--border-color);
    gap: 2px;
}

.nav-tabs-custom .nav-link {
    color: var(--text-muted);
    border: none;
    padding: var(--space-3) var(--space-4);
    font-size: 0.8rem;
    font-weight: 500;
    border-bottom: 2px solid transparent;
    background: none;
    transition: all var(--transition-fast);
}

.nav-tabs-custom .nav-link:hover {
    color: var(--text-primary);
    border-bottom-color: var(--border-color);
}

.nav-tabs-custom .nav-link.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
    background: none;
}

/* ═══════════════════════════════════════════════════════════════════════════ */
/* ─── Scrollbar ──────────────────────────────────────────────────────────── */
/* ═══════════════════════════════════════════════════════════════════════════ */

::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.08); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255, 255, 255, 0.14); }

* { scrollbar-width: thin; scrollbar-color: rgba(255, 255, 255, 0.08) transparent; }

/* ═══════════════════════════════════════════════════════════════════════════ */
/* ─── Animations ─────────────────────────────────────────────────────────── */
/* ═══════════════════════════════════════════════════════════════════════════ */

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

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

@keyframes scaleIn {
    from { opacity: 0; transform: scale(0.96); }
    to { opacity: 1; transform: scale(1); }
}

.fade-in { animation: fadeIn 0.3s ease; }
@keyframes slideIn { from { opacity: 0; transform: translateX(30px); } to { opacity: 1; transform: translateX(0); } }

/* ═══════════════════════════════════════════════════════════════════════════ */
/* ─── Dashboard Page ─────────────────────────────────────────────────────── */
/* ═══════════════════════════════════════════════════════════════════════════ */

.dashboard-page {
    animation: fadeIn 0.35s ease;
}
/* Consistent 12px spacing between all page sections */
.dashboard-page .mb-4,
.main-content .mb-4 {
    margin-bottom: 12px !important;
}
.dashboard-page .mb-3,
.main-content .mb-3 {
    margin-bottom: 12px !important;
}

/* ─── Dashboard Header ───────────────────────────────────────────────────── */

.dash-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-6);
    flex-wrap: wrap;
    gap: var(--space-3);
}

.dash-header-left {
    display: flex;
    align-items: baseline;
    gap: var(--space-4);
}

.dash-title {
    font-size: 1.35rem;
    font-weight: 700;
    letter-spacing: -0.03em;
    margin: 0;
    color: var(--text-primary);
}

.dash-subtitle {
    font-size: 0.78rem;
    color: var(--text-muted);
    font-weight: 400;
}

.dash-header-right {
    display: flex;
    gap: var(--space-2);
}

/* ─── Hero Metric ────────────────────────────────────────────────────────── */

.hero-metric {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: var(--space-8) var(--space-6);
    margin-bottom: var(--space-5);
    text-align: center;
    position: relative;
    overflow: hidden;
}

.hero-metric::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--accent), transparent);
    opacity: 0.4;
}

.hero-metric-inner {
    position: relative;
    z-index: 1;
}

.hero-label {
    font-size: 0.68rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: var(--text-muted);
    margin-bottom: var(--space-2);
}

.hero-value {
    font-size: 2.8rem;
    font-weight: 700;
    letter-spacing: -0.04em;
    line-height: 1.1;
    margin-bottom: var(--space-3);
}

.hero-sub {
    display: flex;
    justify-content: center;
    gap: var(--space-6);
    font-size: 0.78rem;
    color: var(--text-secondary);
}

.hero-sub-item {
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

.hero-sub-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    flex-shrink: 0;
}

.hero-sub-dot.income { background: var(--success); }
.hero-sub-dot.expense { background: var(--danger); }

/* ─── Dashboard Layout: Ticker Strip ─────────────────────────────────────── */

.dv-ticker-strip {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    overflow: hidden;
}
.ticker-cell {
    padding: 16px 14px;
    text-align: center;
    border-right: 1px solid var(--border-color);
}
.ticker-cell:last-child { border-right: none; }
.ticker-label {
    font-size: 0.62rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    margin-bottom: 5px;
}
.ticker-value {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.2;
}
.ticker-sub {
    font-size: 0.68rem;
    color: var(--text-secondary);
    margin-top: 3px;
}

@media (max-width: 991.98px) {
    .dv-ticker-strip { grid-template-columns: repeat(3, 1fr); }
    .ticker-cell:nth-child(3) { border-right: none; }
    .ticker-cell:nth-child(n+4) { border-top: 1px solid var(--border-color); }
}
@media (max-width: 575.98px) {
    .dv-ticker-strip { grid-template-columns: repeat(2, 1fr); }
    .ticker-cell:nth-child(2n) { border-right: none; }
    .ticker-cell:nth-child(n+3) { border-top: 1px solid var(--border-color); }
}

/* ─── Dashboard Layout: Dual Summary Panels ──────────────────────────────── */

.dv-dual-panels {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}
.dv-summary-panel {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 20px;
}
.dv-panel-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 16px;
}
.dv-panel-icon {
    width: 32px; height: 32px;
    border-radius: 8px;
    display: flex; align-items: center; justify-content: center;
    font-size: 0.9rem;
}
.dv-panel-title {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-secondary);
}
.dv-cashflow-hero {
    font-size: 1.8rem;
    font-weight: 700;
    margin-bottom: 14px;
}
.dv-cashflow-bar {
    height: 5px;
    border-radius: 3px;
    background: rgba(var(--color-bad-rgb), 0.25);
    margin-bottom: 14px;
    overflow: hidden;
}
.dv-cashflow-bar-fill {
    height: 100%;
    border-radius: 3px;
    background: var(--color-good);
}
.dv-cashflow-row {
    display: flex;
    justify-content: space-between;
    font-size: 0.82rem;
    margin-bottom: 4px;
}
.dv-snapshot-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
}
.dv-snap-value {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--text-primary);
}
.dv-snap-label {
    font-size: 0.68rem;
    color: var(--text-muted);
    margin-top: 1px;
}

@media (max-width: 767.98px) {
    .dv-dual-panels { grid-template-columns: 1fr; }
}

/* ─── Dashboard Layout: Triple Hero Cards ────────────────────────────────── */

.dv-triple-cards {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
}
.dv-hero-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 20px;
    position: relative;
    overflow: hidden;
}
.dv-hero-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 3px;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}
.dv-hc-cashflow::before { background: var(--color-good); }
.dv-hc-portfolio::before { background: var(--accent); }
.dv-hc-performance::before { background: var(--color-info); }

.dv-hc-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 14px;
}
.dv-hc-icon {
    width: 28px; height: 28px;
    border-radius: 7px;
    display: flex; align-items: center; justify-content: center;
    font-size: 0.8rem;
}
.dv-hc-cashflow .dv-hc-icon { background: rgba(var(--color-good-rgb), 0.12); color: var(--color-good); }
.dv-hc-portfolio .dv-hc-icon { background: rgba(212,168,67,0.12); color: var(--accent); }
.dv-hc-performance .dv-hc-icon { background: rgba(var(--color-info-rgb), 0.12); color: var(--color-info); }

.dv-hc-title {
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.4px;
}
.dv-hc-main {
    font-size: 1.55rem;
    font-weight: 700;
    margin-bottom: 14px;
    line-height: 1.1;
    color: var(--text-primary);
}
.dv-hc-unit {
    font-size: 0.72rem;
    font-weight: 400;
    color: var(--text-muted);
    margin-left: 3px;
}
.dv-hc-metrics {
    display: flex;
    flex-direction: column;
    gap: 7px;
}
.dv-hc-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.8rem;
}
.dv-hc-label {
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 6px;
}
.dv-hc-val {
    color: var(--text-primary);
    font-weight: 500;
}
.dv-hc-divider {
    height: 1px;
    background: var(--border-color);
    margin: 3px 0;
}

@media (max-width: 991.98px) {
    .dv-triple-cards { grid-template-columns: 1fr; }
}

/* ─── KPI Grid ───────────────────────────────────────────────────────────── */

.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: var(--space-3);
    margin-bottom: 1rem;  /* Match mb-3 used on property detail cards */
}

.kpi-grid.kpi-grid-5 {
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
}

.kpi-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: var(--space-5);
    transition: all var(--transition-fast);
    position: relative;
    height: 100%;  /* Equal height in row/grid layouts */
    overflow: hidden;
}

.kpi-card:hover {
    border-color: rgba(255, 255, 255, 0.08);
    background: var(--bg-elevated);
}

.kpi-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-3);
}

.kpi-icon {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
}

.kpi-icon-accent { background: var(--accent-muted); color: var(--accent); }
.kpi-icon-blue { background: rgba(var(--color-info-rgb), 0.10); color: var(--info); }
.kpi-icon-gold { background: rgba(212, 168, 67, 0.10); color: var(--accent); }
.kpi-icon-green { background: rgba(var(--success-rgb), 0.10); color: var(--success); }
.kpi-icon-purple { background: rgba(var(--color-info-rgb), 0.10); color: var(--color-info); }

.kpi-trend {
    font-size: 1rem;
    display: flex;
    align-items: center;
}

.kpi-trend.up { color: var(--success); }
.kpi-trend.down { color: var(--danger); }
.kpi-trend.neutral { color: var(--text-muted); }

.kpi-value {
    font-size: 1.4rem;
    font-weight: 700;
    line-height: 1.15;
    letter-spacing: -0.03em;
}

.kpi-label {
    font-size: 0.68rem;
    color: var(--text-muted);
    margin-top: var(--space-1);
    font-weight: 500;
}

/* ─── State Breakdown ────────────────────────────────────────────────────── */

.state-row {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-3) 0;
    border-bottom: 1px solid var(--border-subtle);
}

.state-row:last-of-type { border-bottom: none; }

.state-info {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    min-width: 80px;
}

.state-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--accent-muted);
    color: var(--accent);
    padding: 2px 8px;
    border-radius: var(--radius-sm);
    font-size: 0.68rem;
    font-weight: 600;
    letter-spacing: 0.3px;
    min-width: 28px;
}

.state-badge.small {
    font-size: 0.6rem;
    padding: 1px 6px;
}

.state-bar-wrap {
    flex: 1;
    height: 4px;
    background: var(--border-subtle);
    border-radius: 2px;
    overflow: hidden;
}

.state-bar {
    height: 100%;
    background: var(--accent);
    border-radius: 2px;
    min-width: 4px;
    transition: width 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ─── Forecast Icon ──────────────────────────────────────────────────────── */

.forecast-icon-wrap {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--accent-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: var(--space-3);
}

.forecast-icon-wrap i {
    font-size: 1.3rem;
    color: var(--accent);
    opacity: 0.8;
}

/* ─── Activity Feed ──────────────────────────────────────────────────────── */

.activity-feed {
    max-height: 400px;
    overflow-y: auto;
}

.activity-item {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-3) var(--space-5);
    border-bottom: 1px solid var(--border-subtle);
    transition: background var(--transition-fast);
}

.activity-item:hover { background: rgba(255, 255, 255, 0.015); }
.activity-item:last-child { border-bottom: none; }

.activity-icon {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    flex-shrink: 0;
}

.activity-icon.income {
    background: rgba(var(--success-rgb), 0.08);
    color: var(--success);
}

.activity-icon.expense {
    background: rgba(var(--danger-rgb), 0.08);
    color: var(--danger);
}

.activity-icon.other {
    background: rgba(107, 114, 128, 0.08);
    color: var(--text-muted);
}

.activity-details { flex: 1; min-width: 0; }

.activity-title {
    font-size: 0.8rem;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.activity-meta {
    font-size: 0.68rem;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.activity-amount {
    font-size: 0.83rem;
    font-weight: 600;
    white-space: nowrap;
    text-align: right;
    letter-spacing: -0.01em;
}

/* ─── Property Rows ──────────────────────────────────────────────────────── */

.property-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3);
    padding: var(--space-3) var(--space-5);
    border-bottom: 1px solid var(--border-subtle);
    text-decoration: none;
    color: var(--text-primary);
    transition: background var(--transition-fast);
}

.property-row:hover {
    background: var(--accent-subtle);
    color: var(--text-primary);
}
.property-row:hover .copy-addr-btn { opacity: 1 !important; }

.property-row:last-child { border-bottom: none; }

.property-row-info { flex: 1; min-width: 0; }

.property-row-name {
    font-size: 0.83rem;
    font-weight: 500;
    color: var(--color-info);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.property-row-meta {
    display: flex;
    align-items: center;
    gap: var(--space-1);
    font-size: 0.68rem;
    margin-top: 1px;
}

.property-row-right {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 4px;
    flex-shrink: 0;
}

.property-row-rent {
    font-size: 0.83rem;
    font-weight: 600;
    color: var(--success);
}

.property-row-rent span {
    font-weight: 400;
    font-size: 0.68rem;
}

/* ─── Equity Section ─────────────────────────────────────────────────────── */

.equity-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: var(--space-4);
    margin-bottom: var(--space-5);
}

.equity-stat-label {
    font-size: 0.68rem;
    color: var(--text-muted);
    font-weight: 500;
    margin-bottom: var(--space-1);
}

.equity-stat-value {
    font-size: 1.2rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.equity-highlights {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-3);
    margin-bottom: var(--space-4);
}

.equity-highlight {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-4);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-subtle);
    background: rgba(255, 255, 255, 0.01);
}

.equity-highlight-icon {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    flex-shrink: 0;
}

.equity-highlight-icon.green {
    background: rgba(var(--success-rgb), 0.08);
    color: var(--success);
}

.equity-highlight-icon.gold {
    background: rgba(212, 168, 67, 0.08);
    color: var(--accent);
}

.equity-highlight-label {
    font-size: 0.72rem;
    color: var(--text-muted);
    font-weight: 500;
}

.equity-highlight-value {
    font-size: 0.95rem;
    font-weight: 600;
}

.equity-insight {
    padding-top: var(--space-4);
    border-top: 1px solid var(--border-subtle);
    font-size: 0.78rem;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

.equity-insight i {
    color: var(--accent);
    opacity: 0.7;
}

.equity-insight strong {
    color: var(--text-primary);
}

/* ─── Renewals ───────────────────────────────────────────────────────────── */

.renewal-list {
    max-height: 320px;
    overflow-y: auto;
}

.renewal-item {
    display: flex;
    align-items: center;
    gap: var(--space-4);
    padding: var(--space-4) var(--space-5);
    border-bottom: 1px solid var(--border-subtle);
}

.renewal-item:last-child { border-bottom: none; }

.renewal-urgency {
    width: 3px;
    height: 32px;
    border-radius: 2px;
    flex-shrink: 0;
    margin-right: 10px;
}

.renewal-urgency.critical { background: var(--danger); }
.renewal-urgency.warning { background: var(--warning); }
.renewal-urgency.normal { background: var(--info); }

.renewal-info { flex: 1; min-width: 0; overflow-wrap: break-word; word-break: normal; }

/* Steadily insurance quote branding — per Steadily Brand Guidelines v2.1 */
.renewal-item-insurance { align-items: flex-start; }
.steadly-logo-badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 7px;
    border-radius: 4px;
    background: rgba(108,29,114,0.12);
    color: #6C1D72;
    font-family: 'Public Sans', sans-serif;
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    border: 1px solid rgba(108,29,114,0.25);
    white-space: nowrap;
    flex-shrink: 0;
}
.steadly-logo-sm { padding: 1px 5px; font-size: 0.62rem; }
.steadly-cta-btn {
    padding: 3px 10px;
    background: #6C1D72;
    color: #fff;
    border: 1px solid rgba(108,29,114,0.5);
    border-radius: 5px;
    font-family: 'Public Sans', sans-serif;
    font-size: 0.75rem;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    text-decoration: none;
    transition: background 0.15s, opacity 0.15s;
    white-space: nowrap;
}
.steadly-cta-btn:hover { background: #310148; color: #fff; opacity: 0.95; }

/* Single-line renewal row — sleek compact layout */
.renewal-row {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px 10px;
    padding: 10px 14px;
    border-bottom: 1px solid var(--border-color);
    text-decoration: none;
    color: var(--text-primary);
    transition: background 0.15s;
}
.renewal-row:last-child { border-bottom: none; }
.renewal-row:hover { background: rgba(255,255,255,0.02); }
.renewal-row-name {
    font-size: 0.83rem;
    font-weight: 600;
    color: var(--color-info);
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.renewal-row:hover .renewal-row-name { color: var(--accent); }
/* Type badge stays next to property name */
.renewal-row .badge { flex-shrink: 0; }
/* Push date/days/fee to the right */
.renewal-row-date {
    font-size: 0.75rem;
    flex-shrink: 0;
    margin-left: auto;
}
.renewal-row-fee {
    font-size: 0.8rem;
    font-weight: 600;
    flex-shrink: 0;
    min-width: 55px;
    text-align: right;
}
/* Mobile: compact renewal rows */
@media (max-width: 767.98px) {
    .renewal-row {
        display: grid;
        grid-template-columns: 4px 1fr auto;
        grid-template-rows: auto auto;
        gap: 2px 8px;
        padding: 8px 10px;
    }
    .renewal-row .renewal-urgency { grid-row: 1 / 3; }
    .renewal-row-name {
        grid-column: 2;
        font-size: 0.8rem;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    .renewal-row .badge:first-of-type { grid-column: 3; grid-row: 1; justify-self: end; font-size: 0.55rem !important; }
    .renewal-row-date { grid-column: 2; font-size: 0.7rem; margin-left: 0; }
    .renewal-row .badge:last-of-type { font-size: 0.55rem !important; }
    .renewal-row-fee { grid-column: 3; grid-row: 2; justify-self: end; font-size: 0.75rem; min-width: auto; }
}
/* Mobile: compact property rows */
@media (max-width: 767.98px) {
    .property-row-right {
        flex-direction: row;
        align-items: center;
        gap: 4px;
    }
    .property-row-right .d-flex.gap-1 { gap: 3px !important; }
    .property-row-right .badge { font-size: 0.5rem !important; padding: 1px 4px; }
    .property-row-rent { font-size: 0.75rem; }
    .property-row-name { font-size: 0.78rem; }
    .property-row-meta { font-size: 0.65rem; }
}

/* Legacy renewal-property for other pages still using old layout */
.renewal-property {
    font-size: 0.83rem;
    font-weight: 600;
    color: var(--color-info);
    text-decoration: none;
}
.renewal-property:hover { color: var(--accent); }

/* Ensure property links in dashboard cards inherit palette color */
.property-row-link { color: inherit; text-decoration: none; }
.property-row-link:hover .property-row-name { color: var(--accent); }

.renewal-meta {
    display: flex;
    align-items: center;
    margin-top: 2px;
}

.renewal-date {
    text-align: right;
    flex-shrink: 0;
}

.renewal-fee {
    min-width: 70px;
    text-align: right;
    font-size: 0.83rem;
    flex-shrink: 0;
}

/* ═══════════════════════════════════════════════════════════════════════════ */
/* ─── Knox AI ─────────────────────────────────────────────────────────────── */
/* ═══════════════════════════════════════════════════════════════════════════ */

/* ─── Knox Command Bar Trigger ────────────────────────────────────────────── */
.knox-cmd-trigger {
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 16px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s;
}
.knox-cmd-trigger:hover {
    background: rgba(255, 255, 255, 0.06);
    border-color: rgba(201, 168, 76, 0.3);
}
.knox-cmd-icon { color: var(--accent); font-size: 1rem; }
.knox-cmd-placeholder { color: var(--text-muted); font-size: 0.82rem; flex: 1; }
.knox-cmd-shortcut {
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid var(--border-color);
    border-radius: 5px;
    padding: 1px 7px;
    font-size: 0.68rem;
    color: var(--text-muted);
    font-family: inherit;
}

[data-theme="light"] .knox-cmd-trigger {
    background: rgba(0, 0, 0, 0.03);
    border-color: var(--border-color);
}
[data-theme="light"] .knox-cmd-trigger:hover {
    background: rgba(0, 0, 0, 0.05);
}

/* ─── Knox Command Palette (⌘K overlay) ───────────────────────────────────── */
.knox-palette-overlay {
    position: fixed;
    inset: 0;
    z-index: 10000;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding-top: 15vh;
    backdrop-filter: blur(4px);
    animation: knoxFadeIn 0.15s ease;
}
@keyframes knoxFadeIn { from { opacity: 0; } to { opacity: 1; } }
.knox-palette {
    width: 580px;
    max-width: calc(100vw - 32px);
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    box-shadow: 0 24px 64px rgba(0, 0, 0, 0.5);
    overflow: hidden;
    animation: knoxSlideDown 0.15s ease;
}
@keyframes knoxSlideDown { from { opacity: 0; transform: translateY(-12px); } to { opacity: 1; transform: translateY(0); } }
.knox-palette-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 18px;
    border-bottom: 1px solid var(--border-color);
    background: rgba(201, 168, 76, 0.03);
}
.knox-palette-icon { color: var(--accent); font-size: 1.1rem; }
.knox-palette-header input {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    color: var(--text-primary);
    font-size: 0.92rem;
    font-family: inherit;
}
.knox-palette-header input::placeholder { color: var(--text-muted); }
.knox-palette-esc {
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid var(--border-color);
    border-radius: 5px;
    padding: 1px 7px;
    font-size: 0.65rem;
    color: var(--text-muted);
    font-family: inherit;
}
.knox-palette-body {
    max-height: 420px;
    overflow-y: auto;
    padding: 8px 0;
}
.knox-palette-section { padding: 6px 18px 4px; }
.knox-palette-section-title {
    font-size: 0.68rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 6px;
}
.knox-palette-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 18px;
    cursor: pointer;
    transition: background 0.12s;
    font-size: 0.82rem;
    color: var(--text-primary);
}
.knox-palette-item:hover { background: rgba(201, 168, 76, 0.08); }
.knox-palette-item i { color: var(--text-muted); font-size: 0.9rem; width: 20px; text-align: center; }
.knox-palette-item:hover i { color: var(--accent); }
.knox-palette-hint {
    padding: 12px 18px;
    font-size: 0.78rem;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 8px;
}
.knox-palette-divider { height: 1px; background: var(--border-color); margin: 6px 18px; }

/* Palette navigation items (generated by JS) */
.knox-nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 0;
    cursor: pointer;
    transition: color 0.12s;
    font-size: 0.82rem;
    color: var(--text-primary);
    text-decoration: none;
}
.knox-nav-item:hover { color: var(--accent); }
.knox-nav-item i { color: var(--text-muted); font-size: 0.9rem; width: 20px; text-align: center; }
.knox-nav-item:hover i { color: var(--accent); }

/* Palette chat messages area */
.knox-palette-msgs {
    padding: 16px 18px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-height: 350px;
    overflow-y: auto;
}
.knox-palette-actions {
    padding: 10px 18px;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}
.knox-palette-chat-footer {
    padding: 10px 18px;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: center;
    flex-shrink: 0;
}

/* ─── Knox Side Panel ─────────────────────────────────────────────────────── */
.knox-panel {
    position: fixed;
    top: 0;
    right: 0;
    width: 360px;
    height: 100vh;
    height: 100dvh;
    background: var(--bg-card);
    border-left: 1px solid var(--border-color);
    box-shadow: -8px 0 32px rgba(0, 0, 0, 0.3);
    z-index: 1050;
    display: none;
    flex-direction: column;
    transform: translateX(100%);
    transition: transform 0.25s ease;
}
.knox-panel.open {
    display: flex;
    transform: translateX(0);
    animation: knoxPanelSlideIn 0.25s ease;
}
@keyframes knoxPanelSlideIn { from { transform: translateX(100%); } to { transform: translateX(0); } }
.knox-panel-header {
    padding: 14px 18px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: rgba(201, 168, 76, 0.03);
    flex-shrink: 0;
}
.knox-panel-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.knox-panel-pending {
    padding: 12px 16px;
    border-top: 1px solid var(--border-color);
    flex-shrink: 0;
}
.knox-panel-input {
    padding: 12px 16px;
    padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px));
    border-top: 1px solid var(--border-color);
    display: flex;
    gap: 8px;
    background: rgba(255, 255, 255, 0.02);
    flex-shrink: 0;
    flex-shrink: 0;
}
.knox-panel-input input {
    flex: 1;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 8px 14px;
    color: var(--text-primary);
    font-size: 16px; /* Must be >= 16px to prevent iOS auto-zoom on focus */
    outline: none;
    font-family: inherit;
}
.knox-panel-input input:focus {
    border-color: rgba(201, 168, 76, 0.4);
    background: rgba(255, 255, 255, 0.06);
}
.knox-input-btn {
    width: 38px;
    height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    background: transparent;
    color: var(--text-secondary);
    font-size: 1rem;
    cursor: pointer;
    flex-shrink: 0;
    transition: all 0.15s ease;
}
.knox-input-btn:hover {
    border-color: var(--accent);
    color: var(--accent);
    background: rgba(201, 168, 76, 0.06);
}
.knox-input-btn--send {
    background: var(--accent);
    border-color: var(--accent);
    color: #000;
}
.knox-input-btn--send:hover {
    background: var(--accent-hover);
    border-color: var(--accent-hover);
    color: #000;
}
[data-theme="light"] .knox-input-btn--attach {
    border-color: var(--border-color);
    color: var(--text-secondary);
}

/* ─── Knox Message Bubbles (shared between palette + panel) ───────────────── */
.knox-msg { display: flex; flex-direction: column; max-width: 85%; margin-bottom: 4px; position: relative; }
.knox-msg-del {
    position: absolute; top: 2px; right: 2px; z-index: 2;
    background: none; border: none; color: var(--text-muted); cursor: pointer;
    font-size: 0.7rem; padding: 2px 4px; border-radius: 4px;
    display: none; opacity: 0; transition: opacity 0.15s;
}
.knox-msg:hover .knox-msg-del { display: block; opacity: 0.6; }
.knox-msg-del:hover { opacity: 1 !important; color: var(--danger, #dc4a4a); background: rgba(255,255,255,0.05); }
.knox-msg.user .knox-msg-del { right: auto; left: 2px; }
.knox-msg.user { align-self: flex-end; }
.knox-msg.assistant { align-self: flex-start; }
.knox-bubble {
    padding: 10px 14px;
    border-radius: 12px;
    font-size: 0.8rem;
    line-height: 1.55;
    word-wrap: break-word;
    overflow-wrap: break-word;
    max-width: 100%;
    overflow-x: hidden;
}
/* Citation chips emitted by Knox (property, owner, tenant, unit, wo). */
.knox-chip {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    padding: 1px 6px;
    margin: 0 2px;
    border-radius: 6px;
    background: rgba(201, 168, 76, 0.14);
    border: 1px solid rgba(201, 168, 76, 0.35);
    color: var(--accent, #c9a84c);
    font-size: 0.68rem;
    font-weight: 500;
    vertical-align: baseline;
    white-space: nowrap;
    cursor: default;
}
.knox-chip i { font-size: 0.7rem; line-height: 1; }
.knox-chip .knox-chip-id { opacity: 0.75; }
.knox-ts {
    font-size: 0.6rem;
    color: var(--text-muted, #666);
    margin-top: 2px;
    padding: 0 4px;
    opacity: 0.6;
}
.knox-msg.user .knox-ts { text-align: right; }
.knox-msg.assistant .knox-ts { text-align: left; }
.knox-msg.user .knox-bubble {
    background: var(--accent);
    color: #000;
    border-bottom-right-radius: 4px;
}
.knox-msg.assistant .knox-bubble {
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid var(--border-color);
    border-bottom-left-radius: 4px;
}
.knox-msg.assistant .knox-bubble em { color: var(--accent); }
.knox-msg.assistant .knox-bubble code {
    background: rgba(201, 168, 76, 0.1);
    padding: 1px 5px;
    border-radius: 3px;
    font-size: 0.76rem;
}

/* ─── Knox Markdown Rendering ──────────────────────────────────────────────── */
.knox-bubble p { margin: 0 0 0.5em; }
.knox-bubble p:last-child { margin-bottom: 0; }
.knox-bubble h1, .knox-bubble h2, .knox-bubble h3, .knox-bubble h4 {
    margin: 0.6em 0 0.3em;
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--accent, #c9a84c);
}
.knox-bubble h1 { font-size: 0.95rem; }
.knox-bubble h2 { font-size: 0.9rem; }
.knox-bubble ul, .knox-bubble ol {
    margin: 0.3em 0 0.5em;
    padding-left: 1.4em;
}
.knox-bubble li { margin-bottom: 0.2em; }
.knox-bubble pre {
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 8px 10px;
    overflow-x: auto;
    margin: 0.4em 0;
    font-size: 0.74rem;
}
.knox-bubble pre code {
    background: none;
    padding: 0;
    font-size: inherit;
}
.knox-bubble blockquote {
    border-left: 3px solid var(--accent, #c9a84c);
    margin: 0.4em 0;
    padding: 4px 10px;
    color: var(--text-muted);
    font-style: italic;
}
.knox-bubble table {
    width: 100%;
    border-collapse: collapse;
    margin: 0.5em 0;
    font-size: 0.76rem;
    display: block;
    overflow-x: auto;
    max-width: 100%;
    -webkit-overflow-scrolling: touch;
}
.knox-bubble table th {
    background: rgba(201, 168, 76, 0.15);
    color: var(--accent, #c9a84c);
    font-weight: 600;
    text-align: left;
    padding: 6px 8px;
    border: 1px solid rgba(201, 168, 76, 0.25);
}
.knox-bubble table td {
    padding: 5px 8px;
    border: 1px solid var(--border-color);
}
.knox-bubble table tr:nth-child(even) td {
    background: rgba(255, 255, 255, 0.02);
}
.knox-bubble table tr:hover td {
    background: rgba(201, 168, 76, 0.06);
}
.knox-bubble hr {
    border: none;
    border-top: 1px solid var(--border-color);
    margin: 0.5em 0;
}
.knox-bubble a {
    color: var(--accent, #c9a84c);
    text-decoration: underline;
}

/* Light theme overrides for Knox markdown */
[data-theme="light"] .knox-bubble table th {
    background: rgba(201, 168, 76, 0.1);
    border-color: rgba(201, 168, 76, 0.2);
}
[data-theme="light"] .knox-bubble table td {
    border-color: #e0e0e0;
}
[data-theme="light"] .knox-bubble table tr:nth-child(even) td {
    background: rgba(0, 0, 0, 0.02);
}
[data-theme="light"] .knox-bubble pre {
    background: rgba(0, 0, 0, 0.04);
    border-color: #e0e0e0;
}

/* ─── Knox Document Analysis Card ──────────────────────────────────────────── */
.knox-success-card {
    background: rgba(40, 167, 69, 0.06);
    border: 1px solid rgba(40, 167, 69, 0.2);
    border-radius: 8px;
    padding: 10px 14px;
    font-size: 0.85rem;
    line-height: 1.8;
}
.knox-doc-card {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 12px 14px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.knox-doc-card--error {
    border-color: rgba(255, 180, 50, 0.25);
    background: rgba(255, 180, 50, 0.04);
}
.knox-doc-card-header {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 6px;
    line-height: 1.3;
}
.knox-doc-card-header i { font-size: 0.9rem; flex-shrink: 0; }
.knox-doc-card-type {
    display: inline-block;
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--accent);
    background: rgba(201, 168, 76, 0.1);
    padding: 1px 8px;
    border-radius: 4px;
    width: fit-content;
}
.knox-doc-card-summary {
    font-size: 0.76rem;
    color: var(--text-secondary);
    line-height: 1.4;
}
.knox-doc-card-row {
    display: flex;
    align-items: flex-start;
    gap: 6px;
    font-size: 0.78rem;
    color: var(--text-secondary);
}
.knox-doc-card-row i { flex-shrink: 0; margin-top: 2px; }
.knox-doc-card-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
}
.knox-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 0.68rem;
    font-weight: 500;
    padding: 2px 8px;
    border-radius: 6px;
    white-space: nowrap;
}
.knox-badge i { font-size: 0.65rem; }
.knox-badge--success { background: rgba(var(--success-rgb), 0.12); color: var(--color-good); }
.knox-badge--info { background: rgba(var(--color-info-rgb), 0.12); color: var(--color-info); }
.knox-badge--warn { background: rgba(var(--warning-rgb), 0.12); color: var(--color-warn); }
.knox-badge--prop { background: rgba(201, 168, 76, 0.1); color: var(--accent); }
.knox-doc-card-status {
    font-size: 0.74rem;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 5px;
}
.knox-doc-card-status i { font-size: 0.8rem; }
.knox-doc-card-note {
    font-size: 0.72rem;
    color: var(--text-muted);
    display: flex;
    align-items: flex-start;
    gap: 5px;
    line-height: 1.35;
}
.knox-doc-card-note i { flex-shrink: 0; margin-top: 1px; font-size: 0.72rem; }
.knox-doc-card-actions {
    display: flex;
    gap: 6px;
    padding-top: 4px;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
}
.knox-doc-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 0.7rem;
    font-weight: 500;
    padding: 4px 10px;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.06);
    color: var(--text-secondary);
    text-decoration: none;
    transition: all 0.15s;
    cursor: pointer;
    border: none;
}
.knox-doc-btn:hover { background: rgba(255, 255, 255, 0.1); color: var(--text-primary); }
.knox-doc-btn--accent { background: rgba(201, 168, 76, 0.1); color: var(--accent); }
.knox-doc-btn--accent:hover { background: rgba(201, 168, 76, 0.2); color: var(--accent); }
.knox-doc-btn--apply { background: rgba(var(--success-rgb), 0.15); color: var(--color-good); font-weight: 600; }
.knox-doc-btn--apply:hover { background: rgba(var(--success-rgb), 0.25); color: var(--color-good); }
.knox-doc-btn--apply:disabled { opacity: 0.6; cursor: wait; }
.knox-doc-btn i { font-size: 0.7rem; }

/* Knox changes preview (review before apply) */
.knox-doc-changes-preview {
    display: flex;
    flex-direction: column;
    gap: 1px;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 6px;
    overflow: hidden;
}
.knox-change-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 4px 10px;
    font-size: 0.7rem;
    background: rgba(255, 255, 255, 0.015);
}
.knox-change-row:nth-child(even) { background: rgba(255, 255, 255, 0.03); }
.knox-change-label { color: var(--text-secondary); flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.knox-change-val { color: var(--text-primary); font-weight: 500; text-align: right; flex-shrink: 0; margin-left: 8px; max-width: 55%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.knox-change-val--txn { color: var(--color-info); }
.knox-change-more { color: var(--text-muted); font-style: italic; justify-content: center; }
.knox-doc-card-status--pending { color: var(--accent); }
.knox-doc-card-status--pending i { color: var(--accent); }

[data-theme="light"] .knox-doc-card { background: rgba(0, 0, 0, 0.02); }
[data-theme="light"] .knox-doc-card--error { background: rgba(255, 180, 50, 0.05); }
[data-theme="light"] .knox-doc-card-actions { border-top-color: rgba(0, 0, 0, 0.06); }
[data-theme="light"] .knox-doc-btn { background: rgba(0, 0, 0, 0.04); color: var(--text-secondary); }
[data-theme="light"] .knox-doc-btn:hover { background: rgba(0, 0, 0, 0.08); }
[data-theme="light"] .knox-doc-btn--apply { background: rgba(var(--success-rgb), 0.08); color: var(--success); }
[data-theme="light"] .knox-doc-btn--apply:hover { background: rgba(var(--success-rgb), 0.15); }
[data-theme="light"] .knox-doc-changes-preview { background: rgba(0, 0, 0, 0.01); border-color: rgba(0, 0, 0, 0.06); }
[data-theme="light"] .knox-change-row { background: rgba(0, 0, 0, 0.01); }
[data-theme="light"] .knox-change-row:nth-child(even) { background: rgba(0, 0, 0, 0.025); }
[data-theme="light"] .knox-badge--success { background: rgba(var(--success-rgb), 0.08); color: var(--success); }
[data-theme="light"] .knox-badge--info { background: rgba(var(--color-info-rgb), 0.08); color: var(--info); }
[data-theme="light"] .knox-badge--warn { background: rgba(var(--warning-rgb), 0.08); color: var(--warning); }

/* ─── Knox Pending Card (transaction confirm) ─────────────────────────────── */
.knox-pending-card {
    background: rgba(201, 168, 76, 0.06);
    border: 1px solid rgba(201, 168, 76, 0.2);
    border-radius: 10px;
    padding: 12px 14px;
}
.knox-pending-title {
    font-size: 0.74rem;
    font-weight: 600;
    color: var(--accent);
    margin-bottom: 6px;
}
.knox-pending-details { font-size: 0.74rem; color: var(--text-secondary); }

/* ─── Knox Typing Indicator ───────────────────────────────────────────────── */
.knox-typing { display: flex; gap: 4px; padding: 10px 14px; align-self: flex-start; }
.knox-typing span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--text-muted);
    animation: knoxBounce 1.2s infinite;
}
.knox-typing span:nth-child(2) { animation-delay: 0.2s; }
.knox-typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes knoxBounce { 0%, 80%, 100% { opacity: 0.3; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-5px); } }

/* ─── Knox Header Button ──────────────────────────────────────────────────── */
.knox-header-btn {
    position: relative;
    color: var(--accent);
    font-size: 1.1rem;
    background: none;
    border: none;
    cursor: pointer;
    padding: 6px;
    border-radius: 8px;
    transition: background 0.15s;
    line-height: 1;
}
.knox-header-btn:hover { background: rgba(201, 168, 76, 0.1); }
.knox-nudge-dot {
    position: absolute;
    top: -2px;
    right: -4px;
    min-width: 16px;
    height: 16px;
    background: var(--accent);
    border-radius: 8px;
    border: 2px solid var(--bg-card);
    color: var(--bg-dark);
    font-size: 0.55rem;
    font-weight: 700;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 0 3px;
    animation: knoxNudgePulse 2s ease-in-out infinite;
}
@keyframes knoxNudgePulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.6; } }
.knox-header-dot {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 8px;
    height: 8px;
    background: var(--accent);
    border-radius: 50%;
    border: 2px solid var(--bg-card);
}
.topbar-user-avatar {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: rgba(201, 168, 76, 0.15);
    color: var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 600;
}
.topbar-user-btn {
    padding: 2px !important;
    background: none;
    border: none;
    cursor: pointer;
    border-radius: 50%;
    transition: box-shadow 0.15s;
}
.topbar-user-btn:hover { box-shadow: 0 0 0 2px rgba(201, 168, 76, 0.3); }

/* ─── Topbar User Dropdown ─────────────────────────────────────────────── */
.topbar-user-dropdown { min-width: 180px; }
.topbar-user-dropdown .dropdown-item {
    font-size: 0.78rem;
    padding: 6px 14px;
}
.topbar-user-dropdown .dropdown-item i {
    font-size: 0.82rem;
    width: 18px;
    text-align: center;
}
.topbar-user-dropdown .dropdown-header {
    padding: 8px 14px;
}
.topbar-user-dropdown .dropdown-divider {
    margin: 4px 0;
}

/* ─── Knox Panel Nudges (hidden — nudges now render as chat messages) ───── */
.knox-panel-nudges {
    display: none !important;
}
/* Nudge bubble styling (inline within chat) */
.knox-nudge-bubble {
    position: relative;
    border: 1px dashed rgba(201, 168, 76, 0.3) !important;
    background: rgba(201, 168, 76, 0.04) !important;
}
.knox-nudge-dismiss-inline {
    position: absolute;
    top: 4px;
    right: 6px;
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 0.75rem;
    cursor: pointer;
    padding: 2px 4px;
    opacity: 0.4;
    transition: opacity 0.15s;
    line-height: 1;
}
.knox-nudge-dismiss-inline:hover {
    opacity: 1;
}
[data-theme="light"] .knox-nudge-bubble {
    border-color: rgba(201, 168, 76, 0.25) !important;
    background: rgba(201, 168, 76, 0.05) !important;
}

/* ─── Knox Panel Backdrop ─────────────────────────────────────────────────── */
.knox-panel-backdrop {
    position: fixed;
    inset: 0;
    z-index: 1049;
    background: rgba(0, 0, 0, 0.2);
}

/* ─── Knox Hint Boxes (contextual nudges on pages) ────────────────────────── */
.knox-hint {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 20px;
    border: 1.5px dashed rgba(201, 168, 76, 0.35);
    border-radius: var(--radius-md);
    background: rgba(201, 168, 76, 0.04);
    cursor: pointer;
    transition: all 0.2s ease;
    margin-bottom: var(--space-4);
}
.knox-hint:hover {
    border-color: rgba(201, 168, 76, 0.55);
    background: rgba(201, 168, 76, 0.08);
}
.knox-hint-icon {
    font-size: 1.2rem;
    color: var(--accent);
    flex-shrink: 0;
}
.knox-hint-text {
    flex: 1;
    font-size: 0.82rem;
    color: var(--text-secondary);
    line-height: 1.4;
}
.knox-hint-text strong {
    color: var(--accent);
}
.knox-hint-arrow {
    font-size: 1rem;
    color: var(--text-muted);
    flex-shrink: 0;
    transition: transform 0.2s ease;
}
.knox-hint:hover .knox-hint-arrow {
    transform: translateX(3px);
    color: var(--accent);
}
.knox-hint-dismiss {
    position: absolute;
    top: 6px;
    right: 8px;
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 0.7rem;
    cursor: pointer;
    padding: 2px 4px;
    opacity: 0;
    transition: opacity 0.15s;
}
.knox-hint:hover .knox-hint-dismiss { opacity: 0.6; }
.knox-hint-dismiss:hover { opacity: 1 !important; }
[data-theme="light"] .knox-hint {
    background: rgba(201, 168, 76, 0.05);
    border-color: rgba(201, 168, 76, 0.25);
}
[data-theme="light"] .knox-hint:hover {
    background: rgba(201, 168, 76, 0.1);
    border-color: rgba(201, 168, 76, 0.45);
}

/* ─── Knox Nudge Cards (contextual reminders) ─────────────────────────────── */
.knox-nudge-card {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 14px 18px;
    border: 1.5px dashed rgba(201, 168, 76, 0.35);
    border-radius: var(--radius-md);
    background: rgba(201, 168, 76, 0.04);
    margin-bottom: var(--space-3);
    animation: fadeInUp 0.3s ease;
}
.knox-nudge-card .knox-nudge-icon {
    font-size: 1.1rem;
    color: var(--accent);
    margin-top: 2px;
    flex-shrink: 0;
}
.knox-nudge-card .knox-nudge-body {
    flex: 1;
    min-width: 0;
}
.knox-nudge-card .knox-nudge-text {
    font-size: 0.82rem;
    color: var(--text-secondary);
    line-height: 1.45;
    margin-bottom: 8px;
}
.knox-nudge-card .knox-nudge-text strong {
    color: var(--text-primary);
}
.knox-nudge-card .knox-nudge-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}
.knox-nudge-card .knox-nudge-actions .btn {
    font-size: 0.72rem;
    padding: 4px 12px;
    border-radius: 6px;
}
@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}
[data-theme="light"] .knox-nudge-card {
    background: rgba(201, 168, 76, 0.05);
    border-color: rgba(201, 168, 76, 0.25);
}

/* ═══════════════════════════════════════════════════════════════════════════ */
/* ─── Quick Actions (legacy support) ─────────────────────────────────────── */
/* ═══════════════════════════════════════════════════════════════════════════ */

.quick-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-5);
    flex-wrap: wrap;
    gap: var(--space-3);
}

.quick-actions-left {
    display: flex;
    align-items: baseline;
    gap: var(--space-4);
}

.quick-actions-right {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: var(--space-2);
}

.page-title {
    font-size: 1.35rem;
    font-weight: 600;
    letter-spacing: -0.02em;
    margin: 0;
}

/* ═══════════════════════════════════════════════════════════════════════════ */
/* ─── Property List Table ────────────────────────────────────────────────── */
/* ═══════════════════════════════════════════════════════════════════════════ */

.property-list-row {
    cursor: pointer;
}

.property-list-row:hover {
    background: var(--accent-subtle) !important;
}

.sortable {
    cursor: pointer;
    user-select: none;
}

.sortable:hover {
    color: var(--accent) !important;
}

/* ═══════════════════════════════════════════════════════════════════════════ */
/* ─── Utility Classes ────────────────────────────────────────────────────── */
/* ═══════════════════════════════════════════════════════════════════════════ */

.text-accent { color: var(--accent) !important; }
.bg-accent-subtle { background: var(--accent-subtle) !important; }
.border-accent { border-color: rgba(212, 168, 67, 0.3) !important; }
.opacity-60 { opacity: 0.6; }
.opacity-80 { opacity: 0.8; }
.fw-450 { font-weight: 450; }
.fs-xs { font-size: 0.68rem; }
.fs-sm { font-size: 0.8rem; }
.letter-tight { letter-spacing: -0.02em; }
.letter-wide { letter-spacing: 0.5px; }

/* ═══════════════════════════════════════════════════════════════════════════ */
/* ─── Mobile Bottom Navigation ───────────────────────────────────────────── */
/* ═══════════════════════════════════════════════════════════════════════════ */

.mobile-bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 64px;
    background: var(--bg-sidebar);
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: space-around;
    align-items: center;
    z-index: 1030;
    padding-bottom: env(safe-area-inset-bottom, 0);
    /* iOS: force fixed positioning to work even with transformed ancestors */
    -webkit-transform: translateZ(0);
    transform: translateZ(0);
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
}

.mobile-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    flex: 1;
    min-height: 44px;
    min-width: 44px;
    padding: 6px 4px;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.58rem;
    font-weight: 500;
    background: none;
    border: none;
    cursor: pointer;
    transition: color var(--transition-fast);
    -webkit-tap-highlight-color: transparent;
    position: relative;
}

.mobile-nav-item i {
    font-size: 1.2rem;
    line-height: 1;
}

.mobile-nav-item span {
    line-height: 1;
    letter-spacing: 0.02em;
}

.mobile-nav-item.active {
    color: var(--accent);
}

.mobile-nav-item:hover,
.mobile-nav-item:active {
    color: var(--text-primary);
}

.mobile-nav-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    height: 18px;
    padding: 0 4px;
    background: var(--accent);
    color: var(--bg-primary);
    border-radius: 9px;
    font-size: 0.65rem;
    font-weight: 600;
    line-height: 1;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.mobile-nav-label {
    font-size: 0.65rem;
    line-height: 1;
}

@media (min-width: 768px) {
    .mobile-bottom-nav {
        display: none !important;
    }
    .txn-cards-mobile { display: none !important; }
    .txn-filter-mobile { display: none !important; }
}

/* ═══════════════════════════════════════════════════════════════════════════ */
/* ─── Page Loading Bar ───────────────────────────────────────────────────── */
/* ═══════════════════════════════════════════════════════════════════════════ */

.page-loading-bar {
    position: fixed;
    top: 0;
    left: 0;
    width: 0;
    height: 2px;
    background: linear-gradient(90deg, var(--accent), var(--accent-hover), var(--accent));
    z-index: 9999;
    transition: width 0.4s ease, opacity 0.3s ease;
    opacity: 0;
    pointer-events: none;
    box-shadow: 0 0 6px rgba(212, 168, 67, 0.3);
}

.page-loading-bar.active {
    opacity: 1;
}

.page-loading-bar.done {
    width: 100% !important;
    opacity: 0;
    transition: width 0.15s ease, opacity 0.4s ease 0.2s;
}

/* ═══════════════════════════════════════════════════════════════════════════ */
/* ─── Skeleton Loading Screens ───────────────────────────────────────────── */
/* ═══════════════════════════════════════════════════════════════════════════ */

@keyframes shimmer {
    0% { background-position: -400px 0; }
    100% { background-position: 400px 0; }
}

.skeleton {
    background: linear-gradient(90deg, var(--bg-card) 25%, var(--bg-elevated) 50%, var(--bg-card) 75%);
    background-size: 800px 100%;
    animation: shimmer 1.8s ease-in-out infinite;
    border-radius: var(--radius-sm);
}

.skeleton-text {
    height: 14px;
    margin-bottom: 8px;
    border-radius: 4px;
    background: linear-gradient(90deg, var(--bg-card) 25%, var(--bg-elevated) 50%, var(--bg-card) 75%);
    background-size: 800px 100%;
    animation: shimmer 1.8s ease-in-out infinite;
}

.skeleton-text.skeleton-text-sm {
    height: 10px;
    max-width: 60%;
}

.skeleton-text.skeleton-text-lg {
    height: 24px;
    max-width: 40%;
}

.skeleton-text.skeleton-text-xl {
    height: 32px;
    max-width: 50%;
}

.skeleton-card {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: var(--space-5);
    min-height: 120px;
}

.skeleton-card .skeleton-icon {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-sm);
    margin-bottom: var(--space-3);
    background: linear-gradient(90deg, var(--bg-elevated) 25%, #1e2233 50%, var(--bg-elevated) 75%);
    background-size: 800px 100%;
    animation: shimmer 1.8s ease-in-out infinite;
}

.skeleton-chart {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    min-height: 300px;
    padding: var(--space-5);
}

.skeleton-chart-inner {
    height: 220px;
    border-radius: var(--radius-sm);
    background: linear-gradient(90deg, var(--bg-card) 25%, var(--bg-elevated) 50%, var(--bg-card) 75%);
    background-size: 800px 100%;
    animation: shimmer 1.8s ease-in-out infinite;
}

.skeleton-table-row {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-3) var(--space-4);
    border-bottom: 1px solid var(--border-subtle);
}

.skeleton-table-row .skeleton-cell {
    height: 14px;
    border-radius: 4px;
    background: linear-gradient(90deg, var(--bg-card) 25%, var(--bg-elevated) 50%, var(--bg-card) 75%);
    background-size: 800px 100%;
    animation: shimmer 1.8s ease-in-out infinite;
    flex: 1;
}

.skeleton-table-row .skeleton-cell:first-child {
    flex: 2;
}

.skeleton-table-row .skeleton-cell-sm {
    max-width: 60px;
    flex: 0 0 60px;
}

.skeleton-hero {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: var(--space-6);
    text-align: center;
    margin-bottom: var(--space-4);
}

/* Hide skeletons when content is ready */
.content-loaded .skeleton-wrapper {
    display: none !important;
}

.content-loaded .real-content {
    display: block !important;
}
/* Dashboard layout overrides — grid must not be overridden to block */
/* Only show if not hidden by Bootstrap responsive classes (d-none, d-lg-none) */
.content-loaded .real-content.dv-triple-cards:not(.d-none):not(.d-lg-none) {
    display: grid !important;
}
.content-loaded .real-content.dv-ticker-strip:not(.d-none):not(.d-lg-none) {
    display: grid !important;
}
.content-loaded .real-content.dv-dual-panels:not(.d-none):not(.d-lg-none) {
    display: grid !important;
}
/* Desktop-only layouts: hidden below lg, grid on lg+ */
@media (min-width: 992px) {
    .content-loaded .real-content.dv-triple-cards.d-none.d-lg-grid,
    .content-loaded .real-content.dv-ticker-strip.d-none.d-lg-grid,
    .content-loaded .real-content.dv-dual-panels.d-none.d-lg-grid {
        display: grid !important;
    }
}
@media (max-width: 991.98px) {
    .content-loaded .real-content.dv-triple-cards.d-none.d-lg-grid,
    .content-loaded .real-content.dv-ticker-strip.d-none.d-lg-grid,
    .content-loaded .real-content.dv-dual-panels.d-none.d-lg-grid {
        display: none !important;
    }
}
/* Mobile-only layouts: visible below lg, hidden on lg+ */
.content-loaded .real-content.dv-triple-cards.d-lg-none,
.content-loaded .real-content.dv-ticker-strip.d-lg-none,
.content-loaded .real-content.dv-dual-panels.d-lg-none {
    display: grid !important;
}
@media (min-width: 992px) {
    .content-loaded .real-content.dv-triple-cards.d-lg-none,
    .content-loaded .real-content.dv-ticker-strip.d-lg-none,
    .content-loaded .real-content.dv-dual-panels.d-lg-none {
        display: none !important;
    }
}

/* Real content hidden by default until loaded */
.real-content {
    display: none !important;
}

.real-content.row {
    display: none !important;
}

.content-loaded .real-content.row {
    display: flex !important;
}

/* KPI grid special handling */
.real-content.kpi-grid {
    display: none !important;
}

.content-loaded .real-content.kpi-grid {
    display: grid !important;
}

/* ═══════════════════════════════════════════════════════════════════════════ */
/* ─── Button Loading State ───────────────────────────────────────────────── */
/* ═══════════════════════════════════════════════════════════════════════════ */

.btn-loading {
    position: relative;
    color: transparent !important;
    pointer-events: none;
}

.btn-loading::after {
    content: '';
    position: absolute;
    width: 16px;
    height: 16px;
    top: 50%;
    left: 50%;
    margin-top: -8px;
    margin-left: -8px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: btn-spin 0.6s linear infinite;
}

.btn-loading.btn-accent::after {
    border-color: rgba(255, 255, 255, 0.3);
    border-top-color: #fff;
}

.btn-loading.btn-outline-accent::after {
    border-color: rgba(212, 168, 67, 0.3);
    border-top-color: var(--accent);
}

@keyframes btn-spin {
    to { transform: rotate(360deg); }
}

/* ─── Document expiry row highlighting ───────────────────────────────────── */

tr.table-danger-subtle td {
    background-color: rgba(var(--danger-rgb), 0.05) !important;
}
tr.table-warning-subtle td {
    background-color: rgba(234, 179, 8, 0.05) !important;
}

/* ═══════════════════════════════════════════════════════════════════════════ */
/* ─── Responsive: Tablet (< 1024px) ─────────────────────────────────────── */
/* ═══════════════════════════════════════════════════════════════════════════ */

@media (max-width: 1024px) {
    .page-content { padding: var(--space-5); }

    .kpi-grid,
    .kpi-grid.kpi-grid-5 {
        grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    }

    .equity-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    /* Hide less-essential topbar icons on tablet to prevent crowding */
    .topbar-hide-tablet { display: none !important; }
    /* Show privacy/theme in user dropdown on tablet */
    .topbar-show-tablet { display: block !important; }
    .topbar-right { gap: 3px; }
    .topbar-icon-btn { width: 32px; height: 32px; }
    .knox-header-btn { padding: 4px; font-size: 1rem; }
}

/* ═══════════════════════════════════════════════════════════════════════════ */
/* ─── Responsive: Mobile (< 768px) ──────────────────────────────────────── */
/* ═══════════════════════════════════════════════════════════════════════════ */

@media (max-width: 767.98px) {
    /* ─── Sidebar mobile overlay ──────────────────────────────────────── */
    .sidebar {
        transform: translateX(-100%);
        box-shadow: none;
        z-index: 1040;
    }
    .sidebar.show {
        transform: translateX(0);
        box-shadow: 4px 0 32px rgba(0, 0, 0, 0.4);
    }
    .main-content { margin-left: 0; }
    html, body { touch-action: pan-y; }
    .page-content { padding: var(--space-4); padding-bottom: 80px; }

    /* ─── Transaction cards (mobile) ─────────────────────────────────── */
    .txn-table-desktop { display: none !important; }
    .txn-cards-mobile { display: block !important; }
    .card-custom .txn-cards-mobile { padding: 12px; }
    .txn-card {
        background: var(--bg-card);
        border: 1px solid var(--border-color);
        border-radius: var(--radius-md);
        padding: 12px;
        margin-bottom: 8px;
    }
    .card-custom .txn-cards-mobile {
        background: var(--body-bg);
    }
    .txn-card-top {
        display: flex;
        justify-content: space-between;
        align-items: flex-start;
        gap: 8px;
        margin-bottom: 6px;
    }
    .txn-card-desc {
        font-weight: 600;
        font-size: 0.85rem;
        color: var(--text-primary);
        word-break: break-word;
        line-height: 1.3;
        flex: 1;
        min-width: 0;
    }
    .txn-card-amount {
        font-weight: 700;
        font-size: 0.9rem;
        white-space: nowrap;
        flex-shrink: 0;
    }
    .txn-card-meta {
        display: flex;
        flex-wrap: wrap;
        gap: 4px 10px;
        font-size: 0.72rem;
        color: var(--text-muted);
    }
    .txn-card-meta span {
        display: inline-flex;
        align-items: center;
        gap: 3px;
    }
    .txn-card-actions {
        display: flex;
        align-items: center;
        gap: 14px;
        margin-top: 6px;
        padding-top: 6px;
        border-top: 1px solid var(--border-color);
        font-size: 0.75rem;
    }
    .txn-card-actions span {
        display: inline-flex;
        align-items: center;
        gap: 4px;
    }
    .txn-card-select {
        flex-shrink: 0;
        margin-right: 4px;
        margin-top: 2px;
    }

    .sidebar-overlay {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: 1035;
    }
    .sidebar.show ~ .sidebar-overlay,
    .sidebar-overlay.show {
        display: block;
    }

    /* ─── Topbar ──────────────────────────────────────────────────────── */
    .topbar {
        padding: 0 var(--space-3);
        gap: var(--space-2);
    }

    .topbar .sidebar-toggle {
        padding: var(--space-1);
        min-width: 44px;
        min-height: 44px;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .topbar .topbar-logo {
        display: flex;
        align-items: center;
        margin-right: 4px;
    }

    /* ─── KPI Grid ────────────────────────────────────────────────────── */
    .kpi-grid,
    .kpi-grid.kpi-grid-5 {
        grid-template-columns: repeat(2, 1fr);
    }

    .kpi-card { padding: var(--space-5); }
    .kpi-card .kpi-value { font-size: 1.25rem; }
    .kpi-label { font-size: 0.75rem; }

    /* ─── Hero Metric ─────────────────────────────────────────────────── */
    .hero-metric { padding: var(--space-6) var(--space-4); }
    .hero-value { font-size: 2rem; }
    .hero-sub {
        flex-direction: column;
        gap: var(--space-2);
        align-items: center;
    }

    /* ─── Dashboard Header ────────────────────────────────────────────── */
    .dash-header {
        flex-direction: row;
        align-items: flex-end;
    }
    .dash-header-left {
        flex: 1;
        min-width: 0;
        flex-direction: column;
        gap: var(--space-1);
    }
    .dash-header-right {
        flex-shrink: 0;
    }

    /* ─── Equity ──────────────────────────────────────────────────────── */
    .equity-grid { grid-template-columns: repeat(2, 1fr); }
    .equity-highlights { grid-template-columns: 1fr; }
    .equity-stat-value { font-size: 1rem; }

    /* ─── Page Header ─────────────────────────────────────────────────── */
    .page-header {
        flex-direction: column;
        align-items: flex-start;
        gap: var(--space-3);
    }
    .page-header h1 { font-size: 1.2rem; }
    h2 { font-size: 1.15rem; }
    h3 { font-size: 1rem; }

    /* ─── Tables ──────────────────────────────────────────────────────── */
    .table-responsive-custom,
    .card-body > .table-responsive,
    .card-custom > .card-body {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    .table-custom { min-width: unset; font-size: 0.85rem; }

    /* ─── Forms ───────────────────────────────────────────────────────── */
    .row > .col-md-6,
    .row > .col-md-4,
    .row > .col-md-3 {
        flex: 0 0 100%;
        max-width: 100%;
    }

    .btn { min-height: 44px; min-width: 44px; display: inline-flex; align-items: center; justify-content: center; }
    .btn-sm { min-height: 44px; min-width: 44px; }

    .form-control,
    .form-select {
        min-height: 48px;
        font-size: 16px !important;
    }

    .filter-bar { flex-direction: column; align-items: stretch; }
    .filter-bar .form-select { width: 100%; min-width: unset; }

    /* ─── Charts ──────────────────────────────────────────────────────── */
    .chart-container { height: 200px !important; }

    /* ─── Activity / Property Rows ────────────────────────────────────── */
    .activity-item { padding: var(--space-2) var(--space-4); }
    .activity-amount { font-size: 0.75rem; }

    .property-row { flex-wrap: wrap; padding: var(--space-3) var(--space-4); gap: var(--space-2); }
    .property-row-link { flex-wrap: wrap !important; }
    .property-row-info { width: 100%; flex: none; }
    .property-row-right { width: 100%; justify-content: space-between; }
    .copy-addr-btn { display: none; }

    .property-card { padding: var(--space-4); }
    .property-card .property-stats { grid-template-columns: 1fr 1fr; gap: var(--space-1); }

    .detail-grid { grid-template-columns: 1fr 1fr; gap: var(--space-3); }

    /* ─── Renewals ────────────────────────────────────────────────────── */
    .renewal-item { flex-wrap: wrap; gap: var(--space-2); padding: var(--space-3) var(--space-4); }
    .renewal-fee { display: none; }
    .renewal-date { font-size: 0.72rem; }

    /* ─── Knox (mobile) ──────────────────────────────────────────────── */
    .knox-cmd-trigger .knox-cmd-placeholder { display: none; }
    .knox-cmd-trigger .knox-cmd-shortcut { display: none !important; }
    .knox-cmd-trigger {
        position: static;
        transform: none;
        width: auto;
        max-width: 44px;
        min-width: 44px;
        min-height: 36px;
        padding: 6px;
        justify-content: center;
        flex: 0 0 auto;
        margin: 0;
        border-radius: 8px;
    }
    .knox-palette { width: calc(100vw - 24px); max-height: 80vh; }
    .knox-palette-body { max-height: 60vh; }
    .knox-panel {
        width: 100vw !important;
        max-width: 100vw !important;
        height: 100dvh;
        height: -webkit-fill-available;
        top: 0 !important;
        bottom: auto !important;
        left: 0 !important;
        right: 0 !important;
        border-left: none;
        border-radius: 0;
        overflow: hidden;
        transform: none !important;
    }
    .knox-panel.open {
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        right: 0 !important;
        bottom: auto !important;
        width: 100vw !important;
        max-width: 100vw !important;
        height: 100dvh;
        height: -webkit-fill-available;
        overflow: hidden;
        z-index: 9999 !important;
        background: var(--bg-card) !important;
    }
    .knox-panel-header {
        padding: 8px 14px;
    }
    .knox-panel-header h6 {
        font-size: 0.85rem;
        margin-bottom: 0;
    }
    .knox-panel-messages {
        flex: 1 1 0;
        min-height: 0;
        overflow-y: auto;
        overflow-x: hidden;
        -webkit-overflow-scrolling: touch;
    }
    /* Input bar: stick to bottom, above keyboard */
    .knox-panel-input {
        padding-bottom: calc(8px + env(safe-area-inset-bottom, 0px));
        flex-shrink: 0;
        position: relative;
        z-index: 10;
        max-width: 100vw;
        box-sizing: border-box;
        background: var(--bg-card);
    }
    .knox-panel-input input {
        font-size: 16px !important; /* Prevents iOS zoom on focus */
        max-width: 100%;
        /* Suppress iOS form assistant (˄ ˅ ✓ bar) */
        -webkit-user-select: text;
    }
    /* Mobile message bubbles: prevent spill */
    .knox-msg { max-width: 90%; }
    .knox-bubble {
        font-size: 0.82rem;
        max-width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    .knox-bubble table { font-size: 0.7rem; }
    .knox-bubble pre { font-size: 0.68rem; max-width: calc(100vw - 80px); }
    .knox-ts { font-size: 0.58rem; }

    /* Hide Knox header icon on mobile — already in bottom nav + cmd trigger */
    .knox-panel-toggle-btn { display: none !important; }

    /* Knox mobile bottom nav badge */
    .knox-mobile-badge {
        position: absolute;
        top: -4px;
        right: -6px;
        min-width: 14px;
        height: 14px;
        border-radius: 7px;
        background: var(--accent);
        color: #000;
        font-size: 0.5rem;
        font-weight: 700;
        display: flex;
        align-items: center;
        justify-content: center;
        padding: 0 3px;
        line-height: 1;
    }

    /* Topbar right spacing on mobile */
    .topbar-right { gap: 2px; }
    .knox-header-btn { padding: 4px; font-size: 1rem; }
    .topbar-icon-btn { width: 32px; height: 32px; }
    .topbar-user-avatar { width: 28px; height: 28px; font-size: 0.7rem; }

    /* ─── Notifications ───────────────────────────────────────────────── */
    .notification-dropdown { width: calc(100vw - 24px) !important; max-width: 340px; }

    /* ─── Tabs ────────────────────────────────────────────────────────── */
    .nav-tabs-custom { overflow-x: auto; -webkit-overflow-scrolling: touch; flex-wrap: nowrap; scrollbar-width: none; }
    .nav-tabs-custom::-webkit-scrollbar { display: none; }
    .nav-tabs-custom .nav-link { white-space: nowrap; font-size: 0.8rem; padding: 10px 16px; }

    /* Settings tabs scrollable */
    .nav-tabs { flex-wrap: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
    .nav-tabs::-webkit-scrollbar { display: none; }
    .nav-tabs .nav-link { white-space: nowrap; padding: 10px 16px; }

    /* ─── Quick Actions (legacy) ──────────────────────────────────────── */
    .quick-actions { flex-direction: column; align-items: stretch; gap: var(--space-2); }
    .quick-actions-left { flex-direction: column; gap: var(--space-1); }
    .quick-actions-right { width: 100%; justify-content: flex-end; flex-wrap: wrap; }

    /* ─── Modal ───────────────────────────────────────────────────────── */
    .modal-dialog { margin: var(--space-3); }
    .modal-body { padding: var(--space-4); }

    /* ─── Pagination ──────────────────────────────────────────────────── */
    .pagination { flex-wrap: wrap; gap: 2px; }
    .pagination .page-link { min-width: 38px; min-height: 38px; display: flex; align-items: center; justify-content: center; padding: var(--space-1) var(--space-2); }

    .badge { font-size: 0.72rem; }
    .file-item { padding: var(--space-3); }
    .file-info .file-name { font-size: 0.78rem; }
    .px-4 { padding-left: var(--space-3) !important; padding-right: var(--space-3) !important; }
    .alert { margin-bottom: var(--space-3); }
    .stat-card .stat-value { font-size: 1.1rem; }
    .stat-card { padding: var(--space-4); }

    /* ─── Mobile full-width cards ──────────────────────────────────────── */
    .card-custom { border-radius: var(--radius-md); }
    .row > [class*="col-"] { padding-left: 0; padding-right: 0; }
    .row.g-3 > [class*="col-"] { padding-left: calc(var(--bs-gutter-x) * .5); padding-right: calc(var(--bs-gutter-x) * .5); }

    /* Ensure property list items fill full width */
    .property-row { width: 100%; }
    .property-card { width: 100%; }

    /* Activity items full width */
    .activity-item { width: 100%; padding: var(--space-3) var(--space-3); }
    .activity-desc { flex: 1; min-width: 0; }

    /* Stat cards fill grid properly */
    .stat-card { width: 100%; }

    /* Ensure all card bodies don't overflow — min 1rem padding */
    .card-custom .card-body { padding: var(--space-4); }
    .card-custom .card-header { padding: var(--space-3) var(--space-4); }

    /* Section 8 / BRRR / other list items */
    .list-group-item { padding: var(--space-3); }

    /* Ensure renewal items stretch */
    .renewal-item { width: 100%; }

    /* Bottom nav spacing */
    .mobile-bottom-nav a { font-size: 0.7rem; padding: 8px 12px; }
    .mobile-nav-item { padding: 8px 6px; font-size: 0.65rem; }
    .mobile-nav-label { font-size: 0.7rem; }

    /* ─── Document actions: hide secondary actions on mobile ──────────── */
    .doc-action-secondary { display: none !important; }

    /* ─── Mobile font sizes: ensure readable minimum ───────────────────── */
    body { font-size: 0.875rem; }
    .text-muted, .small, .form-text { font-size: 0.8rem !important; }

    /* ─── Card body minimum padding ────────────────────────────────────── */
    .card-body { min-height: auto; padding: 16px !important; }

    /* ─── Page header: spacing between title and action buttons ─────────── */
    .page-header { gap: var(--space-4); }
    .page-header .btn { font-size: 0.8rem; }

    /* ─── Nav link touch targets ───────────────────────────────────────── */
    .nav-link { padding: 10px 16px; }

    /* ─── Transaction table text bump ──────────────────────────────────── */
    .table-custom td, .table-custom th { font-size: 0.82rem; padding: 10px 8px; }

    /* ─── Bottom nav safe area ─────────────────────────────────────────── */
    .mobile-bottom-nav { padding-bottom: env(safe-area-inset-bottom, 0); }
}

/* ═══════════════════════════════════════════════════════════════════════════ */
/* ─── Responsive: Extra Small (< 576px) ──────────────────────────────────── */
/* ═══════════════════════════════════════════════════════════════════════════ */

@media (max-width: 575.98px) {
    .page-content { padding: var(--space-3); padding-bottom: 80px; }
    .topbar { padding: 0 var(--space-2); gap: var(--space-1); }
    .knox-cmd-trigger { max-width: 40px; min-width: 40px; padding: 6px; margin: 0; }
    .detail-grid { grid-template-columns: 1fr; }

    .page-header h1 { font-size: 1.1rem; }
    .hero-value { font-size: 1.6rem; }
    .hero-label { font-size: 0.6rem; }
    .stat-card .stat-value { font-size: 1rem; }

    /* ─── Dashboard income/expense chart header: stack on mobile ──────── */
    .card-custom.no-collapse > .card-header {
        flex-direction: column;
        align-items: flex-start !important;
        gap: 0.5rem;
    }
    .card-custom.no-collapse > .card-header > div {
        width: 100%;
        justify-content: space-between !important;
    }
    #incExpPeriods {
        justify-content: flex-end;
    }

    .dash-header-right .btn { font-size: 0.68rem; padding: 4px 8px; min-height: 36px; }
    .quick-actions-right .btn { font-size: 0.68rem; padding: 4px 8px; min-height: 36px; }

    .knox-palette { width: calc(100vw - 16px); border-radius: 12px; }
    .search-results { max-height: 260px; }

    .login-card { padding: var(--space-6); margin: var(--space-3); max-width: none; }
    .login-card .logo i { font-size: 2rem; }
    .login-card .logo h2 { font-size: 1.1rem; }

    .equity-grid { grid-template-columns: 1fr 1fr; }
    .kpi-grid, .kpi-grid.kpi-grid-5 { grid-template-columns: repeat(2, 1fr); }

    /* Table card view */
    .table-responsive-cards .table-custom thead { display: none; }
    .table-responsive-cards .table-custom tbody tr {
        display: block;
        background: var(--bg-card);
        border: 1px solid var(--border-color);
        border-radius: var(--radius-md);
        padding: var(--space-3);
        margin-bottom: var(--space-2);
    }
    .table-responsive-cards .table-custom tbody td {
        display: flex;
        justify-content: space-between;
        padding: var(--space-1) 0;
        border: none;
    }
    .table-responsive-cards .table-custom tbody td::before {
        content: attr(data-label);
        font-weight: 600;
        color: var(--text-muted);
        font-size: 0.68rem;
        text-transform: uppercase;
    }

    .flash-container {
        padding: var(--space-3) var(--space-3) 0;
    }

    /* ─── Health category pills: icon-only on mobile ─────────────────── */
    .health-category-pill { font-size: 0; gap: 0; padding: 4px 6px; }
    .health-category-pill i { font-size: 0.7rem !important; }

    /* ─── Transactions table: hide checkbox + actions columns ─────────── */
    .txn-table-desktop .table-responsive-cards td:first-child,
    .txn-table-desktop .table-responsive-cards th:first-child { display: none; }
    .txn-table-desktop .table-responsive-cards td:nth-last-child(1),
    .txn-table-desktop .table-responsive-cards td:nth-last-child(2) { display: none; }

    /* ─── Portfolio Health nudge: wrap on mobile ──────────────────────── */
    .health-prop-row { flex-wrap: wrap; }
    .health-prop-nudge { width: 100%; font-size: 0.75rem; margin-top: 2px; max-width: none !important; text-overflow: unset; overflow: visible; white-space: normal; }

    /* ─── Text overflow prevention ────────────────────────────────────── */
    .page-header h1,
    .card-custom .card-header h5,
    .card-custom .card-header h6 {
        word-break: break-word;
        overflow-wrap: break-word;
    }

    /* ─── Buttons: allow text wrapping ────────────────────────────────── */
    .btn { white-space: normal; }

    /* ─── Breadcrumbs: hide intermediate items on mobile, show back arrow ── */
    .breadcrumb-item:not(:last-child) { display: none; }
    .breadcrumb-item:last-child::before { content: none; }

    /* ─── Modals: near full-width ─────────────────────────────────────── */
    .modal-dialog { margin: var(--space-2); max-width: calc(100vw - 16px); }
    .modal-footer { flex-wrap: wrap; gap: 4px; }

    /* ─── Tables: ensure text wraps in cells ──────────────────────────── */
    .table-custom td { word-break: normal; overflow-wrap: break-word; white-space: normal; }

    /* ─── Card headers: allow wrapping ────────────────────────────────── */
    .card-custom .card-header { flex-wrap: wrap; gap: 4px; }
}

/* ═══════════════════════════════════════════════════════════════════════════ */
/* ─── Responsive: iPhone Small (≤ 480px) ─────────────────────────────────── */
/* ═══════════════════════════════════════════════════════════════════════════ */

@media (max-width: 480px) {
    /* ─── Typography ──────────────────────────────────────────────────── */
    body { font-size: 0.84rem; }
    .page-header h1 { font-size: 1.05rem; word-break: break-word; }
    h2 { font-size: 1.05rem; }
    h3 { font-size: 0.95rem; }
    .text-muted, .small, .form-text { font-size: 0.75rem !important; }

    /* ─── Page Content ────────────────────────────────────────────────── */
    .page-content { padding: 12px; padding-bottom: 80px; }

    /* ─── KPI Grid: 2 columns tighter ─────────────────────────────────── */
    .kpi-grid,
    .kpi-grid.kpi-grid-5 {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
    }
    .kpi-card { padding: 12px; }
    .kpi-card .kpi-value { font-size: 1.1rem; word-break: break-all; }
    .kpi-label { font-size: 0.7rem; }
    .kpi-sub { font-size: 0.65rem; }

    /* ─── Hero Metric ─────────────────────────────────────────────────── */
    .hero-value { font-size: 1.4rem; }
    .hero-label { font-size: 0.58rem; }
    .hero-metric { padding: var(--space-4) var(--space-3); }

    /* ─── Breadcrumbs ─────────────────────────────────────────────────── */
    .page-header .breadcrumb { font-size: 0.7rem; }
    .breadcrumb-item { max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    .breadcrumb-item + .breadcrumb-item::before { padding: 0 4px; }

    /* ─── Tab Navigation ──────────────────────────────────────────────── */
    .page-tab { padding: 6px 8px; font-size: 0.7rem; }
    .page-tab-nav { margin: -4px 0 12px 0; }
    .page-tab-scroll { flex-wrap: nowrap; }
    .nav-tabs-custom .nav-link { font-size: 0.75rem; padding: 8px 10px; }
    .nav-tabs .nav-link { font-size: 0.75rem; padding: 8px 10px; }

    /* ─── Tables ──────────────────────────────────────────────────────── */
    .table-custom td,
    .table-custom th {
        font-size: 0.78rem;
        padding: 8px 6px;
        word-break: break-word;
    }
    .table-custom { font-size: 0.78rem; }

    /* ─── Buttons ─────────────────────────────────────────────────────── */
    .btn {
        font-size: 0.78rem;
        padding: 6px 10px;
        min-height: 44px;
        white-space: normal;
        word-break: break-word;
    }
    .btn-sm {
        font-size: 0.72rem;
        padding: 4px 8px;
        min-height: 44px;
    }
    .page-header .btn { font-size: 0.75rem; padding: 4px 8px; }
    .dash-header-right .btn,
    .quick-actions-right .btn { font-size: 0.65rem; padding: 3px 6px; min-height: 34px; }

    /* ─── Modals ──────────────────────────────────────────────────────── */
    .modal-dialog {
        margin: 8px;
        max-width: calc(100vw - 16px);
    }
    .modal-body { padding: 12px; }
    .modal-header { padding: 12px; }
    .modal-footer { padding: 8px 12px; }
    .modal-title { font-size: 1rem; }

    /* ─── Cards ───────────────────────────────────────────────────────── */
    .card-body { padding: 12px !important; }
    .card-custom .card-header { padding: 10px 12px; font-size: 0.85rem; }
    .stat-card { padding: 12px; }
    .stat-card .stat-value { font-size: 0.95rem; }

    /* ─── Forms ───────────────────────────────────────────────────────── */
    .form-control,
    .form-select {
        font-size: 16px !important;
        padding: 8px 10px;
    }
    .form-label { font-size: 0.8rem; }

    /* ─── Property Rows ──────────────────────────────────────────────── */
    .property-row { padding: 10px 12px; }
    .property-row-info { font-size: 0.82rem; }

    /* ─── Activity Items ─────────────────────────────────────────────── */
    .activity-item { padding: 8px 10px; }
    .activity-desc { font-size: 0.78rem; }
    .activity-amount { font-size: 0.7rem; }

    /* ─── Equity Grid ─────────────────────────────────────────────────── */
    .equity-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
    .equity-stat-value { font-size: 0.9rem; }

    /* ─── Detail Grid ─────────────────────────────────────────────────── */
    .detail-grid { grid-template-columns: 1fr; gap: 8px; }
    .detail-label { font-size: 0.72rem; }
    .detail-value { font-size: 0.82rem; word-break: break-word; }

    /* ─── Badges ──────────────────────────────────────────────────────── */
    .badge { font-size: 0.68rem; padding: 3px 6px; }

    /* ─── Login Card ─────────────────────────────────────────────────── */
    .login-card { padding: var(--space-4); margin: 8px; }
    .login-card .logo h2 { font-size: 1rem; }

    /* ─── Bottom Nav ─────────────────────────────────────────────────── */
    .mobile-nav-item { padding: 6px 4px; font-size: 0.6rem; }
    .mobile-nav-label { font-size: 0.62rem; }
}

/* ═══════════════════════════════════════════════════════════════════════════ */
/* ─── Responsive: iPhone SE / Mini (≤ 375px) ─────────────────────────────── */
/* ═══════════════════════════════════════════════════════════════════════════ */

@media (max-width: 375px) {
    /* ─── Typography ──────────────────────────────────────────────────── */
    body { font-size: 0.8rem; }
    .page-header h1 { font-size: 0.95rem; line-height: 1.3; word-break: break-word; }
    h2 { font-size: 0.95rem; }
    h3 { font-size: 0.88rem; }
    h4, h5 { font-size: 0.82rem; }
    .text-muted, .small, .form-text { font-size: 0.72rem !important; }

    /* ─── Page Content: tighter padding ───────────────────────────────── */
    .page-content { padding: 10px 8px; padding-bottom: 80px; }

    /* ─── KPI Grid: single column on tiny screens ─────────────────────── */
    .kpi-grid,
    .kpi-grid.kpi-grid-5 {
        grid-template-columns: 1fr;
        gap: 6px;
    }
    .kpi-card {
        padding: 10px 12px;
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 8px;
    }
    .kpi-card .kpi-value { font-size: 1.05rem; }
    .kpi-label { font-size: 0.68rem; margin-bottom: 0; }
    .kpi-sub { font-size: 0.62rem; }

    /* ─── Hero Metric ─────────────────────────────────────────────────── */
    .hero-value { font-size: 1.2rem; }
    .hero-label { font-size: 0.55rem; letter-spacing: 0.08em; }
    .hero-metric { padding: 12px 10px; }

    /* ─── Breadcrumbs ─────────────────────────────────────────────────── */
    .page-header .breadcrumb { font-size: 0.65rem; }
    .breadcrumb-item { max-width: 90px; }

    /* ─── Tab Navigation: scrollable, no truncation ───────────────────── */
    .page-tab { padding: 5px 6px; font-size: 0.65rem; min-width: max-content; }
    .page-tab-nav {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        flex-wrap: nowrap;
        margin: -4px 0 10px 0;
    }
    .page-tab-scroll { flex-wrap: nowrap; gap: 0; }
    .nav-tabs-custom .nav-link {
        font-size: 0.7rem;
        padding: 8px 8px;
        white-space: nowrap;
        min-width: max-content;
    }
    .nav-tabs .nav-link {
        font-size: 0.7rem;
        padding: 8px 8px;
        white-space: nowrap;
        min-width: max-content;
    }

    /* ─── Tables: wrap text, reduce padding ───────────────────────────── */
    .table-custom td,
    .table-custom th {
        font-size: 0.72rem;
        padding: 6px 4px;
        word-break: break-word;
        white-space: normal;
    }
    .table-custom { font-size: 0.72rem; min-width: unset; }
    /* Force table to not overflow card */
    .table-responsive-custom,
    .card-body > .table-responsive {
        margin-left: -12px;
        margin-right: -12px;
        padding: 0 4px;
    }

    /* ─── Buttons: wrap text, proper touch targets ────────────────────── */
    .btn {
        font-size: 0.72rem;
        padding: 6px 8px;
        min-height: 44px;
        white-space: normal;
        word-break: break-word;
        text-align: center;
    }
    .btn-sm {
        font-size: 0.68rem;
        padding: 4px 6px;
        min-height: 44px;
    }
    .page-header .btn {
        font-size: 0.7rem;
        padding: 4px 6px;
    }
    .btn-group .btn { padding: 4px 6px; }
    .dash-header-right .btn,
    .quick-actions-right .btn {
        font-size: 0.62rem;
        padding: 3px 5px;
        min-height: 32px;
    }
    /* Button groups: allow wrapping */
    .btn-group { flex-wrap: wrap; }
    .page-header .d-flex { flex-wrap: wrap; gap: 4px; }

    /* ─── Modals: full-width ──────────────────────────────────────────── */
    .modal-dialog {
        margin: 4px;
        max-width: calc(100vw - 8px);
    }
    .modal-body { padding: 10px; }
    .modal-header { padding: 10px 12px; }
    .modal-header .btn-close { padding: 8px; }
    .modal-footer { padding: 8px 10px; flex-wrap: wrap; gap: 4px; }
    .modal-footer .btn { flex: 1 1 auto; }
    .modal-title { font-size: 0.9rem; }

    /* ─── Cards: minimal padding ─────────────────────────────────────── */
    .card-body { padding: 10px !important; }
    .card-custom .card-header {
        padding: 8px 10px;
        font-size: 0.8rem;
        flex-wrap: wrap;
        gap: 4px;
    }
    .card-custom .card-header h5,
    .card-custom .card-header h6,
    .card-custom .card-header .fw-semibold {
        font-size: 0.82rem;
        word-break: break-word;
    }
    .stat-card { padding: 10px; }
    .stat-card .stat-value { font-size: 0.9rem; }
    .stat-card .stat-label { font-size: 0.68rem; }

    /* ─── Forms: prevent zoom on iOS (16px min) ──────────────────────── */
    .form-control,
    .form-select {
        font-size: 16px !important;
        padding: 8px;
        min-height: 44px;
    }
    .form-label { font-size: 0.75rem; }
    .input-group { flex-wrap: wrap; }
    .input-group .form-control { min-width: 0; }

    /* ─── Property Rows ──────────────────────────────────────────────── */
    .property-row { padding: 8px 10px; gap: 4px; }
    .property-row-info { font-size: 0.78rem; }
    .property-row-name { font-size: 0.82rem; }
    .property-row-meta { font-size: 0.68rem; }
    .property-row-rent { font-size: 0.82rem; }
    .property-card { padding: 10px; }
    .property-card .property-stats { gap: 4px; }

    /* ─── Activity Items ─────────────────────────────────────────────── */
    .activity-item { padding: 6px 8px; }
    .activity-desc { font-size: 0.72rem; }
    .activity-amount { font-size: 0.65rem; }
    .activity-date { font-size: 0.62rem; }

    /* ─── Equity ──────────────────────────────────────────────────────── */
    .equity-grid { grid-template-columns: 1fr; gap: 6px; }
    .equity-stat-value { font-size: 0.85rem; }
    .equity-highlights { gap: 6px; }

    /* ─── Detail Grid ─────────────────────────────────────────────────── */
    .detail-grid { grid-template-columns: 1fr; gap: 6px; }
    .detail-label { font-size: 0.68rem; }
    .detail-value { font-size: 0.78rem; word-break: break-word; overflow-wrap: anywhere; }

    /* ─── Renewals ────────────────────────────────────────────────────── */
    .renewal-item { padding: 8px 10px; }
    .renewal-date { font-size: 0.65rem; }
    .renewal-property { font-size: 0.78rem; }

    /* ─── Badges ──────────────────────────────────────────────────────── */
    .badge { font-size: 0.62rem; padding: 2px 5px; }

    /* ─── Pagination ──────────────────────────────────────────────────── */
    .pagination .page-link { min-width: 34px; min-height: 34px; font-size: 0.72rem; padding: 4px 6px; }
    .pagination { gap: 1px; }

    /* ─── Charts ──────────────────────────────────────────────────────── */
    .chart-container { height: 160px !important; }

    /* ─── Filter Bar ─────────────────────────────────────────────────── */
    .filter-bar { gap: 6px; }
    .filter-bar .form-select { font-size: 0.75rem; min-height: 40px; }
    .filter-bar .btn { font-size: 0.7rem; }

    /* ─── Knox ────────────────────────────────────────────────────────── */
    .knox-palette { width: calc(100vw - 12px); }
    .knox-cmd-trigger { max-width: 36px; min-width: 36px; min-height: 34px; }

    /* ─── Topbar ──────────────────────────────────────────────────────── */
    .topbar { padding: 0 6px; gap: 2px; }
    .topbar-icon-btn { width: 28px; height: 28px; font-size: 0.85rem; }
    .topbar-user-avatar { width: 24px; height: 24px; font-size: 0.6rem; }
    .topbar .topbar-logo img { height: 20px; }

    /* ─── Login Card ─────────────────────────────────────────────────── */
    .login-card { padding: 16px; margin: 6px; }
    .login-card .logo i { font-size: 1.6rem; }
    .login-card .logo h2 { font-size: 0.95rem; }

    /* ─── Bottom Nav ─────────────────────────────────────────────────── */
    .mobile-nav-item { padding: 5px 2px; font-size: 0.55rem; }
    .mobile-nav-item i { font-size: 1rem; }
    .mobile-nav-label { font-size: 0.58rem; }
    .mobile-bottom-nav a { font-size: 0.58rem; padding: 6px 4px; }

    /* ─── Notification Dropdown ───────────────────────────────────────── */
    .notification-dropdown { width: calc(100vw - 16px) !important; max-width: 100%; }

    /* ─── Flex Row Wrapping ───────────────────────────────────────────── */
    .d-flex:not(.mobile-bottom-nav):not(.sidebar-footer-actions) { flex-wrap: wrap; }
    .gap-2 { gap: 4px !important; }
    .gap-3 { gap: 6px !important; }

    /* ─── File Items ─────────────────────────────────────────────────── */
    .file-item { padding: 8px; }
    .file-info .file-name { font-size: 0.72rem; word-break: break-word; }
    .file-info .file-meta { font-size: 0.62rem; }

    /* ─── Flash Alerts ───────────────────────────────────────────────── */
    .flash-container { padding: 6px 8px 0; }
    .alert { font-size: 0.78rem; padding: 8px 10px; }

    /* ─── Health Category Pills: icon only ────────────────────────────── */
    .health-category-pill { font-size: 0; gap: 0; padding: 3px 5px; }
    .health-category-pill i { font-size: 0.65rem !important; }

    /* ─── List Groups ────────────────────────────────────────────────── */
    .list-group-item { padding: 8px 10px; font-size: 0.78rem; }

    /* ─── Dropdown Menus ─────────────────────────────────────────────── */
    .dropdown-menu { font-size: 0.8rem; }
    .dropdown-item { padding: 8px 12px; font-size: 0.78rem; }
}

/* ── Entity Section Separators ────────────────────────────── */
.entity-section + .entity-section {
    border-top: 1px solid var(--border-color);
    margin-top: 1rem;
    padding-top: 1rem;
}

/* ═══════════════════════════════════════════════════════════════════════════ */
/* ─── Sprint 7: Accessibility Improvements ────────────────────────────── */
/* ═══════════════════════════════════════════════════════════════════════════ */

/* 7.2a: Visible focus states for keyboard navigation */
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
.form-check-input:focus-visible,
.btn:focus-visible,
.page-link:focus-visible,
.nav-link:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
    box-shadow: none;
}

/* 7.2b: Increase muted text contrast for WCAG 4.5:1 ratio */
/* Dark theme: --text-muted was #505569 (~3.2:1), bump to #7a7f95 (~4.6:1 against #090b0f) */
:root {
    --text-muted: #7a7f95;
}
/* Light theme: --text-muted was #8c959f (~3.8:1), bump to #656d76 (~5.3:1 against #f5f7f9) */
[data-theme="light"] {
    --text-muted: #656d76;
}

/* Bootstrap .text-secondary override for better contrast on dark bg */
.text-secondary {
    color: var(--text-secondary) !important;
}

/* 7.2c: Accessibility icons next to color-coded financial amounts */
.amount-positive::before {
    content: "\F145";  /* bi-arrow-up-short */
    font-family: "bootstrap-icons";
    margin-right: 2px;
    font-size: 1.05em;
    vertical-align: middle;
}
.amount-negative::before {
    content: "\F124";  /* bi-arrow-down-short */
    font-family: "bootstrap-icons";
    margin-right: 2px;
    font-size: 1.05em;
    vertical-align: middle;
}

/* Don't show icons in very compact contexts (mobile cards, small badges) */
.kpi-value.amount-positive::before,
.kpi-value.amount-negative::before,
.hero-value.amount-positive::before,
.hero-value.amount-negative::before {
    content: none;
}

/* ═══════════════════════════════════════════════════════════════════════════ */
/* ─── Sprint 7: Loading Skeletons for Data-Heavy Pages ────────────────── */
/* ═══════════════════════════════════════════════════════════════════════════ */

/* 7.3: Skeleton row system for table-heavy pages */
.skeleton-loading-container {
    padding: 0;
}

.skeleton-row {
    display: flex;
    gap: 1rem;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border-subtle);
}

.skeleton-row:last-child {
    border-bottom: none;
}

.skeleton-cell {
    background: linear-gradient(90deg, var(--bg-card) 25%, var(--bg-elevated) 50%, var(--bg-card) 75%);
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s infinite;
    border-radius: 4px;
    height: 14px;
    flex: 1;
}

.skeleton-cell.skeleton-cell-wide {
    flex: 2;
}

.skeleton-cell.skeleton-cell-narrow {
    flex: 0 0 60px;
}

.skeleton-cell.skeleton-cell-medium {
    flex: 0 0 100px;
}

@keyframes skeleton-loading {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* Light mode skeleton rows */
[data-theme="light"] .skeleton-cell {
    background: linear-gradient(90deg, #e8edf2 25%, #f0f4f8 50%, #e8edf2 75%);
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s infinite;
}

/* Hide skeleton when data loaded — uses !important to override responsive display rules */
.data-loaded .skeleton-loading-container,
.skeleton-loading-container.dv-skeleton-done {
    display: none !important;
}

/* Show real content when data loaded — override initial hide */
.dv-content-hidden {
    display: none !important;
}
.data-loaded .dv-content-hidden {
    /* This gets overridden by the JS reveal; class is removed */
}

/* Timeline skeleton for Knox Activity */
.skeleton-timeline-item {
    display: flex;
    gap: 16px;
    margin-bottom: 12px;
}

.skeleton-timeline-dot {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    flex-shrink: 0;
    background: linear-gradient(90deg, var(--bg-card) 25%, var(--bg-elevated) 50%, var(--bg-card) 75%);
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s infinite;
}

.skeleton-timeline-card {
    flex: 1;
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 14px 18px;
}

.skeleton-timeline-card .skeleton-cell {
    margin-bottom: 8px;
}

.skeleton-timeline-card .skeleton-cell:last-child {
    margin-bottom: 0;
}

[data-theme="light"] .skeleton-timeline-dot {
    background: linear-gradient(90deg, #e8edf2 25%, #f0f4f8 50%, #e8edf2 75%);
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s infinite;
}

/* ─── Demo Mode Disabled State ──────────────────────────────────────── */
.demo-disabled { opacity: 0.5; cursor: not-allowed !important; pointer-events: auto; }
.demo-disabled:hover { opacity: 0.6; }
.demo-toast {
    position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%) translateY(100px);
    background: #1a1a2e; color: #e0d5b7; border: 1px solid #c9a84c;
    padding: 12px 24px; border-radius: 10px; font-size: 0.9rem;
    z-index: 99999; transition: transform 0.3s ease; white-space: nowrap;
    box-shadow: 0 4px 20px rgba(0,0,0,0.4);
}
.demo-toast.show { transform: translateX(-50%) translateY(0); }

/* ─── Health Card Inline Upload ──────────────────────────────────────── */

.health-upload-zone {
    margin-top: 0.75rem;
    animation: healthSlideDown 0.2s ease-out;
}

@keyframes healthSlideDown {
    from { opacity: 0; max-height: 0; margin-top: 0; }
    to { opacity: 1; max-height: 200px; margin-top: 0.75rem; }
}

.health-dropzone {
    border: 2px dashed var(--border-color);
    border-radius: var(--radius-md, 8px);
    padding: 1rem 1.25rem;
    background: rgba(201, 168, 76, 0.03);
    transition: border-color 0.2s, background 0.2s;
}

.health-dropzone.drag-over {
    border-color: var(--accent);
    background: rgba(201, 168, 76, 0.08);
}

.dropzone-idle {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.dropzone-uploading {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    justify-content: center;
    padding: 0.5rem;
}

.health-upload-result {
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md, 8px);
    padding: 1rem;
    margin-top: 0.75rem;
    background: var(--bg-card);
    animation: healthSlideDown 0.2s ease-out;
}

.result-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
    font-size: 0.9rem;
}

.result-fields {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 0.5rem 1rem;
    margin-bottom: 0.75rem;
    padding: 0.6rem 0.75rem;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 6px;
}

.result-field .field-label {
    display: block;
    font-size: 0.65rem;
    text-transform: uppercase;
    color: var(--text-muted);
    letter-spacing: 0.5px;
}

.result-field .field-value {
    font-size: 0.85rem;
    font-weight: 500;
}

.result-actions {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

@media (max-width: 575.98px) {
    .result-actions {
        flex-direction: column;
    }
    .result-actions .btn {
        width: 100%;
    }
    .result-fields {
        grid-template-columns: 1fr 1fr;
    }
    .dropzone-idle {
        flex-wrap: wrap;
    }
}

/* Password toggle eye icon */
.pw-toggle-wrap { position: relative; }
.pw-toggle-btn { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); background: none; border: none; color: #6b7280; cursor: pointer; padding: 0; z-index: 4; font-size: 1.1rem; line-height: 1; }
.pw-toggle-btn:hover { color: #9ca3af; }

/* ═══ PRIVACY MODE ═══════════════════════════════════════════════════════════
   Blurs sensitive financial data, property names, addresses, and PII.
   Toggled via eye icon in the topbar. State persisted in localStorage.
   CSS-first approach: targets existing classes so new pages auto-covered.
   ═══════════════════════════════════════════════════════════════════════════ */

/* Reusable blur mixin via CSS custom property */
body.privacy-mode { --priv-blur: blur(8px); --priv-blur-light: blur(6px); --priv-blur-heavy: blur(12px); }

/* ─── Generic .sensitive class — manual opt-in on any element ─── */
body.privacy-mode .sensitive,
html.privacy-mode .sensitive {
    filter: var(--priv-blur) !important;
    user-select: none !important;
    pointer-events: none !important;
}

/* ─── GLOBAL: Financial amounts (works across ALL pages) ─── */
body.privacy-mode .amount-positive,
body.privacy-mode .amount-negative,
body.privacy-mode .kpi-value,
body.privacy-mode .kpi-sub,
body.privacy-mode .hero-value,
body.privacy-mode .hero-sub {
    filter: var(--priv-blur) !important;
    user-select: none !important;
}

/* ─── GLOBAL: Charts ─── */
body.privacy-mode canvas {
    filter: var(--priv-blur-heavy) !important;
    pointer-events: none !important;
}

/* ─── GLOBAL: Detail sections (property detail, entity detail, etc.) ─── */
body.privacy-mode .detail-value {
    filter: var(--priv-blur) !important;
    user-select: none !important;
}

/* ─── GLOBAL: Breadcrumb last item (often shows property name/address) ─── */
body.privacy-mode .breadcrumb-item.active {
    filter: var(--priv-blur-light) !important;
    user-select: none !important;
}

/* ─── GLOBAL: Tables — blur financial value columns ─── */
body.privacy-mode .table-dark td.text-end,
body.privacy-mode .table-dark td.fw-semibold,
body.privacy-mode .table-custom td.text-end,
body.privacy-mode .table-sm td.text-end {
    filter: var(--priv-blur) !important;
    user-select: none !important;
}
/* Property names/addresses in tables */
body.privacy-mode .table-dark td a.text-accent,
body.privacy-mode .table-dark td .text-muted.fs-xs {
    filter: var(--priv-blur-light) !important;
    user-select: none !important;
}

/* ─── Dashboard ─── */
body.privacy-mode .dash-subtitle {
    filter: var(--priv-blur-light) !important;
    user-select: none !important;
}
/* Renewal widget */
body.privacy-mode .renewal-property,
body.privacy-mode .renewal-fee {
    filter: var(--priv-blur) !important;
    user-select: none !important;
}
/* Portfolio health property names/scores */
body.privacy-mode .health-prop-row {
    filter: var(--priv-blur-light) !important;
    user-select: none !important;
}
/* Cash Flow Forecast, Market Data values — bold large text with dollar amounts */
body.privacy-mode .fs-4.fw-bold,
body.privacy-mode .fs-5.fw-bold,
body.privacy-mode .fs-4.fw-semibold,
body.privacy-mode .fs-5.fw-semibold {
    filter: var(--priv-blur) !important;
    user-select: none !important;
}
/* Knox Insights (dynamically loaded text with dollar amounts) */
body.privacy-mode #knoxInsightsBody {
    filter: var(--priv-blur-light) !important;
    user-select: none !important;
}
/* Equity section */
body.privacy-mode .equity-stat-value,
body.privacy-mode .equity-highlight-value,
body.privacy-mode .equity-insight strong {
    filter: var(--priv-blur) !important;
    user-select: none !important;
}
/* Property row names/rents in dashboard snapshot */
body.privacy-mode .property-row-name,
body.privacy-mode .property-row-meta,
body.privacy-mode .property-row-rent {
    filter: var(--priv-blur-light) !important;
    user-select: none !important;
}
/* PM Overview section — company name, fees, contact */
body.privacy-mode .pm-company-name {
    filter: var(--priv-blur-light) !important;
    user-select: none !important;
}

/* ─── Properties List ─── */
body.privacy-mode .property-list-row td:first-child {
    filter: var(--priv-blur-light) !important;
    user-select: none !important;
}
body.privacy-mode .property-card h6,
body.privacy-mode .property-card p {
    filter: var(--priv-blur-light) !important;
    user-select: none !important;
}

/* ─── Property Detail ─── */
/* Market data values (AVM, tax assessment, etc.) */
body.privacy-mode .market-stat-value,
body.privacy-mode .fs-4.fw-bold.text-success,
body.privacy-mode .fs-4.fw-bold.text-info,
body.privacy-mode .fs-4.fw-bold.text-warning,
body.privacy-mode .fs-4.fw-bold.text-danger,
body.privacy-mode .fs-4.fw-bold.text-accent,
body.privacy-mode .fs-4.fw-bold.text-muted {
    filter: var(--priv-blur) !important;
    user-select: none !important;
}
/* Fort Knox score badge categories are OK to show */
/* Section 8 values, tenant info, lease details — all use .detail-value */
/* Insurance, financing, depreciation — all use .detail-value */

/* ─── Transactions ─── */
body.privacy-mode .txn-card-amount {
    filter: var(--priv-blur) !important;
    user-select: none !important;
}
body.privacy-mode .txn-card-desc {
    filter: var(--priv-blur-light) !important;
    user-select: none !important;
}

/* ─── Reports ─── */
/* P&L statement rows with amounts */
body.privacy-mode .pnl-amount,
body.privacy-mode .stmt-amount,
body.privacy-mode #stmtTotalIncome,
body.privacy-mode #stmtTotalExpenses,
body.privacy-mode #stmtTotalFinancing,
body.privacy-mode #stmtNoi,
body.privacy-mode #stmtNetCashflow,
body.privacy-mode #stmtTitle,
body.privacy-mode #stmtIncome,
body.privacy-mode #stmtExpenses,
body.privacy-mode #stmtFinancing,
body.privacy-mode #statementResult {
    filter: var(--priv-blur) !important;
    user-select: none !important;
}
/* Performance table property names */
body.privacy-mode #performanceTable td:nth-child(2) {
    filter: var(--priv-blur-light) !important;
    user-select: none !important;
}

/* ─── Entities ─── */
body.privacy-mode .sensitive-field {
    filter: var(--priv-blur) !important;
    user-select: none !important;
}

/* ─── User dropdown (name/email) ─── */
body.privacy-mode .topbar-user-dropdown .dropdown-header {
    filter: var(--priv-blur-light) !important;
    user-select: none !important;
}

/* ─── Privacy toggle button active state ─── */
body.privacy-mode #privacyToggle {
    background: rgba(139, 92, 246, 0.15) !important;
    color: #a78bfa !important;
    border-radius: 8px;
}

/* Privacy banner display */
body.privacy-mode #privacyBanner {
    display: flex !important;
}

/* ─── Smooth transitions ─── */
.hero-value, .hero-sub, .kpi-value, .kpi-sub,
.amount-positive, .amount-negative,
.detail-value, .sensitive, .sensitive-field,
.dash-subtitle, canvas,
.txn-card-amount, .txn-card-desc,
.property-list-row td:first-child,
.property-card h6, .property-card p,
.renewal-property, .renewal-fee,
.health-prop-row, .equity-stat-value,
.equity-highlight-value, .breadcrumb-item.active,
.fs-4.fw-bold, .fs-5.fw-bold, .fs-4.fw-semibold, .fs-5.fw-semibold,
.topbar-user-dropdown .dropdown-header,
.property-row-name, .property-row-meta, .property-row-rent,
#knoxInsightsBody, #performanceTable td:nth-child(2),
.table-dark td.text-end, .table-custom td.text-end {
    transition: filter 0.25s ease;
}

/* ─── PM Branding: "Powered by DoorVault" badge ────────────────────────── */
.pm-powered-badge {
    padding: 8px 16px;
    border-top: 1px solid var(--border-subtle);
    text-align: center;
}
.pm-powered-link {
    display: inline-flex;
    align-items: center;
    font-size: 0.62rem;
    color: var(--text-muted);
    text-decoration: none;
    opacity: 0.7;
    transition: opacity var(--transition-fast);
}
.pm-powered-link:hover {
    opacity: 1;
    color: var(--text-secondary);
}
.sidebar.collapsed .pm-powered-badge span { display: none; }
.sidebar.collapsed .pm-powered-badge { padding: 8px 4px; }
