:root {
    --brand-navy: #0f2d6b;
    --brand-blue: #1d4ed8;
    --brand-gold: #e5b842;
    --surface-bg: #f4f7fb;
    --sidebar-width: 262px;
    --topbar-height: 58px;
}
html {
    scroll-behavior: smooth;
}
body {
    background-color: var(--surface-bg);
    color: #1e293b;
    min-height: 100vh;
    margin: 0;
    overflow-x: hidden;
}

/* Slim Top Progress Bar for Instant SPA Tab Switches */
#spaProgressBar {
    position: fixed;
    top: 0;
    left: 0;
    height: 3px;
    width: 0;
    background: var(--brand-gold);
    z-index: 2000;
    transition: width 0.25s ease, opacity 0.25s ease;
    opacity: 0;
    pointer-events: none;
}
#spaProgressBar.active {
    opacity: 1;
}

/* Fixed Slim Top Header Bar */
.portal-topbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--topbar-height);
    background: linear-gradient(90deg, var(--brand-navy) 0%, var(--brand-blue) 100%);
    border-bottom: 3px solid var(--brand-gold);
    z-index: 1035;
    display: flex;
    align-items: center;
    padding: 0 1rem;
    box-shadow: 0 2px 10px rgba(15, 45, 107, 0.14);
}
.sidebar-toggle-btn {
    width: 40px;
    height: 38px;
    border: 1px solid rgba(255, 255, 255, 0.35);
    border-radius: 0.45rem;
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    display: inline-flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 5px;
    cursor: pointer;
    transition: background 0.18s ease, border-color 0.18s ease;
}
.sidebar-toggle-btn:hover,
.sidebar-toggle-btn:focus {
    background: rgba(255, 255, 255, 0.22);
    border-color: var(--brand-gold);
    outline: none;
}
.sidebar-toggle-btn span {
    display: block;
    width: 20px;
    height: 2px;
    background: #fff;
    border-radius: 2px;
}

/* Side Navigation Drawer */
.portal-sidebar {
    position: fixed;
    top: var(--topbar-height);
    left: 0;
    bottom: 0;
    width: var(--sidebar-width);
    background: #0b1d45;
    color: #e2e8f0;
    z-index: 1030;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    transform: translateX(calc(-1 * var(--sidebar-width)));
    transition: transform 0.26s cubic-bezier(0.22, 1, 0.36, 1), box-shadow 0.26s ease;
    border-right: 1px solid rgba(255, 255, 255, 0.08);
}
body.sidebar-open .portal-sidebar {
    transform: translateX(0);
    box-shadow: 4px 0 20px rgba(11, 29, 69, 0.2);
}

.sidebar-section-label {
    font-size: 0.68rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #94a3b8;
    padding: 0.85rem 1rem 0.35rem 1rem;
    font-weight: 700;
}
.portal-sidebar .side-nav-link {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.58rem 1rem;
    margin: 0.12rem 0.55rem;
    border-radius: 0.5rem;
    color: #dbeafe;
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
    transition: background 0.16s ease, color 0.16s ease, transform 0.16s ease;
}
.portal-sidebar .side-nav-link:hover {
    background: rgba(255, 255, 255, 0.12);
    color: #ffffff;
}
.portal-sidebar .side-nav-link.active {
    background: var(--brand-blue);
    color: #ffffff;
    font-weight: 600;
    box-shadow: inset 3px 0 0 var(--brand-gold);
}
.portal-sidebar .side-nav-link.dev-link {
    color: #fde68a;
}
.portal-sidebar .side-nav-link.dev-link.active {
    background: #b45309;
    color: #fff;
}

/* Dim Backdrop ONLY used in Overlay Mode (or narrow mobile overlay) */
.portal-sidebar-backdrop {
    position: fixed;
    inset: var(--topbar-height) 0 0 0;
    background: rgba(15, 23, 42, 0.42);
    z-index: 1025;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.22s ease;
}
body.sidebar-open.sidebar-mode-overlay .portal-sidebar-backdrop {
    opacity: 1;
    pointer-events: auto;
}

/* Main Content Shell (Auto-Adjusts Width when sidebar_mode = push so it NEVER covers the page!) */
.portal-shell {
    padding-top: var(--topbar-height);
    min-height: 100vh;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    margin-left: 0;
    transition: margin-left 0.26s cubic-bezier(0.22, 1, 0.36, 1), width 0.26s cubic-bezier(0.22, 1, 0.36, 1);
}
body.sidebar-open.sidebar-mode-push .portal-shell {
    margin-left: var(--sidebar-width);
    width: calc(100% - var(--sidebar-width));
    max-width: calc(100% - var(--sidebar-width));
}
@media (max-width: 991.98px) {
    :root {
        --sidebar-width: 256px;
    }
    /* On tablets & phones (<992px), automatically use Overlay mode so the main content ALWAYS gets 100% full width */
    body.sidebar-open.sidebar-mode-push .portal-shell {
        margin-left: 0 !important;
        width: 100% !important;
        max-width: 100% !important;
    }
    body.sidebar-open.sidebar-mode-push .portal-sidebar-backdrop {
        opacity: 1 !important;
        pointer-events: auto !important;
    }
}

/* CRITICAL MODAL FIX:
   Never put `transform` or `animation-fill-mode: both` with transform on <main>!
   Opacity-only transitions avoid creating a CSS stacking context that traps modals behind .modal-backdrop. */
#mainContent {
    flex: 1 1 auto;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    box-sizing: border-box;
    transition: opacity 0.18s ease;
}
#mainContent.spa-swapping {
    opacity: 0.45;
}

/* Ensure Bootstrap modals ALWAYS sit cleanly above topbar & sidebar */
.modal-backdrop {
    z-index: 1050 !important;
}
.modal {
    z-index: 1055 !important;
}

/* Subtle Executive Scroll Reveal (clears transform after reveal so no stacking traps remain) */
[data-reveal] {
    opacity: 0;
    transform: translateY(14px);
    transition: opacity 0.45s cubic-bezier(0.22, 1, 0.36, 1), transform 0.45s cubic-bezier(0.22, 1, 0.36, 1);
}
[data-reveal].is-visible {
    opacity: 1;
    transform: none;
}
@media (prefers-reduced-motion: reduce) {
    #mainContent, [data-reveal], .portal-sidebar, .portal-shell, body {
        animation: none !important;
        transition: none !important;
        opacity: 1 !important;
        transform: none !important;
    }
}

.hero-banner {
    background: linear-gradient(135deg, var(--brand-navy) 0%, var(--brand-blue) 100%);
    color: #fff;
    border-radius: 1rem;
}
.card {
    border: 1px solid rgba(15, 45, 107, 0.08);
    border-radius: 0.85rem;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.card-hover:hover {
    transform: translateY(-2px);
    box-shadow: 0 0.7rem 1.4rem rgba(15, 45, 107, 0.09) !important;
}
.kpi-card {
    border-left: 4px solid var(--brand-blue);
}
.skip-link {
    position: absolute;
    left: -9999px;
    top: 0;
    background: var(--brand-gold);
    color: #000;
    padding: 0.5rem 1rem;
    z-index: 9999;
}
.skip-link:focus {
    left: 1rem;
    top: 1rem;
}
.site-footer {
    background: var(--brand-navy);
    color: #cbd5e1;
    border-top: 3px solid var(--brand-gold);
}
.site-footer a {
    color: #f8fafc;
    text-decoration: none;
}
.site-footer a:hover {
    text-decoration: underline;
    color: var(--brand-gold);
}
.badge-role {
    text-transform: uppercase;
    letter-spacing: 0.04em;
    font-size: 0.7rem;
}

/* Content Protection Helpers */
body.no-copy-mode {
    -webkit-user-select: none;
    -moz-user-select: none;
    user-select: none;
}
body.no-copy-mode input,
body.no-copy-mode textarea,
body.no-copy-mode select {
    -webkit-user-select: text;
    -moz-user-select: text;
    user-select: text;
}
.protected-media {
    position: relative;
    overflow: hidden;
    border-top-left-radius: 0.85rem;
    border-top-right-radius: 0.85rem;
}
.protected-media img {
    width: 100%;
    height: 190px;
    object-fit: cover;
    pointer-events: none;
    -webkit-user-drag: none;
    user-select: none;
}
.protected-media-shield {
    position: absolute;
    inset: 0;
    z-index: 2;
    background: transparent;
}
.feature-pill {
    background: rgba(255, 255, 255, 0.14);
    border: 1px solid rgba(255, 255, 255, 0.25);
    border-radius: 0.65rem;
    padding: 0.6rem 0.85rem;
}

/* Copied School COR/COG Template Overlay Container */
.template-overlay-sheet {
    position: relative;
    width: 100%;
    max-width: 820px;
    margin: 0 auto;
    background: #fff;
    border: 1px solid #cbd5e1;
}
.template-overlay-sheet .template-bg {
    width: 100%;
    height: auto;
    display: block;
}
.template-qr-badge {
    position: absolute;
    background: rgba(255, 255, 255, 0.96);
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    padding: 5px;
    text-align: center;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
}
.template-seal-strip {
    background: #f8fafc;
    border-top: 2px solid var(--brand-navy);
    padding: 8px 14px;
    font-size: 11px;
}


/* =====================================================================
   v6.0 2-Tier Bicol University-Style Institutional Footer + GOVPH Strip
   ===================================================================== */
.footer-tier1 {
    background: #22262b;
    color: #cbd5e1;
    border-top: 4px solid var(--brand-gold);
}
.footer-tier1 .footer-seal-circle {
    width: 112px;
    height: 112px;
    border-radius: 50%;
    background: #fff;
    padding: 8px;
    object-fit: contain;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
}
.footer-tier1 .footer-links-list {
    list-style: none;
    padding-left: 0;
    margin-bottom: 0;
}
.footer-tier1 .footer-links-list li {
    margin-bottom: 0.32rem;
    font-size: 0.88rem;
}
.footer-tier1 .footer-links-list li::before {
    content: "\2022";
    color: var(--brand-gold);
    font-weight: bold;
    display: inline-block;
    width: 0.9rem;
}
.footer-tier1 a {
    color: #e2e8f0;
    text-decoration: none;
}
.footer-tier1 a:hover {
    color: var(--brand-gold);
    text-decoration: underline;
}
.dpo-seal-card {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    background: #fff;
    color: #0f2d6b;
    border: 3px solid #1d4ed8;
    border-radius: 28px 28px 18px 18px;
    padding: 12px 16px;
    max-width: 155px;
    text-align: center;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.3);
}
.footer-tier2-govph {
    background: #0d0f12;
    color: #94a3b8;
    font-size: 0.8rem;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
}
.footer-tier2-govph h6 {
    color: #f8fafc;
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    margin-bottom: 0.5rem;
}
.footer-tier2-govph a {
    color: #cbd5e1;
    text-decoration: none;
}
.footer-tier2-govph a:hover {
    color: var(--brand-gold);
    text-decoration: underline;
}

/* Floating WCAG Accessibility Toolbar (Bicol University Reference) */
.a11y-fab {
    position: fixed;
    right: 16px;
    bottom: 18px;
    z-index: 1042;
    background: #ea580c;
    color: #fff;
    border: 2px solid #fff;
    border-radius: 50%;
    width: 42px;
    height: 42px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.28);
    cursor: pointer;
}
.a11y-fab:hover { background: #c2410c; transform: scale(1.06); }
.a11y-panel {
    position: fixed;
    right: 16px;
    bottom: 68px;
    width: 240px;
    z-index: 1043;
    background: #fff;
    border: 1px solid #cbd5e1;
    border-radius: 0.75rem;
    box-shadow: 0 8px 28px rgba(15, 23, 42, 0.22);
    padding: 0.75rem;
    display: none;
}
.a11y-panel.open { display: block; }
html.a11y-grayscale { filter: grayscale(100%); }
html.a11y-contrast body { background: #000 !important; color: #ff0 !important; }
html.a11y-contrast .card, html.a11y-contrast .bg-white, html.a11y-contrast .bg-light {
    background: #111 !important; color: #ff0 !important; border-color: #ff0 !important;
}
html.a11y-readable body { font-family: Arial, Helvetica, sans-serif !important; letter-spacing: 0.02em; }

/* PST Clock Pill */
.pst-clock-pill {
    font-size: 0.74rem;
    background: rgba(255, 255, 255, 0.14);
    border: 1px solid rgba(255, 255, 255, 0.22);
    border-radius: 999px;
    padding: 0.18rem 0.65rem;
    color: #f8fafc;
    white-space: nowrap;
}


/* =====================================================================
   v6.2 Flagship University Portal (Bicol University Reference Styling)
   ===================================================================== */
.bu-univ-header {
    background: linear-gradient(90deg, var(--brand-navy) 0%, var(--brand-blue) 100%);
    color: #fff;
    border-bottom: 1px solid rgba(255, 255, 255, 0.15);
}
.bu-univ-navbar {
    background: #ffffff;
    border-bottom: 1px solid #e2e8f0;
    box-shadow: 0 3px 10px rgba(15, 23, 42, 0.06);
}
.bu-univ-navbar .nav-link {
    color: #1e293b;
    font-size: 0.88rem;
    font-weight: 600;
    padding: 0.65rem 0.85rem;
}
.bu-univ-navbar .nav-link:hover,
.bu-univ-navbar .nav-link.active {
    color: var(--brand-blue);
    background: #f1f5f9;
}
.bu-page-banner {
    background: linear-gradient(125deg, rgba(15, 45, 107, 0.94) 0%, rgba(29, 78, 216, 0.88) 100%);
    color: #fff;
    border-radius: 0.9rem;
    padding: 2rem 1.75rem;
    border-left: 6px solid var(--brand-gold);
    box-shadow: 0 6px 20px rgba(15, 45, 107, 0.16);
}
.bu-hero-slide {
    min-height: 360px;
    border-radius: 1rem;
    background-size: cover;
    background-position: center;
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: center;
}
.bu-hero-overlay {
    background: linear-gradient(115deg, rgba(11, 29, 69, 0.92) 0%, rgba(29, 78, 216, 0.78) 65%, rgba(15, 45, 107, 0.86) 100%);
    width: 100%;
    min-height: 360px;
    padding: 2.5rem 2.2rem;
    color: #fff;
    display: flex;
    align-items: center;
}
.bu-quick-tile {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 1.15rem 0.75rem;
    border-radius: 0.85rem;
    color: #fff !important;
    text-decoration: none;
    box-shadow: 0 6px 16px rgba(15, 23, 42, 0.14);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    height: 100%;
}
.bu-quick-tile:hover {
    transform: translateY(-4px);
    box-shadow: 0 10px 24px rgba(15, 23, 42, 0.22);
    color: #fff !important;
}
.bu-quick-tile-icon {
    width: 46px;
    height: 46px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    font-weight: 700;
    margin-bottom: 0.55rem;
}
.bu-blue-tile {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    background: #0284c7;
    color: #fff !important;
    border-radius: 0.75rem;
    padding: 1.25rem 0.85rem;
    text-decoration: none;
    font-weight: 600;
    transition: transform 0.18s ease, background 0.18s ease;
    height: 100%;
}
.bu-blue-tile:hover {
    background: var(--brand-navy);
    transform: translateY(-3px);
}
.bu-award-card {
    background: linear-gradient(135deg, #0284c7 0%, #0369a1 100%);
    color: #fff;
    border-radius: 0.85rem;
    padding: 1.25rem;
    height: 100%;
}
@media (max-width: 767.98px) {
    .bu-hero-slide, .bu-hero-overlay { min-height: 280px; padding: 1.5rem 1.25rem; }
}


/* =====================================================================
   v6.9.1 Screen-Loaded Exact Paper & Certificate SVG Layers + Auto-Fit UI
   ===================================================================== */
.paper-stage {
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
    padding: 8px 4px 20px 4px;
    display: flex;
    flex-direction: column;
    align-items: center;
}
.paper-scale-wrap {
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    overflow: hidden;
}
.exact-paper-sheet {
    position: relative;
    overflow: hidden;
    background: #ffffff;
    color: #0f172a;
    margin: 0 auto 20px auto;
    text-align: left;
    box-sizing: border-box;
    box-shadow: 0 10px 28px rgba(15, 23, 42, 0.16);
    border: 1px solid #cbd5e1;
    transform-origin: top center;
    flex-shrink: 0;
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
}
.cert-bg-svg {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    pointer-events: none;
    display: block;
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
}
.cert-foreground {
    position: relative;
    z-index: 2;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

/* Global Auto-Fit Tables & Responsive Action Buttons (Zero Sideways Clipping!) */
.card {
    max-width: 100%;
    min-width: 0;
}
.table-responsive {
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}
.table-autofit {
    width: 100%;
    table-layout: auto;
}
.table-autofit th,
.table-autofit td {
    overflow-wrap: anywhere;
    word-break: break-word;
    vertical-align: middle;
}
.action-btn-group {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
    justify-content: flex-end;
    align-items: center;
}
.btn-group {
    flex-wrap: wrap;
}
@media (max-width: 1199.98px) {
    .table-autofit {
        font-size: 0.82rem;
    }
    .table-autofit td, .table-autofit th {
        padding: 0.38rem 0.42rem;
    }
}
@media (max-width: 767.98px) {
    .portal-topbar {
        padding: 0 0.55rem;
    }
    .portal-topbar .btn {
        font-size: 0.78rem;
        padding: 0.25rem 0.55rem;
    }
    .action-btn-group {
        justify-content: flex-start;
    }
    .card-header {
        flex-wrap: wrap;
        gap: 0.4rem;
    }
}
