/* =============================================
   DISDIK Pamekasan - Admin Panel CSS
   Design: Modern Government Blue with Clean Data Layout
   ============================================= */

:root {
    /* Color Palette */
    --primary: #1a4f8a;
    --primary-dark: #0f3462;
    --primary-light: #2563b0;
    --accent: #e8a020;
    --accent-dark: #c8871a;

    --bg-page: #f0f3f8;
    --bg-card: #ffffff;
    --bg-sidebar: #0f2744;
    --bg-sidebar-hover: rgba(255,255,255,0.07);
    --bg-sidebar-active: rgba(255,255,255,0.12);

    --text-primary: #1a2540;
    --text-secondary: #5a6a7e;
    --text-muted: #94a3b8;
    --text-sidebar: rgba(255,255,255,0.75);
    --text-sidebar-active: #ffffff;

    --border: #e2e8f0;
    --border-light: #f1f5f9;

    --success: #16a34a;
    --success-bg: #dcfce7;
    --warning: #d97706;
    --warning-bg: #fef3c7;
    --danger: #dc2626;
    --danger-bg: #fee2e2;
    --info: #0284c7;
    --info-bg: #e0f2fe;

    /* Spacing & Sizing */
    --sidebar-width: 260px;
    --topbar-height: 64px;
    --radius: 10px;
    --radius-sm: 6px;
    --radius-lg: 16px;

    /* Shadows */
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.08);
    --shadow: 0 4px 12px rgba(0,0,0,0.08);
    --shadow-lg: 0 8px 24px rgba(0,0,0,0.12);
    --shadow-sidebar: 4px 0 24px rgba(0,0,0,0.15);

    /* Fonts */
    --font-display: 'Space Grotesk', sans-serif;
    --font-body: 'Plus Jakarta Sans', sans-serif;
}

/* Reset & Base */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 14px; }
body {
    font-family: var(--font-body);
    background: var(--bg-page);
    color: var(--text-primary);
    line-height: 1.6;
}
a { text-decoration: none; color: inherit; }
button, input, select, textarea {
    font-family: inherit;
    font-size: inherit;
}
img { max-width: 100%; }

/* =============================================
   LAYOUT
   ============================================= */

.app-wrapper {
    display: flex;
    min-height: 100vh;
}

/* SIDEBAR */
.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-sidebar);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; left: 0;
    height: 100vh;
    z-index: 100;
    box-shadow: var(--shadow-sidebar);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    overflow-y: auto;
    overflow-x: hidden;
}

.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-track { background: transparent; }
.sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.15); border-radius: 4px; }

.sidebar-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 24px 20px;
    border-bottom: 1px solid rgba(255,255,255,0.07);
    flex-shrink: 0;
}

.logo-mark {
    width: 42px; height: 42px;
    background: var(--accent);
    border-radius: var(--radius-sm);
    display: flex; align-items: center; justify-content: center;
    color: #fff;
    font-size: 18px;
    flex-shrink: 0;
}

.logo-text { display: flex; flex-direction: column; line-height: 1.3; min-width: 0; }
.logo-title {
    font-family: var(--font-display);
    font-size: 14px;
    font-weight: 700;
    color: #fff;
    letter-spacing: 0.2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.logo-sub { font-size: 11px; color: #f59e0b; letter-spacing: 0.3px; font-weight: 500; white-space: nowrap; }

.sidebar-nav {
    flex: 1;
    padding: 8px 0;
    display: flex;
    flex-direction: column;
}

/* ── CWP-style: group header (section label jadi tombol collapsible) ── */
.nav-section-label {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 11px 18px;
    font-size: 13px;
    font-weight: 500;
    color: rgba(255,255,255,0.82);
    letter-spacing: 0.2px;
    text-transform: none;
    border-top: 1px solid rgba(255,255,255,0.06);
    cursor: pointer;
    user-select: none;
    transition: background 0.15s;
    position: relative;
}
.nav-section-label:first-child { border-top: none; }
.nav-section-label:hover { background: rgba(255,255,255,0.05); }

.nav-section-label .ns-icon {
    width: 18px;
    text-align: center;
    font-size: 15px;
    color: rgba(255,255,255,0.55);
    flex-shrink: 0;
}
.nav-section-label .ns-arrow {
    margin-left: auto;
    font-size: 11px;
    color: rgba(255,255,255,0.35);
    transition: transform 0.22s ease;
}
.nav-section-label.open .ns-arrow {
    transform: rotate(90deg);
}

/* ── grup children ── */
.nav-group {
    overflow: hidden;
    max-height: 0;
    transition: max-height 0.28s ease;
    background: rgba(0,0,0,0.15);
}
.nav-group.open { max-height: 800px; }

/* ── item individual ── */
.nav-item {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 9px 18px 9px 26px;
    color: rgba(255,255,255,0.65);
    font-size: 13px;
    font-weight: 400;
    transition: background 0.15s, color 0.15s;
    cursor: pointer;
    border-bottom: 1px solid rgba(255,255,255,0.04);
    text-decoration: none;
}
.nav-item:last-child { border-bottom: none; }

.nav-item i {
    width: 16px;
    text-align: center;
    font-size: 13px;
    color: rgba(255,255,255,0.45);
    flex-shrink: 0;
    transition: color 0.15s;
}

.nav-item:hover {
    background: rgba(255,255,255,0.07);
    color: #fff;
}
.nav-item:hover i { color: rgba(255,255,255,0.8); }

.nav-item.active {
    background: rgba(255,255,255,0.10);
    color: #fff;
    font-weight: 500;
    border-left: 3px solid var(--accent);
    padding-left: 23px;
}
.nav-item.active i { color: var(--accent); }

/* item langsung (tanpa grup) — Dashboard, Logout, dll */
.nav-item--direct {
    padding: 11px 18px;
    font-size: 13px;
    color: rgba(255,255,255,0.82);
    border-bottom: 1px solid rgba(255,255,255,0.06);
    border-left: none;
}
.nav-item--direct i { width: 18px; font-size: 15px; color: rgba(255,255,255,0.55); }
.nav-item--direct:hover { background: rgba(255,255,255,0.07); color: #fff; }
.nav-item--direct:hover i { color: rgba(255,255,255,0.9); }
.nav-item--direct.active {
    background: rgba(255,255,255,0.10);
    color: #fff;
    border-left: 3px solid var(--accent);
    padding-left: 15px;
}
.nav-item--direct.active i { color: var(--accent); }

.nav-item--danger { color: rgba(252,165,165,0.8) !important; }
.nav-item--danger i { color: rgba(252,165,165,0.6) !important; }
.nav-item--danger:hover { background: rgba(220,38,38,0.15) !important; color: #fca5a5 !important; }

.sidebar-footer {
    padding: 16px 16px 20px;
    border-top: 1px solid rgba(255,255,255,0.07);
    flex-shrink: 0;
}

.admin-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.admin-avatar {
    width: 36px; height: 36px;
    background: var(--accent);
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    color: #fff;
    font-weight: 700;
    font-size: 15px;
    flex-shrink: 0;
}

.admin-details { display: flex; flex-direction: column; line-height: 1.3; }
.admin-name { color: #fff; font-size: 13px; font-weight: 600; }
.admin-role { color: rgba(255,255,255,0.4); font-size: 11px; }

/* MAIN CONTENT */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    transition: margin-left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    overflow-x: hidden;
    min-width: 0;
}

/* TOPBAR */
.topbar {
    height: var(--topbar-height);
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 0 24px;
    position: sticky;
    top: 0;
    z-index: 90;
    box-shadow: var(--shadow-sm);
}

.sidebar-toggle {
    width: 36px; height: 36px;
    background: none;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    color: var(--text-secondary);
    display: flex; align-items: center; justify-content: center;
    transition: all 0.18s;
    font-size: 15px;
}

.sidebar-toggle:hover { background: var(--bg-page); color: var(--primary); }

.topbar-title { flex: 1; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.topbar-title h1 {
    font-family: var(--font-display);
    font-size: 17px;
    font-weight: 600;
    color: var(--text-primary);
    line-height: 1.2;
}

.breadcrumb-nav { margin-top: 2px; }
.breadcrumb {
    list-style: none;
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
    color: var(--text-muted);
}
.breadcrumb a { color: var(--primary); }
.breadcrumb a:hover { text-decoration: underline; }
.breadcrumb .separator { color: var(--text-muted); font-size: 9px; }
.breadcrumb .current { color: var(--text-secondary); }

.topbar-date {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12.5px;
    color: var(--text-secondary);
    background: var(--bg-page);
    padding: 6px 12px;
    border-radius: 20px;
    border: 1px solid var(--border);
}

/* PAGE CONTENT */
.page-content {
    flex: 1;
    padding: 24px;
}

/* =============================================
   CARDS & COMPONENTS
   ============================================= */

.card {
    background: var(--bg-card);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
    overflow: visible;
}

.card-header {
    padding: 18px 24px;
    border-bottom: 1px solid var(--border-light);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    border-radius: var(--radius) var(--radius) 0 0;
}

.card-title {
    font-family: var(--font-display);
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 8px;
}

.card-title i { color: var(--primary); }
.card-body { padding: 24px; }

/* STAT CARDS */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

/* DASHBOARD/STATISTIK GRID SYSTEM
   Grid baris dengan jumlah kolom tetap (bukan auto-fill) supaya selalu
   mengisi penuh lebar halaman secara konsisten di semua section. */
.dash-grid { display: grid; gap: 16px; }
/* Tanpa ini, item grid defaultnya punya min-width:auto — kalau isinya (mis.
   tabel dengan teks panjang yang tidak wrap) lebih lebar dari jatah 1fr-nya,
   grid akan melebar melebihi container dan membuat kolom/card di sebelahnya
   ikut terpotong/tidak terlihat. min-width:0 memaksa item menyusut sesuai
   track-nya, lalu overflow di dalamnya discroll oleh .table-container sendiri. */
.dash-grid > * { min-width: 0; }
.dash-grid-2 { grid-template-columns: repeat(2, 1fr); }
.dash-grid-3 { grid-template-columns: repeat(3, 1fr); }
.dash-grid-4 { grid-template-columns: repeat(4, 1fr); }
.dash-grid-5 { grid-template-columns: repeat(5, 1fr); }
.dash-grid-6 { grid-template-columns: repeat(6, 1fr); }

.mini-stat { background: var(--bg-page); border-radius: var(--radius-sm); padding: 14px 16px; border: 1px solid var(--border-light); }
.mini-stat-label { font-size: 11.5px; color: var(--text-secondary); font-weight: 600; text-transform: uppercase; letter-spacing: 0.4px; margin-bottom: 6px; }
.mini-stat-value { font-size: 22px; font-weight: 700; font-family: var(--font-display); line-height: 1.1; }
.mini-stat-sub { font-size: 11.5px; color: var(--text-muted); margin-top: 4px; }

/* Kotak info biru muda (pengganti pola lama yang salah pakai --primary-light,
   yang ternyata bukan warna terang sehingga teks jadi nyaris tak terbaca). */
.info-box-light {
    background: #eaf2fc;
    color: var(--primary);
    border: 1px solid #cfe1f7;
    border-radius: 8px;
    padding: 12px 16px;
    font-size: 13px;
}
.info-box-light .info-box-sub { font-size: 12px; color: var(--text-secondary); }

@media (max-width: 992px) {
    .dash-grid-3, .dash-grid-4 { grid-template-columns: repeat(2, 1fr); }
    .dash-grid-5 { grid-template-columns: repeat(3, 1fr); }
    .dash-grid-6 { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 768px) {
    .dash-grid-2, .dash-grid-3, .dash-grid-4 { grid-template-columns: 1fr; }
    .dash-grid-5 { grid-template-columns: repeat(2, 1fr); }
    .dash-grid-6 { grid-template-columns: repeat(2, 1fr); }
}

/* DROPDOWN INFO RINGKAS (mis. mapping bentuk pendidikan -> jenjang)
   Ringkas & kecil saat tertutup, melebar penuh menampilkan isi saat diklik. */
.mapping-info {
    background: #f0f6ff;
    border: 1px solid #bfdbfe;
    border-radius: var(--radius);
    font-size: 12.5px;
}
.mapping-info summary {
    list-style: none;
    cursor: pointer;
    padding: 9px 14px;
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    color: var(--primary);
    user-select: none;
}
.mapping-info summary::-webkit-details-marker { display: none; }
.mapping-info-caret { margin-left: auto; font-size: 11px; transition: transform 0.15s; color: var(--text-muted); }
.mapping-info[open] .mapping-info-caret { transform: rotate(180deg); }
.mapping-info-body { padding: 4px 14px 12px; border-top: 1px dashed #bfdbfe; margin-top: 2px; padding-top: 10px; }

.stat-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    padding: 20px;
    display: flex;
    align-items: flex-start;
    gap: 16px;
    box-shadow: var(--shadow-sm);
    transition: box-shadow 0.2s, transform 0.2s;
}

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

.stat-icon {
    width: 48px; height: 48px;
    border-radius: var(--radius-sm);
    display: flex; align-items: center; justify-content: center;
    font-size: 20px;
    flex-shrink: 0;
}

.stat-icon--blue { background: #dbeafe; color: var(--primary); }
.stat-icon--green { background: var(--success-bg); color: var(--success); }
.stat-icon--orange { background: var(--warning-bg); color: var(--warning); }
.stat-icon--red { background: var(--danger-bg); color: var(--danger); }
.stat-icon--purple { background: #f3e8ff; color: #7c3aed; }

.stat-body { flex: 1; min-width: 0; }
.stat-label { font-size: 12px; color: var(--text-secondary); font-weight: 500; }
.stat-value {
    font-family: var(--font-display);
    font-size: 28px;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.1;
    margin: 4px 0;
}
.stat-sub { font-size: 11.5px; color: var(--text-muted); }

/* =============================================
   TABLE
   ============================================= */

.table-container {
    overflow-x: auto;
    overflow-y: visible;
    border-radius: var(--radius);
    -webkit-overflow-scrolling: touch;
    width: 100%;
}

.table-container::-webkit-scrollbar { height: 8px; }
.table-container::-webkit-scrollbar-track { background: #f1f5f9; border-radius: 4px; }
.table-container::-webkit-scrollbar-thumb { background: #94a3b8; border-radius: 4px; }
.table-container::-webkit-scrollbar-thumb:hover { background: #64748b; }
/* SCROLLABLE REFERENCE TABLE */
.ref-table-scroll {
    overflow-x: auto;
    overflow-y: visible;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    width: 100%;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    scrollbar-color: #94a3b8 #f1f5f9;
    display: block;
}

.ref-table-scroll::-webkit-scrollbar { height: 8px; }
.ref-table-scroll::-webkit-scrollbar-track { background: #f1f5f9; }
.ref-table-scroll::-webkit-scrollbar-thumb { background: #94a3b8; border-radius: 4px; }
.ref-table-scroll::-webkit-scrollbar-thumb:hover { background: #475569; }

/* PREVIEW TABLE WRAPPER */
.preview-table-wrap {
    max-height: 320px;
    overflow: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    display: block;
    width: 100%;
    -webkit-overflow-scrolling: touch;
}

.preview-table-wrap::-webkit-scrollbar { width: 6px; height: 8px; }
.preview-table-wrap::-webkit-scrollbar-track { background: #f1f5f9; }
.preview-table-wrap::-webkit-scrollbar-thumb { background: #94a3b8; border-radius: 4px; }


.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
    min-width: 900px;
}

.data-table thead {
    background: var(--bg-page);
    position: sticky;
    top: 0;
    z-index: 10;
}

.data-table th {
    padding: 11px 14px;
    text-align: left;
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 11.5px;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    border-bottom: 2px solid var(--border);
    white-space: nowrap;
}

.data-table td {
    padding: 12px 14px;
    border-bottom: 1px solid var(--border-light);
    color: var(--text-primary);
    vertical-align: top;
}

.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover { background: #f8faff; }

/* Untuk tabel ringkas (sedikit kolom, mis. rekap 2-kolom dalam dash-grid-2)
   yang harus muat penuh di kolom grid-nya tanpa scroll horizontal — tanpa
   modifier ini, .data-table selalu dipaksa min-width:900px yang cocok untuk
   tabel detail banyak kolom, tapi bikin tabel ringkas meluber dari card-nya.
   Diletakkan SETELAH aturan .data-table th/td di atas supaya menang cascade
   (sama-sama specificity 2 class/element, urutan sumber yang menentukan). */
.data-table-compact { min-width: 0; }
.data-table-compact th, .data-table-compact td { white-space: normal; }

/* TABLE ACTIONS */
.table-toolbar {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.search-box {
    position: relative;
    flex: 1;
    min-width: 200px;
    max-width: 340px;
}

.search-box input {
    width: 100%;
    padding: 8px 12px 8px 36px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-page);
    color: var(--text-primary);
    font-size: 13px;
    transition: border-color 0.18s, box-shadow 0.18s;
    outline: none;
}

.search-box input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(26, 79, 138, 0.1);
    background: #fff;
}

.search-box i {
    position: absolute;
    left: 11px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 13px;
}

.filter-select {
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-page);
    color: var(--text-primary);
    font-size: 13px;
    cursor: pointer;
    outline: none;
    transition: border-color 0.18s;
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
@media (max-width: 480px) {
    .filter-select { max-width: 130px; }
}

.filter-select:focus { border-color: var(--primary); }

/* Varian ringkas untuk dropdown dengan teks opsi panjang (mis. "Tampilan").
   Kotak tertutup dibuat sempit & terpotong (...), tapi daftar pilihan saat
   diklik tetap menampilkan teks lengkap (perilaku bawaan browser). */
.filter-select-compact { max-width: 190px; }
@media (max-width: 480px) {
    .filter-select-compact { max-width: 140px; }
}

/* FILTER GRID — label di atas, dropdown di bawah, tersusun rapi mengikuti
   lebar halaman (bukan satu baris horizontal yang memanjang ke samping). */
.filter-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 10px 14px;
    margin-bottom: 12px;
    align-items: flex-end;
}
.filter-field { display: flex; flex-direction: column; gap: 4px; min-width: 0; flex: 1 1 150px; }
.filter-field-label {
    font-size: 11.5px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.3px;
}
.filter-field .filter-select,
.filter-field .form-control { width: 100%; max-width: 100%; }
.filter-bar-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.filter-bar-actions .search-box { flex: 1; min-width: 200px; }
/* Varian tombol aksi yang ditempel sebagai item terakhir di dalam .filter-grid.
   flex: 0 0 auto -> lebarnya cuma sebesar isi tombol, TIDAK dipaksa selebar
   kolom dropdown (beda dgn .filter-field yang flex:1 1 150px). Kalau baris
   penuh, seluruh blok tombol ini turun bersama ke baris baru (bukan
   tombol-per-tombol yang pecah sendiri-sendiri). */
.filter-grid .filter-field-actions {
    display: flex;
    gap: 8px;
    flex-wrap: nowrap;
    align-items: center;
    flex: 0 0 auto;
    min-width: 0;
}
/* Samakan tinggi tombol Analisis/Export dengan tinggi input .form-control
   di sebelahnya (dipakai di halaman Mutasi Guru, Perubahan Jabatan PTK,
   Deteksi Perubahan Rombel, dan Pertumbuhan PAUD-S1). */
.filter-grid .filter-field-actions .btn {
    padding-top: 9px;
    padding-bottom: 9px;
    line-height: normal;
}

/* BUTTONS */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    border: none;
    transition: all 0.18s ease;
    white-space: nowrap;
    line-height: 1;
    text-decoration: none;
}

.btn-sm { padding: 5px 10px; font-size: 12px; gap: 5px; }
.btn-lg { padding: 11px 22px; font-size: 14.5px; }

.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); box-shadow: 0 3px 10px rgba(26,79,138,0.3); transform: translateY(-1px); }

.btn-accent { background: var(--accent); color: #fff; }
.btn-accent:hover { background: var(--accent-dark); }

.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { background: #15803d; }

.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #b91c1c; }

.btn-outline { background: none; border: 1px solid var(--border); color: var(--text-primary); }
.btn-outline:hover { background: var(--bg-page); border-color: var(--primary); color: var(--primary); }

.btn-ghost { background: none; color: var(--text-secondary); }
.btn-ghost:hover { background: var(--bg-page); color: var(--primary); }

/* BADGES */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 9px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    line-height: 1;
}

.badge-blue { background: #dbeafe; color: var(--primary); }
.badge-green { background: var(--success-bg); color: var(--success); }
.badge-orange { background: var(--warning-bg); color: var(--warning); }
.badge-red { background: var(--danger-bg); color: var(--danger); }
.badge-gray { background: #f1f5f9; color: var(--text-secondary); }
.badge-purple { background: #f3e8ff; color: #7c3aed; }

/* FORMS */
.form-grid { display: grid; gap: 16px; }
.form-grid-2 { grid-template-columns: repeat(2, 1fr); }
.form-grid-3 { grid-template-columns: repeat(3, 1fr); }
.form-grid-4 { grid-template-columns: repeat(4, 1fr); }

.form-group { display: flex; flex-direction: column; gap: 5px; }
.form-group.span-2 { grid-column: span 2; }

.form-label {
    font-size: 12.5px;
    font-weight: 600;
    color: var(--text-secondary);
    letter-spacing: 0.3px;
}

.form-label .required { color: var(--danger); margin-left: 3px; }

.form-control {
    padding: 9px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: #fff;
    color: var(--text-primary);
    font-size: 13.5px;
    transition: border-color 0.18s, box-shadow 0.18s;
    outline: none;
    width: 100%;
}

.form-control:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(26, 79, 138, 0.1);
}

.form-control.is-invalid { border-color: var(--danger); }
.form-hint { font-size: 11.5px; color: var(--text-muted); }
.form-error { font-size: 11.5px; color: var(--danger); }

/* MODAL */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 39, 68, 0.55);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 200;
    padding: 16px;
    opacity: 0;
    visibility: hidden;
    transition: all 0.25s ease;
}

.modal-overlay.show { opacity: 1; visibility: visible; }

.modal {
    background: #fff;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 680px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    overflow: hidden; /* penting: kunci tinggi modal ke max-height, konten lebih dari itu hanya bisa muncul lewat scroll internal modal-body, bukan meluber ke luar box */
    transform: scale(0.95) translateY(16px);
    transition: transform 0.25s ease;
}

.modal-overlay.show .modal { transform: scale(1) translateY(0); }
.modal--wide { max-width: 900px; }
.modal--sm { max-width: 440px; }

/* Beberapa modal (Tambah/Edit Pengguna, dll) membungkus modal-body +
   modal-footer di dalam <form>. Tanpa aturan ini, <form> jadi elemen block
   biasa (bukan flex item), sehingga rule flex:1/min-height:0 pada
   .modal-body tidak berlaku — akibatnya saat konten body panjang (mis.
   daftar modul dimunculkan), seluruh <form> (termasuk modal-footer berisi
   tombol Simpan/Batal) ikut terdorong lebih tinggi dari max-height:90vh
   milik .modal lalu ter-clip oleh overflow:hidden, sehingga tombol Simpan/
   Batal tidak terlihat sama sekali (baru terlihat kalau zoom browser
   dikecilkan). Menjadikan <form> sebagai flex container column memastikan
   modal-body yang scroll secara internal, sementara modal-footer tetap
   selalu terlihat — sama seperti perilaku modal tanpa <form>.
*/
.modal > form {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-height: 0;
    overflow: hidden;
}

.modal-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0; /* header selalu tetap ukurannya, tidak ikut terdesak konten body */
}

.modal-title {
    font-family: var(--font-display);
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
}

.modal-close {
    width: 30px; height: 30px;
    background: none;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    color: var(--text-muted);
    display: flex; align-items: center; justify-content: center;
    font-size: 16px;
    transition: all 0.15s;
}

.modal-close:hover { background: var(--bg-page); color: var(--danger); }

.modal-body {
    padding: 24px;
    overflow-y: auto;
    flex: 1 1 auto;
    min-height: 0; /* wajib supaya flex item ini mau menyusut dan men-scroll, bukan mendorong footer keluar layar saat kontennya bertambah (mis. saat daftar modul dimunculkan) */
}

.modal-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
    flex-shrink: 0; /* footer (tombol Simpan/Batal) selalu tetap terlihat, tidak pernah tertutup/terdorong keluar */
}

/* PAGINATION */
.pagination {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-wrap: wrap;
}

.page-btn {
    min-width: 34px;
    height: 34px;
    padding: 0 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: #fff;
    color: var(--text-secondary);
    font-size: 13px;
    cursor: pointer;
    transition: all 0.18s;
}

.page-btn:hover { border-color: var(--primary); color: var(--primary); background: #dbeafe; }
.page-btn.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.page-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* ALERT */
.alert {
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    font-size: 13.5px;
    display: flex;
    align-items: flex-start;
    gap: 10px;
    border: 1px solid;
}

.alert-success { background: var(--success-bg); color: #166534; border-color: #bbf7d0; }
.alert-warning { background: var(--warning-bg); color: #92400e; border-color: #fde68a; }
.alert-danger { background: var(--danger-bg); color: #991b1b; border-color: #fecaca; }
.alert-info { background: var(--info-bg); color: #075985; border-color: #bae6fd; }

/* TOAST */
.toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    padding: 14px 18px;
    border-radius: var(--radius);
    background: #1e293b;
    color: #fff;
    font-size: 13.5px;
    display: flex;
    align-items: center;
    gap: 10px;
    box-shadow: var(--shadow-lg);
    z-index: 9999;
    opacity: 0;
    transform: translateY(16px);
    transition: all 0.3s ease;
    pointer-events: none;
    max-width: 360px;
}

.toast.show { opacity: 1; transform: translateY(0); }
.toast-success { background: #166534; }
.toast-error { background: #991b1b; }
.toast-info { background: var(--primary); }

/* DRAG DROP ZONE */
.drop-zone {
    border: 2px dashed #93c5fd;
    border-radius: var(--radius);
    padding: 56px 24px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s ease;
    background: #f8faff;
    user-select: none;
}

.drop-zone:hover, .drop-zone.drag-over {
    border-color: var(--primary);
    background: #dbeafe;
    transform: scale(1.005);
}

.drop-zone:active {
    transform: scale(0.998);
}

.drop-zone-icon {
    font-size: 40px;
    color: var(--primary);
    opacity: 0.5;
    margin-bottom: 12px;
}

.drop-zone-text { color: var(--text-secondary); font-size: 14px; }
.drop-zone-sub { color: var(--text-muted); font-size: 12px; margin-top: 4px; }

/* PROGRESS */
.progress-bar {
    height: 6px;
    background: var(--border);
    border-radius: 3px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: var(--primary);
    border-radius: 3px;
    transition: width 0.4s ease;
}

/* Sidebar Overlay (mobile) */
.sidebar-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: 99;
    display: none;
}

/* SCROLLBAR */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

/* UTILITIES */
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-muted { color: var(--text-muted); }
.text-small { font-size: 12px; }
.fw-semibold { font-weight: 600; }
.fw-bold { font-weight: 700; }
.d-flex { display: flex; }
.align-center { align-items: center; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.gap-16 { gap: 16px; }
.mb-16 { margin-bottom: 16px; }
.mb-24 { margin-bottom: 24px; }
.mt-16 { margin-top: 16px; }
.w-100 { width: 100%; }
.flex-1 { flex: 1; }
.flex-wrap { flex-wrap: wrap; }
.justify-between { justify-content: space-between; }
.justify-end { justify-content: flex-end; }

/* Empty state */
.empty-state {
    text-align: center;
    padding: 48px 24px;
    color: var(--text-muted);
}

.empty-state i { font-size: 48px; opacity: 0.3; margin-bottom: 12px; display: block; }
.empty-state p { font-size: 14px; }

/* DETAIL TABLE */
.detail-table { width: 100%; border-collapse: collapse; }
.detail-table tr { border-bottom: 1px solid var(--border-light); }
.detail-table tr:last-child { border-bottom: none; }
.detail-table th {
    width: 36%;
    padding: 10px 12px;
    font-size: 12.5px;
    font-weight: 600;
    color: var(--text-secondary);
    text-align: left;
    background: var(--bg-page);
}
.detail-table td { padding: 10px 12px; font-size: 13px; }

/* RESPONSIVE */
@media (max-width: 900px) {
    .sidebar {
        transform: translateX(-100%);
    }

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

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

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

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

    .form-group.span-2 { grid-column: span 1; }

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

    .page-content { padding: 16px; }
}

@media (max-width: 540px) {
    .stats-grid { grid-template-columns: 1fr; }
    .form-grid-3, .form-grid-4 { grid-template-columns: 1fr; }
    .topbar-periode { display: none; }
}

/* CHART CONTAINERS */
.chart-container {
    position: relative;
    height: 260px;
}

/* LOGIN PAGE */
.login-page {
    min-height: 100vh;
    background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary) 50%, #1d5fa0 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.login-card {
    background: #fff;
    border-radius: var(--radius-lg);
    padding: 40px;
    width: 100%;
    max-width: 420px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.25);
}

.login-header { text-align: center; margin-bottom: 32px; }
.login-logo-mark {
    width: 60px; height: 60px;
    background: var(--primary);
    border-radius: var(--radius);
    display: flex; align-items: center; justify-content: center;
    color: #fff;
    font-size: 26px;
    margin: 0 auto 16px;
}

.login-title {
    font-family: var(--font-display);
    font-size: 20px;
    font-weight: 700;
    color: var(--text-primary);
}

.login-subtitle { color: var(--text-muted); font-size: 13.5px; margin-top: 4px; }
.login-form { display: flex; flex-direction: column; gap: 16px; }

.login-btn {
    width: 100%;
    justify-content: center;
    padding: 12px;
    font-size: 15px;
    font-weight: 600;
    letter-spacing: 0.3px;
    border-radius: var(--radius-sm);
}

/* SECTION HEADER */
.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.section-title {
    font-family: var(--font-display);
    font-size: 17px;
    font-weight: 600;
    color: var(--text-primary);
}

/* IMPORT STEPS */
.import-steps {
    display: flex;
    gap: 0;
    margin-bottom: 24px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}

.import-step {
    flex: 1;
    padding: 14px 16px;
    text-align: center;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-muted);
    background: var(--bg-page);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border-right: 1px solid var(--border);
    transition: all 0.2s;
}

.import-step:last-child { border-right: none; }
.import-step.active { background: var(--primary); color: #fff; }
.import-step.done { background: var(--success-bg); color: var(--success); }

.step-num {
    width: 22px; height: 22px;
    border-radius: 50%;
    background: currentColor;
    color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-size: 11px;
    font-weight: 700;
    flex-shrink: 0;
    opacity: 0.85;
}

.import-step.active .step-num { background: rgba(255,255,255,0.3); color: #fff; opacity: 1; }
.import-step.done .step-num { background: var(--success); }

/* PREVIEW TABLE */
.preview-table-wrap {
    max-height: 320px;
    overflow: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
}

.preview-table { min-width: max-content; }
.preview-table th { background: #1e293b; color: #fff; }

/* CARD MENGIKUTI TINGGI CARD SEBELAH KIRI — dipakai pada widget dashboard
   yang isinya bisa banyak (PTK per Jabatan, PTK per Tingkat Pendidikan).
   Tinggi keseluruhan card (class .card-flex-fill) di-set lewat JS supaya
   sama dengan tinggi card di sebelah kirinya; isi di dalamnya (.vscroll)
   otomatis mengisi sisa ruang lalu digeser ke atas/bawah jika konten
   lebih panjang dari ruang yang tersedia. */
.card-flex-fill { display: flex; flex-direction: column; overflow: hidden; }
.card-flex-fill .card-body { flex: 1; display: flex; flex-direction: column; min-height: 0; overflow: hidden; }

.vscroll {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding-right: 6px;
}

.vscroll::-webkit-scrollbar { width: 6px; }
.vscroll::-webkit-scrollbar-track { background: var(--bg-page); border-radius: 4px; }
.vscroll::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
.vscroll::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ── LEAFLET MAP FIX ──────────────────────────────────────────────────────
   Pastikan container peta tidak terpotong oleh overflow-x:hidden dari
   .main-content. Leaflet membutuhkan container yang visible dan memiliki
   dimensi yang jelas agar tile bisa dirender dengan benar.
   ──────────────────────────────────────────────────────────────────────── */
#peta-sekolah,
#map {
    z-index: 1;
    position: relative;
}

.leaflet-container {
    font-family: inherit;
}
