:root {
    --bg-base: #0b0d10;
    --bg-panel: rgba(24, 28, 32, 0.84);
    --bg-panel-strong: rgba(18, 20, 24, 0.96);
    --bg-soft: rgba(255,255,255,0.03);
    --surface: rgba(255,255,255,0.04);
    --surface-strong: rgba(255,255,255,0.08);
    --border: rgba(182, 184, 186, 0.18);
    --text: #edf2ff;
    --muted: #a3adbf;
    --primary: #d9b15d;
    --primary-strong: #f2d58f;
    --silver: #dfe6ef;
    --success: #38d39f;
    --danger: #ff6b6b;
    --warning: #f1c75b;
    --shadow: 0 22px 48px rgba(0, 0, 0, 0.38);
}

* {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body.blockwise-body {
    margin: 0;
    min-height: 100vh;
    font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
    background:
        radial-gradient(circle at top left, rgba(217, 177, 93, 0.16), transparent 26%),
        radial-gradient(circle at bottom right, rgba(223, 230, 239, 0.08), transparent 28%),
        linear-gradient(135deg, #07090b 0%, #101418 28%, #0d1014 100%);
    color: var(--text);
}

img {
    max-width: 100%;
    display: block;
}

a {
    color: inherit;
    text-decoration: none;
}

button,
input,
textarea,
select {
    font: inherit;
}

/* A select sized by a long option label must not push its (often flex)
   label past the card on phones. */
label,
input,
textarea,
select {
    min-width: 0;
    max-width: 100%;
}

.app-shell {
    display: flex;
    min-height: 100vh;
    max-width: 1600px;
    margin: 0 auto;
    padding: 22px;
    gap: 22px;
}

.sidebar {
    width: 285px;
    background: rgba(13, 16, 20, 0.85);
    border: 1px solid var(--border);
    border-radius: 24px;
    box-shadow: var(--shadow);
    backdrop-filter: blur(20px);
    display: flex;
    flex-direction: column;
    padding: 18px 16px 20px;
    position: sticky;
    top: 20px;
    height: calc(100vh - 44px);
}

.brand-panel {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 12px 18px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 16px;
}

.brand-mark {
    width: 58px;
    height: 58px;
    border-radius: 18px;
    background: linear-gradient(135deg, #161a20 0%, #080b0d 100%);
    border: 2px solid rgba(217, 177, 93, 0.8);
    box-shadow: inset 0 0 14px rgba(255,255,255,0.05);
    overflow: hidden;
    flex-shrink: 0;
}

.brand-text {
    min-width: 0;
}

.brand-name {
    font-size: 1.45rem;
    line-height: 1.1;
    font-weight: 800;
    letter-spacing: -0.06em;
    white-space: nowrap;
}

.brand-silver {
    color: var(--silver);
}

.brand-gold {
    color: var(--primary);
}

.brand-subtitle {
    margin-top: 6px;
    color: var(--muted);
    font-size: 0.68rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 8px;
}

.nav-group {
    border-bottom: 1px solid var(--color-border);
    padding-bottom: 6px;
}

.nav-group-title {
    padding: 10px 12px;
    border-radius: 10px;
    color: var(--color-text);
    font-weight: 700;
    cursor: pointer;
}

.nav-group-title:hover,
.nav-group-title:focus-visible {
    background: var(--color-background);
}

.nav-group-items {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 4px 0 4px 10px;
}

.nav-group-items .nav-item {
    padding: 10px 12px;
    font-size: .9rem;
}

.nav-item,
.sidebar-logout {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 12px 14px;
    border-radius: 14px;
    border: 1px solid transparent;
    background: transparent;
    color: var(--text);
    transition: 0.2s ease;
}

.nav-item:hover,
.nav-item.active {
    background: linear-gradient(135deg, rgba(217, 177, 93, 0.16), rgba(223, 230, 239, 0.05));
    border-color: rgba(217, 177, 93, 0.34);
    box-shadow: inset 0 0 0 1px rgba(217, 177, 93, 0.08);
}

.nav-item.disabled {
    opacity: 0.46;
    cursor: not-allowed;
    background: rgba(255,255,255,0.02);
}

.nav-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    color: var(--primary-strong);
    font-size: 0.96rem;
}

.sidebar-footer {
    margin-top: auto;
    padding-top: 16px;
    border-top: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.user-chip {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    background: rgba(255,255,255,0.03);
    border: 1px solid var(--border);
    border-radius: 14px;
}

.user-avatar,
.user-avatar-fallback {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}

.user-avatar-fallback {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, rgba(217,177,93,0.25), rgba(223,230,239,0.18));
    color: var(--text);
    font-weight: 700;
}

.user-chip strong,
.user-chip small {
    display: block;
}

.user-chip small {
    color: var(--muted);
    margin-top: 3px;
}

.sidebar-logout {
    justify-content: center;
    background: linear-gradient(135deg, rgba(217,177,93,0.18), rgba(217,177,93,0.06));
    border: 1px solid rgba(217,177,93,0.28);
    color: var(--text);
    cursor: pointer;
}

.main-panel {
    flex: 1;
    min-width: 0;
    background: rgba(14, 17, 20, 0.38);
    border: 1px solid var(--border);
    border-radius: 26px;
    box-shadow: var(--shadow);
    backdrop-filter: blur(14px);
    padding: 22px 24px 26px;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    margin-bottom: 20px;
    padding-bottom: 18px;
    border-bottom: 1px solid var(--border);
}

.eyebrow {
    color: var(--primary-strong);
    letter-spacing: 0.14em;
    text-transform: uppercase;
    font-size: 0.68rem;
    margin-bottom: 8px;
}

.page-title {
    margin: 0;
    font-size: clamp(2rem, 2vw, 2.6rem);
    letter-spacing: -0.04em;
    color: var(--silver);
}

.status-pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 8px 12px;
    border-radius: 999px;
    background: rgba(56, 211, 159, 0.14);
    border: 1px solid rgba(56, 211, 159, 0.32);
    color: #bff6e2;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.status-pill.muted {
    background: rgba(163, 173, 191, 0.08);
    border-color: rgba(163,173,191,0.2);
    color: var(--muted);
}

.flash-stack {
    display: grid;
    gap: 10px;
    margin-bottom: 20px;
}

.flash-message {
    border-radius: 14px;
    border: 1px solid var(--border);
    padding: 12px 14px;
    background: rgba(255,255,255,0.03);
    color: var(--text);
}

.flash-message.success {
    border-color: rgba(56, 211, 159, 0.36);
    background: rgba(56, 211, 159, 0.1);
}

.flash-message.error {
    border-color: var(--color-accent-line);
    background: var(--color-danger-soft);
}

.flash-message.warning {
    border-color: rgba(241, 199, 91, 0.32);
    background: rgba(241, 199, 91, 0.08);
}

.metrics-grid,
.two-column,
.grid,
.home-layout {
    display: grid;
    gap: 20px;
}

.metrics-grid {
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    margin-bottom: 22px;
}

.metric-card,
.panel,
.card {
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: 20px;
    box-shadow: var(--shadow);
    backdrop-filter: blur(10px);
}

.metric-card {
    padding: 18px 20px;
}

.metric-label {
    /* Templates use both <div> and <span>/<strong>; the label always sits above its value. */
    display: block;
    color: var(--muted);
    letter-spacing: 0.08em;
    text-transform: uppercase;
    font-size: 0.7rem;
    margin-bottom: 12px;
}

.metric-value {
    display: block;
    overflow-wrap: anywhere;
    font-size: clamp(1.75rem, 2vw, 2.5rem);
    font-weight: 700;
    color: var(--silver);
}

.grid,
.home-layout {
    grid-template-columns: 1.4fr 0.9fr;
}

.panel,
.card {
    padding: 18px 20px;
}

.panel h2,
.card h2 {
    margin: 0 0 16px;
    font-size: 1.05rem;
    color: var(--silver);
}

.panel p,
.card p {
    margin: 0 0 12px;
    line-height: 1.6;
    color: #dce4f7;
}

.small-label {
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--primary-strong);
    margin-bottom: 8px;
}

.button-row {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 16px;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 14px;
    border-radius: 12px;
    background: linear-gradient(135deg, rgba(217,177,93,0.22), rgba(217,177,93,0.11));
    border: 1px solid rgba(217,177,93,0.3);
    color: var(--text);
    font-weight: 600;
    transition: transform 0.2s ease, border-color 0.2s ease;
}

.btn:hover {
    transform: translateY(-1px);
    border-color: rgba(217,177,93,0.46);
}

.btn.secondary {
    background: rgba(255,255,255,0.04);
    border-color: var(--border);
}

.message-list,
.link-list,
.vote-list,
.repair-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.message-list li,
.vote-list li,
.repair-list li {
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
    color: #dfe8ff;
}

.message-list li:last-child,
.vote-list li:last-child,
.repair-list li:last-child {
    border-bottom: none;
}

.badge {
    display: inline-block;
    margin-left: 8px;
    padding: 4px 8px;
    border-radius: 999px;
    background: rgba(217,177,93,0.12);
    border: 1px solid rgba(217,177,93,0.35);
    color: var(--primary-strong);
    font-size: 0.68rem;
    font-weight: 700;
}

.money {
    color: var(--success);
    font-weight: 700;
}

.expense {
    color: var(--danger);
    font-weight: 700;
}

.info-box {
    margin-top: 16px;
    padding: 14px 16px;
    border-radius: 14px;
    background: rgba(217,177,93,0.08);
    border: 1px solid rgba(217,177,93,0.26);
}

@media (max-width: 1040px) {
    .app-shell {
        flex-direction: column;
        padding: 14px;
    }

    .sidebar {
        width: 100%;
        position: static;
        height: auto;
    }

    .main-panel {
        padding: 18px;
    }
}

@media (max-width: 720px) {
    .grid,
    .home-layout,
    .two-column {
        grid-template-columns: 1fr;
    }

    .topbar {
        flex-direction: column;
        align-items: flex-start;
    }

    .brand-panel {
        padding-top: 8px;
    }
}

.language-switcher { display: grid; gap: var(--space-2, .5rem); }
.language-switcher label { color: var(--color-muted, #64748b); font-size: .78rem; font-weight: 700; }
.language-switcher select { width: 100%; }

/* REMIOX UI foundation: semantic tokens and responsive components. */
:root {
    --color-primary: #2563eb;
    --color-primary-hover: #1d4ed8;
    --color-secondary: #475569;
    --color-background: #f5f7fb;
    --color-surface: #ffffff;
    --color-text: #172033;
    --color-muted: #64748b;
    --color-success: #15803d;
    --color-warning: #b45309;
    --color-danger: #b91c1c;
    --color-info: #0369a1;
    --color-border: #dbe3ef;
    --space-1: .25rem;
    --space-2: .5rem;
    --space-3: .75rem;
    --space-4: 1rem;
    --space-5: 1.5rem;
    --space-6: 2rem;
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --shadow-sm: 0 2px 8px rgba(15, 23, 42, .06);
    --shadow-md: 0 10px 28px rgba(15, 23, 42, .10);
}

body.blockwise-body {
    background: var(--color-background);
    color: var(--color-text);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
}

.app-shell { max-width: 1680px; gap: var(--space-5); padding: var(--space-5); }
.sidebar, .main-panel { background: var(--color-surface); border: 1px solid var(--color-border); box-shadow: var(--shadow-md); backdrop-filter: none; }
.sidebar { border-radius: var(--radius-lg); padding: var(--space-4); }
.main-panel { border-radius: var(--radius-lg); padding: var(--space-6); }
.brand-panel { border-color: var(--color-border); }
.brand-mark { background: #eff6ff; border-color: #93c5fd; box-shadow: none; }
.brand-name { letter-spacing: -.04em; }
.brand-silver, .page-title, .metric-value, .panel h2, .card h2 { color: var(--color-text); }
.brand-gold, .eyebrow, .small-label { color: var(--color-primary); }
.brand-subtitle, .muted, .metric-label { color: var(--color-muted); }
.nav-item, .sidebar-logout { color: var(--color-secondary); border-radius: var(--radius-md); }
.nav-item:hover, .nav-item.active { color: var(--color-primary); background: #eff6ff; border-color: #bfdbfe; box-shadow: none; }
.nav-item.disabled { color: #94a3b8; background: transparent; }
.nav-icon { color: var(--color-primary); }
.topbar { border-color: var(--color-border); }
.status-pill { background: #dcfce7; border-color: #86efac; color: var(--color-success); }
.status-pill.muted { background: #f1f5f9; border-color: var(--color-border); color: var(--color-muted); }
.metric-card, .panel, .card { background: var(--color-surface); border-color: var(--color-border); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); backdrop-filter: none; }
.panel p, .card p, .message-list li, .vote-list li, .repair-list li { color: var(--color-secondary); }
.btn { background: var(--color-primary); border-color: var(--color-primary); color: #fff; border-radius: var(--radius-md); box-shadow: var(--shadow-sm); }
.btn:hover { background: var(--color-primary-hover); border-color: var(--color-primary-hover); transform: none; }
.btn.secondary { background: #fff; border-color: var(--color-border); color: var(--color-secondary); }
.btn.danger, button.danger { background: var(--color-danger-soft); border-color: var(--color-accent-line); color: var(--color-danger); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--color-primary); box-shadow: none; }
button, input, textarea, select { border-radius: var(--radius-sm); }
input, textarea, select { border: 1px solid var(--color-border); background: #fff; color: var(--color-text); padding: .65rem .75rem; }
input:focus, textarea:focus, select:focus, button:focus-visible, a:focus-visible { outline: 3px solid rgba(37, 99, 235, .25); outline-offset: 2px; }
table { width: 100%; border-collapse: collapse; background: var(--color-surface); }
th { text-align: left; color: var(--color-muted); font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; background: #f8fafc; }
th, td { padding: .75rem .85rem; border-bottom: 1px solid var(--color-border); }
tbody tr:hover { background: #f8fafc; }
.table-responsive, .panel table, .card table { overflow-x: auto; }
.badge { background: #eff6ff; border-color: #bfdbfe; color: var(--color-primary); margin-left: 0; }
.flash-message { background: #f8fafc; border-color: var(--color-border); color: var(--color-text); }
.flash-message.success { background: #f0fdf4; border-color: #bbf7d0; color: var(--color-success); }
.flash-message.warning { background: #fffbeb; border-color: #fde68a; color: var(--color-warning); }
.flash-message.error { background: var(--color-danger-soft); border-color: var(--color-accent-line); color: var(--color-danger); }
.mobile-nav-toggle { display: none; }
.error-page { max-width: 32rem; margin: 10vh auto; padding: 2.5rem; text-align: center; }
.onboarding-stepper { display: grid; grid-template-columns: repeat(9, minmax(0, 1fr)); gap: .5rem; padding: 0; margin: 1.5rem 0; list-style: none; }
.onboarding-stepper li { min-height: 2.5rem; padding: .55rem .4rem; border-top: 3px solid var(--color-border); color: var(--color-muted); font-size: .78rem; text-align: center; }
.onboarding-stepper li.is-current { border-color: var(--color-primary); color: var(--color-primary); font-weight: 700; }
.onboarding-stepper a { color: inherit; }

/* Stage 7B.1 dashboard components: shared, bounded and mobile-first. */
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
.dashboard-hero { display: flex; align-items: center; justify-content: space-between; gap: var(--space-5); margin-bottom: var(--space-5); }
.dashboard-hero h2 { margin: .25rem 0 .4rem; font-size: clamp(1.35rem, 2vw, 1.8rem); }
.scope-summary, .panel-heading, .dashboard-filters { display: flex; align-items: center; gap: .75rem; flex-wrap: wrap; }
.panel-heading { justify-content: space-between; margin-bottom: .8rem; }
.panel-heading h2 { margin-bottom: 0; }
.dashboard-filters { align-items: end; }
.dashboard-filters label { display: flex; min-width: 9rem; flex: 1 1 9rem; flex-direction: column; gap: .35rem; color: var(--color-secondary); font-size: .84rem; font-weight: 600; }
.dashboard-filters .btn { flex: 0 0 auto; }
.dashboard-kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--space-4); margin: var(--space-5) 0; }
.dashboard-kpis .metric-card { min-width: 0; }
.metric-card-accent { border-top: 3px solid var(--color-primary); }
.metric-card-success { border-top: 3px solid var(--color-success); }
.metric-card-warning { border-top: 3px solid var(--color-warning); }
.dashboard-columns { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-5); margin-bottom: var(--space-5); }
.attention-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--space-4); margin-bottom: var(--space-5); }
.attention-grid > div { padding: .9rem; border-radius: var(--radius-md); background: #f8fafc; border: 1px solid var(--color-border); }
.attention-value { display: block; margin-top: .35rem; font-size: 1.4rem; color: var(--color-text); }
.trend-chart { min-height: 14rem; display: flex; align-items: stretch; gap: .4rem; padding: 1rem .5rem .25rem; border: 1px solid var(--color-border); border-radius: var(--radius-md); background: linear-gradient(180deg, #f8fafc, #fff); }
.trend-column { flex: 1 1 0; min-width: 1.8rem; display: flex; align-items: stretch; }
.trend-bars { position: relative; display: flex; align-items: end; justify-content: center; gap: 2px; width: 100%; min-height: 11rem; padding-bottom: 1.5rem; }
.trend-bar { display: block; width: 38%; min-height: 3px; border-radius: 4px 4px 0 0; transition: height .2s ease; }
.trend-label { position: absolute; bottom: 0; left: 50%; transform: translateX(-50%) rotate(-35deg); transform-origin: top left; white-space: nowrap; font-size: .63rem; color: var(--color-muted); }
.accessible-chart-table { margin-top: .85rem; font-size: .82rem; }
.accessible-chart-table caption { text-align: left; color: var(--color-muted); margin-bottom: .4rem; }
.status-badge { display: inline-flex; align-items: center; border-radius: 999px; padding: .2rem .55rem; font-size: .76rem; font-weight: 700; }
.status-success { background: #dcfce7; color: var(--color-success); }
.status-warning { background: #fef3c7; color: var(--color-warning); }
.status-danger { background: var(--color-danger-soft); color: var(--color-danger); }
.empty-state { color: var(--color-muted); text-align: center; padding: 1.25rem !important; }
.table-responsive { overflow-x: auto; }
.content-card, main.container { max-width: none; margin: 0; padding: 0; }
.resident-portal { display: grid; min-width: 0; gap: var(--space-5); }
.resident-portal > * { min-width: 0; }
.resident-portal > .topbar { padding: var(--space-4); border: 1px solid var(--color-border); border-radius: var(--radius-lg); background: #f8fafc; }
.resident-portal .card { overflow: visible; }
.resident-portal .table-responsive { max-width: 100%; }
.resident-portal .avatar-pill { display: inline-flex; align-items: center; gap: .5rem; padding: .35rem .7rem .35rem .4rem; border: 1px solid var(--color-border); border-radius: 999px; background: #eff6ff; }
.resident-portal .avatar-thumb, .resident-portal .avatar-fallback { width: 2rem; height: 2rem; border-radius: 50%; }
.resident-portal .avatar-fallback { display: inline-flex; align-items: center; justify-content: center; background: var(--color-primary); color: #fff; font-weight: 700; }
.resident-portal .pill { display: inline-flex; align-items: center; padding: .3rem .65rem; border-radius: 999px; background: #eff6ff; color: var(--color-primary); font-size: .78rem; font-weight: 700; }
.resident-portal .list { list-style: none; padding: 0; margin: 0; }
.resident-portal .list li { padding: .8rem 0; border-bottom: 1px solid var(--color-border); }
.resident-portal-v2 { scroll-behavior: smooth; }
.resident-hero { display: flex; align-items: end; justify-content: space-between; gap: var(--space-5); padding: var(--space-5); border: 1px solid var(--color-border); border-radius: var(--radius-lg); background: linear-gradient(135deg, #eff6ff, #fff); }
.resident-hero h2 { margin: .25rem 0; }
.resident-scope-form, .inline-filter { display: flex; align-items: end; gap: .65rem; flex-wrap: wrap; }
.resident-scope-form label, .inline-filter label { display: flex; flex-direction: column; gap: .35rem; color: var(--color-secondary); font-size: .84rem; font-weight: 700; }
.resident-scope-form select { min-width: min(22rem, 80vw); }
.resident-dashboard-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-5); }
.resident-feed { display: grid; gap: .75rem; margin: 0 0 var(--space-4); padding: 0; list-style: none; }
.resident-feed li { display: flex; align-items: flex-start; justify-content: space-between; gap: .75rem; flex-wrap: wrap; padding: .75rem 0; border-bottom: 1px solid var(--color-border); }
.resident-feed li p { flex-basis: 100%; margin: 0; }
.resident-feed small { color: var(--color-muted); }
.resident-profile-form { display: grid; gap: var(--space-4); }
.resident-profile-form .grid,
.resident-profile-form .grid > *,
.resident-profile-form fieldset,
.resident-profile-form input,
.resident-profile-form textarea,
.resident-profile-form select { min-width: 0; max-width: 100%; }
.resident-profile-form label { display: flex; flex-direction: column; gap: .35rem; color: var(--color-secondary); font-weight: 600; }
.resident-profile-form fieldset { margin: 0; padding: var(--space-4); border: 1px solid var(--color-border); border-radius: var(--radius-md); }
.resident-profile-form legend { padding: 0 .35rem; color: var(--color-text); font-weight: 700; }
.resident-section-page { display: grid; gap: var(--space-5); }
.resident-empty-account { max-width: 44rem; text-align: center; }
.main-panel > h1, .main-panel > main > h1, .main-panel > .content-card > h1 { margin: 0 0 var(--space-5); color: var(--color-text); font-size: clamp(1.5rem, 2.4vw, 2.1rem); }
.content-card { padding: var(--space-5); background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); }
.content-card > form, .main-panel > form { display: flex; align-items: end; flex-wrap: wrap; gap: .75rem; margin-bottom: var(--space-5); }
.content-card > form label, .main-panel > form label { display: flex; flex: 1 1 10rem; flex-direction: column; gap: .35rem; color: var(--color-secondary); font-weight: 600; font-size: .84rem; }
.content-card table, .main-panel > table { margin-top: var(--space-4); }
.notification { margin: 0 0 var(--space-3); padding: var(--space-4); border: 1px solid var(--color-border); border-radius: var(--radius-md); background: var(--color-surface); box-shadow: var(--shadow-sm); }
.notification--unread { border-left: 4px solid var(--color-primary); background: #eff6ff; }
.notification h2 { margin-bottom: .35rem; font-size: 1rem; }
.notification small { color: var(--color-muted); }
.main-panel dl { display: grid; grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr)); gap: .75rem; margin: var(--space-5) 0; }
.main-panel dl dt, .main-panel dl dd { margin: 0; padding: .75rem; border: 1px solid var(--color-border); }
.main-panel dl dt { color: var(--color-muted); font-size: .8rem; }
.main-panel dl dd { font-size: 1.2rem; font-weight: 700; color: var(--color-text); }
.main-panel ul:not(.message-list):not(.link-list):not(.vote-list):not(.repair-list) { padding-left: 1.25rem; }

@media (prefers-reduced-motion: reduce) {
    .trend-bar, .btn, * { transition-duration: .01ms !important; animation-duration: .01ms !important; scroll-behavior: auto !important; }
}

@media (max-width: 720px) {
    .app-shell { padding: var(--space-3); }
    .main-panel { padding: var(--space-4); }
    .brand-panel { padding: .5rem .25rem 1rem; }
    .page-title { font-size: 1.65rem; }
    table { min-width: 620px; }
    .panel, .card { overflow-x: auto; }
    .onboarding-stepper { display: flex; overflow-x: auto; justify-content: flex-start; }
    .onboarding-stepper li { min-width: 6.5rem; }
    .dashboard-hero, .dashboard-columns { grid-template-columns: 1fr; flex-direction: column; align-items: flex-start; }
    .dashboard-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .75rem; }
    .attention-grid { grid-template-columns: 1fr; }
    .trend-chart { min-height: 12rem; }
    .resident-portal .topbar > div { min-width: 0; max-width: 100%; }
    .resident-portal .pill { max-width: 100%; white-space: normal; overflow-wrap: anywhere; }
    .resident-hero { align-items: stretch; flex-direction: column; }
    .resident-scope-form select { min-width: 0; width: 100%; }
    .resident-dashboard-grid { grid-template-columns: 1fr; }
    .resident-kpis, .resident-finance-kpis { grid-template-columns: 1fr; }
}

/* Keep phone navigation independent from the saved desktop preference. */
@media (max-width: 767px) {
    .mobile-nav-toggle { display: block; width: 100%; margin-bottom: var(--space-2); padding: .65rem; border: 1px solid var(--color-border); background: #f8fafc; color: var(--color-secondary); }
    .sidebar-nav { display: none; }
    .sidebar-nav.is-open { display: flex; }
}

.sidebar-toggle { display: none; }
.main-panel > .topbar { flex-wrap: wrap; }
.topbar-heading { display: flex; align-items: center; gap: .75rem; min-width: 0; }
.topbar-heading > div { min-width: 0; }
.topbar-actions { display: flex; align-items: center; gap: .75rem; flex-wrap: wrap; }

@media screen and (min-width: 768px) {
    .sidebar-ready .app-shell { transition: gap 180ms ease; }
    .sidebar-ready .sidebar { transition: width 180ms ease, max-height 180ms ease, padding 180ms ease, border-width 180ms ease, opacity 180ms ease; }
    .sidebar-collapsed .app-shell { gap: 0; }
    .sidebar-collapsed .sidebar { opacity: 0; visibility: hidden; }
    .sidebar-toggle {
        display: inline-flex;
        align-items: center;
        gap: .5rem;
        flex-shrink: 0;
        padding: .6rem .75rem;
        border: 1px solid var(--color-border);
        background: #f8fafc;
        color: var(--color-secondary);
        cursor: pointer;
    }
    .sidebar-toggle:hover { background: #eff6ff; color: var(--color-primary); }
}

@media screen and (min-width: 1041px) {
    .sidebar { flex: 0 0 auto; width: 285px; min-width: 0; overflow-x: hidden; }
    /* Keep the logo and links at their natural width during the transition. */
    .sidebar > * { min-width: 251px; }
    .sidebar-collapsed .sidebar { width: 0; padding-inline: 0; border-inline-width: 0; }
}

@media screen and (min-width: 768px) and (max-width: 1040px) {
    /* Preserve the existing stacked tablet layout and its full-width content. */
    .sidebar { max-height: calc(100vh - 2 * var(--space-5)); }
    .sidebar-collapsed .sidebar { max-height: 0; padding-block: 0; border-block-width: 0; overflow: hidden; }
    .sidebar-toggle-label { display: none; }
}

@media (prefers-reduced-motion: reduce) {
    .sidebar-ready .app-shell, .sidebar-ready .sidebar { transition: none !important; }
}

/* Data tables (distribution, balances, debtors, billing): rounded, softly alternating rows. */
.reseda-table {
    --reseda-head: #EEF0F4;
    --reseda-odd: #FFFFFF;
    --reseda-even: #F7F8FA;
    --reseda-hover: #E6F6EF;
    --reseda-line: #E3E6EB;
    --reseda-text: #14171F;
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    border: 1px solid var(--reseda-line);
    border-radius: 14px;
    overflow: hidden;
    background: var(--reseda-odd);
    color: var(--reseda-text);
}
.reseda-table th,
.reseda-table td { padding: .7rem .9rem; border-bottom: 1px solid var(--reseda-line); text-align: left; }
.reseda-table thead th,
.reseda-table tr:first-child:has(> th + th) > th {
    background: var(--reseda-head);
    font-size: .78rem;
    letter-spacing: .04em;
    text-transform: uppercase;
    font-weight: 700;
}
.reseda-table tr:nth-child(odd) > td { background: var(--reseda-odd); }
.reseda-table tr:nth-child(even) > td { background: var(--reseda-even); }
.reseda-table tr:hover > td { background: var(--reseda-hover); }
.reseda-table tr.is-own > td { background: #E6F6EF; font-weight: 600; }
.reseda-table tr:last-child > td { border-bottom: 0; }
.reseda-table tfoot th,
.reseda-table tfoot td { background: var(--reseda-head); font-weight: 700; border-bottom: 0; border-top: 2px solid var(--reseda-line); }
.reseda-table .badge { border-radius: 999px; }
.reseda-table tbody th[scope="row"] { background: var(--reseda-head); }

/* Themes from the approved mobile reference palette (templates/mobile, theme.css):
   light by day (default) and navy-black by night (data-theme="dark"); the choice is kept per browser.
   Light primary is the darker reference green so white button text stays at 4.5:1. */
:root {
    --color-primary: #0B8457;
    --color-primary-hover: #086B46;
    --color-secondary: #5E6673;
    --color-background: #F4F5F7;
    --color-surface: #FFFFFF;
    --color-text: #14171F;
    --color-muted: #5E6673;
    --color-border: #E3E6EB;
    --color-soft: #EEF0F4;
    --color-accent-soft: #E6F6EF;
    --color-accent-line: #BFE6D4;
    --color-input: #F7F8FA;
    --color-success: #00843A;
    --color-danger: #E0001B;
    --color-warning: #C2410C;
    --color-warning-soft: #FFEDD5;
    --color-danger-soft: #FDE8EA;
    --color-on-primary: #ffffff;
    --color-strong-surface: #0F131C;
    --color-strong-item: #1B212D;
    --color-on-strong: #ffffff;
    --color-on-strong-muted: #C9CED6;
    --shadow-sm: 0 2px 8px rgba(20, 23, 31, .06);
    --shadow-md: 0 10px 28px rgba(20, 23, 31, .10);
}
:root[data-theme="dark"] {
    --color-primary: #2EBD85;
    --color-primary-hover: #5FD3A4;
    --color-secondary: #B7BDC7;
    --color-background: #0B0E15;
    --color-surface: #161A23;
    --color-text: #EAECEF;
    --color-muted: #8B93A1;
    --color-border: #222936;
    --color-soft: #1B212D;
    --color-accent-soft: #19332F;
    --color-accent-line: #24564A;
    --color-input: #0F131C;
    --color-success: #2EBD85;
    --color-danger: #F6465D;
    --color-warning: #FB923C;
    --color-warning-soft: #3B1F0E;
    --color-danger-soft: #38212C;
    --color-on-primary: #08130E;
    --color-strong-surface: #0F131C;
    --color-strong-item: #1B212D;
    --color-on-strong: #EAECEF;
    --color-on-strong-muted: #8B93A1;
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, .40);
    --shadow-md: 0 10px 28px rgba(0, 0, 0, .50);
    color-scheme: dark;
}
:root[data-theme="dark"] .reseda-table {
    --reseda-head: #1B212D;
    --reseda-odd: #161A23;
    --reseda-even: #1B212D;
    --reseda-hover: #222936;
    --reseda-line: #2B3341;
    --reseda-text: #EAECEF;
}
:root[data-theme="dark"] .reseda-table tr.is-own > td { background: #19332F; }
input, textarea, select { background: var(--color-input); color: var(--color-text); }
th { background: var(--color-soft); }
tbody tr:hover { background: var(--color-soft); }
.btn { color: #fff; }
:root[data-theme="dark"] .btn { color: var(--color-on-primary); }
:root[data-theme="dark"] .btn.danger { color: var(--color-danger); }
.btn.secondary { background: var(--color-surface); }
.badge, .resident-portal .pill { background: var(--color-accent-soft); border-color: var(--color-accent-line); color: var(--color-primary); }
.nav-item:hover, .nav-item.active { background: var(--color-accent-soft); border-color: var(--color-accent-line); }
.brand-mark { background: var(--color-accent-soft); border-color: var(--color-accent-line); }
.flash-message, .attention-grid > div, .resident-portal > .topbar, .mobile-nav-toggle { background: var(--color-soft); }
.notification--unread, .resident-portal .avatar-pill { background: var(--color-accent-soft); }
.resident-hero { background: linear-gradient(135deg, var(--color-accent-soft), var(--color-surface)); }
.trend-chart { background: linear-gradient(180deg, var(--color-soft), var(--color-surface)); }
.status-pill.muted { background: var(--color-soft); }
:root[data-theme="dark"] .flash-message.success, :root[data-theme="dark"] .status-success, :root[data-theme="dark"] .status-pill { background: #19332F; border-color: #24564A; }
:root[data-theme="dark"] .flash-message.warning, :root[data-theme="dark"] .status-warning { background: #3B1F0E; border-color: #9A3412; }
:root[data-theme="dark"] .flash-message.error, :root[data-theme="dark"] .status-danger { background: var(--color-danger-soft); border-color: var(--color-accent-line); }
:root .flash-message.error, :root .status-danger, :root .status-pill.danger { background: var(--color-danger-soft); border-color: var(--color-accent-line); color: var(--color-danger); }
:root .flash-message.warning, :root .status-warning { background: var(--color-warning-soft); border-color: #FDBA74; color: var(--color-warning); }
@media (min-width: 768px) { .sidebar-toggle { background: var(--color-soft); } .sidebar-toggle:hover { background: var(--color-accent-soft); } }
.theme-toggle {
    border: 1px solid var(--color-border); background: var(--color-surface); color: var(--color-text);
    border-radius: 999px; padding: .35rem .75rem; font: inherit; font-size: .85rem; cursor: pointer;
}
.theme-toggle:hover { background: var(--color-accent-soft); }
/* Pages that define their own palette (dashboard, cashier portal, documents) follow the theme. */
:root :is(.management-dashboard, .cashier-portal, .entrance-documents) {
    --bg: var(--color-background);
    --card: var(--color-surface);
    --primary: var(--color-primary);
    --primary-soft: var(--color-accent-soft);
    --text: var(--color-text);
    --muted: var(--color-muted);
    --line: var(--color-border);
    --success: var(--color-success);
    --warning: var(--color-warning);
    --danger: var(--color-danger);
    background: transparent;
    color: var(--color-text);
}
:root :is(.management-dashboard, .cashier-portal, .entrance-documents) .card { box-shadow: var(--shadow-sm); border: 1px solid var(--color-border); }
:root :is(.management-dashboard, .cashier-portal, .entrance-documents) :is(td, label) { color: var(--color-text); }
:root :is(.management-dashboard, .cashier-portal, .entrance-documents) th { color: var(--color-muted); }
:root :is(.management-dashboard, .cashier-portal, .entrance-documents) .tag { background: var(--color-accent-soft); color: var(--color-primary); }
:root[data-theme="dark"] :is(.management-dashboard, .cashier-portal, .entrance-documents) .btn { color: var(--color-on-primary); }
:root[data-theme="dark"] .cashier-portal .status.paid { background: #19332F; }
:root[data-theme="dark"] .cashier-portal .status.unpaid { background: var(--color-danger-soft); }
/* Dark theme: plain tables get readable text and softly alternating grey rows. */
:root[data-theme="dark"] table:not(.reseda-table) td { color: var(--color-text); }
:root[data-theme="dark"] table:not(.reseda-table) tbody tr:nth-child(odd) > td { background: var(--color-surface); }
:root[data-theme="dark"] table:not(.reseda-table) tbody tr:nth-child(even) > td { background: var(--color-soft); }
:root[data-theme="dark"] table:not(.reseda-table) th { color: var(--color-muted); }
:root a.back-link { background: var(--color-surface); border-color: var(--color-border); color: var(--color-text); }
:root a.back-link:hover { background: var(--color-accent-soft); }
/* Sensitive audit rows: a warm amber highlight instead of red in both themes. */
.reseda-table tr.audit-sensitive > td { background: #FFF3D6; }
:root[data-theme="dark"] .reseda-table tr.audit-sensitive > td { background: #33280F; }
.reseda-table tr.billing-difference td { background: var(--color-accent-soft); }

/* Home page: livelier greens with a warm golden accent (day theme only). */
:root:not([data-theme="dark"]) .marketing-home {
    --vivid-deep: #2f6b2a;
    --vivid-green: #4f9a3a;
    --vivid-lime: #9cc84a;
    --vivid-gold: #e0b43c;
    --vivid-mint: #e3f1d2;
}
:root:not([data-theme="dark"]) .marketing-home .hero::before { background: radial-gradient(circle at 30% 30%, #cfe8b0, #b6dd8a 60%, transparent 70%); opacity: .9; }
:root:not([data-theme="dark"]) .marketing-home .hero::after { background: radial-gradient(circle at 60% 40%, #f3e2a6, #ecd27a 55%, transparent 70%); opacity: .7; }
:root:not([data-theme="dark"]) .marketing-home .hero-kicker,
:root:not([data-theme="dark"]) .marketing-home .section-eyebrow {
    background: linear-gradient(90deg, var(--vivid-green), var(--vivid-lime)); color: #fff; border-color: transparent;
}
:root:not([data-theme="dark"]) .marketing-home h1 span,
:root:not([data-theme="dark"]) .marketing-home .hero h1 em,
:root:not([data-theme="dark"]) .marketing-home .accent {
    background: linear-gradient(90deg, var(--vivid-green), var(--vivid-gold)); -webkit-background-clip: text; background-clip: text; color: transparent;
}
:root:not([data-theme="dark"]) .marketing-home .marketing-btn:not(.secondary) {
    background: linear-gradient(135deg, var(--vivid-deep), var(--vivid-green)); border-color: var(--vivid-deep); color: #fff;
    box-shadow: 0 8px 20px rgba(47, 107, 42, .28);
}
:root:not([data-theme="dark"]) .marketing-home .marketing-btn.secondary { border-color: var(--vivid-green); color: var(--vivid-deep); }
:root:not([data-theme="dark"]) .marketing-home .dashboard-preview { box-shadow: 0 24px 48px rgba(47, 107, 42, .18); border-color: #b9d99a; }
:root:not([data-theme="dark"]) .marketing-home .preview-status { background: var(--vivid-lime); color: #1f3d18; }
:root:not([data-theme="dark"]) .marketing-home .preview-stat { border-top: 4px solid var(--vivid-green); }
:root:not([data-theme="dark"]) .marketing-home .preview-stat:nth-child(2) { border-top-color: var(--vivid-lime); }
:root:not([data-theme="dark"]) .marketing-home .preview-stat:nth-child(3) { border-top-color: var(--vivid-gold); }
:root:not([data-theme="dark"]) .marketing-home .chart-bar { background: linear-gradient(180deg, var(--vivid-green), var(--vivid-lime)); }
:root:not([data-theme="dark"]) .marketing-home .chart-bar:nth-child(3n) { background: linear-gradient(180deg, var(--vivid-gold), #f1d888); }
:root:not([data-theme="dark"]) .marketing-home .service-icon,
:root:not([data-theme="dark"]) .marketing-home .step-number { background: linear-gradient(135deg, var(--vivid-green), var(--vivid-lime)); color: #fff; }
:root:not([data-theme="dark"]) .marketing-home .service-card:nth-child(3n+2) .service-icon { background: linear-gradient(135deg, var(--vivid-gold), #f1d888); color: #3d2f08; }
:root:not([data-theme="dark"]) .marketing-home .featured { border-color: var(--vivid-green); box-shadow: 0 16px 36px rgba(47, 107, 42, .2); }
:root:not([data-theme="dark"]) .marketing-home .pricing-badge { background: var(--vivid-gold); color: #3d2f08; }
:root:not([data-theme="dark"]) .marketing-home .marketing-cta { background: linear-gradient(135deg, var(--vivid-deep), var(--vivid-green) 60%, #6fae47); color: #fff; }
/* Dark theme: secondary buttons keep light text (the dark-text rule is for filled buttons). */
:root[data-theme="dark"] .btn.secondary,
:root[data-theme="dark"] button.btn.secondary { color: var(--color-text); background: var(--color-soft); border-color: var(--color-border); }
:root[data-theme="dark"] .btn.secondary:hover { background: var(--color-accent-soft); }
/* The notifications envelope is a visible pill button, like the theme toggle. */
:root .notification-envelope {
    gap: .45rem; padding: .35rem .8rem; border: 1px solid var(--color-border); border-radius: 999px;
    background: var(--color-surface); color: var(--color-text); font-size: .95rem;
}
:root .notification-envelope:hover { background: var(--color-accent-soft); border-color: var(--color-accent-line); }
.notification-envelope .envelope-icon { font-size: 1.45rem; line-height: 1; color: var(--color-primary); }
.notification-envelope .envelope-label { font-weight: 600; }
@media (max-width: 600px) { .notification-envelope .envelope-label { display: none; } }
