:root {
    --hijau: #0f5132;
    --hijau-tua: #0a3622;
    --hijau-muda: #e8f3ed;
    --emas: #b8860b;
    --teks: #1f2933;
    --abu: #6b7280;
    --garis: #d9e2dc;
    --putih: #ffffff;
    --latar: #f6f8f7;
    --merah: #b42318;
    --radius: 10px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
    margin: 0;
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
    font-size: 16px;
    line-height: 1.6;
    color: var(--teks);
    background: var(--latar);
}
h1, h2, h3 { line-height: 1.25; color: var(--hijau-tua); margin: 0 0 .5em; }
h1 { font-size: 1.75rem; }
h2 { font-size: 1.25rem; }
a { color: var(--hijau); }
.container { width: 100%; max-width: 1080px; margin: 0 auto; padding: 0 16px; }
.muted { color: var(--abu); }
.small { font-size: .875rem; }
.center { text-align: center; }
.inline { display: inline; margin: 0; }

/* Header v2: minimalis, ramah HP */
.site-header, .dash-header {
    position: sticky; top: 0; z-index: 50;
    background: var(--putih); border-bottom: 1px solid var(--garis);
}
.bar { display: flex; align-items: center; gap: 0 12px; min-height: 56px; }
.brand {
    display: inline-flex; align-items: center; gap: 10px; min-width: 0;
    font-weight: 700; font-size: 1rem; color: var(--hijau-tua); text-decoration: none;
}
.brand-mark {
    flex: none; width: 32px; height: 32px; border-radius: 9px;
    display: inline-flex; align-items: center; justify-content: center;
    background: var(--hijau); color: var(--putih); font-size: .95rem; font-weight: 700;
}
.brand-text { min-width: 0; max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.brand-center { display: block; text-align: center; margin-bottom: 18px; }
.nav { display: flex; align-items: center; gap: 16px; margin-left: auto; }
.nav a { text-decoration: none; }
.site-header .bar { justify-content: space-between; }
.badge { background: var(--hijau-muda); color: var(--hijau-tua); padding: 2px 10px; border-radius: 999px; font-size: .8rem; }
.sr-only {
    position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden;
    clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}

/* Susunan header dashboard (desktop): merek | menu | akun */
.dash-header .brand { order: 1; flex: none; }
.dash-header .menu { order: 2; flex: 1 1 auto; min-width: 0; margin-left: 12px; }
.dash-header .user-menu { order: 3; flex: none; margin-left: auto; }
.nav-check { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.nav-burger { display: none; }

/* Menu akun (avatar + dropdown) */
.user-menu { position: relative; }
.user-menu summary {
    display: flex; align-items: center; gap: 10px; list-style: none; cursor: pointer;
    padding: 5px 8px 5px 5px; border-radius: 999px;
}
.user-menu summary::-webkit-details-marker { display: none; }
.user-menu summary:hover, .user-menu[open] summary { background: var(--latar); }
.avatar {
    flex: none; width: 34px; height: 34px; border-radius: 50%;
    display: inline-flex; align-items: center; justify-content: center;
    background: var(--hijau-muda); color: var(--hijau-tua); font-weight: 700;
}
.user-info { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; text-align: left; }
.user-name { max-width: 130px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .9rem; font-weight: 600; }
.user-role { font-size: .75rem; color: var(--abu); }
.user-panel {
    position: absolute; right: 0; top: calc(100% + 6px); z-index: 60; width: 260px;
    background: var(--putih); border: 1px solid var(--garis); border-radius: 12px; padding: 8px;
    box-shadow: 0 10px 28px rgba(15, 81, 50, .14);
}
.user-meta { padding: 8px 10px 10px; margin-bottom: 6px; border-bottom: 1px solid var(--garis); }
.user-meta strong { display: block; overflow-wrap: anywhere; }
.user-meta span { display: block; font-size: .85rem; color: var(--abu); }
.user-panel form { margin: 0; }
.user-panel a, .user-panel button {
    display: block; width: 100%; padding: 10px; border: 0; border-radius: 8px; background: none;
    font: inherit; color: var(--teks); text-align: left; text-decoration: none; cursor: pointer;
}
.user-panel a:hover, .user-panel button:hover { background: var(--latar); }
.user-panel .danger { color: var(--merah); }

/* Tombol */
.btn {
    display: inline-block; padding: 10px 18px; border-radius: 8px; border: 1px solid transparent;
    font: inherit; font-weight: 600; text-decoration: none; cursor: pointer; text-align: center;
}
.btn-primary { background: var(--hijau); color: var(--putih); }
.btn-primary:hover { background: var(--hijau-tua); }
.btn-outline { background: var(--putih); color: var(--hijau); border-color: var(--hijau); }
.btn-outline:hover { background: var(--hijau-muda); }
.btn-sm { padding: 6px 12px; font-size: .9rem; }
.btn-block { display: block; width: 100%; margin-top: 18px; }

/* Konten */
.hero { background: linear-gradient(135deg, var(--hijau-tua), var(--hijau)); color: var(--putih); padding: 64px 0; }
.hero h1 { color: var(--putih); font-size: 2rem; }
.hero .lead { font-size: 1.1rem; opacity: .92; }
.section { padding: 32px 16px; }
.card { background: var(--putih); border: 1px solid var(--garis); border-radius: var(--radius); padding: 20px; margin-bottom: 16px; }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 16px; margin: 16px 0; }
.stat { margin: 0; text-align: center; }
.stat-number { font-size: 2rem; font-weight: 700; color: var(--hijau); }
.dash-main { padding-top: 24px; padding-bottom: 40px; }
.site-footer { padding: 24px 0; color: var(--abu); font-size: .9rem; border-top: 1px solid var(--garis); margin-top: 32px; background: var(--putih); }

/* Formulir */
label { display: block; font-weight: 600; margin: 14px 0 6px; }
input[type="text"], input[type="password"], input[type="email"] {
    width: 100%; padding: 10px 12px; font: inherit; border: 1px solid #b9c7be; border-radius: 8px; background: var(--putih);
}
input:focus { outline: 2px solid var(--hijau); outline-offset: 1px; border-color: var(--hijau); }

/* Halaman login */
.auth-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px; background: var(--hijau-muda); }
.auth-card { width: 100%; max-width: 420px; background: var(--putih); border: 1px solid var(--garis); border-radius: 14px; padding: 28px 24px; box-shadow: 0 6px 24px rgba(15, 81, 50, .08); }

/* Pesan */
.alert { padding: 12px 14px; border-radius: 8px; margin: 12px 0; font-size: .95rem; border: 1px solid transparent; }
.alert-success { background: #e7f6ec; color: #14532d; border-color: #b7e4c7; }
.alert-error { background: #fdecea; color: var(--merah); border-color: #f5c2c0; }
.alert-info { background: #eaf2fb; color: #1e4a7a; border-color: #bcd4ee; }
main > .alert { max-width: 1048px; margin: 12px auto; }

@media (max-width: 560px) {
    .hero { padding: 44px 0; }
}

/* ===== Tahap 2: menu header & manajemen menu ===== */
[hidden] { display: none !important; }

.menu ul { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 2px; }
.menu a, .menu summary {
    display: flex; align-items: center; height: 56px; padding: 0 10px; box-sizing: border-box;
    border-bottom: 2px solid transparent; color: var(--abu); font-weight: 500;
    text-decoration: none; cursor: pointer;
}
.menu a:hover, .menu summary:hover { color: var(--hijau-tua); }
.menu li.active > a,
.menu li.active > details > summary { color: var(--hijau-tua); border-bottom-color: var(--hijau); font-weight: 600; }
.menu summary { list-style: none; }
.menu summary::-webkit-details-marker { display: none; }
.menu summary::after {
    content: ""; width: 6px; height: 6px; margin: -3px 0 0 8px;
    border-right: 1.5px solid currentColor; border-bottom: 1.5px solid currentColor; transform: rotate(45deg);
}
.menu details { position: relative; }
.menu .sub {
    position: absolute; top: calc(100% + 2px); left: 0; z-index: 60; min-width: 220px; flex-direction: column; gap: 2px;
    background: var(--putih); border: 1px solid var(--garis); border-radius: 12px; padding: 6px;
    box-shadow: 0 10px 28px rgba(15, 81, 50, .14);
}
.menu .sub a { height: auto; min-height: 40px; padding: 8px 12px; border-bottom: 0; border-radius: 8px; color: var(--teks); font-weight: 500; }
.menu .sub a:hover { background: var(--latar); }
.menu .sub li.active > a { background: var(--hijau-muda); color: var(--hijau-tua); }

.tabs { display: flex; flex-wrap: wrap; gap: 8px; margin: 16px 0; }
.tab {
    padding: 8px 16px; border: 1px solid var(--garis); border-radius: 999px;
    background: var(--putih); text-decoration: none; color: var(--teks); font-weight: 500;
}
.tab:hover { background: var(--hijau-muda); }
.tab.active { background: var(--hijau); color: var(--putih); border-color: var(--hijau); }

.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--garis); vertical-align: middle; }
.table th { font-size: .8rem; color: var(--abu); text-transform: uppercase; letter-spacing: .03em; white-space: nowrap; }
.table tr.child .judul-cell { padding-left: 32px; }
.link-cell { max-width: 300px; overflow-wrap: anywhere; font-size: .9rem; }
.status { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: .8rem; font-weight: 600; }
.status-on { background: #e7f6ec; color: #14532d; }
.status-off { background: #f1f3f2; color: var(--abu); }
.actions { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }

.btn-danger { background: var(--putih); color: var(--merah); border-color: var(--merah); }
.btn-danger:hover { background: #fdecea; }
.btn[disabled] { opacity: .4; cursor: not-allowed; }

.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 0 16px; }
select {
    width: 100%; padding: 10px 12px; font: inherit; color: var(--teks);
    border: 1px solid #b9c7be; border-radius: 8px; background: var(--putih);
}
select:focus { outline: 2px solid var(--hijau); outline-offset: 1px; border-color: var(--hijau); }
.check { display: flex; align-items: center; gap: 8px; font-weight: 500; margin: 14px 0 6px; }
.check input { width: auto; }


/* ===== Tahap 3: manajemen akun ===== */
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.filters-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 0 16px; align-items: end; }
.filters-actions { display: flex; gap: 8px; margin-top: 14px; flex-wrap: wrap; }
.pagination { display: flex; align-items: center; gap: 12px; margin-top: 16px; flex-wrap: wrap; }
.status-warn { background: #fff7e0; color: #7a5200; }
.alert-warn { background: #fff7e0; color: #7a5200; border-color: #f1d79a; }
.cred { background: var(--hijau-muda); border: 1px dashed var(--hijau); border-radius: 10px; padding: 16px; margin: 12px 0; }
.cred-row { display: flex; gap: 12px; flex-wrap: wrap; align-items: baseline; margin: 6px 0; }
.cred-label { min-width: 150px; color: var(--abu); }
.cred-value { font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace; font-size: 1.2rem; font-weight: 700; letter-spacing: .04em; user-select: all; }
.detail-list { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 0; }
.detail-list dt { color: var(--abu); }
.detail-list dd { margin: 0; }
.check-list { display: flex; flex-direction: column; gap: 4px; margin-bottom: 12px; }
.check-row { display: flex; flex-wrap: wrap; gap: 4px 24px; align-items: center; }

/* ===== Tahap 4: data santri & wali ===== */
textarea, input[type="date"] {
    width: 100%; padding: 10px 12px; font: inherit; color: var(--teks);
    border: 1px solid #b9c7be; border-radius: 8px; background: var(--putih);
}
textarea { resize: vertical; min-height: 84px; }
textarea:focus, input[type="date"]:focus { outline: 2px solid var(--hijau); outline-offset: 1px; border-color: var(--hijau); }
.link-edit { margin-top: 8px; }
.link-edit summary { cursor: pointer; color: var(--hijau); font-size: .9rem; }
.link-edit form { margin-top: 8px; padding: 12px; background: var(--latar); border: 1px solid var(--garis); border-radius: 8px; }
.card h3 { margin-top: 0; }

/* Header v2: tampilan HP/tablet (menu dilipat) */
@media (max-width: 1100px) {
    .dash-header .bar { flex-wrap: wrap; }
    .dash-header .brand { flex: 1 1 0; }
    .dash-header .user-menu { order: 2; margin-left: 0; }
    .nav-burger {
        order: 3; display: inline-flex; align-items: center; justify-content: center;
        width: 44px; height: 44px; margin: 0 -6px 0 0; border-radius: 10px; cursor: pointer;
    }
    .nav-burger:hover { background: var(--latar); }
    .nav-check:focus-visible + .nav-burger { outline: 2px solid var(--hijau); outline-offset: 2px; }
    .burger-icon, .burger-icon::before, .burger-icon::after {
        display: block; width: 20px; height: 2px; border-radius: 2px; background: var(--teks);
    }
    .burger-icon { position: relative; transition: background .15s; }
    .burger-icon::before, .burger-icon::after { content: ""; position: absolute; left: 0; transition: transform .15s, top .15s; }
    .burger-icon::before { top: -6px; }
    .burger-icon::after { top: 6px; }
    .nav-check:checked + .nav-burger .burger-icon { background: transparent; }
    .nav-check:checked + .nav-burger .burger-icon::before { top: 0; transform: rotate(45deg); }
    .nav-check:checked + .nav-burger .burger-icon::after { top: 0; transform: rotate(-45deg); }

    .dash-header .menu {
        order: 4; flex: 1 0 100%; display: none; margin: 0; padding: 6px 0 12px;
        max-height: calc(100vh - 70px); overflow-y: auto; border-top: 1px solid var(--garis);
    }
    .nav-check:checked ~ .menu { display: block; }
    .menu ul { flex-direction: column; gap: 2px; }
    .menu a, .menu summary {
        height: auto; min-height: 46px; padding: 10px 12px; border-bottom: 0; border-radius: 10px; color: var(--teks);
    }
    .menu a:hover, .menu summary:hover { background: var(--latar); }
    .menu li.active > a, .menu li.active > details > summary { background: var(--hijau-muda); }
    .menu summary { justify-content: space-between; }
    .menu .sub { position: static; min-width: 0; padding: 0 0 0 14px; border: 0; background: transparent; box-shadow: none; }

    .user-info { display: none; }
    .user-menu summary { padding: 5px; }
    .user-panel { position: fixed; top: 62px; left: 12px; right: 12px; width: auto; max-width: 340px; margin-left: auto; }

    .site-header .brand-text { max-width: 55vw; }
}

/* Foto & NIK santri */
.profile-head { display: flex; gap: 20px; align-items: flex-start; flex-wrap: wrap; }
.profile-body { flex: 1; min-width: 260px; }
.foto-santri { width: 120px; height: 160px; object-fit: cover; border-radius: 8px; border: 1px solid #d5dfd8; background: #fff; display: block; }
.foto-kosong { display: flex; align-items: center; justify-content: center; text-align: center; font-size: .8rem; color: #5b6f69; padding: 8px; box-sizing: border-box; }
.nik-besar { font-family: ui-monospace, Consolas, monospace; font-size: 1.5rem; letter-spacing: .05em; margin: 8px 0; }

/* Gambar sampul berita (pratinjau staf) */
.berita-cover { display: block; width: 100%; max-height: 280px; object-fit: cover; border-radius: 8px; margin-bottom: 10px; background: #fff; }

/* Logo pondok dan foto profil pengguna */
.brand-logo { flex: none; height: 32px; width: auto; max-width: 96px; object-fit: contain; display: block; }
.avatar-img { object-fit: cover; display: block; }
.auth-logo { display: block; margin: 0 auto 10px; max-height: 72px; max-width: 200px; width: auto; height: auto; }
.logo-preview { max-height: 96px; max-width: 240px; width: auto; height: auto; border: 1px dashed #d5dfd8; padding: 6px; background: #fff; }
.foto-profil { width: 140px; height: 140px; border-radius: 50%; object-fit: cover; border: 1px solid #d5dfd8; background: #fff; display: block; }
