:root {
    --primary: #1c5d3b;
    --primary-dark: #123f28;
    --primary-light: #e3f3e9;
    --accent: #2f8a5a;
    --bg: #f4f6f5;
    --card-bg: #ffffff;
    --border: #dfe3e0;
    --text: #202824;
    --text-muted: #5c6a63;
    --error: #b3261e;
    --error-bg: #fbe9e7;
    --success: #1c5d3b;
    --pending: #b56a00;
    --radius: 10px;
    --radius-sm: 6px;
    --shadow-sm: 0 1px 2px rgba(18, 40, 28, 0.06);
    --shadow-md: 0 4px 16px rgba(18, 40, 28, 0.08);
    --sidebar-w: 250px;
    --topbar-mobile-h: 54px;
    --topbar-h: 60px;
    --footer-h: 44px;
    --info: #1c6fb3;
    --info-bg: #e5f1fb;
    --warning: #b56a00;
    --warning-bg: #fdf1de;
    --danger: #b3261e;
    --danger-bg: #fbe9e7;
    --table-header-bg: #eef2ef;
    --table-hover-bg: #f8faf8;
    --badge-neutral-bg: #e3e8e5;
    --overlay-bg: rgba(18, 40, 28, 0.45);
    --focus-ring: rgba(47, 138, 90, 0.18);
}

/* ---------- Dark mode ----------
   Toggled by setting data-theme="dark" on <html> (see the inline script in
   <head> and the topbar toggle button). The sidebar stays its usual dark
   green in both themes — only the light surfaces (page background, cards,
   tables, topbar, modals) flip to dark equivalents. */
:root[data-theme="dark"] {
    --primary: #3f9468;
    --primary-dark: #2c6f4b;
    --primary-light: #16281f;
    --accent: #45a873;
    --bg: #141815;
    --card-bg: #1d2320;
    --border: #333c36;
    --text: #e7ece8;
    --text-muted: #a2aca4;
    --error: #ff6f61;
    --error-bg: #3a1f1c;
    --success: #45a873;
    --pending: #e3a53f;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.35);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.5);
    --info: #5aa4e0;
    --info-bg: #1c2a35;
    --warning: #e3a53f;
    --warning-bg: #3a2c14;
    --danger: #ff6f61;
    --danger-bg: #3a1f1c;
    --table-header-bg: #242b26;
    --table-hover-bg: #232a25;
    --badge-neutral-bg: #2b322d;
    --overlay-bg: rgba(0, 0, 0, 0.6);
    --focus-ring: rgba(69, 168, 115, 0.28);
}

* { box-sizing: border-box; }

/* The `hidden` attribute must always win over a class's own `display`
   property (e.g. `.btn { display: inline-flex }` would otherwise silently
   defeat `<button hidden>` on any element that also carries a display-setting
   class — this bit several real elements: the wizard's submit button, the
   draft-resume banner, transfer-only fields, dropdown menus). */
[hidden] { display: none !important; }

body {
    margin: 0;
    font-family: "Montserrat", -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.45;
}

a { color: inherit; }
h1, h2, h3, .brand-name, .nav-dropdown summary, .mainnav > a { font-family: "Montserrat", sans-serif; }

/* ---------- App shell ---------- */

.app-shell {
    display: flex;
    align-items: stretch;
    min-height: 100vh;
}

.app-main {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
}

/* ---------- Sidebar ---------- */

.sidebar {
    width: var(--sidebar-w);
    flex-shrink: 0;
    background: linear-gradient(180deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: white;
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    box-shadow: var(--shadow-md);
    z-index: 30;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 18px 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.12);
    flex-shrink: 0;
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    color: white;
    font-weight: 700;
    font-size: 0.98rem;
    min-width: 0;
}

.brand-mark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: 9px;
    background: rgba(255, 255, 255, 0.16);
    font-size: 1rem;
    font-weight: 800;
    flex-shrink: 0;
}

.brand-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ---------- Vertical nav ---------- */

.mainnav {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 14px 10px;
    overflow-y: auto;
    flex: 1;
}

.mainnav > a,
.nav-dropdown summary {
    color: rgba(255, 255, 255, 0.88);
    text-decoration: none;
    font-size: 0.87rem;
    font-weight: 500;
    padding: 11px 12px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    list-style: none;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 10px;
    transition: background .12s, color .12s;
}
.nav-dropdown summary::-webkit-details-marker { display: none; }
.nav-dropdown summary::after { content: "▾"; font-size: 0.65em; opacity: 0.75; transition: transform .15s; margin-left: auto; }
.nav-dropdown[open] summary::after { transform: rotate(180deg); }

.mainnav > a:hover,
.nav-dropdown summary:hover {
    background: rgba(255, 255, 255, 0.14);
    color: white;
}

.mainnav > a[aria-current="page"] {
    background: white;
    color: var(--primary-dark);
    font-weight: 600;
}

.nav-dropdown[open] summary { background: rgba(255, 255, 255, 0.1); color: white; }

.dropdown-menu {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 6px 0 6px 14px;
    margin-top: 2px;
    border-left: 2px solid rgba(255, 255, 255, 0.15);
    margin-left: 12px;
}
.dropdown-menu a {
    display: flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
    color: rgba(255, 255, 255, 0.78);
    font-size: 0.83rem;
    padding: 8px 10px;
    border-radius: 5px;
}
.dropdown-menu a:hover { background: rgba(255, 255, 255, 0.12); color: white; }
.dropdown-menu a[aria-current="page"] { background: rgba(255, 255, 255, 0.94); color: var(--primary-dark); font-weight: 600; }

.nav-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    flex-shrink: 0;
    font-size: 1rem;
    line-height: 1;
}

/* ---------- Sidebar-bottom logout row (aligned with the fixed footer) ---------- */

.sidebar-footer {
    height: var(--footer-h);
    flex-shrink: 0;
    border-top: 1px solid rgba(255, 255, 255, 0.14);
    background: rgba(0, 0, 0, 0.1);
    display: flex;
    align-items: center;
    padding: 0 10px;
}
.sidebar-logout {
    display: flex;
    align-items: center;
    gap: 9px;
    width: 100%;
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    text-decoration: none;
    color: rgba(255, 255, 255, 0.88);
    font-size: 0.87rem;
    font-weight: 600;
}
.sidebar-logout:hover { background: rgba(255, 255, 255, 0.14); color: white; }

.page-icon { margin-right: 4px; }

/* ---------- Top bar (desktop + mobile) ---------- */

.nav-toggle-input { display: none; }

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    background: var(--card-bg);
    border-bottom: 1px solid var(--border);
    padding: 0 24px;
    height: var(--topbar-h);
    flex-shrink: 0;
    box-shadow: var(--shadow-sm);
    z-index: 20;
    position: relative;
}
.topbar-left { display: flex; align-items: center; gap: 12px; min-width: 0; flex: 1; }
.topbar-right { display: flex; align-items: center; gap: 10px; flex-wrap: nowrap; flex-shrink: 0; }
.topbar-title { font-weight: 700; font-size: 1rem; color: var(--primary-dark); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar-mobile-title { font-weight: 600; font-size: 0.95rem; }

.nav-toggle {
    display: none;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 4px;
    width: 32px;
    height: 32px;
    cursor: pointer;
    border-radius: var(--radius-sm);
    color: var(--primary-dark);
    font-size: 1.3rem;
    line-height: 1;
    flex-shrink: 0;
}
.nav-toggle span { display: block; height: 2px; width: 20px; background: var(--primary-dark); border-radius: 2px; }
.nav-toggle:hover { background: var(--primary-light); }
.sidebar-brand .nav-toggle span { background: white; }
.sidebar-brand .nav-toggle { color: white; }

/* ---------- Top-right icon cluster (theme toggle, notifications) ---------- */

.topbar-icons { display: flex; align-items: center; gap: 4px; flex-wrap: nowrap; flex-shrink: 0; }

.topbar-icon-btn {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    border: none;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    font-family: inherit;
    flex-shrink: 0;
}
.topbar-icon-btn:hover { background: var(--primary-light); color: var(--primary); }
.topbar-icon { font-size: 1.15rem; line-height: 1; }
.icon-badge {
    position: absolute;
    top: 2px;
    right: 2px;
    min-width: 16px;
    height: 16px;
    padding: 0 3px;
    border-radius: 999px;
    background: var(--danger);
    color: #fff;
    font-size: 0.62rem;
    font-weight: 700;
    line-height: 16px;
    text-align: center;
    box-shadow: 0 0 0 2px var(--card-bg);
}

/* Theme toggle: shows the sun in dark mode ("switch to light") and the moon
   in light mode ("switch to dark"); CSS swaps which icon is visible. */
.theme-toggle-btn .theme-icon-dark { display: inline; }
.theme-toggle-btn .theme-icon-light { display: none; }
:root[data-theme="dark"] .theme-toggle-btn .theme-icon-dark { display: none; }
:root[data-theme="dark"] .theme-toggle-btn .theme-icon-light { display: inline; }

.notif-dropdown { position: relative; }
.notif-dropdown-menu {
    position: absolute;
    right: 0;
    top: calc(100% + 8px);
    width: 340px;
    max-width: 88vw;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
    display: none;
    z-index: 40;
    overflow: hidden;
}
.notif-dropdown.open .notif-dropdown-menu { display: block; }
.notif-dropdown-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
}
.notif-dropdown-header strong { font-size: 0.9rem; color: var(--text); display: flex; align-items: center; gap: 6px; }
.notif-count-pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 20px;
    height: 20px;
    padding: 0 5px;
    border-radius: 999px;
    background: var(--primary-light);
    color: var(--primary);
    font-size: 0.68rem;
    font-weight: 700;
}
.notif-dropdown-header form { margin: 0; }
.notif-mark-all {
    background: none;
    border: none;
    color: var(--primary);
    font-size: 0.78rem;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    padding: 0;
}
.notif-mark-all:hover { text-decoration: underline; }
.notif-list { max-height: 360px; overflow-y: auto; }
.notif-empty { padding: 24px 16px; text-align: center; color: var(--text-muted); font-size: 0.85rem; margin: 0; }
.notif-item {
    display: flex;
    gap: 10px;
    padding: 11px 16px;
    border-bottom: 1px solid var(--border);
}
.notif-item:last-child { border-bottom: none; }
.notif-item.unread { background: var(--primary-light); }
.notif-item .notif-icon {
    flex-shrink: 0;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: var(--bg);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.95rem;
}
.notif-item .notif-body { min-width: 0; flex: 1; }
.notif-item .notif-body p { margin: 0 0 3px; font-size: 0.84rem; color: var(--text); line-height: 1.35; }
.notif-item .notif-body time { font-size: 0.72rem; color: var(--text-muted); }
.notif-view-all {
    display: block;
    text-align: center;
    padding: 10px;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--primary);
    text-decoration: none;
    background: var(--bg);
}
.notif-view-all:hover { background: var(--primary-light); }

/* Full inbox page (modules/notifications/my_notifications.php) */
.notif-page-list { max-width: 720px; margin-top: 12px; background: var(--card-bg); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); overflow: hidden; }
.notif-page-list .notif-item { padding: 14px 18px; }
.notif-page-list .notif-body p { font-size: 0.88rem; }

/* ---------- Top-right user dropdown ---------- */

.user-dropdown { position: relative; }
.user-dropdown-toggle {
    display: flex;
    align-items: center;
    gap: 9px;
    background: transparent;
    border: 1px solid var(--border);
    padding: 6px 10px 6px 6px;
    border-radius: 30px;
    cursor: pointer;
    color: var(--text);
    font-family: inherit;
    flex-shrink: 0;
}
.user-dropdown-toggle:hover { background: var(--primary-light); border-color: var(--accent); }
.user-dropdown-toggle .user-avatar {
    width: 30px; height: 30px; border-radius: 50%;
    background: var(--primary); color: white;
    display: inline-flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 0.82rem; flex-shrink: 0;
}
.user-dropdown-toggle .user-info { display: flex; flex-direction: column; line-height: 1.2; text-align: left; }
.user-dropdown-toggle .user-info strong { font-size: 0.83rem; max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-dropdown-toggle .user-info small { font-size: 0.72rem; color: var(--text-muted); }
.user-dropdown-toggle .chevron { font-size: 0.65em; color: var(--text-muted); transition: transform .15s; }
.user-dropdown.open .chevron { transform: rotate(180deg); }

.user-dropdown-menu {
    position: absolute;
    right: 0;
    top: calc(100% + 8px);
    min-width: 190px;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
    padding: 6px;
    display: none;
    z-index: 40;
}
.user-dropdown.open .user-dropdown-menu { display: block; }
.user-dropdown-menu a {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 9px 11px;
    border-radius: var(--radius-sm);
    text-decoration: none;
    color: var(--text);
    font-size: 0.87rem;
    font-weight: 500;
}
.user-dropdown-menu a:hover { background: var(--primary-light); color: var(--primary-dark); }
.user-dropdown-menu .dropdown-divider { height: 1px; background: var(--border); margin: 5px 2px; }
.user-dropdown-menu a.logout-link:hover { background: var(--danger-bg); color: var(--danger); }
.user-dropdown-menu .menu-icon { font-size: 0.95em; width: 16px; text-align: center; flex-shrink: 0; }

/* ---------- Layout content: scrolls beneath the fixed footer ---------- */

.content-scroll {
    flex: 1;
    overflow-y: auto;
    padding-bottom: calc(var(--footer-h) + 14px);
}

/* Content lines up with the topbar title on its left edge and always fills
   the full width available beside the sidebar — no artificial page cap. */
.content { max-width: none; margin: 0; padding: 18px 24px 20px; width: 100%; }

/* ---------- Page locator (breadcrumb) ---------- */

.page-locator {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
    padding: 10px 24px;
    font-size: 0.8rem;
    color: var(--text-muted);
    background: var(--card-bg);
    border-bottom: 1px solid var(--border);
}
.page-locator a { text-decoration: none; color: var(--text-muted); display: flex; align-items: center; gap: 5px; }
.page-locator a:hover { color: var(--primary); text-decoration: underline; }
.page-locator .locator-sep { opacity: 0.5; }
.page-locator .locator-current { color: var(--primary-dark); font-weight: 600; }

.footer {
    flex-shrink: 0;
    height: var(--footer-h);
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.78rem;
    background: var(--card-bg);
    border-top: 1px solid var(--border);
}

h1 { font-size: 1.4rem; margin: 0 0 4px; font-weight: 700; }

/* ---------- Alerts ---------- */

.alert { padding: 11px 15px; border-radius: var(--radius-sm); margin-bottom: 16px; font-size: 0.9rem; border: 1px solid transparent; }
.alert-success { background: var(--primary-light); color: var(--success); border-color: var(--accent); }
.alert-error { background: var(--error-bg); color: var(--error); border-color: var(--error); }

/* ---------- Dashboard cards (quick-link tabs) ---------- */

.dashboard-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 16px; margin-top: 20px; }
.card {
    display: flex;
    align-items: center;
    gap: 14px;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px 18px;
    text-decoration: none;
    color: var(--text);
    font-weight: 600;
    box-shadow: var(--shadow-sm);
    transition: box-shadow .15s, transform .15s, border-color .15s;
}
.card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); border-color: var(--accent); }
.card-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: var(--primary-light);
    color: var(--primary);
    font-size: 1.15rem;
    flex-shrink: 0;
}
.card-label { flex: 1; min-width: 0; }
.card-arrow {
    flex-shrink: 0;
    color: var(--text-muted);
    font-size: 1.1rem;
    transition: transform .15s, color .15s;
}
.card:hover .card-arrow { transform: translateX(4px); color: var(--accent); }

/* ---------- Auth (login) ---------- */

.auth-wrapper {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 20px;
}
.auth-form {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 36px 32px;
    width: 360px;
    box-shadow: var(--shadow-md);
    text-align: center;
}
.auth-mark {
    width: 52px;
    height: 52px;
    margin: 0 auto 16px;
    border-radius: 14px;
    background: var(--primary-light);
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 1.3rem;
}
.auth-form h1 { font-size: 1.15rem; margin: 0 0 4px; color: var(--primary-dark); }
.auth-form h2 { font-size: 0.92rem; margin: 0 0 20px; font-weight: 400; color: var(--text-muted); }
.auth-form label { display: block; margin-bottom: 14px; font-size: 0.86rem; text-align: left; color: var(--text-muted); }
.auth-form input {
    width: 100%;
    padding: 10px 12px;
    margin-top: 5px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.95rem;
    font-family: inherit;
}
.auth-form button { width: 100%; padding: 11px; font-size: 0.95rem; margin-top: 4px; }

/* ---------- Buttons & forms ---------- */

.auth-form button, .stacked-form button, .filter-form button, .inline-form button, .btn, .btn-small {
    background: var(--primary);
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 999px;
    cursor: pointer;
    font-size: 0.82rem;
    font-family: inherit;
    font-weight: 600;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: background .12s, filter .12s, transform .12s;
}
.auth-form button:hover, .stacked-form button:hover, .filter-form button:hover, .inline-form button:hover, .btn:hover { background: var(--primary-dark); }
.btn:active { transform: translateY(1px); }
.btn-small { padding: 5px 12px; font-size: 0.74rem; }
/* Compact width variant: content-sized rather than stretching, for wizards
   and toolbars where several buttons sit side by side. */
.btn-compact { padding: 7px 14px; font-size: 0.8rem; min-width: 0; }
.stacked-form button { width: auto; justify-self: start; }
/* A lone "Filter"/"Search" submit button in a toolbar form reads better with
   a hint of what it does — most of these have no icon in their own markup. */
.filter-form button[type="submit"]::before { content: '\1F50D'; }

/* ---------- Button color variants ---------- */

.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-success { background: var(--accent); color: #fff; }
.btn-success:hover { background: #256e47; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #8c1e17; }
.btn-warning { background: var(--warning); color: #fff; }
.btn-warning:hover { background: #8f5300; }
.btn-info { background: var(--info); color: #fff; }
.btn-info:hover { background: #145586; }
.btn-outline { background: transparent; color: var(--primary); border: 1px solid var(--primary); }
.btn-outline:hover { background: var(--primary-light); }

/* ---------- Row action buttons (view / edit / delete) ---------- */

.action-buttons { display: flex; gap: 8px; align-items: center; flex-wrap: nowrap; }
.action-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    font-size: 0.92rem;
    text-decoration: none;
    color: #fff;
    transition: filter .12s, transform .12s;
    font-family: inherit;
    box-shadow: var(--shadow-sm);
}
.action-btn:hover { filter: brightness(0.92); transform: translateY(-1px) scale(1.05); }
.action-view { background: var(--info); }
.action-edit { background: var(--warning); }
.action-delete { background: var(--danger); }

/* ---------- Modal dialogs (add / edit / view) ---------- */

.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: var(--overlay-bg);
    z-index: 100;
    align-items: flex-start;
    justify-content: center;
    padding: 5vh 16px;
    overflow-y: auto;
}
.modal-overlay.open { display: flex; }
.modal-box {
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
    width: 100%;
    max-width: 680px;
    padding: 24px 28px;
}
.modal-box h3 { margin-top: 0; color: var(--primary-dark); }
.modal-box .stacked-form { margin: 0; }
.modal-box .stacked-form label { margin-bottom: 14px; }
.modal-box .stacked-form input, .modal-box .stacked-form select { max-width: none; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; grid-column: 1 / -1; }
.modal-close {
    position: absolute; top: 14px; right: 14px; border: none;
    background: var(--danger-bg); color: var(--danger);
    width: 30px; height: 30px; border-radius: 50%;
    font-size: 1.1rem; line-height: 1; cursor: pointer;
    display: inline-flex; align-items: center; justify-content: center;
    transition: filter .12s;
}
.modal-close:hover { filter: brightness(0.94); }
.modal-box { position: relative; }
.kv-table.modal-kv td { padding: 7px 0; }

input, select, textarea, button { font-family: inherit; }

input:focus, select:focus, textarea:focus, button:focus-visible {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--focus-ring);
}

.stacked-form fieldset { border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 18px; padding: 16px; background: var(--card-bg); grid-column: 1 / -1; }
.stacked-form legend { font-weight: 600; color: var(--primary); padding: 0 8px; }
.stacked-form label { display: block; margin-bottom: 14px; font-size: 0.9rem; }
.stacked-form input, .stacked-form select, .stacked-form textarea { width: 100%; padding: 9px 12px; margin-top: 4px; border: 1px solid var(--border); border-radius: var(--radius-sm); }

/* Two-column layout on wider screens: each <label> is a grid cell, while
   fieldsets/textareas/buttons/.span-2 elements stretch across both columns. */
.stacked-form {
    display: grid;
    grid-template-columns: 1fr;
    column-gap: 24px;
    align-items: start;
    max-width: 760px;
}
@media (min-width: 620px) {
    .stacked-form { grid-template-columns: 1fr 1fr; }
}
.stacked-form textarea,
.stacked-form button,
.stacked-form .span-2,
.stacked-form > p {
    grid-column: 1 / -1;
}
.stacked-form textarea { min-height: 90px; resize: vertical; }

.filter-form, .inline-form { display: flex; gap: 10px; align-items: center; margin: 16px 0; flex-wrap: wrap; }
.filter-form input, .filter-form select, .inline-form input, .inline-form select { padding: 8px 10px; border: 1px solid var(--border); border-radius: var(--radius-sm); }

/* ---------- Multi-step wizard (student registration, etc.) ---------- */

.wizard-steps { display: flex; align-items: flex-start; margin: 18px 0 22px; max-width: 860px; }
.wizard-step { display: flex; flex-direction: column; align-items: center; gap: 6px; flex: 1; min-width: 0; position: relative; background: none; border: none; font-family: inherit; cursor: default; padding: 0; }
.wizard-step-num {
    width: 30px; height: 30px; border-radius: 50%;
    background: var(--card-bg); border: 2px solid var(--border);
    color: var(--text-muted);
    display: inline-flex; align-items: center; justify-content: center;
    font-size: 0.82rem; font-weight: 700; z-index: 1;
}
.wizard-step-label { font-size: 0.72rem; font-weight: 600; color: var(--text-muted); text-align: center; padding: 0 4px; }
.wizard-step::after {
    content: "";
    position: absolute;
    top: 15px; left: 50%; width: 100%; height: 2px;
    background: var(--border);
    z-index: 0;
}
.wizard-step:last-child::after { display: none; }
.wizard-step.is-active .wizard-step-num { background: var(--primary); border-color: var(--primary); color: #fff; }
.wizard-step.is-active .wizard-step-label { color: var(--primary); }
.wizard-step.is-done { cursor: pointer; }
.wizard-step.is-done .wizard-step-num { background: var(--accent); border-color: var(--accent); color: #fff; }
.wizard-step.is-done::after { background: var(--accent); }

.wizard-panel {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px 22px;
    box-shadow: var(--shadow-sm);
    margin-bottom: 16px;
    max-width: 860px;
}
.wizard-panel[hidden] { display: none; }
.wizard-panel h2 { margin: 0 0 4px; font-size: 1.05rem; color: var(--primary-dark); }
.wizard-panel .wizard-panel-hint { margin: 0 0 16px; color: var(--text-muted); font-size: 0.85rem; }
.wizard-panel .stacked-form { max-width: none; }
.wizard-panel .stacked-form:not(:last-child) { margin-bottom: 6px; }
.wizard-draft-hint { font-size: 0.76rem; color: var(--text-muted); margin-top: -8px; }

.wizard-actions { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-top: 4px; max-width: 860px; }
.wizard-actions-right { display: flex; gap: 10px; margin-left: auto; }

.wizard-review dl { display: grid; grid-template-columns: 1fr 1fr; column-gap: 20px; margin: 0; }
.wizard-review dt { color: var(--text-muted); font-size: 0.78rem; font-weight: 600; text-transform: uppercase; margin-top: 10px; }
.wizard-review dd { margin: 2px 0 0; font-size: 0.9rem; color: var(--text); }
.wizard-review dt:nth-of-type(1), .wizard-review dt:nth-of-type(2) { margin-top: 0; }

/* Draft-resume banner shown above a wizard when a saved draft is found */
.draft-banner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    flex-wrap: wrap;
    background: var(--info-bg);
    border: 1px solid var(--info);
    border-radius: var(--radius);
    padding: 12px 16px;
    margin: 14px 0;
    max-width: 860px;
}
.draft-banner p { margin: 0; font-size: 0.86rem; color: var(--text); }
.draft-banner .draft-banner-actions { display: flex; gap: 8px; flex-shrink: 0; }

/* ---------- Tables ---------- */

.data-table { width: 100%; border-collapse: collapse; margin-top: 12px; background: var(--card-bg); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow-sm); }
.data-table th, .data-table td { text-align: left; padding: 11px 14px; border-bottom: 1px solid var(--border); font-size: 0.88rem; }
.data-table th { background: var(--table-header-bg); font-weight: 600; color: var(--text-muted); text-transform: uppercase; font-size: 0.72rem; letter-spacing: 0.03em; }
.data-table tbody tr:hover { background: var(--table-hover-bg); }
.data-table tbody tr:last-child td { border-bottom: none; }

.kv-table th { text-align: left; padding: 6px 10px 6px 0; color: var(--text-muted); font-size: 0.85rem; width: 160px; font-weight: 600; }
.kv-table td { padding: 6px 0; font-size: 0.9rem; }

.badge { display: inline-block; padding: 3px 10px; border-radius: 20px; font-size: 0.74rem; background: var(--badge-neutral-bg); font-weight: 600; color: var(--text); }
.badge-active, .badge-provided { background: var(--primary-light); color: var(--success); }
.badge-pending, .badge-inactive { background: var(--warning-bg); color: var(--pending); }
.badge-danger { background: var(--danger-bg); color: var(--danger); }
.badge-info { background: var(--info-bg); color: var(--info); }

/* ---------- DataTables theme overrides ---------- */

.dataTables_wrapper { margin-top: 12px; }
.dataTables_wrapper .dataTables_filter input,
.dataTables_wrapper .dataTables_length select {
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 6px 10px;
    font-family: inherit;
    margin-left: 6px;
}
.dataTables_wrapper .dataTables_filter { float: right; margin-bottom: 10px; }
.dataTables_wrapper .dataTables_length { float: left; margin-bottom: 10px; font-size: 0.86rem; color: var(--text-muted); }
.dataTables_wrapper .dataTables_info { font-size: 0.82rem; color: var(--text-muted); padding-top: 12px; }
.dataTables_wrapper .dataTables_paginate {
    padding-top: 8px;
}
.dataTables_wrapper .dataTables_paginate .paginate_button {
    padding: 5px 11px;
    margin-left: 3px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border) !important;
    background: var(--card-bg) !important;
    color: var(--text) !important;
    cursor: pointer;
}
.dataTables_wrapper .dataTables_paginate .paginate_button.current,
.dataTables_wrapper .dataTables_paginate .paginate_button:hover {
    background: var(--primary) !important;
    color: #fff !important;
    border-color: var(--primary) !important;
}
.dataTables_wrapper .dataTables_paginate .paginate_button.disabled { opacity: 0.5; cursor: default; }
table.dataTable thead th { position: relative; }
.data-table thead th.sorting:after,
.data-table thead th.sorting_asc:after,
.data-table thead th.sorting_desc:after { opacity: 0.55; }
div.dataTables_wrapper div.dataTables_length,
div.dataTables_wrapper div.dataTables_filter,
div.dataTables_wrapper div.dataTables_info,
div.dataTables_wrapper div.dataTables_paginate { color: var(--text); }

/* ---------- Toolbar above tables ---------- */

.table-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 18px 0 4px; flex-wrap: wrap; }
.table-toolbar h1, .table-toolbar h3 { margin: 0; }

/* ---------- Detail panels ---------- */

.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; margin-top: 20px; }
.detail-grid > div { background: var(--card-bg); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow-sm); }
.detail-grid > div:last-child { grid-column: 1 / -1; }

.guardian-card { border: 1px solid var(--border); border-radius: 8px; padding: 10px 14px; margin-bottom: 10px; font-size: 0.9rem; background: var(--card-bg); }

.panel { background: var(--card-bg); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; margin: 16px 0; box-shadow: var(--shadow-sm); }

/* ---------- Dashboard KPI stat cards ---------- */

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; margin: 18px 0; }
.stat-card {
    display: flex;
    align-items: center;
    gap: 14px;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px 18px;
    box-shadow: var(--shadow-sm);
}
.stat-card .stat-icon {
    width: 44px; height: 44px; border-radius: 12px;
    background: var(--primary-light); color: var(--primary);
    display: inline-flex; align-items: center; justify-content: center;
    font-size: 1.2rem; flex-shrink: 0;
}
.stat-card .stat-value { font-size: 1.25rem; font-weight: 800; color: var(--text); line-height: 1.25; }
.stat-card .stat-label { font-size: 0.76rem; color: var(--text-muted); font-weight: 600; }
.stat-card-link {
    text-decoration: none;
    cursor: pointer;
    transition: transform .12s, box-shadow .12s, border-color .12s;
}
.stat-card-link:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); border-color: var(--accent); }

/* ---------- Dashboard collections bar chart (dependency-free, server-rendered) ---------- */

.bar-chart { display: flex; align-items: flex-end; gap: 14px; height: 200px; padding: 10px 4px 0; }
.bar-chart-col { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; min-width: 0; }
.bar-chart-value { font-size: 0.7rem; color: var(--text-muted); font-weight: 600; margin-bottom: 4px; white-space: nowrap; }
.bar-chart-bar {
    width: 60%;
    min-height: 3px;
    background: linear-gradient(180deg, var(--accent) 0%, var(--primary) 100%);
    border-radius: 5px 5px 0 0;
    transition: height .3s;
}
.bar-chart-label { font-size: 0.72rem; color: var(--text-muted); margin-top: 8px; text-align: center; }
.item-row { display: flex; gap: 10px; margin-bottom: 8px; }
.item-row input { padding: 8px 10px; border: 1px solid var(--border); border-radius: var(--radius-sm); }

.subtitle { color: var(--text-muted); margin-top: -8px; }
.hint { color: var(--text-muted); font-size: 0.85rem; margin: -6px 0 14px; }

/* ---------- Responsive: off-canvas sidebar ---------- */

@media (max-width: 900px) {
    .nav-toggle { display: flex; }
    .topbar { padding: 0 14px; height: var(--topbar-mobile-h); }
    .user-dropdown-toggle .user-info { display: none; }
    .user-dropdown-toggle { padding: 4px; border: none; }

    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        transform: translateX(-100%);
        transition: transform .2s ease;
        z-index: 50;
        width: min(var(--sidebar-w), 82vw);
        height: 100vh;
    }
    .sidebar-brand .nav-toggle { display: flex; font-size: 1.5rem; }

    .nav-toggle-input:checked ~ .app-shell .sidebar {
        transform: translateX(0);
        box-shadow: 0 0 0 100vmax rgba(0, 0, 0, 0.35);
    }

    .content { padding: 16px 16px 20px; }
    .page-locator { padding: 8px 16px; }
}

@media (min-width: 901px) {
    .sidebar-brand .nav-toggle { display: none; }
}

@media (max-width: 700px) {
    .detail-grid { grid-template-columns: 1fr; }
}
