/**
 * JTC EQC Portal — eqc-portal.css
 *
 * Desktop layout:
 *   [sidebar 280px] + [portal-main flex:1]
 *   Sidebar: [brand + collapse-toggle] → [nav] → [user-block]
 *   Portal-main: [topbar: breadcrumb + 🔔] → [content-wrapper]
 *
 * Desktop collapse (min-width:901px):
 *   Sidebar shrinks to 60px icon rail.
 *   Logo visible; hover brand area → logo crossfades to toggle button.
 *   Labels/text animate out via opacity + max-width + flex:0 0 0px.
 *   JS-positioned fixed tooltips appear on hover over nav icons.
 *
 * Mobile (≤900px):
 *   Sidebar is a fixed overlay — ALWAYS fully expanded.
 *   Hidden off-screen (translateX -100%), slides in on hamburger tap.
 *   Dark backdrop behind it. Collapsed state is NEVER active on mobile.
 *
 * User dropdown: position:fixed (set by JS) to escape sidebar overflow.
 * Toasts appear top-right, just below the topbar.
 */

/* ===================================================================
   CSS VARIABLES
   =================================================================== */
:root {
    --green:          #15453A;
    --green-light:    #1f6651;
    --gold:           #FFD700;
    --gold-dark:      #d4a900;

    --text:           #1a1a1a;
    --text-sec:       #5a5a5a;
    --text-ter:       #8a8a8a;

    --border:         #e0e0e0;
    --border-light:   #f0f0f0;
    --bg:             #f7f7f5;
    --bg-card:        #ffffff;
    --bg-hover:       #f0f0ee;

    --info-bg:    #e6f1fb;  --info-fg:    #0c447c;
    --warn-bg:    #faeeda;  --warn-fg:    #633806;
    --success-bg: #eaf3de;  --success-fg: #3b6d11;
    --danger-bg:  #fcebeb;  --danger-fg:  #791f1f;

    --sidebar-w:           280px;
    --sidebar-w-collapsed:  60px;
    --topbar-h:             48px;
    --r:    6px;
    --r-lg: 10px;
    --ease: 200ms ease-in-out;

    --z-overlay:  400;
    --z-sidebar:  500;
    --z-dropdown: 9000;
    --z-modal:    1050;
    --z-confirm:  1060;
    --z-toast:    1070;
}

/* ===================================================================
   RESET & BASE
   =================================================================== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 14px; -webkit-font-smoothing: antialiased; }
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Inter', 'Segoe UI', sans-serif;
    font-size: 13px; line-height: 1.5;
    color: var(--text); background: var(--bg);
    overflow: hidden;
}
a { color: var(--green); text-decoration: none; }
a:hover { color: var(--green-light); }

/* ===================================================================
   VISIBILITY TOGGLE — login vs portal  (NEVER REMOVE)
   =================================================================== */
#eqcPortalApp                    { display: none; }
body.authenticated #eqcLoginView { display: none; }
body.authenticated #eqcPortalApp {
    display: flex;
    height: 100vh;
    width: 100vw;
    overflow: hidden;
}

/* ===================================================================
   LOGIN VIEW
   =================================================================== */
#eqcLoginView {
    min-height: 100vh;
    display: flex; flex-direction: column;
    background: linear-gradient(160deg, #0d2820 0%, var(--green) 55%, var(--green-light) 100%);
    position: relative; overflow: hidden;
}
#eqcLoginView::before {
    content: ''; position: absolute; inset: 0;
    background:
        radial-gradient(circle at 18% 78%, rgba(212,169,0,.09) 0%, transparent 48%),
        radial-gradient(circle at 82% 18%, rgba(212,169,0,.06) 0%, transparent 38%);
    pointer-events: none;
}
.login-header {
    padding: 1.25rem 2rem;
    display: flex; align-items: center; gap: 1rem;
    border-bottom: 1px solid rgba(255,255,255,.1);
    position: relative; z-index: 1;
}
.login-header-logo { height: 42px; }
.login-header-text h1 {
    font-size: 1.0625rem; font-weight: 700;
    color: #fff; margin: 0; line-height: 1.2;
}
.login-header-text p {
    font-size: .6875rem; color: var(--gold); margin: 0;
    font-weight: 500; letter-spacing: .05em; text-transform: uppercase;
}
.login-body {
    flex: 1;
    display: flex; align-items: center; justify-content: center;
    padding: 2rem; position: relative; z-index: 1;
}
.login-card {
    width: 100%; max-width: 440px;
    background: #fff;
    border-radius: var(--r-lg);
    box-shadow: 0 24px 48px rgba(0,0,0,.25);
    overflow: hidden;
}
.login-card-header {
    background: linear-gradient(135deg, var(--green) 0%, var(--green-light) 100%);
    padding: 2rem 2rem 1.5rem; text-align: center; position: relative;
}
.login-card-header::after {
    content: ''; position: absolute;
    bottom: 0; left: 0; right: 0;
    height: 3px; background: var(--gold-dark);
}
.login-card-icon {
    width: 54px; height: 54px;
    background: rgba(255,255,255,.15);
    border: 2px solid rgba(255,255,255,.25);
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    margin: 0 auto 1rem;
    font-size: 1.5rem; color: var(--gold);
}
.login-card-header h2 { color: #fff; font-size: 1.1875rem; margin-bottom: .25rem; }
.login-card-header p  { color: rgba(255,255,255,.7); font-size: .8125rem; margin: 0; }
.login-card-body { padding: 1.75rem 2rem; }
.login-card-body table { width: 100%; }
.login-card-body td    { padding: .375rem 0; vertical-align: top; }
.login-card-body input[type="text"],
.login-card-body input[type="password"],
.login-card-body input[type="email"] {
    width: 100%; padding: .625rem .875rem;
    border: 1px solid var(--border); border-radius: var(--r);
    font-size: .875rem; font-family: inherit;
    background: var(--bg); color: var(--text);
    transition: border-color var(--ease), box-shadow var(--ease);
}
.login-card-body input:focus {
    outline: none; border-color: var(--green);
    background: #fff; box-shadow: 0 0 0 3px rgba(21,69,58,.08);
}
.login-card-body input[type="submit"],
.login-card-body .cbSubmitButton {
    width: 100%; padding: .6875rem 1rem;
    background: var(--green); color: #fff; border: none;
    border-radius: var(--r);
    font-size: .875rem; font-weight: 600; font-family: inherit;
    cursor: pointer; margin-top: .375rem;
    transition: background var(--ease), box-shadow var(--ease), transform var(--ease);
}
.login-card-body input[type="submit"]:hover,
.login-card-body .cbSubmitButton:hover {
    background: var(--green-light);
    box-shadow: 0 4px 12px rgba(21,69,58,.25);
    transform: translateY(-1px);
}
.login-footer {
    padding: 1rem 2rem;
    background: var(--bg); border-top: 1px solid var(--border-light);
    text-align: center; font-size: .8125rem; color: var(--text-sec);
}
.login-footer a { color: var(--green); font-weight: 500; }
.login-page-footer {
    padding: .875rem 2rem;
    border-top: 1px solid rgba(255,255,255,.08);
    display: flex; align-items: center; justify-content: center;
    gap: 1.5rem; position: relative; z-index: 1;
}
.login-page-footer span,
.login-page-footer a { font-size: .8125rem; color: rgba(255,255,255,.5); }
.login-page-footer a:hover { color: var(--gold); }

/* ===================================================================
   SIDEBAR OVERLAY (mobile only)
   =================================================================== */
.sidebar-overlay {
    display: none;
    position: fixed; inset: 0;
    background: rgba(0,0,0,.4);
    z-index: var(--z-overlay);
}
.sidebar-overlay.active { display: block; }

/* ===================================================================
   SIDEBAR — base (expanded on desktop, full on mobile)
   =================================================================== */
.sidebar {
    width: var(--sidebar-w);
    flex-shrink: 0;
    background: var(--green);
    display: flex;
    flex-direction: column;
    overflow: visible;
    position: relative;
    z-index: 10;
    transition: width 250ms ease-in-out;
}

/* --- Brand row --- */
.sidebar-brand {
    padding: .875rem 1rem;
    border-bottom: 1px solid rgba(255,255,255,.12);
    display: flex;
    align-items: center;
    gap: .5rem;
    flex-shrink: 0;
    overflow: hidden;
    transition: padding 250ms ease-in-out, gap 250ms ease-in-out, justify-content 250ms ease-in-out;
}
.sidebar-brand-logo {
    height: 28px; flex-shrink: 0;
    transition: opacity 150ms ease-in-out, max-width 200ms ease-in-out;
}
.sidebar-brand-text {
    flex: 1; overflow: hidden;
    transition: opacity 150ms ease-in-out, max-width 200ms ease-in-out;
}
.sidebar-brand-text .title {
    display: block; font-size: .875rem; font-weight: 600;
    color: var(--gold); line-height: 1.2;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.sidebar-brand-text .sub {
    display: block; font-size: .5625rem;
    color: rgba(255,255,255,.45);
    letter-spacing: .05em; text-transform: uppercase; margin-top: 1px;
    white-space: nowrap;
}

/* Collapse toggle button — in sidebar brand on desktop */
#sidebarToggle {
    width: 26px; height: 26px;
    flex-shrink: 0;
    border: 1px solid rgba(255,255,255,.2);
    background: rgba(255,255,255,.08);
    color: rgba(255,255,255,.7);
    border-radius: 5px;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    font-size: .75rem;
    transition: all var(--ease);
    margin: 0;
}
#sidebarToggle:hover {
    background: rgba(255,255,255,.18);
    color: #fff;
}

/* --- Nav area (scrollable vertically) --- */
.sidebar-nav-wrap {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,.15) transparent;
}
.sidebar-nav-wrap::-webkit-scrollbar { width: 3px; }
.sidebar-nav-wrap::-webkit-scrollbar-thumb { background: rgba(255,255,255,.15); border-radius: 4px; }

.sidebar-nav { padding: .625rem 0; }

.nav-section-header {
    font-size: .5625rem; font-weight: 700; text-transform: uppercase;
    letter-spacing: .1em; color: rgba(255,255,255,.35);
    padding: .875rem .875rem .375rem;
    white-space: nowrap;
    transition: opacity 100ms ease-in-out, max-height 150ms ease-in-out, padding 150ms ease-in-out, margin 150ms ease-in-out;
}

.nav-item {
    display: flex; align-items: center; gap: .625rem;
    padding: .5625rem .875rem;
    color: rgba(255,255,255,.7);
    text-decoration: none; font-size: .8125rem; font-weight: 500;
    transition: all var(--ease);
    margin: 1px .5rem;
    border-radius: 5px;
    border-left: 2px solid transparent;
    cursor: pointer;
    white-space: nowrap;
    overflow: hidden;
    position: relative;
}
.nav-item:hover { background: rgba(255,255,255,.08); color: #fff; }
.nav-item.active {
    background: rgba(255,255,255,.12); color: #fff;
    border-left-color: var(--gold);
}
.nav-item.active .nav-icon { color: var(--gold); }
.nav-icon {
    width: 16px; text-align: center; font-size: .9375rem;
    flex-shrink: 0;
}
.nav-label {
    flex: 1; overflow: hidden; text-overflow: ellipsis;
    transition: opacity 150ms ease-in-out, max-width 200ms ease-in-out, padding 200ms ease-in-out;
}
.nav-badge {
    background: #ef4444; color: #fff;
    font-size: .5rem; font-weight: 700;
    padding: 1px 5px; border-radius: 10px; flex-shrink: 0;
    transition: opacity 100ms ease-in-out, max-height 150ms ease-in-out, padding 150ms ease-in-out, margin 150ms ease-in-out;
}

/* --- User block (sidebar bottom) --- */
.sidebar-footer {
    border-top: 1px solid rgba(255,255,255,.1);
    padding: .75rem .875rem;
    flex-shrink: 0;
    transition: padding 250ms ease-in-out;
}
.sidebar-user {
    display: flex; align-items: center; gap: .625rem;
    padding: .375rem .25rem;
    cursor: pointer;
    border-radius: 5px;
    transition: background var(--ease);
}
.sidebar-user:hover { background: rgba(255,255,255,.06); }
.user-avatar {
    width: 30px; height: 30px; border-radius: 50%;
    object-fit: cover; background: var(--green-light);
    border: 2px solid rgba(255,255,255,.25); flex-shrink: 0;
}
.user-info {
    flex: 1; min-width: 0;
    transition: opacity 150ms ease-in-out, max-width 200ms ease-in-out;
}
.user-name {
    display: block; font-size: .8125rem; font-weight: 600;
    color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.user-role {
    display: block; font-size: .625rem;
    color: rgba(255,255,255,.5);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* User dropdown — position:fixed set by JS */
.user-dropdown {
    position: fixed;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--r);
    box-shadow: 0 8px 24px rgba(0,0,0,.15);
    opacity: 0; visibility: hidden;
    transform: translateY(4px);
    transition: all var(--ease);
    z-index: var(--z-dropdown);
    min-width: 170px;
}
.user-dropdown.show {
    opacity: 1; visibility: visible; transform: translateY(0);
}
.dropdown-item {
    display: flex; align-items: center; gap: .5rem;
    padding: .625rem .875rem;
    color: var(--text); font-size: .8125rem;
    cursor: pointer; transition: background var(--ease);
    text-decoration: none;
}
.dropdown-item:hover { background: var(--bg-hover); color: var(--green); }
.dropdown-item i { width: 14px; color: var(--text-sec); font-size: .875rem; }
.user-dropdown hr { border: none; border-top: 1px solid var(--border-light); margin: .25rem 0; }

.sidebar-version {
    font-size: .5rem; color: rgba(255,255,255,.2);
    text-align: center; display: block; margin-top: .375rem;
    white-space: nowrap; overflow: hidden;
    transition: opacity 150ms ease-in-out, max-width 200ms ease-in-out;
}

/* ===================================================================
   SIDEBAR TOOLTIP — single fixed element, positioned by JS
   =================================================================== */
.sidebar-tooltip {
    position: fixed;
    z-index: 99999;
    background: rgba(10, 30, 22, .95);
    color: #fff;
    padding: .375rem .75rem;
    border-radius: var(--r);
    font-size: .8125rem;
    white-space: nowrap;
    pointer-events: none;
    opacity: 0;
    transform: translateY(-50%) translateX(4px);
    transition: opacity 120ms ease-in-out, transform 120ms ease-in-out;
    box-shadow: 0 4px 12px rgba(0,0,0,.25);
}
.sidebar-tooltip.visible {
    opacity: 1;
    transform: translateY(-50%) translateX(0);
}

/* ===================================================================
   DESKTOP COLLAPSED STATE — scoped to min-width:901px only
   =================================================================== */
@media (min-width: 901px) {

    body.sidebar-collapsed .sidebar {
        width: var(--sidebar-w-collapsed);
    }

    /* Text elements: fade out and collapse to zero.
       .sidebar-brand-logo NOT here — logo stays visible. */
    body.sidebar-collapsed .sidebar-brand-text,
    body.sidebar-collapsed .nav-label,
    body.sidebar-collapsed .user-info,
    body.sidebar-collapsed .sidebar-version {
        opacity: 0;
        max-width: 0;
        overflow: hidden;
        flex: 0 0 0px;
        padding: 0;
    }

    /* Section headers & badges: collapse vertically */
    body.sidebar-collapsed .nav-section-header,
    body.sidebar-collapsed .nav-badge {
        opacity: 0;
        pointer-events: none;
        max-height: 0;
        overflow: hidden;
        margin: 0;
        padding: 0;
    }

    /* Brand: logo visible by default. Toggle overlaid on top, hidden.
       On hover: logo fades out, toggle fades in — same spot, crossfade. */
    body.sidebar-collapsed .sidebar-brand {
        justify-content: center;
        padding: .875rem 0;
        gap: 0;
        position: relative;
    }

    /* Logo: visible, centered by flexbox */
    body.sidebar-collapsed .sidebar-brand-logo {
        opacity: 1;
        transition: opacity 120ms ease;
    }
    /* Logo: fades out on brand hover */
    body.sidebar-collapsed .sidebar-brand:hover .sidebar-brand-logo {
        opacity: 0;
        pointer-events: none;
    }

    /* Toggle: absolutely positioned on top of logo, invisible by default */
    body.sidebar-collapsed .sidebar #sidebarToggle {
        position: absolute;
        left: 50%;
        top: 50%;
        transform: translate(-50%, -50%);
        width: 28px;
        height: 28px;
        opacity: 0;
        pointer-events: none;
        transition: opacity 120ms ease, background var(--ease), color var(--ease);
    }
    /* Toggle: fades in on brand hover */
    body.sidebar-collapsed .sidebar-brand:hover #sidebarToggle {
        opacity: 1;
        pointer-events: auto;
    }

    /* Nav items: center the icon */
    body.sidebar-collapsed .nav-item {
        justify-content: center;
        padding: .5625rem 0;
        margin: 1px .375rem;
        border-left-color: transparent !important;
    }
    body.sidebar-collapsed .nav-item.active {
        background: rgba(255,255,255,.15);
    }
    body.sidebar-collapsed .nav-item.active .nav-icon {
        color: var(--gold);
    }

    /* Footer: center the avatar */
    body.sidebar-collapsed .sidebar-footer {
        padding: .75rem 0;
    }
    body.sidebar-collapsed .sidebar-user {
        justify-content: center;
        padding: .375rem 0;
    }
}

/* ===================================================================
   PORTAL MAIN
   =================================================================== */
.portal-main {
    flex: 1;
    display: flex; flex-direction: column;
    overflow: hidden; min-width: 0;
    background: var(--bg);
}

/* ===================================================================
   TOPBAR
   =================================================================== */
.portal-topbar {
    height: var(--topbar-h);
    background: var(--bg-card);
    border-bottom: 1px solid var(--border-light);
    display: flex; align-items: center;
    padding: 0 1.25rem;
    gap: .75rem;
    flex-shrink: 0;
}

.mobile-hamburger {
    width: 30px; height: 30px;
    border: 1px solid var(--border); background: transparent;
    color: var(--text-sec); font-size: .875rem;
    cursor: pointer; border-radius: var(--r);
    display: none; align-items: center; justify-content: center;
    flex-shrink: 0; transition: all var(--ease);
}
.mobile-hamburger:hover { background: var(--bg-hover); color: var(--green); border-color: #ccc; }

/* Breadcrumb */
.breadcrumb {
    flex: 1;
    display: flex; align-items: center; gap: .375rem;
    font-size: .75rem; color: var(--text-ter);
    min-width: 0; overflow: hidden;
}
/* Ancestor items — clickable */
.breadcrumb a,
.breadcrumb .bc-link {
    color: var(--text-sec); text-decoration: none;
    white-space: nowrap; transition: color .12s;
}
.breadcrumb a:hover,
.breadcrumb .bc-link:hover { color: var(--green); text-decoration: underline; }
/* Current page — end of trail */
.breadcrumb span,
.breadcrumb .bc-current {
    color: var(--text); font-weight: 500;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
/* Non-linked ancestor text (legacy fallback) */
.breadcrumb .bc-text { color: var(--text-sec); white-space: nowrap; }
/* Separator chevron */
.breadcrumb i,
.breadcrumb .bc-sep { font-size: .5rem; color: var(--text-ter); flex-shrink: 0; }
/* Back button — depth-2+ pages */
.breadcrumb .bc-back {
    color: var(--green); font-weight: 500;
    text-decoration: none; white-space: nowrap; flex-shrink: 0;
    display: inline-flex; align-items: center; gap: .2rem;
    transition: color var(--ease);
}
.breadcrumb .bc-back:hover { color: var(--green-light); text-decoration: underline; }
/* Vertical divider between back button and trail */
.breadcrumb .bc-divider {
    display: inline-block;
    width: 1px; height: 13px;
    background: var(--border);
    flex-shrink: 0; margin: 0 .25rem;
    align-self: center;
}

.topbar-right {
    display: flex; align-items: center; gap: .5rem; flex-shrink: 0;
}
.notification-icon {
    position: relative;
    width: 32px; height: 32px;
    display: flex; align-items: center; justify-content: center;
    border: 1px solid var(--border); border-radius: var(--r);
    color: var(--text-sec); font-size: .9375rem;
    cursor: pointer; transition: all var(--ease); background: transparent;
}
.notification-icon:hover { background: var(--bg-hover); color: var(--green); border-color: #ccc; }
.notification-badge {
    position: absolute; top: -4px; right: -4px;
    background: #ef4444; color: #fff;
    font-size: .4375rem; font-weight: 700;
    padding: 1px 3px; border-radius: 6px;
    min-width: 13px; text-align: center;
    display: none;
}

/* ===================================================================
   CONTENT AREA
   =================================================================== */
.content-wrapper {
    flex: 1; overflow-y: auto; overflow-x: auto; padding: 1.25rem;
}
.content-area {
    background: var(--bg-card);
    border-radius: var(--r);
    border: 1px solid var(--border-light);
    min-height: 400px;
    padding: 0;          /* DataPages fill full card width; header/spinner carry own padding */
}

/* DataPage container — full width, padding so content breathes */
#datapageContainer {
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    padding: 0 20px 20px;
}

/* Spinner has padding when there is no content header above it */
.content-loading {
    padding: 40px 20px;
}

/* Override Caspio's default form/report container widths */
[id^="cbResultSetContainerDiv_"],
[id^="cbForm_"],
[id^="cbTable_"],
.cbFormContainer, .cbResultSetContainer,
.cbFormSection    { width: 100% !important; max-width: 100% !important; }
.content-wrapper .cbResultSetTable thead th {
    position: sticky !important; top: 0 !important; z-index: 5 !important;
    background: var(--green) !important; color: #fff !important;
    border-bottom: 2px solid var(--gold-dark) !important;
    padding: 9px 12px !important; font-size: .8125rem !important;
    white-space: nowrap !important; font-weight: 500 !important;
}
.content-wrapper .cbResultSetTable tbody tr:nth-child(even) { background: #f9fafb !important; }
.content-wrapper .cbResultSetTable tbody tr:hover            { background: #e5f0ec !important; }

/* ===================================================================
   PLACEHOLDER / STATIC PAGES
   =================================================================== */
.static-page { max-width: 680px; margin: 0 auto; padding: 2rem; }
.static-page h2 {
    color: var(--green); border-bottom: 2px solid var(--gold-dark);
    padding-bottom: .625rem; margin-bottom: 1.25rem; font-size: 1.125rem;
}
.placeholder-page { text-align: center; padding: 4rem 2rem; }
.placeholder-icon { font-size: 3rem; color: var(--border); margin-bottom: 1.25rem; }
.placeholder-page h2 { color: var(--green); margin-bottom: .5rem; }
.placeholder-msg  { color: var(--text-sec); font-size: .9375rem; }
.placeholder-sub  { color: var(--text-ter); font-size: .875rem; }

/* ===================================================================
   BUTTONS
   =================================================================== */
.btn {
    display: inline-flex; align-items: center; gap: .375rem;
    padding: .5rem 1rem; font-size: .8125rem; font-weight: 500;
    border: 1px solid var(--border); border-radius: var(--r);
    cursor: pointer; background: var(--bg-card); color: var(--text-sec);
    transition: all var(--ease); text-decoration: none;
    white-space: nowrap; font-family: inherit;
}
.btn:hover { background: var(--bg-hover); border-color: #ccc; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--green); color: #fff; border-color: var(--green); }
.btn-primary:hover { background: var(--green-light); border-color: var(--green-light); color: #fff; box-shadow: 0 2px 8px rgba(21,69,58,.2); }
.btn-submit  { background: var(--gold-dark); color: #fff; border-color: var(--gold-dark); }
.btn-submit:hover { background: #b07a00; color: #fff; }
.btn-secondary { background: var(--bg-card); color: var(--text); border-color: var(--border); }
.btn-secondary:hover { background: var(--bg); }
.btn-danger { color: var(--danger-fg); border-color: #e8c8c8; background: transparent; }
.btn-danger:hover { background: var(--danger-bg); }

.pill {
    display: inline-block; font-size: .6875rem;
    padding: 3px 9px; border-radius: 12px; font-weight: 500; white-space: nowrap;
}
.pill.draft      { background: var(--warn-bg);    color: var(--warn-fg); }
.pill.open       { background: var(--success-bg); color: var(--success-fg); }
.pill.inprogress { background: var(--info-bg);    color: var(--info-fg); }
.pill.deferred   { background: var(--warn-bg);    color: var(--warn-fg); }
.pill.closed     { background: #f0f0ee;            color: #5a5a55; }
.pill.alert      { background: var(--danger-bg);  color: var(--danger-fg); }

/* ===================================================================
   MODAL
   =================================================================== */
.modal {
    position: fixed; inset: 0; z-index: var(--z-modal);
    display: none; align-items: center; justify-content: center;
}
.modal.active { display: flex; }
.modal-backdrop {
    position: absolute; inset: 0;
    background: rgba(0,0,0,.45); backdrop-filter: blur(2px);
}
.modal-container {
    position: relative; background: var(--bg-card);
    border-radius: var(--r-lg);
    box-shadow: 0 24px 48px rgba(0,0,0,.2);
    display: flex; flex-direction: column;
    max-height: 90vh; width: 90vw;
    animation: modalIn .2s ease-out;
}
@keyframes modalIn {
    from { opacity: 0; transform: scale(.97) translateY(-8px); }
    to   { opacity: 1; transform: scale(1)   translateY(0); }
}
.modal-small  { max-width: 440px; }
.modal-medium { max-width: 640px; }
.modal-large  { max-width: 900px; }
.modal-full   { max-width: 95vw; height: 90vh; }
.modal-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 1rem 1.375rem;
    background: linear-gradient(135deg, var(--green) 0%, var(--green-light) 100%);
    border-bottom: 3px solid var(--gold-dark);
    border-radius: var(--r-lg) var(--r-lg) 0 0; flex-shrink: 0;
}
.modal-header h3 { color: #fff; margin: 0; font-size: .9375rem; }
.modal-close {
    width: 28px; height: 28px; border: none;
    background: rgba(255,255,255,.15); color: #fff; border-radius: 50%;
    cursor: pointer; display: flex; align-items: center; justify-content: center;
    font-size: .875rem; transition: background var(--ease);
}
.modal-close:hover { background: rgba(255,255,255,.3); }
.modal-body { flex: 1; overflow-y: auto; padding: 1.375rem; }
.modal-footer {
    padding: .875rem 1.375rem;
    border-top: 1px solid var(--border-light);
    display: flex; align-items: center; justify-content: flex-end; gap: .625rem;
    flex-shrink: 0; background: var(--bg);
    border-radius: 0 0 var(--r-lg) var(--r-lg);
}

/* ===================================================================
   TOASTS
   =================================================================== */
.toast-container {
    position: fixed;
    top: calc(var(--topbar-h) + 10px);
    right: 1rem;
    z-index: var(--z-toast);
    display: flex; flex-direction: column; gap: .5rem;
    max-width: 340px; width: calc(100vw - 2rem);
}
.toast {
    display: flex; align-items: flex-start; gap: .625rem;
    padding: .75rem 1rem;
    border-radius: var(--r);
    box-shadow: 0 4px 16px rgba(0,0,0,.15);
    background: var(--bg-card); border-left: 4px solid var(--border);
    font-size: .8125rem; opacity: 0; transform: translateX(16px);
    transition: all var(--ease);
}
.toast.show { opacity: 1; transform: translateX(0); }
.toast-success { border-left-color: var(--success-fg); }
.toast-error   { border-left-color: var(--danger-fg); }
.toast-warning { border-left-color: var(--warn-fg); }
.toast-info    { border-left-color: var(--info-fg); }
.toast-icon { flex-shrink: 0; font-size: .9375rem; margin-top: 1px; }
.toast-success .toast-icon { color: var(--success-fg); }
.toast-error   .toast-icon { color: var(--danger-fg); }
.toast-warning .toast-icon { color: var(--warn-fg); }
.toast-info    .toast-icon { color: var(--info-fg); }
.toast-message { flex: 1; color: var(--text); line-height: 1.4; }
.toast-close { background: none; border: none; color: var(--text-ter); cursor: pointer; font-size: .875rem; padding: 0; }
.toast-close:hover { color: var(--text); }

/* ===================================================================
   CONFIRM DIALOG
   =================================================================== */
.confirm-dialog {
    position: fixed; inset: 0; z-index: var(--z-confirm);
    display: none; align-items: center; justify-content: center;
}
.confirm-dialog.active { display: flex; }
.confirm-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,.5); }
.confirm-box {
    position: relative; background: var(--bg-card);
    border-radius: var(--r-lg);
    box-shadow: 0 24px 48px rgba(0,0,0,.2);
    padding: 1.75rem 1.375rem;
    max-width: 360px; width: 90%; text-align: center;
    animation: modalIn .2s ease-out;
}
.confirm-icon { font-size: 2.25rem; color: #f59e0b; margin-bottom: .875rem; }
.confirm-box h3 { font-size: 1rem; margin-bottom: .375rem; }
.confirm-box p  { color: var(--text-sec); font-size: .875rem; margin-bottom: 1.375rem; }
.confirm-buttons { display: flex; gap: .625rem; justify-content: center; }
.confirm-buttons .btn { flex: 1; justify-content: center; }

/* ===================================================================
   LOADING / ERROR
   =================================================================== */
.content-loading {
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    min-height: 300px; gap: .875rem;
}
.spinner-large {
    width: 44px; height: 44px;
    border: 3px solid var(--border); border-top-color: var(--green);
    border-radius: 50%; animation: spin 1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.content-loading p { color: var(--text-sec); font-size: .875rem; }
.content-error { text-align: center; padding: 4rem 2rem; }
.error-icon { font-size: 3rem; color: #ef4444; margin-bottom: 1rem; }
.content-error h2 { color: var(--text); margin-bottom: .375rem; }
.content-error p  { color: var(--text-sec); margin-bottom: 1rem; font-size: .875rem; }

/* ===================================================================
   RESPONSIVE — MOBILE  (≤ 900px)
   =================================================================== */
@media (max-width: 900px) {
    .sidebar {
        position: fixed;
        top: 0; left: 0; bottom: 0;
        z-index: var(--z-sidebar);
        transform: translateX(-100%);
        width: var(--sidebar-w) !important;
        transition: transform 200ms ease-in-out;
    }
    .sidebar.open {
        transform: translateX(0);
    }

    .mobile-hamburger { display: flex; }
    #sidebarToggle    { display: none; }

    .content-wrapper { padding: 1rem; }
    .portal-topbar   { padding: 0 1rem; gap: .5rem; }
}

@media (max-width: 600px) {
    .login-header    { padding: 1rem; }
    .login-body      { padding: 1rem; }
    .login-card-body { padding: 1.25rem; }
    .login-card-header { padding: 1.5rem 1.25rem 1.25rem; }
    .content-wrapper { padding: .75rem; }
    .modal-container { width: calc(100% - 1.5rem); margin: .75rem; }
    .confirm-box     { width: calc(100% - 1.5rem); margin: .75rem; }
}

@media (max-width: 400px) {
    .login-card { border-radius: 0; }
    .login-body { padding: 0; }
}

@media (min-width: 1400px) {
    :root { --sidebar-w: 240px; }
}

/* =============================================================================
   CONTENT PAGE HEADER
   Rendered by router.js from route.header definition.
   Shows above every DataPage — title, subtitle, optional action button.
   view-submission (hub) is excluded — hub DataPage renders its own header.
   ============================================================================= */

.eqc-content-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    padding: 20px 20px 18px;   /* top/side padding since content-area has padding:0 */
    margin-bottom: 0;
    border-bottom: 1px solid var(--border, #e0e0e0);
    flex-wrap: wrap;
}

.eqc-content-header-text {
    flex: 1;
    min-width: 0;
}

.eqc-page-title {
    font-size: 20px;
    font-weight: 600;
    color: var(--text, #1a1a1a);
    margin: 0 0 4px;
    line-height: 1.2;
}

.eqc-page-subtitle {
    font-size: 12px;
    color: var(--text-secondary, #5a5a5a);
    margin: 0;
    line-height: 1.5;
}

.eqc-content-header-actions {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-shrink: 0;
}

/* Header action buttons */
.eqc-hdr-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    border: 1px solid transparent;
    white-space: nowrap;
    transition: background 0.15s, border-color 0.15s;
}

.eqc-hdr-btn-primary {
    background: #15453A;
    color: #fff;
    border-color: #15453A;
}
.eqc-hdr-btn-primary:hover {
    background: #1f6651;
    border-color: #1f6651;
}

.eqc-hdr-btn-gold {
    background: #d4a900;
    color: #fff;
    border-color: #d4a900;
}
.eqc-hdr-btn-gold:hover { background: #b8940a; }

.eqc-hdr-btn-secondary {
    background: #fff;
    color: #15453A;
    border-color: #e0e0e0;
}
.eqc-hdr-btn-secondary:hover {
    background: #f7f7f5;
    border-color: #15453A;
}

/* Responsive: stack header on narrow screens */
@media (max-width: 600px) {
    .eqc-content-header {
        flex-direction: column;
        align-items: flex-start;
    }
    .eqc-page-title { font-size: 17px; }
}


/* No top gap when header is directly above DataPage */
.eqc-content-header + #datapageContainer,
.eqc-content-header ~ #datapageContainer { padding-top: 16px; }

/* =============================================================================
   DASHBOARD DATAPAGE — full width override
   The dashboard footer script sets max-width:960px on #eqc-dash.
   Override here so it fills the full content card width.
   ============================================================================= */
#eqc-dash {
    max-width: 100% !important;
}