/* =====================================================================
   Goobsan UI – Bootstrap 5.3 theme layer.
   Brand colours come from Settings and are injected as CSS variables
   (--gb-primary, --gb-accent, --gb-sidebar) by _Theme.cshtml.
   ===================================================================== */
:root {
    --gb-radius: .85rem;
    --gb-shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 1px 3px rgba(16, 24, 40, .08);
    --gb-shadow-lg: 0 10px 30px rgba(16, 24, 40, .12);
    --gb-sidebar-w: 260px;
    --bs-body-font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    --bs-body-font-size: .925rem;
}

[data-bs-theme="light"] { --bs-body-bg: #f4f6f8; --gb-card: #fff; --gb-muted-bg: #f8fafc; --gb-topbar-bg: rgba(244, 246, 248, .85); }
[data-bs-theme="dark"]  { --bs-body-bg: #0f1720; --gb-card: #16212c; --gb-muted-bg: #1b2834; --gb-topbar-bg: rgba(15, 23, 32, .85); }

/* brand overrides of Bootstrap components */
.btn-primary {
    --bs-btn-bg: var(--gb-primary); --bs-btn-border-color: var(--gb-primary);
    --bs-btn-hover-bg: var(--gb-primary-dark); --bs-btn-hover-border-color: var(--gb-primary-dark);
    --bs-btn-active-bg: var(--gb-primary-dark); --bs-btn-active-border-color: var(--gb-primary-dark);
    --bs-btn-disabled-bg: var(--gb-primary); --bs-btn-disabled-border-color: var(--gb-primary);
}
.btn-outline-primary {
    --bs-btn-color: var(--gb-primary); --bs-btn-border-color: var(--gb-primary);
    --bs-btn-hover-bg: var(--gb-primary); --bs-btn-hover-border-color: var(--gb-primary);
    --bs-btn-active-bg: var(--gb-primary-dark); --bs-btn-active-border-color: var(--gb-primary-dark);
}
.text-brand { color: var(--gb-primary) !important; }
.bg-brand { background: var(--gb-primary) !important; color: #fff; }
.bg-brand-soft { background: var(--gb-primary-soft) !important; }
.text-accent { color: var(--gb-accent) !important; }
a { color: var(--gb-primary); }
.form-control:focus, .form-select:focus { border-color: var(--gb-primary); box-shadow: 0 0 0 .2rem var(--gb-primary-soft); }
.form-check-input:checked { background-color: var(--gb-primary); border-color: var(--gb-primary); }
.nav-pills .nav-link.active { background: var(--gb-primary); }
.page-link { color: var(--gb-primary); }
.active > .page-link, .page-link.active { background: var(--gb-primary); border-color: var(--gb-primary); }

/* ---------------------------------------------------------- layout */
.gb-sidebar {
    position: fixed; inset: 0 auto 0 0; width: var(--gb-sidebar-w); z-index: 1040;
    background: var(--gb-sidebar); color: rgba(255,255,255,.8);
    display: flex; flex-direction: column; transition: transform .25s ease;
}
.gb-brand { display: flex; align-items: center; gap: .75rem; padding: 1.1rem 1.25rem; color: #fff; text-decoration: none; }
.gb-brand:hover { color: #fff; }
.gb-logo {
    width: 40px; height: 40px; border-radius: .7rem; flex: 0 0 40px; display: grid; place-items: center;
    background: linear-gradient(135deg, var(--gb-primary), var(--gb-accent)); color: #fff; font-weight: 800; letter-spacing: .5px;
    overflow: hidden;
}
.gb-logo img { width: 100%; height: 100%; object-fit: contain; background: #fff; }
.gb-brand-name { font-weight: 700; font-size: 1.1rem; line-height: 1.1; }
.gb-brand-tag { font-size: .72rem; opacity: .65; }
.gb-nav { padding: .5rem .75rem 1rem; overflow-y: auto; flex: 1; }
.gb-nav-title { font-size: .68rem; text-transform: uppercase; letter-spacing: .08em; opacity: .5; padding: 1rem .75rem .35rem; }
.gb-nav a {
    display: flex; align-items: center; gap: .7rem; padding: .55rem .75rem; border-radius: .6rem;
    color: rgba(255,255,255,.78); text-decoration: none; font-weight: 500; margin-bottom: 2px;
}
.gb-nav a i { font-size: 1.05rem; width: 1.2rem; text-align: center; }
.gb-nav a:hover { background: rgba(255,255,255,.08); color: #fff; }
.gb-nav a.active { background: var(--gb-primary); color: #fff; box-shadow: 0 4px 14px rgba(0,0,0,.2); }
.gb-nav .badge { margin-left: auto; }
.gb-sidebar-foot { padding: .9rem 1.25rem; font-size: .75rem; opacity: .55; border-top: 1px solid rgba(255,255,255,.08); }

.gb-main { margin-left: var(--gb-sidebar-w); min-height: 100vh; display: flex; flex-direction: column; }
.gb-topbar {
    position: sticky; top: 0; z-index: 1030; background: var(--gb-topbar-bg);
    backdrop-filter: blur(8px); border-bottom: 1px solid var(--bs-border-color-translucent);
    display: flex; align-items: center; gap: .75rem; padding: .7rem 1.5rem;
}
.gb-content { padding: 1.5rem; flex: 1; }
.gb-footer { padding: 1rem 1.5rem; font-size: .8rem; color: var(--bs-secondary-color); }
.gb-avatar {
    width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: .85rem;
    background: var(--gb-primary-soft); color: var(--gb-primary);
}
.gb-backdrop { display: none; }

@media (max-width: 991.98px) {
    .gb-sidebar { transform: translateX(-100%); }
    .gb-sidebar.show { transform: none; box-shadow: var(--gb-shadow-lg); }
    .gb-main { margin-left: 0; }
    .gb-backdrop.show { display: block; position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 1035; }
    .gb-content { padding: 1rem; }
}

/* ---------------------------------------------------------- cards & tiles */
.card { border: 1px solid var(--bs-border-color-translucent); border-radius: var(--gb-radius); box-shadow: var(--gb-shadow); background: var(--gb-card); }
.card-header { background: transparent; border-bottom: 1px solid var(--bs-border-color-translucent); padding: .9rem 1.1rem; font-weight: 600; }
.card-header:first-child { border-radius: var(--gb-radius) var(--gb-radius) 0 0; }
.page-head { display: flex; flex-wrap: wrap; align-items: center; gap: .75rem; justify-content: space-between; margin-bottom: 1.25rem; }
.page-head h1 { font-size: 1.45rem; font-weight: 700; margin: 0; }
.page-head .sub { color: var(--bs-secondary-color); font-size: .875rem; }

.kpi { position: relative; padding: 1.1rem 1.2rem; height: 100%; overflow: hidden; }
.kpi .kpi-label { font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; color: var(--bs-secondary-color); font-weight: 600; }
.kpi .kpi-value { font-size: 1.6rem; font-weight: 750; line-height: 1.2; margin: .25rem 0; }
.kpi .kpi-sub { font-size: .8rem; color: var(--bs-secondary-color); }
.kpi .kpi-icon {
    position: absolute; right: 1rem; top: 1rem; width: 44px; height: 44px; border-radius: .75rem;
    display: grid; place-items: center; font-size: 1.3rem; background: var(--gb-primary-soft); color: var(--gb-primary);
}
.kpi.kpi-accent .kpi-icon { background: var(--gb-accent-soft, rgba(245, 158, 11, .18)); color: var(--gb-accent); }
.kpi.kpi-danger .kpi-icon { background: rgba(220,53,69,.12); color: #dc3545; }
.kpi.kpi-info .kpi-icon { background: rgba(13,110,253,.12); color: #0d6efd; }
.kpi.kpi-success .kpi-icon { background: rgba(25,135,84,.12); color: #198754; }

.health { border-radius: var(--gb-radius); padding: 1.1rem 1.2rem; color: #fff; height: 100%; }
.health.HEALTHY { background: linear-gradient(135deg, #15803d, #22c55e); }
.health.WATCH { background: linear-gradient(135deg, #b45309, #f59e0b); }
.health.DEFICIT { background: linear-gradient(135deg, #991b1b, #ef4444); }
.health .h-value { font-size: 1.6rem; font-weight: 800; letter-spacing: .04em; }

.stat-list .d-flex { padding: .45rem 0; border-bottom: 1px dashed var(--bs-border-color-translucent); }
.stat-list .d-flex:last-child { border-bottom: 0; }

.alert-line { display: flex; gap: .6rem; padding: .55rem .2rem; border-bottom: 1px dashed var(--bs-border-color-translucent); font-size: .875rem; }
.alert-line:last-child { border-bottom: 0; }

.progress-thin { height: .5rem; border-radius: 1rem; }
.progress-bar.bg-brand { background: var(--gb-primary) !important; }

/* ---------------------------------------------------------- tables */
.table { --bs-table-bg: transparent; margin-bottom: 0; }
.table > :not(caption) > * > * { padding: .6rem .75rem; vertical-align: middle; }
.table thead th { font-size: .72rem; text-transform: uppercase; letter-spacing: .05em; color: var(--bs-secondary-color); font-weight: 600; white-space: nowrap; background: var(--gb-muted-bg); }
.table-hover > tbody > tr:hover > * { --bs-table-bg-state: var(--gb-primary-soft); }
.money { font-variant-numeric: tabular-nums; white-space: nowrap; text-align: right; }
.nowrap { white-space: nowrap; }
div.dt-container .dt-search input { border-radius: .5rem; }
div.dt-container { font-size: .875rem; }

/* contributions grid (Excel look) */
.grid-wrap { overflow: auto; max-height: calc(100vh - 260px); }
.contrib-grid { border-collapse: separate; border-spacing: 0; font-size: .8rem; }
.contrib-grid th, .contrib-grid td { border-bottom: 1px solid var(--bs-border-color-translucent); padding: .4rem .5rem; white-space: nowrap; }
.contrib-grid thead th { position: sticky; top: 0; z-index: 2; background: var(--gb-muted-bg); text-align: center; }
.contrib-grid .sticky-col { position: sticky; left: 0; z-index: 1; background: var(--gb-card); min-width: 230px; box-shadow: 1px 0 0 var(--bs-border-color-translucent); }
.contrib-grid thead .sticky-col { z-index: 3; background: var(--gb-muted-bg); }
.contrib-grid tfoot td { position: sticky; bottom: 0; background: var(--gb-muted-bg); font-weight: 700; }
.cell { min-width: 62px; text-align: center; border-radius: .4rem; font-weight: 600; cursor: default; }
.cell[data-pay] { cursor: pointer; }
.cell[data-pay]:hover { outline: 2px solid var(--gb-primary); }
.cell.Paid { background: rgba(34,197,94,.16); color: #15803d; }
.cell.Partial, .cell.AdvancePartial { background: rgba(245,158,11,.2); color: #b45309; }
.cell.Unpaid { background: rgba(239,68,68,.15); color: #b91c1c; }
.cell.Advance { background: rgba(59,130,246,.15); color: #1d4ed8; }
.cell.Future { color: var(--bs-secondary-color); }
.cell.NotDue, .cell.AfterExit { background: repeating-linear-gradient(45deg, transparent, transparent 4px, rgba(127,127,127,.08) 4px, rgba(127,127,127,.08) 8px); color: var(--bs-secondary-color); }
.legend-dot { display: inline-block; width: .8rem; height: .8rem; border-radius: .25rem; vertical-align: -1px; margin-right: .3rem; }
th.current-month, td.current-month { box-shadow: inset 0 -3px 0 var(--gb-accent); }

/* month calendar (statement / portal) */
.month-cal { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: .5rem; }
.month-cal .mc { border-radius: .6rem; padding: .5rem .6rem; font-size: .78rem; border: 1px solid var(--bs-border-color-translucent); }
.month-cal .mc .m { font-weight: 700; }
.month-cal .mc.Paid { background: rgba(34,197,94,.12); border-color: rgba(34,197,94,.35); }
.month-cal .mc.Unpaid { background: rgba(239,68,68,.1); border-color: rgba(239,68,68,.35); }
.month-cal .mc.Partial, .month-cal .mc.AdvancePartial { background: rgba(245,158,11,.13); border-color: rgba(245,158,11,.4); }
.month-cal .mc.Advance { background: rgba(59,130,246,.1); border-color: rgba(59,130,246,.35); }
.month-cal .mc.Future, .month-cal .mc.NotDue, .month-cal .mc.AfterExit { opacity: .6; }

/* ---------------------------------------------------------- auth pages */
.auth-wrap { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; }
.auth-hero {
    background: radial-gradient(circle at 20% 20%, var(--gb-accent-glow, rgba(245, 158, 11, .35)), transparent 40%),
                linear-gradient(140deg, var(--gb-sidebar), var(--gb-primary));
    color: #fff; padding: 3rem; display: flex; flex-direction: column; justify-content: space-between; position: relative; overflow: hidden;
}
.auth-hero::after { content: ""; position: absolute; right: -120px; bottom: -120px; width: 380px; height: 380px; border-radius: 50%; border: 60px solid rgba(255,255,255,.06); }
.auth-hero h1 { font-weight: 800; font-size: 2.4rem; }
.auth-hero .feature { display: flex; gap: .8rem; align-items: flex-start; margin-bottom: 1rem; opacity: .92; }
.auth-hero .feature i { font-size: 1.3rem; }
.auth-panel { display: grid; place-items: center; padding: 2rem; }
.auth-card { width: 100%; max-width: 410px; }
@media (max-width: 991.98px) { .auth-wrap { grid-template-columns: 1fr; } .auth-hero { display: none; } }

/* ---------------------------------------------------------- portal */
.portal-nav { background: var(--gb-sidebar); }
.portal-nav .navbar-brand, .portal-nav .nav-link { color: rgba(255,255,255,.85); }
.portal-nav .nav-link.active, .portal-nav .nav-link:hover { color: #fff; }
.portal-nav .nav-link.active { box-shadow: inset 0 -3px 0 var(--gb-accent); }
.portal-hero {
    background: linear-gradient(135deg, var(--gb-primary), var(--gb-primary-deep, var(--gb-sidebar)));
    color: #fff; border-radius: var(--gb-radius); padding: 1.5rem; position: relative; overflow: hidden;
}
.portal-hero::after { content: ""; position: absolute; right: -60px; top: -60px; width: 220px; height: 220px; border-radius: 50%; background: rgba(255,255,255,.08); }
.eligibility { border-radius: .7rem; padding: .8rem 1rem; display: flex; gap: .75rem; align-items: center; }
.eligibility.yes { background: rgba(34,197,94,.14); color: #166534; }
.eligibility.no { background: rgba(245,158,11,.16); color: #92400e; }
[data-bs-theme="dark"] .eligibility.yes { color: #86efac; }
[data-bs-theme="dark"] .eligibility.no { color: #fcd34d; }

/* ---------------------------------------------------------- misc */
.select2-container { width: 100% !important; }
.select2-container--bootstrap-5 .select2-selection { border-radius: var(--bs-border-radius); }
.toast-container { z-index: 1090; }
.empty { text-align: center; padding: 2.5rem 1rem; color: var(--bs-secondary-color); }
.empty i { font-size: 2.2rem; display: block; margin-bottom: .5rem; opacity: .5; }
.tree ul { list-style: none; padding-left: 1.4rem; border-left: 1px dashed var(--bs-border-color); margin-left: .6rem; }
.tree > ul { border-left: 0; padding-left: 0; margin-left: 0; }
.tree li { margin: .3rem 0; }
.tree .node { display: inline-flex; align-items: center; gap: .5rem; padding: .35rem .6rem; border-radius: .5rem; background: var(--gb-muted-bg); }
.tree .node .actions { opacity: .2; transition: opacity .15s; }
.tree .node:hover .actions { opacity: 1; }
.swatch { width: 2.5rem; height: 2.4rem; padding: .2rem; }
.temp-password { font-family: ui-monospace, Consolas, monospace; font-size: 1.3rem; letter-spacing: .08em; }

/* ---------------------------------------------------------- print */
@media print {
    .gb-sidebar, .gb-topbar, .gb-footer, .no-print, .portal-nav, .btn, .dt-search, .dt-length, .dt-paging { display: none !important; }
    .gb-main { margin: 0 !important; }
    .gb-content { padding: 0 !important; }
    body { background: #fff !important; font-size: 11pt; }
    .card { box-shadow: none !important; border: 1px solid #ccc !important; break-inside: avoid; }
    a { color: inherit; text-decoration: none; }
}
.validation-summary-valid.empty-hide { display: none; }
a { text-decoration: none; }
a:hover { text-decoration: underline; }
.btn:hover, .nav-link:hover, .dropdown-item:hover, .gb-nav a:hover, .navbar-brand:hover, .gb-brand:hover { text-decoration: none; }


/* ---------------------------------------------------------- sidebar scrollbar (follows the theme colours)
   --gb-scroll-thumb / --gb-scroll-track are calculated from Settings › Appearance in _Theme.cshtml */
.gb-nav { scrollbar-gutter: stable; }

/* Chrome, Edge, Opera, Safari */
.gb-nav::-webkit-scrollbar { width: 8px; }
.gb-nav::-webkit-scrollbar-track { background: transparent; border-radius: 8px; margin: 6px 0; }
.gb-nav:hover::-webkit-scrollbar-track { background: var(--gb-scroll-track, rgba(255, 255, 255, .12)); }
.gb-nav::-webkit-scrollbar-thumb { background: var(--gb-scroll-thumb, var(--gb-primary)); border-radius: 8px; border: 2px solid var(--gb-sidebar); }
.gb-nav::-webkit-scrollbar-thumb:hover,
.gb-nav::-webkit-scrollbar-thumb:active { background: var(--gb-primary); }
.gb-nav::-webkit-scrollbar-button { display: none; height: 0; }

/* Firefox – only where ::-webkit-scrollbar is unknown (in Chrome/Edge these would replace the rounded style above) */
@supports not selector(::-webkit-scrollbar) {
    .gb-nav { scrollbar-width: thin; scrollbar-color: var(--gb-scroll-thumb, var(--gb-primary)) transparent; }
    .gb-nav:hover { scrollbar-color: var(--gb-primary) var(--gb-scroll-track, rgba(255, 255, 255, .12)); }
}

/* =====================================================================
   RESPONSIVE – phones (≥320px), tablets and desktops
   ===================================================================== */
html { -webkit-text-size-adjust: 100%; }
body { overflow-x: hidden; }
.chart-box { position: relative; height: 320px; }
.chart-box.chart-sm { height: 190px; }
.chart-box.chart-md { height: 260px; }

/* mobile top bar brand (sidebar is hidden on small screens) */
.gb-topbar-brand { display: none; align-items: center; gap: .55rem; color: inherit; text-decoration: none; font-weight: 700; min-width: 0; }
.gb-topbar-brand .gb-logo { width: 32px; height: 32px; flex: 0 0 32px; font-size: .75rem; border-radius: .55rem; }
.gb-topbar-brand span.name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.gb-sidebar-close { display: none; }

/* bottom app bar (phones & tablets) */
.gb-bottomnav {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 1032; display: none;
    background: var(--gb-card); border-top: 1px solid var(--bs-border-color-translucent);
    box-shadow: 0 -4px 18px rgba(16, 24, 40, .08);
    padding: .25rem .25rem calc(.25rem + env(safe-area-inset-bottom));
}
.gb-bottomnav .bn-inner { display: flex; align-items: stretch; justify-content: space-around; max-width: 640px; margin: 0 auto; }
.gb-bottomnav a, .gb-bottomnav button.bn-item {
    flex: 1 1 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
    padding: .35rem .1rem; border: 0; background: none; color: var(--bs-secondary-color); text-decoration: none;
    font-size: .68rem; font-weight: 600; position: relative; min-height: 52px; border-radius: .75rem;
}
.gb-bottomnav a i, .gb-bottomnav button.bn-item i { font-size: 1.3rem; line-height: 1; }
.gb-bottomnav a.active { color: var(--gb-primary); }
.gb-bottomnav a.active::before { content: ""; position: absolute; top: -.25rem; width: 28px; height: 3px; border-radius: 3px; background: var(--gb-primary); }
.gb-bottomnav .bn-badge { position: absolute; top: .2rem; left: calc(50% + 6px); font-size: .6rem; }
.gb-bottomnav .bn-fab {
    flex: 0 0 auto; width: 54px; height: 54px; margin: -22px .35rem 0; border-radius: 50%; border: 4px solid var(--bs-body-bg);
    background: linear-gradient(135deg, var(--gb-primary), var(--gb-primary-dark)); color: #fff; display: grid; place-items: center;
    font-size: 1.5rem; box-shadow: 0 6px 16px rgba(0,0,0,.2);
}

/* install-app button is shown only when the browser offers installation */
[data-install-app] { display: none !important; }
body.can-install [data-install-app] { display: inline-flex !important; }

/* ---------------------------------------------------------- < 992px : tablets & phones */
@media (max-width: 991.98px) {
    .gb-topbar { padding: .55rem .9rem; padding-top: calc(.55rem + env(safe-area-inset-top)); }
    .gb-topbar-brand { display: flex; }
    .gb-sidebar { width: min(86vw, 300px); padding-top: env(safe-area-inset-top); }
    .gb-sidebar-close { display: inline-flex; }
    .gb-bottomnav { display: block; }
    .gb-main { padding-bottom: calc(64px + env(safe-area-inset-bottom)); }
    .gb-footer { padding-bottom: 1.25rem; }
    body.gb-noscroll { overflow: hidden; }
    .portal-main { padding-bottom: calc(80px + env(safe-area-inset-bottom)) !important; }
    .portal-footer { padding-bottom: calc(80px + env(safe-area-inset-bottom)) !important; }
    .chart-box { height: 260px; }
}

/* ---------------------------------------------------------- < 768px : phones */
@media (max-width: 767.98px) {
    .gb-content { padding: .85rem .75rem 1rem; }
    .page-head { flex-direction: column; align-items: stretch; gap: .6rem; margin-bottom: .9rem; }
    .page-head h1 { font-size: 1.2rem; }
    .page-head .sub { font-size: .8rem; }
    .page-head > div:last-child { flex-wrap: wrap; }
    .page-head form { flex-wrap: wrap; flex: 1 1 100%; }
    .page-head form > input, .page-head form > .form-control, .page-head form > select { flex: 1 1 140px; width: auto; }
    .page-head form > .btn { flex: 0 0 auto; }
    .page-head > .d-flex > .btn, .page-head > .btn { flex: 1 1 auto; }

    .card-header { padding: .75rem .85rem; }
    .card-body { padding: .85rem; }
    .kpi { padding: .8rem .85rem; }
    .kpi .kpi-label { font-size: .64rem; padding-right: 2.2rem; }
    .kpi .kpi-value { font-size: 1.15rem; }
    .kpi .kpi-sub { font-size: .72rem; }
    .kpi .kpi-icon { width: 32px; height: 32px; font-size: 1rem; right: .7rem; top: .7rem; border-radius: .55rem; }
    .health { padding: .8rem .85rem; }
    .health .h-value { font-size: 1.2rem; }
    .chart-box { height: 230px; }
    .chart-box.chart-sm { height: 170px; }

    /* scrollable pill tabs instead of many wrapped rows */
    .nav-scroll { flex-wrap: nowrap !important; overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none; padding-bottom: 2px; }
    .nav-scroll::-webkit-scrollbar { display: none; }
    .nav-scroll .nav-link { white-space: nowrap; padding: .4rem .75rem; font-size: .85rem; }

    /* tables: list rows become cards (labels come from the header, see goobsan.js) */
    table.table-stack thead { display: none; }
    table.table-stack, table.table-stack > tbody, table.table-stack > tbody > tr, table.table-stack > tbody > tr > td,
    table.table-stack > tfoot, table.table-stack > tfoot > tr, table.table-stack > tfoot > tr > td { display: block; width: 100% !important; }
    table.table-stack > tbody > tr {
        border: 1px solid var(--bs-border-color-translucent); border-radius: .75rem; margin: 0 0 .6rem; padding: .45rem .8rem;
        background: var(--gb-card); box-shadow: var(--gb-shadow);
    }
    table.table-stack > tbody > tr > td, table.table-stack > tfoot > tr > td {
        border: 0 !important; padding: .3rem 0 !important; text-align: right; white-space: normal; overflow-wrap: anywhere;
        background: transparent !important; box-shadow: none !important; min-height: 1.9rem;
    }
    table.table-stack > tbody > tr > td::after, table.table-stack > tfoot > tr > td::after { content: ""; display: table; clear: both; }
    table.table-stack > tbody > tr > td::before, table.table-stack > tfoot > tr > td::before {
        content: attr(data-label); float: left; max-width: 45%; margin-right: .75rem; padding-top: .15rem; text-align: left;
        font-size: .68rem; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--bs-secondary-color); overflow-wrap: normal;
    }
    table.table-stack > tbody > tr > td > .dropdown { display: inline-block; }
    table.table-stack > tbody > tr > td[data-label=""]::before, table.table-stack > tfoot > tr > td[data-label=""]::before { display: none; }
    table.table-stack > tbody > tr > td:first-child { font-weight: 600; border-bottom: 1px dashed var(--bs-border-color-translucent) !important; padding-bottom: .4rem !important; margin-bottom: .15rem; }
    table.table-stack > tbody > tr > td[colspan] { text-align: center; }
    table.table-stack > tbody > tr > td[colspan]::before { display: none; }
    table.table-stack > tbody > tr > td:empty { display: none; }
    table.table-stack > tfoot > tr { padding: .4rem .8rem; border-radius: .75rem; background: var(--gb-muted-bg); }
    table.table-stack .money { text-align: right; }
    .table-responsive:has(> table.table-stack), .table-responsive:has(table.table-stack) { overflow: visible; }
    .card:has(> .table-responsive > table.table-stack), .card:has(table.table-stack.dataTable) { background: transparent; border: 0; box-shadow: none; }

    /* DataTables controls stack nicely */
    div.dt-container .row { --bs-gutter-x: 0; row-gap: .5rem; }
    div.dt-container .dt-search, div.dt-container .dt-search input { width: 100% !important; margin-left: 0 !important; }
    div.dt-container .dt-length { display: none; }
    div.dt-container .dt-info { text-align: center; font-size: .78rem; }
    div.dt-container .dt-paging { display: flex; justify-content: center; }

    /* wide financial tables keep horizontal scrolling */
    .table-responsive { -webkit-overflow-scrolling: touch; }
    .table-sm > :not(caption) > * > * { padding: .45rem .5rem; }

    /* contributions grid */
    .grid-wrap { max-height: calc(100vh - 210px); min-height: 360px; }
    .contrib-grid .sticky-col { min-width: 150px; max-width: 150px; white-space: normal; }
    .cell { min-width: 44px; }

    /* month calendar */
    .month-cal { grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: .4rem; }

    /* portal */
    .portal-hero { padding: 1.1rem; }
    .portal-hero h2 { font-size: 1.35rem; }
    .eligibility { align-items: flex-start; }

    .tree ul { padding-left: .9rem; }
    .tree .node { flex-wrap: wrap; }
    .tree .node .actions { opacity: 1; }
    .swatch { width: 3rem; }
}

/* ---------------------------------------------------------- touch devices: bigger targets, no iOS zoom */
@media (hover: none) and (pointer: coarse) {
    .form-control, .form-select, .select2-container--bootstrap-5 .select2-selection, div.dt-container .dt-search input { font-size: 16px; }
    .btn { min-height: 40px; }
    .btn-sm { min-height: 34px; }
    .dropdown-item { padding-top: .6rem; padding-bottom: .6rem; }
    .form-check-input { width: 1.2em; height: 1.2em; }
    .tree .node .actions { opacity: 1; }
}

/* ---------------------------------------------------------- very small phones */
@media (max-width: 374.98px) {
    .gb-topbar-brand span.name { display: none; }
    .kpi .kpi-value { font-size: 1.02rem; }
    .gb-bottomnav a, .gb-bottomnav button.bn-item { font-size: .62rem; }
}

/* ---------------------------------------------------------- large screens */
@media (min-width: 1600px) {
    .gb-content { padding: 2rem 2.5rem; }
    :root { --gb-sidebar-w: 280px; }
}

@media print {
    .gb-bottomnav, .gb-topbar-brand { display: none !important; }
    .gb-main { padding-bottom: 0 !important; }
    .chart-box { height: 260px; }
}
@media (max-width: 767.98px) {
    table.table-stack td > .form-control, table.table-stack td > .form-select { display: inline-block; width: 55%; text-align: left; }
}

/* ---------------------------------------------------------- modals: header & footer stay visible, the body scrolls
   (our modal forms wrap header/body/footer in a <form>, so the form must pass the flex layout through) */
.modal-content > form { display: flex; flex-direction: column; flex: 1 1 auto; min-height: 0; max-height: 100%; }
.modal-content > form > .modal-header, .modal-content > form > .modal-footer { flex-shrink: 0; }
.modal-content > form > .modal-body { flex: 1 1 auto; min-height: 0; }
.modal-dialog-scrollable .modal-content > form > .modal-body,
.modal-fullscreen .modal-content > form > .modal-body { overflow-y: auto; }
.modal-body { -webkit-overflow-scrolling: touch; overscroll-behavior: contain; }
@media (max-width: 575.98px) {
    .modal-fullscreen-sm-down .modal-content > form > .modal-body { overflow-y: auto; }
    .modal-fullscreen-sm-down .modal-footer { padding-bottom: calc(.75rem + env(safe-area-inset-bottom)); }
    .modal-fullscreen-sm-down .modal-header { padding-top: calc(1rem + env(safe-area-inset-top)); }
    .modal-footer { flex-wrap: nowrap; gap: .5rem; }
    .modal-footer > * { margin: 0; }
    .modal-footer .form-check { flex: 1 1 auto; font-size: .8rem; }
}
/* tablets / landscape phones: keep long dialogs inside the screen as well */
@media (min-width: 576px) and (max-width: 991.98px) {
    .modal-dialog.modal-lg, .modal-dialog.modal-xl { max-width: calc(100vw - 2rem); }
}
