* { box-sizing: border-box; }
body {
    margin: 0;
    font-family: 'Segoe UI', Arial, sans-serif;
    background: #f4f6f9;
    color: #1f2937;
}

/* ---------- Login page ---------- */
.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: #f4f6f9;
    padding: 24px;
}
.login-wrapper {
    display: flex;
    width: 100%;
    max-width: 900px;
    background: #fff;
    border-radius: 14px;
    overflow: hidden;
    box-shadow: 0 10px 40px rgba(0,0,0,.15);
}
.login-illustration {
    flex: 1 1 45%;
    position: relative;
    background: linear-gradient(135deg, #15803d, #14532d);
    min-height: 480px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    overflow: hidden;
}
.illustration-svg { position: absolute; inset: 0; width: 100%; height: 100%; z-index: 0; }
.illustration-bg-img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; z-index: 0; }
.illustration-overlay {
    position: absolute; inset: 0; z-index: 0;
    background: linear-gradient(180deg, rgba(21,128,61,.6), rgba(20,83,45,.75));
}
.illustration-top { position: relative; z-index: 1; color: #fff; padding: 24px 28px 0; }
.brand-row { display: flex; align-items: center; gap: 12px; }
.login-logo-img-inline {
    height: 48px; width: 48px; object-fit: contain; background: #fff; border-radius: 8px; padding: 4px; flex-shrink: 0;
}
.brand-text h2 { margin: 0; font-size: 26px; letter-spacing: 1px; line-height: 1; }
.brand-text p { margin: 2px 0 0; font-size: 12px; opacity: .9; }
.illustration-address {
    position: relative; z-index: 1; color: #fff; opacity: .85; font-size: 12px;
    padding: 0 28px 20px; line-height: 1.5;
}

.login-box {
    flex: 1 1 55%;
    background: #fff;
    padding: 40px;
}
.login-box h1 { font-size: 20px; margin: 0 0 4px; }
.login-box .subtitle { color: #6b7280; font-size: 13px; margin-bottom: 16px; }
.login-box label { display: block; font-size: 13px; margin-bottom: 4px; margin-top: 12px; }
.login-box input, .login-box select {
    width: 100%; padding: 10px; border: 1px solid #d1d5db; border-radius: 6px; font-size: 14px;
}
.password-field { position: relative; }
.password-field input { padding-right: 40px; }
.toggle-password {
    position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
    background: none; border: none; cursor: pointer; font-size: 16px; padding: 4px;
}
.btn-login {
    width: 100%; margin-top: 20px; padding: 12px; background: #15803d; color: #fff;
    border: none; border-radius: 8px; font-size: 14px; font-weight: 600; cursor: pointer;
    box-shadow: 0 2px 10px rgba(21,128,61,.35); transition: filter .15s ease, transform .1s ease;
}
.btn-login:hover { filter: brightness(1.08); }
.btn-login:active { transform: translateY(1px); }
.level-tabs { display: flex; gap: 6px; margin-bottom: 16px; }
.level-tabs a {
    flex: 1; text-align: center; padding: 6px 8px; border-radius: 6px; text-decoration: none;
    font-size: 12px; color: #374151; background: #f3f4f6;
}
.level-tabs a.active, .level-tabs a:hover { background: #15803d; color: #fff; }
.login-links { text-align: center; margin-top: 14px; font-size: 13px; }
.login-links a { color: #15803d; }
.login-disclaimer {
    text-align: center; font-size: 11px; color: #9ca3af; margin-top: 20px; line-height: 1.6;
}
.alert { padding: 10px; border-radius: 6px; font-size: 13px; margin-top: 12px; }
.alert-error { background: #fee2e2; color: #991b1b; }
.alert-success { background: #dcfce7; color: #166534; }

@media (max-width: 720px) {
    .login-page { padding: 0; }
    .login-wrapper { flex-direction: column; border-radius: 0; max-width: 100%; min-height: 100vh; }
    .login-illustration { min-height: 220px; }
    .illustration-top { padding: 20px 20px 0; }
    .brand-text h2 { font-size: 22px; }
    .login-box { padding: 28px 20px; }
}

/* ---------- App shell ---------- */
.app-shell { display: flex; min-height: 100vh; }
.app-sidebar {
    width: 230px; background: #14532d; color: #e5e7eb; padding: 0; flex-shrink: 0;
    display: flex; flex-direction: column; height: 100vh; position: sticky; top: 0;
}
.sidebar-brand {
    display: flex; flex-direction: column; align-items: center; text-align: center;
    padding: 20px 20px; gap: 4px; background: #1f2937;
}
.sidebar-brand-logo {
    width: 44px; height: 44px; object-fit: contain;
}
.sidebar-brand-short { font-weight: 700; font-size: 18px; color: #fff; }
.sidebar-brand-full { font-size: 12px; color: #bbf7d0; line-height: 1.3; }
.sidebar-nav { flex: 1; display: flex; flex-direction: column; overflow-y: auto; padding: 2px 0; }
.nav-icon { display: block; width: 18px; height: 18px; min-width: 18px; max-width: 18px; flex-shrink: 0; }
.nav-label { display: flex; align-items: center; gap: 10px; }
.app-sidebar a {
    color: #d1fae5; text-decoration: none; font-size: 14px; display: flex; align-items: center; gap: 10px;
    margin: 2px 12px; padding: 9px 14px; border-radius: 8px; border-left: 3px solid transparent;
    transition: background-color .15s ease, color .15s ease;
}
.app-sidebar a:hover { background: rgba(255,255,255,.08); color: #fff; }
.app-sidebar a.active {
    background: rgba(255,255,255,.14); color: #fff; font-weight: 600; border-left-color: #4ade80;
}

/* Label seksi (PENGATURAN / ADMINISTRASI / AKUN) — divider, bukan tombol. */
.sidebar-section-label {
    color: #7f9f8a; font-size: 10.5px; font-weight: 700; letter-spacing: .8px; text-transform: uppercase;
    padding: 6px 26px; margin-top: 10px;
}

/* Sub-grup (Lembaga / Guru / Siswa / Rapor) — baris menu normal + panah. */
.sidebar-group summary {
    color: #d1fae5; text-decoration: none; font-size: 14px; cursor: pointer;
    display: flex; align-items: center; justify-content: space-between; list-style: none;
    margin: 2px 12px; padding: 9px 14px; border-radius: 8px; transition: background-color .15s ease, color .15s ease;
}
.sidebar-group summary::-webkit-details-marker { display: none; }
.sidebar-group summary::after { content: '\25BE'; font-size: 11px; transition: transform .15s; }
.sidebar-group:not([open]) summary::after { transform: rotate(-90deg); }
.sidebar-group summary:hover { background: rgba(255,255,255,.08); color: #fff; }
.sidebar-group-items { display: flex; flex-direction: column; }
.sidebar-group .sidebar-group-items > a { padding-left: 26px; font-size: 13.5px; }
.sidebar-subgroup summary {
    padding-left: 26px; font-size: 13px; text-transform: none; font-weight: 600; letter-spacing: normal;
}
.sidebar-subgroup .sidebar-group-items > a { padding-left: 38px; }

.sidebar-footer { border-top: 1px solid rgba(255,255,255,.12); padding: 8px 0; }
.sidebar-logout { color: #fca5a5 !important; }
.sidebar-logout:hover { background: rgba(255,255,255,.08); }

.app-main { flex: 1; display: flex; flex-direction: column; }
.app-topbar {
    background: #fff; padding: 14px 24px; display: flex; align-items: center;
    justify-content: space-between; border-bottom: 1px solid #e5e7eb;
}
.app-topbar h1 { font-size: 18px; margin: 0; }
.topbar-right { display: flex; align-items: center; gap: 16px; font-size: 13px; }
.level-switch a { margin: 0 4px; padding: 4px 8px; border-radius: 4px; text-decoration: none; color: #374151; }
.level-switch a.active, .level-switch a:hover { background: #15803d; color: #fff; }
.badge-level { background: #e5e7eb; padding: 4px 10px; border-radius: 4px; }
.topbar-profile-link { display: flex; align-items: center; gap: 8px; text-decoration: none; color: #1f2937; }
.topbar-profile-link:hover { text-decoration: underline; }
.topbar-avatar { width: 28px; height: 28px; border-radius: 50%; object-fit: cover; }

.app-content { padding: 24px; overflow-x: hidden; }

.table-responsive { overflow-x: auto; -webkit-overflow-scrolling: touch; margin-bottom: 8px; }

.hamburger-btn {
    display: inline-block; background: none; border: none; font-size: 22px; cursor: pointer;
    padding: 4px 8px; color: #111827; margin-right: 12px; flex-shrink: 0;
}
.app-topbar h1 { display: flex; align-items: center; }
.sidebar-backdrop { display: none; }

/* Desktop: sidebar tampil normal, tombol hamburger menyembunyikannya sepenuhnya
   (menambah ruang konten) lewat class .collapsed. */
.app-sidebar.collapsed { display: none; }

@media (max-width: 900px) {
    .app-sidebar {
        position: fixed; top: 0; left: 0; bottom: 0; z-index: 60; width: 250px;
        transform: translateX(-100%); transition: transform .25s ease; overflow-y: auto;
        display: flex !important;
    }
    .app-sidebar.open { transform: translateX(0); }
    .sidebar-backdrop.open {
        display: block; position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 55;
    }
    .app-main { width: 100%; }
    .app-topbar { padding: 12px 16px; flex-wrap: wrap; gap: 8px; }
    .topbar-right { flex-wrap: wrap; gap: 10px; font-size: 12px; }
    .app-content { padding: 16px; }
    .form-card { max-width: 100%; }
    .stat-grid { grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); }
}

.marquee-bar {
    background: #fef3c7; color: #92400e; overflow: hidden; white-space: nowrap;
    padding: 6px 0; font-size: 13px; border-bottom: 1px solid #fde68a;
}
.marquee-track {
    display: inline-block; padding-left: 100%; animation: marquee-scroll 18s linear infinite;
}
@keyframes marquee-scroll {
    0% { transform: translateX(0); }
    100% { transform: translateX(-100%); }
}

/* ---------- Loading overlay (login, simpan, hapus, transaksi apapun) ---------- */
.loading-overlay {
    display: none; position: fixed; inset: 0; background: rgba(255,255,255,.88);
    z-index: 9999; align-items: center; justify-content: center; flex-direction: column;
}
.loading-overlay.active { display: flex; }
.loading-spinner {
    position: relative; width: 96px; height: 96px; display: flex;
    align-items: center; justify-content: center;
}
.loading-ring {
    position: absolute; inset: 0; border-radius: 50%; border: 4px solid #e5e7eb;
    border-top-color: #15803d; animation: loading-spin .8s linear infinite;
}
.loading-logo { width: 56px; height: 56px; object-fit: contain; border-radius: 50%; z-index: 1; background: #fff; }
.loading-logo-text { font-weight: 700; color: #15803d; font-size: 18px; z-index: 1; }
@keyframes loading-spin { to { transform: rotate(360deg); } }

/* ---------- Notice modal (notifikasi batas pengisian saat login guru/wali kelas) ---------- */
.notice-modal {
    display: none; position: fixed; inset: 0; background: rgba(17,24,39,.55);
    z-index: 9998; align-items: center; justify-content: center; padding: 20px;
}
.notice-modal.active { display: flex; }
.notice-modal-box {
    background: #fff; border-radius: 10px; max-width: 440px; width: 100%;
    padding: 24px; box-shadow: 0 10px 40px rgba(0,0,0,.2);
}
.notice-modal-box h3 { margin: 0 0 12px; color: #15803d; }
.notice-modal-box p { white-space: pre-line; line-height: 1.6; font-size: 14px; }

/* ---------- Dashboard ---------- */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; }
.stat-card { background: #fff; border-radius: 10px; padding: 20px; box-shadow: 0 1px 3px rgba(0,0,0,.08); }
.stat-label { display: block; font-size: 13px; color: #6b7280; }
.stat-value { display: block; font-size: 28px; font-weight: 700; margin-top: 6px; }
.muted { color: #6b7280; font-size: 13px; }

/* ---------- Progress bar (Status Nilai) ---------- */
.progress-bar {
    width: 160px; max-width: 100%; height: 12px; background: #e5e7eb; border-radius: 6px;
    overflow: hidden; display: inline-block; vertical-align: middle; margin-right: 8px;
}
.progress-bar-fill { height: 100%; background: #15803d; transition: width .3s ease; }

/* ---------- Table avatar (Data Guru foto) ---------- */
.table-avatar { width: 36px; height: 36px; border-radius: 50%; object-fit: cover; display: block; }
.table-avatar-placeholder {
    width: 36px; height: 36px; border-radius: 50%; background: #e5e7eb; color: #9ca3af;
    display: inline-flex; align-items: center; justify-content: center;
}
.table-avatar-placeholder .nav-icon { width: 20px; height: 20px; }

/* ---------- Table search toolbar ---------- */
.table-toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 12px; }
.table-toolbar input[type="search"], .table-toolbar select {
    padding: 8px 10px; border: 1px solid #d1d5db; border-radius: 6px; font-size: 14px;
}
.table-toolbar input[type="search"] { min-width: 220px; }

/* ---------- Tables & forms ---------- */
.data-table { width: 100%; border-collapse: collapse; background: #fff; }
.data-table th, .data-table td { padding: 10px 12px; border-bottom: 1px solid #e5e7eb; font-size: 14px; text-align: left; }
.data-table th { background: #f9fafb; }
.toolbar { margin-bottom: 16px; display: flex; justify-content: space-between; }
.btn {
    display: inline-block; padding: 9px 16px; border-radius: 8px; text-decoration: none;
    font-size: 13px; font-weight: 600; border: none; cursor: pointer;
    transition: filter .15s ease, box-shadow .15s ease, transform .1s ease;
}
.btn:hover { filter: brightness(1.07); box-shadow: 0 3px 10px rgba(0,0,0,.12); }
.btn:active { transform: translateY(1px); box-shadow: none; }
.btn-primary { background: #15803d; color: #fff; }
.btn-danger { background: #dc2626; color: #fff; }
.btn-secondary { background: #eef1f4; color: #111827; }
.btn-secondary:hover { filter: none; background: #e2e6eb; }
.form-card { background: #fff; padding: 20px; border-radius: 10px; max-width: 480px; }
.form-card label { display: block; font-size: 13px; margin: 10px 0 4px; }
.form-card input, .form-card select, .form-card textarea {
    width: 100%; padding: 8px; border: 1px solid #d1d5db; border-radius: 6px; font-size: 14px;
}

/* ---------- Sampul Rapor ---------- */
.sampul-sheet {
    background: #fff; padding: 40px; max-width: 640px; text-align: center;
    border: 3px double #15803d; min-height: 900px;
}
.sampul-logo { max-height: 80px; margin-bottom: 10px; }
.sampul-kop { font-size: 15px; margin: 0 0 30px; letter-spacing: .5px; }
.sampul-title { font-size: 20px; line-height: 1.5; margin: 0 0 40px; }
.sampul-photo-box {
    width: 120px; height: 160px; border: 1px solid #333; margin: 0 auto 40px;
    display: flex; align-items: center; justify-content: center; font-size: 12px; color: #6b7280;
}
.sampul-identity { margin: 0 auto; font-size: 14px; text-align: left; border-collapse: collapse; }
.sampul-identity td { padding: 3px 6px; vertical-align: top; }
.sampul-identity td:first-child { white-space: nowrap; }

/* ---------- Rapor Cetak (kop resmi) ---------- */
.rapor-sheet { background: #fff; padding: 24px; max-width: 900px; font-size: 13px; position: relative; }
.rapor-watermark {
    position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
    width: 340px; height: 340px; object-fit: contain; opacity: .1; z-index: 0; pointer-events: none;
}
.rapor-sheet > *:not(.rapor-watermark) { position: relative; z-index: 1; }
.rapor-kop { display: flex; align-items: center; gap: 16px; }
.rapor-kop-logo { height: 90px; width: 90px; object-fit: contain; flex-shrink: 0; }
.rapor-kop-text { flex: 1; text-align: center; }
.kop-yayasan, .kop-satuan { margin: 0; font-size: 13px; font-weight: 600; letter-spacing: .3px; }
.kop-nama { margin: 2px 0; font-size: 22px; font-weight: 700; }
.kop-nomor { margin: 2px 0; font-size: 12px; }
.kop-sk { margin: 2px 0; font-size: 11px; font-style: italic; }
.kop-alamat { margin: 2px 0; font-size: 11px; }
.kop-divider { border: none; border-top: 2px solid #111827; margin: 10px 0 16px; }
.rapor-title { text-align: center; text-decoration: underline; margin: 0 0 16px; font-size: 16px; }
.tamat-badge {
    display: inline-block; border: 2px solid #111827; padding: 10px 24px; font-weight: 700;
    font-size: 16px; margin-bottom: 12px;
}
.identity-table { width: 100%; border-collapse: collapse; font-size: 13px; margin-bottom: 12px; }
.identity-table td { padding: 3px 4px; vertical-align: top; }
.rapor-grades-table th, .rapor-grades-table td { text-align: center; font-size: 12px; border: 1px solid #000; }
.rapor-kepribadian-table, .rapor-ketidakhadiran-table { border-collapse: collapse; }
.rapor-kepribadian-table td, .rapor-ketidakhadiran-table td { border: 1px solid #000; padding: 2px 6px; }

.rapor-verification-box {
    margin-top: 24px; display: flex; align-items: center; gap: 10px; text-align: left;
}
.rapor-verification-text { font-size: 10px; color: #374151; line-height: 1.5; }

/* ---------- Print / Rapor ---------- */
@media print {
    .app-sidebar, .app-topbar, .marquee-bar, .no-print { display: none !important; }
    .app-content { padding: 0; }
    .sidebar-backdrop { display: none !important; }
}
