:root {
    --school-red: #b7192b;
    --school-yellow: #f7c948;
    --ink: #202431;
    --muted: #6a7486;
    --surface: #ffffff;
    --line: rgba(26, 32, 44, 0.10);
    --bg: #f6f7fb;
    --shadow: 0 18px 55px rgba(48, 28, 36, 0.12);
}

[data-bs-theme="dark"] {
    --ink: #f6f7fb;
    --muted: #b8c2d2;
    --surface: #171b25;
    --line: rgba(255, 255, 255, 0.12);
    --bg: #0f131b;
    --shadow: 0 18px 55px rgba(0, 0, 0, 0.32);
}

body {
    font-family: "Sarabun", system-ui, sans-serif;
    color: var(--ink);
    background: var(--bg);
}

.btn-school {
    color: #fff;
    background: linear-gradient(135deg, var(--school-red), #e44d31);
    border: 0;
    box-shadow: 0 12px 26px rgba(183, 25, 43, 0.22);
}

.btn-school:hover {
    color: #fff;
}

.auth-body {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
    background: radial-gradient(circle at 20% 20%, rgba(247, 201, 72, 0.35), transparent 32%), linear-gradient(135deg, #801222, #b7192b 48%, #f7c948);
}

.auth-card {
    display: grid;
    grid-template-columns: 1fr 420px;
    width: min(980px, 100%);
    overflow: hidden;
    background: rgba(255, 255, 255, 0.82);
    border: 1px solid rgba(255, 255, 255, 0.50);
    border-radius: 8px;
    box-shadow: var(--shadow);
    backdrop-filter: blur(18px);
}

.auth-visual {
    padding: 54px;
    color: #fff;
    background: linear-gradient(135deg, rgba(42, 15, 20, 0.86), rgba(183, 25, 43, 0.72)), url("../images/school-hero.png") center/cover;
}

.brand-mark {
    display: inline-grid;
    place-items: center;
    color: #fff;
    background: linear-gradient(135deg, var(--school-red), var(--school-yellow));
    border-radius: 10px;
}

.brand-mark.big {
    width: 74px;
    height: 74px;
    font-size: 34px;
}

.auth-form {
    padding: 46px;
    background: var(--surface);
}

.auth-form h2,
.auth-visual h1 {
    font-weight: 800;
}

.back-home {
    display: inline-flex;
    gap: 8px;
    margin-top: 18px;
    color: var(--muted);
}

.admin-body {
    min-height: 100vh;
}

.admin-sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 20;
    width: 278px;
    padding: 22px;
    overflow-y: auto;
    color: #fff;
    background: linear-gradient(180deg, #064e3b 0%, #047857 55%, #059669 100%);
    box-shadow: 2px 0 20px rgba(6,78,59,.22);
}

/* Custom scrollbar for sidebar */
.admin-sidebar::-webkit-scrollbar {
    width: 6px;
}
.admin-sidebar::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.1);
}
.admin-sidebar::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.3);
    border-radius: 10px;
}

.admin-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 26px;
    color: #fff;
    font-size: 1.2rem;
    font-weight: 800;
}

.admin-brand span {
    display: grid;
    place-items: center;
    width: 42px;
    height: 42px;
    color: #064e3b;
    background: linear-gradient(135deg, #6ee7b7, #34d399);
    border-radius: 10px;
    box-shadow: 0 3px 10px rgba(52,211,153,.35);
}

.admin-sidebar a:not(.admin-brand) {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    margin-bottom: 6px;
    color: rgba(255, 255, 255, 0.86);
    border-radius: 8px;
    text-decoration: none;
}

.sidebar-section-label {
    padding: 14px 20px 4px;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.4);
    user-select: none;
}

.admin-sidebar a:not(.admin-brand):hover {
    background: rgba(255, 255, 255, 0.14);
    color: #fff;
}

.admin-sidebar a:not(.admin-brand).active,
.admin-sidebar a:not(.admin-brand)[aria-current="page"] {
    background: rgba(255, 255, 255, 0.18);
    color: #fff;
    border-left: 3px solid #6ee7b7;
    padding-left: 11px;
}

.admin-shell {
    margin-left: 278px;
}

.admin-topbar {
    position: sticky;
    top: 0;
    z-index: 10;
    display: flex;
    align-items: center;
    gap: 14px;
    min-height: 76px;
    padding: 14px 28px;
    background: rgba(246, 247, 251, 0.86);
    border-bottom: 1px solid var(--line);
    backdrop-filter: blur(16px);
}

[data-bs-theme="dark"] .admin-topbar {
    background: rgba(15, 19, 27, 0.86);
}

.admin-topbar small {
    display: block;
    color: var(--muted);
}

.admin-content {
    padding: 28px;
}

.icon-btn {
    width: 42px;
    height: 42px;
    padding: 0;
    color: var(--ink);
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
}

.admin-user {
    display: inline-flex;
    padding: 8px 12px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 999px;
}

.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 18px;
}

.stat-card,
.admin-panel,
.side-box {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
}

.stat-card {
    position: relative;
    overflow: hidden;
    padding: 24px;
}

.stat-card::after {
    content: "";
    position: absolute;
    right: -30px;
    bottom: -36px;
    width: 120px;
    height: 120px;
    background: currentColor;
    border-radius: 50%;
    opacity: 0.10;
}

.stat-card i {
    display: grid;
    place-items: center;
    width: 48px;
    height: 48px;
    margin-bottom: 16px;
    color: #fff;
    border-radius: 8px;
}

.stat-card span {
    color: var(--muted);
}

.stat-card strong {
    display: block;
    margin-top: 8px;
    font-size: 2rem;
    font-weight: 800;
}

.stat-card.red { color: #b7192b; }
.stat-card.yellow { color: #c18a09; }
.stat-card.blue { color: #2563eb; }
.stat-card.green { color: #16885f; }
.stat-card.red i { background: #b7192b; }
.stat-card.yellow i { background: #d99d21; }
.stat-card.blue i { background: #2563eb; }
.stat-card.green i { background: #16885f; }

.admin-panel,
.side-box {
    padding: 24px;
}

.panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    margin-bottom: 22px;
}

.panel-head h2 {
    margin: 0;
    font-size: 1.3rem;
    font-weight: 800;
}

.panel-head p,
.panel-head span {
    margin: 0;
    color: var(--muted);
}

.chart-placeholder {
    display: flex;
    align-items: end;
    gap: 16px;
    height: 280px;
    padding: 18px;
    background: linear-gradient(180deg, rgba(247, 201, 72, 0.18), rgba(183, 25, 43, 0.08));
    border-radius: 8px;
}

.chart-placeholder div {
    flex: 1;
    min-height: 42px;
    background: linear-gradient(180deg, var(--school-yellow), var(--school-red));
    border-radius: 8px 8px 0 0;
}

.quick-actions {
    display: grid;
    gap: 12px;
}

.quick-actions a,
.security-list span {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 13px 14px;
    color: var(--ink);
    background: rgba(104, 116, 134, 0.08);
    border-radius: 8px;
    text-decoration: none;
}

.security-list {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.security-list i {
    color: #16885f;
}

.table-thumb {
    width: 72px;
    height: 52px;
    object-fit: cover;
    border-radius: 8px;
}

.table td small {
    display: block;
    color: var(--muted);
}

.preview-image {
    width: 100%;
    margin-top: 14px;
    border-radius: 8px;
}

.swal2-popup {
    font-family: "Sarabun", system-ui, sans-serif;
}

@media (max-width: 991.98px) {
    .auth-card {
        grid-template-columns: 1fr;
    }

    .auth-visual {
        display: none;
    }

    .admin-sidebar {
        transform: translateX(-100%);
        transition: transform 0.25s ease;
    }

    .admin-sidebar.open {
        transform: translateX(0);
    }

    .admin-shell {
        margin-left: 0;
    }

    .dashboard-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 575.98px) {
    .admin-content {
        padding: 14px;
    }

    .dashboard-grid {
        grid-template-columns: 1fr;
    }

    .panel-head {
        display: block;
    }
}

/* ─── Sidebar top bar (brand + close button) ──── */
.sidebar-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 26px;
}
.sidebar-top .admin-brand {
    margin-bottom: 0;
    flex: 1;
    min-width: 0;
}
.sidebar-close-btn {
    display: none;
    width: 34px;
    height: 34px;
    border: none;
    background: rgba(255,255,255,.15);
    color: #fff;
    border-radius: 50%;
    cursor: pointer;
    font-size: .95rem;
    align-items: center;
    justify-content: center;
    transition: background .15s;
    flex-shrink: 0;
    margin-left: 8px;
}
.sidebar-close-btn:hover { background: rgba(255,255,255,.3); }

@media (max-width: 991.98px) {
    .sidebar-close-btn { display: flex; }
}

/* ─── Mobile sidebar backdrop ──────────────────── */
.sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.48);
    z-index: 19;
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
    transition: opacity .25s;
}
.sidebar-backdrop.show { display: block; }

/* ═══════════════════════════════════════════════════════════════
   DASHBOARD REDESIGN v2  —  White / Green / Light tone
   ═══════════════════════════════════════════════════════════════ */

/* ── CSS tokens for green palette ── */
:root {
    --db-green:      #059669;   /* emerald-600  */
    --db-green-lt:   #10b981;   /* emerald-500  */
    --db-green-xl:   #d1fae5;   /* emerald-100  */
    --db-teal:       #0d9488;   /* teal-600     */
    --db-cyan:       #0891b2;   /* cyan-600     */
    --db-bg:         #f6fdf9;   /* faint green-white page bg */
}

/* ── Greeting banner ── */
.db-greeting {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 24px;
    padding: 22px 26px;
    background: linear-gradient(120deg, #fff 55%, #f0fdf4 100%);
    border: 1px solid #d1fae5;
    border-radius: 18px;
    box-shadow: 0 2px 16px rgba(5,150,105,.08);
    flex-wrap: wrap;
}
.db-greeting h1 {
    font-size: 1.4rem;
    font-weight: 800;
    margin: 0 0 4px;
    color: var(--ink);
}
.db-greeting p {
    margin: 0;
    font-size: .88rem;
    color: var(--muted);
}
.db-greeting-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 9px 18px;
    background: linear-gradient(135deg, #047857, #059669);
    color: #fff;
    border-radius: 999px;
    font-size: .82rem;
    font-weight: 600;
    white-space: nowrap;
    flex-shrink: 0;
    box-shadow: 0 4px 14px rgba(4,120,87,.3);
}
[data-bs-theme="dark"] .db-greeting {
    background: linear-gradient(120deg, #0f1b14 55%, #0a1a10 100%);
    border-color: rgba(16,185,129,.18);
}

/* ── Stat Cards ── */
.db-stat-card {
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 20px 18px;
    background: #fff;
    border-radius: 18px;
    border: 1px solid rgba(5,150,105,.12);
    box-shadow: 0 4px 20px var(--card-shadow, rgba(5,150,105,.07));
    transition: transform .22s, box-shadow .22s;
}
.db-stat-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 10px 32px var(--card-shadow, rgba(5,150,105,.16));
}
.db-stat-icon {
    width: 54px;
    height: 54px;
    border-radius: 15px;
    background: var(--card-grad, linear-gradient(135deg,#059669,#10b981));
    display: grid;
    place-items: center;
    flex-shrink: 0;
    font-size: 1.4rem;
    color: #fff;
    box-shadow: 0 4px 16px var(--card-shadow, rgba(5,150,105,.22));
}
.db-stat-body { flex: 1; min-width: 0; }
.db-stat-num {
    font-size: 1.9rem;
    font-weight: 800;
    line-height: 1;
    color: var(--ink);
    margin-bottom: 3px;
}
.db-stat-label {
    font-size: .8rem;
    color: var(--muted);
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.db-stat-ring {
    position: absolute;
    right: -28px;
    bottom: -28px;
    width: 110px;
    height: 110px;
    border-radius: 50%;
    background: var(--card-grad, linear-gradient(135deg,#059669,#10b981));
    opacity: .08;
    pointer-events: none;
}
[data-bs-theme="dark"] .db-stat-card {
    background: #0f1e18;
    border-color: rgba(16,185,129,.15);
}

/* ── Chart cards ── */
.db-chart-card {
    background: #fff;
    border: 1px solid rgba(5,150,105,.1);
    border-radius: 18px;
    padding: 20px 22px;
    box-shadow: 0 2px 14px rgba(5,150,105,.07);
    height: 100%;
}
[data-bs-theme="dark"] .db-chart-card {
    background: #0f1e18;
    border-color: rgba(16,185,129,.15);
}
.db-chart-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 16px;
}
.db-chart-title {
    font-size: .9rem;
    font-weight: 700;
    color: var(--ink);
    display: flex;
    align-items: center;
    gap: 7px;
}
.db-chart-title i { color: var(--db-green); font-size: .95rem; }
.db-chart-sub { font-size: .75rem; color: var(--muted); margin-top: 2px; }
.db-badge-blue {
    display: inline-flex;
    align-items: center;
    padding: 3px 12px;
    border-radius: 8px;
    font-size: .72rem;
    font-weight: 600;
    background: rgba(5,150,105,.1);
    color: #047857;
    border: 1px solid rgba(5,150,105,.18);
    white-space: nowrap;
    flex-shrink: 0;
}

/* ── Panel (generic card) ── */
.db-panel {
    background: #fff;
    border: 1px solid rgba(5,150,105,.1);
    border-radius: 18px;
    padding: 20px 22px;
    box-shadow: 0 2px 14px rgba(5,150,105,.06);
}
[data-bs-theme="dark"] .db-panel {
    background: #0f1e18;
    border-color: rgba(16,185,129,.15);
}
.db-panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: .9rem;
    font-weight: 700;
    color: var(--ink);
    margin-bottom: 14px;
    padding-bottom: 12px;
    border-bottom: 1px solid rgba(5,150,105,.1);
}

/* ── Quick action list ── */
.db-quick-list { display: flex; flex-direction: column; gap: 8px; }
.db-quick-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 14px;
    border-radius: 12px;
    text-decoration: none;
    color: var(--ink);
    background: rgba(5,150,105,.04);
    border: 1px solid transparent;
    transition: background .18s, border-color .18s, transform .15s;
}
.db-quick-item:hover {
    background: rgba(5,150,105,.09);
    border-color: rgba(5,150,105,.22);
    transform: translateX(3px);
    color: var(--ink);
}
.db-quick-item strong { display: block; font-size: .88rem; }
.db-quick-item small  { display: block; font-size: .75rem; color: var(--muted); }
.db-quick-icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    display: grid;
    place-items: center;
    color: #fff;
    font-size: 1rem;
    flex-shrink: 0;
}

/* ── System shortcut grid ── */
.db-sys-link {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 7px;
    padding: 14px 8px;
    border-radius: 13px;
    text-decoration: none;
    color: var(--ink);
    background: rgba(5,150,105,.04);
    border: 1px solid transparent;
    font-size: .8rem;
    font-weight: 600;
    text-align: center;
    transition: background .18s, border-color .18s, transform .15s;
}
.db-sys-link:hover {
    background: rgba(5,150,105,.09);
    border-color: rgba(5,150,105,.22);
    transform: translateY(-3px);
    color: var(--ink);
}
.db-sys-icon {
    width: 46px;
    height: 46px;
    border-radius: 13px;
    display: grid;
    place-items: center;
    font-size: 1.3rem;
}

/* ── Dark mode tweaks ── */
[data-bs-theme="dark"] .db-quick-item { background: rgba(16,185,129,.05); }
[data-bs-theme="dark"] .db-quick-item:hover { background: rgba(16,185,129,.12); border-color: rgba(16,185,129,.3); }
[data-bs-theme="dark"] .db-sys-link  { background: rgba(16,185,129,.05); }
[data-bs-theme="dark"] .db-sys-link:hover { background: rgba(16,185,129,.12); border-color: rgba(16,185,129,.25); }
[data-bs-theme="dark"] .db-stat-num  { color: #ecfdf5; }
[data-bs-theme="dark"] .db-badge-blue { background: rgba(16,185,129,.12); color: #34d399; border-color: rgba(16,185,129,.25); }

/* ── Responsive ── */
@media (max-width: 991px) {
    .db-greeting h1 { font-size: 1.15rem; }
}
@media (max-width: 575px) {
    .db-stat-num { font-size: 1.5rem; }
    .db-stat-icon { width: 44px; height: 44px; font-size: 1.1rem; }
}
