/* ==========================================================================
   Masjid Management System - application styles
   Light theme by default; dark theme via data-theme="dark" or the OS setting.
   ========================================================================== */

:root {
    --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;

    --brand: #0f766e;
    --brand-strong: #115e59;
    --brand-soft: #ccfbf1;
    --accent: #b45309;
    --accent-soft: #fef3c7;

    --bg: #f4f6f5;
    --surface: #ffffff;
    --surface-2: #f8faf9;
    --sidebar: #0b3b37;
    --sidebar-text: #cfe7e3;
    --sidebar-active: rgba(255, 255, 255, 0.12);

    --text: #0f172a;
    --text-muted: #64748b;
    --border: #e2e8f0;
    --focus: #14b8a6;

    --success: #15803d;
    --success-soft: #dcfce7;
    --warning: #b45309;
    --warning-soft: #fef3c7;
    --danger: #b91c1c;
    --danger-soft: #fee2e2;
    --info: #1d4ed8;
    --info-soft: #dbeafe;
    --muted-soft: #eef2f7;

    --radius: 14px;
    --radius-sm: 9px;
    --shadow: 0 1px 2px rgba(15, 23, 42, 0.04), 0 4px 16px rgba(15, 23, 42, 0.05);
    --shadow-lg: 0 10px 30px rgba(15, 23, 42, 0.12);

    --sidebar-width: 268px;
    --topbar-height: 64px;

    color-scheme: light;
}

:root[data-theme="dark"] {
    --brand: #2dd4bf;
    --brand-strong: #5eead4;
    --brand-soft: rgba(45, 212, 191, 0.14);
    --accent: #fbbf24;
    --accent-soft: rgba(251, 191, 36, 0.14);

    --bg: #0b1220;
    --surface: #111a2c;
    --surface-2: #0f1728;
    --sidebar: #070d18;
    --sidebar-text: #94a3b8;
    --sidebar-active: rgba(255, 255, 255, 0.08);

    --text: #e2e8f0;
    --text-muted: #94a3b8;
    --border: #1e2a40;
    --focus: #2dd4bf;

    --success: #4ade80;
    --success-soft: rgba(74, 222, 128, 0.14);
    --warning: #fbbf24;
    --warning-soft: rgba(251, 191, 36, 0.14);
    --danger: #f87171;
    --danger-soft: rgba(248, 113, 113, 0.14);
    --info: #60a5fa;
    --info-soft: rgba(96, 165, 250, 0.14);
    --muted-soft: rgba(148, 163, 184, 0.14);

    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 16px 40px rgba(0, 0, 0, 0.5);

    color-scheme: dark;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --brand: #2dd4bf;
        --brand-strong: #5eead4;
        --brand-soft: rgba(45, 212, 191, 0.14);
        --accent: #fbbf24;
        --accent-soft: rgba(251, 191, 36, 0.14);

        --bg: #0b1220;
        --surface: #111a2c;
        --surface-2: #0f1728;
        --sidebar: #070d18;
        --sidebar-text: #94a3b8;
        --sidebar-active: rgba(255, 255, 255, 0.08);

        --text: #e2e8f0;
        --text-muted: #94a3b8;
        --border: #1e2a40;
        --focus: #2dd4bf;

        --success: #4ade80;
        --success-soft: rgba(74, 222, 128, 0.14);
        --warning: #fbbf24;
        --warning-soft: rgba(251, 191, 36, 0.14);
        --danger: #f87171;
        --danger-soft: rgba(248, 113, 113, 0.14);
        --info: #60a5fa;
        --info-soft: rgba(96, 165, 250, 0.14);
        --muted-soft: rgba(148, 163, 184, 0.14);

        --shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
        --shadow-lg: 0 16px 40px rgba(0, 0, 0, 0.5);

        color-scheme: dark;
    }
}

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

html {
    -webkit-text-size-adjust: 100%;
}

body {
    margin: 0;
    font-family: var(--font);
    font-size: 15px;
    line-height: 1.55;
    color: var(--text);
    background: var(--bg);
    background-image: radial-gradient(1200px 400px at 100% -10%, var(--brand-soft), transparent 60%);
    background-attachment: fixed;
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 {
    margin: 0;
    line-height: 1.25;
    color: var(--text);
}

h2 { font-size: 1.6rem; font-weight: 700; letter-spacing: -0.01em; }
h3 { font-size: 1.05rem; font-weight: 600; }
h4 { font-size: 0.95rem; font-weight: 600; margin: 1.25rem 0 0.5rem; }

p { margin: 0; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
code {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 0.82em;
    background: var(--muted-soft);
    padding: 0.1em 0.4em;
    border-radius: 6px;
}

img { max-width: 100%; display: block; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

.muted { color: var(--text-muted); }
.small { font-size: 0.85rem; }
.strong { font-weight: 600; }
.nowrap { white-space: nowrap; }
.wrap { max-width: 320px; overflow-wrap: anywhere; }
.align-start { align-items: start; }
.align-right { text-align: right; }
.text-danger { color: var(--danger) !important; }
.text-success { color: var(--success) !important; }
.amount-in { color: var(--success); font-weight: 600; }
.amount-out { color: var(--danger); font-weight: 600; }
.row-muted td { color: var(--text-muted); }
.sr-only {
    position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0 0 0 0); border: 0;
}
.icon-btn.only-mobile { display: none; }
.no-print { }
[hidden] { display: none !important; }

.icon {
    width: 18px;
    height: 18px;
    flex: none;
}

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

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

.app-shell {
    display: grid;
    grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
    min-height: 100vh;
}

.sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    display: flex;
    flex-direction: column;
    background: var(--sidebar);
    color: var(--sidebar-text);
    padding: 1.25rem 0.9rem;
    overflow-y: auto;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.25rem 0.5rem 1.25rem;
}

.brand-logo {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    background: #fff;
    padding: 4px;
    object-fit: contain;
}

.brand-name {
    color: #fff;
    font-weight: 700;
    font-size: 0.95rem;
    line-height: 1.2;
}

.brand-sub {
    font-size: 0.75rem;
    color: var(--sidebar-text);
    opacity: 0.8;
}

.sidebar .icon-btn {
    margin-left: auto;
    color: #fff;
    background: transparent;
}

.nav { display: flex; flex-direction: column; gap: 1.1rem; flex: 1; }
.nav-group { display: flex; flex-direction: column; gap: 2px; }

.nav-heading {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    padding: 0 0.75rem;
    margin-bottom: 0.25rem;
    opacity: 0.6;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    padding: 0.6rem 0.75rem;
    border-radius: 10px;
    color: var(--sidebar-text);
    font-weight: 500;
    font-size: 0.93rem;
    border: 0;
    background: transparent;
    width: 100%;
    text-align: left;
    cursor: pointer;
    font-family: inherit;
    transition: background 0.15s, color 0.15s;
}

.nav-link:hover {
    background: var(--sidebar-active);
    color: #fff;
    text-decoration: none;
}

.nav-link.is-active {
    background: var(--sidebar-active);
    color: #fff;
    box-shadow: inset 3px 0 0 #5eead4;
}

.sidebar-footer {
    margin-top: 1rem;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    padding-top: 0.75rem;
}

.app-main {
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    gap: 1rem;
    height: var(--topbar-height);
    padding: 0 2rem;
    background: color-mix(in srgb, var(--bg) 85%, transparent);
    backdrop-filter: saturate(1.4) blur(10px);
    border-bottom: 1px solid var(--border);
}

.topbar-title {
    font-size: 1.05rem;
    font-weight: 600;
    flex: 1;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.user-chip {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.3rem 0.8rem 0.3rem 0.3rem;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--surface);
}

.avatar {
    width: 32px;
    height: 32px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--brand), var(--accent));
    color: #fff;
    font-size: 0.78rem;
    font-weight: 700;
}

.user-meta {
    display: flex;
    flex-direction: column;
    line-height: 1.15;
}

.user-name { font-size: 0.85rem; font-weight: 600; }
.user-role { font-size: 0.72rem; color: var(--text-muted); }

.content {
    padding: 2rem;
    width: 100%;
    max-width: 1280px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.app-footer {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
    padding: 1rem 2rem 1.5rem;
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: auto;
}

.sidebar-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(2, 6, 23, 0.5);
    z-index: 30;
}

/* ---------- Page header ---------- */

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    gap: 1rem;
    flex-wrap: wrap;
}

.page-header p.muted { margin-top: 0.25rem; }

.page-actions {
    display: flex;
    gap: 0.6rem;
    flex-wrap: wrap;
    align-items: center;
}

.back {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.88rem;
    margin-bottom: 0.4rem;
}

/* ---------- Cards ---------- */

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.25rem 1.35rem;
    min-width: 0;
}

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

.card-header p { font-size: 0.85rem; margin-top: 0.15rem; }

.table-card { padding: 0; overflow: hidden; }
.table-card .pagination { padding: 1rem 1.35rem; }

.stack { display: flex; flex-direction: column; gap: 1.5rem; min-width: 0; }

.grid-2 {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1.5rem;
}

.hero-card {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 2rem;
    flex-wrap: wrap;
    background:
        linear-gradient(135deg, color-mix(in srgb, var(--brand) 16%, var(--surface)), var(--surface) 60%),
        var(--surface);
}

.hero-amount {
    font-size: clamp(1.9rem, 4vw, 2.6rem);
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--brand-strong);
    line-height: 1.1;
    margin: 0.2rem 0 0.4rem;
}

.hero-meta {
    display: flex;
    gap: 2rem;
    flex-wrap: wrap;
}

.hero-meta > div {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    min-width: 150px;
}

.hero-meta strong { font-size: 1.15rem; }

/* ---------- Stat cards ---------- */

.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
    gap: 1rem;
}

.stat-grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.stat-grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }

.stat-card {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    color: var(--text);
    transition: transform 0.15s, box-shadow 0.15s;
}

a.stat-card:hover {
    text-decoration: none;
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.stat-icon {
    width: 38px;
    height: 38px;
    display: grid;
    place-items: center;
    border-radius: 10px;
    background: var(--brand-soft);
    color: var(--brand-strong);
    margin-bottom: 0.4rem;
}

.stat-label {
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-muted);
}

.stat-value {
    font-size: 1.45rem;
    font-weight: 700;
    letter-spacing: -0.01em;
    line-height: 1.2;
}

.small-value { font-size: 1.05rem; }

.stat-sub {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.chart-box { position: relative; height: 280px; }
.chart-box canvas { width: 100% !important; height: 100% !important; }

/* ---------- Lists ---------- */

.activity-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.activity-list li {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    padding: 0.7rem 0;
    border-bottom: 1px solid var(--border);
}

.activity-list li:last-child { border-bottom: 0; }
.activity-list div { display: flex; flex-direction: column; gap: 0.1rem; min-width: 0; }
.activity-list .muted { font-size: 0.83rem; }

.empty {
    color: var(--text-muted);
    text-align: center;
    padding: 2rem 0;
}

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 0.5rem;
    padding: 3rem 1.5rem;
}

.empty-state .icon {
    width: 40px;
    height: 40px;
    color: var(--brand);
    margin-bottom: 0.5rem;
}

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

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.45rem;
    padding: 0.6rem 1.05rem;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    font: inherit;
    font-size: 0.92rem;
    font-weight: 600;
    line-height: 1.2;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.15s, border-color 0.15s, color 0.15s, box-shadow 0.15s;
    text-decoration: none;
}

.btn:hover { text-decoration: none; }
.btn .icon { width: 16px; height: 16px; }

.btn-primary {
    background: var(--brand);
    color: #fff;
    box-shadow: 0 1px 2px rgba(15, 118, 110, 0.3);
}

.btn-primary:hover { background: var(--brand-strong); color: #fff; }

.btn-outline {
    background: var(--surface);
    border-color: var(--border);
    color: var(--text);
}

.btn-outline:hover { border-color: var(--brand); color: var(--brand); }

.btn-ghost {
    background: transparent;
    color: var(--text-muted);
}

.btn-ghost:hover { color: var(--text); background: var(--muted-soft); }

.btn-danger {
    background: var(--danger);
    color: #fff;
}

.btn-danger:hover { filter: brightness(0.92); color: #fff; }

.btn-sm { padding: 0.4rem 0.7rem; font-size: 0.82rem; }
.btn-block { width: 100%; }

.btn.is-disabled { opacity: 0.45; pointer-events: none; }

.icon-btn {
    display: inline-grid;
    place-items: center;
    width: 36px;
    height: 36px;
    border-radius: 10px;
    border: 1px solid transparent;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0;
    font: inherit;
    transition: background 0.15s, color 0.15s;
}

.icon-btn:hover {
    background: var(--muted-soft);
    color: var(--text);
    text-decoration: none;
}

.icon-btn.danger:hover { color: var(--danger); background: var(--danger-soft); }

.topbar .icon-btn { border-color: var(--border); background: var(--surface); }

/* ---------- Tables ---------- */

.table-wrap {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 0.92rem;
}

.table th,
.table td {
    padding: 0.8rem 1.1rem;
    text-align: left;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

.table thead th {
    font-size: 0.74rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    background: var(--surface-2);
    white-space: nowrap;
}

.table tbody tr:hover td { background: var(--surface-2); }
.table tbody tr:last-child td { border-bottom: 0; }
.table tfoot th { font-weight: 700; border-top: 2px solid var(--border); border-bottom: 0; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table .actions { white-space: nowrap; text-align: right; display: flex; justify-content: flex-end; gap: 0.25rem; }
.table .actions form { margin: 0; }
.actions-col { width: 1%; }

/* ---------- Badges & alerts ---------- */

.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.2rem 0.6rem;
    border-radius: 999px;
    font-size: 0.74rem;
    font-weight: 600;
    background: var(--muted-soft);
    color: var(--text-muted);
    white-space: nowrap;
}

.badge-success { background: var(--success-soft); color: var(--success); }
.badge-warning { background: var(--warning-soft); color: var(--warning); }
.badge-danger { background: var(--danger-soft); color: var(--danger); }
.badge-info { background: var(--info-soft); color: var(--info); }
.badge-muted { background: var(--muted-soft); color: var(--text-muted); }
.badge-normal { background: var(--info-soft); color: var(--info); }
.badge-premium { background: var(--accent-soft); color: var(--accent); }
.badge-vip { background: var(--success-soft); color: var(--success); }
.badge-vvip { background: var(--danger-soft); color: var(--danger); }

.alert {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 0.85rem 1rem;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    font-size: 0.92rem;
}

.alert .icon { margin-top: 2px; }
.alert-body { flex: 1; min-width: 0; }
.alert-success { background: var(--success-soft); color: var(--success); border-color: color-mix(in srgb, var(--success) 25%, transparent); }
.alert-error { background: var(--danger-soft); color: var(--danger); border-color: color-mix(in srgb, var(--danger) 25%, transparent); }
.alert-warning { background: var(--warning-soft); color: var(--warning); border-color: color-mix(in srgb, var(--warning) 25%, transparent); }
.alert-info { background: var(--info-soft); color: var(--info); border-color: color-mix(in srgb, var(--info) 25%, transparent); }

.alert-close {
    background: none;
    border: 0;
    color: inherit;
    font-size: 1.2rem;
    line-height: 1;
    cursor: pointer;
    padding: 0 0.2rem;
    opacity: 0.7;
}

.alert-close:hover { opacity: 1; }
.receipt-banner { margin-top: 1rem; align-items: center; }

/* ---------- Forms ---------- */

.toolbar {
    display: flex;
    gap: 0.7rem;
    flex-wrap: wrap;
    align-items: center;
    padding: 0.9rem 1rem;
}

.search {
    flex: 1 1 260px;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0 0.85rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface-2);
    color: var(--text-muted);
    min-width: 0;
}

.search input {
    flex: 1;
    border: 0;
    background: transparent;
    padding: 0.6rem 0;
    font: inherit;
    color: var(--text);
    min-width: 0;
}

.search input:focus { outline: none; }
.search:focus-within { border-color: var(--focus); box-shadow: 0 0 0 3px var(--brand-soft); }

.form-control {
    width: 100%;
    padding: 0.6rem 0.8rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface-2);
    color: var(--text);
    font: inherit;
    font-size: 0.95rem;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.form-control:focus {
    outline: none;
    border-color: var(--focus);
    box-shadow: 0 0 0 3px var(--brand-soft);
}

.form-control[readonly] { color: var(--text-muted); }
.form-control.is-invalid { border-color: var(--danger); }
.toolbar .form-control { width: auto; min-width: 150px; }

textarea.form-control { resize: vertical; min-height: 84px; }

.form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1rem 1.25rem;
}

.field { display: flex; flex-direction: column; gap: 0.35rem; min-width: 0; }
.field-wide { grid-column: 1 / -1; }
.field-inline { display: flex; flex-direction: column; gap: 0.3rem; }

.label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text);
}

.req { color: var(--danger); }

.hint {
    font-size: 0.78rem;
    color: var(--text-muted);
}

.invalid-feedback {
    font-size: 0.8rem;
    color: var(--danger);
}

.form-card { display: flex; flex-direction: column; gap: 1.25rem; max-width: 860px; }
.form-note {
    padding: 0.75rem 1rem;
    background: var(--brand-soft);
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    color: var(--text);
}

.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.6rem;
    flex-wrap: wrap;
    padding-top: 0.5rem;
}

.form-grid .form-actions { justify-content: flex-start; }

/* ---------- Payment calendar ---------- */

.calendar-head { align-items: center; flex-wrap: wrap; }

.year-nav {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.year-nav .form-control { width: auto; padding: 0.45rem 0.7rem; font-weight: 600; }
.year-nav .icon-btn { border-color: var(--border); background: var(--surface); }
.icon-flip .icon { transform: scaleX(-1); }
.icon-btn.is-disabled { opacity: 0.35; pointer-events: none; }

.calendar-summary {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 1rem;
    margin-bottom: 1.25rem;
    padding: 0.9rem 1rem;
    background: var(--surface-2);
    border-radius: var(--radius-sm);
}

.calendar-summary div { display: flex; flex-direction: column; gap: 0.1rem; }
.calendar-summary strong { font-size: 1.1rem; }

.calendar-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 0.75rem;
}

.cal-cell {
    --cal: var(--border);
    --cal-bg: var(--surface);
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    padding: 0.85rem 0.9rem;
    text-align: left;
    font: inherit;
    color: var(--text);
    background: var(--cal-bg);
    border: 1px solid var(--cal);
    border-left: 4px solid var(--cal);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: transform 0.12s, box-shadow 0.12s, border-color 0.12s;
}

.cal-cell:disabled { cursor: default; }
.cal-cell:not(:disabled):hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.cal-cell[aria-pressed="true"] { box-shadow: 0 0 0 3px var(--focus); transform: translateY(-2px); }

.cal-month { font-size: 1.05rem; font-weight: 700; }
.cal-status { font-size: 0.72rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: var(--cal); }
.cal-amount { font-size: 0.88rem; font-variant-numeric: tabular-nums; }
.cal-date { font-size: 0.74rem; color: var(--text-muted); }

.cal-paid { --cal: var(--success); --cal-bg: var(--success-soft); }
.cal-partial { --cal: var(--warning); --cal-bg: var(--warning-soft); }
.cal-unpaid { --cal: var(--danger); --cal-bg: var(--danger-soft); }
.cal-upcoming { --cal: var(--info); --cal-bg: var(--surface); }
.cal-na { --cal: var(--border); --cal-bg: var(--surface-2); color: var(--text-muted); }
.cal-na .cal-status { color: var(--text-muted); }

.calendar-legend {
    display: flex;
    gap: 1.25rem;
    flex-wrap: wrap;
    margin-top: 1rem;
    font-size: 0.82rem;
    color: var(--text-muted);
}

.dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 3px;
    margin-right: 0.35rem;
    background: var(--cal);
}

.calendar-bar {
    position: sticky;
    bottom: 1rem;
    margin-top: 1.25rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
    padding: 0.8rem 1rem;
    background: var(--surface);
    border: 1px solid var(--focus);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-lg);
}

.toolbar-spacer { flex: 1; }
.toolbar-total { display: flex; flex-direction: column; align-items: flex-end; line-height: 1.2; }
.toolbar-total strong { font-size: 1.2rem; }

/* ---------- Progress and toasts ---------- */

.progress {
    height: 8px;
    border-radius: 999px;
    background: var(--muted-soft);
    overflow: hidden;
    margin-top: 0.4rem;
}

.progress > span {
    display: block;
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, var(--brand), var(--accent));
}

.toast-stack {
    position: fixed;
    top: calc(var(--topbar-height) + 0.75rem);
    right: 1rem;
    z-index: 50;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    width: min(380px, calc(100vw - 2rem));
    pointer-events: none;
}

.toast-stack .alert {
    pointer-events: auto;
    box-shadow: var(--shadow-lg);
    background-color: var(--surface);
    animation: toast-in 0.25s ease-out;
}

.guest-wrap .toast-stack { position: static; width: 100%; }

@keyframes toast-in {
    from { opacity: 0; transform: translateY(-8px); }
    to { opacity: 1; transform: none; }
}

kbd {
    font-family: inherit;
    font-size: 0.72rem;
    padding: 0.05rem 0.4rem;
    border: 1px solid var(--border);
    border-radius: 5px;
    background: var(--surface-2);
    color: var(--text-muted);
}

/* ---------- Payments modal ---------- */

.modal {
    border: 0;
    padding: 0;
    width: min(880px, calc(100vw - 2rem));
    max-width: none;
    max-height: calc(100dvh - 2rem);
    background: transparent;
    color: var(--text);
}

.modal::backdrop {
    background: rgba(2, 6, 23, 0.55);
    backdrop-filter: blur(3px);
}

.modal[open] {
    display: flex;
    flex-direction: column;
    animation: modal-in 0.22s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.modal-box {
    display: flex;
    flex-direction: column;
    min-height: 0;
    max-height: calc(100dvh - 2rem);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 18px;
    box-shadow: var(--shadow-lg);
    overflow: hidden;
}

.modal-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
    padding: 1.25rem 1.5rem 1rem;
}

.modal-title h3 { font-size: 1.25rem; }
.modal-title .eyebrow { margin-bottom: 0.1rem; }
.modal-close { flex: none; }

.tabs {
    display: flex;
    gap: 0.25rem;
    padding: 0 1.25rem;
    border-bottom: 1px solid var(--border);
    overflow-x: auto;
    scrollbar-width: none;
}

.tabs::-webkit-scrollbar { display: none; }

.tab {
    position: relative;
    flex: none;
    padding: 0.75rem 0.9rem;
    border: 0;
    background: transparent;
    font: inherit;
    font-size: 0.92rem;
    font-weight: 600;
    color: var(--text-muted);
    cursor: pointer;
    white-space: nowrap;
}

.tab:hover { color: var(--text); }
.tab[aria-selected="true"] { color: var(--brand-strong); }

.tab[aria-selected="true"]::after {
    content: "";
    position: absolute;
    left: 0.6rem;
    right: 0.6rem;
    bottom: -1px;
    height: 3px;
    border-radius: 3px 3px 0 0;
    background: var(--brand);
}

.modal-body {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 1.25rem 1.5rem;
    -webkit-overflow-scrolling: touch;
}

.calendar-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: 1rem;
}

.year-nav { display: flex; align-items: center; gap: 0.5rem; }
.year-select { margin: 0; }
.year-select .form-control { width: auto; padding: 0.45rem 0.8rem; font-weight: 600; min-width: 96px; }

.calendar-stats { display: flex; gap: 1.5rem; }
.calendar-stats div { display: flex; flex-direction: column; line-height: 1.2; }
.calendar-stats strong { font-size: 1.1rem; }

.calendar-legend .legend-hint { margin-left: auto; font-style: italic; }

.help-text { font-size: 0.84rem; color: var(--text-muted); }

.modal-form { padding-top: 0.25rem; }

.modal-form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.6rem;
    flex-wrap: wrap;
    padding-top: 0.5rem;
}

.receipt-summary {
    border: 1px solid color-mix(in srgb, var(--success) 35%, transparent);
    background: var(--success-soft);
    border-radius: var(--radius-sm);
    padding: 1rem 1.1rem;
    margin-bottom: 1.25rem;
}

.receipt-summary-head { display: flex; gap: 0.8rem; align-items: center; }
.receipt-summary-head > div { display: flex; flex-direction: column; }

.success-mark {
    width: 36px;
    height: 36px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    background: var(--success);
    color: #fff;
    flex: none;
}

.allocation-list {
    list-style: none;
    margin: 0.9rem 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.allocation-list li {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto auto;
    gap: 0.75rem;
    align-items: center;
    background: var(--surface);
    border-radius: 8px;
    padding: 0.5rem 0.75rem;
    font-size: 0.9rem;
}

.receipt-summary-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; }

.modal-foot {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
    padding: 0.9rem 1.5rem;
    border-top: 1px solid var(--border);
    background: var(--surface-2);
}

.modal-foot > div:first-child { display: flex; gap: 0.4rem; flex-wrap: wrap; align-items: baseline; }
.modal-foot-actions { display: flex; gap: 0.5rem; }

.stack-sm { display: flex; flex-direction: column; gap: 0.6rem; }
.button-link { background: none; border: 0; padding: 0; font: inherit; cursor: pointer; }

@keyframes modal-in {
    from { opacity: 0; transform: translateY(14px) scale(0.98); }
    to { opacity: 1; transform: none; }
}

@media (max-width: 720px) {
    .modal {
        width: 100vw;
        max-height: 92dvh;
        margin: auto 0 0;
    }

    .modal-box {
        border-radius: 20px 20px 0 0;
        max-height: 92dvh;
    }

    .modal[open] { animation-name: sheet-in; }

    .modal-head { padding: 1rem 1.1rem 0.8rem; }
    .modal-body { padding: 1rem 1.1rem; }
    .tabs { padding: 0 0.6rem; }
    .modal-foot { padding: 0.8rem 1.1rem; }

    .calendar-toolbar { align-items: stretch; }
    .calendar-stats { justify-content: space-between; }
    .calendar-legend .legend-hint { margin-left: 0; width: 100%; }
    .allocation-list li { grid-template-columns: minmax(0, 1fr) auto; }
    .allocation-list li .num { grid-column: 1 / -1; text-align: left; }
}

@keyframes sheet-in {
    from { opacity: 0; transform: translateY(40px); }
    to { opacity: 1; transform: none; }
}

/* ---------- Two-column financial position ---------- */

.statement-card { padding: 0; overflow: hidden; }
.statement-card > .statement-head { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; padding: 1rem 1.25rem; border-bottom: 1px solid var(--border); background: var(--surface-2); }
.statement-card > .statement-head h3 { font-size: 1rem; }

.position { overflow-x: auto; }

.pos-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.92rem;
    font-variant-numeric: tabular-nums;
    color: var(--text);
}

.pos-table th,
.pos-table td {
    padding: 0.6rem 1rem;
    border: 1px solid var(--border);
    text-align: left;
    vertical-align: middle;
}

.pos-table thead th {
    background: var(--muted-soft);
    font-size: 0.74rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text);
    border-top: 0;
}

.pos-table .r { text-align: right; white-space: nowrap; }

.pos-table .pos-head { font-weight: 700; }
.pos-table .pos-sub { padding-left: 2.2rem; color: var(--text-muted); }
.pos-table .pos-plain { font-weight: 600; }

.pos-table .pos-total { font-weight: 700; background: var(--surface-2); }

.pos-table .pos-amt { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 0.88rem; }

.pos-table .pos-blank td,
.pos-table .pos-blank { background: transparent; }

.pos-note {
    display: block;
    font-size: 0.74rem;
    font-weight: 400;
    color: var(--text-muted);
    margin-top: 0.05rem;
}

.pos-table tfoot th,
.pos-table tfoot td {
    background: var(--muted-soft);
    font-size: 1.02rem;
    font-weight: 700;
    border-top: 2px solid var(--text);
    padding: 0.85rem 1rem;
}

.pos-table tfoot .pos-note { display: inline; margin-left: 0.6rem; font-weight: 400; }

@media (max-width: 720px) {
    .pos-table { font-size: 0.82rem; }
    .pos-table th, .pos-table td { padding: 0.5rem; }
    .pos-table .pos-sub { padding-left: 1.2rem; }
}

/* ---------- Financial reports ---------- */

.report-controls {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    gap: 1rem;
    flex-wrap: wrap;
}

.segmented {
    display: inline-flex;
    padding: 4px;
    gap: 2px;
    background: var(--muted-soft);
    border-radius: 12px;
    flex-wrap: wrap;
}

.segmented a {
    padding: 0.45rem 0.85rem;
    border-radius: 9px;
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--text-muted);
}

.segmented a:hover { color: var(--text); text-decoration: none; }

.segmented a.is-active {
    background: var(--surface);
    color: var(--brand-strong);
    box-shadow: var(--shadow);
}

.period-form {
    display: flex;
    align-items: flex-end;
    gap: 0.6rem;
    flex-wrap: wrap;
}

.period-form .form-control { width: auto; min-width: 150px; }

.kpi-grid {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 1rem;
}

.kpi {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    min-width: 0;
}

.kpi-label { font-size: 0.8rem; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; }
.kpi-value { font-size: 1.35rem; font-weight: 700; letter-spacing: -0.01em; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.kpi-sub { font-size: 0.8rem; color: var(--text-muted); }

.stat-grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }

.report-tabs {
    border-bottom: 1px solid var(--border);
    margin-bottom: -0.5rem;
}

.report-panel { display: flex; flex-direction: column; gap: 1.5rem; }
.report-panel[hidden] { display: none !important; }

.statement-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr);
    gap: 1.5rem;
    align-items: start;
}

.statement { padding: 0; overflow: hidden; }

.statement-head {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 1rem;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border);
    background: var(--surface-2);
}

.statement-head h3 { font-size: 1rem; }

.ledger-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.92rem;
    font-variant-numeric: tabular-nums;
}

.ledger-table td,
.ledger-table th {
    padding: 0.55rem 1.25rem;
    border-bottom: 1px solid var(--border);
    text-align: left;
    vertical-align: middle;
}

.ledger-table .num { text-align: right; white-space: nowrap; }
.ledger-table .indent { padding-left: 2.1rem; }
.ledger-table .indent-2 { padding-left: 3.4rem; color: var(--text-muted); font-size: 0.86rem; }
.ledger-table .share { color: var(--text-muted); font-size: 0.82rem; }

.ledger-table .section-row th {
    padding-top: 0.9rem;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    background: transparent;
}

.ledger-table .total-row th,
.ledger-table .total-row td {
    font-weight: 700;
    border-top: 1px solid var(--border);
}

.ledger-table .result-row th,
.ledger-table .result-row td {
    font-weight: 700;
    font-size: 1.02rem;
    background: var(--brand-soft);
    border-bottom: 0;
}

.ledger-table .sub-row td { font-size: 0.86rem; color: var(--text-muted); }

.note, .basis-note {
    padding: 0.8rem 1.25rem;
    font-size: 0.8rem;
    color: var(--text-muted);
    margin: 0;
}

.chart-box-sm { height: 240px; }

.bar-col { min-width: 170px; }

.bar {
    display: inline-block;
    width: 110px;
    height: 8px;
    border-radius: 999px;
    background: var(--muted-soft);
    overflow: hidden;
    vertical-align: middle;
}

.bar > span {
    display: block;
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, var(--brand), #14b8a6);
}

.bar-cost > span { background: linear-gradient(90deg, var(--accent), #f59e0b); }

.table .group-row th {
    background: var(--surface-2);
    font-size: 0.8rem;
    color: var(--brand-strong);
    text-transform: none;
    letter-spacing: 0;
}

.ledger .opening-row td {
    font-weight: 600;
    background: var(--surface-2);
    color: var(--text-muted);
}

.ledger td.wrap { white-space: normal; }

.menu { position: relative; }
.menu > summary { list-style: none; cursor: pointer; }
.menu > summary::-webkit-details-marker { display: none; }
.menu > summary .icon { transform: rotate(0deg); transition: transform 0.15s; }
.menu[open] > summary .icon { transform: rotate(180deg); }

.menu-panel {
    position: absolute;
    right: 0;
    top: calc(100% + 6px);
    z-index: 30;
    min-width: 260px;
    display: flex;
    flex-direction: column;
    padding: 0.4rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-lg);
}

.menu-panel a {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.55rem 0.7rem;
    border-radius: 8px;
    color: var(--text);
    font-size: 0.9rem;
}

.menu-panel a:hover { background: var(--muted-soft); text-decoration: none; }
.menu-panel .small { margin-left: auto; }

.signatures {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 2rem;
    margin-top: 3.5rem;
}

.signatures > div { display: flex; flex-direction: column; gap: 0.4rem; font-size: 0.85rem; }
.sig-line { display: block; border-top: 1px solid #111; margin-top: 2.5rem; }

@media (max-width: 1280px) {
    .kpi-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .statement-grid { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 960px) {
    .statement-grid { grid-template-columns: minmax(0, 1fr); }
    .stat-grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 720px) {
    .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .kpi-value { font-size: 1.1rem; }
    .segmented { display: flex; width: 100%; }
    .segmented a { flex: 1; text-align: center; padding: 0.45rem 0.4rem; font-size: 0.8rem; }
    .period-form { width: 100%; }
    .period-form .field-inline, .period-form .form-control, .period-form .btn { width: 100%; flex: 1 1 100%; }
    .menu-panel { right: auto; left: 0; min-width: 240px; }
    .ledger-table td, .ledger-table th { padding: 0.5rem 0.85rem; }
    .ledger-table .indent { padding-left: 1.5rem; }
    .signatures { grid-template-columns: minmax(0, 1fr); }
}

/* ---------- Printable financial statement (A4) ---------- */

/* Two-column position inside the printed statement */
.statement-doc .pos-table { font-size: 9.5pt; }
.statement-doc .pos-table th,
.statement-doc .pos-table td { padding: 1.6mm 2.5mm; border-color: #d1d5db; }
.statement-doc .pos-table thead th { background: #f3f4f6; color: #111827; font-size: 7.5pt; padding-top: 2.2mm; padding-bottom: 2.2mm; }
.statement-doc .pos-table .pos-total { background: #f9fafb; }
.statement-doc .pos-table tfoot th,
.statement-doc .pos-table tfoot td { background: #f3f4f6; border-top: 1.5px solid #111827; font-size: 10.5pt; padding: 2.4mm 2.5mm; }
.statement-doc .pos-table .pos-note { font-size: 7.5pt; color: #6b7280; }
.statement-doc .pos-table .pos-sub { color: #374151; }
.statement-doc .pos-table .pos-amt { font-size: 9pt; }
.statement-doc .position { margin-bottom: 4mm; }
@media print {
    .pos-table tr { break-inside: avoid; }
    .pos-table thead { display: table-header-group; }
}

.print-body {
    background: #e6ebe9;
    color: #0f172a;
    font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

.print-body .print-toolbar {
    position: sticky;
    top: 0;
    z-index: 10;
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(8px);
}

/* The statement is always printed on white paper, so it keeps the light palette even when the app is in dark mode. */
.statement-doc {
    color-scheme: light;
    --text: #111827;
    --text-muted: #6b7280;
    --border: #e5e7eb;
    --surface: #ffffff;
    --surface-2: #f9fafb;
    --muted-soft: #f3f4f6;
    --ink: #111827;
    --muted: #6b7280;
    --rule: #e5e7eb;
    --brand: #111827;
    --brand-soft: #f3f4f6;
    width: 210mm;
    max-width: calc(100vw - 2rem);
    margin: 1.5rem auto 3rem;
    background: #fff;
    color: var(--ink);
    box-shadow: 0 10px 40px rgba(15, 23, 42, 0.12);
    font-size: 10pt;
    line-height: 1.45;
    font-variant-numeric: tabular-nums;
}

.statement-doc .page,
.statement-doc .page-inline,
.statement-doc .cover,
.statement-doc .approval {
    padding: 14mm 16mm;
}

.statement-doc .page { border-top: 1px dashed var(--rule); }

/* Cover */
.cover {
    display: flex;
    flex-direction: column;
    gap: 9mm;
    min-height: 262mm;
    color: var(--ink);
    border-top: 6px solid var(--ink);
}

.cover-top { display: flex; align-items: center; gap: 4mm; }
.cover-logo { width: 13mm; height: 13mm; object-fit: contain; }
.cover-org { display: flex; flex-direction: column; line-height: 1.2; }
.cover-org strong { font-size: 11pt; }
.cover-org span { font-size: 8.5pt; color: var(--muted); }
.cover-ref { margin-left: auto; text-align: right; display: flex; flex-direction: column; font-size: 8pt; color: var(--muted); }
.cover-ref strong { font-size: 9.5pt; color: var(--ink); letter-spacing: 0.04em; }

.cover-title { margin-top: 22mm; padding-bottom: 8mm; border-bottom: 1px solid var(--rule); }
.cover-kicker { text-transform: uppercase; letter-spacing: 0.18em; font-size: 8pt; color: var(--muted); margin: 0 0 3mm; }
.cover-title h1 { font-size: 27pt; line-height: 1.12; margin: 0; font-weight: 700; letter-spacing: -0.02em; color: var(--ink); }
.cover-title h1 span { font-weight: 400; color: var(--muted); font-size: 0.6em; }
.cover-meta { margin: 4mm 0 0; font-size: 9pt; color: var(--muted); }

.cover-kpis {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0;
    border: 1px solid var(--rule);
}

.cover-kpis > div {
    padding: 5mm 5mm;
    display: flex;
    flex-direction: column;
    gap: 1mm;
    border-right: 1px solid var(--rule);
    border-bottom: 1px solid var(--rule);
}

.cover-kpis > div:nth-child(2n) { border-right: 0; }
.cover-kpis > div:nth-child(n + 3) { border-bottom: 0; }

.cover-kpis span { font-size: 8pt; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); }
.cover-kpis strong { font-size: 17pt; font-weight: 700; font-variant-numeric: tabular-nums; }

.cover-contents {
    margin-top: auto;
    border-top: 1px solid var(--ink);
    padding-top: 4mm;
}

.cover-contents h3 { font-size: 8pt; text-transform: uppercase; letter-spacing: 0.14em; margin: 0 0 3mm; color: var(--muted); }
.cover-contents ol { list-style: none; margin: 0; padding: 0; counter-reset: toc; display: grid; grid-template-columns: 1fr 1fr; gap: 1.6mm 8mm; }
.cover-contents li { counter-increment: toc; display: flex; align-items: center; gap: 2mm; font-size: 9pt; }
.cover-contents li::before { content: counter(toc); font-weight: 700; color: var(--muted); width: 4mm; }
.cover-contents li span { flex: 1; }
.cover-contents li i { flex: 0 0 auto; border-bottom: 1px dotted var(--rule); width: 6mm; }

.cover-note { margin: 0; font-size: 7.5pt; color: var(--muted); }

/* Section headers */
.page-head {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 4mm;
    padding-bottom: 2.5mm;
    margin-bottom: 4mm;
    border-bottom: 2px solid var(--brand);
}

.page-head h2 { font-size: 14pt; margin: 0; font-weight: 700; color: var(--ink); display: flex; align-items: center; gap: 2.5mm; }
.sec-no {
    display: inline-grid;
    place-items: center;
    width: 7mm;
    height: 7mm;
    border-radius: 2mm;
    background: var(--brand);
    color: #fff;
    font-size: 9pt;
    font-weight: 700;
}

.page-period { font-size: 8.5pt; color: var(--muted); }

/* Accounting statements */
.fs,
.grid {
    width: 100%;
    border-collapse: collapse;
    font-size: 9.5pt;
}

.fs td,
.fs th,
.grid td,
.grid th {
    padding: 1.7mm 2.5mm;
    text-align: left;
    vertical-align: middle;
}

.fs .fs-amt,
.grid .r { text-align: right; white-space: nowrap; }
.fs .fs-share { text-align: right; width: 22mm; color: var(--muted); font-size: 8.5pt; white-space: nowrap; }
.fs-indent { padding-left: 7mm !important; }
.fs-indent-2 { padding-left: 13mm !important; color: var(--muted); font-size: 8.5pt; }
.fs-note { color: var(--muted); font-size: 8pt; margin-left: 1.5mm; }

.fs-section th {
    padding-top: 4mm;
    font-size: 7.5pt;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--muted);
    border-bottom: 1px solid var(--rule);
}

.fs-sub td { font-size: 8.5pt; color: var(--muted); }

.fs-total th,
.fs-total td {
    border-top: 1px solid var(--ink);
    font-weight: 700;
    padding-top: 2.2mm;
}

.fs-result th,
.fs-result td {
    background: var(--brand-soft);
    font-weight: 700;
    font-size: 10.5pt;
    border-top: 2px solid var(--brand);
    border-bottom: 2px solid var(--brand);
    padding-top: 2.6mm;
    padding-bottom: 2.6mm;
}

.fs-foot { margin: 3mm 0 0; font-size: 8pt; color: var(--muted); }

.kpi-row {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 3mm;
    margin-top: 6mm;
}

.kpi-row-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); margin-bottom: 4mm; }

.kpi-row > div {
    border: 1px solid var(--rule);
    border-radius: 2.5mm;
    padding: 3mm 3.5mm;
    display: flex;
    flex-direction: column;
    gap: 1mm;
}

.kpi-row span { font-size: 7.5pt; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); }
.kpi-row strong { font-size: 12pt; font-variant-numeric: tabular-nums; }

.grid thead th {
    background: var(--ink);
    color: #fff;
    font-size: 8pt;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    padding-top: 2.2mm;
    padding-bottom: 2.2mm;
}

.grid tbody td { border-bottom: 1px solid var(--rule); }
.grid tbody tr:nth-child(even) td { background: #f7faf9; }
.grid tfoot th,
.grid tfoot td { border-top: 2px solid var(--ink); font-weight: 700; }
.grid .grid-group th {
    background: var(--brand-soft);
    color: var(--ink);
    font-size: 8.5pt;
    border-bottom: 0;
}

.grid .strong { font-weight: 700; }

/* Chart */
.chart { margin: 0 0 5mm; }
.chart svg { width: 100%; height: auto; display: block; }
.chart .grid-line { stroke: var(--rule); stroke-width: 0.6; }
.chart .axis-label { font-size: 8px; fill: var(--muted); }
.chart .bar-in { fill: #111827; }
.chart .bar-out { fill: #9ca3af; }
.chart figcaption { display: flex; gap: 6mm; margin-top: 2mm; font-size: 8pt; color: var(--muted); }
.legend { display: inline-flex; align-items: center; gap: 1.5mm; }
.legend i { width: 3mm; height: 3mm; border-radius: 0.6mm; display: inline-block; }
.sw-in { background: #111827; }
.sw-out { background: #9ca3af; }

.basis { margin: 0; padding-left: 5mm; font-size: 9pt; display: flex; flex-direction: column; gap: 2mm; }

/* Approval */
.approval { border-top: 2px solid var(--ink); }
.approval h3 { font-size: 9pt; text-transform: uppercase; letter-spacing: 0.12em; margin: 0; color: var(--muted); }
.approval .signatures { margin-top: 8mm; gap: 8mm; grid-template-columns: repeat(3, minmax(0, 1fr)); }
.approval .signatures > div { font-size: 9pt; }
.approval .signatures strong { font-weight: 600; }
.approval .signatures small { color: var(--muted); font-size: 7.5pt; }

.doc-footer {
    display: flex;
    justify-content: space-between;
    gap: 4mm;
    padding: 4mm 16mm 0;
    margin-top: 6mm;
    border-top: 1px solid var(--rule);
    font-size: 7.5pt;
    color: var(--muted);
}

/* Screen: each block reads like a page */
@media screen and (max-width: 760px) {
    .statement-doc { font-size: 9.5pt; }
    .statement-doc .page, .statement-doc .page-inline, .statement-doc .cover, .statement-doc .approval { padding: 8mm 5mm; }
    .cover-kpis { grid-template-columns: 1fr; }
    .cover-contents ol { grid-template-columns: 1fr; }
    .kpi-row, .kpi-row-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .statement-doc .grid, .statement-doc .fs { display: block; overflow-x: auto; white-space: nowrap; }
}

@media print {
    @page {
        size: A4;
        margin: 14mm 14mm 16mm;
        @bottom-left { content: "Financial statement"; font-size: 7.5pt; color: #64748b; }
        @bottom-right { content: "Page " counter(page) " of " counter(pages); font-size: 7.5pt; color: #64748b; }
    }

    html, body, .print-body { background: #fff !important; }
    .statement-doc {
        width: auto;
        max-width: none;
        margin: 0;
        box-shadow: none;
        font-size: 9.5pt;
    }

    .statement-doc .cover,
    .statement-doc .page,
    .statement-doc .page-inline,
    .statement-doc .approval { padding: 0; }

    .cover {
        min-height: 265mm;
        padding: 12mm 14mm;
        margin: -14mm -14mm 0;
        width: calc(100% + 28mm);
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
        break-after: page;
    }

    .statement-doc .page { break-before: page; border-top: 0; }
    .statement-doc .page-inline { break-before: auto; }
    .statement-doc .page-inline + .page-inline,
    .statement-doc .approval { break-before: auto; }

    .page-head, .fs-section, .grid thead, .chart, .kpi-row, .approval { break-inside: avoid; break-after: avoid; }
    .fs tr, .grid tr { break-inside: avoid; }
    .grid thead { display: table-header-group; }
    .fs-result th, .fs-result td, .fs-total th, .fs-total td, .grid thead th, .sec-no, .grid .grid-group th, .cover-kpis > div, .cover-contents, .kpi-row > div {
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    .doc-footer { display: none; }
    .approval { break-before: auto; }
}

/* ---------- Pagination ---------- */

.pagination {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
    border-top: 1px solid var(--border);
    font-size: 0.88rem;
    color: var(--text-muted);
}

.pagination-links { display: flex; align-items: center; gap: 0.5rem; }
.pagination-current { padding: 0 0.5rem; }

/* ---------- Export grid ---------- */

.export-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 0.75rem;
}

/* ---------- Guest pages ---------- */

.guest-body {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 1.5rem 1rem;
}

.guest-wrap {
    width: 100%;
    max-width: 420px;
}

.login-card {
    padding: 2rem 1.75rem;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    box-shadow: var(--shadow-lg);
}

.login-brand { text-align: center; display: flex; flex-direction: column; align-items: center; gap: 0.4rem; }
.login-logo { width: 72px; height: 72px; object-fit: contain; border-radius: 18px; background: var(--brand-soft); padding: 8px; }
.login-brand h1 { font-size: 1.35rem; }
.login-form { display: flex; flex-direction: column; gap: 1rem; }

.error-card {
    text-align: center;
    padding: 2.5rem 1.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    align-items: center;
}

.error-code {
    font-size: 3.5rem;
    font-weight: 800;
    color: var(--brand);
    line-height: 1;
}

/* ---------- Receipt and printable report ---------- */

.receipt {
    max-width: 820px;
    margin: 0 auto;
    width: 100%;
    padding: 2rem;
}

.receipt-head {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
    padding-bottom: 1.25rem;
    border-bottom: 2px solid var(--brand);
}

.receipt-head h3 { font-size: 1.25rem; }
.receipt-logo { width: 56px; height: 56px; object-fit: contain; }
.receipt-meta { margin-left: auto; display: flex; flex-direction: column; gap: 0.25rem; text-align: right; font-size: 0.9rem; }

.receipt-details {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.9rem 1.5rem;
    margin: 1.5rem 0 0.5rem;
}

.receipt-details dt { font-size: 0.78rem; color: var(--text-muted); font-weight: 500; }
.receipt-details dd { margin: 0.1rem 0 0; font-weight: 600; }
.receipt-details .strong { color: var(--brand-strong); }
.receipt-foot { margin-top: 1.75rem; text-align: center; }

.print-body {
    background: #fff;
    color: #111;
    padding: 0;
}

.print-toolbar {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid #e5e7eb;
    background: #f9fafb;
}

.report-sheet {
    max-width: 880px;
    margin: 2rem auto;
    padding: 0 1.5rem;
}

.report-head {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding-bottom: 1rem;
    border-bottom: 2px solid #0f766e;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.report-head h1 { font-size: 1.4rem; }
.report-date { margin-left: auto; font-size: 0.85rem; }
.report-sheet h2 { font-size: 1.05rem; margin: 1.5rem 0 0.5rem; }

/* ---------- Responsive ---------- */

@media (max-width: 1100px) {
    .stat-grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 960px) {
    .app-shell { grid-template-columns: minmax(0, 1fr); }

    .icon-btn.only-mobile { display: inline-grid; }

    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        bottom: 0;
        width: min(86vw, 300px);
        height: 100vh;
        z-index: 40;
        transform: translateX(-102%);
        transition: transform 0.25s ease;
        box-shadow: var(--shadow-lg);
    }

    .sidebar.is-open { transform: translateX(0); }

    .topbar { padding: 0 1rem; }
    .content { padding: 1.25rem 1rem; }
    .grid-2 { grid-template-columns: minmax(0, 1fr); }
    .user-meta { display: none; }
}

@media (max-width: 720px) {
    body { font-size: 14.5px; }

    .calendar-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .calendar-summary { grid-template-columns: minmax(0, 1fr); }
    h2 { font-size: 1.35rem; }

    .form-grid { grid-template-columns: minmax(0, 1fr); }
    .stat-grid-2,
    .stat-grid-3 { grid-template-columns: minmax(0, 1fr); }

    .toolbar { padding: 0.8rem; }
    .toolbar .form-control,
    .toolbar .search { flex: 1 1 100%; width: 100%; }

    .receipt { padding: 1.25rem; }
    .receipt-details { grid-template-columns: minmax(0, 1fr); }
    .receipt-meta { margin-left: 0; text-align: left; }

    .table .num,
    .table td,
    .table th { padding: 0.65rem 0.7rem; }

    .card { padding: 1rem; }
    .hero-meta { gap: 1.25rem; }
    .page-header { align-items: flex-start; }
    .app-footer { padding: 1rem; }
}

@media print {
    .statement-print .report-head { border-bottom-color: #111; }
    .statement-print h2 { font-size: 1rem; margin: 1.25rem 0 0.5rem; page-break-after: avoid; }
    .statement-print table { page-break-inside: auto; }
    .statement-print tr { page-break-inside: avoid; }
    .statement-print .table td, .statement-print .table th { padding: 0.35rem 0.5rem; font-size: 0.85rem; }
    .statement-print .table thead th { background: #f3f4f6; }
    .statement-print .total-row th, .statement-print .total-row td { border-top: 1px solid #111; }
    .statement-print .result-row th { border-top: 2px solid #111; border-bottom: 2px double #111; }
    .statement-print .result-row th, .statement-print .result-row td { background: none; }
    .statement-print .basis-note { padding: 0 0 0.5rem; }
    .statement-print .signatures { page-break-inside: avoid; }
    .no-print,
    .sidebar,
    .topbar,
    .app-footer,
    .sidebar-backdrop,
    .print-toolbar { display: none !important; }

    .app-shell { display: block; }
    .content { padding: 0; max-width: none; }
    body { background: #fff; color: #000; }
    .card { box-shadow: none; border: 0; padding: 0; }
    .receipt, .report-sheet { margin: 0 auto; max-width: none; }
    .table thead th { background: #f3f4f6; color: #111; }
    .table td, .table th { color: #111; }
    .badge { border: 1px solid #ccc; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { transition: none !important; animation: none !important; }
}

/* ==========================================================================
   Modern and responsive layer. Loaded last so it refines everything above.
   Mobile first behaviour lives in the (max-width) blocks at the end.
   ========================================================================== */

:root {
    --bottom-nav: 64px;
    --safe-top: env(safe-area-inset-top, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
    --ring: 0 0 0 3px color-mix(in srgb, var(--focus) 30%, transparent);
}

::selection { background: color-mix(in srgb, var(--brand) 28%, transparent); }

html { scroll-behavior: smooth; scroll-padding-top: calc(var(--topbar-height) + 1rem); }

body { min-height: 100dvh; }

* { scrollbar-width: thin; scrollbar-color: var(--border) transparent; }

.skip-link {
    position: fixed;
    left: 1rem;
    top: -4rem;
    z-index: 100;
    padding: 0.6rem 1rem;
    border-radius: var(--radius-sm);
    background: var(--brand);
    color: #fff;
    font-weight: 600;
    transition: top 0.15s;
}

.skip-link:focus { top: 0.75rem; text-decoration: none; }

.icon-btn.only-desktop { display: inline-grid; }
.btn-lg { padding: 0.8rem 1.25rem; font-size: 1rem; }

/* Cards and controls: a little more depth and consistent focus rings */
.card { transition: box-shadow 0.2s, border-color 0.2s; }
.form-control:focus, .search:focus-within { box-shadow: var(--ring); }
.btn:focus-visible, .icon-btn:focus-visible, .tab:focus-visible, .cal-cell:focus-visible, a:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.btn:active { transform: translateY(1px); }

/* Table scroll hints: a soft edge shadow shows when more columns are off screen */
.table-wrap {
    background:
        linear-gradient(to right, var(--surface) 30%, transparent) left center / 36px 100% no-repeat local,
        linear-gradient(to left, var(--surface) 30%, transparent) right center / 36px 100% no-repeat local,
        radial-gradient(farthest-side at 0 50%, rgba(15, 23, 42, 0.16), transparent) left center / 12px 100% no-repeat scroll,
        radial-gradient(farthest-side at 100% 50%, rgba(15, 23, 42, 0.16), transparent) right center / 12px 100% no-repeat scroll;
}

/* Top bar search */
.topbar-search {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    width: min(280px, 26vw);
    padding: 0 0.7rem;
    height: 38px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--surface);
    color: var(--text-muted);
    transition: border-color 0.15s, box-shadow 0.15s, width 0.2s;
}

.topbar-search:focus-within { border-color: var(--focus); box-shadow: var(--ring); width: min(360px, 34vw); }
.topbar-search input { flex: 1; min-width: 0; border: 0; background: transparent; color: var(--text); font: inherit; font-size: 0.9rem; }
.topbar-search input:focus { outline: none; }
.topbar-search .icon { width: 16px; height: 16px; }

/* Two-column financial position: phone version */
.pos-stacked { display: none; }

.pos-list h4 {
    margin: 1.1rem 0 0.45rem;
    font-size: 0.74rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
}

.pos-list ul {
    list-style: none;
    margin: 0;
    padding: 0;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    overflow: hidden;
}

.pos-list li {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 1rem;
    padding: 0.65rem 0.85rem;
    border-bottom: 1px solid var(--border);
    font-size: 0.9rem;
}

.pos-list li:last-child { border-bottom: 0; }
.pos-list li b { font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.pos-list li small { display: block; font-size: 0.74rem; color: var(--text-muted); }
.pos-list li.pos-head span { font-weight: 700; }
.pos-list li.pos-sub { padding-left: 1.5rem; color: var(--text-muted); }
.pos-list li.pos-total { background: var(--surface-2); font-weight: 700; }

.pos-net-card {
    margin-top: 1rem;
    padding: 1rem 1.1rem;
    border-radius: var(--radius-sm);
    background: var(--text);
    color: var(--surface);
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
}

.pos-net-card span { font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.08em; opacity: 0.8; }
.pos-net-card strong { font-size: 1.5rem; font-variant-numeric: tabular-nums; }
.pos-net-card small { opacity: 0.7; }

/* Login */
.guest-wrap { max-width: 980px; }

.auth-shell {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 22px;
    box-shadow: var(--shadow-lg);
    overflow: hidden;
}

.auth-brand {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    justify-content: center;
    padding: 2.75rem 2.5rem;
    color: #fff;
    background:
        radial-gradient(520px 260px at 0% 0%, rgba(45, 212, 191, 0.28), transparent 70%),
        linear-gradient(160deg, #0f766e, #0b3b37 70%);
}

.auth-logo { width: 64px; height: 64px; object-fit: contain; background: #fff; border-radius: 18px; padding: 8px; }
.auth-brand h1 { color: #fff; font-size: 1.6rem; letter-spacing: -0.01em; }
.auth-brand p { opacity: 0.85; max-width: 32ch; }
.auth-points { list-style: none; margin: 0.5rem 0 0; padding: 0; display: flex; flex-direction: column; gap: 0.7rem; font-size: 0.92rem; }
.auth-points li { display: flex; align-items: center; gap: 0.7rem; opacity: 0.95; }
.auth-points .icon { flex: none; width: 18px; height: 18px; color: #5eead4; }

.auth-card { padding: 2.75rem 2.5rem; display: flex; flex-direction: column; gap: 1.25rem; justify-content: center; }
.auth-card-head { display: flex; flex-direction: column; gap: 0.2rem; }
.auth-card-head h2 { font-size: 1.5rem; }
.auth-logo-sm { display: none; width: 52px; height: 52px; object-fit: contain; border-radius: 14px; background: var(--brand-soft); padding: 6px; margin-bottom: 0.4rem; }
.auth-foot { text-align: center; }
.login-form { gap: 1.1rem; }

.guest-wrap .toast-stack { margin-bottom: 0; }

/* ----- Collapsible sidebar (desktop) ----- */
@media (min-width: 961px) {
    .app-shell { transition: grid-template-columns 0.22s ease; }

    .sidebar-collapsed .app-shell { grid-template-columns: 78px minmax(0, 1fr); }
    .sidebar-collapsed .sidebar { padding-inline: 0.65rem; }
    .sidebar-collapsed .sidebar-brand { justify-content: center; padding-inline: 0; }
    .sidebar-collapsed .sidebar-brand > div,
    .sidebar-collapsed .nav-link span,
    .sidebar-collapsed .nav-heading { display: none; }
    .sidebar-collapsed .nav-link { justify-content: center; padding-inline: 0; }
    .sidebar-collapsed .nav { gap: 0.4rem; }
    .sidebar-collapsed .nav-group + .nav-group { border-top: 1px solid rgba(255, 255, 255, 0.08); padding-top: 0.5rem; }
    .sidebar-collapsed .nav-link.is-active { box-shadow: none; }
    .bottom-nav, .sheet, .sheet-backdrop { display: none !important; }
}

/* ----- Tablet and phone navigation ----- */
@media (max-width: 960px) {
    .icon-btn.only-desktop { display: none; }
    .topbar-search { display: none; }

    .topbar {
        height: calc(var(--topbar-height) + var(--safe-top));
        padding-top: var(--safe-top);
    }

    .app-main { padding-bottom: calc(var(--bottom-nav) + var(--credit-h) + var(--safe-bottom) + var(--nav-lift) + 0.65rem); }

    /* Floating pill navigation (matches the member portal) */
    .bottom-nav {
        position: fixed;
        left: 0;
        right: 0;
        bottom: calc(var(--nav-lift) + var(--safe-bottom));
        z-index: 35;
        display: flex;
        flex-direction: column;
        align-items: stretch;
        width: min(460px, calc(100% - 2rem));
        margin: 0 auto;
        padding: 0.35rem;
        background: color-mix(in srgb, var(--surface) 86%, transparent);
        backdrop-filter: saturate(1.5) blur(16px);
        border: 1px solid color-mix(in srgb, var(--border) 80%, transparent);
        border-radius: 22px; /* gentle pill, only slightly rounded */
        box-shadow: 0 12px 30px rgba(15, 23, 42, 0.16), 0 2px 6px rgba(15, 23, 42, 0.08);
    }

    .bn-item {
        position: relative;
        flex: 1;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 0.2rem;
        border: 0;
        border-radius: 16px;
        background: transparent;
        color: var(--text-muted);
        font: inherit;
        font-size: 0.68rem;
        font-weight: 600;
        cursor: pointer;
        -webkit-tap-highlight-color: transparent;
        text-decoration: none;
        transition: color 0.15s, background 0.15s;
    }

    .bn-item .icon { width: 21px; height: 21px; }
    .bn-item:hover { text-decoration: none; color: var(--text); }
    .bn-item.is-active { color: var(--brand-strong); background: var(--brand-soft); }

    .sheet-backdrop {
        position: fixed;
        inset: 0;
        z-index: 36;
        background: rgba(2, 6, 23, 0.5);
    }

    .sheet {
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 37;
        padding: 0.6rem 1rem calc(1rem + var(--safe-bottom));
        background: var(--surface);
        border-radius: 20px 20px 0 0;
        box-shadow: var(--shadow-lg);
        animation: sheet-in 0.22s ease-out;
    }

    .sheet-grab { width: 40px; height: 4px; border-radius: 4px; background: var(--border); margin: 0 auto 0.8rem; }
    .sheet-title { font-size: 1rem; margin-bottom: 0.6rem; }
    .sheet-links { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.6rem; }

    .sheet-link {
        display: flex;
        align-items: center;
        gap: 0.7rem;
        padding: 0.8rem;
        border: 1px solid var(--border);
        border-radius: var(--radius-sm);
        color: var(--text);
        font-weight: 600;
        font-size: 0.9rem;
    }

    .sheet-link:hover { text-decoration: none; border-color: var(--brand); }
    .sheet-link.is-active { border-color: var(--brand); background: var(--brand-soft); }

    .sheet-icon {
        flex: none;
        width: 34px;
        height: 34px;
        display: grid;
        place-items: center;
        border-radius: 10px;
        background: var(--brand-soft);
        color: var(--brand-strong);
    }

    .toast-stack { top: calc(var(--topbar-height) + var(--safe-top) + 0.5rem); }

    .auth-shell { grid-template-columns: minmax(0, 1fr); max-width: 460px; margin: 0 auto; }
    .auth-brand { display: none; }
    .auth-logo-sm { display: block; }
    .auth-card { padding: 2rem 1.5rem; }
    .guest-wrap { max-width: 460px; }
}

/* ----- Phones ----- */
@media (max-width: 720px) {
    .content { padding: 1rem 0.9rem 1.5rem; gap: 1rem; }

    /* Touch targets and no iOS zoom on focus */
    .btn, .form-control, .icon-btn, .tab { min-height: 44px; }
    .btn-sm { min-height: 38px; }
    .icon-btn { width: 44px; height: 44px; }
    input, select, textarea, .form-control { font-size: 16px; }

    /* Page header: title first, actions as a tidy grid */
    .page-header { flex-direction: column; align-items: stretch; gap: 0.9rem; }
    .page-header h2 { font-size: 1.35rem; }
    .page-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; }
    .page-actions > form { display: contents; }
    .page-actions .btn { flex: 1 1 calc(50% - 0.25rem); }
    .page-actions > .btn:only-child,
    .page-actions > .menu:only-child { flex-basis: 100%; }
    .page-actions .menu { flex: 1 1 calc(50% - 0.25rem); }
    .page-actions .menu > summary { width: 100%; }

    /* Compact stat cards, two per row */
    .stat-grid,
    .stat-grid-2,
    .stat-grid-3,
    .stat-grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.65rem; }
    .stat-grid > :last-child:nth-child(odd),
    .kpi-grid > :last-child:nth-child(odd) { grid-column: 1 / -1; }
    .stat-card { padding: 0.85rem; gap: 0.2rem; }
    .stat-value { font-size: 1.1rem; }
    .stat-label { font-size: 0.74rem; }
    .stat-sub { font-size: 0.72rem; }
    .stat-icon { width: 30px; height: 30px; margin-bottom: 0.2rem; }
    .small-value { font-size: 0.95rem; }
    .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.65rem; }
    .kpi { padding: 0.85rem; }
    .kpi-value { font-size: 1.05rem; }
    .kpi-label { font-size: 0.68rem; }
    .kpi-sub { font-size: 0.72rem; }

    .hero-card { padding: 1.1rem; gap: 1rem; }
    .hero-meta { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.75rem; width: 100%; }
    .hero-meta > div { min-width: 0; }
    .hero-meta strong { font-size: 1rem; }

    .grid-2 { gap: 1rem; }
    .card { padding: 1rem; border-radius: 14px; }
    .card-header { flex-wrap: wrap; margin-bottom: 0.75rem; }
    .chart-box { height: 220px; }

    /* Filters: search on top, controls in a two column grid */
    .toolbar { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.6rem; padding: 0.8rem; }
    .toolbar .search { grid-column: 1 / -1; flex: none; width: 100%; }
    .toolbar .form-control { width: 100%; min-width: 0; }
    .toolbar .btn { width: 100%; }
    .toolbar .toolbar-spacer { display: none; }
    .toolbar-total { align-items: flex-start; grid-column: 1 / -1; }
    .report-controls .field-inline, .period-form .field-inline { width: 100%; }

    /* Lists become cards */
    .js .table[data-stack] thead { display: none; }
    .js .table[data-stack],
    .js .table[data-stack] tbody { display: flex; flex-direction: column; }
    .js .table[data-stack] tbody { gap: 0.65rem; padding: 0.75rem; }

    .js .table[data-stack] tr {
        display: flex;
        flex-direction: column;
        padding: 0.8rem 0.95rem;
        border: 1px solid var(--border);
        border-radius: 12px;
        background: var(--surface);
    }

    .js .table[data-stack] tbody tr:hover td { background: transparent; }

    .js .table[data-stack] td {
        display: flex;
        justify-content: space-between;
        align-items: baseline;
        gap: 1rem;
        padding: 0.28rem 0;
        border: 0;
        text-align: right;
        white-space: normal;
        max-width: none;
    }

    .js .table[data-stack] td::before {
        content: attr(data-label);
        flex: none;
        font-size: 0.7rem;
        font-weight: 600;
        text-transform: uppercase;
        letter-spacing: 0.05em;
        color: var(--text-muted);
        text-align: left;
    }

    .js .table[data-stack] td[data-label=""]::before { display: none; }

    .js .table[data-stack] td.stack-primary {
        order: -1;
        display: block;
        text-align: left;
        font-size: 1rem;
        font-weight: 700;
        padding-bottom: 0.45rem;
        margin-bottom: 0.3rem;
        border-bottom: 1px solid var(--border);
    }

    .js .table[data-stack] td.stack-primary::before { display: none; }

    .js .table[data-stack] td.actions {
        order: 99;
        justify-content: flex-end;
        gap: 0.4rem;
        margin-top: 0.4rem;
        padding-top: 0.55rem;
        border-top: 1px dashed var(--border);
    }

    .js .table[data-stack] td.actions::before { display: none; }
    .js .table[data-stack] td.wrap { max-width: none; }

    .table-card .pagination { padding: 0.9rem; justify-content: center; text-align: center; }
    .pagination-links { width: 100%; justify-content: space-between; }

    /* Forms */
    .form-grid { grid-template-columns: minmax(0, 1fr); gap: 0.9rem; }
    .form-card { gap: 1rem; }

    .form-card > .form-actions {
        position: sticky;
        bottom: calc(var(--bottom-nav) + var(--credit-h) + var(--safe-bottom) + var(--nav-lift) + 0.4rem);
        z-index: 5;
        margin: 0 -1rem -1rem;
        padding: 0.8rem 1rem;
        background: color-mix(in srgb, var(--surface) 94%, transparent);
        backdrop-filter: blur(8px);
        border-top: 1px solid var(--border);
        border-radius: 0 0 14px 14px;
    }

    .form-card > .form-actions .btn { flex: 1; }
    .modal-form-actions .btn { flex: 1; }

    /* Detail pages */
    .activity-list li { align-items: flex-start; }
    .calendar-summary { padding: 0.75rem; }

    /* Financial position: stacked lists instead of four narrow columns */
    .pos-table { display: none; }
    .pos-stacked { display: block; padding: 0 0.9rem 1rem; }
    .statement-card > .statement-head { padding: 0.9rem; }

    .statement-head { flex-wrap: wrap; }
    .ledger-table td, .ledger-table th { padding: 0.55rem 0.8rem; }

    .report-tabs { margin-inline: -0.9rem; padding-inline: 0.9rem; }
    .segmented a { min-height: 40px; display: grid; place-items: center; }

    /* Payment dialog becomes a full-height sheet with a grab handle */
    .modal-box::before {
        content: "";
        display: block;
        width: 40px;
        height: 4px;
        border-radius: 4px;
        background: var(--border);
        margin: 0.55rem auto 0;
        flex: none;
    }

    .modal-head { padding-top: 0.6rem; }
    .calendar-grid { gap: 0.55rem; }
    .cal-cell { padding: 0.7rem; min-height: 88px; }

}

@media (max-width: 340px) {
    .stat-grid, .stat-grid-2, .stat-grid-3, .stat-grid-4, .kpi-grid { gap: 0.5rem; }
    .stat-value, .kpi-value { font-size: 1rem; }
    .page-actions .btn { flex-basis: 100%; }
}

@media (max-width: 340px) {
    .sheet-links { grid-template-columns: minmax(0, 1fr); }
}

@media print {
    .bottom-nav, .sheet, .sheet-backdrop, .topbar-search, .skip-link { display: none !important; }
    .pos-stacked { display: none !important; }
    .pos-table { display: table !important; }
    .app-main { padding-bottom: 0 !important; }
}
body.no-scroll { overflow: hidden; }


/* ----- Card lists: compact two-column field grid, no nested card ----- */
@media (max-width: 720px) {
    .table-card:has(table[data-stack]) {
        background: transparent;
        border: 0;
        box-shadow: none;
        overflow: visible;
    }

    .table-wrap:has(table[data-stack]) { background: none; overflow: visible; }

    .js .table[data-stack] tbody { padding: 0; gap: 0.6rem; }

    .js .table[data-stack] tr {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 0.6rem 1rem;
        padding: 0.85rem 0.95rem;
        box-shadow: var(--shadow);
    }

    .js .table[data-stack] td {
        display: block;
        min-width: 0;
        padding: 0;
        text-align: left;
        overflow-wrap: anywhere;
    }

    .js .table[data-stack] td::before { display: block; margin-bottom: 0.12rem; }

    .js .table[data-stack] td.stack-primary,
    .js .table[data-stack] td.wrap,
    .js .table[data-stack] td.actions { grid-column: 1 / -1; }

    .js .table[data-stack] td.stack-primary { padding-bottom: 0.5rem; margin-bottom: 0; }

    .js .table[data-stack] td.actions {
        display: flex;
        justify-content: flex-end;
        margin-top: 0;
        padding-top: 0.5rem;
    }

    .table-card:has(table[data-stack]) .pagination { border-top: 0; padding: 0.5rem 0 0; }
}
@media (max-width: 720px) {
    .segmented a { white-space: nowrap; font-size: 0.78rem; padding-inline: 0.3rem; }
}
/* ----- Wide data tables on phones: pinned first column and tighter cells ----- */
@media (max-width: 720px) {
    .table-wrap .table:not([data-stack]) th,
    .table-wrap .table:not([data-stack]) td { padding: 0.6rem 0.7rem; font-size: 0.84rem; }

    .table-wrap .table:not([data-stack]) th:first-child,
    .table-wrap .table:not([data-stack]) td:first-child {
        position: sticky;
        left: 0;
        z-index: 2;
        background: var(--surface);
        box-shadow: 1px 0 0 var(--border);
    }

    .table-wrap .table:not([data-stack]) thead th:first-child { background: var(--surface-2); z-index: 3; }
    .table-wrap .table:not([data-stack]) tfoot th:first-child,
    .table-wrap .table:not([data-stack]) tfoot td:first-child { background: var(--surface); }
    .table-wrap .table:not([data-stack]) .group-row th:first-child { background: var(--surface-2); }
    .table-wrap .table:not([data-stack]) .opening-row td:first-child { background: var(--surface-2); }

    .table-wrap .table:not([data-stack]) td:first-child { white-space: nowrap; }
    .table-wrap .table.ledger td.wrap { min-width: 180px; }
    .table .bar-col { min-width: 130px; }
    .bar { width: 70px; }
}
/* ==========================================================================
   Phone and tablet: the bottom bar is the navigation, so there is no top bar
   and no side drawer. "More" opens a sheet with the remaining menus.
   ========================================================================== */
@media (max-width: 960px) {
    .topbar,
    .sidebar,
    .sidebar-backdrop { display: none !important; }

    .content { padding-top: calc(1.1rem + var(--safe-top)); }
    .toast-stack { top: calc(var(--safe-top) + 0.6rem); }

    .sheet-tall {
        max-height: 88dvh;
        overflow-y: auto;
        overscroll-behavior: contain;
        padding-bottom: calc(1.25rem + var(--safe-bottom));
    }
}

.sheet-account {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    padding: 0.2rem 0 0.4rem;
}

.sheet-account > div { display: flex; flex-direction: column; min-width: 0; line-height: 1.3; }
.sheet-account strong { font-size: 1.02rem; }
.sheet-account .small { overflow-wrap: anywhere; }
.avatar-lg { width: 46px; height: 46px; font-size: 1rem; flex: none; }

.sheet-heading {
    margin: 1.1rem 0 0.45rem;
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
}

.sheet-list {
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    overflow: hidden;
    background: var(--surface);
}

.sheet-row {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    width: 100%;
    min-height: 54px;
    padding: 0.55rem 0.8rem;
    border: 0;
    background: transparent;
    color: var(--text);
    font: inherit;
    font-size: 0.95rem;
    font-weight: 600;
    text-align: left;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.sheet-row + .sheet-row { border-top: 1px solid var(--border); }
.sheet-row:hover { text-decoration: none; background: var(--surface-2); }
.sheet-row.is-active { background: var(--brand-soft); color: var(--brand-strong); }
.sheet-row-label { flex: 1; min-width: 0; }
.sheet-chevron { width: 16px; height: 16px; margin-left: auto; transform: rotate(-90deg); color: var(--text-muted); flex: none; }

.switch {
    margin-left: auto;
    position: relative;
    flex: none;
    width: 44px;
    height: 26px;
    border-radius: 999px;
    background: var(--border);
    transition: background 0.2s;
}

.switch > span {
    position: absolute;
    top: 3px;
    left: 3px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.3);
    transition: transform 0.2s;
}

.is-dark .switch { background: var(--brand); }
.is-dark .switch > span { transform: translateX(18px); }

.sheet-signout { margin-top: 1.1rem; }
/* ==========================================================================
   Payments dialog (calendar, record payment, history)
   ========================================================================== */

.pay-modal { width: min(960px, calc(100vw - 2rem)); }

.pay-head {
    display: flex;
    align-items: center;
    gap: 0.9rem;
    padding: 1.15rem 1.5rem 0.9rem;
}

.pay-id { flex: 1; min-width: 0; }
.pay-id h3 { font-size: 1.2rem; letter-spacing: -0.01em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.pay-meta {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.45rem;
    margin: 0.2rem 0 0;
    font-size: 0.84rem;
    color: var(--text-muted);
}

/* Segmented tabs */
.pay-tabs {
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: 1fr;
    gap: 2px;
    margin: 0 1.5rem;
    padding: 4px;
    background: var(--muted-soft);
    border-radius: 12px;
}

.pay-tab {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.45rem;
    min-height: 40px;
    padding: 0 0.9rem;
    border: 0;
    border-radius: 9px;
    background: transparent;
    color: var(--text-muted);
    font: inherit;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.15s, color 0.15s, box-shadow 0.15s;
}

.pay-tab .icon { width: 16px; height: 16px; }
.pay-tab:hover { color: var(--text); }
.pay-tab[aria-selected="true"] { background: var(--surface); color: var(--brand-strong); box-shadow: var(--shadow); }

.pay-modal .modal-body { padding: 1.25rem 1.5rem 1.5rem; }
.pay-modal .tab-panel { animation: panel-in 0.18s ease-out; }
@keyframes panel-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ----- Calendar ----- */
.cal { transition: opacity 0.15s; }
.cal.is-loading { opacity: 0.45; pointer-events: none; }

.cal-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
    margin-bottom: 1rem;
}

.year-switch { display: flex; align-items: center; gap: 0.4rem; }
.year-switch .icon-btn { border: 1px solid var(--border); background: var(--surface); }
.year-switch .icon-btn:disabled { opacity: 0.35; cursor: default; }
.year-pick select { width: auto; min-width: 104px; font-weight: 700; font-size: 1.05rem; text-align: center; padding-block: 0.45rem; }

.cal-summary {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr)) minmax(0, 1.4fr);
    gap: 0;
    margin-bottom: 1.1rem;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: var(--surface-2);
    overflow: hidden;
}

.cal-stat, .cal-progress { padding: 0.8rem 1rem; border-right: 1px solid var(--border); }
.cal-progress { border-right: 0; display: flex; flex-direction: column; justify-content: center; gap: 0.4rem; }
.cal-stat { display: flex; flex-direction: column; gap: 0.1rem; }
.cal-stat span, .cal-progress-head span { font-size: 0.72rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-muted); }
.cal-stat strong { font-size: 1.1rem; font-variant-numeric: tabular-nums; }
.cal-stat .is-pos { color: var(--success); }
.cal-stat .is-neg { color: var(--danger); }
.cal-progress-head { display: flex; justify-content: space-between; align-items: baseline; }
.cal-progress .progress { margin-top: 0; }

.cal-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 0.75rem;
}

.cal-tile {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    min-height: 112px;
    padding: 0.8rem 0.85rem 0.95rem;
    text-align: left;
    font: inherit;
    color: var(--text);
    background: color-mix(in srgb, var(--cal) 6%, var(--surface));
    border: 1px solid color-mix(in srgb, var(--cal) 32%, var(--border));
    border-radius: 14px;
    cursor: pointer;
    overflow: hidden;
    transition: transform 0.14s, box-shadow 0.14s, border-color 0.14s, background 0.14s;
    -webkit-tap-highlight-color: transparent;
}

.cal-tile:disabled { cursor: default; }
.cal-tile:not(:disabled):hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.cal-tile.cal-upcoming { border-style: dashed; background: var(--surface); }
.cal-tile.cal-na { background: var(--surface-2); color: var(--text-muted); border-color: var(--border); }
.cal-tile.cal-na .tile-bar { display: none; }

.tile-head { display: flex; justify-content: space-between; align-items: center; }
.tile-month { font-size: 1.05rem; font-weight: 700; letter-spacing: -0.01em; }

.tile-badge {
    display: grid;
    place-items: center;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    color: var(--cal);
    background: color-mix(in srgb, var(--cal) 16%, transparent);
    transition: opacity 0.12s;
}

.tile-badge .icon { width: 13px; height: 13px; stroke-width: 2.4; }
.tile-amount { font-size: 0.9rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.tile-meta { font-size: 0.72rem; color: var(--text-muted); }

.tile-bar {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 5px;
    background: color-mix(in srgb, var(--cal) 14%, transparent);
}

.tile-bar > span { display: block; height: 100%; background: var(--cal); border-radius: 0 3px 3px 0; }

.tile-check {
    position: absolute;
    top: 0.65rem;
    right: 0.7rem;
    display: grid;
    place-items: center;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--brand);
    color: #fff;
    opacity: 0;
    transform: scale(0.5);
    transition: opacity 0.12s, transform 0.14s;
}

.tile-check .icon { width: 13px; height: 13px; stroke-width: 3; }

.tile-now {
    position: absolute;
    right: 0.7rem;
    bottom: 0.85rem;
    padding: 0.04rem 0.42rem;
    border-radius: 999px;
    background: var(--text);
    color: var(--surface);
    font-size: 0.6rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.cal-tile[aria-pressed="true"] {
    background: var(--brand-soft);
    border-color: var(--brand);
    box-shadow: 0 0 0 2px var(--brand);
}

.cal-tile[aria-pressed="true"] .tile-check { opacity: 1; transform: scale(1); }
.cal-tile[aria-pressed="true"] .tile-badge { opacity: 0; }

.cal-legend {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5rem 1.1rem;
    margin-top: 1rem;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.cal-legend .legend-hint { margin-left: auto; font-style: italic; }

/* ----- Selection bar ----- */
.pay-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    padding: 0.85rem 1.5rem;
    border-top: 1px solid var(--border);
    background: var(--surface);
    box-shadow: 0 -8px 24px rgba(15, 23, 42, 0.06);
}

.pay-bar-info { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.pay-bar-info strong { font-size: 0.8rem; font-weight: 600; color: var(--text-muted); }
.pay-bar-info span { font-size: 1.2rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.pay-bar-actions { display: flex; gap: 0.5rem; align-items: center; }

/* ----- Record payment ----- */
.pay-layout {
    display: grid;
    grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr);
    gap: 1.5rem;
    align-items: start;
}

.pay-fields { display: flex; flex-direction: column; gap: 1.1rem; }
.pay-pair { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.9rem; }

.amount-input {
    display: flex;
    align-items: stretch;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface-2);
    overflow: hidden;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.amount-input:focus-within { border-color: var(--focus); box-shadow: var(--ring); }
.amount-input.is-invalid { border-color: var(--danger); }
.amount-prefix { display: grid; place-items: center; padding: 0 0.9rem; background: var(--muted-soft); color: var(--text-muted); font-weight: 600; font-size: 0.9rem; }

.amount-input input {
    flex: 1;
    min-width: 0;
    padding: 0.75rem 0.9rem;
    border: 0;
    background: transparent;
    color: var(--text);
    font: inherit;
    font-size: 1.4rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.amount-input input:focus { outline: none; }

.presets { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-top: 0.6rem; }

.chip {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.38rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--surface);
    color: var(--text-muted);
    font: inherit;
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    transition: border-color 0.15s, color 0.15s, background 0.15s;
}

.chip b { color: var(--text); font-weight: 700; }
.chip:hover { border-color: var(--brand); color: var(--brand-strong); }
.chip.is-active { background: var(--brand-soft); border-color: var(--brand); color: var(--brand-strong); }

.pay-summary {
    padding: 1.1rem;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: var(--surface-2);
    display: flex;
    flex-direction: column;
    gap: 0.9rem;
    min-width: 0;
}

.pay-summary h4 { margin: 0; font-size: 0.74rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-muted); }
.summary-label { display: block; margin-bottom: 0.35rem; font-size: 0.8rem; color: var(--text-muted); }
.chip-list { display: flex; flex-wrap: wrap; gap: 0.35rem; }
.chip-list .tag { padding: 0.2rem 0.6rem; border-radius: 999px; background: var(--brand-soft); color: var(--brand-strong); font-size: 0.78rem; font-weight: 600; }

.summary-preview .allocation-list { margin: 0; }
.summary-preview .allocation-list li { background: var(--surface); border: 1px solid var(--border); }

.alloc-total {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-top: 0.7rem;
    padding-top: 0.7rem;
    border-top: 1px dashed var(--border);
    font-size: 0.9rem;
}

.alloc-total b { font-size: 1.15rem; font-variant-numeric: tabular-nums; }
.alloc-error { color: var(--danger); font-size: 0.86rem; }
.summary-preview.is-loading { opacity: 0.5; }

.pay-actions {
    grid-column: 1 / -1;
    display: flex;
    justify-content: flex-end;
    gap: 0.6rem;
    padding-top: 0.25rem;
}

/* ----- History timeline ----- */
.timeline-year { margin: 0.4rem 0 0.5rem; font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-muted); }
.timeline-year:first-child { margin-top: 0; }

.timeline {
    list-style: none;
    margin: 0 0 1.2rem 0.45rem;
    padding: 0;
    border-left: 2px solid var(--border);
}

.timeline-item {
    position: relative;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    padding: 0.6rem 0 0.6rem 1.15rem;
}

.timeline-dot {
    position: absolute;
    left: -7px;
    top: 50%;
    width: 12px;
    height: 12px;
    margin-top: -6px;
    border-radius: 50%;
    background: var(--surface);
    border: 3px solid var(--success);
}

.timeline-item.is-partial .timeline-dot { border-color: var(--warning); }
.timeline-main { display: flex; flex-direction: column; min-width: 0; }
.timeline-side { display: flex; align-items: center; gap: 0.6rem; flex: none; }
.timeline-side b { font-variant-numeric: tabular-nums; }

/* ----- Phones: full-height sheet, compact tiles, sticky actions ----- */
@media (max-width: 720px) {
    .pay-modal { width: 100vw; max-height: 94dvh; }
    .pay-modal .modal-box { max-height: 94dvh; }

    .pay-head { padding: 0.5rem 1rem 0.7rem; gap: 0.7rem; }
    .pay-head .avatar-lg { width: 40px; height: 40px; font-size: 0.9rem; }
    .pay-id h3 { font-size: 1.05rem; }

    .pay-tabs { margin: 0 1rem; }
    .pay-tab { padding: 0 0.4rem; gap: 0.35rem; font-size: 0.82rem; }
    .pay-tab .icon { width: 15px; height: 15px; }

    .pay-modal .modal-body { padding: 1rem 1rem 1.25rem; }

    .cal-toolbar { margin-bottom: 0.8rem; }
    .year-switch { flex: 1; justify-content: space-between; }
    .year-pick { flex: 1; }
    .year-pick select { width: 100%; }
    .cal-actions { width: 100%; }
    .cal-actions .btn { width: 100%; }

    .cal-summary { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .cal-stat { padding: 0.65rem 0.7rem; }
    .cal-stat strong { font-size: 0.92rem; }
    .cal-stat span, .cal-progress-head span { font-size: 0.64rem; }
    .cal-progress { grid-column: 1 / -1; border-top: 1px solid var(--border); padding: 0.6rem 0.8rem; }

    .cal-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0.5rem; }
    .cal-tile { min-height: 92px; padding: 0.6rem 0.65rem 0.8rem; border-radius: 12px; }
    .tile-month { font-size: 0.98rem; }
    .tile-badge { width: 20px; height: 20px; }
    .tile-badge .icon { width: 11px; height: 11px; }
    .tile-check { top: 0.5rem; right: 0.55rem; width: 20px; height: 20px; }
    .tile-amount { font-size: 0.8rem; }
    .tile-meta { display: none; }
    .tile-now { right: 0.55rem; bottom: 0.7rem; font-size: 0.55rem; }

    .cal-legend { gap: 0.4rem 0.9rem; }
    .cal-legend .legend-hint { margin-left: 0; width: 100%; }

    .pay-bar { padding: 0.75rem 1rem calc(0.75rem + var(--safe-bottom)); }
    .pay-bar-actions .btn-ghost { display: none; }

    .pay-layout { grid-template-columns: minmax(0, 1fr); gap: 1rem; }
    .pay-pair { grid-template-columns: minmax(0, 1fr); gap: 0.9rem; }
    .amount-input input { font-size: 1.3rem; }
    .chip { min-height: 36px; }

    .pay-actions {
        position: sticky;
        bottom: -1.25rem;
        z-index: 4;
        margin: 0 -1rem -1.25rem;
        padding: 0.8rem 1rem calc(0.8rem + var(--safe-bottom));
        background: color-mix(in srgb, var(--surface) 95%, transparent);
        backdrop-filter: blur(8px);
        border-top: 1px solid var(--border);
    }

    .pay-actions .btn { flex: 1; }
    .pay-actions .btn-ghost { flex: 0 0 auto; }
}

@media (max-width: 360px) {
    .cal-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
/* Keep the dialog the same height on every tab so it does not jump */
.pay-modal .modal-box { min-height: min(74dvh, 620px); }
/* Totals live in the summary cards on phones, so the footer row is hidden in card lists */
@media (max-width: 720px) {
    .js .table[data-stack] tfoot { display: none; }
}
/* ==========================================================================
   Staff, salaries and advances
   ========================================================================== */
.salary-form { display: flex; flex-direction: column; gap: 1rem; }

.salary-preview {
    padding: 0.9rem 1rem;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--surface-2);
    transition: opacity 0.15s;
}

.salary-preview.is-loading { opacity: 0.5; }
.sp-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.5rem; }
.sp-row { padding: 0.6rem 0.75rem; border-radius: 10px; background: var(--surface); border: 1px solid var(--border); }
.sp-head { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; }
.sp-pay { font-weight: 700; font-variant-numeric: tabular-nums; }
.sp-meta { display: flex; flex-wrap: wrap; gap: 0.2rem 0.9rem; margin-top: 0.15rem; font-size: 0.78rem; color: var(--text-muted); }
.sp-meta .is-due { color: var(--warning); font-weight: 600; }
.sp-meta .is-done { color: var(--success); font-weight: 600; }

.advance-list { display: flex; flex-direction: column; gap: 0.9rem; margin-top: 1.1rem; }

.advance {
    padding: 0.95rem 1rem;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: var(--surface);
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.advance.is-active { border-color: color-mix(in srgb, var(--warning) 40%, var(--border)); background: color-mix(in srgb, var(--warning) 5%, var(--surface)); }
.advance header { display: flex; justify-content: space-between; align-items: center; gap: 1rem; }
.advance header strong { font-size: 1.1rem; font-variant-numeric: tabular-nums; }
.advance .progress { margin: 0; }
.advance-figures { display: flex; justify-content: space-between; gap: 1rem; margin: 0; font-size: 0.86rem; color: var(--text-muted); }
.advance-figures b { color: var(--text); font-variant-numeric: tabular-nums; }
.advance-more summary { cursor: pointer; font-size: 0.84rem; font-weight: 600; color: var(--brand-strong); padding: 0.2rem 0; }

.schedule { list-style: none; margin: 0.4rem 0 0; padding: 0; display: flex; flex-direction: column; gap: 0.25rem; }
.schedule li { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: 0.75rem; align-items: center; padding: 0.35rem 0.6rem; border-radius: 8px; background: var(--surface-2); font-size: 0.84rem; }
.schedule li span:nth-child(2) { font-variant-numeric: tabular-nums; }

.advance-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 0.6rem 1rem; padding-top: 0.6rem; border-top: 1px dashed var(--border); }
.advance-actions form { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem 0.8rem; margin: 0; }
.check { display: inline-flex; align-items: center; gap: 0.5rem; font-size: 0.85rem; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--brand); }

.payment-list .payment-side { display: flex; align-items: center; gap: 0.3rem; flex-direction: row; }
.payment-list .payment-side form { margin: 0; }
.icon-btn.is-disabled { opacity: 0.4; cursor: help; pointer-events: auto; }

.month-bar { justify-content: center; gap: 0.6rem; }
.month-pick .form-control { min-width: 170px; text-align: center; font-weight: 600; }

.payslip .signatures { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.payslip-balance { margin-top: 4mm; }
.payslip-head { padding-bottom: 0 !important; }

@media (max-width: 720px) {
    .month-bar { display: flex; flex-wrap: wrap; }
    .month-pick { flex: 1; }
    .month-pick .form-control { width: 100%; }
    .advance-actions form { width: 100%; }
    .advance-actions .btn { width: 100%; }
    .payment-list .payment-side { gap: 0.1rem; }
}
/* ==========================================================================
   Member portal + floating pill navigation
   The portal is a single centred column with its own slim header and a
   floating pill nav along the bottom, shown at every screen size.
   ========================================================================== */

:root { --pill-nav-h: 66px; }

.portal-body { background: var(--bg); color: var(--text); }

.portal-shell {
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: 880px;
    margin: 0 auto;
    padding-bottom: calc(var(--pill-nav-h) + var(--credit-h) + var(--safe-bottom) + var(--nav-lift) + 0.9rem);
}

.portal-topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    height: var(--topbar-height);
    padding: 0 1.25rem;
    padding-top: var(--safe-top);
    background: color-mix(in srgb, var(--surface) 90%, transparent);
    backdrop-filter: saturate(1.4) blur(12px);
    border-bottom: 1px solid var(--border);
}

.portal-brand {
    display: inline-flex;
    align-items: center;
    gap: 0.6rem;
    font-weight: 700;
    color: var(--text);
    text-decoration: none;
    min-width: 0;
}

.portal-brand span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.portal-logo { width: 34px; height: 34px; border-radius: 9px; object-fit: contain; }

.portal-top-actions { display: inline-flex; align-items: center; gap: 0.5rem; }

.portal-content {
    flex: 1;
    width: 100%;
    padding: 1.5rem 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.portal-footer {
    display: flex;
    justify-content: space-between;
    gap: 0.75rem;
    flex-wrap: wrap;
    padding: 0.5rem 1.25rem 1.25rem;
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* Profile hero */
.portal-hero { display: flex; flex-direction: column; gap: 1.1rem; }
.portal-hero-id { display: flex; align-items: center; gap: 0.9rem; }
.portal-hero-id h2 { margin: 0 0 0.15rem; }
.portal-hero-id p { margin: 0; }

.portal-facts {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.75rem;
    margin: 0;
    padding-top: 1.1rem;
    border-top: 1px solid var(--border);
}

.portal-facts div { min-width: 0; }
.portal-facts dt { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-muted); }
.portal-facts dd { margin: 0.2rem 0 0; font-weight: 600; overflow: hidden; text-overflow: ellipsis; }

.history-year {
    margin: 1.1rem 0 0.4rem;
    font-size: 0.8rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
}
.history-year:first-child { margin-top: 0; }

.cal-readonly .cal-tile { cursor: default; }

/* Shared footer credit, used by the staff app footer and the portal footer */
.footer-credit a { color: inherit; text-decoration: none; border-bottom: 1px solid currentColor; }
.footer-credit a:hover { color: var(--brand-strong); }

/* ---------- Floating pill navigation ---------- */
.pill-nav {
    position: fixed;
    left: 0;
    right: 0;
    bottom: calc(var(--nav-lift) + var(--safe-bottom));
    z-index: 40;
    display: flex;
    justify-content: center;
    padding: 0 1rem;
    pointer-events: none;
}

.pill-nav-inner {
    pointer-events: auto;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    width: min(460px, 100%);
    padding: 0.35rem;
    background: color-mix(in srgb, var(--surface) 86%, transparent);
    backdrop-filter: saturate(1.5) blur(16px);
    border: 1px solid color-mix(in srgb, var(--border) 80%, transparent);
    border-radius: 22px; /* gentle pill, only slightly rounded */
    box-shadow: 0 12px 30px rgba(15, 23, 42, 0.16), 0 2px 6px rgba(15, 23, 42, 0.08);
}

.pill-item {
    position: relative;
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.2rem;
    min-height: 52px;
    margin: 0;
    padding: 0.4rem 0.3rem;
    border-radius: 16px;
    color: var(--text-muted);
    font-size: 0.68rem;
    font-weight: 600;
    text-decoration: none;
    border: 0;
    background: transparent;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    transition: color 0.15s, background 0.15s;
}

.pill-item .icon { width: 21px; height: 21px; }
.pill-item:hover { color: var(--text); text-decoration: none; }

.pill-item.is-active {
    color: var(--brand-strong);
    background: var(--brand-soft);
}

/* The sign-out item is a form wrapping a button; make the button fill it */
.pill-signout { padding: 0; }
.pill-signout button {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.2rem;
    min-height: 52px;
    border: 0;
    background: transparent;
    color: inherit;
    font: inherit;
    font-size: 0.68rem;
    font-weight: 600;
    border-radius: 16px;
    cursor: pointer;
}
.pill-signout button:hover { color: var(--danger); }

@media print {
    .pill-nav, .portal-topbar, .portal-footer { display: none !important; }
    .portal-shell { padding-bottom: 0; }
}

/* ==========================================================================
   Developer settings page
   ========================================================================== */

.form-section-title {
    margin: 0.25rem 0 0.75rem;
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
}
.form-card .form-section-title { margin-top: 1.5rem; }
.form-card .form-section-title:first-of-type { margin-top: 0; }

.logo-manager {
    display: flex;
    gap: 1.25rem;
    align-items: flex-start;
    flex-wrap: wrap;
    padding: 1rem;
    margin-bottom: 1.25rem;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.logo-preview {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.4rem;
    text-align: center;
}

.logo-preview img {
    width: 84px;
    height: 84px;
    object-fit: contain;
    padding: 0.5rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
}

.logo-fields { flex: 1; min-width: 240px; display: flex; flex-direction: column; gap: 0.75rem; }

.checkbox-row {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    font-size: 0.9rem;
    color: var(--text);
    cursor: pointer;
}
.checkbox-row input { width: 18px; height: 18px; accent-color: var(--brand); }

.footer-user { color: var(--text-muted); }

@media (max-width: 560px) {
    .logo-manager { flex-direction: column; align-items: stretch; }
    .logo-preview { align-items: flex-start; }
}

/* ==========================================================================
   Modern polish layer (phase 3)
   A tasteful refinement over everything above: more depth, softer elevation
   and livelier interactions. Theme-aware; loaded last so it wins.
   ========================================================================== */

:root {
    --radius: 16px;
    --radius-sm: 10px;
    --shadow: 0 1px 2px rgba(15, 23, 42, 0.05), 0 6px 20px rgba(15, 23, 42, 0.06);
    --shadow-lg: 0 14px 40px rgba(15, 23, 42, 0.14);
    --elev-brand: 0 6px 16px color-mix(in srgb, var(--brand) 32%, transparent);
}

:root[data-theme="dark"] {
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.35), 0 8px 24px rgba(0, 0, 0, 0.35);
    --shadow-lg: 0 18px 44px rgba(0, 0, 0, 0.55);
    --elev-brand: 0 6px 18px rgba(0, 0, 0, 0.45);
}

/* Subtle page depth: a faint brand-tinted glow behind the content */
body {
    background-image:
        radial-gradient(1100px 520px at 100% -8%, color-mix(in srgb, var(--brand) 9%, transparent), transparent 60%),
        radial-gradient(900px 480px at -10% 0%, color-mix(in srgb, var(--accent) 7%, transparent), transparent 55%);
    background-attachment: fixed;
}

/* Cards: hairline border + layered shadow, with a gentle lift on hover */
.card {
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    transition: box-shadow 0.2s ease, transform 0.2s ease, border-color 0.2s ease;
}
.stat-card:hover,
.table-card:hover { box-shadow: var(--shadow-lg); }

/* Stat cards get a slim brand accent along the top edge */
.stat-card {
    position: relative;
    overflow: hidden;
}
.stat-card::before {
    content: "";
    position: absolute;
    inset: 0 0 auto 0;
    height: 3px;
    background: linear-gradient(90deg, var(--brand), var(--accent));
    opacity: 0.85;
}

/* Primary action: a quiet gradient and brand-tinted elevation */
.btn-primary {
    background-image: linear-gradient(135deg, var(--brand), var(--brand-strong));
    box-shadow: var(--elev-brand);
}
.btn-primary:hover {
    background-image: linear-gradient(135deg, var(--brand-strong), var(--brand-strong));
    transform: translateY(-1px);
    box-shadow: var(--shadow-lg);
}
.btn-primary:active { transform: translateY(0); }

/* Portal hero echoes the stat-card accent for a consistent, premium feel */
.portal-hero { position: relative; overflow: hidden; }
.portal-hero::before {
    content: "";
    position: absolute;
    inset: 0 0 auto 0;
    height: 3px;
    background: linear-gradient(90deg, var(--brand), var(--accent));
}

/* Floating pill navs: lift slightly on hover for a tactile feel */
.pill-nav-inner, .bottom-nav { transition: box-shadow 0.2s ease; }

/* Honour users who prefer less motion */
@media (prefers-reduced-motion: reduce) {
    * { transition: none !important; scroll-behavior: auto !important; }
    .btn-primary:hover, .card:hover, .cal-tile:hover { transform: none !important; }
}

/* ==========================================================================
   Liquid Glass layer (phase 4) — iOS 26 / visionOS inspired
   Frosted translucent surfaces, specular hairline highlights and a living
   aurora backdrop that the glass refracts. Loaded last so it governs the app.
   Theme-aware; neutralised for print; respects reduced motion.
   ========================================================================== */

:root {
    /* Glass surfaces */
    --glass-bg: rgba(255, 255, 255, 0.55);
    --glass-bg-strong: rgba(255, 255, 255, 0.72);
    --glass-bg-soft: rgba(255, 255, 255, 0.4);
    --glass-border: rgba(255, 255, 255, 0.65);
    --glass-hairline: rgba(255, 255, 255, 0.9);
    --glass-blur: 22px;
    --glass-sat: 180%;
    --glass-shadow: 0 2px 8px rgba(15, 23, 42, 0.06), 0 16px 40px rgba(15, 23, 42, 0.10);
    --glass-shadow-lg: 0 10px 24px rgba(15, 23, 42, 0.12), 0 30px 70px rgba(15, 23, 42, 0.18);
    --glass-highlight: inset 0 1px 0 var(--glass-hairline), inset 0 0 0 1px rgba(255, 255, 255, 0.18);
    /* Dark glass sidebar: keeps its dark teal identity with a frosted edge */
    --glass-dark-bg: rgba(11, 48, 45, 0.84);
    --glass-dark-border: rgba(255, 255, 255, 0.14);

    --radius: 20px;
    --radius-sm: 13px;
}

:root[data-theme="dark"] {
    --glass-bg: rgba(22, 32, 50, 0.55);
    --glass-bg-strong: rgba(24, 35, 54, 0.74);
    --glass-bg-soft: rgba(22, 32, 50, 0.4);
    --glass-border: rgba(255, 255, 255, 0.14);
    --glass-hairline: rgba(255, 255, 255, 0.18);
    --glass-shadow: 0 2px 8px rgba(0, 0, 0, 0.4), 0 16px 44px rgba(0, 0, 0, 0.5);
    --glass-shadow-lg: 0 12px 28px rgba(0, 0, 0, 0.5), 0 34px 80px rgba(0, 0, 0, 0.6);
    --glass-highlight: inset 0 1px 0 rgba(255, 255, 255, 0.12), inset 0 0 0 1px rgba(255, 255, 255, 0.05);
    --glass-dark-bg: rgba(8, 14, 26, 0.66);
    --glass-dark-border: rgba(255, 255, 255, 0.1);
}

/* ---------- Living aurora backdrop ---------- */
html { background: var(--bg); }
body { position: relative; background: transparent; isolation: isolate; }

body::before {
    content: "";
    position: fixed;
    inset: -20vmax;
    z-index: -1;
    pointer-events: none;
    background:
        radial-gradient(52vmax 52vmax at 16% 6%, color-mix(in srgb, var(--brand) 72%, transparent), transparent 60%),
        radial-gradient(48vmax 48vmax at 92% 0%, color-mix(in srgb, var(--accent) 62%, transparent), transparent 58%),
        radial-gradient(58vmax 58vmax at 84% 90%, color-mix(in srgb, #6366f1 60%, transparent), transparent 62%),
        radial-gradient(50vmax 50vmax at 4% 96%, color-mix(in srgb, #14b8a6 64%, transparent), transparent 60%),
        radial-gradient(42vmax 42vmax at 55% 48%, color-mix(in srgb, #22d3ee 42%, transparent), transparent 66%);
    filter: saturate(145%);
    opacity: 0.68;
    animation: aurora-drift 32s ease-in-out infinite alternate;
}

:root[data-theme="dark"] body::before { opacity: 0.6; filter: saturate(165%); }

@keyframes aurora-drift {
    0%   { transform: translate3d(0, 0, 0) scale(1); }
    50%  { transform: translate3d(2.5vmax, -2vmax, 0) scale(1.08); }
    100% { transform: translate3d(-2vmax, 2.5vmax, 0) scale(1.04); }
}

/* ---------- Shared glass treatment ---------- */
.card,
.sheet,
.modal-box,
.auth-shell,
.stat-card {
    background: var(--glass-bg);
    -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-sat));
    backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-sat));
    border: 1px solid var(--glass-border);
    box-shadow: var(--glass-shadow), var(--glass-highlight);
}

/* Panels that hold dense data read better a touch more opaque */
.table-card,
.modal-box,
.sheet { background: var(--glass-bg-strong); }

.card:hover { box-shadow: var(--glass-shadow), var(--glass-highlight); }
.stat-card:hover,
.table-card:hover { box-shadow: var(--glass-shadow-lg), var(--glass-highlight); }

/* Keep the stat-card / portal-hero specular accent crisp on glass */
.stat-card::before,
.portal-hero::before { opacity: 0.9; z-index: 1; }

/* ---------- App shell ---------- */
.topbar {
    background: var(--glass-bg);
    -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-sat));
    backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-sat));
    border-bottom: 1px solid var(--glass-border);
    box-shadow: var(--glass-highlight);
}

.sidebar {
    background: var(--glass-dark-bg);
    -webkit-backdrop-filter: blur(26px) saturate(160%);
    backdrop-filter: blur(26px) saturate(160%);
    border-right: 1px solid var(--glass-dark-border);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

.nav-link.is-active {
    background: rgba(255, 255, 255, 0.16);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.18);
}

/* Portal header as glass */
.portal-topbar {
    background: var(--glass-bg);
    -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-sat));
    backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-sat));
    border-bottom: 1px solid var(--glass-border);
    box-shadow: var(--glass-highlight);
}

/* ---------- Floating pill navs: deeper glass ---------- */
.pill-nav-inner,
.bottom-nav {
    background: var(--glass-bg-strong);
    -webkit-backdrop-filter: blur(26px) saturate(185%);
    backdrop-filter: blur(26px) saturate(185%);
    border: 1px solid var(--glass-border);
    box-shadow: var(--glass-shadow-lg), var(--glass-highlight);
}

/* ---------- Sheets & modal backdrops ---------- */
.sheet { box-shadow: var(--glass-shadow-lg), var(--glass-highlight); }
.modal::backdrop { background: rgba(2, 6, 23, 0.4); -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px); }
.sheet-backdrop, .sidebar-backdrop { -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); background: rgba(2, 6, 23, 0.35); }

/* ---------- Glassy controls ---------- */
.btn-outline,
.btn-ghost,
.icon-btn,
.user-chip,
.form-control,
.search,
select.form-control {
    background: var(--glass-bg-soft);
    -webkit-backdrop-filter: blur(12px) saturate(160%);
    backdrop-filter: blur(12px) saturate(160%);
    border: 1px solid var(--glass-border);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.4);
}
:root[data-theme="dark"] .btn-outline,
:root[data-theme="dark"] .btn-ghost,
:root[data-theme="dark"] .icon-btn,
:root[data-theme="dark"] .user-chip,
:root[data-theme="dark"] .form-control { box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.07); }

.btn-ghost { border-color: transparent; background: transparent; box-shadow: none; }
.btn-ghost:hover { background: var(--glass-bg-soft); }
.form-control:focus { background: var(--glass-bg-strong); }

/* Primary action: a vivid "coloured glass" pill */
.btn-primary {
    box-shadow: var(--elev-brand), inset 0 1px 0 rgba(255, 255, 255, 0.4);
}

/* Sidebar controls stay light-on-dark */
.sidebar .icon-btn { background: transparent; border-color: transparent; box-shadow: none; }

/* ---------- Auth pages over the aurora ---------- */
.auth-shell { background: var(--glass-bg-strong); }
.auth-card { background: transparent; }

/* ---------- Guards ---------- */
@media (prefers-reduced-motion: reduce) {
    body::before { animation: none !important; }
}

@media print {
    body::before { display: none !important; }
    .card, .sheet, .modal-box, .sidebar, .topbar, .table-card, .stat-card, .auth-shell,
    .portal-topbar, .pill-nav-inner, .bottom-nav, .form-control, .btn, .icon-btn, .user-chip {
        -webkit-backdrop-filter: none !important;
        backdrop-filter: none !important;
        background: #fff !important;
        box-shadow: none !important;
    }
}

/* ==========================================================================
   Liquid Glass v2 + floating sheets + members directory + fee statement
   ========================================================================== */

/* ---------- Stronger, more refractive glass ---------- */
:root {
    --glass-bg: rgba(255, 255, 255, 0.34);
    --glass-bg-strong: rgba(255, 255, 255, 0.5);
    --glass-bg-soft: rgba(255, 255, 255, 0.26);
    --glass-border: rgba(255, 255, 255, 0.72);
    --glass-blur: 30px;
    --glass-sat: 210%;
    --glass-sheen: linear-gradient(135deg, rgba(255, 255, 255, 0.62) 0%, rgba(255, 255, 255, 0.14) 34%, rgba(255, 255, 255, 0) 58%, rgba(255, 255, 255, 0.22) 100%);
    --glass-highlight: inset 0 1.5px 0 rgba(255, 255, 255, 0.95), inset 1px 0 0 rgba(255, 255, 255, 0.55), inset 0 -1px 0 rgba(255, 255, 255, 0.3), inset 0 0 28px rgba(255, 255, 255, 0.28);
    --glass-shadow: 0 1px 2px rgba(15, 23, 42, 0.06), 0 10px 28px rgba(15, 23, 42, 0.1), 0 24px 56px rgba(15, 23, 42, 0.08);
    --glass-dark-bg: rgba(11, 48, 45, 0.7);
    --orb-a: rgba(255, 255, 255, 0.55);
}

:root[data-theme="dark"] {
    --glass-bg: rgba(24, 34, 54, 0.38);
    --glass-bg-strong: rgba(24, 34, 54, 0.6);
    --glass-bg-soft: rgba(30, 42, 64, 0.32);
    --glass-border: rgba(255, 255, 255, 0.2);
    --glass-sheen: linear-gradient(135deg, rgba(255, 255, 255, 0.2) 0%, rgba(255, 255, 255, 0.05) 34%, rgba(255, 255, 255, 0) 58%, rgba(255, 255, 255, 0.07) 100%);
    --glass-highlight: inset 0 1.5px 0 rgba(255, 255, 255, 0.32), inset 1px 0 0 rgba(255, 255, 255, 0.14), inset 0 -1px 0 rgba(255, 255, 255, 0.06), inset 0 0 26px rgba(255, 255, 255, 0.05);
    --glass-dark-bg: rgba(8, 16, 28, 0.62);
    --orb-a: rgba(255, 255, 255, 0.1);
}

/* A more vivid aurora, plus a second drifting layer of bright orbs */
body::before { opacity: 0.85; filter: saturate(160%); }
:root[data-theme="dark"] body::before { opacity: 0.7; filter: saturate(175%); }

body::after {
    content: "";
    position: fixed;
    inset: -10vmax;
    z-index: -1;
    pointer-events: none;
    background:
        radial-gradient(20vmax 20vmax at 28% 22%, var(--orb-a), transparent 70%),
        radial-gradient(24vmax 24vmax at 74% 60%, color-mix(in srgb, #f472b6 50%, transparent), transparent 70%),
        radial-gradient(18vmax 18vmax at 18% 74%, color-mix(in srgb, #38bdf8 55%, transparent), transparent 70%),
        radial-gradient(16vmax 16vmax at 86% 18%, color-mix(in srgb, #a78bfa 50%, transparent), transparent 70%);
    filter: blur(8px);
    opacity: 0.75;
    animation: aurora-drift-2 44s ease-in-out infinite alternate;
}

@keyframes aurora-drift-2 {
    0%   { transform: translate3d(0, 0, 0) scale(1); }
    100% { transform: translate3d(-3vmax, 3vmax, 0) scale(1.12); }
}

/* Every glass surface gets the same refractive sheen + brighter edge light */
.card, .stat-card, .msum, .member-row, .table-card, .modal-box, .sheet, .auth-shell,
.topbar, .portal-topbar, .pill-nav-inner, .bottom-nav,
.btn-outline, .icon-btn, .user-chip, .form-control, .search, .mbtn, .sheet-list, .sheet-link {
    background-image: var(--glass-sheen);
}

.card, .stat-card, .msum, .member-row, .table-card, .modal-box, .sheet, .auth-shell {
    -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-sat));
    backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-sat));
    box-shadow: var(--glass-shadow), var(--glass-highlight);
}

.pill-nav-inner, .bottom-nav {
    background-color: var(--glass-bg-strong);
    -webkit-backdrop-filter: blur(34px) saturate(230%);
    backdrop-filter: blur(34px) saturate(230%);
}

.sidebar {
    background-image: linear-gradient(180deg, rgba(255, 255, 255, 0.14), rgba(255, 255, 255, 0) 32%);
    -webkit-backdrop-filter: blur(36px) saturate(200%);
    backdrop-filter: blur(36px) saturate(200%);
}

/* Active nav item reads as a polished glass lens */
.bn-item.is-active, .bn-item.is-open, .pill-item.is-active {
    color: var(--brand-strong);
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.75), rgba(255, 255, 255, 0.2)), var(--brand-soft);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.95), 0 4px 12px color-mix(in srgb, var(--brand) 24%, transparent);
}
:root[data-theme="dark"] .bn-item.is-active,
:root[data-theme="dark"] .bn-item.is-open,
:root[data-theme="dark"] .pill-item.is-active {
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.18), rgba(255, 255, 255, 0.04)), var(--brand-soft);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.3), 0 4px 12px rgba(0, 0, 0, 0.35);
}

/* Fallbacks: no backdrop-filter support, or the user asked for less transparency */
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
    :root { --glass-bg: rgba(255, 255, 255, 0.9); --glass-bg-strong: rgba(255, 255, 255, 0.96); --glass-bg-soft: rgba(255, 255, 255, 0.8); }
    :root[data-theme="dark"] { --glass-bg: rgba(20, 30, 48, 0.92); --glass-bg-strong: rgba(20, 30, 48, 0.97); --glass-bg-soft: rgba(24, 36, 56, 0.85); }
}
@media (prefers-reduced-transparency: reduce) {
    :root { --glass-bg: rgba(255, 255, 255, 0.94); --glass-bg-strong: #fff; --glass-bg-soft: rgba(255, 255, 255, 0.85); }
    :root[data-theme="dark"] { --glass-bg: rgba(20, 30, 48, 0.94); --glass-bg-strong: #141e30; --glass-bg-soft: rgba(24, 36, 56, 0.88); }
    body::before, body::after { display: none; }
}
@media (prefers-reduced-motion: reduce) { body::after { animation: none !important; } }

/* ---------- Floating sheets: sit above the pill nav, never over it ---------- */
@keyframes sheet-float-in {
    from { opacity: 0; transform: translateY(18px) scale(0.97); }
    to   { opacity: 1; transform: none; }
}

@media (max-width: 960px) {
    .bottom-nav { z-index: 45; }

    .sheet-backdrop {
        z-index: 40;
        background: rgba(2, 6, 23, 0.26);
        -webkit-backdrop-filter: blur(10px) saturate(140%);
        backdrop-filter: blur(10px) saturate(140%);
    }

    .sheet,
    .sheet-tall {
        --sheet-gap: calc(var(--nav-lift) + var(--bottom-nav) + var(--credit-h) + var(--safe-bottom) + 0.7rem);
        left: 0;
        right: 0;
        bottom: var(--sheet-gap);
        width: min(460px, calc(100% - 2rem));
        margin-inline: auto;
        z-index: 42;
        max-height: calc(100dvh - var(--sheet-gap) - var(--safe-top) - 1rem);
        overflow-y: auto;
        overscroll-behavior: contain;
        padding: 0.7rem 1rem 1rem;
        border-radius: 28px;
        background-color: var(--glass-bg-strong);
        animation: sheet-float-in 0.26s cubic-bezier(0.2, 0.8, 0.2, 1);
    }

    .sheet-grab { background: color-mix(in srgb, var(--text) 22%, transparent); }

    .sheet-list,
    .sheet-link {
        background-color: var(--glass-bg-soft);
        border: 1px solid var(--glass-border);
        box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.5);
    }
    .sheet-list { border-radius: 18px; overflow: hidden; }
    .sheet-row + .sheet-row { border-top: 1px solid color-mix(in srgb, var(--text) 8%, transparent); }
    .sheet-row:hover { background: color-mix(in srgb, var(--brand) 9%, transparent); }
    .sheet-signout { margin-top: 0.9rem; }
}

/* ---------- Members directory ---------- */
.member-summary {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 0.9rem;
}

.msum {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    padding: 0.95rem 1.1rem;
    border: 1px solid var(--glass-border);
    border-radius: var(--radius);
    background-color: var(--glass-bg);
}

.msum-icon {
    flex: none;
    width: 42px;
    height: 42px;
    display: grid;
    place-items: center;
    border-radius: 14px;
    background: var(--brand-soft);
    color: var(--brand-strong);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.6);
}
.msum-icon .icon { width: 20px; height: 20px; }
.msum.is-success .msum-icon { background: var(--success-soft); color: var(--success); }
.msum.is-warning .msum-icon { background: var(--warning-soft); color: var(--warning); }
.msum.is-danger .msum-icon { background: var(--danger-soft); color: var(--danger); }

.msum > div { display: flex; flex-direction: column; min-width: 0; }
.msum-label { font-size: 0.74rem; font-weight: 600; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.msum strong { font-size: 1.5rem; line-height: 1.15; font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }

.member-list {
    --member-cols: minmax(0, 2.3fr) minmax(0, 1.4fr) 88px minmax(0, 1.6fr) 84px 84px;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

.member-list-head {
    display: grid;
    grid-template-columns: var(--member-cols);
    gap: 1rem;
    padding: 0.2rem 1.15rem;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
}

.member-row {
    display: grid;
    grid-template-columns: var(--member-cols);
    align-items: center;
    gap: 1rem;
    padding: 0.8rem 1.15rem;
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    background-color: var(--glass-bg);
    transition: transform 0.18s ease, box-shadow 0.18s ease;
}
.member-row:hover { transform: translateY(-2px); box-shadow: var(--glass-shadow-lg), var(--glass-highlight); }

.member-ident {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    min-width: 0;
    color: var(--text);
    text-decoration: none;
}
.member-ident:hover { text-decoration: none; }
.member-ident:hover strong { color: var(--brand-strong); }

.member-avatar {
    --c1: #3b82f6;
    --c2: #6366f1;
    flex: none;
    width: 46px;
    height: 46px;
    display: grid;
    place-items: center;
    border-radius: 16px;
    background: linear-gradient(135deg, var(--c1), var(--c2));
    color: #fff;
    font-size: 0.9rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.45), 0 6px 14px color-mix(in srgb, var(--c1) 38%, transparent);
}
.member-avatar.type-premium { --c1: #f59e0b; --c2: #d97706; }
.member-avatar.type-vip { --c1: #10b981; --c2: #0d9488; }
.member-avatar.type-vvip { --c1: #f43f5e; --c2: #a855f7; }

.member-name { display: flex; flex-direction: column; min-width: 0; line-height: 1.3; }
.member-name strong { font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; transition: color 0.15s; }
.member-name small { color: var(--text-muted); font-size: 0.78rem; }
.member-name code { background: none; padding: 0; font-weight: 600; color: var(--text); }

.member-cell { display: flex; align-items: center; gap: 0.5rem; min-width: 0; font-size: 0.9rem; }
.member-cell .icon { flex: none; width: 16px; height: 16px; color: var(--text-muted); }
.member-cell > span:not(.badge), .member-cell > a { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.member-cell a { color: inherit; text-decoration: none; }
.member-cell a:hover { color: var(--brand-strong); text-decoration: underline; }

.member-state { display: none; }
.member-state i { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.member-state-month { display: none; }

.member-actions { display: flex; justify-content: flex-end; gap: 0.4rem; }

.mbtn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    width: 38px;
    height: 38px;
    padding: 0;
    border: 1px solid var(--glass-border);
    border-radius: 13px;
    background-color: var(--glass-bg-soft);
    color: var(--text);
    font-size: 0.84rem;
    font-weight: 600;
    text-decoration: none;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.5);
    transition: background-color 0.15s, color 0.15s, transform 0.15s;
}
.mbtn:hover { background-color: var(--brand-soft); color: var(--brand-strong); text-decoration: none; transform: translateY(-1px); }
.mbtn .icon { width: 17px; height: 17px; }
.mbtn span, .mbtn.only-card { display: none; }

.member-list .pagination {
    padding: 0.8rem 1.15rem;
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    background-color: var(--glass-bg);
    -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-sat));
    backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-sat));
}

@media (max-width: 1100px) {
    .member-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 720px) {
    .member-summary { gap: 0.65rem; }
    .msum { padding: 0.8rem 0.9rem; gap: 0.65rem; border-radius: 18px; }
    .msum-icon { width: 38px; height: 38px; border-radius: 12px; }
    .msum strong { font-size: 1.3rem; }
}

/* The list adapts to the space it actually has (with or without the sidebar) */
.member-list { container-type: inline-size; }

@container (max-width: 980px) {
    .member-list-head,
    .member-row { grid-template-columns: minmax(0, 2fr) minmax(0, 1.2fr) 84px minmax(0, 1.5fr) 84px 84px; gap: 0.8rem; }
}

@container (max-width: 760px) {
    .member-list-head { display: none; }

    .member-row {
        position: relative;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        grid-template-areas:
            "ident ident"
            "area type"
            "phone phone"
            "actions actions";
        gap: 0.95rem 0.9rem;
        padding: 1rem;
        border-radius: 24px;
    }
    .member-row:hover { transform: none; }

    .member-ident { grid-area: ident; padding-right: 6.2rem; }
    .member-area { grid-area: area; }
    .member-type { grid-area: type; }
    .member-phone { grid-area: phone; }
    .member-status-cell { display: none; }

    .member-state {
        position: absolute;
        top: 1.1rem;
        right: 1rem;
        display: inline-flex;
        align-items: center;
        gap: 0.4rem;
        padding: 0.32rem 0.75rem;
        border-radius: 999px;
        font-size: 0.78rem;
        font-weight: 650;
        box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.5);
    }
    .member-state.state-success { background: var(--success-soft); color: var(--success); }
    .member-state.state-warning { background: var(--warning-soft); color: var(--warning); }
    .member-state.state-danger { background: var(--danger-soft); color: var(--danger); }

    .member-cell {
        display: grid;
        grid-template-columns: auto minmax(0, 1fr);
        column-gap: 0.5rem;
        align-items: center;
        font-size: 0.92rem;
    }
    .member-cell::before {
        content: attr(data-label);
        grid-column: 1 / -1;
        margin-bottom: 0.22rem;
        font-size: 0.66rem;
        font-weight: 700;
        text-transform: uppercase;
        letter-spacing: 0.08em;
        color: var(--text-muted);
    }

    .member-actions {
        grid-area: actions;
        justify-content: stretch;
        padding-top: 0.85rem;
        border-top: 1px dashed color-mix(in srgb, var(--text) 16%, transparent);
    }
    .mbtn { flex: 1; width: auto; height: 42px; border-radius: 14px; }
    .mbtn span { display: inline; }
    .mbtn.only-card { display: inline-flex; }
}

/* ---------- Print / statement layout ---------- */
.print-body::before, .print-body::after { display: none; }

.print-toolbar {
    align-items: center;
    gap: 0.6rem;
    padding: 0.7rem 1rem;
    padding-top: calc(0.7rem + var(--safe-top));
}
.print-toolbar .btn { padding: 0.55rem 0.9rem; }
.print-toolbar .btn-ghost { min-width: 0; flex: 0 1 auto; }
.print-toolbar .toolbar-label { overflow: hidden; text-overflow: ellipsis; }
.print-toolbar .btn-primary { flex: none; }

@media (max-width: 560px) {
    .hide-xs { display: none; }
}

/* Fee statement paper */
.fee-statement { font-size: 10pt; }

.fee-head {
    display: flex;
    align-items: center;
    gap: 1rem;
    border-bottom: 2px solid #0f766e;
}
.fee-head h1 { font-size: 1.35rem; line-height: 1.2; margin: 0; color: var(--ink); }
.fee-head-text { flex: 1 1 9rem; min-width: 0; }
.fee-head-text p { margin: 0.15rem 0 0; color: var(--muted); }
.fee-generated { margin-left: auto; text-align: right; font-size: 0.8rem; color: var(--muted); line-height: 1.4; }
.fee-generated strong { color: var(--ink); font-weight: 600; }

.fee-member h2 { margin: 0 0 0.8rem; font-size: 1.25rem; color: var(--ink); }
.fee-details {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 0.8rem 1.25rem;
    margin: 0;
}
.fee-details dt { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
.fee-details dd { margin: 0.15rem 0 0; font-weight: 600; overflow-wrap: anywhere; }

.fee-kpis {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 0.75rem;
}
.fee-kpis > div {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    padding: 0.8rem 0.95rem;
    border: 1px solid var(--rule);
    border-radius: 12px;
    background: #f9fafb;
}
.fee-kpis span { font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.07em; color: var(--muted); }
.fee-kpis strong { font-size: 1.15rem; font-variant-numeric: tabular-nums; color: var(--ink); }
.fee-kpis .is-pos strong { color: #15803d; }
.fee-kpis .is-neg strong { color: #b91c1c; }
.fee-progress i { display: block; height: 6px; border-radius: 6px; background: #e5e7eb; overflow: hidden; margin-top: 0.15rem; }
.fee-progress b { display: block; height: 100%; border-radius: 6px; background: linear-gradient(90deg, #0f766e, #14b8a6); }

.fee-table { width: 100%; border-collapse: collapse; }
.fee-table th {
    padding: 0.6rem 0.5rem;
    text-align: left;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: var(--muted);
    border-bottom: 1.5px solid var(--ink);
}
.fee-table td { padding: 0.62rem 0.5rem; border-bottom: 1px solid var(--rule); }
.fee-table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.fee-table tfoot th, .fee-table tfoot td { padding: 0.7rem 0.5rem; border-top: 1.5px solid var(--ink); border-bottom: 0; color: var(--ink); font-size: 0.85rem; letter-spacing: 0; text-transform: none; }
.fee-table .fee-month { font-weight: 600; }
.fee-foot { color: var(--muted); font-size: 0.75rem; text-align: center; }

/* Phones: month rows stack into cards, so nothing scrolls sideways */
@media screen and (max-width: 760px) {
    .fee-statement .page-inline { padding: 1.1rem 1rem; }
    .fee-head { flex-wrap: wrap; gap: 0.75rem; }
    .fee-head .receipt-logo { width: 46px; height: 46px; }
    .fee-head h1 { font-size: 1.15rem; }
    .fee-generated { width: 100%; margin-left: 0; text-align: left; }

    .fee-details { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .fee-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.6rem; }
    .fee-kpis strong { font-size: 1.02rem; }

    .fee-table, .fee-table tbody, .fee-table tfoot { display: block; }
    .fee-table thead { display: none; }
    .fee-table tbody { display: flex; flex-direction: column; gap: 0.6rem; }

    .fee-table tbody tr,
    .fee-table tfoot tr {
        display: grid;
        grid-template-columns: repeat(3, minmax(0, 1fr));
        grid-template-areas:
            "month month status"
            "fee paid due"
            "date date date";
        gap: 0.6rem 0.5rem;
        padding: 0.8rem 0.85rem;
        border: 1px solid var(--rule);
        border-left-width: 4px;
        border-radius: 12px;
        background: #fff;
    }
    .fee-table tr.st-paid { border-left-color: #16a34a; }
    .fee-table tr.st-partial { border-left-color: #d97706; }
    .fee-table tr.st-unpaid { border-left-color: #dc2626; }
    .fee-table tr.st-upcoming, .fee-table tr.st-na { border-left-color: #9ca3af; }

    .fee-table td, .fee-table th { padding: 0; border: 0; text-align: left; font-size: 0.9rem; }
    .fee-table .fee-month { grid-area: month; font-size: 1rem; align-self: center; }
    .fee-table .fee-status { grid-area: status; justify-self: end; align-self: center; }
    .fee-table td:nth-child(2), .fee-table th:nth-child(2) { grid-area: fee; }
    .fee-table td:nth-child(3), .fee-table th:nth-child(3) { grid-area: paid; }
    .fee-table td:nth-child(4), .fee-table th:nth-child(4) { grid-area: due; }
    .fee-table .fee-date { grid-area: date; color: var(--muted); font-size: 0.8rem; padding-top: 0.5rem; border-top: 1px dashed var(--rule); }
    .fee-table .fee-date.is-empty { display: none; }

    .fee-table td[data-label]::before,
    .fee-table tfoot th[data-label]:not([data-label=""])::before {
        content: attr(data-label);
        display: block;
        margin-bottom: 0.15rem;
        font-size: 0.64rem;
        font-weight: 700;
        text-transform: uppercase;
        letter-spacing: 0.07em;
        color: var(--muted);
    }
    .fee-table .fee-date::before { display: inline; margin: 0 0.35rem 0 0; }
    .fee-table td.fee-month::before { display: none; }
    .fee-table td.num, .fee-table th.num { text-align: left; }

    .fee-table tfoot { margin-top: 0.8rem; }
    .fee-table tfoot tr {
        grid-template-areas: "month month month" "fee paid due";
        background: #f3f4f6;
        border-left-color: var(--ink);
    }
    .fee-table tfoot th, .fee-table tfoot td { padding: 0; border: 0; font-size: 0.9rem; }
    .fee-table tfoot th[colspan] { display: none; }
    .fee-table tfoot .fee-month { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); }
}

@media print {
    .fee-statement .fee-table td, .fee-statement .fee-table th { padding: 0.35rem 0.5rem; }
    .fee-kpis > div { background: none; }
}

/* ==========================================================================
   Dark mode, readable edition
   Brighter frosted surfaces, higher text contrast, visible borders and a
   calmer colour tint behind the glass. Loaded last so it wins in dark mode.
   ========================================================================== */

:root[data-theme="dark"] {
    --bg: #0f1b30;
    --surface: #1a2942;
    --surface-2: #203150;
    --muted-soft: rgba(190, 205, 230, 0.16);

    --text: #f4f7fc;
    --text-muted: #b9c5d9;
    --border: rgba(255, 255, 255, 0.18);
    --sidebar-text: #d7e0ee;
    --sidebar-active: rgba(255, 255, 255, 0.16);

    --brand: #3ee0cb;
    --brand-strong: #7bf0df;
    --brand-soft: rgba(62, 224, 203, 0.2);
    --accent: #fcc34a;
    --accent-soft: rgba(252, 195, 74, 0.2);

    --success: #6ff0aa;
    --success-soft: rgba(111, 240, 170, 0.2);
    --warning: #fcd34d;
    --warning-soft: rgba(252, 211, 77, 0.2);
    --danger: #ff9494;
    --danger-soft: rgba(255, 148, 148, 0.2);
    --info: #9ccbff;
    --info-soft: rgba(156, 203, 255, 0.2);

    --glass-bg: rgba(58, 80, 120, 0.5);
    --glass-bg-strong: rgba(46, 66, 102, 0.78);
    --glass-bg-soft: rgba(78, 102, 144, 0.4);
    --glass-border: rgba(255, 255, 255, 0.3);
    --glass-blur: 26px;
    --glass-sat: 140%;
    --glass-sheen: linear-gradient(135deg, rgba(255, 255, 255, 0.28) 0%, rgba(255, 255, 255, 0.08) 36%, rgba(255, 255, 255, 0) 60%, rgba(255, 255, 255, 0.1) 100%);
    --glass-highlight: inset 0 1.5px 0 rgba(255, 255, 255, 0.42), inset 1px 0 0 rgba(255, 255, 255, 0.18), inset 0 -1px 0 rgba(255, 255, 255, 0.08), inset 0 0 24px rgba(255, 255, 255, 0.06);
    --glass-shadow: 0 2px 6px rgba(0, 0, 0, 0.3), 0 14px 36px rgba(0, 0, 0, 0.35);
    --glass-shadow-lg: 0 10px 24px rgba(0, 0, 0, 0.4), 0 28px 64px rgba(0, 0, 0, 0.45);
    --glass-dark-bg: rgba(16, 34, 58, 0.8);
    --orb-a: rgba(255, 255, 255, 0.08);
}

/* A lighter, calmer backdrop: enough colour to read as glass, not enough to muddy it */
:root[data-theme="dark"] body::before { opacity: 0.55; filter: saturate(120%); }
:root[data-theme="dark"] body::after { opacity: 0.4; }

:root[data-theme="dark"] .card,
:root[data-theme="dark"] .stat-card,
:root[data-theme="dark"] .table-card,
:root[data-theme="dark"] .msum,
:root[data-theme="dark"] .member-row { background-color: var(--glass-bg); }

:root[data-theme="dark"] .topbar { background-color: var(--glass-bg-strong); }

/* Secondary text and labels: clearly readable, not ghosted */
:root[data-theme="dark"] .muted,
:root[data-theme="dark"] .stat-label,
:root[data-theme="dark"] .stat-sub,
:root[data-theme="dark"] .eyebrow,
:root[data-theme="dark"] .label,
:root[data-theme="dark"] .hint,
:root[data-theme="dark"] .msum-label { color: var(--text-muted); }

:root[data-theme="dark"] h1,
:root[data-theme="dark"] h2,
:root[data-theme="dark"] h3,
:root[data-theme="dark"] h4,
:root[data-theme="dark"] .stat-value,
:root[data-theme="dark"] .member-name strong,
:root[data-theme="dark"] .hero-meta strong { color: var(--text); }

:root[data-theme="dark"] .hero-amount { color: var(--brand-strong); }

/* Tables: visible row dividers and header */
:root[data-theme="dark"] .table th { color: var(--text-muted); background: rgba(255, 255, 255, 0.07); }
:root[data-theme="dark"] .table td,
:root[data-theme="dark"] .table th { border-color: rgba(255, 255, 255, 0.14); }
:root[data-theme="dark"] .table tbody tr:hover td { background: rgba(255, 255, 255, 0.07); }

/* Inputs and buttons: legible text, visible placeholders and edges */
:root[data-theme="dark"] .form-control,
:root[data-theme="dark"] .search input,
:root[data-theme="dark"] .topbar-search input { color: var(--text); }
:root[data-theme="dark"] ::placeholder { color: #a9b7cd; opacity: 1; }
:root[data-theme="dark"] .form-control { background-color: rgba(10, 20, 38, 0.38); border-color: rgba(255, 255, 255, 0.26); }
:root[data-theme="dark"] .form-control:focus { background-color: rgba(10, 20, 38, 0.55); border-color: var(--brand); }
:root[data-theme="dark"] .btn-outline,
:root[data-theme="dark"] .icon-btn,
:root[data-theme="dark"] .mbtn { color: var(--text); border-color: rgba(255, 255, 255, 0.28); }
:root[data-theme="dark"] .btn-primary { color: #04231f; background-image: linear-gradient(135deg, #5eead4, #2dd4bf); }
:root[data-theme="dark"] .btn-primary:hover { color: #04231f; background-image: linear-gradient(135deg, #7bf0df, #3ee0cb); }

/* Sidebar: readable links and a clear active state */
:root[data-theme="dark"] .nav-link { color: var(--sidebar-text); }
:root[data-theme="dark"] .nav-link:hover { color: #fff; }
:root[data-theme="dark"] .nav-link.is-active { color: #fff; background: rgba(255, 255, 255, 0.18); }
:root[data-theme="dark"] .nav-heading { opacity: 0.85; }

/* Floating navs and sheets: lighter glass so icons and labels stand out */
:root[data-theme="dark"] .pill-nav-inner,
:root[data-theme="dark"] .bottom-nav { background-color: var(--glass-bg-strong); }
:root[data-theme="dark"] .bn-item,
:root[data-theme="dark"] .pill-item { color: #c3cee0; }
:root[data-theme="dark"] .sheet { background-color: var(--glass-bg-strong); }
:root[data-theme="dark"] .sheet-row,
:root[data-theme="dark"] .sheet-link { color: var(--text); }
:root[data-theme="dark"] .sheet-backdrop { background: rgba(2, 8, 20, 0.5); }

/* Statement paper stays white in every theme */
:root[data-theme="dark"] .statement-doc { color: #111827; }

:root[data-theme="dark"] .bn-item.is-active,
:root[data-theme="dark"] .bn-item.is-open,
:root[data-theme="dark"] .pill-item.is-active { color: #fff; }

/* ==========================================================================
   Calm content
   Glass is kept for the chrome (sidebar, top bar, floating menus, popup
   sheets). Everything you read or type into (cards, tables, member rows,
   forms, dialogs) is a clean solid surface. Loaded last so it wins.
   ========================================================================== */

:root[data-theme] {
    --content-shadow: 0 1px 2px rgba(15, 23, 42, 0.05), 0 6px 18px rgba(15, 23, 42, 0.06);
    --content-shadow-hover: 0 2px 4px rgba(15, 23, 42, 0.06), 0 12px 28px rgba(15, 23, 42, 0.11);
}
:root[data-theme="dark"] {
    --content-shadow: 0 1px 2px rgba(0, 0, 0, 0.35), 0 6px 18px rgba(0, 0, 0, 0.28);
    --content-shadow-hover: 0 2px 4px rgba(0, 0, 0, 0.4), 0 12px 28px rgba(0, 0, 0, 0.38);
}

/* Content surfaces: solid, no blur, no sheen */
:root[data-theme] .card,
:root[data-theme] .stat-card,
:root[data-theme] .table-card,
:root[data-theme] .msum,
:root[data-theme] .member-row,
:root[data-theme] .member-list .pagination,
:root[data-theme] .modal-box,
:root[data-theme] .auth-shell {
    background-color: var(--surface);
    background-image: none;
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
    border: 1px solid var(--border);
    box-shadow: var(--content-shadow);
}

/* The hero card keeps its soft brand wash */
:root[data-theme] .hero-card {
    background-color: var(--surface);
    background-image: linear-gradient(135deg, color-mix(in srgb, var(--brand) 14%, var(--surface)), var(--surface) 62%);
}

:root[data-theme] .stat-card:hover,
:root[data-theme] .table-card:hover,
:root[data-theme] .member-row:hover { box-shadow: var(--content-shadow-hover); }

/* The login card sits on the page itself, so its right side needs no extra layer */
:root[data-theme] .auth-card { background: transparent; }

/* Fields and buttons you interact with: plain, crisp, high contrast */
:root[data-theme] .form-control,
:root[data-theme] .search,
:root[data-theme] select.form-control {
    background-color: var(--surface-2);
    background-image: none;
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
    border: 1px solid var(--border);
    box-shadow: none;
}
:root[data-theme] .form-control:focus,
:root[data-theme] .search:focus-within { background-color: var(--surface); border-color: var(--brand); }

:root[data-theme] .card .btn-outline,
:root[data-theme] .table-card .btn-outline,
:root[data-theme] .member-list .btn-outline,
:root[data-theme] .toolbar .btn-outline,
:root[data-theme] .page-actions .btn-outline,
:root[data-theme] .modal-box .btn-outline,
:root[data-theme] .mbtn {
    background-color: var(--surface);
    background-image: none;
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
    border: 1px solid var(--border);
    box-shadow: none;
}
:root[data-theme] .mbtn { background-color: var(--surface-2); }
:root[data-theme] .card .btn-outline:hover,
:root[data-theme] .toolbar .btn-outline:hover,
:root[data-theme] .page-actions .btn-outline:hover,
:root[data-theme] .mbtn:hover { background-color: var(--brand-soft); border-color: var(--brand); }

:root[data-theme] .card .icon-btn,
:root[data-theme] .table-card .icon-btn,
:root[data-theme] .modal-box .icon-btn {
    background-color: var(--surface-2);
    background-image: none;
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
    border: 1px solid var(--border);
    box-shadow: none;
}

/* Quieter backdrop behind the content */
body::before { opacity: 0.55; filter: saturate(125%); }
body::after { opacity: 0.4; }
:root[data-theme="dark"] body::before { opacity: 0.4; filter: saturate(115%); }
:root[data-theme="dark"] body::after { opacity: 0.25; }

/* Solid surfaces in dark mode: a clear step up from the page */
:root[data-theme="dark"] .card,
:root[data-theme="dark"] .stat-card,
:root[data-theme="dark"] .table-card,
:root[data-theme="dark"] .msum,
:root[data-theme="dark"] .member-row,
:root[data-theme="dark"] .modal-box,
:root[data-theme="dark"] .member-list .pagination { background-color: var(--surface); }
:root[data-theme="dark"] .table th { background: rgba(255, 255, 255, 0.05); }

/* ==========================================================================
   Light mode, refined
   A calm, clean page, a deep-teal sidebar, readable floating bars, and a
   balanced stat grid.
   ========================================================================== */

/* Quiet, pastel backdrop: a hint of colour at the corners, no big glow patches */
:root[data-theme="light"] body::before { opacity: 0.3; filter: saturate(105%); }
:root[data-theme="light"] body::after { opacity: 0.18; }

/* Sidebar keeps its deep-teal identity (frosted edge, but not see-through) */
:root[data-theme="light"] { --glass-dark-bg: rgba(11, 59, 55, 0.95); }
:root[data-theme="light"] .sidebar {
    background-image: linear-gradient(180deg, rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0) 30%);
    border-right-color: rgba(255, 255, 255, 0.1);
}
:root[data-theme="light"] .nav-link { color: #d3e6e3; }
:root[data-theme="light"] .nav-link:hover { color: #fff; }
:root[data-theme="light"] .nav-link.is-active { color: #fff; background: rgba(255, 255, 255, 0.16); }

/* Bars that float over scrolling content need to stay legible */
:root[data-theme="light"] .topbar,
:root[data-theme="light"] .portal-topbar { background-color: rgba(255, 255, 255, 0.84); }
:root[data-theme="light"] .pill-nav-inner,
:root[data-theme="light"] .bottom-nav { background-color: rgba(255, 255, 255, 0.78); }
:root[data-theme="light"] .sheet { background-color: rgba(255, 255, 255, 0.84); }

/* Dashboard stat cards: six cards read best as 3 + 3, or one row on wide screens */
@media (min-width: 721px) {
    .stat-grid-6 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (min-width: 1760px) {
    .stat-grid-6 { grid-template-columns: repeat(6, minmax(0, 1fr)); }
    .stat-grid-6 .stat-value { font-size: 1.45rem; white-space: nowrap; }
}

/* Cards in a row share one height so the grid looks tidy */
.stat-grid > .stat-card { height: 100%; }

/* ==========================================================================
   Site footer (liquid glass) — slim & sticky
   Desktop/tablet (>960px) & sign-in pages show a compact single-row glass bar,
   kept in view while scrolling. On phones the staff app and portal hide it and
   carry the developer credit inside the floating bottom menu instead.
   ========================================================================== */

:root {
    --nav-lift: 0.9rem;
    --credit-h: 1.45rem;   /* space the credit strip adds inside the bottom menu */
}

.site-footer {
    position: sticky;
    bottom: 0.75rem;
    z-index: 25;
    margin: auto 2rem 0.75rem;
    padding: 0.5rem 1.1rem;
    border-radius: 16px;
    border: 1px solid var(--glass-border);
    background-color: var(--glass-bg-strong);
    background-image:
        radial-gradient(120% 180% at 0% 0%, color-mix(in srgb, var(--brand) 12%, transparent), transparent 46%),
        radial-gradient(120% 180% at 100% 0%, color-mix(in srgb, var(--accent) 8%, transparent), transparent 44%),
        var(--glass-sheen);
    -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-sat));
    backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-sat));
    box-shadow: var(--glass-shadow), var(--glass-highlight);
    color: var(--text-muted);
    overflow: hidden;
}

/* A hairline brand → accent light along the very top edge */
.site-footer::before {
    content: "";
    position: absolute;
    inset: 0 0 auto 0;
    height: 2px;
    background: linear-gradient(90deg, var(--brand), var(--accent));
    opacity: 0.85;
    pointer-events: none;
}

.sf-inner {
    display: flex;
    align-items: center;
    gap: 0.6rem 1.4rem;
    flex-wrap: wrap;
}

.sf-brand {
    display: inline-flex;
    align-items: center;
    gap: 0.6rem;
    min-width: 0;
    color: var(--text);
    text-decoration: none;
}

.sf-logo {
    width: 34px;
    height: 34px;
    flex: none;
    object-fit: contain;
    padding: 4px;
    border-radius: 10px;
    background: var(--surface);
    border: 1px solid var(--border);
    box-shadow: 0 3px 10px rgba(15, 23, 42, 0.13), var(--glass-highlight);
}

.sf-brand-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.2; }
.sf-brand-text strong { font-size: 0.86rem; font-weight: 700; letter-spacing: -0.01em; color: var(--text); }
.sf-brand-text small { color: var(--text-muted); font-size: 0.69rem; }

.sf-right {
    display: inline-flex;
    align-items: center;
    gap: 0.6rem;
    margin-left: auto;
}

.sf-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    max-width: 100%;
    padding: 0.32rem 0.8rem;
    border-radius: 999px;
    background: color-mix(in srgb, var(--surface) 64%, transparent);
    border: 1px solid var(--border);
    box-shadow: var(--glass-highlight);
    font-size: 0.74rem;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sf-chip strong { color: var(--text); font-weight: 600; }

.sf-dot {
    width: 7px;
    height: 7px;
    flex: none;
    border-radius: 50%;
    background: #22c55e;
    box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.5);
    animation: sf-pulse 2.6s ease-out infinite;
}

@keyframes sf-pulse {
    0%   { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.45); }
    70%  { box-shadow: 0 0 0 5px rgba(34, 197, 94, 0); }
    100% { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0); }
}

/* The developer's signature: a filled deep-teal pill, legible in both themes */
.sf-credit {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.34rem 0.82rem;
    border-radius: 999px;
    background: linear-gradient(135deg, #0f766e, #115e59);
    color: #fff;
    font-weight: 600;
    font-size: 0.74rem;
    white-space: nowrap;
    box-shadow: 0 4px 12px rgba(15, 118, 110, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.26);
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.sf-credit:hover {
    transform: translateY(-1px);
    box-shadow: 0 7px 18px rgba(15, 118, 110, 0.44), inset 0 1px 0 rgba(255, 255, 255, 0.32);
}

.sf-credit .icon { width: 13px; height: 13px; color: rgba(255, 255, 255, 0.9); }
.sf-credit a { color: #fff; border-bottom: 0; text-decoration: none; }
.sf-credit a:hover { color: #fff; text-decoration: none; }

@media (prefers-reduced-motion: reduce) {
    .sf-dot { animation: none; }
}

/* The member portal always uses the pill nav, so it never shows the bar */
.portal-shell > .site-footer { display: none; }

/* Phones: hide the staff-app bar; the credit lives in the bottom menu instead */
@media (max-width: 960px) {
    .app-main > .site-footer { display: none; }
}

/* ---------- Developer credit strip inside the floating bottom menu ---------- */
.bn-row {
    display: flex;
    align-items: stretch;
    gap: 0.25rem;
    width: 100%;
}

.bn-credit {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.32rem;
    width: 100%;
    margin-top: 0.3rem;
    padding-top: 0.32rem;
    border-top: 1px solid color-mix(in srgb, var(--border) 55%, transparent);
    font-size: 0.62rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    line-height: 1;
    color: var(--text-muted);
}

.bn-credit a,
.bn-credit span { color: inherit; text-decoration: none; }
.bn-credit a:hover { color: var(--brand-strong); }
.bn-credit-icon { width: 12px; height: 12px; flex: none; opacity: 0.75; }

@media print {
    .site-footer, .bn-credit { display: none !important; }
}

/* ---------- Sign-in pages: footer sits statically beneath the card ---------- */
.guest-body {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1.25rem;
}

.guest-body .site-footer {
    position: static;
    width: 100%;
    max-width: 980px;
    margin: 0;
}

/* Keep the slim footer to one row on narrow desktops/tablets */
@media (max-width: 920px) { .sf-chip { display: none; } }

/* ==========================================================================
   Announcements, committee report, recycle bin / backups helpers
   ========================================================================== */
.pill-icon { position: relative; display: inline-flex; }
.pill-dot {
    position: absolute;
    top: -5px;
    right: -9px;
    min-width: 16px;
    height: 16px;
    padding: 0 4px;
    border-radius: 999px;
    background: var(--danger);
    color: #fff;
    font-size: 0.62rem;
    font-weight: 700;
    line-height: 16px;
    text-align: center;
}

.announcement-list { display: grid; gap: 1rem; }
.announcement { display: grid; gap: 0.5rem; border-left: 4px solid var(--border); }
.announcement header { display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem; }
.announcement header time { margin-left: auto; }
.announcement h3 { margin: 0; font-size: 1.1rem; }
.announcement p { margin: 0; line-height: 1.6; overflow-wrap: anywhere; }
.announcement footer { padding-top: 0.25rem; }
.announcement-urgent { border-left-color: var(--danger); }
.announcement-notice { border-left-color: var(--warning); }
.announcement-event { border-left-color: var(--info); }
.announcement-general { border-left-color: var(--brand); }
.portal-notices h3 { display: flex; align-items: center; gap: 0.4rem; }
.portal-notices h3 .icon { width: 18px; height: 18px; }

.committee-picker { display: flex; flex-wrap: wrap; gap: 1rem; align-items: end; max-width: 860px; margin: 1rem auto; }

.committee-doc {
    color-scheme: light;
    --text: #111827;
    --text-muted: #6b7280;
    --border: #e5e7eb;
    --surface: #ffffff;
    max-width: 860px;
    margin: 1rem auto 2rem;
    padding: 2rem;
    background: #fff;
    color: #111827;
    border-radius: 12px;
    box-shadow: 0 8px 30px rgba(15, 23, 42, 0.12);
}
.committee-head { display: flex; gap: 1rem; align-items: center; padding-bottom: 1rem; border-bottom: 2px solid var(--brand); }
.committee-head h1 { margin: 0; font-size: 1.4rem; }
.committee-head p { margin: 0.15rem 0; }
.committee-logo { width: 64px; height: 64px; object-fit: contain; }
.committee-kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 0.75rem; margin: 1.25rem 0; }
.committee-kpis > div { padding: 0.75rem; border: 1px solid #e5e7eb; border-radius: 10px; background: #f8fafc; }
.committee-kpis span { display: block; font-size: 0.72rem; color: #6b7280; text-transform: uppercase; letter-spacing: 0.04em; }
.committee-kpis strong { display: block; margin-top: 0.2rem; font-size: 1.05rem; }
.committee-section { margin-top: 1.5rem; break-inside: avoid-page; }
.committee-section h2 { margin: 0 0 0.5rem; font-size: 1.05rem; border-bottom: 1px solid #e5e7eb; padding-bottom: 0.3rem; }
.committee-section h3 { margin: 1rem 0 0.4rem; font-size: 0.95rem; }
.committee-doc .table { width: 100%; }
.committee-doc .table tr.total td { border-top: 2px solid #111827; }
.committee-doc .table tr.sub td { color: #4b5563; font-size: 0.9em; }
.committee-signatures { display: grid; grid-template-columns: repeat(3, 1fr); gap: 2rem; margin-top: 3.5rem; text-align: center; font-size: 0.85rem; color: #4b5563; break-inside: avoid; }
.committee-signatures span { display: block; border-top: 1px solid #111827; margin-bottom: 0.3rem; }

@media (max-width: 640px) {
    .committee-doc { padding: 1.1rem; margin: 0.5rem 0 5rem; border-radius: 0; }
    .committee-doc .table { font-size: 0.82rem; }
    .committee-signatures { gap: 0.75rem; }
}

@media print {
    .committee-doc { box-shadow: none; border-radius: 0; margin: 0; padding: 0; max-width: none; }
    .committee-picker { display: none !important; }
}

/* Pay from: choosing the fund sources for a payout */
.payfrom { display: grid; gap: 0.6rem; padding: 0.9rem 1rem; border: 1px solid var(--border); border-radius: var(--radius-sm, 12px); background: var(--surface-2, transparent); }
.payfrom-head { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem 1.1rem; }
.payfrom-choice { display: inline-flex; align-items: center; gap: 0.4rem; font-size: 0.92rem; cursor: pointer; }
.payfrom-custom { display: grid; gap: 0.5rem; }
.payfrom-row { display: grid; grid-template-columns: minmax(0, 1fr) 9rem auto; align-items: center; gap: 0.6rem; }
.payfrom-row > div { display: grid; }
.payfrom-name { font-weight: 600; }
.payfrom-row.is-empty { opacity: 0.55; }
@media (max-width: 520px) {
    .payfrom-row { grid-template-columns: minmax(0, 1fr) 7rem auto; }
}

/* Closing the books */
.lock-card { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.75rem 1.5rem; padding: 0.9rem 1.1rem; }
.lock-card p { margin: 0.2rem 0 0; }
.lock-form { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; }
.lock-form .form-control { width: auto; min-width: 9rem; }

/* Receipts and vouchers */
.doc-signatures { display: flex; flex-wrap: wrap; gap: 2rem; margin-top: 3rem; }
.doc-signatures > div { flex: 1 1 10rem; font-size: 0.85rem; color: var(--text-muted); }
.doc-signatures span { display: block; border-bottom: 1px solid var(--border-strong, var(--border)); height: 2.2rem; margin-bottom: 0.35rem; }
.gap-card { padding: 0.9rem 1.1rem; }
.gap-card p { margin: 0.2rem 0 0.4rem; }
.gap-list { margin: 0; padding-left: 1.1rem; font-size: 0.9rem; }
@media print { .doc-signatures span { border-color: #000; } }

/* Announcement pictures, member read status and the read figures */
.announcement-images { grid-column: 1 / -1; display: grid; gap: 0.5rem; }
.image-grid { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 0.6rem; }
.image-grid:empty { display: none; }
.image-tile { position: relative; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; background: var(--surface); }
.image-tile img { display: block; width: 100%; aspect-ratio: 4 / 3; object-fit: cover; }
.image-tile.is-removed img { opacity: 0.3; filter: grayscale(1); }
.image-tile .image-name { display: block; padding: 0.25rem 0.4rem; font-size: 0.75rem; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.image-remove { display: flex; align-items: center; gap: 0.35rem; padding: 0.3rem 0.5rem; font-size: 0.8rem; cursor: pointer; }
.row-thumb { width: 44px; height: 44px; object-fit: cover; border-radius: 8px; float: left; margin-right: 0.6rem; border: 1px solid var(--border); }
a.announcement-link { color: inherit; text-decoration: none; transition: box-shadow 0.15s, transform 0.15s; }
a.announcement-link:hover { box-shadow: var(--shadow-md, 0 6px 18px rgba(0, 0, 0, 0.12)); transform: translateY(-1px); }
.announcement-row { display: flex; gap: 0.8rem; align-items: flex-start; }
.announcement-row > div { min-width: 0; flex: 1; }
.announcement-thumb { width: 84px; height: 84px; object-fit: cover; border-radius: 10px; border: 1px solid var(--border); flex: none; }
.announcement.is-unread h3 { font-weight: 700; }
.announcement.is-read h3 { font-weight: 600; color: var(--text-muted); }
.announcement-full h2 { margin: 0.2rem 0 0.4rem; font-size: 1.5rem; }
.announcement-body { line-height: 1.7; overflow-wrap: anywhere; font-size: 1.02rem; }
.announcement-gallery { display: grid; gap: 0.6rem; margin: 0.4rem 0 0.6rem; }
.announcement-gallery.gallery-1 { grid-template-columns: 1fr; }
.announcement-gallery.gallery-2 { grid-template-columns: repeat(2, 1fr); }
.announcement-gallery.gallery-3 { grid-template-columns: repeat(3, 1fr); }
.gallery-item { display: block; border-radius: 12px; overflow: hidden; border: 1px solid var(--border); background: var(--surface); }
.gallery-item img { display: block; width: 100%; height: 100%; max-height: 520px; object-fit: cover; }
.gallery-1 .gallery-item img { object-fit: contain; max-height: 70vh; background: #0001; }
@media (max-width: 560px) { .announcement-gallery.gallery-2, .announcement-gallery.gallery-3 { grid-template-columns: repeat(2, 1fr); } }
.read-chip { display: inline-flex; align-items: center; gap: 0.3rem; color: var(--success); font-weight: 600; }
.read-chip .icon { width: 14px; height: 14px; }
.notice-link { display: grid; gap: 0.15rem; color: inherit; text-decoration: none; flex: 1; min-width: 0; }
.notice-link:hover strong { text-decoration: underline; }
.title-cell { min-width: 13rem; }
.title-cell .row-thumb { float: none; display: block; width: 64px; height: 64px; margin: 0 0 0.4rem; }

.gallery-item img { height: auto; aspect-ratio: 4 / 3; max-height: 520px; }
.gallery-1 .gallery-item img { aspect-ratio: auto; width: 100%; object-fit: contain; max-height: 70vh; }

/* Phone and tablet: messages float just above the bottom menu instead of at the top */
@media (max-width: 960px) {
    .toast-stack {
        top: auto;
        right: auto;
        left: 50%;
        bottom: calc(var(--nav-lift) + max(var(--bottom-nav), var(--pill-nav-h, 0px)) + var(--credit-h) + var(--safe-bottom) + 0.7rem);
        transform: translateX(-50%);
        flex-direction: column-reverse;
        width: min(460px, calc(100vw - 2rem));
    }

    .toast-stack .alert { animation-name: toast-in-up; }

    .guest-wrap .toast-stack { left: auto; bottom: auto; transform: none; width: 100%; flex-direction: column; }
    .guest-wrap .toast-stack .alert { animation-name: toast-in; }
}

@keyframes toast-in-up {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: none; }
}

/* Global search */
.topbar-search { position: relative; }
.search-panel {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    width: min(440px, 92vw);
    max-height: min(70vh, 520px);
    overflow-y: auto;
    padding: 0.35rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 14px;
    box-shadow: var(--shadow-lg, 0 18px 40px rgba(15, 23, 42, 0.18));
    z-index: 60;
    color: var(--text);
}
.search-group-title { padding: 0.5rem 0.65rem 0.2rem; font-size: 0.7rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-muted); }
.search-item { display: grid; gap: 0.05rem; padding: 0.45rem 0.65rem; border-radius: 9px; color: inherit; text-decoration: none; }
.search-item:hover, .search-item.is-active { background: var(--brand-soft); text-decoration: none; }
.search-item strong { font-size: 0.92rem; }
.search-empty { padding: 0.9rem 0.65rem; color: var(--text-muted); font-size: 0.9rem; }
.search-all { display: block; margin-top: 0.25rem; padding: 0.55rem 0.65rem; border-top: 1px solid var(--border); font-size: 0.85rem; font-weight: 600; color: var(--brand-strong); text-decoration: none; }
.search-all:hover { text-decoration: underline; }

.search-page-form { display: flex; align-items: center; gap: 0.6rem; padding: 0.6rem 0.8rem; margin-bottom: 1rem; }
.search-page-form .icon { width: 18px; height: 18px; color: var(--text-muted); flex: none; }
.search-page-form input { flex: 1; min-width: 0; border: 0; background: transparent; color: var(--text); font: inherit; font-size: 1.05rem; padding: 0.35rem 0; }
.search-page-form input:focus { outline: none; }
.search-summary { margin: 0 0 0.6rem; }
.search-results { display: grid; gap: 1rem; }
.search-group { padding: 0.4rem 0.4rem 0.6rem; }
.search-group-head { display: flex; align-items: center; justify-content: space-between; padding: 0.5rem 0.7rem 0.3rem; }
.search-group-head h3 { display: flex; align-items: center; gap: 0.45rem; margin: 0; font-size: 1rem; }
.search-group-head .icon { width: 18px; height: 18px; }
.search-list { list-style: none; margin: 0; padding: 0; }
.search-list a { display: flex; align-items: center; gap: 0.75rem; padding: 0.6rem 0.7rem; border-radius: 10px; color: inherit; text-decoration: none; }
.search-list a:hover { background: var(--brand-soft); text-decoration: none; }
.search-main { display: grid; min-width: 0; flex: 1; }
.search-main > .small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.search-more { padding: 0 0.7rem; margin: 0.3rem 0 0; }
.doc-badge { display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; font-weight: 700; font-size: 0.85rem; flex: none; }
.doc-in { background: var(--success-soft); color: var(--success); }
.doc-out { background: var(--danger-soft); color: var(--danger); }

/* ---------- Install app row (PWA) ---------- */
.sheet-hint {
    margin: 0.5rem 0.25rem 0;
    font-size: 0.85rem;
    line-height: 1.45;
    color: var(--text-muted);
}
