/* ==========================================================================
   Samaj Platform — premium theme layer on top of Bootstrap 5.3
   Per-tenant colours are injected as CSS variables in base.html (:root),
   so this file never hard-codes a brand colour — it only references the vars.
   ========================================================================== */

:root {
    --sp-primary:        #7b1113;
    --sp-primary-rgb:    123, 17, 19;
    --sp-accent:         #e8a33d;
    --sp-accent-rgb:     232, 163, 61;
    --sp-radius:         14px;
    --sp-radius-sm:      10px;
    --sp-shadow:         0 10px 30px rgba(0, 0, 0, .08);
    --sp-shadow-lg:      0 24px 60px rgba(0, 0, 0, .14);
    --sp-header-h:       72px;
}

/* Map our brand vars onto Bootstrap's theme variables so buttons/links inherit */
:root,
[data-bs-theme="light"] {
    --bs-primary:        var(--sp-primary);
    --bs-primary-rgb:    var(--sp-primary-rgb);
    --bs-link-color:     var(--sp-primary);
    --bs-link-color-rgb: var(--sp-primary-rgb);
    --bs-link-hover-color: var(--sp-accent);
    --sp-surface:        #ffffff;
    --sp-surface-2:      #faf7f2;
    --sp-border:         rgba(0, 0, 0, .07);
    --sp-text-muted:     #6b6256;
}

[data-bs-theme="dark"] {
    --bs-body-bg:        #14110f;
    --bs-body-color:     #e9e2d6;
    --sp-surface:        #1d1916;
    --sp-surface-2:      #221d19;
    --sp-border:         rgba(255, 255, 255, .08);
    --sp-text-muted:     #b3a995;
    --sp-shadow:         0 10px 30px rgba(0, 0, 0, .5);
    --sp-shadow-lg:      0 24px 60px rgba(0, 0, 0, .6);
}

body {
    font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3, .display-1, .display-2, .display-3, .display-4, .navbar-brand {
    font-family: "Playfair Display", Georgia, "Times New Roman", serif;
    letter-spacing: -.01em;
}

.btn-primary {
    --bs-btn-bg: var(--sp-primary);
    --bs-btn-border-color: var(--sp-primary);
    --bs-btn-hover-bg: color-mix(in srgb, var(--sp-primary) 86%, #000);
    --bs-btn-hover-border-color: color-mix(in srgb, var(--sp-primary) 86%, #000);
    --bs-btn-active-bg: color-mix(in srgb, var(--sp-primary) 78%, #000);
}
.btn-accent {
    --bs-btn-color: #1a1206;
    --bs-btn-bg: var(--sp-accent);
    --bs-btn-border-color: var(--sp-accent);
    --bs-btn-hover-color: #1a1206;
    --bs-btn-hover-bg: color-mix(in srgb, var(--sp-accent) 88%, #000);
    --bs-btn-hover-border-color: color-mix(in srgb, var(--sp-accent) 88%, #000);
    font-weight: 600;
}
.btn-outline-light-accent {
    color: #fff; border: 1.5px solid rgba(255, 255, 255, .6);
}
.btn-outline-light-accent:hover { background: #fff; color: var(--sp-primary); }
.text-accent { color: var(--sp-accent) !important; }
.bg-primary-soft { background: rgba(var(--sp-primary-rgb), .07); }
.bg-accent-soft  { background: rgba(var(--sp-accent-rgb), .12); }

a { text-decoration: none; }

/* ---------- Navbar ---------------------------------------------------------*/
.sp-navbar {
    background: var(--sp-surface);
    border-bottom: 1px solid var(--sp-border);
    min-height: var(--sp-header-h);
    /* Truly fixed bar — never moves on scroll. */
    position: fixed;
    top: 0; left: 0; right: 0; width: 100%;
    z-index: 1030;
    /* Promote to its own GPU layer so it never judders/repaints during scroll. */
    transform: translateZ(0);
    will-change: transform;
    backface-visibility: hidden;
    box-shadow: 0 1px 0 var(--sp-border);   /* constant — no toggle = no repaint jump */
    /* Fill the notch/status-bar area with the bar's background, but keep the
       logo + buttons BELOW the notch (iPhone safe area). (#3) */
    padding-top: env(safe-area-inset-top);
    padding-left: env(safe-area-inset-left);
    padding-right: env(safe-area-inset-right);
}
/* Offset page content so it isn't hidden under the fixed bar (incl. the notch). */
body { padding-top: calc(var(--sp-header-h) + env(safe-area-inset-top)); }
/* Anchor jumps (#about, #events…) land below the fixed bar, not under it. */
html { scroll-padding-top: calc(var(--sp-header-h) + env(safe-area-inset-top) + 8px); }
.sp-navbar.is-stuck { box-shadow: var(--sp-shadow); }
/* Brand: nudged toward the left edge, logo vertically centred, never spilling. */
.sp-navbar .navbar-brand {
    font-weight: 700; color: var(--sp-primary); font-size: 1.2rem;
    display: flex; align-items: center; gap: .5rem; padding: 0; margin: 0;
    line-height: 1;
}
.sp-navbar .navbar-brand img {
    height: 38px; width: auto; max-height: calc(var(--sp-header-h) - 22px);
    object-fit: contain; display: block;
}
/* Smaller, tidier right-side controls (language / theme / account). */
.sp-navbar .btn { padding: .22rem .5rem; font-size: .74rem; }
.sp-navbar .btn .bi { font-size: .85rem; }
.sp-navbar .theme-toggle { width: 32px; height: 32px; }
.sp-navbar .theme-toggle .bi { font-size: .9rem; }
.sp-navbar .dropdown-menu { font-size: .85rem; }
/* Snappier dropdowns (#10): the fixed/translateZ navbar made menus repaint slowly.
   Promote the menu to its own layer + a tiny, GPU-friendly open animation so it
   feels instant instead of laggy. */
.dropdown-menu {
    box-shadow: 0 6px 20px rgba(0,0,0,.10);
    border-color: var(--sp-border);
}
.dropdown-menu.show {
    will-change: transform, opacity;
    transform: translateZ(0);
    animation: spDropIn .1s ease-out;
}
@keyframes spDropIn {
    from { opacity: .35; transform: translate3d(0, -4px, 0); }
    to   { opacity: 1;   transform: translate3d(0, 0, 0); }
}
.sp-navbar .navbar-brand + * { gap: .4rem; }
.sp-navbar .nav-link { font-weight: 500; color: var(--bs-body-color); position: relative; }
.sp-navbar .nav-link:hover,
.sp-navbar .nav-link.active { color: var(--sp-primary); }
.sp-navbar .nav-link.active::after {
    content: ""; position: absolute; left: .75rem; right: .75rem; bottom: 2px;
    height: 2px; background: var(--sp-accent); border-radius: 2px;
}
.theme-toggle {
    width: 40px; height: 40px; border-radius: 50%;
    display: inline-flex; align-items: center; justify-content: center;
    border: 1px solid var(--sp-border); background: var(--sp-surface-2);
    color: var(--bs-body-color); cursor: pointer;
}
/* In light mode the toggle washed out against the white navbar — give it a
   clear dark border + icon so it stays visible and accessible (#2). */
[data-bs-theme="light"] .theme-toggle {
    border: 1.5px solid #1f2937;        /* dark, high-contrast outline */
    color: #1f2937;
    background: #fff;
}
[data-bs-theme="light"] .theme-toggle:hover {
    background: #1f2937; color: #fff;
}
[data-bs-theme="light"] .theme-toggle .bi-sun-fill,
[data-bs-theme="dark"]  .theme-toggle .bi-moon-stars-fill { display: none; }

/* Checkboxes (esp. the directory "tick to print" boxes) washed out against white
   in light mode / on phones — give them a clearly visible dark border (#4).
   Scoped to "not dark" (incl. the default, attribute-less light state) so it also
   applies on mobile where the theme attribute may be unset. */
html:not([data-bs-theme="dark"]) .form-check-input,
html:not([data-bs-theme="dark"]) input[type="checkbox"].form-check-input {
    border: 1.5px solid #475569;
    background-color: #fff;
}
/* Bootstrap draws the checkmark as a hardcoded white SVG, so a checked box filled
   with the raw per-community --sp-primary washes the tick out whenever that brand
   color is light (auto-extracted from a logo, or set light by an admin). Mixing in
   black guarantees the fill is always dark enough for the white tick to read. */
html:not([data-bs-theme="dark"]) .form-check-input:checked {
    background-color: color-mix(in srgb, var(--sp-primary) 55%, #111827 45%) !important;
    border-color: color-mix(in srgb, var(--sp-primary) 55%, #111827 45%) !important;
}
/* The directory / split select boxes get an always-visible border (any theme) and
   a slightly larger tap target for phones. */
.sp-pick, #sp-pick-all, .sp-split-pick {
    width: 1.15rem; height: 1.15rem;
    border: 1.5px solid #64748b !important;
}
.sp-pick:checked, #sp-pick-all:checked, .sp-split-pick:checked {
    background-color: color-mix(in srgb, var(--sp-primary) 55%, #111827 45%) !important;
    border-color: color-mix(in srgb, var(--sp-primary) 55%, #111827 45%) !important;
}

/* ---------- Hero -----------------------------------------------------------*/
.sp-hero {
    position: relative; color: #fff; overflow: hidden;
    background: linear-gradient(115deg,
        color-mix(in srgb, var(--sp-primary) 92%, #000) 0%,
        var(--sp-primary) 55%,
        color-mix(in srgb, var(--sp-primary) 70%, var(--sp-accent)) 100%);
}
.sp-hero__bg {
    position: absolute; inset: 0; object-fit: cover; width: 100%; height: 100%;
    opacity: .18; mix-blend-mode: luminosity;
}
.sp-hero__inner { position: relative; padding: clamp(3.5rem, 8vw, 7rem) 0; }
.sp-hero h1 { font-size: clamp(2.2rem, 5vw, 3.6rem); line-height: 1.05; }
.sp-hero .lead { color: rgba(255, 255, 255, .9); max-width: 38rem; }
.sp-hero__badge {
    display: inline-flex; align-items: center; gap: .5rem; font-weight: 600;
    font-size: .8rem; letter-spacing: .08em; text-transform: uppercase;
    background: rgba(255, 255, 255, .14); padding: .4rem .9rem; border-radius: 100px;
}

/* ---------- Sections + cards ----------------------------------------------*/
.sp-section { padding: clamp(2.25rem, 4vw, 3.75rem) 0; }

/* Tighter desktop density (#6): content cards / KPI boxes were oversized on wide
   screens. Cap their inner padding and trim KPI height so layouts feel compact. */
@media (min-width: 992px) {
    .sp-card.p-lg-5, .sp-card.p-5 { padding: 1.75rem !important; }
    .sp-card.p-4 { padding: 1.25rem !important; }
    .sp-kpi { padding: .9rem 1.1rem; }
    .sp-kpi__value { font-size: 1.5rem; }
    .sp-kpi__icon { width: 40px; height: 40px; font-size: 1.1rem; }
    .sp-portal .sp-content { padding-top: 1.25rem; padding-bottom: 1.25rem; }
}
.sp-section--alt { background: var(--sp-surface-2); }
.sp-eyebrow {
    color: var(--sp-accent); font-weight: 700; letter-spacing: .12em;
    text-transform: uppercase; font-size: .78rem;
}
.sp-section-title { font-weight: 700; }
.sp-divider { width: 64px; height: 4px; border-radius: 4px; background: var(--sp-accent); }

.sp-card {
    background: var(--sp-surface); border: 1px solid var(--sp-border);
    border-radius: var(--sp-radius); box-shadow: var(--sp-shadow);
    overflow: hidden; height: 100%; transition: transform .22s ease, box-shadow .22s ease;
}
.sp-card:hover { transform: translateY(-4px); box-shadow: var(--sp-shadow-lg); }
.sp-card__img { aspect-ratio: 16 / 10; object-fit: cover; width: 100%; }
.sp-card__img--square { aspect-ratio: 1 / 1; }

.sp-stat { text-align: center; }
.sp-stat__num {
    font-family: "Playfair Display", Georgia, serif; font-weight: 800;
    font-size: clamp(2rem, 4vw, 3rem); color: var(--sp-primary); line-height: 1;
}
[data-bs-theme="dark"] .sp-stat__num { color: var(--sp-accent); }

/* ===== Public landing polish (#8) ===== */
.sp-hero--landing {
    background:
        radial-gradient(1200px 500px at 110% -10%, color-mix(in srgb, var(--sp-accent) 38%, transparent) 0%, transparent 60%),
        linear-gradient(125deg,
            color-mix(in srgb, var(--sp-primary) 95%, #000) 0%,
            var(--sp-primary) 48%,
            color-mix(in srgb, var(--sp-primary) 62%, var(--sp-accent)) 100%);
    position: relative;
}
.sp-hero--landing::after {
    content: ""; position: absolute; inset: 0; pointer-events: none;
    background-image: radial-gradient(rgba(255,255,255,.07) 1px, transparent 1px);
    background-size: 22px 22px; opacity: .5;
}
.sp-hero--landing .sp-hero__inner { position: relative; z-index: 1; }
.sp-hero--landing h1 { font-family: "Playfair Display", Georgia, serif; letter-spacing: .01em; }
.sp-card--public { border: 1px solid var(--sp-border); }
.sp-card--public:hover {
    border-color: color-mix(in srgb, var(--sp-accent) 60%, transparent);
    box-shadow: 0 14px 34px rgba(123, 17, 19, .14);
}
/* Stat cards a touch richer on the public site */
.sp-section--alt .sp-stat .sp-icon-badge {
    width: 56px; height: 56px; border-radius: 16px;
    display: inline-flex; align-items: center; justify-content: center;
    font-size: 1.5rem; color: #fff;
    background: linear-gradient(135deg, var(--sp-primary), color-mix(in srgb, var(--sp-primary) 60%, var(--sp-accent)));
}
.sp-stat__label { color: var(--sp-text-muted); font-weight: 600; letter-spacing: .02em; }
.sp-stat__label { color: var(--sp-text-muted); font-weight: 500; margin-top: .35rem; }

.sp-icon-badge {
    width: 56px; height: 56px; border-radius: 16px; display: inline-flex;
    align-items: center; justify-content: center; font-size: 1.5rem;
    background: rgba(var(--sp-primary-rgb), .1); color: var(--sp-primary);
}

/* progress (donation campaigns) */
.sp-progress { height: 10px; border-radius: 100px; background: rgba(var(--sp-primary-rgb), .12); }
.sp-progress > span { display: block; height: 100%; border-radius: 100px;
    background: linear-gradient(90deg, var(--sp-primary), var(--sp-accent)); }

/* avatar + committee */
.sp-avatar { width: 96px; height: 96px; border-radius: 50%; object-fit: cover;
    border: 3px solid var(--sp-surface); box-shadow: var(--sp-shadow); }
.sp-avatar--sm { width: 44px; height: 44px; }

/* gallery */
.sp-gallery img { border-radius: var(--sp-radius-sm); cursor: pointer; aspect-ratio: 1/1;
    object-fit: cover; width: 100%; transition: filter .2s ease; }
.sp-gallery img:hover { filter: brightness(1.05) saturate(1.1); }

/* sponsor logos */
.sp-sponsor {
    display: flex; align-items: center; justify-content: center; padding: 1.25rem;
    background: var(--sp-surface); border: 1px solid var(--sp-border);
    border-radius: var(--sp-radius-sm); height: 110px;
}
.sp-sponsor img { max-height: 64px; max-width: 100%; object-fit: contain;
    filter: grayscale(1); opacity: .75; transition: all .2s ease; }
.sp-sponsor:hover img { filter: none; opacity: 1; }

/* CTA band */
.sp-cta { position: relative; color: #fff; border-radius: var(--sp-radius); overflow: hidden;
    background: var(--sp-primary); }
.sp-cta__bg { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; opacity: .25; }
.sp-cta__inner { position: relative; padding: clamp(2.5rem, 5vw, 4rem); }

/* ---------- Footer ---------------------------------------------------------*/
.sp-footer { background: #17120f; color: #cdc4b5; padding-top: 2.5rem; }
.sp-footer img { height: 40px; width: auto; }
@media (max-width: 575.98px) {
    .sp-footer { padding-top: 1.5rem; font-size: .92rem; }
    .sp-footer .row.g-4 { --bs-gutter-y: .9rem; }
    .sp-footer h6 { margin-bottom: .5rem !important; }
    .sp-footer .col-lg-4:first-child p { margin-bottom: .75rem !important; }
    .sp-footer__bottom { text-align: center; }
}
[data-bs-theme="light"] .sp-footer { background: #1c1714; }
.sp-footer a { color: #cdc4b5; }
.sp-footer a:hover { color: var(--sp-accent); }
.sp-footer h6 { color: #fff; font-weight: 700; letter-spacing: .03em; }
.sp-footer__bottom { border-top: 1px solid rgba(255, 255, 255, .08); }
.sp-social { width: 38px; height: 38px; border-radius: 50%; display: inline-flex;
    align-items: center; justify-content: center; background: rgba(255, 255, 255, .08); }
.sp-social:hover { background: var(--sp-accent); color: #1a1206 !important; }

/* ---------- Portal (logged-in) --------------------------------------------*/
.sp-portal { display: flex; min-height: calc(100vh - var(--sp-header-h)); }
.sp-sidebar {
    width: 264px; flex: 0 0 264px; background: var(--sp-surface); padding: 1.25rem .9rem;
    border-right: 1px solid var(--sp-border);
}
.sp-sidebar .nav-link {
    color: var(--bs-body-color); border-radius: 10px; padding: .6rem .85rem;
    font-weight: 500; display: flex; align-items: center; gap: .7rem;
}
.sp-sidebar .nav-link .bi { font-size: 1.1rem; color: var(--sp-text-muted); }
.sp-sidebar .nav-link:hover { background: var(--sp-surface-2); }
.sp-sidebar .nav-link.active { background: rgba(var(--sp-primary-rgb), .1); color: var(--sp-primary); }
.sp-sidebar .nav-link.active .bi { color: var(--sp-primary); }
.sp-sidebar__heading { font-size: .72rem; text-transform: uppercase; letter-spacing: .1em;
    color: var(--sp-text-muted); font-weight: 700; padding: .5rem .85rem; margin-top: .5rem; }
.sp-content { flex: 1 1 auto; padding: clamp(1.25rem, 3vw, 2.25rem); background: var(--bs-body-bg); }

.sp-kpi { background: var(--sp-surface); border: 1px solid var(--sp-border);
    border-radius: var(--sp-radius); padding: 1.25rem 1.4rem; box-shadow: var(--sp-shadow); }
.sp-kpi__icon { width: 48px; height: 48px; border-radius: 12px; display: inline-flex;
    align-items: center; justify-content: center; font-size: 1.3rem; }
.sp-kpi__value { font-size: 1.8rem; font-weight: 800; line-height: 1; }

@media (max-width: 991.98px) {
    .sp-portal { flex-direction: column; }
    .sp-sidebar { width: 100%; flex-basis: auto; border-right: 0; border-bottom: 1px solid var(--sp-border); }
}

/* AOS fallback: never let content stay invisible if JS fails */
.no-js [data-aos] { opacity: 1 !important; transform: none !important; }

/* ---------- Mobile-first refinements (app-ready) --------------------------*/
html { -webkit-text-size-adjust: 100%; }
img { max-width: 100%; height: auto; }
/* respect iOS safe-area (notch) when installed as a PWA */
.sp-navbar { padding-left: env(safe-area-inset-left); padding-right: env(safe-area-inset-right); }
.sp-footer { padding-bottom: calc(1rem + env(safe-area-inset-bottom)); }

@media (max-width: 575.98px) {
    .sp-navbar .navbar-brand { font-size: 1.05rem; }
    .sp-navbar .navbar-brand img { height: 36px; }
    .sp-navbar .navbar-brand span { max-width: 60vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    .sp-hero h1 { font-size: 2rem; }
    .sp-hero .lead { font-size: 1rem; }
    /* comfortable, thumb-friendly tap targets */
    .btn { min-height: 44px; display: inline-flex; align-items: center; justify-content: center; }
    .sp-navbar .nav-link { padding-top: .6rem; padding-bottom: .6rem; }
    .sp-stat__num { font-size: 1.9rem; }
    .sp-kpi__value { font-size: 1.45rem; }
    /* committee avatars + (often long) Gujarati names */
    .sp-avatar { width: 76px; height: 76px; }
    .sp-section { padding-top: 2.5rem; padding-bottom: 2.5rem; }
}

/* mobile nav panel: give the collapsed menu breathing room + a surface */
@media (max-width: 991.98px) {
    .sp-navbar .navbar-collapse {
        background: var(--sp-surface); border-radius: var(--sp-radius-sm);
        margin-top: .5rem; padding: .75rem; box-shadow: var(--sp-shadow);
    }
    .sp-navbar .nav-link.active::after { display: none; }
}

/* ---------- Mobile bottom tab bar (native-app feel) ---------------------- */
.sp-tabbar { display: none; }
@media (max-width: 991.98px) {
    .sp-tabbar {
        display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 1040;
        background: var(--sp-surface); border-top: 1px solid var(--sp-border);
        padding: .35rem .25rem calc(.35rem + env(safe-area-inset-bottom));
        box-shadow: 0 -6px 24px rgba(0,0,0,.08);
    }
    .sp-tabbar a {
        flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px;
        font-size: .66rem; color: var(--sp-text-muted); text-decoration: none; padding: .25rem 0;
        position: relative;
    }
    .sp-tabbar a .bi { font-size: 1.25rem; }
    .sp-tabbar a.active { color: var(--sp-primary); }
    [data-bs-theme="dark"] .sp-tabbar a.active { color: var(--sp-accent); }
    .sp-tabbar a .sp-tab-badge {
        position: absolute; top: 0; right: 28%; min-width: 16px; height: 16px;
        font-size: .6rem; line-height: 16px; border-radius: 8px; background: #dc3545;
        color: #fff; padding: 0 4px;
    }
    /* keep content clear of the bar + the portal sidebar collapses anyway */
    .sp-content { padding-bottom: 5rem !important; }
    body.has-tabbar { padding-bottom: 0; }
    /* On mobile, hide the long sidebar in favour of the tab bar */
    .sp-portal .sp-sidebar { display: none; }
}

/* ---------- PWA install banner ------------------------------------------- */
#sp-install {
    position: fixed; left: 1rem; right: 1rem; bottom: 5.5rem; z-index: 1050;
    display: none; align-items: center; gap: .75rem;
    background: var(--sp-surface); border: 1px solid var(--sp-border);
    border-radius: var(--sp-radius); box-shadow: var(--sp-shadow-lg); padding: .75rem 1rem;
}
@media (min-width: 992px) { #sp-install { left: auto; right: 1.5rem; bottom: 1.5rem; max-width: 360px; } }

/* nicer scrollbars + tap feedback on touch */
@media (hover: none) { .sp-card:active { transform: scale(.995); } }

/* ===== Advertisement slots (#14) =================================== */
.sp-ad-tag { position: absolute; top: 4px; left: 6px; font-size: .58rem; line-height: 1;
    letter-spacing: .04em; text-transform: uppercase; color: #fff; background: rgba(0,0,0,.45);
    padding: 2px 5px; border-radius: 4px; pointer-events: none; }

/* bottom-right popup */
.sp-ad-popup { position: fixed; right: 1rem; bottom: 1rem; z-index: 1080; width: min(320px, 86vw);
    background: var(--bs-body-bg, #fff); border: 1px solid rgba(0,0,0,.12); border-radius: 14px;
    box-shadow: 0 12px 40px rgba(0,0,0,.22); overflow: hidden; transform: translateY(16px);
    opacity: 0; transition: opacity .25s ease, transform .25s ease; }
.sp-ad-popup.is-in { transform: translateY(0); opacity: 1; }
.sp-ad-popup img { display: block; width: 100%; height: auto; }
.sp-ad-popup__txt { padding: 2rem 1rem; text-align: center; font-weight: 600; }
.sp-ad-popup__close { position: absolute; top: 6px; right: 8px; z-index: 2; width: 26px; height: 26px;
    border: 0; border-radius: 50%; background: rgba(0,0,0,.55); color: #fff; font-size: 1.1rem;
    line-height: 1; cursor: pointer; display: flex; align-items: center; justify-content: center; }

/* side rails (xxl only) */
.sp-ad-rail { position: fixed; top: 50%; transform: translateY(-50%); z-index: 1010; width: 160px; }
.sp-ad-rail--left  { left: 12px; }
.sp-ad-rail--right { right: 12px; }
.sp-ad-box { position: relative; display: block; border: 1px solid rgba(0,0,0,.10); border-radius: 12px;
    overflow: hidden; background: var(--bs-tertiary-bg, #f6f3ee); box-shadow: 0 6px 18px rgba(0,0,0,.10); }
.sp-ad-box img { display: block; width: 100%; height: auto; }
.sp-ad-box__txt { display: flex; align-items: center; justify-content: center; min-height: 320px;
    padding: 1rem; text-align: center; font-weight: 600; }

/* footer strip */
.sp-ad-footer { position: relative; display: flex; align-items: center; justify-content: center;
    gap: .75rem; padding: .55rem 1rem; background: var(--sp-accent); color: #1a1a1a;
    text-decoration: none; font-weight: 600; }
.sp-ad-footer img { height: 28px; width: auto; border-radius: 4px; }
.sp-ad-footer .sp-ad-tag { background: rgba(0,0,0,.3); }

/* ===== Responsive polish (PC / tablet / mobile) =================== */
/* Hard-stop horizontal scroll on every viewport. The navbar is position:fixed,
   and overflow:clip does NOT create a scroll container, so the fixed navbar and
   the sticky sidebar are unaffected — stray-wide content just can't push the
   page sideways on a phone. */
html, body { overflow-x: clip; max-width: 100%; }
img, video, iframe, table { max-width: 100%; }
main.container, .sp-section, .sp-hero, .sp-content { overflow-x: clip; }
/* let *text* containers in flex rows shrink (prevents overflow) without
   squishing buttons/inputs — applied narrowly, NOT to every element. */
.flex-grow-1, .text-truncate, .sp-card .list-group-item > span { min-width: 0; }

/* ----- Phone (<576px) ----- */
@media (max-width: 575.98px) {
    .table-responsive { -webkit-overflow-scrolling: touch; }
    .table { font-size: .9rem; }
    h1, .h1, h1.h3 { font-size: 1.35rem; }
    h2, .h2 { font-size: 1.2rem; }
    .nav-pills { flex-wrap: wrap; gap: .35rem; }
    .nav-pills .nav-link { padding: .4rem .7rem; font-size: .85rem; }

    /* comfortable tap targets everywhere */
    .btn, .form-control, .form-select { min-height: 44px; }
    .btn-sm, .form-control-sm, .form-select-sm { min-height: 38px; }

    /* primary / large actions go full-width so they're easy to tap */
    .btn-lg { width: 100%; }
    form .btn-primary:not(.btn-sm):not(.w-auto) { width: 100%; }

    /* button groups (Print/Filter/Families etc.) wrap instead of overflowing */
    .btn-group { flex-wrap: wrap; }

    /* tighter, even card spacing */
    .card-body { padding: .9rem 1rem; }
    .sp-card.p-4, .sp-card.p-3 { padding: 1rem !important; }
    .container, main.container { padding-left: 14px; padding-right: 14px; }

    /* filter grids: avoid cramped 2-up selects — stack to full width */
    form .row.g-2 > [class*="col-"],
    form .row.g-3 > [class*="col-"] { flex: 0 0 100%; max-width: 100%; }
    /* keep the min/max number pairs side-by-side inside their input-group */
    form .row .input-group { flex-wrap: nowrap; }
}

/* ----- Small tablet ----- */
@media (min-width: 576px) and (max-width: 767.98px) {
    .btn-lg { font-size: .95rem; }
}

/* tablet: keep multi-column forms readable */
@media (min-width: 576px) and (max-width: 991.98px) {
    .sp-content { padding: 1.25rem; }
}

/* leave room for the mobile bottom tab bar so content isn't hidden */
@media (max-width: 991.98px) {
    body { padding-bottom: 64px; }
    .sp-ad-popup { bottom: 72px; }   /* sit above the tab bar */
}

/* respect reduced-motion + safe-area (notches) for app-readiness */
@supports (padding: max(0px)) {
    .sp-tabbar { padding-bottom: max(.25rem, env(safe-area-inset-bottom)); }
}

/* ===== Minimal / newbie-friendly layer (#8) =======================
   Calmer typography, lighter cards, tighter spacing. Loaded last so it
   wins the cascade without touching the rules above. */
:root {
    --sp-radius:    10px;
    --sp-radius-sm: 8px;
    --sp-shadow:    0 1px 2px rgba(16,24,40,.06), 0 1px 3px rgba(16,24,40,.05);
    --sp-shadow-lg: 0 4px 14px rgba(16,24,40,.08);
}
body { font-size: 15px; line-height: 1.6; }

/* one clean, nominal typeface everywhere — drop the decorative serif headings */
h1, h2, h3, h4, h5, h6,
.sp-section-title, .sp-cta__title, .display-4, .display-5, .display-6 {
    font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif !important;
    font-weight: 600 !important;
    letter-spacing: -0.01em;
}
h1, .h1 { font-size: 1.75rem; }
h2, .h2 { font-size: 1.4rem; }
h3, .h3 { font-size: 1.2rem; }

/* flatter, lighter cards — no heavy boxes, no big hover lift */
.sp-card, .card { box-shadow: var(--sp-shadow); border: 1px solid rgba(16,24,40,.08); }
.card { border-radius: var(--sp-radius); }
.sp-card:hover { transform: none; box-shadow: var(--sp-shadow-lg); }
.shadow-sm { box-shadow: var(--sp-shadow) !important; }
.card-header { border-bottom: 1px solid rgba(16,24,40,.06); }

/* calmer spacing */
.sp-hero__inner { padding: clamp(2.25rem, 5vw, 4rem) 0; }
.sp-section { padding: clamp(2rem, 4vw, 3.5rem) 0; }
.card-body { padding: 1.1rem 1.25rem; }

/* softer buttons & badges */
.btn { border-radius: 8px; font-weight: 500; }
.btn-lg { font-size: 1rem; padding: .6rem 1.1rem; }
.badge { font-weight: 500; }

/* gentler default text colour for readability */
body { color: #1f2733; }
[data-bs-theme="dark"] body { color: #e6e8ec; }

/* ===== Collapsible sidebar groups (fit 22 items via arrow dropdowns) ===== */
@media (min-width: 992px) {
    .sp-sidebar {                      /* keep the sidebar on-screen + scrollable */
        position: sticky; top: var(--sp-header-h); align-self: flex-start;
        max-height: calc(100vh - var(--sp-header-h)); overflow-y: auto;
    }
}
.sp-sidebar__group {
    display: flex; align-items: center; gap: .7rem; width: 100%;
    border: 0; background: transparent; text-align: left; cursor: pointer;
    color: var(--sp-text-muted); font-weight: 700; font-size: .72rem;
    text-transform: uppercase; letter-spacing: .08em;
    padding: .6rem .85rem; margin-top: .35rem; border-radius: 10px;
}
.sp-sidebar__group:hover { background: var(--sp-surface-2); color: var(--bs-body-color); }
.sp-sidebar__group > .bi:first-child { font-size: 1rem; }
.sp-sidebar__group .sp-chevron { margin-left: auto; font-size: .85rem; transition: transform .2s ease; }
.sp-sidebar__group.collapsed .sp-chevron { transform: rotate(-90deg); }
.sp-sidebar .collapse .nav-link,
.sp-sidebar .collapsing .nav-link { padding-left: 1.1rem; }   /* slight indent under a group */

/* Uppercase data entry for directory forms (#2) — visual; values are also
   uppercased on save. Excludes email/url/password/date/number inputs. */
.sp-upper input[type="text"],
.sp-upper textarea { text-transform: uppercase; }
.sp-upper input[type="text"]::placeholder,
.sp-upper textarea::placeholder { text-transform: none; }

/* ===== Sidebar hide/show toggle (#7) ============================== */
.sp-sidebar-toggle {
    position: fixed; top: calc(var(--sp-header-h) + 10px); left: 10px; z-index: 1031;
    width: 38px; height: 38px; border-radius: 9px; cursor: pointer;
    border: 1px solid var(--sp-border); background: var(--sp-surface);
    color: var(--bs-body-color); display: none; align-items: center;
    justify-content: center; font-size: 1.2rem; box-shadow: var(--sp-shadow);
}
.sp-sidebar-toggle:hover { background: var(--sp-surface-2); }
/* hidden state: collapse the sidebar, content reclaims the width */
.sp-portal.sidebar-hidden .sp-sidebar { display: none; }
@media (min-width: 992px) {
    .sp-sidebar-toggle { display: inline-flex; }   /* always available on desktop */
    /* clear the floating toggle so it doesn't cover the first menu item */
    .sp-portal:not(.sidebar-hidden) .sp-sidebar { padding-top: 3rem; }
}

/* ===== Dashboard event calendar (#9) ============================= */
.sp-cal { width: 100%; border-collapse: collapse; table-layout: fixed; }
.sp-cal th { font-size: .68rem; font-weight: 600; color: var(--sp-text-muted);
    text-align: center; padding: .25rem 0; }
.sp-cal td { text-align: center; padding: .2rem 0; font-size: .82rem; position: relative;
    height: 30px; vertical-align: middle; }
.sp-cal td a { color: inherit; display: block; font-weight: 600; }
.sp-cal__out { color: var(--sp-text-muted); opacity: .35; }
.sp-cal__today { background: rgba(var(--sp-primary-rgb), .1); border-radius: 7px;
    color: var(--sp-primary); font-weight: 700; }
.sp-cal__has a { color: var(--sp-primary); }
.sp-cal__dot { display: inline-block; width: 6px; height: 6px; border-radius: 50%;
    background: var(--sp-primary); vertical-align: middle; margin-left: 1px; }
.sp-cal__dot--trip { background: var(--sp-accent); }
.sp-cal td .sp-cal__dot { position: absolute; bottom: 2px; left: 50%; transform: translateX(-50%); margin: 0; }

/* KPI cards: tighter on phones so values don't clip (#10) */
@media (max-width: 575.98px) {
    .sp-kpi { padding: .75rem .85rem; gap: .55rem; }
    .sp-kpi__icon { width: 38px; height: 38px; font-size: 1.1rem; border-radius: 10px; }
    .sp-kpi__value { font-size: 1.3rem; }
}

/* ===== Mobile nav: hamburger + drawer (#6) ======================= */
.sp-burger {
    border: 1px solid var(--sp-border); background: var(--sp-surface);
    color: var(--bs-body-color); width: 38px; height: 38px; border-radius: 9px;
    font-size: 1.25rem; display: inline-flex; align-items: center;
    justify-content: center; cursor: pointer; margin-right: .15rem;
}
.sp-burger:hover { background: var(--sp-surface-2); }
.sp-offcanvas { width: 290px; max-width: 86vw; }
.sp-offcanvas .offcanvas-body { padding-top: .25rem; }
.sp-offcanvas .nav-link {
    display: flex; align-items: center; gap: .7rem; padding: .6rem .85rem;
    border-radius: 10px; color: var(--bs-body-color); font-weight: 500;
}
.sp-offcanvas .nav-link:hover,
.sp-offcanvas .nav-link.active { background: var(--sp-surface-2); }
.sp-offcanvas .nav-link .bi { font-size: 1.1rem; color: var(--sp-text-muted); width: 1.2rem; text-align: center; }
.sp-offcanvas .sp-sidebar__heading { margin-top: .6rem; }

/* Navbar Back / Home buttons */
.sp-navbtn {
    border: 1px solid var(--sp-border); background: var(--sp-surface);
    color: var(--bs-body-color); width: 36px; height: 36px; border-radius: 9px;
    font-size: 1.05rem; display: inline-flex; align-items: center;
    justify-content: center; cursor: pointer; text-decoration: none; flex: 0 0 auto;
}
.sp-navbtn:hover { background: var(--sp-surface-2); color: var(--sp-primary); }
