/* ================================================================
 * CCS Attendance Management System — Enterprise Design System v2.0
 * Mobile-First | Bootstrap 5 Compatible | PHP 8.2 Ready
 * ================================================================ */

/* ── 1. FONT IMPORT ─────────────────────────────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

/* ── 2. DESIGN TOKENS ───────────────────────────────────────────── */
:root {
    /* Brand */
    --ams-primary:          #2563EB;
    --ams-primary-dark:     #1D4ED8;
    --ams-primary-light:    #EFF6FF;
    --ams-primary-ring:     rgba(37, 99, 235, 0.22);

    /* Sidebar */
    --ams-sb-bg:            #0F172A;
    --ams-sb-hover:         rgba(255,255,255,0.07);
    --ams-sb-active-bg:     rgba(37,99,235,0.18);
    --ams-sb-active-bar:    #2563EB;
    --ams-sb-text:          #94A3B8;
    --ams-sb-text-h:        #CBD5E1;
    --ams-sb-text-a:        #FFFFFF;
    --ams-sb-border:        rgba(255,255,255,0.07);
    --ams-sb-section:       rgba(148,163,184,0.5);
    --ams-sb-w:             260px;
    --ams-sb-cw:            68px;

    /* Surfaces */
    --ams-bg:               #F1F5F9;
    --ams-surface:          #FFFFFF;
    --ams-surface-2:        #F8FAFC;

    /* Text */
    --ams-text:             #0F172A;
    --ams-text-2:           #475569;
    --ams-text-3:           #94A3B8;

    /* Borders */
    --ams-border:           #E2E8F0;
    --ams-border-2:         #CBD5E1;

    /* Topbar */
    --ams-topbar-h:         60px;

    /* Status colors */
    --ams-green:            #16A34A;
    --ams-green-bg:         #F0FDF4;
    --ams-green-ring:       rgba(22,163,74,0.2);
    --ams-amber:            #D97706;
    --ams-amber-bg:         #FFFBEB;
    --ams-amber-ring:       rgba(217,119,6,0.2);
    --ams-red:              #DC2626;
    --ams-red-bg:           #FEF2F2;
    --ams-red-ring:         rgba(220,38,38,0.2);
    --ams-sky:              #0284C7;
    --ams-sky-bg:           #F0F9FF;
    --ams-sky-ring:         rgba(2,132,199,0.2);
    --ams-violet:           #7C3AED;
    --ams-violet-bg:        #F5F3FF;
    --ams-violet-ring:      rgba(124,58,237,0.2);
    --ams-teal:             #0D9488;
    --ams-teal-bg:          #F0FDFA;
    --ams-teal-ring:        rgba(13,148,136,0.2);
    --ams-orange:           #EA580C;
    --ams-orange-bg:        #FFF7ED;
    --ams-orange-ring:      rgba(234,88,12,0.2);
    --ams-indigo:           #4F46E5;
    --ams-indigo-bg:        #EEF2FF;
    --ams-indigo-ring:      rgba(79,70,229,0.2);

    /* Shadows */
    --sh-xs:  0 1px 2px rgba(0,0,0,0.05);
    --sh-sm:  0 1px 3px rgba(0,0,0,0.09), 0 1px 2px rgba(0,0,0,0.06);
    --sh-md:  0 4px 6px rgba(0,0,0,0.07), 0 2px 4px rgba(0,0,0,0.05);
    --sh-lg:  0 10px 15px rgba(0,0,0,0.08), 0 4px 6px rgba(0,0,0,0.04);
    --sh-xl:  0 20px 25px rgba(0,0,0,0.09), 0 8px 10px rgba(0,0,0,0.04);

    /* Radii */
    --r-sm:   6px;
    --r-md:   10px;
    --r-lg:   14px;
    --r-xl:   20px;
    --r-full: 9999px;

    /* Transitions */
    --tr-fast: 150ms ease;
    --tr-base: 200ms ease;
    --tr-slow: 300ms cubic-bezier(.4, 0, .2, 1);
}

/* ── 3. BASE ─────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

html { font-size: 16px; scroll-behavior: smooth; }

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background-color: var(--ams-bg);
    color: var(--ams-text);
    margin: 0;
    padding: 0;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ── 4. SCROLLBAR ────────────────────────────────────────────────── */
::-webkit-scrollbar            { width: 5px; height: 5px; }
::-webkit-scrollbar-track      { background: transparent; }
::-webkit-scrollbar-thumb      { background: var(--ams-border-2); border-radius: var(--r-full); }
::-webkit-scrollbar-thumb:hover{ background: var(--ams-text-3); }

/* ── 5. LAYOUT WRAPPER ───────────────────────────────────────────── */
.ams-layout { display: flex; min-height: 100vh; }

/* ── 6. SIDEBAR ──────────────────────────────────────────────────── */
.ams-sidebar {
    position: fixed;
    top: 0; left: 0;
    width: var(--ams-sb-w);
    height: 100vh;
    background: var(--ams-sb-bg);
    display: flex;
    flex-direction: column;
    z-index: 1040;
    transition: width var(--tr-slow), transform var(--tr-slow);
    overflow: hidden;
    flex-shrink: 0;
}

/* Brand Area */
.sb-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 18px 16px;
    border-bottom: 1px solid var(--ams-sb-border);
    min-height: 72px;
    flex-shrink: 0;
    position: relative;
}

.sb-logo {
    width: 38px;
    height: 38px;
    background: var(--ams-primary);
    border-radius: var(--r-md);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 1.1rem;
    flex-shrink: 0;
    box-shadow: 0 0 0 3px rgba(37,99,235,0.3);
}

.sb-brand-text { overflow: hidden; }

.sb-brand-name {
    font-size: 0.9375rem;
    font-weight: 700;
    color: #fff;
    white-space: nowrap;
    letter-spacing: -0.01em;
}

.sb-brand-sub {
    font-size: 0.6563rem;
    color: var(--ams-sb-section);
    white-space: nowrap;
    margin-top: 1px;
    text-transform: uppercase;
    letter-spacing: 0.07em;
}

/* Collapse Button (Desktop) */
.sb-collapse-btn {
    position: absolute;
    top: 24px;
    right: -13px;
    width: 26px;
    height: 26px;
    background: var(--ams-surface);
    border: 1px solid var(--ams-border);
    border-radius: var(--r-full);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--ams-text-2);
    font-size: 0.6rem;
    transition: var(--tr-fast);
    z-index: 5;
    box-shadow: var(--sh-sm);
    outline: none;
}

.sb-collapse-btn:hover {
    background: var(--ams-primary);
    color: #fff;
    border-color: var(--ams-primary);
}

/* Scrollable Nav Area */
.sb-content {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 10px 0 16px;
}
.sb-content::-webkit-scrollbar { width: 0; }

/* Section Labels */
.sb-section-label {
    font-size: 0.6rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--ams-sb-section);
    padding: 14px 20px 5px;
    white-space: nowrap;
    overflow: hidden;
    transition: opacity var(--tr-base), max-height var(--tr-base);
}

/* Nav Links */
.sb-link {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 9px 14px 9px 18px;
    margin: 1px 8px;
    border-radius: var(--r-md);
    color: var(--ams-sb-text);
    text-decoration: none !important;
    font-size: 0.875rem;
    font-weight: 500;
    transition: background var(--tr-fast), color var(--tr-fast), border-color var(--tr-fast);
    white-space: nowrap;
    overflow: hidden;
    border-left: 3px solid transparent;
    line-height: 1.4;
}

.sb-link i {
    font-size: 1rem;
    flex-shrink: 0;
    width: 18px;
    text-align: center;
    transition: color var(--tr-fast);
}

.sb-link span {
    overflow: hidden;
    text-overflow: ellipsis;
    transition: opacity var(--tr-base), max-width var(--tr-slow);
}

.sb-link:hover {
    background: var(--ams-sb-hover);
    color: var(--ams-sb-text-h);
    border-left-color: rgba(37,99,235,.35);
}

.sb-link.active {
    background: var(--ams-sb-active-bg);
    color: var(--ams-sb-text-a);
    border-left-color: var(--ams-sb-active-bar);
}

.sb-link.active i { color: var(--ams-primary); }

.sb-link.sb-logout:hover {
    background: rgba(220,38,38,.12);
    color: #FCA5A5;
    border-left-color: var(--ams-red);
}

.sb-divider {
    height: 1px;
    background: var(--ams-sb-border);
    margin: 10px 16px;
}

/* ── Collapsed State ── */
.ams-layout.sb-collapsed .ams-sidebar { width: var(--ams-sb-cw); }

.ams-layout.sb-collapsed .sb-brand-text,
.ams-layout.sb-collapsed .sb-link span,
.ams-layout.sb-collapsed .sb-section-label {
    opacity: 0;
    max-width: 0;
    pointer-events: none;
}

.ams-layout.sb-collapsed .sb-link {
    padding: 9px 0;
    justify-content: center;
    border-left: 3px solid transparent;
    gap: 0;
}

.ams-layout.sb-collapsed .sb-link i { width: auto; }

/* Sidebar backdrop (mobile) */
.sb-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.52);
    z-index: 1039;
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
}

/* ── 7. MAIN CONTENT AREA ───────────────────────────────────────── */
.ams-main {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    margin-left: var(--ams-sb-w);
    transition: margin-left var(--tr-slow);
}

.ams-layout.sb-collapsed .ams-main { margin-left: var(--ams-sb-cw); }

/* ── 8. TOPBAR ──────────────────────────────────────────────────── */
.ams-topbar {
    height: var(--ams-topbar-h);
    background: var(--ams-surface);
    border-bottom: 1px solid var(--ams-border);
    display: flex;
    align-items: center;
    padding: 0 20px;
    gap: 12px;
    position: sticky;
    top: 0;
    z-index: 1030;
    box-shadow: var(--sh-xs);
    flex-shrink: 0;
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
    min-width: 0;
}

.topbar-hamburger {
    width: 36px;
    height: 36px;
    border: none;
    background: transparent;
    border-radius: var(--r-md);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--ams-text-2);
    font-size: 1.25rem;
    transition: var(--tr-fast);
    flex-shrink: 0;
    outline: none;
}

.topbar-hamburger:hover { background: var(--ams-bg); color: var(--ams-text); }

.topbar-search {
    display: flex;
    align-items: center;
    gap: 9px;
    background: var(--ams-bg);
    border: 1px solid var(--ams-border);
    border-radius: var(--r-full);
    padding: 7px 16px;
    max-width: 300px;
    width: 100%;
    transition: var(--tr-fast);
}

.topbar-search:focus-within {
    border-color: var(--ams-primary);
    box-shadow: 0 0 0 3px var(--ams-primary-ring);
    background: var(--ams-surface);
}

.topbar-search i   { color: var(--ams-text-3); font-size: 0.875rem; flex-shrink: 0; }
.topbar-search input {
    border: none;
    background: transparent;
    outline: none;
    font-size: 0.875rem;
    color: var(--ams-text);
    font-family: inherit;
    width: 100%;
}
.topbar-search input::placeholder { color: var(--ams-text-3); }

.topbar-right {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

.topbar-date {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.8125rem;
    color: var(--ams-text-2);
    font-weight: 500;
    padding: 0 6px;
    white-space: nowrap;
}
.topbar-date i { color: var(--ams-text-3); font-size: 0.8125rem; }

.topbar-divider { width: 1px; height: 22px; background: var(--ams-border); }

.topbar-icon-btn {
    width: 36px;
    height: 36px;
    border: none;
    background: transparent;
    border-radius: var(--r-md);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--ams-text-2);
    font-size: 1rem;
    transition: var(--tr-fast);
    position: relative;
    outline: none;
}
.topbar-icon-btn:hover { background: var(--ams-bg); color: var(--ams-text); }

.topbar-user {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 5px 10px;
    border-radius: var(--r-lg);
    cursor: pointer;
    transition: var(--tr-fast);
    min-width: 0;
}
.topbar-user:hover { background: var(--ams-bg); }

.user-avatar {
    width: 32px;
    height: 32px;
    background: var(--ams-primary);
    color: #fff;
    border-radius: var(--r-full);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8125rem;
    font-weight: 700;
    flex-shrink: 0;
    user-select: none;
}

.user-meta { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }

.user-fullname {
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--ams-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-role-label { font-size: 0.6875rem; color: var(--ams-text-3); white-space: nowrap; }

/* ── 9. PAGE CONTENT WRAPPER ────────────────────────────────────── */
.ams-content {
    flex: 1;
    padding: 28px 28px 48px;
    min-width: 0;
}

/* ── 10. PAGE HEADER ─────────────────────────────────────────────── */
.page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 24px;
    gap: 16px;
    flex-wrap: wrap;
}

.page-title {
    font-size: 1.375rem;
    font-weight: 700;
    color: var(--ams-text);
    margin: 0 0 4px;
    line-height: 1.3;
    letter-spacing: -0.02em;
}

.page-subtitle {
    font-size: 0.875rem;
    color: var(--ams-text-2);
    margin: 0;
    line-height: 1.5;
}

.page-header-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
    margin-top: 2px;
}

.date-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: var(--ams-surface);
    border: 1px solid var(--ams-border);
    border-radius: var(--r-full);
    padding: 6px 14px;
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--ams-text-2);
    box-shadow: var(--sh-xs);
    white-space: nowrap;
}
.date-chip i { color: var(--ams-text-3); font-size: 0.8125rem; }

/* ── 11. STAT CARDS ─────────────────────────────────────────────── */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-bottom: 20px;
}

.stat-card {
    background: var(--ams-surface);
    border: 1px solid var(--ams-border);
    border-radius: var(--r-lg);
    padding: 20px 20px 18px;
    box-shadow: var(--sh-sm);
    transition: box-shadow var(--tr-fast), transform var(--tr-fast);
    position: relative;
    overflow: hidden;
    cursor: default;
}

.stat-card::after {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 3px;
    background: var(--sc-color, var(--ams-primary));
    border-radius: var(--r-lg) var(--r-lg) 0 0;
}

.stat-card:hover {
    box-shadow: var(--sh-md);
    transform: translateY(-2px);
}

.stat-card-top {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 14px;
}

.stat-icon {
    width: 44px;
    height: 44px;
    border-radius: var(--r-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    background: var(--sc-bg, var(--ams-primary-light));
    color: var(--sc-color, var(--ams-primary));
    flex-shrink: 0;
}

.stat-trend {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    font-size: 0.6875rem;
    font-weight: 600;
    padding: 3px 8px;
    border-radius: var(--r-full);
    background: var(--ams-surface-2);
    color: var(--ams-text-3);
    white-space: nowrap;
}

.stat-value {
    font-size: 1.875rem;
    font-weight: 700;
    color: var(--ams-text);
    line-height: 1;
    margin-bottom: 5px;
    letter-spacing: -0.03em;
}

.stat-label {
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--ams-text-2);
}

.stat-sublabel {
    font-size: 0.75rem;
    color: var(--ams-text-3);
    margin-top: 4px;
    line-height: 1.4;
}

/* ── 12. QUICK ACTIONS ───────────────────────────────────────────── */
.dashboard-section { margin-bottom: 20px; }

.section-hd {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 14px;
}

.section-title {
    font-size: 0.9375rem;
    font-weight: 700;
    color: var(--ams-text);
    margin: 0;
    letter-spacing: -0.01em;
}

.section-more {
    font-size: 0.8125rem;
    color: var(--ams-primary);
    font-weight: 500;
    text-decoration: none;
    transition: color var(--tr-fast);
}
.section-more:hover { color: var(--ams-primary-dark); }

.quick-actions-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
}

.qa-card {
    background: var(--ams-surface);
    border: 1px solid var(--ams-border);
    border-radius: var(--r-lg);
    padding: 18px 16px 16px;
    text-decoration: none !important;
    display: flex;
    flex-direction: column;
    gap: 10px;
    transition: box-shadow var(--tr-fast), transform var(--tr-fast), border-color var(--tr-fast);
    position: relative;
    overflow: hidden;
    cursor: pointer;
}

.qa-card:hover {
    box-shadow: var(--sh-md);
    transform: translateY(-2px);
    border-color: var(--qa-color, var(--ams-primary));
    text-decoration: none;
}

.qa-icon {
    width: 40px;
    height: 40px;
    border-radius: var(--r-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.125rem;
    background: var(--qa-bg, var(--ams-primary-light));
    color: var(--qa-color, var(--ams-primary));
    flex-shrink: 0;
}

.qa-label {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--ams-text);
    margin: 0;
    line-height: 1.3;
}

.qa-desc {
    font-size: 0.75rem;
    color: var(--ams-text-3);
    margin: 1px 0 0;
    line-height: 1.4;
}

.qa-arrow {
    position: absolute;
    bottom: 14px;
    right: 14px;
    font-size: 0.875rem;
    color: var(--ams-text-3);
    transition: opacity var(--tr-fast), transform var(--tr-fast);
    opacity: 0;
    transform: translateX(-4px);
}

.qa-card:hover .qa-arrow {
    opacity: 1;
    transform: translateX(0);
}

/* ── 13. DASHBOARD BOTTOM GRID ───────────────────────────────────── */
.dashboard-bottom {
    display: grid;
    grid-template-columns: 1fr 360px;
    gap: 18px;
    margin-bottom: 20px;
}

/* ── 14. PANEL (generic card) ────────────────────────────────────── */
.panel {
    background: var(--ams-surface);
    border: 1px solid var(--ams-border);
    border-radius: var(--r-lg);
    box-shadow: var(--sh-sm);
    overflow: hidden;
}

.panel-hd {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--ams-border);
    flex-shrink: 0;
}

.panel-title {
    font-size: 0.9375rem;
    font-weight: 700;
    color: var(--ams-text);
    margin: 0;
}

.panel-actions { display: flex; gap: 6px; align-items: center; }

.panel-tab {
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--ams-text-3);
    padding: 4px 12px;
    border-radius: var(--r-full);
    cursor: pointer;
    border: 1px solid transparent;
    background: transparent;
    transition: var(--tr-fast);
    outline: none;
}

.panel-tab.active,
.panel-tab:hover {
    background: var(--ams-primary-light);
    color: var(--ams-primary);
    border-color: rgba(37,99,235,.2);
}

.panel-bd { padding: 20px; }

.chart-wrap { position: relative; height: 240px; }

/* ── 15. ACTIVITY FEED ───────────────────────────────────────────── */
.activity-list { display: flex; flex-direction: column; }

.activity-item {
    display: flex;
    gap: 12px;
    padding: 13px 20px;
    border-bottom: 1px solid var(--ams-border);
    transition: background var(--tr-fast);
}
.activity-item:last-child { border-bottom: none; }
.activity-item:hover { background: var(--ams-surface-2); }

.act-dot {
    width: 8px;
    height: 8px;
    border-radius: var(--r-full);
    background: var(--act-color, var(--ams-primary));
    flex-shrink: 0;
    margin-top: 5px;
}

.act-body { flex: 1; min-width: 0; }

.act-desc {
    font-size: 0.8125rem;
    color: var(--ams-text);
    font-weight: 500;
    margin-bottom: 2px;
    line-height: 1.4;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.act-meta { font-size: 0.75rem; color: var(--ams-text-3); }

.act-empty {
    padding: 32px 20px;
    text-align: center;
    color: var(--ams-text-3);
    font-size: 0.875rem;
}

/* ── 16. BUTTONS ─────────────────────────────────────────────────── */
.btn {
    font-family: inherit;
    font-weight: 500;
    border-radius: var(--r-md);
    transition: var(--tr-fast);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    font-size: 0.875rem;
    letter-spacing: 0;
}

.btn:active { transform: scale(0.98); }
.btn i { font-size: 0.9375rem; }

.btn-primary {
    background: var(--ams-primary);
    border-color: var(--ams-primary);
    color: #fff;
    box-shadow: 0 1px 2px rgba(0,0,0,.1);
}
.btn-primary:hover {
    background: var(--ams-primary-dark);
    border-color: var(--ams-primary-dark);
    color: #fff;
    box-shadow: 0 2px 8px rgba(37,99,235,.35);
}
.btn-primary:focus-visible { box-shadow: 0 0 0 3px var(--ams-primary-ring); }

.btn-secondary {
    background: var(--ams-surface);
    border: 1px solid var(--ams-border);
    color: var(--ams-text-2);
}
.btn-secondary:hover { background: var(--ams-bg); border-color: var(--ams-border-2); color: var(--ams-text); }

.btn-danger {
    background: var(--ams-red);
    border-color: var(--ams-red);
    color: #fff;
}
.btn-danger:hover { background: #B91C1C; border-color: #B91C1C; color: #fff; }

.btn-outline-primary { color: var(--ams-primary); border-color: var(--ams-primary); background: transparent; }
.btn-outline-primary:hover { background: var(--ams-primary-light); color: var(--ams-primary); }
.btn-outline-danger { color: var(--ams-red); border-color: var(--ams-red); background: transparent; }
.btn-outline-danger:hover { background: var(--ams-red-bg); color: var(--ams-red); }

/* ── 17. DATA TABLES ─────────────────────────────────────────────── */
.ams-table-wrap {
    background: var(--ams-surface);
    border: 1px solid var(--ams-border);
    border-radius: var(--r-lg);
    box-shadow: var(--sh-sm);
    overflow: hidden;
    margin-bottom: 0;
}

.ams-table-hd {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 18px;
    border-bottom: 1px solid var(--ams-border);
    flex-wrap: wrap;
    gap: 10px;
    background: var(--ams-surface);
}

.ams-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
    background: var(--ams-surface);
}

.ams-table thead th {
    background: var(--ams-bg);
    color: var(--ams-text-2);
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 11px 16px;
    border-bottom: 1px solid var(--ams-border);
    white-space: nowrap;
    user-select: none;
}

.ams-table tbody td {
    padding: 13px 16px;
    border-bottom: 1px solid var(--ams-border);
    color: var(--ams-text);
    vertical-align: middle;
}

.ams-table tbody tr:last-child td { border-bottom: none; }
.ams-table tbody tr:hover td { background: var(--ams-primary-light); }

/* Override Bootstrap default table for consistency */
.table { font-size: 0.875rem; color: var(--ams-text); }

.table th {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--ams-text-2);
    border-bottom-width: 1px;
    background: var(--ams-bg);
    padding: 11px 14px;
}

.table td { padding: 12px 14px; vertical-align: middle; color: var(--ams-text); }
.table-hover tbody tr:hover td { background: var(--ams-primary-light); }
.table-dark th { background: var(--ams-sb-bg) !important; color: var(--ams-sb-text-a); }

/* ── 18. FORMS ───────────────────────────────────────────────────── */
.form-card {
    background: var(--ams-surface);
    border: 1px solid var(--ams-border);
    border-radius: var(--r-lg);
    padding: 24px;
    box-shadow: var(--sh-sm);
    margin-bottom: 0;
}

.form-card-title {
    font-size: 0.9375rem;
    font-weight: 700;
    color: var(--ams-text);
    margin-bottom: 20px;
    padding-bottom: 14px;
    border-bottom: 1px solid var(--ams-border);
    display: flex;
    align-items: center;
    gap: 8px;
}

.form-card-title i { color: var(--ams-primary); font-size: 1.0625rem; }

.form-label {
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--ams-text-2);
    margin-bottom: 6px;
}

.form-control, .form-select {
    font-family: inherit;
    font-size: 0.875rem;
    color: var(--ams-text);
    background: var(--ams-surface);
    border: 1px solid var(--ams-border);
    border-radius: var(--r-md);
    padding: 9px 12px;
    transition: var(--tr-fast);
    width: 100%;
}

.form-control:focus, .form-select:focus {
    border-color: var(--ams-primary);
    box-shadow: 0 0 0 3px var(--ams-primary-ring);
    outline: none;
    background: var(--ams-surface);
    color: var(--ams-text);
}

.form-control::placeholder { color: var(--ams-text-3); }

.form-control-sm, .form-select-sm { font-size: 0.8125rem; padding: 7px 10px; }

.form-text { font-size: 0.75rem; color: var(--ams-text-3); margin-top: 4px; }

/* ── 19. BADGES / STATUS CHIPS ───────────────────────────────────── */
.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 10px;
    border-radius: var(--r-full);
    font-size: 0.75rem;
    font-weight: 600;
    line-height: 1.5;
    white-space: nowrap;
}

.status-present { background: var(--ams-green-bg); color: var(--ams-green); border: 1px solid var(--ams-green-ring); }
.status-absent  { background: var(--ams-red-bg);   color: var(--ams-red);   border: 1px solid var(--ams-red-ring); }
.status-od      { background: var(--ams-sky-bg);   color: var(--ams-sky);   border: 1px solid var(--ams-sky-ring); }
.status-active  { background: var(--ams-green-bg); color: var(--ams-green); border: 1px solid var(--ams-green-ring); }

.role-badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    border-radius: var(--r-full);
    font-size: 0.6875rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.role-hod   { background: var(--ams-violet-bg); color: var(--ams-violet); }
.role-staff { background: var(--ams-primary-light); color: var(--ams-primary); }
.role-cc    { background: var(--ams-teal-bg); color: var(--ams-teal); }

/* ── 20. MODALS ──────────────────────────────────────────────────── */
.modal-content {
    border: none;
    border-radius: var(--r-xl);
    box-shadow: var(--sh-xl);
    overflow: hidden;
}

.modal-header {
    background: var(--ams-surface);
    border-bottom: 1px solid var(--ams-border);
    padding: 18px 24px;
}

.modal-title {
    font-size: 1rem;
    font-weight: 700;
    color: var(--ams-text);
}

.modal-body { padding: 24px; background: var(--ams-surface); }

.modal-footer {
    background: var(--ams-surface-2);
    border-top: 1px solid var(--ams-border);
    padding: 14px 24px;
    gap: 10px;
}

/* Modal animation */
.modal.fade .modal-dialog {
    transform: scale(0.95) translateY(-10px);
    transition: transform 0.2s ease;
}
.modal.show .modal-dialog {
    transform: scale(1) translateY(0);
}

/* ── 21. TOAST NOTIFICATIONS ────────────────────────────────────── */
.ams-toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
    width: 340px;
    max-width: calc(100vw - 32px);
}

.ams-toast {
    background: var(--ams-surface);
    border: 1px solid var(--ams-border);
    border-radius: var(--r-lg);
    padding: 14px 14px 14px 16px;
    box-shadow: var(--sh-lg);
    display: flex;
    align-items: flex-start;
    gap: 11px;
    pointer-events: all;
    animation: toastIn 0.25s ease;
    border-left: 4px solid var(--toast-color, var(--ams-primary));
}

.ams-toast.toast-hiding { animation: toastOut 0.25s ease forwards; }

.toast-icon {
    width: 28px;
    height: 28px;
    border-radius: var(--r-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.875rem;
    background: var(--toast-bg, var(--ams-primary-light));
    color: var(--toast-color, var(--ams-primary));
    flex-shrink: 0;
}

.toast-content { flex: 1; min-width: 0; }

.toast-title { font-size: 0.875rem; font-weight: 600; color: var(--ams-text); margin-bottom: 2px; }

.toast-message {
    font-size: 0.8125rem;
    color: var(--ams-text-2);
    line-height: 1.4;
    word-break: break-word;
}

.toast-close {
    width: 22px;
    height: 22px;
    border: none;
    background: transparent;
    cursor: pointer;
    color: var(--ams-text-3);
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--r-sm);
    font-size: 0.75rem;
    flex-shrink: 0;
    transition: var(--tr-fast);
    padding: 0;
}

.toast-close:hover { background: var(--ams-bg); color: var(--ams-text); }

.ams-toast.toast-success { --toast-color: var(--ams-green);  --toast-bg: var(--ams-green-bg); }
.ams-toast.toast-error   { --toast-color: var(--ams-red);    --toast-bg: var(--ams-red-bg); }
.ams-toast.toast-warning { --toast-color: var(--ams-amber);  --toast-bg: var(--ams-amber-bg); }
.ams-toast.toast-info    { --toast-color: var(--ams-sky);    --toast-bg: var(--ams-sky-bg); }

/* ── 22. SKELETON LOADERS ────────────────────────────────────────── */
.skeleton {
    background: linear-gradient(90deg, var(--ams-border) 25%, var(--ams-bg) 50%, var(--ams-border) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.4s infinite;
    border-radius: var(--r-md);
}

/* ── 23. EMPTY STATE ─────────────────────────────────────────────── */
.empty-state {
    text-align: center;
    padding: 56px 24px;
    color: var(--ams-text-2);
}

.empty-state-icon {
    width: 68px;
    height: 68px;
    border-radius: var(--r-xl);
    background: var(--ams-bg);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.875rem;
    color: var(--ams-text-3);
    margin: 0 auto 18px;
}

.empty-state-title { font-size: 1rem; font-weight: 700; color: var(--ams-text); margin-bottom: 8px; }
.empty-state-desc {
    font-size: 0.875rem;
    color: var(--ams-text-2);
    margin-bottom: 20px;
    max-width: 340px;
    margin-left: auto;
    margin-right: auto;
    line-height: 1.5;
}

/* ── 24. PAGINATION ──────────────────────────────────────────────── */
.pagination { gap: 4px; }

.page-link {
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--ams-text-2);
    border: 1px solid var(--ams-border);
    border-radius: var(--r-md) !important;
    padding: 6px 12px;
    transition: var(--tr-fast);
}

.page-link:hover { background: var(--ams-bg); border-color: var(--ams-border-2); color: var(--ams-text); }

.page-item.active .page-link {
    background: var(--ams-primary);
    border-color: var(--ams-primary);
    color: #fff;
    box-shadow: 0 2px 6px rgba(37,99,235,.3);
}

.page-item.disabled .page-link { color: var(--ams-text-3); background: transparent; }

/* ── 25. ALERTS ──────────────────────────────────────────────────── */
.alert {
    border-radius: var(--r-lg);
    border: none;
    font-size: 0.875rem;
    font-weight: 500;
    padding: 12px 16px;
    border-left-width: 4px;
    border-left-style: solid;
}

.alert-success { background: var(--ams-green-bg);  color: var(--ams-green);  border-left-color: var(--ams-green); }
.alert-danger  { background: var(--ams-red-bg);    color: var(--ams-red);    border-left-color: var(--ams-red); }
.alert-warning { background: var(--ams-amber-bg);  color: var(--ams-amber);  border-left-color: var(--ams-amber); }
.alert-info    { background: var(--ams-sky-bg);    color: var(--ams-sky);    border-left-color: var(--ams-sky); }

/* ── 26. CARD OVERRIDE (Bootstrap cards) ────────────────────────── */
.card {
    border-radius: var(--r-lg);
    border: 1px solid var(--ams-border);
    box-shadow: var(--sh-sm);
    background: var(--ams-surface);
}

/* ── 27. CODE / MONOSPACE ────────────────────────────────────────── */
code {
    background: var(--ams-bg);
    color: var(--ams-text-2);
    padding: 2px 7px;
    border-radius: var(--r-sm);
    font-size: 0.8125rem;
    border: 1px solid var(--ams-border);
}

/* ── 28. LOGIN PAGE (preserved, refined) ─────────────────────────── */
.login-container {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: linear-gradient(135deg, #0F172A 0%, #1E293B 55%, #0F172A 100%);
    position: relative;
    overflow: hidden;
}

.login-container::before {
    content: '';
    position: absolute;
    width: 600px; height: 600px;
    background: radial-gradient(circle, rgba(37,99,235,.14) 0%, transparent 70%);
    top: -200px; right: -150px;
    pointer-events: none;
}

.login-header { text-align: center; margin-bottom: 28px; }

.login-header img.logo {
    width: 80px; height: auto;
    margin-bottom: 14px;
    border-radius: var(--r-lg);
    box-shadow: var(--sh-lg);
}

.login-header h2 {
    margin: 8px 0 4px;
    font-size: 1.25rem;
    font-weight: 700;
    color: #E2E8F0;
    letter-spacing: -0.02em;
}

.login-header p { font-size: 0.875rem; color: #94A3B8; margin: 0; }

.login-box {
    background: var(--ams-surface);
    padding: 36px 36px 32px;
    border-radius: var(--r-xl);
    box-shadow: var(--sh-xl);
    width: 100%;
    max-width: 420px;
    position: relative;
    z-index: 1;
}

.login-box h3 {
    text-align: center;
    margin-bottom: 24px;
    font-weight: 700;
    color: var(--ams-text);
    font-size: 1.125rem;
}

/* Form Group (login page specific) */
.form-group { margin-bottom: 18px; }

.form-group label {
    display: block;
    margin-bottom: 7px;
    font-weight: 600;
    font-size: 0.8125rem;
    color: var(--ams-text-2);
}

.form-group input, .form-group select {
    width: 100%;
    padding: 11px 13px;
    border: 1px solid var(--ams-border);
    border-radius: var(--r-md);
    box-sizing: border-box;
    font-family: inherit;
    transition: var(--tr-fast);
    font-size: 0.875rem;
    color: var(--ams-text);
    background: var(--ams-surface);
}

.form-group input:focus, .form-group select:focus {
    border-color: var(--ams-primary);
    outline: none;
    box-shadow: 0 0 0 3px var(--ams-primary-ring);
}

/* Login submit button (standalone class, not .btn.btn-primary) */
button.btn-primary:not(.btn),
input[type="submit"].btn-primary:not(.btn) {
    width: 100%;
    padding: 12px;
    background-color: var(--ams-primary);
    color: #fff;
    border: none;
    border-radius: var(--r-md);
    cursor: pointer;
    font-size: 1rem;
    font-weight: 600;
    font-family: inherit;
    transition: var(--tr-fast);
    margin-top: 4px;
}

button.btn-primary:not(.btn):hover,
input[type="submit"].btn-primary:not(.btn):hover {
    background-color: var(--ams-primary-dark);
    box-shadow: 0 4px 14px rgba(37,99,235,.35);
}

.error-msg {
    background: var(--ams-red-bg);
    color: var(--ams-red);
    padding: 12px;
    border-radius: var(--r-md);
    margin-bottom: 18px;
    text-align: center;
    border: 1px solid var(--ams-red-ring);
    font-size: 0.875rem;
    font-weight: 500;
}

.footer-text {
    margin-top: 24px;
    font-size: 0.8125rem;
    color: #64748B;
    text-align: center;
    position: relative;
    z-index: 1;
}

/* ── 29. LEGACY COMPAT (unredesigned pages) ─────────────────────── */
.dashboard-container { display: flex; min-height: 100vh; }

.sidebar {
    width: 260px;
    background-color: var(--ams-sb-bg);
    color: #fff;
    flex-shrink: 0;
    transition: var(--tr-slow);
    position: fixed;
    height: 100vh;
    z-index: 1040;
    display: flex;
    flex-direction: column;
}

.sidebar-header {
    padding: 20px 20px;
    background: rgba(0,0,0,.2);
    border-bottom: 1px solid var(--ams-sb-border);
    flex-shrink: 0;
}

.sidebar-header h3 { font-size: 1.0625rem; font-weight: 700; color: #fff; margin: 0; }

.sidebar-menu ul { list-style: none; padding: 10px 0; margin: 0; }

.sidebar-menu li a {
    display: block;
    padding: 11px 18px;
    color: var(--ams-sb-text);
    text-decoration: none;
    font-weight: 500;
    font-size: 0.875rem;
    border-left: 3px solid transparent;
    transition: var(--tr-fast);
}

.sidebar-menu li a:hover,
.sidebar-menu li a.active {
    background: var(--ams-sb-hover);
    color: var(--ams-sb-text-h);
    border-left-color: var(--ams-primary);
}

.main-content {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    margin-left: 260px;
}

.top-bar {
    background: var(--ams-surface);
    padding: 14px 22px;
    box-shadow: var(--sh-xs);
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--ams-border);
    position: sticky;
    top: 0;
    z-index: 1030;
}

.content-wrapper { padding: 24px; overflow-y: auto; flex-grow: 1; }

/* Legacy sidebar toggle */
.sidebar-toggle-btn { display: none; }

.sidebar-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.45);
    z-index: 1030;
    display: none;
    backdrop-filter: blur(2px);
}

.sidebar-backdrop.show { display: block; }

/* ── 30. UTILITIES ───────────────────────────────────────────────── */
.fw-500 { font-weight: 500; }
.fw-600 { font-weight: 600; }
.fw-700 { font-weight: 700; }
.text-right { text-align: right; }
.text-center { text-align: center; }
.mb-3 { margin-bottom: 1rem; }
.max-w-500 { max-width: 500px; }

/* ── 31. KEYFRAMES ───────────────────────────────────────────────── */
@keyframes shimmer {
    0%   { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

@keyframes toastIn {
    from { opacity: 0; transform: translateX(20px); }
    to   { opacity: 1; transform: translateX(0); }
}

@keyframes toastOut {
    from { opacity: 1; transform: translateX(0); }
    to   { opacity: 0; transform: translateX(20px); }
}

@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(14px); }
    to   { opacity: 1; transform: translateY(0); }
}

.fade-in-up { animation: fadeInUp 0.3s ease both; }

/* ── 32. RESPONSIVE ──────────────────────────────────────────────── */

/* ── Large Tablet (≤ 1279px) ── */
@media (max-width: 1279.98px) {
    .stats-grid { grid-template-columns: repeat(4, 1fr); }
    .topbar-search { max-width: 240px; }
}

/* ── Tablet (≤ 1199px) ── */
@media (max-width: 1199.98px) {
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .quick-actions-grid { grid-template-columns: repeat(3, 1fr); }
    .dashboard-bottom { grid-template-columns: 1fr; }
}

/* ── Below Sidebar Breakpoint (≤ 1023px) — Drawer Mode ── */
@media (max-width: 1023.98px) {
    /* New sidebar as drawer */
    .ams-sidebar {
        transform: translateX(-100%);
        width: var(--ams-sb-w) !important;
    }

    .ams-layout.sb-open .ams-sidebar {
        transform: translateX(0);
        box-shadow: var(--sh-xl);
    }

    .ams-layout.sb-open .sb-backdrop { display: block; }

    .ams-main { margin-left: 0 !important; }

    .sb-collapse-btn { display: none !important; }

    /* Legacy sidebar */
    .sidebar {
        transform: translateX(-100%);
        box-shadow: 4px 0 20px rgba(0,0,0,.18);
    }

    .sidebar.show { transform: translateX(0); }

    .sidebar-toggle-btn { display: inline-flex !important; }

    .main-content { margin-left: 0; }
}

/* ── Mobile (≤ 767px) ── */
@media (max-width: 767.98px) {
    .ams-content { padding: 16px 14px 40px; }
    .stats-grid { grid-template-columns: 1fr 1fr; gap: 11px; }
    .quick-actions-grid { grid-template-columns: 1fr 1fr; }
    .topbar-search { display: none; }
    .topbar-date { display: none; }
    .topbar-divider { display: none; }
    .page-title { font-size: 1.25rem; }
    .page-header { margin-bottom: 18px; }
    .dashboard-bottom { grid-template-columns: 1fr; }
    .content-wrapper { padding: 14px; }

    .btn-responsive-full {
        width: 100% !important;
        justify-content: center;
        margin-left: 0 !important;
        margin-top: 8px;
    }
}

/* ── Small Mobile (≤ 480px) ── */
@media (max-width: 480px) {
    .stats-grid { gap: 10px; }
    .quick-actions-grid { grid-template-columns: 1fr 1fr; }
    .stat-value { font-size: 1.625rem; }
}
