@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700;800&display=swap');

:root {
    --sidebar-width: 288px;
    --sidebar-collapsed: 78px;
    --topbar-height: 72px;

    --primary: #00a86b;
    --primary-dark: #008f5a;
    --primary-light: #e6f7ef;
    --primary-soft: #d1f2e3;
    --primary-gradient: linear-gradient(135deg, #00c853 0%, #009e60 55%, #007a4d 100%);

    --sidebar-bg: #ffffff;
    --sidebar-text: #5b6b7c;
    --sidebar-hover: #f3faf6;
    --sidebar-active: #00a86b;
    --sidebar-border: #eef2f0;

    --body-bg: #f3f6f4;
    --surface: #ffffff;
    --text: #1a2332;
    --text-muted: #6b7c8a;
    --border: #e5ebe8;

    --success: #00a86b;
    --warning: #f59e0b;
    --danger: #ef4444;
    --info: #3b82f6;

    --radius-sm: 10px;
    --radius: 16px;
    --radius-lg: 20px;
    --radius-pill: 999px;

    --shadow-sm: 0 2px 8px rgba(16, 42, 30, 0.04);
    --shadow: 0 4px 16px rgba(16, 42, 30, 0.06);
    --shadow-lg: 0 12px 32px rgba(16, 42, 30, 0.08);

    --font: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: var(--font);
    background: var(--body-bg);
    color: var(--text);
    -webkit-font-smoothing: antialiased;
}

a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-dark); }

.wrapper {
    display: flex;
    min-height: 100vh;
}

/* ========== Sidebar ========== */
.sidebar {
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    border-right: 1px solid var(--sidebar-border);
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    z-index: 1000;
    transition: width 0.3s ease;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.sidebar.collapsed { width: var(--sidebar-collapsed); }

.sidebar-brand {
    padding: 1.25rem 1.25rem 1rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    white-space: nowrap;
}

.brand-mark {
    width: 42px;
    height: 42px;
    min-width: 42px;
    border-radius: 12px;
    background: var(--primary-gradient);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 1.25rem;
    box-shadow: 0 6px 16px rgba(0, 168, 107, 0.35);
}

.brand-meta { line-height: 1.2; }
.brand-meta .brand-text {
    font-weight: 800;
    font-size: 1.15rem;
    color: var(--text);
    display: block;
}
.brand-meta .brand-tag {
    display: inline-block;
    margin-top: 0.2rem;
    background: var(--primary-light);
    color: var(--primary-dark);
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    padding: 0.15rem 0.45rem;
    border-radius: var(--radius-pill);
    text-transform: uppercase;
}

.sidebar.collapsed .brand-meta { opacity: 0; width: 0; overflow: hidden; }

.assoc-card {
    margin: 0 1rem 1rem;
    padding: 0.85rem 1rem;
    background: var(--body-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    white-space: nowrap;
    overflow: hidden;
}
.assoc-card .assoc-label {
    font-size: 0.7rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    font-weight: 600;
}
.assoc-card .assoc-name {
    font-weight: 700;
    font-size: 0.9rem;
    color: var(--text);
    margin-top: 0.15rem;
}
.assoc-card .assoc-sub {
    font-size: 0.75rem;
    color: var(--text-muted);
}
.sidebar.collapsed .assoc-card { display: none; }

.sidebar-nav {
    flex: 1;
    padding: 0.25rem 0.7rem 1rem;
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-width: thin;
    scrollbar-color: #d6dfdb transparent;
}
.sidebar-nav::-webkit-scrollbar { width: 6px; }
.sidebar-nav::-webkit-scrollbar-thumb { background: #d6dfdb; border-radius: 6px; }
.sidebar-nav::-webkit-scrollbar-track { background: transparent; }

.sidebar-nav .nav-link {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.6rem 0.7rem;
    color: var(--sidebar-text);
    border-radius: 12px;
    margin-bottom: 0.15rem;
    font-weight: 500;
    font-size: 0.86rem;
    transition: background 0.2s ease, color 0.2s ease, box-shadow 0.2s ease;
    white-space: nowrap;
    min-width: 0;
}
.sidebar-nav .nav-link i {
    font-size: 1.1rem;
    min-width: 22px;
    flex-shrink: 0;
    text-align: center;
}
.sidebar-nav .nav-link .nav-label {
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: opacity 0.2s;
}
.sidebar-nav .nav-badge {
    flex-shrink: 0;
    white-space: nowrap;
    font-size: 0.66rem;
    font-weight: 700;
    padding: 0.15rem 0.4rem;
    border-radius: var(--radius-pill);
    background: var(--body-bg);
    color: var(--text-muted);
}
.sidebar-nav .nav-badge.danger {
    background: #fee2e2;
    color: #b91c1c;
}
.sidebar-nav .nav-badge.success {
    background: var(--primary-light);
    color: var(--primary-dark);
}
.sidebar.collapsed .nav-label,
.sidebar.collapsed .nav-badge { opacity: 0; width: 0; overflow: hidden; padding: 0; }

.sidebar-nav .nav-link:hover {
    background: var(--sidebar-hover);
    color: var(--primary-dark);
}
.sidebar-nav .nav-link.active {
    background: var(--primary);
    color: #fff;
    box-shadow: 0 6px 16px rgba(0, 168, 107, 0.3);
}
.sidebar-nav .nav-link.active .nav-badge {
    background: #fff;
    color: var(--primary-dark);
}
.sidebar-nav .nav-link.active .nav-badge.danger { color: #b91c1c; }

.sidebar-footer {
    padding: 1rem;
    border-top: 1px solid var(--sidebar-border);
}
.audit-card {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.85rem;
    background: var(--primary-light);
    border-radius: var(--radius-sm);
}
.audit-card i {
    font-size: 1.35rem;
    color: var(--primary);
}
.audit-card strong {
    display: block;
    font-size: 0.8rem;
    color: var(--text);
}
.audit-card span {
    font-size: 0.7rem;
    color: var(--text-muted);
}
.sidebar.collapsed .audit-card span,
.sidebar.collapsed .audit-card strong { display: none; }

/* ========== Main ========== */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    transition: margin-left 0.3s ease;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    min-width: 0;
}
.sidebar.collapsed ~ .main-content,
.wrapper.sidebar-collapsed .main-content {
    margin-left: var(--sidebar-collapsed);
}

/* ========== Topbar ========== */
.topbar {
    min-height: var(--topbar-height);
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.75rem 1.5rem;
    position: sticky;
    top: 0;
    z-index: 900;
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    min-width: 0;
}

.sidebar-toggle {
    background: var(--body-bg);
    border: 1px solid var(--border);
    width: 40px;
    height: 40px;
    border-radius: 12px;
    color: var(--text-muted);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    transition: all 0.2s;
}
.sidebar-toggle:hover {
    background: var(--primary-light);
    color: var(--primary);
    border-color: var(--primary-soft);
}

.topbar-title {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--text);
}
.topbar-sub {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.topbar-center {
    flex: 1;
    max-width: 420px;
    display: none;
}
@media (min-width: 1100px) {
    .topbar-center { display: block; }
}

.search-box {
    position: relative;
}
.search-box i {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
}
.search-box input {
    width: 100%;
    border: 1px solid var(--border);
    background: var(--body-bg);
    border-radius: var(--radius-pill);
    padding: 0.65rem 1rem 0.65rem 2.5rem;
    font-size: 0.875rem;
    font-family: inherit;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}
.search-box input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(0, 168, 107, 0.12);
    background: #fff;
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 0.65rem;
}

.stat-pill {
    display: none;
    align-items: center;
    gap: 0.35rem;
    padding: 0.4rem 0.75rem;
    border-radius: var(--radius-pill);
    font-size: 0.75rem;
    font-weight: 700;
    white-space: nowrap;
}
.stat-pill.funds { background: var(--primary-light); color: var(--primary-dark); }
.stat-pill.rate { background: #e0f2fe; color: #0369a1; }
.stat-pill.alerts { background: #fee2e2; color: #b91c1c; }
@media (min-width: 1280px) {
    .stat-pill { display: inline-flex; }
}

.icon-btn {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: #fff;
    color: var(--text-muted);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    position: relative;
}
.icon-btn .dot {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 8px;
    height: 8px;
    background: var(--danger);
    border-radius: 50%;
    border: 2px solid #fff;
}

.btn-emerald {
    background: var(--primary);
    color: #fff !important;
    border: none;
    border-radius: var(--radius-pill);
    padding: 0.55rem 1.1rem;
    font-weight: 700;
    font-size: 0.85rem;
    font-family: inherit;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    box-shadow: 0 6px 16px rgba(0, 168, 107, 0.28);
    transition: all 0.2s;
}
.btn-emerald:hover {
    background: var(--primary-dark);
    color: #fff !important;
    transform: translateY(-1px);
}
.btn-emerald-outline {
    background: #fff;
    color: var(--primary) !important;
    border: 1px solid var(--primary-soft);
    border-radius: var(--radius-pill);
    padding: 0.55rem 1.1rem;
    font-weight: 700;
    font-size: 0.85rem;
    font-family: inherit;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
}
.btn-emerald-outline:hover {
    background: var(--primary-light);
}

.user-chip {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.25rem 0.5rem 0.25rem 0.25rem;
    border-radius: var(--radius-pill);
    border: 1px solid var(--border);
    background: #fff;
}
.user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--primary-gradient);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.85rem;
}
.user-chip .user-name {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--text);
    line-height: 1.2;
}
.user-chip .user-role {
    font-size: 0.7rem;
    color: var(--text-muted);
}
@media (max-width: 900px) {
    .user-chip .user-meta { display: none; }
}

/* ========== Page ========== */
.page-content {
    flex: 1;
    padding: 1.5rem;
}

.footer {
    background: transparent;
    padding: 0.85rem 1.5rem 1.25rem;
    text-align: center;
    font-size: 0.78rem;
    color: var(--text-muted);
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 1.5rem;
}
.page-header h2 {
    margin: 0;
    font-size: 1.45rem;
    font-weight: 800;
    letter-spacing: -0.02em;
}
.page-header .page-desc {
    margin: 0.25rem 0 0;
    color: var(--text-muted);
    font-size: 0.875rem;
}
.page-actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

/* ========== Cards ========== */
.content-card,
.dash-card {
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    border: 1px solid rgba(229, 235, 232, 0.8);
    padding: 1.35rem;
}

.kpi-card {
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    border: 1px solid rgba(229, 235, 232, 0.8);
    padding: 1.35rem 1.4rem;
    height: 100%;
    transition: transform 0.2s, box-shadow 0.2s;
}
.kpi-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}
.kpi-label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
}
.kpi-value {
    font-size: 1.75rem;
    font-weight: 800;
    color: var(--text);
    letter-spacing: -0.03em;
    line-height: 1.15;
}
.kpi-trend {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--primary);
    background: var(--primary-light);
    padding: 0.2rem 0.55rem;
    border-radius: var(--radius-pill);
    margin-left: 0.5rem;
    vertical-align: middle;
}
.kpi-meta {
    margin-top: 0.85rem;
    padding-top: 0.85rem;
    border-top: 1px solid var(--border);
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem 1.25rem;
    font-size: 0.8rem;
    color: var(--text-muted);
}
.kpi-meta strong { color: var(--text); font-weight: 700; }
.kpi-meta .danger-text { color: var(--danger); font-weight: 700; }
.kpi-badge {
    display: inline-block;
    font-size: 0.72rem;
    font-weight: 700;
    padding: 0.25rem 0.6rem;
    border-radius: var(--radius-pill);
    background: var(--primary-light);
    color: var(--primary-dark);
}

/* Gradient portfolio card */
.portfolio-card {
    background: var(--primary-gradient);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    color: #fff;
    height: 100%;
    position: relative;
    overflow: hidden;
    box-shadow: 0 10px 28px rgba(0, 168, 107, 0.28);
}
.portfolio-card::after {
    content: '';
    position: absolute;
    width: 180px;
    height: 180px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.08);
    top: -40px;
    right: -40px;
}
.portfolio-tag {
    display: inline-block;
    background: rgba(255, 255, 255, 0.2);
    padding: 0.25rem 0.65rem;
    border-radius: var(--radius-pill);
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}
.portfolio-card h3 {
    font-size: 1.65rem;
    font-weight: 800;
    margin: 1rem 0 0.35rem;
    position: relative;
    z-index: 1;
}
.portfolio-card p {
    opacity: 0.9;
    font-size: 0.85rem;
    margin: 0;
    position: relative;
    z-index: 1;
}
.portfolio-card .portfolio-foot {
    margin-top: 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: relative;
    z-index: 1;
}
.btn-white-pill {
    background: #fff;
    color: var(--primary-dark) !important;
    border: none;
    border-radius: var(--radius-pill);
    padding: 0.45rem 0.9rem;
    font-weight: 700;
    font-size: 0.8rem;
    font-family: inherit;
}

/* Gauge */
.gauge-wrap {
    position: relative;
    width: 180px;
    height: 100px;
    margin: 0.5rem auto 0;
}
.gauge-wrap svg { width: 180px; height: 100px; overflow: visible; }
.gauge-center {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    text-align: center;
}
.gauge-center .g-val {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--text);
    line-height: 1;
}
.gauge-center .g-sub {
    font-size: 0.65rem;
    font-weight: 700;
    color: var(--text-muted);
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

/* Donut */
.donut-wrap {
    display: flex;
    align-items: center;
    gap: 1.25rem;
}
.donut-chart {
    position: relative;
    width: 120px;
    height: 120px;
    min-width: 120px;
}
.donut-chart canvas { width: 120px !important; height: 120px !important; }
.donut-center {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    pointer-events: none;
}
.donut-center strong {
    font-size: 1.35rem;
    font-weight: 800;
    line-height: 1;
}
.donut-center span {
    font-size: 0.65rem;
    font-weight: 700;
    color: var(--text-muted);
    letter-spacing: 0.05em;
}
.legend-list { list-style: none; padding: 0; margin: 0; flex: 1; }
.legend-list li {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.8rem;
    margin-bottom: 0.55rem;
}
.legend-list .dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
    margin-right: 0.45rem;
}
.legend-list .muted { color: var(--text-muted); font-size: 0.75rem; }

.card-title {
    font-size: 1rem;
    font-weight: 800;
    margin: 0;
}
.card-sub {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin: 0.15rem 0 0;
}

.section-foot {
    margin-top: 1rem;
    padding-top: 0.85rem;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* Heatmap */
.heatmap {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 6px;
}
.heat-cell {
    aspect-ratio: 1;
    border-radius: 6px;
    font-size: 0.65rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #065f46;
}
.heat-cell.paid { background: #bbf7d0; }
.heat-cell.due { background: #fde68a; color: #92400e; }
.heat-cell.overdue { background: #fecaca; color: #991b1b; }
.heat-legend {
    display: flex;
    gap: 0.85rem;
    margin-top: 0.85rem;
    font-size: 0.72rem;
    color: var(--text-muted);
}
.heat-legend span::before {
    content: '';
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 3px;
    margin-right: 0.35rem;
    vertical-align: -1px;
}
.heat-legend .l-paid::before { background: #bbf7d0; }
.heat-legend .l-due::before { background: #fde68a; }
.heat-legend .l-overdue::before { background: #fecaca; }

/* Tables */
.table {
    --bs-table-bg: transparent;
}
.table th {
    font-weight: 700;
    font-size: 0.72rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    border-bottom-width: 1px;
    padding: 0.85rem 0.75rem;
}
.table td {
    padding: 0.95rem 0.75rem;
    vertical-align: middle;
    border-color: var(--border);
    font-size: 0.875rem;
}
.table-hover tbody tr:hover { background: var(--primary-light); }

.unit-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: 10px;
    background: var(--primary-light);
    color: var(--primary-dark);
    font-weight: 800;
    font-size: 0.75rem;
    margin-right: 0.65rem;
}

.badge,
.badge-status-paid,
.badge-status-pending,
.badge-status-overdue,
.badge-status-open,
.badge-status-in_progress,
.badge-status-resolved,
.badge-status-closed {
    border-radius: var(--radius-pill) !important;
    font-weight: 700 !important;
    font-size: 0.72rem !important;
    padding: 0.35rem 0.7rem !important;
}

.badge-status-paid,
.badge-status-resolved { background: var(--primary-light) !important; color: var(--primary-dark) !important; }
.badge-status-pending,
.badge-status-in_progress { background: #dbeafe !important; color: #1d4ed8 !important; }
.badge-status-overdue,
.badge-status-open { background: #fee2e2 !important; color: #b91c1c !important; }
.badge-status-closed { background: #e2e8f0 !important; color: #475569 !important; }

.bg-primary { background-color: var(--primary) !important; }
.bg-success { background-color: var(--primary) !important; }
.text-primary { color: var(--primary) !important; }
.btn-primary {
    --bs-btn-bg: var(--primary);
    --bs-btn-border-color: var(--primary);
    --bs-btn-hover-bg: var(--primary-dark);
    --bs-btn-hover-border-color: var(--primary-dark);
    --bs-btn-active-bg: var(--primary-dark);
    --bs-btn-active-border-color: var(--primary-dark);
    border-radius: var(--radius-pill);
    font-weight: 700;
    font-family: inherit;
}
.btn-outline-primary {
    --bs-btn-color: var(--primary);
    --bs-btn-border-color: var(--primary);
    --bs-btn-hover-bg: var(--primary);
    --bs-btn-hover-border-color: var(--primary);
    border-radius: var(--radius-pill);
    font-weight: 600;
}
.btn-outline-secondary,
.btn-outline-danger,
.btn-outline-success,
.btn-outline-info,
.btn-outline-warning {
    border-radius: 10px;
}
.form-control, .form-select {
    border-radius: 12px;
    border-color: var(--border);
    padding: 0.65rem 0.9rem;
    font-family: inherit;
}
.form-control:focus, .form-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(0, 168, 107, 0.15);
}
.form-check-input:checked {
    background-color: var(--primary);
    border-color: var(--primary);
}

.alert { border-radius: 12px; border: none; }
.link-soft {
    background: var(--primary-light);
    color: var(--primary-dark) !important;
    font-weight: 700;
    font-size: 0.8rem;
    padding: 0.4rem 0.85rem;
    border-radius: var(--radius-pill);
}

/* Auth */
.auth-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background:
        radial-gradient(circle at 15% 20%, rgba(0, 200, 83, 0.18), transparent 40%),
        radial-gradient(circle at 85% 80%, rgba(0, 122, 77, 0.15), transparent 40%),
        var(--body-bg);
    padding: 1.5rem;
}
.auth-card {
    background: #fff;
    border-radius: 24px;
    padding: 2.5rem;
    width: 100%;
    max-width: 420px;
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border);
}
.auth-card h2 {
    text-align: center;
    margin-bottom: 0.35rem;
    font-weight: 800;
}
.auth-card .subtitle {
    text-align: center;
    color: var(--text-muted);
    margin-bottom: 2rem;
    font-size: 0.9rem;
}
.auth-logo {
    width: 56px;
    height: 56px;
    border-radius: 16px;
    background: var(--primary-gradient);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    margin: 0 auto 1rem;
    box-shadow: 0 8px 20px rgba(0, 168, 107, 0.35);
}

/* ========== Responsive shell: drawer, compact topbar, bottom nav ========== */
.drawer-close,
.mobile-brand,
.bottom-nav,
.drawer-logout { display: none; }
.sidebar-backdrop[hidden] { display: none; }
.assoc-card { position: relative; }
.assoc-card .live-dot {
    display: inline-block;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--primary);
    margin-right: 0.3rem;
    vertical-align: middle;
}
.assoc-count {
    position: absolute;
    top: 0.8rem;
    right: 0.85rem;
    background: var(--primary-light);
    color: var(--primary-dark);
    font-size: 0.7rem;
    font-weight: 800;
    padding: 0.15rem 0.5rem;
    border-radius: var(--radius-pill);
}
.user-chip { color: inherit; }
.user-chip:hover { color: inherit; border-color: var(--primary-soft); }
.min-w-0 { min-width: 0; }

@media (max-width: 991.98px) {
    .sidebar,
    .sidebar.collapsed {
        width: min(320px, 86vw);
        transform: translateX(-105%);
        transition: transform 0.28s ease;
        z-index: 1100;
        box-shadow: none;
    }
    .sidebar.open {
        transform: translateX(0);
        box-shadow: 0 0 40px rgba(15, 23, 42, 0.25);
    }
    .sidebar.collapsed .brand-meta,
    .sidebar.collapsed .nav-label,
    .sidebar.collapsed .nav-badge { opacity: 1; width: auto; padding: revert; overflow: visible; }
    .sidebar.collapsed .assoc-card,
    .sidebar.collapsed .audit-card strong,
    .sidebar.collapsed .audit-card span { display: revert; }
    .sidebar-brand { justify-content: space-between; }
    .drawer-close {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        margin-left: auto;
        width: 38px;
        height: 38px;
        border-radius: 12px;
        border: 1px solid var(--border);
        background: #fff;
        color: var(--text-muted);
    }
    .drawer-logout {
        display: flex;
        align-items: center;
        gap: 0.6rem;
        padding: 0.65rem 0.9rem;
        margin-bottom: 0.75rem;
        border-radius: 12px;
        color: var(--danger) !important;
        font-weight: 700;
        background: #fef2f2;
    }
    .sidebar-backdrop {
        position: fixed;
        inset: 0;
        background: rgba(15, 23, 42, 0.45);
        backdrop-filter: blur(3px);
        z-index: 1050;
    }
    body.drawer-open { overflow: hidden; }

    .main-content,
    .sidebar.collapsed ~ .main-content,
    .wrapper.sidebar-collapsed .main-content { margin-left: 0; }

    .topbar { padding: 0.55rem 1rem; min-height: 60px; gap: 0.6rem; }
    .topbar-heading, .topbar-center, .topbar-logout, .user-chip .user-meta { display: none !important; }
    .topbar-right { gap: 0.45rem; }
    .user-chip { border: 0; padding: 0; background: transparent; }
    .sidebar-toggle, .icon-btn { width: 38px; height: 38px; }
    .mobile-brand {
        display: flex;
        align-items: center;
        gap: 0.55rem;
        min-width: 0;
        color: var(--text) !important;
    }
    .brand-mark.sm { width: 34px; height: 34px; min-width: 34px; border-radius: 10px; font-size: 1rem; box-shadow: none; }
    .mobile-brand-name {
        display: flex;
        align-items: center;
        gap: 0.35rem;
        font-weight: 800;
        font-size: 0.95rem;
        line-height: 1.2;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    .mobile-brand-sub { display: block; font-size: 0.72rem; color: var(--text-muted); }
    .role-chip {
        background: var(--primary-light);
        color: var(--primary-dark);
        border: 1px solid var(--primary-soft);
        border-radius: var(--radius-pill);
        padding: 0.05rem 0.45rem;
        font-size: 0.62rem;
        font-weight: 800;
        text-transform: uppercase;
        letter-spacing: 0.04em;
    }
    .topbar-notice { padding: 0.45rem 0.8rem; font-size: 0.8rem; }

    .page-content { padding: 1rem; }
    body.has-bottom-nav .main-content { padding-bottom: calc(78px + env(safe-area-inset-bottom)); }

    .bottom-nav {
        display: flex;
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 1000;
        background: rgba(255, 255, 255, 0.97);
        backdrop-filter: blur(10px);
        border-top: 1px solid var(--border);
        padding: 0.35rem 0.25rem calc(0.35rem + env(safe-area-inset-bottom));
        box-shadow: 0 -6px 20px rgba(16, 42, 30, 0.06);
    }
    .bn-item {
        flex: 1;
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 0.1rem;
        padding: 0.3rem 0;
        border: 0;
        background: none;
        color: var(--text-muted) !important;
        font: inherit;
        font-size: 0.7rem;
        font-weight: 600;
        min-width: 0;
    }
    .bn-item.active { color: var(--primary) !important; font-weight: 800; }
    .bn-icon { position: relative; font-size: 1.3rem; line-height: 1; }
    .bn-badge {
        position: absolute;
        top: -0.35rem;
        right: -0.7rem;
        min-width: 1.1rem;
        padding: 0.05rem 0.3rem;
        border-radius: var(--radius-pill);
        background: var(--danger);
        color: #fff;
        font-size: 0.62rem;
        font-weight: 800;
        line-height: 1.3;
    }
    .bn-fab .bn-icon {
        width: 48px;
        height: 48px;
        margin-top: -1.35rem;
        border-radius: 50%;
        background: var(--primary-gradient);
        color: #fff;
        display: flex;
        align-items: center;
        justify-content: center;
        box-shadow: 0 8px 18px rgba(0, 168, 107, 0.4);
        border: 3px solid #fff;
    }
    .bn-fab { color: var(--primary) !important; font-weight: 800; }
}

@media print {
    .bottom-nav, .sidebar-backdrop { display: none !important; }
}

/* ========== Resident registry (Flats & Residents) ========== */
.registry-hero {
    background: var(--surface);
    border: 1px solid rgba(229, 235, 232, 0.8);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    padding: 1.5rem 1.75rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 1.5rem;
}
.registry-eyebrow {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.78rem;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--primary-dark);
    margin-bottom: 0.35rem;
}
.registry-eyebrow .live-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-soft);
}
.registry-eyebrow .eyebrow-meta { color: var(--text-muted); }
.registry-eyebrow .eyebrow-meta::before { content: '•'; margin-right: 0.5rem; color: var(--border); }
.registry-hero h1 {
    font-size: 1.75rem;
    font-weight: 800;
    letter-spacing: -0.02em;
    margin: 0;
    color: var(--text);
}
.btn-ghost-white {
    background: #fff;
    color: var(--text) !important;
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 0.55rem 1.1rem;
    font-weight: 700;
    font-size: 0.85rem;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    transition: background 0.2s, border-color 0.2s;
}
.btn-ghost-white:hover { background: var(--primary-light); border-color: var(--primary-soft); }

.block-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}
.block-card {
    background: var(--surface);
    border: 1px solid rgba(229, 235, 232, 0.8);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    padding: 1.35rem 1.4rem;
    color: inherit;
    transition: transform 0.2s, box-shadow 0.2s, border-color 0.2s;
}
.block-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); color: inherit; }
.block-card.active { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-light); }
.block-card .block-label {
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
}
.block-card .block-value {
    font-size: 1.9rem;
    font-weight: 800;
    letter-spacing: -0.02em;
    margin: 0.35rem 0 0.25rem;
    color: var(--text);
}
.block-card .block-sub { font-size: 0.88rem; font-weight: 700; color: var(--primary); }

.registry-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 1.25rem;
}
.seg-tabs {
    display: inline-flex;
    flex-wrap: wrap;
    gap: 0.25rem;
    background: #e9efec;
    padding: 0.3rem;
    border-radius: 14px;
}
.seg-tabs a {
    padding: 0.5rem 1.05rem;
    border-radius: 11px;
    font-weight: 600;
    font-size: 0.92rem;
    color: var(--text-muted);
    white-space: nowrap;
}
.seg-tabs a:hover { color: var(--text); }
.seg-tabs a.active { background: #fff; color: var(--text); font-weight: 800; box-shadow: var(--shadow-sm); }

.registry-search { position: relative; flex: 0 1 360px; min-width: 220px; }
.registry-search i {
    position: absolute;
    left: 0.95rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--primary);
}
.registry-search input {
    width: 100%;
    border: 1px solid var(--border);
    background: #fff;
    border-radius: 12px;
    padding: 0.65rem 0.9rem 0.65rem 2.5rem;
    font-size: 0.9rem;
    font-family: inherit;
}
.registry-search input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(0, 168, 107, 0.15); }

.registry-table-card {
    background: var(--surface);
    border: 1px solid rgba(229, 235, 232, 0.8);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    padding: 1.25rem 1.75rem;
}
.registry-table td { padding: 1.05rem 0.75rem; }
.registry-table tbody tr:last-child td { border-bottom: none; }
.flat-cell { display: flex; align-items: center; gap: 0.85rem; }
.flat-tile {
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    border-radius: 12px;
    background: var(--primary-light);
    color: var(--primary-dark);
    font-weight: 800;
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    justify-content: center;
}
.flat-tile.tenant { background: #e0f2fe; color: #0369a1; }
.flat-tile.vacant { background: #fef3c7; color: #92400e; }
.cell-title { font-weight: 800; color: var(--text); line-height: 1.25; }
.cell-sub { font-size: 0.8rem; color: var(--text-muted); }
.cell-mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 0.8rem; }

.status-pill {
    display: inline-block;
    padding: 0.25rem 0.7rem;
    border-radius: var(--radius-pill);
    font-size: 0.75rem;
    font-weight: 700;
    border: 1px solid transparent;
    white-space: nowrap;
}
.status-pill.owner { background: var(--primary-light); color: var(--primary-dark); border-color: #a7e3c8; }
.status-pill.tenant { background: #f1f5f9; color: #334155; border-color: #cbd5e1; }
.status-pill.vacant { background: #fef3c7; color: #92400e; border-color: #fcd34d; }

.btn-profile {
    background: var(--primary-gradient);
    color: #fff !important;
    border-radius: var(--radius-pill);
    padding: 0.45rem 1rem;
    font-weight: 800;
    font-size: 0.85rem;
    white-space: nowrap;
    box-shadow: 0 6px 14px rgba(0, 168, 107, 0.25);
    transition: transform 0.2s, box-shadow 0.2s;
}
.btn-profile:hover { transform: translateY(-1px); box-shadow: 0 8px 18px rgba(0, 168, 107, 0.35); }
.btn-kebab {
    width: 34px;
    height: 34px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: #fff;
    color: var(--text-muted);
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.btn-kebab:hover { background: var(--primary-light); color: var(--primary-dark); }
.dropdown-menu { border-radius: 12px; border-color: var(--border); box-shadow: var(--shadow); padding: 0.35rem; }
.dropdown-item { border-radius: 8px; font-size: 0.875rem; padding: 0.45rem 0.75rem; }
.dropdown-item i { width: 1.25rem; }

.registry-empty { text-align: center; padding: 3rem 1rem; color: var(--text-muted); }
.registry-empty i { font-size: 2.5rem; color: var(--primary); display: block; margin-bottom: 0.75rem; }
.registry-empty h5 { color: var(--text); font-weight: 800; }

/* Flat profile */
.profile-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 1rem 1.5rem; }
.profile-field .label {
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
}
.profile-field .value { font-weight: 700; color: var(--text); word-break: break-word; }
.profile-tile { width: 56px; height: 56px; border-radius: 16px; font-size: 1.1rem; }

@media (max-width: 576px) {
    .registry-hero, .registry-table-card { padding: 1.1rem; }
    .registry-hero h1 { font-size: 1.35rem; }
    .registry-search { flex: 1 1 100%; }
}
