:root {
    --bg-gradient: linear-gradient(135deg, #f0f7ff 0%, #e0efff 45%, #f3e8ff 100%);
    --glass-bg: rgba(255, 255, 255, 0.78);
    --glass-border: rgba(255, 255, 255, 0.92);
    --glass-shadow: 0 20px 40px -15px rgba(30, 64, 175, 0.12);
    --primary: #2563eb;
    --primary-soft: #dbeafe;
    --secondary: #0ea5e9;
    --accent: #7c3aed;
    --success: #10b981;
    --success-soft: #d1fae5;
    --warning: #f59e0b;
    --warning-soft: #fef3c7;
    --danger: #ef4444;
    --danger-soft: #fee2e2;
    --text-main: #0f172a;
    --text-muted: #64748b;
    --morph-curve: cubic-bezier(0.22, 1, 0.36, 1);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Plus Jakarta Sans', sans-serif;
}

body {
    background: var(--bg-gradient);
    background-attachment: fixed;
    color: var(--text-main);
    min-height: 100vh;
    overflow-x: hidden;
    position: relative;
}

.blob {
    position: fixed;
    border-radius: 50%;
    filter: blur(80px);
    z-index: -1;
    opacity: 0.6;
    animation: morphBlob 14s infinite alternate var(--morph-curve);
}
.blob-1 { width: 420px; height: 420px; background: #bae6fd; top: -100px; left: -100px; }
.blob-2 { width: 380px; height: 380px; background: #ddd6fe; bottom: -80px; right: -80px; animation-delay: -5s; }
.blob-3 { width: 300px; height: 300px; background: #bbf7d0; top: 40%; left: 55%; animation-delay: -9s; }

@keyframes morphBlob {
    0% { border-radius: 40% 60% 70% 30% / 40% 50% 60% 50%; transform: translate(0, 0) scale(1); }
    50% { border-radius: 70% 30% 50% 50% / 30% 30% 70% 70%; transform: translate(30px, -25px) scale(1.08); }
    100% { border-radius: 50% 60% 30% 70% / 60% 40% 60% 40%; transform: translate(-20px, 20px) scale(0.95); }
}

.glass {
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
    box-shadow: var(--glass-shadow);
    border-radius: 24px;
    transition: all 0.4s var(--morph-curve);
}

.glass:hover {
    box-shadow: 0 25px 50px -12px rgba(37, 99, 235, 0.16);
}

#loadingOverlay {
    position: fixed;
    inset: 0;
    background: rgba(248, 250, 252, 0.82);
    backdrop-filter: blur(10px);
    display: none;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 9999;
}

.loader-ring {
    width: 56px;
    height: 56px;
    border: 4px solid var(--primary-soft);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

#toastContainer {
    position: fixed;
    top: 24px;
    right: 24px;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.toast {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 20px;
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.96);
    backdrop-filter: blur(12px);
    box-shadow: 0 15px 30px rgba(15, 23, 42, 0.12);
    border-left: 5px solid var(--primary);
    font-size: 14px;
    font-weight: 600;
    animation: slideIn 0.4s var(--morph-curve);
    max-width: 360px;
}

.toast.success { border-left-color: var(--success); }
.toast.warning { border-left-color: var(--warning); }
.toast.error { border-left-color: var(--danger); }

@keyframes slideIn {
    from { opacity: 0; transform: translateX(40px) scale(0.95); }
    to { opacity: 1; transform: translateX(0) scale(1); }
}

#loginSection {
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

.login-card {
    width: 100%;
    max-width: 440px;
    padding: 36px 28px;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.login-logo {
    display: block;
    width: 88px;
    height: 88px;
    object-fit: contain;
    margin: 0 auto 16px auto;
    filter: drop-shadow(0 8px 16px rgba(37, 99, 235, 0.2));
}

.input-group {
    position: relative;
    width: 100%;
    margin: 22px 0 16px;
}

.badge-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    border-radius: 999px;
    background: var(--primary-soft);
    color: var(--primary);
    font-size: 12px;
    font-weight: 700;
    margin-bottom: 12px;
}

.input-modern {
    width: 100%;
    padding: 15px 18px 15px 46px;
    border-radius: 16px;
    border: 1.5px solid #cbd5e1;
    background: rgba(255, 255, 255, 0.92);
    font-size: 15px;
    font-weight: 600;
    color: var(--text-main);
    transition: all 0.3s ease;
    outline: none;
}

.input-modern:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.12);
}

.input-icon {
    position: absolute;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    width: 18px;
    height: 18px;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 13px 20px;
    border-radius: 16px;
    border: none;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s var(--morph-curve);
}

.btn-primary {
    background: linear-gradient(135deg, #2563eb, #0ea5e9);
    color: white;
    box-shadow: 0 10px 20px -6px rgba(37, 99, 235, 0.45);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 14px 25px -6px rgba(37, 99, 235, 0.55);
}

.btn-soft {
    background: rgba(255, 255, 255, 0.88);
    color: var(--text-main);
    border: 1px solid #e2e8f0;
}

.btn-soft:hover {
    background: white;
    border-color: var(--primary);
    color: var(--primary);
}

.btn-success {
    background: linear-gradient(135deg, #10b981, #059669);
    color: white;
    box-shadow: 0 10px 20px -6px rgba(16, 185, 129, 0.4);
}

#appSection {
    display: none;
    max-width: 1340px;
    margin: 0 auto;
    padding: 20px;
}

.navbar {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    padding: 18px 24px;
    margin-bottom: 24px;
    gap: 16px;
}

.brand-area {
    display: flex;
    align-items: center;
    gap: 14px;
}

.brand-area img {
    width: 48px;
    height: 48px;
    object-fit: contain;
}

.sync-status {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.live-dot {
    width: 10px;
    height: 10px;
    background: var(--success);
    border-radius: 50%;
    box-shadow: 0 0 0 4px var(--success-soft);
    animation: pulseDot 2s infinite;
}

@keyframes pulseDot {
    0% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.6); }
    70% { box-shadow: 0 0 0 8px rgba(16, 185, 129, 0); }
    100% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

.nav-tabs {
    display: flex;
    gap: 8px;
    padding: 8px;
    margin-bottom: 24px;
    border-radius: 20px;
}

.tab-btn {
    padding: 12px 20px;
    border-radius: 14px;
    border: none;
    background: transparent;
    color: var(--text-muted);
    font-weight: 700;
    font-size: 14px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    white-space: nowrap;
    transition: all 0.35s var(--morph-curve);
}

.tab-btn.active {
    background: white;
    color: var(--primary);
    box-shadow: 0 8px 20px -4px rgba(37, 99, 235, 0.18);
    transform: translateY(-1px);
}

.tab-panel {
    display: none;
    animation: panelMorph 0.45s var(--morph-curve);
}

.tab-panel.active {
    display: block;
}

@keyframes panelMorph {
    from { opacity: 0; transform: translateY(14px) scale(0.99); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

/* ==========================================================================
   TAB 1: KARTU UJIAN & MODE FOKUS
   ========================================================================== */
.grid-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
    gap: 20px;
}

.grid-cards.has-focus {
    grid-template-columns: 1fr;
    max-width: 720px;
    margin: 0 auto;
}

.grid-cards.has-focus .exam-card:not(.focused) {
    display: none;
}

.exam-card {
    padding: 20px 22px;
    position: relative;
    overflow: hidden;
    cursor: pointer;
    user-select: none;
}

.exam-card.is-live {
    border: 1.5px solid #93c5fd;
    background: rgba(255, 255, 255, 0.94);
}

.exam-card.focused {
    padding: 28px;
    cursor: default;
    border: 1.5px solid #bfdbfe;
    background: rgba(255, 255, 255, 0.96);
    animation: panelMorph 0.35s var(--morph-curve);
}

.exam-card.focused .hint-detail {
    display: none;
}

.exam-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
}

.exam-details {
    display: none;
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px dashed #cbd5e1;
}

.exam-card.focused .exam-details {
    display: block;
}

.back-btn-bar {
    display: none;
    margin-bottom: 16px;
}

.exam-card.focused .back-btn-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.token-box {
    background: rgba(248, 250, 252, 0.92);
    border: 1px solid #e2e8f0;
    border-radius: 16px;
    padding: 14px 16px;
    margin-top: 14px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.token-code {
    font-family: 'JetBrains Mono', monospace;
    font-size: 24px;
    font-weight: 700;
    letter-spacing: 3px;
    color: var(--primary);
}

.token-code.exit {
    color: var(--accent);
}

.locked-notice {
    margin-top: 14px;
    padding: 12px 16px;
    border-radius: 14px;
    background: #f8fafc;
    border: 1px dashed #cbd5e1;
    font-size: 12.5px;
    font-weight: 600;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    text-align: center;
}

.progress-track {
    width: 100%;
    height: 10px;
    background: #e2e8f0;
    border-radius: 999px;
    overflow: hidden;
    margin: 12px 0 6px;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #2563eb, #0ea5e9);
    border-radius: 999px;
    transition: width 0.6s var(--morph-curve);
}

/* ==========================================================================
   TAB 2: OVERALL MONITORING (3 BLOK JENJANG KELAS 7, 8, 9)
   ========================================================================== */
.live-toolbar {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: 14px;
    padding: 18px 22px;
    margin-bottom: 20px;
}

.jenjang-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 18px;
    align-items: start;
    width: 100%;
}

@media (max-width: 1120px) {
    .jenjang-grid {
        grid-template-columns: minmax(0, 1fr);
    }
}

.jenjang-card {
    padding: 20px;
    border-radius: 22px;
    min-width: 0;
    width: 100%;
}

.jenjang-hero {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 18px;
    border-radius: 18px;
    background: linear-gradient(135deg, #1e3a8a, #2563eb);
    color: white;
    margin-bottom: 16px;
}

.jenjang-hero.low { background: linear-gradient(135deg, #991b1b, #dc2626); }
.jenjang-hero.mid { background: linear-gradient(135deg, #b45309, #f59e0b); }
.jenjang-hero.high { background: linear-gradient(135deg, #065f46, #10b981); }

.mini-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 11.5px;
    margin-bottom: 16px;
}

.mini-table th {
    background: #eff6ff;
    color: #1e3a8a;
    padding: 7px 5px;
    text-align: center;
    font-weight: 800;
    border: 1px solid #dbeafe;
}

.mini-table td {
    padding: 6px 4px;
    text-align: center;
    border: 1px solid #f1f5f9;
    font-weight: 600;
}

.mini-table td.row-label {
    text-align: left;
    font-weight: 800;
    background: #f8fafc;
    padding-left: 8px;
}

.sub-box-title {
    font-size: 12px;
    font-weight: 800;
    color: var(--primary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin: 14px 0 8px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.belum-scroll {
    max-height: 260px;
    overflow-y: auto;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
}

/* ==========================================================================
   KOMPONEN UMUM TABEL & STATISTIK
   ========================================================================== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 16px;
}

.stat-icon {
    width: 50px;
    height: 50px;
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.table-wrapper {
    overflow-x: auto;
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.7);
    border: 1px solid rgba(255, 255, 255, 0.95);
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13.5px;
    text-align: left;
}

th {
    background: rgba(241, 245, 249, 0.95);
    padding: 14px 16px;
    font-weight: 700;
    color: var(--text-main);
    border-bottom: 1px solid #e2e8f0;
    white-space: nowrap;
}

td {
    padding: 13px 16px;
    border-bottom: 1px solid #f1f5f9;
    color: #334155;
}

tr:hover td {
    background: rgba(239, 246, 255, 0.65);
}

.status-pill {
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
    display: inline-block;
    white-space: nowrap;
}

.pill-done { background: var(--success-soft); color: #065f46; }
.pill-working { background: var(--warning-soft); color: #92400e; }
.pill-pending { background: var(--danger-soft); color: #991b1b; }

.filter-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 18px;
    align-items: center;
}

.select-modern {
    padding: 11px 16px;
    border-radius: 14px;
    border: 1px solid #cbd5e1;
    background: white;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-main);
    outline: none;
}

/* ==========================================================================
   OPTIMASI KHUSUS LAYAR HP (MENU TAMPIL SEMUA TANPA GESER)
   ========================================================================== */
/* ==========================================================================
   TAB 3: STATUS PER RUANGAN (GRID KARTU RUANG 1 - 18)
   ========================================================================== */
.ruang-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
    gap: 14px;
    margin-top: 16px;
}

.ruang-card {
    background: rgba(255, 255, 255, 0.9);
    border: 1px solid #e2e8f0;
    border-radius: 18px;
    padding: 16px;
    transition: all 0.3s var(--morph-curve);
}

.ruang-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 24px -8px rgba(37, 99, 235, 0.15);
}

.ruang-card.done { border-left: 4px solid var(--success); }
.ruang-card.working { border-left: 4px solid var(--warning); }
.ruang-card.empty { border-left: 4px solid var(--danger); }

.ruang-metrics {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
    margin-top: 12px;
    padding-top: 10px;
    border-top: 1px dashed #e2e8f0;
    text-align: center;
}

@media (max-width: 768px) {
    .ruang-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 10px;
    }
    .ruang-card {
        padding: 13px 12px;
    }
}
@media (max-width: 768px) {
    #loginSection { padding: 16px; }
    .login-card { padding: 28px 20px; border-radius: 20px; }
    .login-card h2 { font-size: 19px !important; }
    .login-logo { width: 76px; height: 76px; }
    #appSection { padding: 12px; }
    .navbar {
        padding: 14px 16px;
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
    }
    .sync-status {
        justify-content: space-between;
        width: 100%;
    }
    .nav-tabs {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
        padding: 8px;
        overflow: visible;
    }
    .tab-btn {
        flex-direction: column;
        text-align: center;
        padding: 12px 8px;
        font-size: 12px;
        line-height: 1.3;
        white-space: normal;
        gap: 6px;
    }
    .tab-btn:last-child {
        grid-column: 1 / -1;
        flex-direction: row;
    }
    .grid-cards { grid-template-columns: 1fr; gap: 12px; }
    .exam-card { padding: 16px 18px; }
    .exam-card.focused { padding: 20px 16px; }
    .token-box {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }
    .token-box > div:last-child {
        width: 100%;
        justify-content: flex-end;
    }
    .token-code { font-size: 20px; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
    .stat-card { padding: 14px; gap: 10px; }
    .filter-bar { flex-direction: column; align-items: stretch; }
    .select-modern, .filter-bar .btn { width: 100% !important; margin-left: 0 !important; }
    #toastContainer { top: auto; bottom: 16px; left: 16px; right: 16px; }
    .toast { max-width: 100%; }
}