:root {
    --blue-600: #2563eb;
    --blue-700: #1d4ed8;
    --blue-800: #1e40af;
    --indigo-600: #4f46e5;
    --indigo-800: #3730a3;
    --indigo-900: #312e81;
    --slate-100: #f1f5f9;
    --slate-200: #e2e8f0;
    --slate-400: #94a3b8;
    --slate-500: #64748b;
    --slate-600: #475569;
    --slate-800: #1e293b;
    --green-600: #16a34a;
    --green-700: #15803d;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    height: 100%;
    font-family: Inter, "Segoe UI", sans-serif;
    background: var(--slate-100);
    color: var(--slate-800);
    overflow-x: hidden;
}

.font-display, h1, h2, h3 { font-family: Outfit, Inter, sans-serif; }

a { color: var(--blue-600); text-decoration: none; }

.admin-shell {
    display: flex;
    min-height: 100vh;
    overflow: hidden;
}

.sidebar {
    width: 256px;
    background: linear-gradient(180deg, var(--blue-800), var(--indigo-900));
    color: #fff;
    display: flex;
    flex-direction: column;
    box-shadow: 0 25px 50px rgba(15, 23, 42, 0.25);
    z-index: 30;
}

.brand {
    padding: 24px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 8px;
}

.brand-logo-sm {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    object-fit: contain;
    background: #fff;
    padding: 4px;
    box-shadow: 0 0 0 2px rgba(255,255,255,0.35);
}

.brand h1 {
    margin: 0;
    font-size: 1rem;
    font-weight: 700;
}

.brand p {
    margin: 2px 0 0;
    color: #93c5fd;
    font-size: 0.75rem;
}

.sidebar nav {
    flex: 1;
    padding: 16px 12px;
    overflow-y: auto;
}

.sidebar a {
    display: flex;
    align-items: center;
    gap: 12px;
    color: #bfdbfe;
    padding: 10px 12px;
    border-radius: 12px;
    margin-bottom: 4px;
    font-size: 0.875rem;
    font-weight: 600;
}

.sidebar a.active,
.sidebar a:hover {
    background: rgba(255, 255, 255, 0.2);
    color: #fff;
}

.sidebar-foot {
    padding: 16px 12px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar a.logout {
    color: #fca5a5;
}

.sidebar a.logout:hover {
    background: rgba(239, 68, 68, 0.2);
    color: #fecaca;
}

.main-col {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.topbar {
    background: #fff;
    border-bottom: 1px solid var(--slate-200);
    padding: 12px 16px;
    display: flex;
    align-items: center;
    gap: 16px;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}

.topbar h2 {
    margin: 0;
    font-size: 1.125rem;
    font-weight: 700;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
}

.avatar {
    margin-left: auto;
    width: 32px;
    height: 32px;
    border-radius: 999px;
    background: var(--blue-600);
    color: #fff;
    display: grid;
    place-items: center;
    font-size: 0.75rem;
    font-weight: 700;
}

.menu-btn {
    display: none;
    border: 0;
    background: transparent;
    color: var(--slate-500);
    cursor: pointer;
}

.content {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
}

@media (min-width: 768px) {
    .content { padding: 24px; }
}

.page-head {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 20px;
}

.page-head h2 { margin: 0; font-size: 1.25rem; font-weight: 700; }
.page-head p { margin: 4px 0 0; color: var(--slate-400); font-size: 0.875rem; }

.actions { display: flex; flex-wrap: wrap; gap: 8px; }

.cards {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
    margin-bottom: 24px;
}

@media (min-width: 1024px) {
    .cards { grid-template-columns: repeat(4, 1fr); }
}

.stat-card,
.panel {
    background: #fff;
    border: 1px solid var(--slate-200);
    border-radius: 16px;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}

.stat-card { padding: 20px; }
.panel { overflow: hidden; }

.stat-icon {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    display: grid;
    place-items: center;
    color: #fff;
    margin-bottom: 12px;
    font-size: 1.25rem;
}

.stat-card span {
    display: block;
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--slate-400);
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

.stat-card strong {
    display: block;
    font-family: Outfit, Inter, sans-serif;
    font-size: 1.875rem;
    font-weight: 800;
    margin-top: 4px;
}

.bg-blue { background: var(--blue-600); }
.bg-indigo { background: var(--indigo-600); }
.bg-violet { background: #7c3aed; }
.bg-emerald { background: #059669; }
.bg-purple { background: #a855f7; }
.bg-pink { background: #ec4899; }
.bg-rose { background: #f43f5e; }
.bg-orange { background: #f97316; }
.bg-amber { background: #f59e0b; }
.bg-teal { background: #14b8a6; }

.grid-2 {
    display: grid;
    gap: 24px;
}

@media (min-width: 768px) {
    .grid-2 { grid-template-columns: 1fr 1fr; }
}

.panel-head {
    padding: 16px 20px;
    border-bottom: 1px solid #f1f5f9;
}

.panel-head h3 { margin: 0; font-size: 1rem; font-weight: 700; }
.panel-head p { margin: 2px 0 0; color: var(--slate-400); font-size: 0.75rem; }

.panel-pad { padding: 16px 20px; }

.bar-row { margin-bottom: 8px; }
.bar-meta {
    display: flex;
    justify-content: space-between;
    font-size: 0.75rem;
    margin-bottom: 4px;
}
.bar-meta span { color: var(--slate-600); font-weight: 600; }
.bar-meta strong { color: var(--slate-400); font-weight: 700; }
.bar {
    height: 6px;
    background: #f1f5f9;
    border-radius: 99px;
    overflow: hidden;
}
.bar > i {
    display: block;
    height: 100%;
    background: #3b82f6;
    border-radius: 99px;
}
.bar > i.bg-blue { background: var(--blue-600); }
.bar > i.bg-indigo { background: var(--indigo-600); }
.bar > i.bg-violet { background: #7c3aed; }
.bar > i.bg-purple { background: #a855f7; }
.bar > i.bg-pink { background: #ec4899; }
.bar > i.bg-rose { background: #f43f5e; }
.bar > i.bg-orange { background: #f97316; }
.bar > i.bg-amber { background: #f59e0b; }
.bar > i.bg-emerald { background: #059669; }
.bar > i.bg-teal { background: #14b8a6; }

.recent-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 20px;
    border-top: 1px solid #f1f5f9;
}

.recent-item p { margin: 0; font-size: 0.875rem; font-weight: 600; }
.recent-item small { color: var(--slate-400); font-size: 0.75rem; }
.recent-std { margin-left: auto; color: var(--slate-400); font-size: 0.75rem; }

.avatar-sm {
    width: 32px;
    height: 32px;
    border-radius: 999px;
    background: #dbeafe;
    color: var(--blue-700);
    display: grid;
    place-items: center;
    font-size: 0.75rem;
    font-weight: 700;
    flex-shrink: 0;
}

.school-mark {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: #dbeafe;
    color: var(--blue-700);
    display: grid;
    place-items: center;
    font-size: 0.75rem;
    font-weight: 700;
}

.filters {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
    background: #fff;
    border: 1px solid var(--slate-200);
    border-radius: 16px;
    padding: 16px;
    margin-bottom: 20px;
}

@media (min-width: 640px) {
    .filters { grid-template-columns: 1fr 1fr; }
}
@media (min-width: 1024px) {
    .filters { grid-template-columns: repeat(4, 1fr); }
}

.filters input,
.filters select,
.search-input {
    padding: 10px 12px;
    border: 1px solid var(--slate-200);
    border-radius: 12px;
    font: inherit;
    font-size: 16px;
    background: #fff;
    width: 100%;
    max-width: 100%;
}

.filters input:focus,
.filters select:focus,
.search-input:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

.search-wrap { position: relative; display: flex; align-items: center; gap: 8px; }
.search-wrap svg {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--slate-400);
}
.search-wrap input { padding-left: 36px; width: 24rem; max-width: 100%; }

.school-detail-box {
    margin: 10px 0 8px;
    padding: 12px 14px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
}

.school-detail-box p {
    margin: 0 0 6px;
    color: #334155;
    font-size: 0.88rem;
    font-weight: 600;
}

.school-detail-box p:last-child { margin-bottom: 0; }

.btn {
    border: 0;
    border-radius: 8px;
    padding: 8px 12px;
    font: inherit;
    font-size: 0.75rem;
    font-weight: 700;
    cursor: pointer;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: var(--blue-600);
    color: #fff !important;
}

.btn:hover { filter: brightness(0.95); }
.btn-green { background: var(--green-600); }
.btn-green:hover { background: var(--green-700); }
.btn-red { background: #dc2626; }
.btn-red:hover { background: #b91c1c; }
.inline-del { display: inline-flex; margin: 0; }
.btn-indigo { background: var(--indigo-600); }
.btn-light {
    background: #e0e7ff;
    color: #3730a3 !important;
}
.btn-ghost {
    background: #fff;
    color: var(--slate-600) !important;
    border: 1px solid var(--slate-200);
}

.pill {
    background: #dbeafe;
    color: var(--blue-700);
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 700;
}

.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; max-width: 100%; }

table.data {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
    min-width: 640px;
}

table.data th,
table.data td {
    padding: 12px 16px;
    border-bottom: 1px solid #f1f5f9;
    text-align: left;
    vertical-align: middle;
}

table.data th {
    background: #f8fafc;
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--slate-500);
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

table.data.blue-head th {
    background: var(--blue-600);
    color: #fff;
}

table.data tbody tr:hover { background: rgba(239, 246, 255, 0.4); }
table.data tbody tr:nth-child(even) { background: #f8fafc; }

.cell-school {
    display: flex;
    align-items: center;
    gap: 12px;
    font-weight: 600;
    min-width: 0;
}

.school-name {
    min-width: 0;
    overflow-wrap: anywhere;
}

.school-meta {
    display: block;
    margin-top: 4px;
    color: #64748b;
    font-size: 0.75rem;
    font-weight: 600;
}

.col-sr { width: 72px; }
.col-count { width: 130px; }
.col-action { width: 250px; white-space: nowrap; }

.row-actions {
    display: flex;
    flex-wrap: nowrap;
    justify-content: flex-end;
    align-items: center;
    gap: 6px;
}

.row-actions .btn {
    flex: 0 0 auto;
    white-space: nowrap;
    padding: 7px 10px;
}

.right { text-align: right !important; }
.center { text-align: center !important; }

.icon-btn {
    border: 0;
    background: transparent;
    border-radius: 8px;
    padding: 6px;
    cursor: pointer;
    color: var(--slate-400);
}

.icon-btn.edit { color: #3b82f6; }
.icon-btn.del { color: #f87171; }
.icon-btn.ok { color: var(--green-600); }
.icon-btn:hover { background: #f1f5f9; }

.pager {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    padding: 12px 20px;
    border-top: 1px solid #f1f5f9;
    background: #f8fafc;
    font-size: 0.75rem;
    color: var(--slate-400);
}

.pager-links { display: flex; gap: 4px; flex-wrap: wrap; }

.pager a,
.pager span {
    padding: 6px 12px;
    border-radius: 8px;
    border: 1px solid var(--slate-200);
    background: #fff;
    color: var(--slate-600);
    font-weight: 700;
    font-size: 0.75rem;
}

.pager a.active {
    background: var(--blue-600);
    border-color: var(--blue-600);
    color: #fff;
}

.table-foot {
    padding: 12px 20px;
    border-top: 1px solid #f1f5f9;
    background: #f8fafc;
    font-size: 0.75rem;
    color: var(--slate-400);
}

.comp-grid {
    display: grid;
    gap: 16px;
}

@media (min-width: 640px) {
    .comp-grid { grid-template-columns: 1fr 1fr; }
}
@media (min-width: 1024px) {
    .comp-grid { grid-template-columns: 1fr 1fr 1fr; }
}

.comp-card {
    background: #fff;
    border: 1px solid var(--slate-200);
    border-radius: 16px;
    padding: 20px;
    display: block;
    color: inherit;
}

.comp-card:hover { box-shadow: 0 8px 20px rgba(15, 23, 42, 0.08); }
.comp-card strong { font-size: 1.5rem; font-family: Outfit, Inter, sans-serif; }
.comp-top { display: flex; gap: 12px; margin-bottom: 12px; }
.comp-icon {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    display: grid;
    place-items: center;
    color: #fff;
    flex-shrink: 0;
}

.download-hero {
    background: linear-gradient(90deg, var(--green-600), #059669);
    color: #fff;
    border-radius: 16px;
    padding: 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 16px;
    margin-bottom: 24px;
    box-shadow: 0 10px 25px rgba(22, 163, 74, 0.25);
}

.download-hero h3 { margin: 0; font-size: 1.5rem; }
.download-hero p { margin: 4px 0 0; color: #d1fae5; font-size: 0.875rem; }
.download-hero .kicker {
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: #d1fae5;
    margin: 0 0 4px;
}

.btn-white {
    background: #fff !important;
    color: var(--green-700) !important;
}

.download-row {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px 24px;
    border-top: 1px solid #f1f5f9;
}

.download-row:hover { background: #f8fafc; }
.download-row .num { width: 32px; text-align: right; color: #cbd5e1; font-weight: 600; }
.download-row p { margin: 0; font-weight: 700; }
.download-row small { display: block; color: var(--slate-400); margin-top: 2px; }

.settings-list { max-width: 36rem; }
.settings-row {
    padding: 20px 24px;
    border-top: 1px solid #f1f5f9;
}
.settings-row:first-child { border-top: 0; }
.settings-row h4 { margin: 0 0 4px; font-size: 0.875rem; }
.settings-row p { margin: 0; color: var(--slate-500); font-size: 0.75rem; }
.settings-row.danger h4 { color: #dc2626; }

.stack { display: grid; gap: 12px; margin-top: 12px; max-width: 24rem; }
.stack label { font-size: 0.75rem; font-weight: 700; color: var(--slate-500); display: grid; gap: 6px; }
.stack input {
    padding: 10px 12px;
    border: 1px solid var(--slate-200);
    border-radius: 12px;
    font: inherit;
}

.alert {
    padding: 12px 16px;
    border-radius: 12px;
    margin-bottom: 16px;
    font-size: 0.875rem;
}

.alert-error { background: #fef2f2; color: #b91c1c; border: 1px solid #fecaca; }
.alert-ok { background: #f0fdf4; color: #166534; }

.empty { text-align: center; color: var(--slate-400); padding: 40px 16px; }

.login-wrap {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 16px;
    background: linear-gradient(135deg, var(--blue-700), var(--indigo-800));
}

.login-inner { width: min(28rem, 100%); }
.login-brand { text-align: center; margin-bottom: 32px; color: #fff; }
.login-brand .mark {
    width: 88px;
    height: 88px;
    border-radius: 50%;
    background: #fff;
    display: grid;
    place-items: center;
    margin: 0 auto 16px;
    overflow: hidden;
    padding: 6px;
    box-shadow: 0 0 0 3px rgba(255,255,255,0.35);
}
.login-brand .mark img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    border-radius: 50%;
}
.login-brand h1 { margin: 0; font-size: 1.875rem; font-weight: 800; }
.login-brand p { margin: 4px 0 0; color: #bfdbfe; font-size: 0.875rem; }

.login-card {
    background: #fff;
    border-radius: 24px;
    padding: 32px;
    box-shadow: 0 25px 50px rgba(15, 23, 42, 0.25);
}

.login-card label {
    display: grid;
    gap: 8px;
    margin-bottom: 20px;
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--slate-500);
    text-transform: uppercase;
    letter-spacing: 0.12em;
}

.login-card input {
    padding: 12px 16px;
    border: 2px solid var(--slate-200);
    border-radius: 12px;
    font: inherit;
    font-size: 16px;
    text-transform: none;
    letter-spacing: normal;
    font-weight: 500;
    color: var(--slate-800);
    width: 100%;
}

.pass-wrap { position: relative; }
.pass-wrap input { width: 100%; padding-right: 48px; }
.pass-wrap button {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    border: 0;
    background: transparent;
    color: var(--slate-400);
    cursor: pointer;
}

.login-card .btn { width: 100%; justify-content: center; padding: 14px; border-radius: 12px; font-size: 1rem; }
.hint { text-align: center; color: var(--slate-400); font-size: 0.75rem; margin-top: 16px; }
.back-link { text-align: center; margin-top: 24px; }
.back-link a { color: #bfdbfe; font-size: 0.875rem; font-weight: 600; display: inline-flex; align-items: center; gap: 4px; }
.back-link a:hover { color: #fff; }

.overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    display: grid;
    place-items: center;
    z-index: 50;
    padding: 16px;
}

.modal {
    background: #fff;
    border-radius: 16px;
    padding: 24px;
    max-width: 24rem;
    width: 100%;
    box-shadow: 0 25px 50px rgba(15, 23, 42, 0.2);
}

.modal h3 { margin: 0 0 8px; }
.modal p { color: var(--slate-500); font-size: 0.875rem; }
.modal-actions { display: flex; gap: 12px; margin-top: 20px; }
.modal-actions .btn { flex: 1; justify-content: center; }

.filter-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    grid-column: 1 / -1;
}

.filter-actions .btn {
    min-height: 42px;
    justify-content: center;
}

.student-edit-form {
    grid-template-columns: 80px minmax(0, 1fr) 8rem minmax(0, 1fr) auto auto;
}

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: 35;
}

.sidebar {
    z-index: 40;
}

body.nav-open {
    overflow: hidden;
}

@media (max-width: 1023px) {
    .menu-btn { display: inline-flex; min-width: 44px; min-height: 44px; align-items: center; justify-content: center; }
    .sidebar {
        position: fixed;
        inset: 0 auto 0 0;
        width: min(280px, 86vw);
        height: 100dvh;
        max-height: 100%;
        transform: translateX(-100%);
        transition: transform 0.2s ease;
        z-index: 40;
    }
    .sidebar.open { transform: translateX(0); }
    .sidebar-overlay.show { display: block; }
    .content { padding: 16px; }
    .page-head .actions,
    .page-head .search-wrap { width: 100%; }
    .search-wrap { flex-wrap: wrap; width: 100%; }
    .search-wrap input { width: 100%; }
    .download-hero { align-items: stretch; }
    .download-hero .btn { width: 100%; justify-content: center; }
    .filter-actions .btn { flex: 1 1 140px; }

    table.data {
        min-width: 0;
        font-size: 0.9rem;
    }
    table.data thead { display: none; }
    table.data,
    table.data tbody,
    table.data tr,
    table.data td {
        display: block;
        width: 100%;
        text-align: left !important;
        white-space: normal;
    }
    table.data tbody tr {
        background: #fff;
        border: 1px solid var(--slate-200);
        border-radius: 12px;
        margin: 0 0 12px;
        padding: 6px 0;
        overflow: hidden;
    }
    table.data tbody tr:nth-child(even),
    table.data tbody tr:hover {
        background: #fff;
    }
    table.data td {
        display: flex;
        justify-content: space-between;
        align-items: flex-start;
        gap: 12px;
        padding: 10px 14px;
        border-bottom: 1px solid #f1f5f9;
    }
    table.data td:last-child { border-bottom: 0; }
    table.data td::before {
        content: attr(data-label);
        font-size: 0.72rem;
        font-weight: 700;
        color: var(--slate-500);
        text-transform: uppercase;
        letter-spacing: 0.04em;
        flex: 0 0 38%;
        padding-top: 2px;
    }
    table.data td[data-label="Action"] {
        flex-wrap: wrap;
    }
    table.data td[data-label="Action"] .actions,
    table.data td[data-label="Action"] .row-actions {
        width: 100%;
        flex-wrap: wrap;
        justify-content: stretch;
    }
    table.data td[data-label="Action"] .btn,
    table.data td[data-label="Action"] .inline-del {
        flex: 1 1 30%;
    }
    table.data td[data-label="Action"] .btn {
        justify-content: center;
        min-height: 40px;
    }
    table.data td.empty {
        display: block;
        text-align: center !important;
    }
    table.data td.empty::before,
    table.data td:not([data-label])::before { content: none; }
    table.data td:not([data-label]) {
        display: block;
    }
}

@media (max-width: 767px) {
    .cards { grid-template-columns: 1fr; gap: 10px; }
    .stat-card { padding: 14px; }
    .stat-card strong { font-size: 1.5rem; }
    .content { padding: 12px; }
    .page-head h2 { font-size: 1.1rem; }
    .download-row {
        flex-wrap: wrap;
        padding: 14px;
        gap: 10px;
    }
    .download-row .num { display: none; }
    .download-row .actions { width: 100%; }
    .pager {
        padding: 10px;
        justify-content: center;
        text-align: center;
    }
    .pager-links { justify-content: center; width: 100%; }
    .login-card { padding: 22px 16px; border-radius: 18px; }
    .login-brand h1 { font-size: 1.5rem; }
    .login-brand { margin-bottom: 20px; }
    .settings-row, .panel-head, .panel-pad { padding: 14px; }
    .recent-item { padding: 10px 14px; align-items: flex-start; }
    .recent-std { margin-left: 44px; width: calc(100% - 44px); }
    .modal-actions { flex-direction: column; }
    .bar-meta { gap: 8px; }
    .bar-meta span { max-width: 75%; word-break: break-word; }
    .download-hero h3 { font-size: 1.2rem; }
    .student-edit-form { grid-template-columns: 1fr; }
    .stack { max-width: none; }
}

@media (max-width: 479px) {
    .topbar { padding: 10px 12px; gap: 8px; }
    .topbar h2 { font-size: 1rem; }
    .brand-logo-sm { width: 56px; height: 56px; }
}

code { background: #f1f5f9; padding: 0 4px; border-radius: 4px; }
