:root {
    --band: #17584a;
    --band-deep: #124a3e;
    --ink: #1b2622;
    --ink-soft: #46514c;
    --muted: #7d8782;
    --cream: #f7f3e7;
    --card: #ffffff;
    --line: #eceee9;
    --line-strong: #e1e5df;
    --tile: #eff2ef;
    --pill: #e2ebe7;
    --pill-ink: #2b463e;
    --teal: #1f5a4c;
    --teal-2: #3b7a6a;
    --teal-3: #6f9f93;
    --teal-4: #a6c6bd;
    --teal-5: #d3e2dd;
    --yellow: #f6d77e;
    --yellow-ink: #3f3308;
    --danger: #c0392b;
    --danger-bg: #fbeceb;
    --success: #1f7a4d;
    --success-bg: #e9f6ef;
    --soft-surface: #fbfaf5;
    --soft-line: #eeeae0;
    --radius-card: 18px;
    --gutter: clamp(12px, 1.4vw, 26px);
    --shadow-3d:
        inset 0 1px 0 rgba(255, 255, 255, 0.95),
        inset 0 -3px 0 rgba(16, 40, 32, 0.035),
        0 0 0 1px rgba(16, 40, 32, 0.045),
        0 2px 4px rgba(16, 40, 32, 0.06),
        0 12px 24px -8px rgba(16, 40, 32, 0.14),
        0 30px 50px -22px rgba(16, 40, 32, 0.22);
    --shadow-3d-hover:
        inset 0 1px 0 rgba(255, 255, 255, 0.95),
        inset 0 -3px 0 rgba(16, 40, 32, 0.035),
        0 0 0 1px rgba(16, 40, 32, 0.05),
        0 4px 8px rgba(16, 40, 32, 0.08),
        0 22px 36px -10px rgba(16, 40, 32, 0.2),
        0 44px 70px -26px rgba(16, 40, 32, 0.3);
    --card-face: linear-gradient(180deg, #ffffff 0%, #fdfcf9 60%, #f8f7f2 100%);
    --shadow-card: 0 1px 2px rgba(16, 40, 32, 0.04), 0 6px 18px rgba(16, 40, 32, 0.04);
    --grain: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.09'/%3E%3C/svg%3E");
}

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

/* Stops mobile Safari/Chrome from auto-inflating text size, which makes pages load looking
   zoomed-in until the user pinches them back down. */
html {
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}
body { overflow-x: clip; }

body {
    font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
    color: var(--ink);
    background: var(--cream) var(--grain);
    line-height: 1.55;
    font-size: 14.5px;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--teal); text-decoration: none; }
a:hover { text-decoration: underline; }
svg { flex-shrink: 0; }

/* ============ Band (teal header area) ============ */
.band {
    background: var(--band) var(--grain);
    color: #fff;
    padding: 0 var(--gutter);
}
.is-page .band { padding-bottom: 92px; }
.is-auth .band { padding-bottom: 110px; }

.topbar {
    display: flex;
    align-items: center;
    gap: 24px;
    height: 76px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    color: #fff;
    font-size: 21px;
    font-weight: 500;
    letter-spacing: -0.01em;
    white-space: nowrap;
}
.brand:hover { text-decoration: none; }

.nav { display: flex; align-items: center; gap: 4px; }
.nav a, .nav-more summary {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    color: rgba(255, 255, 255, 0.72);
    font-size: 13.5px;
    font-weight: 400;
    padding: 11px 13px;
    border-radius: 999px;
    white-space: nowrap;
    transition: background 0.15s ease, color 0.15s ease;
}
.nav a:hover, .nav-more summary:hover { color: #fff; background: rgba(255, 255, 255, 0.06); text-decoration: none; }
.nav a.active, .nav-more summary.active {
    color: #fff;
    background: rgba(255, 255, 255, 0.12);
    font-weight: 500;
}

details { position: relative; }
details > summary { list-style: none; cursor: pointer; }
details > summary::-webkit-details-marker { display: none; }

.menu {
    position: absolute;
    top: calc(100% + 10px);
    left: 0;
    min-width: 220px;
    background: #fff;
    border-radius: 14px;
    padding: 8px;
    box-shadow: 0 18px 40px rgba(10, 30, 24, 0.18);
    z-index: 50;
    display: flex;
    flex-direction: column;
}
.menu-right { left: auto; right: 0; }
.menu a {
    display: flex;
    align-items: center;
    gap: 11px;
    color: var(--ink);
    font-size: 13.5px;
    padding: 10px 12px;
    border-radius: 10px;
}
.menu a svg { color: var(--teal); }
.menu a:hover { background: #f2f5f2; text-decoration: none; }
.menu-count { margin-left: auto; background: var(--teal); color: #fff; font-size: 11px; padding: 1px 8px; border-radius: 999px; }

.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }

.icon-btn {
    position: relative;
    width: 46px;
    height: 46px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    transition: background 0.15s ease;
}
.icon-btn:hover, .icon-btn.active { background: rgba(255, 255, 255, 0.18); text-decoration: none; }
.icon-dot {
    position: absolute;
    top: 11px;
    right: 12px;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--yellow);
    box-shadow: 0 0 0 2px var(--band);
}

.user-chip { display: flex; align-items: center; gap: 12px; padding-left: 4px; }
.user-meta { display: flex; flex-direction: column; line-height: 1.3; }
.user-name { font-size: 14px; font-weight: 600; color: #fff; display: inline-flex; align-items: center; gap: 7px; white-space: nowrap; }
.user-role { font-size: 12px; color: rgba(255, 255, 255, 0.62); }
.online { width: 7px; height: 7px; border-radius: 50%; background: #3ddc84; display: inline-block; }

.avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 600;
    flex-shrink: 0;
}
.avatar-md { width: 42px; height: 42px; font-size: 13px; }
.tone-1 { background: #1f5a4c; color: #fff; }
.tone-2 { background: #d8e8e1; color: #1f5a4c; }
.tone-3 { background: #f3dfb2; color: #6b4f12; }
.tone-4 { background: #3b7a6a; color: #fff; }
.tone-5 { background: #eadbca; color: #5a4330; }
.user-chip .avatar { box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.25); }

/* ============ Hero (greeting) ============ */
.hero {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    gap: 24px;
    padding: 34px 0 104px;
}
.hero-eyebrow { font-size: 15px; font-weight: 300; color: rgba(255, 255, 255, 0.8); }
.hero-name { font-size: 32px; font-weight: 500; color: #fff; letter-spacing: -0.015em; line-height: 1.2; margin-top: 2px; }
.hero-actions { display: flex; align-items: center; gap: 12px; }

.year-pill {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    border: 1px solid rgba(255, 255, 255, 0.28);
    border-radius: 999px;
    padding: 10px 16px;
    color: #fff;
}
.year-pill select {
    display: inline-block;
    width: auto;
    margin: 0;
    padding: 0 2px;
    border: 0;
    background: transparent;
    color: #fff;
    font: inherit;
    font-size: 14px;
    appearance: none;
    -webkit-appearance: none;
    cursor: pointer;
    box-shadow: none;
}
.year-pill select:focus { outline: none; box-shadow: none; }
.year-pill select option { color: var(--ink); }

.btn-white {
    display: inline-flex;
    align-items: center;
    background: #fff;
    color: var(--ink);
    font-size: 14px;
    font-weight: 500;
    padding: 13px 26px;
    border-radius: 999px;
    white-space: nowrap;
}
.btn-white:hover { text-decoration: none; background: #f3f6f3; }

/* ============ Dashboard ============ */
.dash {
    padding: 0 var(--gutter) 44px;
}

/* Pulls whichever section is first inside .dash up into the green band, so the cards
   overlap the header the same way whether or not the "My Contributions" panel is present. */
.dash > *:first-child {
    margin-top: -80px;
}

.kpi-row {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 16px;
    margin-top: 16px;
}
.owed-panel {
    position: relative;
    z-index: 1;
}
.kpi-card {
    background: var(--card);
    border-radius: var(--radius-card);
    padding: 16px 18px 18px;
    box-shadow: var(--shadow-card);
    display: flex;
    flex-direction: column;
    min-height: 128px;
}
.kpi-top { display: flex; justify-content: space-between; align-items: flex-start; }
.kpi-icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: var(--tile);
    color: var(--teal);
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.kpi-arrow {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 1px solid var(--line-strong);
    color: var(--ink);
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.kpi-arrow:hover { background: var(--tile); text-decoration: none; }
.kpi-value-row { display: flex; align-items: center; gap: 10px; margin-top: 12px; flex-wrap: wrap; }
.kpi-value { font-size: 30px; font-weight: 500; letter-spacing: -0.02em; line-height: 1.1; color: var(--ink); }
.kpi-money { font-size: 23px; letter-spacing: -0.025em; }
.kpi-label { font-size: 14.5px; color: var(--muted); margin-top: 4px; }

.badge {
    display: inline-flex;
    align-items: center;
    font-size: 11px;
    font-weight: 600;
    padding: 4px 9px;
    border-radius: 999px;
    white-space: nowrap;
}
.badge-up { background: var(--teal); color: #fff; }
.badge-warn { background: var(--yellow); color: var(--yellow-ink); }

.kpi-add {
    align-items: center;
    justify-content: center;
    gap: 12px;
    color: var(--ink);
    font-size: 15px;
    border: 1.5px dashed #d7ddd8;
    box-shadow: none;
    text-align: center;
}
.kpi-add:hover { text-decoration: none; border-color: var(--teal-3); }
.kpi-add-icon {
    width: 46px;
    height: 46px;
    border-radius: 50%;
    background: var(--teal);
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.grid-3 { display: grid; grid-template-columns: 0.72fr 1fr 0.92fr; gap: 16px; margin-top: 16px; }
.grid-2 { display: grid; grid-template-columns: 1.72fr 0.92fr; gap: 16px; margin-top: 16px; }

.panel {
    background: var(--card);
    border-radius: var(--radius-card);
    padding: 18px 22px 12px;
    box-shadow: var(--shadow-card);
    min-width: 0;
}
.panel-head { display: flex; justify-content: space-between; align-items: center; }
.panel-title { font-size: 18px; font-weight: 500; color: var(--ink); letter-spacing: -0.01em; }
.panel-link { color: var(--ink); display: inline-flex; }
.panel-link:hover { color: var(--teal); }

.panel-count-row { display: flex; justify-content: space-between; align-items: center; margin: 4px 0 8px; }
.panel-count { font-size: 22px; color: var(--ink-soft); font-weight: 400; }
.panel-count strong { font-size: 25px; font-weight: 500; color: var(--ink); margin-right: 2px; }
.panel-count-note { font-size: 12px; color: var(--muted); margin-left: 4px; }

.pager { display: flex; gap: 8px; }
.round-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 1px solid var(--line-strong);
    color: var(--ink);
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.round-btn:hover { background: var(--tile); text-decoration: none; }
.round-btn.is-disabled { opacity: 0.4; pointer-events: none; }

.list { list-style: none; }
.list li { border-bottom: 1px solid var(--line); }
.list li:last-child { border-bottom: none; }
.list-row { display: flex; align-items: center; gap: 12px; padding: 12px 0; color: inherit; }
.list-row:hover { text-decoration: none; }
.list-row:hover .list-title { color: var(--teal); }
.list-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.35; }
.list-title { font-size: 14.5px; font-weight: 500; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list-sub { font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list .empty { color: var(--muted); padding: 14px 0; font-size: 13.5px; }

.tile {
    width: 42px;
    height: 42px;
    border-radius: 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--tile);
    color: var(--teal);
    flex-shrink: 0;
}
.tile-rose { background: #fbeef0; color: #c2566b; }
.tile-amber { background: #fbf3e2; color: #b7862b; }
.tile-blue { background: #eaf2fa; color: #3d7bb8; }
.tile-teal { background: #e9f2ee; color: var(--teal); }

.date-pill {
    margin-left: auto;
    background: var(--pill);
    color: var(--pill-ink);
    font-size: 12px;
    padding: 9px 14px;
    border-radius: 999px;
    white-space: nowrap;
}

.comp-total { display: flex; justify-content: space-between; align-items: baseline; margin: 14px 0 12px; }
.comp-total span { font-size: 15px; color: var(--ink-soft); }
.comp-total strong { font-size: 22px; font-weight: 500; }
.seg-bar { display: flex; gap: 4px; height: 22px; margin-bottom: 6px; }
.seg { border-radius: 5px; min-width: 10px; }
.seg-1 { background: var(--teal); }
.seg-2 { background: var(--teal-2); }
.seg-3 { background: var(--teal-3); }
.seg-4 { background: var(--teal-4); }
.seg-5 { background: var(--teal-5); }
.legend { list-style: none; }
.legend li { display: flex; justify-content: space-between; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--line); }
.legend li:last-child { border-bottom: none; }
.legend-label { display: inline-flex; align-items: center; font-size: 14.5px; color: var(--ink); }
.legend-value { font-size: 18px; font-weight: 500; }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; margin-right: 12px; }

.kpi-big-row { display: flex; align-items: baseline; gap: 16px; flex-wrap: wrap; margin: 4px 0 6px; }
.kpi-big { font-size: 32px; font-weight: 500; letter-spacing: -0.02em; }
.kpi-big-note { font-size: 13px; color: var(--muted); }

.owed-panel { margin-bottom: 16px; }
.owed-panel .kpi-big.owed-amount { color: var(--danger); }
.owed-panel .kpi-big.paid-amount { color: var(--success); }
.date-pill.is-owed { background: var(--danger-bg); color: var(--danger); font-weight: 600; }
.date-pill.is-settled { background: var(--success-bg); color: var(--success); font-weight: 600; }
.owed-breakdown { margin: 4px 0 0; }
.owed-breakdown .list { margin-top: 10px; }

.chart { width: 100%; height: auto; display: block; margin-bottom: 6px; }
.grid-line { stroke: var(--line); stroke-width: 1; }
.grid-target { stroke: #e7a79e; stroke-width: 1; stroke-dasharray: 5 5; }
.axis-label { fill: #9aa39e; font-size: 13px; font-family: 'Plus Jakarta Sans', sans-serif; }
.chart-line { fill: none; stroke: var(--teal); stroke-width: 2.5; stroke-linejoin: round; stroke-linecap: round; }
.chart-dot { fill: #fff; stroke: var(--teal); stroke-width: 2; }

.heatmap {
    display: grid;
    grid-template-rows: repeat(7, 1fr);
    grid-auto-flow: column;
    grid-auto-columns: 1fr;
    gap: 5px;
    margin-top: 16px;
}
.hm { display: block; aspect-ratio: 1; border-radius: 3px; min-width: 7px; }
.hm-0 { background: #e9ede9; }
.hm-1 { background: #c6dad3; }
.hm-2 { background: #8db4a6; }
.hm-3 { background: #4f8676; }
.hm-4 { background: var(--teal); }
.hm-future { background: #f4f5f2; }
.hm-foot { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin: 14px 0 8px; font-size: 12.5px; color: var(--muted); }
.hm-legend { display: inline-flex; align-items: center; gap: 4px; }
.hm-legend .hm { width: 10px; height: 10px; min-width: 10px; display: inline-block; }

/* ============ Inner pages ============ */
.page {
    padding: 0 var(--gutter) 44px;
    margin-top: -64px;
}
.page-card {
    position: relative;
    background: var(--card);
    border-radius: 20px;
    padding: 30px 34px 34px;
    box-shadow: var(--shadow-card);
}
.page-card h2 { font-size: 24px; font-weight: 600; letter-spacing: -0.015em; margin-bottom: 14px; color: var(--ink); }

.profile-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; flex-wrap: wrap; }
.profile-head h2 { margin-bottom: 0; }
.btn-edit {
    display: inline-flex; align-items: center; gap: 6px;
    background: var(--soft-surface); border: 1px solid var(--soft-line);
    color: var(--ink); font-size: 13.5px; font-weight: 600;
    padding: 8px 14px; border-radius: 999px; flex-shrink: 0; margin-top: 2px;
}
.btn-edit:hover { border-color: var(--teal-3); color: var(--teal); text-decoration: none; }
.page-card h3 { font-size: 16.5px; font-weight: 600; margin: 26px 0 10px; color: var(--ink); }
.page-card p { margin-bottom: 8px; }
.page-card ul:not([class]) { margin: 0 0 8px 20px; }

.site-footer { text-align: center; padding: 26px 16px 34px; color: var(--muted); font-size: 12.5px; }

.hint { color: var(--muted); font-size: 13.5px; margin-bottom: 12px; }
.error { color: #8c2a1f; background: #fbece9; padding: 11px 16px; border-radius: 12px; margin-bottom: 14px; font-size: 14px; }
.success { color: #1c5a3f; background: #e6f3ec; padding: 11px 16px; border-radius: 12px; margin-bottom: 14px; font-size: 14px; }

form label { display: block; margin-bottom: 14px; font-size: 13.5px; font-weight: 500; color: var(--ink-soft); }
form input, form select, form textarea {
    display: block;
    width: 100%;
    padding: 11px 14px;
    margin-top: 6px;
    border: 1px solid var(--line-strong);
    border-radius: 12px;
    font: inherit;
    font-size: 14px;
    color: var(--ink);
    background: #fff;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
form input:focus, form select:focus, form textarea:focus {
    outline: none;
    border-color: var(--teal-3);
    box-shadow: 0 0 0 3px rgba(31, 90, 76, 0.12);
}
form textarea { min-height: 96px; resize: vertical; }
form button {
    background: var(--teal);
    color: #fff;
    border: none;
    padding: 12px 24px;
    border-radius: 999px;
    cursor: pointer;
    font: inherit;
    font-size: 14px;
    font-weight: 500;
    transition: background 0.15s ease;
}
form button:hover { background: var(--band-deep); }
form button[value="reject"] { background: #fff; color: #8c2a1f; border: 1px solid #efc9c2; }

.member-picker { position: relative; }
.member-picker .mp-input.mp-input-error { border-color: var(--danger); }
.mp-results {
    display: none;
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    background: #fff;
    border: 1px solid var(--soft-line);
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(16, 40, 32, 0.14);
    max-height: 240px;
    overflow-y: auto;
    z-index: 40;
}
.mp-results.open { display: block; }
.mp-item { padding: 9px 14px; cursor: pointer; display: flex; flex-direction: column; gap: 1px; }
.mp-item:hover { background: var(--soft-surface); }
.mp-item-name { font-size: 14px; color: var(--ink); }
.mp-item-sub { font-size: 12px; color: var(--muted); }
.mp-empty { padding: 9px 14px; font-size: 13px; color: var(--muted); }

.inline-form { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.inline-form input, .inline-form select { width: auto; margin: 0; min-width: 110px; }
.inline-form button { padding: 9px 16px; font-size: 13px; }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; margin: 16px 0 22px; }
.stat-card {
    background: var(--soft-surface);
    border: 1px solid var(--soft-line);
    border-radius: 16px;
    padding: 16px 18px;
}
.stat-label { display: block; font-size: 12.5px; color: var(--muted); }
.stat-value { display: block; font-size: 26px; font-weight: 500; letter-spacing: -0.02em; margin: 4px 0; color: var(--ink); }
.stat-sub { display: block; font-size: 12.5px; color: #a3502c; margin-bottom: 4px; }
.stat-card a { font-size: 13px; font-weight: 500; }

.callout {
    background: #fbf6e6;
    border-left: 3px solid #e3b95a;
    padding: 13px 16px;
    margin-bottom: 14px;
    border-radius: 12px;
    font-size: 14px;
}
.callout ul { margin: 6px 0 0 18px; }

.data-table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 14px; }
.data-table th {
    background: #f6f4ec;
    color: #6b746f;
    font-size: 11.5px;
    font-weight: 600;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    text-align: left;
    padding: 12px 14px;
}
.data-table th:first-child { border-radius: 12px 0 0 12px; }
.data-table th:last-child { border-radius: 0 12px 12px 0; }
.data-table td { padding: 13px 14px; border-bottom: 1px solid var(--line); }
.data-table tbody tr:hover td { background: #fbfaf6; }
.data-table tbody tr:last-child td { border-bottom: none; }

.family-tree, .family-tree ul { list-style: none; padding-left: 28px; border-left: 2px solid #e3e8e3; margin-left: 18px; }
.family-tree { padding-left: 0; border-left: none; margin-left: 0; }
.family-tree li { margin: 10px 0; }
.tree-person {
    display: inline-flex;
    align-items: center;
    background: #fff;
    border: 1px solid var(--line-strong);
    color: var(--ink);
    font-weight: 500;
    padding: 8px 16px;
    border-radius: 999px;
    box-shadow: var(--shadow-card);
}
.tree-person:hover { border-color: var(--teal-3); color: var(--teal); text-decoration: none; }
.tree-spouse { color: #a47a2c; font-size: 13px; margin-left: 8px; }

.event-list, .notification-list, .admin-menu { list-style: none; }
.event-list li, .notification-list li {
    background: var(--soft-surface);
    border: 1px solid var(--soft-line);
    border-radius: 14px;
    padding: 14px 18px;
    margin-bottom: 10px;
}
.admin-menu li { margin-bottom: 10px; }
.admin-menu a {
    display: block;
    background: var(--soft-surface);
    border: 1px solid var(--soft-line);
    border-radius: 14px;
    padding: 15px 18px;
    color: var(--ink);
    font-weight: 500;
}
.admin-menu a:hover { border-color: var(--teal-3); color: var(--teal); text-decoration: none; }

.doc-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px; }
.doc-card { background: var(--soft-surface); border: 1px solid var(--soft-line); border-radius: 16px; padding: 18px; }

/* ---------------- Family Photos & Documents ---------------- */
.pd-tabs { display: flex; gap: 8px; margin-bottom: 18px; border-bottom: 1px solid var(--line); }
.pd-tab {
    display: inline-flex; align-items: center; gap: 7px;
    background: none; border: none; cursor: pointer; font: inherit;
    font-size: 14.5px; font-weight: 600; color: var(--muted);
    padding: 10px 6px 12px; margin-bottom: -1px;
    border-bottom: 2px solid transparent;
}
.pd-tab:hover { color: var(--teal); }
.pd-tab.active { color: var(--teal); border-bottom-color: var(--teal); }
.pd-panel.pd-hidden, .pd-view.pd-hidden { display: none; }
.pd-admin-bar { display: flex; flex-wrap: wrap; gap: 12px; margin-bottom: 18px; }
.pd-admin-bar .new-form { flex: 1 1 260px; margin-bottom: 0; }

.back-btn {
    display: inline-flex; align-items: center; gap: 4px;
    background: none; border: none; cursor: pointer; font: inherit;
    font-size: 13.5px; font-weight: 600; color: var(--teal);
    padding: 6px 0; margin-bottom: 10px;
}
.back-btn:hover { color: var(--band-deep); }

/* Album / folder tiles ("phone gallery" home screen) */
.gallery-albums { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 16px; }
.album-tile {
    display: flex; flex-direction: column; gap: 8px;
    background: none; border: none; cursor: pointer; font: inherit; text-align: left; padding: 0;
}
.album-thumb {
    width: 100%; aspect-ratio: 1 / 1; border-radius: 16px; overflow: hidden;
    background: var(--tile); box-shadow: var(--shadow-card);
    display: flex; align-items: center; justify-content: center;
}
.album-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.album-thumb-empty { color: var(--teal-3); display: flex; align-items: center; justify-content: center; width: 100%; height: 100%; background: linear-gradient(160deg, var(--teal-5), var(--tile)); }
.album-tile:hover .album-thumb { box-shadow: var(--shadow-3d-hover); transform: translateY(-2px); }
.album-thumb { transition: box-shadow .15s ease, transform .15s ease; }
.album-meta strong { display: block; font-size: 13.5px; font-weight: 600; color: var(--ink); line-height: 1.3; }
.album-meta .hint { margin: 2px 0 0; font-size: 12px; }
.folder-tile .album-thumb { background: linear-gradient(160deg, var(--teal-5), var(--tile)); }

/* Inside-album phone-gallery thumbnail grid */
.phone-gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 4px; }
.thumb-tile {
    position: relative; aspect-ratio: 1 / 1; border: none; padding: 0; cursor: pointer;
    background: var(--tile); border-radius: 6px; overflow: hidden;
}
.thumb-tile img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb-tile:hover img { opacity: 0.92; }
.thumb-video-placeholder { position: absolute; inset: 0; background: linear-gradient(160deg, var(--band-deep), var(--band)); }
.thumb-play-badge {
    position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
    color: #fff; font-size: 18px; text-shadow: 0 1px 4px rgba(0, 0, 0, 0.4);
}
.thumb-sensitive-badge {
    position: absolute; top: 4px; left: 4px; background: rgba(192, 57, 43, 0.9); color: #fff;
    font-size: 9.5px; font-weight: 700; padding: 2px 6px; border-radius: 999px; text-transform: uppercase; letter-spacing: 0.02em;
}

/* Lightbox */
.pd-lightbox {
    position: fixed; inset: 0; z-index: 200; background: rgba(10, 18, 15, 0.94);
    display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 20px;
}
.pd-lightbox.pd-hidden { display: none; }
.lb-stage { max-width: min(92vw, 1000px); max-height: 68vh; display: flex; align-items: center; justify-content: center; }
.lb-stage img, .lb-stage video { max-width: 100%; max-height: 68vh; border-radius: 10px; object-fit: contain; box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5); }
.lb-caption { max-width: min(92vw, 1000px); width: 100%; color: #fff; text-align: center; margin-top: 16px; }
.lb-caption strong { font-size: 15px; }
.lb-caption .hint { color: rgba(255, 255, 255, 0.65); }
.lb-caption .btn-edit { background: rgba(255, 255, 255, 0.08); border-color: rgba(255, 255, 255, 0.2); color: #fff; margin-top: 6px; }
.lb-caption .btn-edit:hover { background: rgba(255, 255, 255, 0.16); border-color: rgba(255, 255, 255, 0.3); color: #fff; }
.lb-btn {
    position: fixed; background: rgba(255, 255, 255, 0.1); border: none; color: #fff;
    width: 46px; height: 46px; border-radius: 999px; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
}
.lb-btn:hover { background: rgba(255, 255, 255, 0.2); }
.lb-close { top: 18px; right: 18px; }
.lb-prev { left: 18px; top: 50%; transform: translateY(-50%); }
.lb-next { right: 18px; top: 50%; transform: translateY(-50%); }

/* Document file cards inside a folder */
.doc-card-file { display: flex; flex-direction: column; gap: 4px; }
.doc-file-head { display: flex; align-items: center; gap: 10px; margin-bottom: 2px; }
.file-badge {
    flex: none; display: flex; align-items: center; justify-content: center;
    width: 38px; height: 38px; border-radius: 10px; font-size: 10px; font-weight: 700; letter-spacing: 0.02em;
}
.file-badge.ft-pdf { background: var(--danger-bg); color: var(--danger); }
.file-badge.ft-doc { background: #e5edff; color: #2c4fb0; }
.file-badge.ft-xls { background: var(--success-bg); color: var(--success); }
.file-badge.ft-img { background: var(--teal-5); color: var(--teal); }
.file-badge.ft-generic { background: var(--pill); color: var(--pill-ink); }

@media (max-width: 560px) {
    .gallery-albums { grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 12px; }
    .phone-gallery { grid-template-columns: repeat(auto-fill, minmax(90px, 1fr)); gap: 3px; }
    .lb-prev { left: 6px; }
    .lb-next { right: 6px; }
    .lb-btn { width: 40px; height: 40px; }
    .pd-admin-bar { flex-direction: column; }
}

.tag {
    display: inline-flex;
    align-items: center;
    background: var(--pill);
    color: var(--pill-ink);
    font-size: 11.5px;
    font-weight: 500;
    padding: 3px 10px;
    border-radius: 999px;
    margin-left: 6px;
}
.tag-deceased { background: #efece6; color: #6b675f; font-size: 11.5px; font-weight: 500; padding: 3px 10px; border-radius: 999px; margin-left: 8px; }
.row-deceased td { color: var(--muted); }

.new-form { background: var(--soft-surface); border: 1px solid var(--soft-line); border-radius: 16px; padding: 16px 20px; margin-bottom: 20px; }
.new-form summary { font-weight: 600; color: var(--teal); }
.new-form form { margin-top: 16px; }

.filter-form { margin-bottom: 16px; max-width: 320px; }

.search-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
    gap: 4px 14px;
    background: var(--soft-surface);
    border: 1px solid var(--soft-line);
    padding: 18px 18px 6px;
    border-radius: 16px;
    margin-bottom: 14px;
}
.search-form { margin-bottom: 18px; }

/* ============ Login ============ */
.auth-hero { padding: 40px 0 0; text-align: center; }
.auth-main { padding: 0 20px 40px; margin-top: -80px; }
.auth-card {
    max-width: 420px;
    margin: 0 auto;
    background: #fff;
    border-radius: 22px;
    padding: 32px 32px 26px;
    box-shadow: 0 10px 40px rgba(16, 40, 32, 0.1);
}
.auth-card h2 { font-size: 22px; font-weight: 600; margin-bottom: 18px; }
.auth-card form button { width: 100%; padding: 13px; margin-top: 4px; }
.auth-card .hint { text-align: center; margin: 16px 0 0; }

/* ============ Full-screen layout ============ */
body.is-dashboard, body.is-page { display: flex; flex-direction: column; min-height: 100vh; }
.dash, .page { flex: 1; }

/* ============ 3D depth layer ============ */
.band {
    position: relative;
    background:
        radial-gradient(ellipse 60% 120% at 12% -10%, rgba(255, 255, 255, 0.11), transparent 55%),
        radial-gradient(ellipse 50% 90% at 95% 0%, rgba(120, 220, 190, 0.1), transparent 60%),
        var(--grain),
        linear-gradient(180deg, #1c6553 0%, #17584a 55%, #134b3f 100%);
    box-shadow: inset 0 -30px 40px -30px rgba(0, 0, 0, 0.35);
}

.nav a.active, .nav-more summary.active {
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.2), rgba(255, 255, 255, 0.08));
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.25), inset 0 -1px 0 rgba(0, 0, 0, 0.15), 0 4px 10px rgba(0, 0, 0, 0.18);
}
.icon-btn {
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.18), rgba(255, 255, 255, 0.06));
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.25), inset 0 -2px 0 rgba(0, 0, 0, 0.18), 0 6px 14px rgba(0, 0, 0, 0.22);
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.icon-btn:hover { transform: translateY(-2px); }
.icon-btn:active { transform: translateY(1px); box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.25); }
.user-chip .avatar { box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.3), 0 6px 14px rgba(0, 0, 0, 0.25); }

.year-pill { background: rgba(0, 0, 0, 0.1); box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.2), 0 1px 0 rgba(255, 255, 255, 0.12); }
.btn-white {
    background: linear-gradient(180deg, #ffffff 0%, #eef2ee 100%);
    box-shadow: inset 0 1px 0 #fff, inset 0 -3px 0 rgba(16, 40, 32, 0.1), 0 8px 18px rgba(0, 0, 0, 0.25);
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.btn-white:hover { transform: translateY(-2px); background: linear-gradient(180deg, #ffffff 0%, #f3f6f3 100%); }
.btn-white:active { transform: translateY(1px); box-shadow: inset 0 2px 5px rgba(16, 40, 32, 0.2); }

.kpi-card, .panel {
    position: relative;
    background: var(--card-face);
    box-shadow: var(--shadow-3d);
    transition: transform 0.25s cubic-bezier(.2, .8, .2, 1), box-shadow 0.25s ease;
    transform-style: preserve-3d;
    will-change: transform;
}
.kpi-card:hover, .panel:hover { box-shadow: var(--shadow-3d-hover); }
.kpi-card::after {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: inherit;
    background: radial-gradient(circle at var(--mx, 50%) var(--my, 0%), rgba(255, 255, 255, 0.75), transparent 55%);
    opacity: 0;
    transition: opacity 0.25s ease;
    pointer-events: none;
}
.kpi-card:hover::after { opacity: 1; }
.kpi-card > * { position: relative; z-index: 1; }

.kpi-icon, .tile {
    background: linear-gradient(145deg, #ffffff 0%, #e4ebe6 100%);
    box-shadow: inset 0 1px 0 #fff, inset 0 -2px 0 rgba(16, 40, 32, 0.08), 0 4px 10px rgba(16, 40, 32, 0.12), 0 1px 2px rgba(16, 40, 32, 0.08);
}
.tile-rose { background: linear-gradient(145deg, #fff6f7 0%, #f7dde2 100%); }
.tile-amber { background: linear-gradient(145deg, #fffaf0 0%, #f5e5c3 100%); }
.tile-blue { background: linear-gradient(145deg, #f5f9fd 0%, #d9e7f5 100%); }
.tile-teal { background: linear-gradient(145deg, #f4faf7 0%, #d6e8e0 100%); }

.kpi-arrow, .round-btn {
    background: linear-gradient(180deg, #ffffff 0%, #eff2ef 100%);
    border-color: rgba(16, 40, 32, 0.08);
    box-shadow: inset 0 1px 0 #fff, 0 3px 7px rgba(16, 40, 32, 0.12);
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.kpi-arrow:hover, .round-btn:hover { transform: translateY(-2px); box-shadow: inset 0 1px 0 #fff, 0 6px 12px rgba(16, 40, 32, 0.18); }
.kpi-arrow:active, .round-btn:active { transform: translateY(1px); box-shadow: inset 0 2px 4px rgba(16, 40, 32, 0.15); }

.kpi-value, .kpi-big, .panel-count strong, .comp-total strong { text-shadow: 0 1px 0 #fff, 0 3px 6px rgba(16, 40, 32, 0.12); }

.badge-up {
    background: linear-gradient(180deg, #2c7262 0%, #184c40 100%);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.28), 0 3px 6px rgba(20, 70, 58, 0.35);
}
.badge-warn {
    background: linear-gradient(180deg, #fbe7a6 0%, #f1c95a 100%);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.6), 0 3px 6px rgba(160, 120, 20, 0.3);
}

.kpi-add { background: linear-gradient(180deg, #ffffff 0%, #f6f5f0 100%); box-shadow: inset 0 2px 8px rgba(16, 40, 32, 0.05), 0 10px 22px -10px rgba(16, 40, 32, 0.18); }
.kpi-add:hover { background: #fff; box-shadow: var(--shadow-3d-hover); }
.kpi-add-icon {
    background: radial-gradient(circle at 35% 30%, #3b8a77 0%, #1f5a4c 55%, #143f35 100%);
    box-shadow: inset 0 2px 3px rgba(255, 255, 255, 0.3), inset 0 -3px 5px rgba(0, 0, 0, 0.25), 0 8px 18px rgba(20, 70, 58, 0.4);
}

.avatar { box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.35), inset 0 -2px 3px rgba(0, 0, 0, 0.12), 0 4px 10px rgba(16, 40, 32, 0.16); }
.tone-1 { background: radial-gradient(circle at 35% 30%, #3b8a77, #1f5a4c 60%, #16463b); }
.tone-2 { background: radial-gradient(circle at 35% 30%, #eef6f2, #d0e3da 60%, #b8d3c7); }
.tone-3 { background: radial-gradient(circle at 35% 30%, #fbefd1, #f0d69c 60%, #e2c07a); }
.tone-4 { background: radial-gradient(circle at 35% 30%, #5d9c8c, #3b7a6a 60%, #2c6154); }
.tone-5 { background: radial-gradient(circle at 35% 30%, #f5ebe0, #e6d3bf 60%, #d4bca3); }

.date-pill { background: linear-gradient(180deg, #e8f0ec, #dce7e2); box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.8), 0 2px 4px rgba(16, 40, 32, 0.08); }

.seg-bar { padding: 3px; border-radius: 8px; background: #eef1ee; box-shadow: inset 0 2px 4px rgba(16, 40, 32, 0.1); height: 28px; }
.seg { box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.3), inset 0 -2px 0 rgba(0, 0, 0, 0.12), 0 2px 4px rgba(16, 40, 32, 0.15); }
.seg-1 { background: linear-gradient(180deg, #2f7564, #1a4f42); }
.seg-2 { background: linear-gradient(180deg, #4f9080, #336d5f); }
.seg-3 { background: linear-gradient(180deg, #86b4a8, #62938a); }
.seg-4 { background: linear-gradient(180deg, #bcd7cf, #9dbfb5); }
.seg-5 { background: linear-gradient(180deg, #e3eeea, #c9dcd6); }
.dot { box-shadow: 0 2px 4px rgba(16, 40, 32, 0.25); }

.hm-0 { background: #e6ebe7; box-shadow: inset 0 1px 2px rgba(16, 40, 32, 0.12); }
.hm-1, .hm-2, .hm-3, .hm-4 { box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.35), 0 2px 3px rgba(16, 40, 32, 0.2); }
.hm-1 { background: linear-gradient(180deg, #d3e5de, #b5cfc6); }
.hm-2 { background: linear-gradient(180deg, #a3c6b9, #7aa596); }
.hm-3 { background: linear-gradient(180deg, #62988a, #437768); }
.hm-4 { background: linear-gradient(180deg, #2c7262, #184c40); }
.hm-future { background: #f2f3ef; box-shadow: none; }

.chart-line { filter: drop-shadow(0 6px 6px rgba(31, 90, 76, 0.35)); stroke-width: 3; }
.chart-dot { filter: drop-shadow(0 2px 2px rgba(31, 90, 76, 0.4)); }

@media (prefers-reduced-motion: reduce) {
    .kpi-card, .panel, .icon-btn, .btn-white, .kpi-arrow, .round-btn { transition: none; }
}

/* ============ Login (photo + frosted glass) ============ */
.login-body {
    min-height: 100vh;
    font-family: 'Poppins', 'Plus Jakarta Sans', sans-serif;
    color: #fff;
    background-color: #2b3f4f;
    background-image:
        linear-gradient(90deg, rgba(8, 18, 28, 0.62) 0%, rgba(8, 18, 28, 0.34) 45%, rgba(8, 18, 28, 0.12) 100%),
        var(--login-photo, none),
        radial-gradient(ellipse 60% 35% at 22% 18%, rgba(255, 255, 255, 0.28), transparent 70%),
        radial-gradient(ellipse 45% 20% at 70% 14%, rgba(255, 255, 255, 0.22), transparent 70%),
        radial-gradient(ellipse 70% 14% at 50% 45%, rgba(233, 150, 170, 0.55), transparent 75%),
        radial-gradient(ellipse 55% 40% at 30% 96%, #5b3e2c 0%, #3a2a20 45%, transparent 72%),
        radial-gradient(ellipse 40% 30% at 92% 88%, #4a3527 0%, transparent 70%),
        linear-gradient(180deg, #365d7a 0%, #6f8aa3 26%, #b7a3b4 44%, #d9b3bd 48%, #7d95ab 50%, #5c7489 64%, #3f4f5c 80%, #2e2a27 100%);
    background-size: cover;
    background-position: center;
    background-attachment: fixed;
}
.login-scene {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 48px;
    padding: 48px max(40px, calc((100% - 1120px) / 2));
}
.login-intro { max-width: 460px; }
.login-logo {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    font-family: 'Bebas Neue', sans-serif;
    font-size: 26px;
    line-height: 0.95;
    letter-spacing: 0.04em;
    margin-bottom: 26px;
}
.login-title {
    font-family: 'Bebas Neue', sans-serif;
    font-weight: 400;
    font-size: clamp(56px, 7vw, 92px);
    line-height: 0.92;
    letter-spacing: 0.02em;
    color: #fff;
    text-transform: uppercase;
    margin-bottom: 22px;
}
.login-tagline { font-size: 19px; font-weight: 400; line-height: 1.3; margin-bottom: 14px; }
.login-copy { font-size: 14px; font-weight: 300; line-height: 1.55; color: rgba(255, 255, 255, 0.9); }

.login-glass {
    width: 100%;
    max-width: 430px;
    padding: 40px 44px 30px;
    border-radius: 24px;
    background: rgba(255, 255, 255, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.28);
    backdrop-filter: blur(18px) saturate(120%);
    -webkit-backdrop-filter: blur(18px) saturate(120%);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.18);
}
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

.login-heading { font-family: 'Plus Jakarta Sans', sans-serif; font-size: 28px; font-weight: 600; color: #fff; margin-bottom: 6px; }
.login-sub { font-size: 13.5px; color: rgba(255, 255, 255, 0.82); margin-bottom: 26px; }

.field-icon { position: relative; margin-bottom: 18px; }
.login-form input {
    display: block;
    width: 100%;
    margin: 0;
    padding: 14px 46px 14px 18px;
    border: 1px solid rgba(255, 255, 255, 0.4);
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
    font-family: inherit;
    font-size: 14px;
    box-shadow: none;
}
.login-form input::placeholder { color: rgba(255, 255, 255, 0.65); }
.login-form input:focus { outline: none; border-color: rgba(255, 255, 255, 0.85); box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.15); }
.field-icon-glyph {
    position: absolute;
    top: 50%;
    right: 15px;
    transform: translateY(-50%);
    display: inline-flex;
    color: rgba(255, 255, 255, 0.75);
    background: none;
    border: none;
    padding: 0;
    cursor: default;
}
button.field-icon-glyph { cursor: pointer; }
button.field-icon-glyph:hover { color: #fff; }
.pw-field .icon-eye-off { display: none; }
.pw-field.is-visible .icon-eye { display: none; }
.pw-field.is-visible .icon-eye-off { display: inline-flex; }

.login-row { display: flex; align-items: center; justify-content: space-between; margin: 2px 0 22px; flex-wrap: wrap; gap: 10px; }
.remember-check { display: inline-flex; align-items: center; gap: 9px; font-size: 13.5px; color: #fff; cursor: pointer; margin: 0; }
.remember-check input { position: absolute; opacity: 0; width: 0; height: 0; }
.check-box {
    width: 19px;
    height: 19px;
    border-radius: 5px;
    border: 1.5px solid rgba(255, 255, 255, 0.6);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    flex-shrink: 0;
}
.check-box svg { opacity: 0; transition: opacity 0.1s ease; }
.remember-check input:checked + .check-box { background: linear-gradient(135deg, #8bc34a, #2e8b57); border-color: transparent; }
.remember-check input:checked + .check-box svg { opacity: 1; }
.login-forgot {
    color: rgba(255, 255, 255, 0.75);
    font-size: 13.5px;
    margin: 0;
}
.login-help {
    font-size: 12.5px;
    line-height: 1.5;
    color: rgba(255, 255, 255, 0.95);
    background: rgba(0, 0, 0, 0.28);
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 10px;
    padding: 11px 14px;
    margin: 0 0 20px;
}
.login-form .login-submit {
    display: block;
    width: 100%;
    padding: 15px;
    border: none;
    border-radius: 10px;
    background: linear-gradient(120deg, #9ccc3c 0%, #2e8b57 100%);
    color: #fff;
    font-family: inherit;
    font-size: 15px;
    font-weight: 600;
    letter-spacing: 0.04em;
    cursor: pointer;
    box-shadow: 0 10px 22px rgba(46, 139, 87, 0.35);
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.login-form .login-submit:hover { transform: translateY(-2px); box-shadow: 0 14px 28px rgba(46, 139, 87, 0.42); }
.login-form .login-submit:active { transform: translateY(1px); box-shadow: 0 6px 14px rgba(46, 139, 87, 0.3); }
.login-divider {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 22px;
    margin: 24px 0 18px;
    font-size: 14px;
}
.login-divider::before, .login-divider::after { content: ""; width: 78px; height: 1px; background: rgba(255, 255, 255, 0.7); }
.login-new { text-align: center; font-size: 13.5px; }
.login-new a { color: #fff; text-decoration: underline; }
.login-error { background: rgba(192, 57, 43, 0.85); color: #fff; font-size: 13.5px; padding: 10px 14px; border-radius: 8px; margin-bottom: 18px; }

@media (max-width: 860px) and (min-width: 681px) {
    .login-scene { flex-direction: column; justify-content: center; padding: 40px 20px; gap: 32px; }
    .login-intro { text-align: center; }
    .login-glass { padding: 30px 24px 24px; }
}

/* Mobile: full-bleed hills-at-sunset scene, no side intro text, card centered on the photo */
@media (max-width: 680px) {
    .login-body {
        background-image:
            var(--login-photo, none),
            radial-gradient(ellipse 90% 40% at 50% 0%, rgba(255, 255, 255, 0.35), transparent 70%),
            radial-gradient(ellipse 70% 22% at 50% 34%, rgba(255, 200, 170, 0.65), transparent 75%),
            linear-gradient(180deg, #bfe3e0 0%, #cdebd8 30%, #a9d98f 42%, #7fbf5e 52%, #5fa347 64%, #4c8f3c 78%, #3a7530 100%);
        background-attachment: scroll;
    }
    .login-scene {
        display: flex;
        align-items: center;
        justify-content: center;
        min-height: 100svh;
        padding: 28px 20px;
    }
    .login-intro { display: none; }
    .login-glass {
        width: 100%;
        max-width: 380px;
        padding: 34px 26px 28px;
        border-radius: 28px;
        background: rgba(60, 70, 60, 0.28);
        border: 1px solid rgba(255, 255, 255, 0.35);
    }
    .login-heading { font-size: 26px; }
}

/* ============ Responsive ============ */
.mobile-nav { display: none; }
.chart-scroll { width: 100%; }

@media (max-width: 1320px) {
    .nav a span, .nav-more summary span { display: none; }
    .nav a, .nav-more summary { padding: 11px 13px; }
}
@media (max-width: 1100px) {
    .kpi-row { grid-template-columns: repeat(3, 1fr); }
    .grid-3 { grid-template-columns: 1fr 1fr; }
    .grid-3 > .panel:last-child { grid-column: 1 / -1; }
    .grid-2 { grid-template-columns: 1fr; }
    .user-meta { display: none; }
}

/* Tablets & phones: hamburger menu replaces the pill nav */
@media (max-width: 900px) {
    .nav { display: none; }
    .mobile-nav { display: block; }
    .mobile-nav > summary {
        width: 42px;
        height: 42px;
        border-radius: 12px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        color: #fff;
        background: linear-gradient(180deg, rgba(255, 255, 255, 0.18), rgba(255, 255, 255, 0.06));
        box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.25), 0 6px 14px rgba(0, 0, 0, 0.2);
    }
    .mobile-nav .menu { min-width: 250px; max-height: 70vh; overflow-y: auto; }
    .mobile-nav .menu a.active { background: #eaf2ee; font-weight: 600; }
    .menu-sep { height: 1px; background: #eceee9; margin: 6px 4px; }
    .topbar { gap: 14px; }
}

@media (max-width: 760px) {
    /* iOS zooms the page when focusing any field under 16px — keep every input at 16px on phones. */
    input, select, textarea, .login-form input { font-size: 16px; }
    .topbar { height: 68px; }
    .brand { font-size: 17px; }
    .icon-btn { width: 40px; height: 40px; }
    .topbar-right { gap: 8px; }
    .user-chip .avatar { width: 40px; height: 40px; font-size: 13px; }

    .hero { flex-direction: column; align-items: flex-start; gap: 18px; padding: 24px 0 96px; }
    .hero-name { font-size: 26px; }
    .hero-actions { width: 100%; }
    .hero-actions .btn-white { flex: 1; justify-content: center; }

    .kpi-row { grid-template-columns: 1fr 1fr; gap: 12px; }
    .kpi-row > .kpi-add { grid-column: 1 / -1; min-height: 96px; flex-direction: row; }
    .kpi-card { padding: 14px 14px 16px; min-height: 118px; }
    .kpi-value { font-size: 26px; }
    .kpi-money { font-size: 20px; }
    .kpi-label { font-size: 13px; }

    .grid-3, .grid-2 { grid-template-columns: 1fr; gap: 12px; margin-top: 12px; }
    .grid-3 > .panel:last-child { grid-column: auto; }
    .panel { padding: 16px 16px 10px; }
    .date-pill { padding: 7px 10px; font-size: 11px; }
    .list-text { flex: 1; }

    .chart-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 0 -4px; padding: 0 4px; }
    .chart-scroll .chart { min-width: 620px; }
    .heatmap { gap: 3px; }
    .hm { min-width: 0; border-radius: 2px; }

    .page { margin-top: -70px; }
    .page-card { padding: 22px 16px 24px; border-radius: 18px; }
    .page-card h2 { font-size: 21px; }
    .data-table { display: block; overflow-x: auto; white-space: nowrap; -webkit-overflow-scrolling: touch; }
    .inline-form input, .inline-form select { min-width: 0; flex: 1 1 120px; }
    .filter-form { max-width: none; }
    .doc-grid { grid-template-columns: 1fr; }
    .family-tree ul { padding-left: 16px; margin-left: 10px; }
}

@media (max-width: 420px) {
    .brand span { display: none; }
    .kpi-row { grid-template-columns: 1fr 1fr; }
    .kpi-value-row { gap: 6px; }
    .badge { font-size: 10px; padding: 3px 7px; }
    .list-row { gap: 10px; }
    .avatar-md, .tile { width: 38px; height: 38px; }
    .panel-count { font-size: 19px; }
    .panel-count strong { font-size: 22px; }
}

/* ============ Loans ============ */
.page-card h4 { font-size: 14.5px; font-weight: 600; margin: 20px 0 10px; color: var(--ink-soft); }
.head-links { display: flex; gap: 8px; flex-wrap: wrap; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin: 26px 0 10px; }
.section-head h3 { margin: 0 !important; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 0 16px; }
form label.check { display: flex; align-items: center; gap: 10px; font-weight: 500; }
form label.check input { width: auto; margin: 0; flex: none; }
.text-danger { color: var(--danger) !important; }
.text-success { color: var(--success) !important; }

.loan-tag { margin-left: 0; white-space: nowrap; }
.loan-pending { background: #fbf1d9; color: #8a5a00; }
.loan-active { background: #e2f1ea; color: #1c5a3f; }
.loan-overdue { background: #fbe4df; color: #9b2c1c; }
.loan-repaid { background: #e6eef8; color: #2a4f7a; }
.loan-defaulted { background: #3d2320; color: #fff; }
.loan-rejected, .loan-cancelled { background: #efece6; color: #6b675f; }

.loan-preview { margin: 4px 0 16px; }
.calc-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 10px; background: #fff; border: 1px dashed var(--line-strong); border-radius: 14px; padding: 14px; }
.calc-grid span, .detail-grid span { display: block; font-size: 12px; color: var(--muted); }
.calc-grid strong { font-size: 15px; font-weight: 600; color: var(--teal); }

.detail-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 14px 20px; background: var(--soft-surface); border: 1px solid var(--soft-line); border-radius: 16px; padding: 18px 20px; margin-bottom: 20px; }
.detail-grid strong { font-size: 14px; font-weight: 500; color: var(--ink); }

.alert-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 14px; margin-bottom: 22px; }
.alert-card { background: var(--soft-surface); border: 1px solid var(--soft-line); border-radius: 16px; padding: 14px 16px; }
.alert-card.alert-danger { border-color: #efc9c2; background: #fdf6f4; }
.page-card .alert-card h3 { font-size: 14px; margin: 0 0 10px; display: flex; justify-content: space-between; align-items: center; }
.alert-card .count { background: #fff; border: 1px solid var(--soft-line); border-radius: 999px; padding: 1px 9px; font-size: 12px; }
.alert-card ul { list-style: none; margin: 0; padding: 0; max-height: 190px; overflow-y: auto; }
.alert-card li { display: flex; justify-content: space-between; gap: 10px; padding: 6px 0; border-top: 1px solid var(--soft-line); font-size: 13.5px; }
.alert-card li:first-child { border-top: none; }
.alert-card li span { color: var(--muted); text-align: right; }
.alert-card .hint { margin: 0; }

.filter-pills { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
.filter-pills a { padding: 6px 13px; border-radius: 999px; border: 1px solid var(--soft-line); background: var(--soft-surface); font-size: 13px; color: var(--ink-soft); }
.filter-pills a.active, .filter-pills a:hover { background: var(--teal); border-color: var(--teal); color: #fff; text-decoration: none; }

.data-table tfoot td { padding: 12px 14px; border-top: 2px solid var(--soft-line); font-weight: 600; }
.sched-overdue td { color: var(--danger); }
.sched-paid td { color: var(--muted); }
.history-list { list-style: none; margin: 0; padding: 0; font-size: 13.5px; }
.history-list li { padding: 8px 0; border-top: 1px solid var(--soft-line); }
.history-list li .hint { display: block; margin: 0 0 2px; font-size: 12px; }

.balance-box { display: flex; align-items: baseline; gap: 14px; flex-wrap: wrap; padding: 16px 20px; border-radius: 16px; border: 1px solid var(--soft-line); background: var(--soft-surface); }
.balance-box strong { font-size: 26px; font-weight: 600; }
.balance-box span { color: var(--ink-soft); font-size: 14px; }
.balance-box.is-owed strong { color: #a3502c; }
.balance-box.is-overdue { background: #fdf6f4; border-color: #efc9c2; }
.balance-box.is-overdue strong { color: var(--danger); }
.balance-box.is-clear strong { color: var(--success); }

.pl-table { max-width: 620px; }
.pl-table td:last-child { text-align: right; white-space: nowrap; }
.pl-table .pl-sub td { font-weight: 600; }
.pl-table .pl-total td { font-weight: 700; font-size: 15.5px; border-top: 2px solid var(--line-strong); }

.report-filters { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; background: var(--soft-surface); border: 1px solid var(--soft-line); border-radius: 16px; padding: 14px 16px; margin-bottom: 18px; }
.report-filters label { margin: 0; min-width: 180px; flex: 1 1 180px; }
.report-filters button { flex: none; }

.statement-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap; margin-bottom: 16px; }
.statement-meta { text-align: right; font-size: 13.5px; color: var(--ink-soft); display: grid; gap: 4px; justify-items: end; }
.btn-print { background: var(--teal); color: #fff; border: none; padding: 11px 22px; border-radius: 999px; font: inherit; font-size: 14px; cursor: pointer; }

@media (max-width: 680px) {
    .form-grid { grid-template-columns: 1fr; }
    .statement-meta { text-align: left; justify-items: start; }
}

@media print {
    .band, .site-footer, .no-print, .new-form, .action-panels, .head-links, .btn-edit { display: none !important; }
    body, .page, .page-card { background: #fff !important; box-shadow: none !important; margin: 0 !important; padding: 0 !important; }
    .page-card { border: none !important; }
    .data-table { display: table !important; white-space: normal !important; font-size: 12px; }
    .stat-card, .detail-grid, .alert-card { break-inside: avoid; }
    a { color: inherit; text-decoration: none; }
}

/* ============ Photos & contact ============ */
.avatar-photo { object-fit: cover; background: var(--soft-surface); display: inline-block; }
.avatar-sm { width: 32px; height: 32px; font-size: 11.5px; flex: none; }
.avatar-xl { width: 88px; height: 88px; font-size: 26px; }
.avatar-xxl { width: 112px; height: 112px; font-size: 34px; box-shadow: 0 0 0 4px #fff, 0 8px 22px rgba(16, 40, 32, 0.14); }
.name-cell { display: inline-flex; align-items: center; gap: 10px; }
.profile-id { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }
.profile-id a { display: inline-flex; }
.contact-line { display: flex; gap: 18px; flex-wrap: wrap; margin: 6px 0 0; font-size: 14.5px; }
.contact-line span { display: inline-flex; align-items: center; gap: 6px; color: var(--ink-soft); }
.photo-field { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; background: var(--soft-surface); border: 1px solid var(--soft-line); border-radius: 16px; padding: 14px 16px; margin-bottom: 16px; }
.photo-field .photo-label { flex: 1 1 240px; margin: 0; }
.photo-field .photo-label .hint { display: block; margin: 6px 0 0; font-weight: 400; }
.photo-field label.check { margin: 0; }
.photo-empty { background: #fff; border: 2px dashed var(--line-strong); color: var(--muted); }
.who { display: flex; flex-direction: column; }
.who small { font-size: 12px; }
.alert-card li .who a { color: var(--teal); }

.fund-add { background: #eef6f1; border: 1px solid #cfe3d8; border-radius: 16px; padding: 16px 20px; margin-bottom: 22px; }
.page-card .fund-add h3 { margin: 0 0 8px; display: flex; align-items: center; gap: 8px; color: var(--teal); }
.fund-add .inline-form input[type="number"] { min-width: 170px; }
.btn-edit.btn-primary { background: var(--teal); border-color: var(--teal); color: #fff; }
.btn-edit.btn-primary:hover { background: var(--band-deep); color: #fff; }

@media (max-width: 680px) {
    .avatar-xxl { width: 88px; height: 88px; }
    .profile-head .head-links { width: 100%; }
}
