/* Shared typography applies to both screen and printed pages. */
:root {
    --app-font-family: "Manrope", system-ui, sans-serif;
    --bs-font-sans-serif: var(--app-font-family);
    --bs-body-font-family: var(--app-font-family);
}
body, button, input, optgroup, select, textarea {
    font-family: var(--app-font-family);
}

/* Shared visual theme: teal-green accents, pale primary-tinted canvas, rounded surfaces.
   Screen-only styling keeps the existing receipt and register print layouts. */
@media screen {
    :root {
        --nijc: #159f85;
        --sidebar: #ffffff;
        --ink: #19231f;
        --canvas: #eff9f6;
        --muted: #68736d;
        --theme-green: #159f85;
        --theme-green-dark: #107c68;
        --theme-tint: #e8f6f2;
        --theme-line: #dcece6;
        --theme-field: #f5fbf9;
        --theme-muted: #e1f3ee;
        --shadow-panel: 0 2px 5px rgb(16 80 65 / 3%), 0 10px 28px rgb(16 80 65 / 6%);
        --bs-secondary-bg: var(--theme-muted);
        --bs-tertiary-bg: var(--theme-field);
        --radius-sm: 6px;
        --radius-md: 8px;
        --radius-lg: 12px;
        --bs-border-radius: var(--radius-md);
        --bs-border-radius-sm: var(--radius-sm);
        --bs-border-radius-lg: var(--radius-lg);
        --bs-border-radius-xl: var(--radius-lg);
        --bs-border-radius-xxl: var(--radius-lg);
        --bs-border-radius-pill: var(--radius-md);
        --bs-primary-rgb: 21, 159, 133;
        --bs-success-rgb: 21, 159, 133;
        --bs-link-color: #159f85;
        --bs-link-hover-color: #107c68;
        --bs-body-color: #19231f;
        --bs-secondary-color: #68736d;
        --bs-border-color: #e6eae5;
    }

    body {
        background: var(--canvas);
        color: var(--ink);
        font-family: var(--app-font-family);
        -webkit-font-smoothing: antialiased;
    }
    h1, h2, h3, .stat-number { letter-spacing: -.035em; }
    a { color: var(--theme-green); }
    .text-secondary { color: var(--muted) !important; }
    .btn { border-radius: var(--radius-md); font-weight: 500; padding: 10px 18px; }
    .btn-sm { padding: 7px 13px; }
    .btn-primary, .btn-success {
        --bs-btn-bg: var(--theme-green);
        --bs-btn-border-color: var(--theme-green);
        --bs-btn-hover-bg: var(--theme-green-dark);
        --bs-btn-hover-border-color: var(--theme-green-dark);
        --bs-btn-active-bg: var(--theme-green-dark);
        --bs-btn-active-border-color: var(--theme-green-dark);
        --bs-btn-disabled-bg: var(--theme-green);
        --bs-btn-disabled-border-color: var(--theme-green);
        background: var(--bs-btn-bg);
        border-color: var(--bs-btn-border-color);
    }
    .btn-primary:hover, .btn-success:hover { background: var(--theme-green-dark); border-color: var(--theme-green-dark); }
    .btn-outline-primary, .btn-outline-success {
        --bs-btn-color: var(--theme-green);
        --bs-btn-border-color: #add9d0;
        --bs-btn-hover-bg: var(--theme-green);
        --bs-btn-hover-border-color: var(--theme-green);
        --bs-btn-active-bg: var(--theme-green-dark);
        --bs-btn-active-border-color: var(--theme-green-dark);
    }
    .btn-light { --bs-btn-bg: var(--theme-tint); --bs-btn-border-color: var(--theme-tint); }
    .form-control, .form-select { border-color: var(--theme-line); border-radius: var(--radius-md); background-color: var(--theme-field); color: var(--ink); }
    .form-control[readonly] { background-color: #edf8f4; }
    .form-control:disabled, .form-select:disabled { background-color: var(--theme-muted); color: #526d65; }
    .form-control:focus, .form-select:focus { border-color: #78c4b5; box-shadow: 0 0 0 3px #159f8518; background-color: #fff; }
    .form-check-input:checked { background-color: var(--theme-green); border-color: var(--theme-green); }
    .form-label { font-weight: 600; margin-bottom: 4px; }
    :focus-visible { outline: 2px solid var(--theme-green); outline-offset: 3px; }

    .shell { gap: 0; padding: 0; min-height: 100vh; align-items: flex-start; }
    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        z-index: 1020;
        width: 240px;
        height: 100vh;
        height: 100dvh;
        margin: 0;
        display: flex;
        flex-direction: column;
        overflow: hidden;
        padding: 0;
        background: white;
        border-radius: 0;
    }
    .sidebar-brand { display: flex; align-items: center; gap: 10px; flex: none; padding: 18px 14px; border-bottom: 1px solid var(--theme-line); }
    .sidebar-brand .brand-logo { width: 36px; height: 44px; object-fit: contain; flex: none; background: white; }
    .sidebar-brand > div { min-width: 0; }
    .sidebar-brand h1 { margin: 0; color: var(--theme-green); font-size: 15px; font-weight: 700; line-height: 1.1; }
    .sidebar-brand p { margin: 0; color: var(--muted); font-size: 11px; line-height: 1.2; }
    .sidebar-scroll { flex: 1; min-height: 0; overflow-y: auto; overflow-x: hidden; overscroll-behavior-y: contain; scrollbar-width: thin; scrollbar-color: #c8ded8 transparent; scrollbar-gutter: stable; padding: 16px 10px 12px 12px; }
    .sidebar-scroll:focus-visible { outline-offset: -3px; }
    .sidebar-account { display: grid; grid-template-columns: minmax(0, 1fr) 30px; grid-template-rows: auto auto; column-gap: 8px; row-gap: 2px; align-items: center; flex: none; padding: 10px 12px; border-top: 1px solid var(--theme-line); }
    .sidebar-account-row { display: contents; }
    .sidebar-account-name { grid-column: 1; grid-row: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink); font-size: 14px; font-weight: 600; line-height: 19px; }
    .sidebar-account form { grid-column: 2; grid-row: 1 / 3; }
    .sidebar-account .sidebar-signout { display: grid; place-items: center; width: 30px; height: 30px; padding: 0; border: 0; color: var(--theme-green-dark); font-size: 16px; }
    .sidebar-label { color: var(--muted); padding: 4px 12px 8px; font-size: 11px; }
    .sidebar a { color: #4d5952; border-radius: var(--radius-md); font-size: 13px; padding: 6px 10px; margin: 3px 0; gap: 10px; }
    .sidebar-scroll > a { font-size: 13px; font-weight: 600; }
    .sidebar a:hover { background: #eef8f5; color: var(--theme-green-dark); transform: none; }
    .sidebar a.active { background: var(--theme-green); color: white; transform: none; }
    .nav-icon { border-radius: var(--radius-md); background: var(--theme-tint); color: inherit; width: 30px; height: 30px; }
    .sidebar a.active .nav-icon { background: #ffffff24; }
    .sidebar-group { background: transparent; color: #36463c; border-radius: var(--radius-md); padding: 8px 10px; font-size: 13px; font-weight: 600; margin: 2px 0; }
    .sidebar-group:hover, .sidebar-group[aria-expanded="true"] { background: var(--theme-tint); color: var(--theme-green-dark); }
    .sidebar-submenu { margin: 2px 0 8px 12px; padding-left: 8px; border-left: 1px solid var(--theme-line); }
    .sidebar-submenu a { font-size: 12px; padding: 6px 10px; }
    .sidebar-date { grid-column: 1; grid-row: 2; display: flex; flex-wrap: nowrap; gap: 4px; min-width: 0; margin: 0; padding: 0; border: 0; border-radius: 0; background: none; }
    .sidebar-date-text { white-space: nowrap; color: var(--muted); font-size: 12px; font-weight: 400; line-height: 17px; }
    .sidebar-date-text + .sidebar-date-text::before { content: "·"; margin-right: 4px; }
    .main { margin-left: 240px; padding: 24px; }
    .wrap { max-width: 1440px; }
    .panel, .stat-card, .card { border: 1px solid #fff; border-radius: var(--radius-lg); background: white; box-shadow: var(--shadow-panel); }
    .panel { padding: 26px; }
    .panel-title { color: var(--ink); font-size: 20px; font-weight: 600; border-color: #eef0ec; }
    .stat-card { border-left: 0; padding: 24px; }
    .stat-label { color: var(--muted); font-size: 13px; }
    .stat-number { color: var(--ink); font-size: 36px; font-weight: 500; margin-top: 14px; font-variant-numeric: tabular-nums; }
    .dashboard-stats > div:first-child .stat-card { background: var(--theme-green); border-color: var(--theme-green); }
    .dashboard-stats > div:first-child .stat-label { color: #d5f3ec; }
    .dashboard-stats > div:first-child .stat-number { color: #fff; }
    .table { --bs-table-striped-bg: var(--theme-field); --bs-table-hover-bg: var(--theme-tint); --bs-table-color: var(--ink); font-size: 13px; }
    .table thead th { background: white; color: var(--muted); font-weight: 500; font-size: 12px; border-bottom: 1px solid var(--theme-line); padding: 15px 12px; }
    .table tbody td { padding: 14px 12px; border-color: #f0f2ee; vertical-align: middle; }
    .badge { border-radius: var(--radius-md); font-weight: 500; padding: 7px 11px; }
    .receipt-preview-head { background: var(--theme-green); box-shadow: none; }
    .user-stat, .user-form-card { background: white; border-color: var(--theme-line); border-radius: var(--radius-lg); box-shadow: var(--shadow-panel); }
    .user-avatar, .role-admin, .role-user, .receipt-preview-total, .program-help { background: var(--theme-tint); color: var(--theme-green-dark); border-color: #cce9e2; }
    .receipt-preview { background: white; box-shadow: var(--shadow-panel); border-color: var(--theme-line); border-radius: var(--radius-lg); }
    .modal-content { border: 0; border-radius: var(--radius-lg); }

    /* Carry the same palette through authentication and the household portal. */
    .login-card { border-radius: var(--radius-lg); border: 1px solid white; box-shadow: 0 18px 60px #263c2f0a; }
    .brand { color: var(--theme-green); }
    .login-visual { border-radius: var(--radius-lg); }
    .user-role, .user-status, .badge { border-radius: var(--radius-sm); }
    .user-avatar, .brand-mark, .program-help, .receipt-preview-total { border-radius: var(--radius-md); }
    .brand-mark { color: var(--theme-green); background: var(--theme-tint); }
    .card > .brand { background: transparent; }
    .visual-shade { background: linear-gradient(145deg, #0c7664c9, #103f3730); }
    .top { margin: 18px; border-radius: var(--radius-lg); background: var(--theme-green); }
    .today { border-radius: var(--radius-lg); }

    @media (max-width: 1000px) {
        .main { padding: 18px; }
    }
    @media (max-width: 700px) {
        .shell { display: block; padding: 0; }
        .sidebar { position: relative; top: auto; width: 100%; height: min(560px, 100vh); height: min(560px, 100dvh); border-radius: 0; padding: 0; margin: 0; }
        .sidebar-brand { padding: 16px 18px; }
        .main { margin-left: 0; padding: 16px 10px; }
        .panel { padding: 18px; border-radius: var(--radius-lg); }
        .stat-card { padding: 20px; }
    }
}

/* Dashboard charts use native SVG/CSS, without an additional chart library. */
.dashboard-chart-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; margin-bottom: 22px; }
.dashboard-chart-heading h2 { margin: 0 0 8px; font-size: 20px; font-weight: 600; color: var(--ink); }
.dashboard-chart-heading p, .dashboard-chart-footnote { margin: 0; color: var(--muted); font-size: 14px; }
.dashboard-period-total { text-align: right; flex: none; }
.dashboard-period-total strong { display: block; color: var(--theme-green); font-size: 26px; font-weight: 600; }
.dashboard-period-total span { color: var(--muted); font-size: 14px; }
.dashboard-chart-legend { display: flex; gap: 20px; margin-bottom: 12px; color: var(--muted); font-size: 14px; }
.dashboard-chart-legend span, .dashboard-mix-row > span { display: inline-flex; align-items: center; gap: 8px; }
.chart-dot { display: inline-block; width: 10px; height: 10px; border-radius: 3px; flex: none; }
.chart-local { fill: #159f85; background: #159f85; }
.chart-gulf { fill: #a2dacf; background: #a2dacf; }
.registration-chart { display: block; width: 100%; min-width: 560px; height: auto; }
.dashboard-chart-scroll { overflow-x: auto; }
.chart-gridline { stroke: #e6eae5; stroke-dasharray: 4 5; }
.chart-axis { fill: #526a62; font-size: 16px; }
.chart-value { fill: #19231f; font-size: 14px; font-weight: 600; }
.registration-bar:hover rect { opacity: .8; }
.dashboard-chart-empty { color: var(--muted); text-align: center; font-size: 14px; }
.dashboard-chart-data { margin-top: 14px; font-size: 14px; color: var(--muted); }
.dashboard-chart-data summary { cursor: pointer; color: var(--theme-green); }
.membership-donut { width: 190px; aspect-ratio: 1; margin: 16px auto 30px; border-radius: 50%; display: grid; place-items: center; background: conic-gradient(#159f85 0 var(--local-share), #a2dacf var(--local-share) 100%); }
.membership-donut.is-empty { background: var(--theme-muted, #e1f3ee); }
.membership-donut > div { width: 144px; aspect-ratio: 1; border-radius: 50%; background: white; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.membership-donut strong { font-size: 32px; font-weight: 600; letter-spacing: -.035em; }
.membership-donut span { font-size: 14px; color: var(--muted); }
.dashboard-mix-row { display: flex; justify-content: space-between; align-items: center; gap: 14px; padding: 14px 0; border-top: 1px solid var(--theme-line); font-size: 14px; }
.dashboard-mix-row strong { white-space: nowrap; }
.dashboard-mix-row small { font-size: 13px; color: var(--muted); margin-left: 8px; font-weight: 400; }
.dashboard-insight-label { display: block; font-size: 14px; color: var(--muted); }
.dashboard-insight-cards strong { display: block; font-size: 28px; font-weight: 600; margin: 12px 0; color: var(--theme-green); }
.dashboard-insight-cards .dashboard-insight-month { font-size: 22px; }
.dashboard-insight-cards p { margin: 0; font-size: 14px; line-height: 1.7; color: var(--muted); }
@media (max-width: 700px) { .dashboard-chart-heading { flex-wrap: wrap; } .dashboard-period-total { text-align: left; } }

.dashboard-stats .stat-card { padding: 14px 20px; }
.dashboard-stats .stat-number { margin-top: 4px; font-size: 32px; line-height: 1.2; }
.dashboard-stat-heading { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.dashboard-stats .stat-label { font-size: 14px; font-weight: 500; }
.dashboard-stat-icon { display: grid; place-items: center; flex: none; width: 30px; height: 30px; border-radius: var(--radius-md); background: var(--theme-tint); color: var(--theme-green-dark); font-size: 18px; }
.dashboard-stats > div:first-child .dashboard-stat-icon { background: rgb(255 255 255 / 18%); color: white; }

/* New member entry: two groups with consistent label/input rows. */
.member-form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 32px; }
.member-form-group { min-width: 0; margin: 0; padding: 0; border: 0; }
.member-form-group legend { float: none; width: auto; margin: 0 0 20px; color: var(--theme-green-dark); font-size: 14px; font-weight: 600; }
.member-form-field { display: grid; grid-template-columns: 130px minmax(0, 1fr); align-items: start; gap: 12px; margin-bottom: 14px; }
.member-form-field .form-label { margin: 0; padding-top: 11px; line-height: 1.5; }
.member-form-field > .form-control, .member-form-field > .form-select, .member-form-control { min-width: 0; }
.member-form-control .form-text { margin-top: 6px; font-size: 12px; line-height: 1.6; }
@media (max-width: 1199px) { .member-form-grid { grid-template-columns: 1fr; gap: 24px; } }
@media (max-width: 479px) {
    .member-form-field { grid-template-columns: 1fr; gap: 4px; }
    .member-form-field .form-label { padding-top: 0; }
}

/* SweetAlert2 confirmations follow the shared typography and button styles. */
.swal2-popup.app-confirm-dialog { font-family: var(--app-font-family); border-radius: var(--radius-lg); color: var(--ink); padding-bottom: 24px; }
.app-confirm-dialog .swal2-title { font-size: 22px; font-weight: 600; }
.app-confirm-dialog .swal2-html-container { font-size: 14px; line-height: 1.6; }
.app-confirm-dialog .app-confirm-actions { gap: 10px; }
