/* iTAMS – DepEd Division of Sagay City */
/* Design: Government-utility meets editorial precision */

:root {
    --deped-blue: #008000;
    --deped-blue-dark: #005A00;
    --deped-blue-light: #009A00;
    --accent: #F5A623;
    --accent-green: #27AE60;
    --accent-red: #E74C3C;
    --accent-purple: #8B5CF6;
    --bg: #F0F4FA;
    --surface: #FFFFFF;
    --surface-2: #F7F9FC;
    --border: #DDE4EF;
    --text-primary: #0D1B3E;
    --text-secondary: #5A6A8A;
    --text-muted: #9AA6BC;
    --sidebar-w: 260px;
    --sidebar-collapsed: 70px;
    --topbar-h: 60px;
    --radius: 12px;
    --radius-sm: 8px;
    --shadow: 0 2px 12px rgba(0,71,171,0.08);
    --shadow-md: 0 4px 24px rgba(0,71,171,0.12);
    --transition: all 0.22s cubic-bezier(.4,0,.2,1);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
    overflow-x: clip;
    max-width: 100%;
}

body {
    font-family: 'Roboto', sans-serif;
    background: var(--bg);
    color: var(--text-primary);
    font-size: 14px;
    line-height: 1.6;
    overflow-x: clip;
    max-width: 100%;
}

/* Responsive Media */
img, video, canvas, svg, iframe {
    max-width: 100%;
    height: auto;
}

/* ── APP SHELL ─────────────────────────────── */
.app-shell {
    display: flex;
    min-height: 100vh;
    overflow-x: clip;
    max-width: 100%;
}

/* ── SIDEBAR ───────────────────────────────── */
.sidebar {
    width: var(--sidebar-w);
    background: #008000;
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    z-index: 100;
    overflow: hidden;
    flex-shrink: 0;
}

.sidebar.collapsed {
    width: var(--sidebar-collapsed);
}
.sidebar.collapsed .brand-text,
.sidebar.collapsed .nav-item span:not(.badge-ai),
.sidebar.collapsed .nav-section-label,
.sidebar.collapsed .user-info,
.sidebar.collapsed .badge-ai {
    display: none;
}
.sidebar.collapsed .nav-item {
    justify-content: center;
    padding: 12px;
}
.sidebar.collapsed .nav-item i {
    margin: 0;
}

.sidebar-brand {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 18px 14px 14px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    min-height: auto;
}

.brand-mark {
    width: 36px; height: 36px;
    background: var(--accent);
    border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    font-family: 'Roboto', sans-serif;
    font-weight: 800;
    font-size: 18px;
    color: var(--deped-blue-dark);
    flex-shrink: 0;
}

.brand-text strong {
    display: block;
    font-family: 'Roboto', sans-serif;
    font-weight: 700;
    color: #fff;
    font-size: 14px;
    letter-spacing: 0.03em;
    line-height: 1.2;
}
.brand-text small {
    color: rgba(255,255,255,0.5);
    font-size: 9px;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    line-height: 1.2;
}

.sidebar-nav {
    flex: 1;
    padding: 16px 0;
    overflow-y: auto;
    overflow-x: hidden;
    max-height: calc(100vh - 140px);
}
.sidebar-nav::-webkit-scrollbar { width: 3px; }
.sidebar-nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.15); border-radius: 3px; }

.nav-section-label {
    color: rgba(255,255,255,0.7);
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    padding: 12px 20px 4px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 20px;
    color: #fff;
    text-decoration: none;
    border-radius: 0;
    transition: var(--transition);
    font-size: 13.5px;
    font-weight: 700;
    position: relative;
}
.nav-item:hover { background: rgba(255,255,255,0.1); color: #fff; }
.nav-item.active {
    background: rgba(255,255,255,0.18);
    color: #fff;
    font-weight: 700;
}
.nav-item.active::before {
    content: '';
    position: absolute;
    left: 0; top: 0; bottom: 0;
    width: 3px;
    background: var(--accent);
    border-radius: 0 3px 3px 0;
}
.nav-item i { width: 18px; text-align: center; font-size: 14px; }

.badge-ai {
    margin-left: auto;
    background: var(--accent-purple);
    color: #fff;
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 0.06em;
    padding: 2px 6px;
    border-radius: 4px;
}

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 16px;
    border-top: 1px solid rgba(255,255,255,0.1);
    background: rgba(0,0,0,0.15);
}
.user-avatar {
    width: 34px; height: 34px;
    background: var(--accent);
    border-radius: 8px;
    display: flex; align-items: center; justify-content: center;
    font-family: 'Roboto', sans-serif;
    font-weight: 700;
    font-size: 12px;
    color: var(--deped-blue-dark);
    flex-shrink: 0;
}
.user-name { display: block; color: #fff; font-size: 12.5px; font-weight: 500; }
.user-role { display: block; color: rgba(255,255,255,0.45); font-size: 10.5px; }
.logout-btn { margin-left: auto; color: rgba(255,255,255,0.4); text-decoration: none; font-size: 14px; transition: var(--transition); }
.logout-btn:hover { color: #fff; }

/* ── MAIN WRAP ─────────────────────────────── */
.main-wrap {
    margin-left: var(--sidebar-w);
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    min-width: 0;
    overflow-x: clip;
}
.sidebar.collapsed ~ .main-wrap { margin-left: var(--sidebar-collapsed); }

.topbar {
    height: var(--topbar-h);
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 0 24px;
    position: sticky; top: 0;
    z-index: 50;
    box-shadow: 0 1px 4px rgba(0,71,171,0.06);
}
.sidebar-toggle { background: none; border: none; cursor: pointer; color: var(--text-secondary); font-size: 16px; padding: 6px; }
.topbar-title {
    font-family: 'Roboto', sans-serif;
    font-weight: 700;
    font-size: 15px;
    color: var(--text-primary);
}
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 12px; }

.cycle-badge {
    background: var(--bg);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    padding: 5px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
    display: flex; align-items: center; gap: 6px;
}
.notif-btn { background: none; border: none; cursor: pointer; color: var(--text-secondary); font-size: 16px; position: relative; padding: 6px; }
.notif-dot {
    width: 7px; height: 7px;
    background: var(--accent-red);
    border-radius: 50%;
    position: absolute; top: 4px; right: 4px;
    border: 2px solid var(--surface);
}

.content-area { flex: 1; padding: 28px; }

/* ── ALERTS ────────────────────────────────── */
.alert {
    display: flex; align-items: center; gap: 10px;
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    margin-bottom: 20px;
    font-size: 13.5px;
}
.alert-success { background: #E8F8F0; color: #1a7a48; border: 1px solid #A8E6C3; }
.alert-error { background: #FEE8E7; color: #8B1A1A; border: 1px solid #F5C0BC; }

/* ── PAGE HEADER ───────────────────────────── */
.page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 28px;
}
.page-header h1 {
    font-family: 'Roboto', sans-serif;
    font-weight: 700;
    font-size: 22px;
    color: var(--text-primary);
}
.page-header p {
    color: var(--text-secondary);
    font-size: 13px;
    margin-top: 3px;
}

/* ── CARDS ─────────────────────────────────── */
.card {
    background: var(--surface);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
}
.card-header {
    padding: 18px 22px 14px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.card-title {
    font-family: 'Roboto', sans-serif;
    font-weight: 700;
    font-size: 14px;
    color: var(--text-primary);
}
.card-body { padding: 22px; }

/* ── STAT CARDS ────────────────────────────── */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 18px;
    margin-bottom: 28px;
}

.stat-card {
    background: var(--surface);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    padding: 20px 22px;
    display: flex;
    align-items: flex-start;
    gap: 16px;
    box-shadow: var(--shadow);
    transition: var(--transition);
}
.stat-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }

.stat-icon {
    width: 44px; height: 44px;
    border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
}
.stat-icon.blue { background: #EEF3FF; color: var(--deped-blue); }
.stat-icon.green { background: #E8F8F0; color: var(--accent-green); }
.stat-icon.amber { background: #FFF8EE; color: var(--accent); }
.stat-icon.red { background: #FEE8E7; color: var(--accent-red); }
.stat-icon.purple { background: #F3EEFF; color: var(--accent-purple); }

.stat-label { font-size: 11.5px; color: var(--text-muted); font-weight: 500; text-transform: uppercase; letter-spacing: 0.05em; }
.stat-value {
    font-family: 'Roboto', sans-serif;
    font-weight: 700;
    font-size: 26px;
    color: var(--text-primary);
    line-height: 1.1;
}
.stat-sub { font-size: 11.5px; color: var(--text-muted); margin-top: 3px; }
.stat-change {
    font-size: 11px;
    font-weight: 600;
    padding: 2px 6px;
    border-radius: 4px;
    margin-top: 4px;
    display: inline-block;
}
.stat-change.up { background: #E8F8F0; color: var(--accent-green); }
.stat-change.down { background: #FEE8E7; color: var(--accent-red); }

/* ── CONTENT GRID ──────────────────────────── */
.content-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 20px;
}
.content-grid.three { grid-template-columns: 1fr 1fr 1fr; }
.span-2 { grid-column: span 2; }

/* ── TABLE ─────────────────────────────────── */
.data-table {
    width: 100%;
    border-collapse: collapse;
}
.data-table th {
    padding: 10px 14px;
    text-align: left;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    border-bottom: 1px solid var(--border);
    background: var(--surface-2);
}
.data-table td {
    padding: 13px 14px;
    border-bottom: 1px solid var(--border);
    font-size: 13.5px;
    color: var(--text-primary);
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover { background: var(--surface-2); }

/* ── BADGES ────────────────────────────────── */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
}
.badge-success { background: #E8F8F0; color: #1a7a48; }
.badge-warning { background: #FFF8EE; color: #B36A00; }
.badge-danger { background: #FEE8E7; color: #8B1A1A; }
.badge-info { background: #EEF3FF; color: var(--deped-blue); }
.badge-purple { background: #F3EEFF; color: #6D28D9; }
.badge-gray { background: #F3F5F8; color: var(--text-secondary); }

/* ── BUTTONS ───────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 9px 18px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    border: none;
    text-decoration: none;
    transition: var(--transition);
    font-family: 'Roboto', sans-serif;
}
.btn-primary { background: #008000; color: #fff; }
.btn-primary:hover { background: #009A00; }
.btn-accent { background: var(--accent); color: var(--deped-blue-dark); }
.btn-accent:hover { background: #e09400; }
.btn-outline { background: transparent; border: 1.5px solid var(--border); color: var(--text-secondary); }
.btn-outline:hover { border-color: #008000; color: #008000; }
.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-danger { background: var(--accent-red); color: #fff; }
.btn-danger:hover { background: #c0392b; }

/* ── FORMS ─────────────────────────────────── */
.form-group { margin-bottom: 18px; }
.form-label {
    display: block;
    font-size: 12.5px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 6px;
    letter-spacing: 0.02em;
}
.form-control {
    width: 100%;
    padding: 9px 13px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 13.5px;
    color: var(--text-primary);
    background: var(--surface);
    font-family: 'Roboto', sans-serif;
    transition: var(--transition);
    outline: none;
}
.form-control:focus { border-color: var(--deped-blue); box-shadow: 0 0 0 3px rgba(0,128,0,0.08); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-grid.three { grid-template-columns: 1fr 1fr 1fr; }

/* ── FLOWCHART PROCESS INDICATOR ───────────── */
.process-steps {
    display: flex;
    align-items: center;
    gap: 0;
    overflow-x: auto;
    padding-bottom: 4px;
    margin-bottom: 24px;
}
.process-step {
    display: flex;
    align-items: center;
    gap: 0;
}
.step-node {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    min-width: 90px;
}
.step-circle {
    width: 32px; height: 32px;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 12px;
    font-weight: 700;
    border: 2px solid var(--border);
    background: var(--surface);
    color: var(--text-muted);
    font-family: 'Roboto', sans-serif;
}
.step-circle.done { background: var(--accent-green); border-color: var(--accent-green); color: #fff; }
.step-circle.active { background: var(--deped-blue); border-color: var(--deped-blue); color: #fff; box-shadow: 0 0 0 4px rgba(0,128,0,0.18); }
.step-circle.pending { background: var(--surface-2); }
.step-label { font-size: 10px; color: var(--text-muted); text-align: center; }
.step-label.active { color: var(--deped-blue); font-weight: 600; }
.step-connector { width: 30px; height: 2px; background: var(--border); margin-bottom: 18px; flex-shrink: 0; }
.step-connector.done { background: var(--accent-green); }

/* ── PROGRESS BAR ──────────────────────────── */
.progress-bar-wrap {
    background: var(--border);
    border-radius: 20px;
    height: 8px;
    overflow: hidden;
}
.progress-bar-fill {
    height: 100%;
    border-radius: 20px;
    background: var(--deped-blue);
    transition: width 0.6s ease;
}
.progress-bar-fill.green { background: var(--accent-green); }
.progress-bar-fill.amber { background: var(--accent); }
.progress-bar-fill.red { background: var(--accent-red); }

/* ── ANALYTICS ─────────────────────────────── */
.ai-insight-box {
    background: linear-gradient(135deg, #EEF3FF 0%, #F3EEFF 100%);
    border: 1.5px solid #C5D5FF;
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 20px;
    display: flex;
    gap: 14px;
    align-items: flex-start;
}
.ai-insight-icon {
    width: 40px; height: 40px;
    background: var(--deped-blue);
    border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    color: #fff;
    font-size: 16px;
    flex-shrink: 0;
}
.ai-insight-content h4 {
    font-family: 'Roboto', sans-serif;
    font-weight: 700;
    font-size: 13px;
    color: var(--deped-blue-dark);
    margin-bottom: 4px;
}
.ai-insight-content p { font-size: 13px; color: var(--text-secondary); }

/* ── LOGIN ─────────────────────────────────── */
.login-page {
    min-height: 100vh;
    background: var(--deped-blue-dark);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
}
.login-page::before {
    content: '';
    position: absolute;
    width: 600px; height: 600px;
    background: radial-gradient(circle, rgba(245,166,35,0.12) 0%, transparent 70%);
    top: -200px; right: -100px;
}
.login-box {
    background: var(--surface);
    border-radius: 20px;
    padding: 44px 40px;
    width: 420px;
    box-shadow: 0 24px 60px rgba(0,0,0,0.3);
    position: relative;
    z-index: 1;
}
.login-logo {
    display: flex; align-items: center; gap: 14px;
    justify-content: center;
    margin-bottom: 28px;
}
.login-brand-mark {
    width: 50px; height: 50px;
    background: var(--deped-blue);
    border-radius: 14px;
    display: flex; align-items: center; justify-content: center;
    font-family: 'Roboto', sans-serif;
    font-weight: 800;
    font-size: 22px;
    color: var(--accent);
}
.login-box h2 {
    font-family: 'Roboto', sans-serif;
    font-weight: 800;
    font-size: 26px;
    color: var(--text-primary);
    text-align: center;
    margin-bottom: 4px;
}
.login-box p {
    text-align: center;
    color: var(--text-muted);
    font-size: 12.5px;
    margin-bottom: 32px;
}
.login-box .btn { width: 100%; justify-content: center; padding: 12px; font-size: 14px; font-weight: 600; margin-top: 6px; }

/* ── EMPTY STATE ───────────────────────────── */
.empty-state {
    text-align: center;
    padding: 48px 24px;
    color: var(--text-muted);
}
.empty-state i { font-size: 40px; margin-bottom: 14px; opacity: 0.4; }
.empty-state p { font-size: 13.5px; }

/* ── UTILITY ───────────────────────────────── */
.text-right { text-align: right; }
.text-center { text-align: center; }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.mb-3 { margin-bottom: 24px; }
.flex { display: flex; }
.flex-center { display: flex; align-items: center; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.fw-600 { font-weight: 600; }
.text-muted { color: var(--text-muted); }
.text-sm { font-size: 12px; }
.gap-1 { gap: 4px; }
.mb-4 { margin-bottom: 32px; }
.italic { font-style: italic; }

/* Alert danger alias */
.alert-danger { background: #FEE8E7; color: #8B1A1A; border: 1px solid #F5C0BC; }

/* Tables scroll on all viewports — hidden overflow is set per-card in responsive */
.card { overflow: hidden; }

/* ── RESPONSIVE ────────────────────────────── */

/* Tablet (≤1024px) */
@media (max-width: 1024px) {
    .content-grid, .content-grid.three { grid-template-columns: 1fr !important; }
    .span-2 { grid-column: span 1; }
    .form-grid, .form-grid.three { grid-template-columns: 1fr 1fr; }
    [style*="grid-template-columns:1fr 1fr 1fr"],
    [style*="grid-template-columns: 1fr 1fr 1fr"] {
        grid-template-columns: 1fr 1fr !important;
    }
    /* User role stats grid (11 col): collapse to 4 on tablet */
    [style*="grid-template-columns:repeat(11,"],
    [style*="grid-template-columns: repeat(11,"],
    [style*="grid-template-columns:repeat(11, "] {
        grid-template-columns: repeat(4, 1fr) !important;
    }
}

/* Mobile (≤768px) */
@media (max-width: 768px) {
    /* ── Sidebar: off-canvas slide ── */
    .sidebar {
        transform: translateX(-100%);
        z-index: 200;
    }
    .sidebar.mobile-open {
        transform: translateX(0);
        box-shadow: 4px 0 30px rgba(0,0,0,0.35);
    }
    .sidebar-overlay {
        display: none;
        position: fixed;
        inset: 0;
        background: rgba(0,0,0,0.4);
        z-index: 199;
    }
    .sidebar-overlay.active { display: block; }

    /* ── Layout ── */
    .main-wrap { margin-left: 0 !important; }
    .content-area { padding: 14px; }

    /* ── Forms ── */
    .form-grid, .form-grid.three { grid-template-columns: 1fr; }

    /* ── Stat cards: 2 columns on mobile ── */
    .stat-grid {
        grid-template-columns: 1fr 1fr !important;
    }
    [style*="grid-template-columns:repeat(4,1fr)"],
    [style*="grid-template-columns: repeat(4, 1fr)"],
    [style*="grid-template-columns:repeat(3,1fr)"],
    [style*="grid-template-columns: repeat(3, 1fr)"] {
        grid-template-columns: 1fr 1fr !important;
    }


    /* ── Tables: Stacked card layout on mobile (no horizontal scroll) ── */
    .card { overflow: hidden; }

    /* Hide the table header row — labels come from data-label CSS */
    table.data-table {
        min-width: 0 !important;
        white-space: normal !important;
    }
    table.data-table thead {
        display: none;
    }

    /* Each row becomes a card */
    table.data-table tbody tr {
        display: block;
        background: var(--surface);
        border: 1px solid var(--border);
        border-radius: var(--radius-sm);
        margin-bottom: 10px;
        overflow: hidden;
    }
    table.data-table tbody tr:hover {
        background: var(--surface);
    }

    /* Each cell becomes a flex row: label on left, value on right */
    table.data-table tbody td {
        display: flex;
        align-items: flex-start;
        justify-content: space-between;
        gap: 10px;
        padding: 9px 14px;
        border-bottom: 1px solid var(--border);
        font-size: 13px;
        text-align: right;
        min-height: 0;
        white-space: normal;
    }
    table.data-table tbody td:last-child {
        border-bottom: none;
    }

    /* The data-label pseudo-element = column header text */
    table.data-table tbody td[data-label]::before {
        content: attr(data-label);
        font-size: 10.5px;
        font-weight: 700;
        color: var(--text-muted);
        text-transform: uppercase;
        letter-spacing: 0.05em;
        white-space: nowrap;
        flex-shrink: 0;
        text-align: left;
        margin-top: 2px;
        min-width: 80px;
    }

    /* Action cells: left-align buttons */
    table.data-table tbody td:last-child {
        justify-content: flex-end;
    }
    table.data-table tbody td:last-child::before {
        display: none;
    }

    /* Empty state row: show as normal block */
    table.data-table tbody tr:has(td[colspan]) {
        display: table-row;
    }
    table.data-table tbody td[colspan] {
        display: table-cell;
    }


    /* ── Multi-col inline grids: stack or reduce ── */
    [style*="grid-template-columns:1fr 1fr"],
    [style*="grid-template-columns: 1fr 1fr"],
    [style*="grid-template-columns:1fr 1fr 1fr"],
    [style*="grid-template-columns: 1fr 1fr 1fr"] {
        grid-template-columns: 1fr !important;
    }
    /* User role stats grid (11 col) → 3 columns on phone */
    [style*="grid-template-columns:repeat(11,"],
    [style*="grid-template-columns: repeat(11,"],
    [style*="grid-template-columns:repeat(11, "] {
        grid-template-columns: repeat(3, 1fr) !important;
    }

    /* ── Page header: stack ── */
    .page-header {
        flex-direction: column;
        gap: 12px;
        align-items: flex-start;
    }
    .page-header .btn { width: 100%; justify-content: center; }

    /* ── Filter / search forms inside cards: stack ── */
    .card-body form[style*="display:flex"],
    .card-body form[style*="display: flex"],
    .card > form[style*="display:flex"],
    .card > form[style*="display: flex"] {
        flex-direction: column !important;
        gap: 10px !important;
    }
    .card-body form[style*="display:flex"] > *,
    .card-body form[style*="display: flex"] > *,
    .card > form[style*="display:flex"] > *,
    .card > form[style*="display: flex"] > * {
        min-width: 100% !important;
        width: 100% !important;
        flex: none !important;
    }

    /* ── Card-header search rows: stack ── */
    .card-header {
        flex-wrap: wrap;
        gap: 10px;
    }
    .card-header > div[style*="display:flex"],
    .card-header > div[style*="display: flex"] {
        flex-wrap: wrap;
        gap: 8px;
        width: 100%;
    }
    .card-header form {
        flex-direction: column !important;
        width: 100%;
    }
    .card-header form input[type="text"],
    .card-header form .form-control {
        min-width: 0 !important;
        width: 100% !important;
    }
    .card-header form .btn { width: 100%; justify-content: center; }

    /* ── Action button groups: wrap ── */
    .flex.gap-2, .flex.gap-1 { flex-wrap: wrap; }

    /* ── AI insight: stack ── */
    .ai-insight-box { flex-direction: column; }

    /* ── Topbar compact & sticky ── */
    .cycle-badge { display: none !important; }
    .topbar-title {
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        max-width: 160px;
        font-size: 13px;
    }
    .topbar { 
        position: sticky !important; 
        top: 0 !important; 
        z-index: 100 !important; 
        padding: 0 12px; 
        gap: 6px; 
        background-color: var(--surface) !important;
        box-shadow: 0 2px 8px rgba(0,0,0,0.1) !important;
    }

    /* ── Notifications dropdown ── */
    #notifMenu {
        width: min(340px, calc(100vw - 24px)) !important;
        right: -8px !important;
    }

    /* ── Dashboard workflow: horizontal scroll ── */
    .workflow-container {
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch;
        padding-bottom: 8px;
        justify-content: flex-start !important;
        min-width: max-content;
    }
    #workflow-card .card-body { overflow-x: auto !important; }

    /* ── Tab bars: horizontal scroll ── */
    div[style*="border-bottom:2px solid var(--border)"],
    div[style*="border-bottom: 2px solid var(--border)"] {
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch;
        flex-wrap: nowrap !important;
    }

    /* ── Login box ── */
    .login-box {
        width: calc(100vw - 32px) !important;
        padding: 32px 20px !important;
    }

    /* ── Modals ── */
    div[id*="Modal_"] > div {
        padding: 24px 20px !important;
        width: 94vw !important;
    }
    #feedbackModal {
        width: 95vw !important;
        padding: 0 !important;
    }

    /* ── Feedback FAB: smaller ── */
    #feedbackTrigger {
        width: 44px !important;
        height: 44px !important;
        font-size: 17px !important;
        bottom: 16px !important;
        right: 16px !important;
    }
}

/* Extra small (≤480px) */
@media (max-width: 480px) {
    .stat-grid,
    [style*="grid-template-columns:repeat(4,1fr)"],
    [style*="grid-template-columns: repeat(4, 1fr)"],
    [style*="grid-template-columns:repeat(3,1fr)"],
    [style*="grid-template-columns: repeat(3, 1fr)"],
    [style*="grid-template-columns:repeat(2,1fr)"],
    [style*="grid-template-columns: repeat(2, 1fr)"] {
        grid-template-columns: 1fr 1fr !important;
    }
    /* Role stat grid: 3 col even on smallest screens (readable) */
    [style*="grid-template-columns:repeat(11,"],
    [style*="grid-template-columns: repeat(11,"],
    [style*="grid-template-columns:repeat(11, "] {
        grid-template-columns: repeat(3, 1fr) !important;
    }
    .stat-value { font-size: 22px; }
    .page-header h1 { font-size: 18px; }
    .topbar { padding: 0 10px; gap: 4px; }
    .topbar-title { max-width: 130px; font-size: 12.5px; }
    .step-node { min-width: 65px; }
    .step-label { font-size: 9px; }
}

/* ── PAGINATION ─────────────────────────────── */
.pagination {
    display: flex;
    align-items: center;
    list-style: none;
    gap: 6px;
    padding: 16px 0 4px;
    margin: 0;
    flex-wrap: wrap;
}
.pagination li { margin: 0; }
.pagination li a,
.pagination li span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 32px;
    height: 32px;
    padding: 0 10px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    text-decoration: none;
    transition: var(--transition);
    border: 1.5px solid var(--border);
    background: var(--surface);
    color: var(--text-secondary);
}
.pagination li a:hover {
    border-color: var(--deped-blue);
    color: var(--deped-blue);
    background: #EEF3FF;
}
.pagination li.active span {
    background: var(--deped-blue);
    color: #fff;
    border-color: var(--deped-blue);
    font-weight: 700;
}
.pagination li.disabled span {
    opacity: 0.4;
    cursor: not-allowed;
    background: var(--surface-2);
}

