:root {
    color-scheme: light;
    --navy: #18354f;
    --navy-deep: #122b42;
    --navy-soft: #284b67;
    --ink: #24394b;
    --muted: #718295;
    --line: #e3eaf0;
    --canvas: #f3f7fa;
    --white: #fff;
    --sage: #e8f1ed;
    --blue-soft: #e9f1f8;
    --peach: #f8eee5;
    --lilac: #f0edf7;
    --gold: #d9bd80;
    --radius: 16px;
    --shadow: 0 8px 24px rgba(26, 55, 79, .055);
}

* { box-sizing: border-box; }

html { min-width: 320px; background: var(--canvas); }

body {
    min-height: 100vh;
    margin: 0;
    background: var(--canvas);
    color: var(--ink);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    font-size: 14px;
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
}

button, input, select, textarea { font: inherit; }
button { -webkit-tap-highlight-color: transparent; }

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

.sidebar {
    position: sticky;
    top: 0;
    display: flex;
    flex: 0 0 264px;
    flex-direction: column;
    width: 264px;
    height: 100vh;
    overflow-y: auto;
    padding: 27px 16px 18px;
    background: linear-gradient(165deg, var(--navy) 0%, var(--navy-deep) 100%);
    color: #f4f7fa;
    scrollbar-width: thin;
    scrollbar-color: #45617a transparent;
}

.brand { display: flex; align-items: center; gap: 13px; margin: 0 5px 29px; }

.brand-icon {
    display: grid;
    flex: 0 0 47px;
    width: 47px;
    height: 47px;
    place-items: center;
    border: 1px solid rgba(239, 222, 178, .38);
    border-radius: 15px;
    background: rgba(238, 223, 189, .12);
    color: #ead9aa;
}

.brand-icon svg { width: 36px; height: 36px; fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 2.2; }
.brand h2 { margin: 0; color: #fff; font-size: 18px; font-weight: 750; letter-spacing: .09em; line-height: 1.2; }
.brand small { display: block; max-width: 160px; margin-top: 4px; color: #bac8d4; font-size: 10px; line-height: 1.35; }
.menu-label { margin: 0 12px 10px; color: #8ea4b8; font-size: 10px; font-weight: 700; letter-spacing: .14em; }

nav { display: grid; gap: 4px; }
.nav-btn, .nav-group-toggle {
    display: flex;
    width: 100%;
    min-height: 42px;
    align-items: center;
    gap: 12px;
    padding: 9px 12px;
    border: 0;
    border-radius: 11px;
    background: transparent;
    color: #d4e0e9;
    text-align: left;
    text-decoration: none;
    cursor: pointer;
    font-size: 13px;
    font-weight: 540;
    transition: background-color .14s ease, color .14s ease;
}

.nav-btn:hover, .nav-group-toggle:hover { background: rgba(255, 255, 255, .075); color: #fff; }
.nav-btn.active, .nav-group-toggle.active { background: #2b4d68; color: #fff; box-shadow: inset 3px 0 0 #d9bd80; }
.nav-icon { width: 18px; height: 18px; flex: 0 0 18px; fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.65; opacity: .92; }
.nav-btn span:last-child, .nav-group-toggle span { min-width: 0; }
.nav-group { display: grid; gap: 3px; }
.nav-group-toggle { justify-content: flex-start; }
.nav-group-toggle .nav-chevron { width: 14px; height: 14px; margin-left: auto; fill: none; stroke: currentColor; stroke-width: 1.7; transition: transform .14s ease; }
.nav-group-toggle[aria-expanded="false"] .nav-chevron { transform: rotate(-90deg); }
.nav-submenu { display: grid; gap: 2px; padding: 2px 0 5px 15px; }
.nav-group.collapsed .nav-submenu { display: none; }
.nav-submenu .nav-btn { min-height: 36px; padding: 7px 11px; font-size: 12px; }
.nav-sub-link { min-height: 35px; padding-left: 43px; color: #adc0ce; font-size: 11px; }
.nav-sub-dot { width: 6px; height: 6px; flex: 0 0 6px; border-radius: 50%; background: #87a69f; }
.nav-submenu .nav-btn.active .nav-sub-dot, .nav-sub-link.active .nav-sub-dot { background: var(--gold); }

.sidebar-footer { margin: auto 10px 0; padding-top: 24px; color: #d7e2e9; font-size: 11px; font-weight: 700; letter-spacing: .05em; line-height: 1.8; }
.sidebar-footer small { color: #91a7b9; font-size: 10px; font-weight: 400; letter-spacing: 0; }

.main { flex: 1; min-width: 0; }
.topbar {
    position: sticky;
    z-index: 4;
    top: 0;
    display: flex;
    min-height: 83px;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    padding: 17px clamp(20px, 4vw, 54px);
    border-bottom: 1px solid rgba(222, 231, 238, .9);
    background: rgba(255, 255, 255, .93);
    backdrop-filter: blur(10px);
}

.topbar h2 { margin: 0; color: var(--navy); font-size: 18px; font-weight: 700; letter-spacing: -.02em; }
.topbar p { margin: 3px 0 0; color: var(--muted); font-size: 12px; }
.admin-label { display: inline-flex; align-items: center; gap: 8px; padding: 8px 13px; border: 1px solid #e5ecef; border-radius: 999px; background: #f7fafb; color: #526a7e; font-size: 12px; font-weight: 600; white-space: nowrap; }
.status-dot { width: 7px; height: 7px; border-radius: 50%; background: #7aa296; }

#page-content { width: min(100%, 1510px); margin: 0 auto; padding: 32px clamp(20px, 4vw, 54px) 48px; }
.page-heading { margin: 0 0 23px; }
.page-heading h2 { margin: 2px 0 6px; color: var(--navy); font-size: clamp(22px, 2.5vw, 29px); font-weight: 730; letter-spacing: -.035em; line-height: 1.22; }
.page-heading p { margin: 0; color: var(--muted); font-size: 13px; }
.eyebrow { margin: 0 0 5px; color: #829388; font-size: 10px; font-weight: 750; letter-spacing: .13em; }

.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 15px; margin: 0 0 19px; }
.stat-card, .panel { border: 1px solid var(--line); border-radius: var(--radius); background: var(--white); box-shadow: var(--shadow); }
.stat-card { position: relative; min-height: 142px; padding: 18px 19px; }
.stat-card span { display: block; color: #667b8d; font-size: 12px; font-weight: 600; }
.stat-card h2 { margin: 9px 0 0; color: var(--navy); font-size: 30px; font-weight: 720; letter-spacing: -.04em; line-height: 1.1; }
.stat-card small { display: block; margin-top: 7px; color: #94a1ad; font-size: 10px; line-height: 1.4; }
.stat-icon { display: grid; width: 34px; height: 34px; float: right; place-items: center; border-radius: 11px; font-size: 16px; font-weight: 700; }
.stat-icon-blue { background: var(--blue-soft); color: #567e9c; }
.stat-icon-sage { background: var(--sage); color: #6f9184; }
.stat-icon-peach { background: var(--peach); color: #a78164; }
.stat-icon-lilac { background: var(--lilac); color: #81759d; }

.dashboard-grid { display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(330px, .95fr); gap: 17px; margin-bottom: 17px; }
.lower-grid { grid-template-columns: minmax(0, 1.05fr) minmax(330px, .95fr); }
.panel { margin: 0 0 17px; padding: 22px; }
.dashboard-grid > .panel { margin-bottom: 0; }
.panel h2, .panel h3 { margin: 0 0 15px; color: var(--navy); font-size: 16px; font-weight: 700; letter-spacing: -.015em; }
.panel p { color: #63788b; }
.section-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 13px; }
.section-heading h3 { margin: 0; }
.section-heading .eyebrow { margin-bottom: 3px; }
.soft-badge { display: inline-flex; align-items: center; padding: 5px 9px; border-radius: 999px; background: #eef4f1; color: #678477; font-size: 10px; font-weight: 700; white-space: nowrap; }
.dashboard-satker-picker { max-width: 430px; }
.satker-summary { margin-top: 17px; padding: 15px 16px; border: 1px solid #e5ecef; border-radius: 13px; background: #f8fafb; }
.satker-summary h4 { margin: 0 0 3px; color: var(--navy); font-size: 15px; }
.satker-summary p { margin: 0 0 4px; color: #657a8c; font-size: 12px; }
.satker-summary small { color: #8c9ba7; font-size: 11px; }
.empty-inline { margin: 14px 0 0; padding: 13px 15px; border-radius: 11px; background: #f7f9fb; color: #81909d !important; font-size: 12px; }
.quick-actions { display: grid; gap: 8px; }
.quick-action { display: flex; min-height: 58px; align-items: center; gap: 12px; padding: 9px 11px; border: 1px solid #e8edf0; border-radius: 12px; background: #fff; color: var(--ink); text-align: left; cursor: pointer; }
.quick-action:hover { border-color: #cbd9dc; background: #fbfcfc; }
.quick-action > span:nth-child(2) { display: grid; flex: 1; }
.quick-action strong { color: #334e63; font-size: 12px; }
.quick-action small { margin-top: 1px; color: #84929d; font-size: 10px; }
.quick-action > b { color: #99a9b3; font-size: 20px; font-weight: 400; }
.quick-action-icon { display: grid; width: 34px; height: 34px; place-items: center; border-radius: 10px; background: var(--blue-soft); color: #64849a; font-size: 16px; }
.quick-action:nth-child(2) .quick-action-icon { background: var(--sage); color: #708e80; }
.quick-action:nth-child(3) .quick-action-icon { background: var(--peach); color: #a98266; }
.text-btn { padding: 4px 0; border: 0; background: none; color: #68859a; cursor: pointer; font-size: 11px; font-weight: 650; }
.empty-state { display: grid; min-height: 155px; align-content: center; justify-items: center; padding: 15px; border: 1px dashed #dce5e9; border-radius: 13px; background: #fbfcfd; text-align: center; }
.empty-state-icon { display: grid; width: 38px; height: 38px; margin-bottom: 8px; place-items: center; border-radius: 12px; background: #edf3f5; color: #7e98a4; font-size: 16px; }
.empty-state p { margin: 0 0 3px; color: #526a7d; font-size: 12px; font-weight: 650; }
.empty-state small { color: #91a0aa; font-size: 10px; }
.guide-list { display: grid; gap: 13px; margin: 3px 0 0; padding: 0; list-style: none; }
.guide-list li { display: flex; align-items: flex-start; gap: 11px; }
.guide-list li > span { display: grid; width: 26px; height: 26px; flex: 0 0 26px; place-items: center; border-radius: 9px; background: var(--sage); color: #6a8a7d; font-size: 11px; font-weight: 750; }
.guide-list li div { display: grid; }
.guide-list strong { color: #405a6e; font-size: 11px; }
.guide-list small { margin-top: 2px; color: #84939f; font-size: 10px; }

.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 17px; }
.form-group { display: flex; min-width: 0; flex-direction: column; gap: 7px; margin-bottom: 14px; }
.form-group label { color: #42596d; font-size: 12px; font-weight: 650; }
.address-form-group { grid-column: 1 / -1; padding: 15px; border: 1px solid #e5ebef; border-radius: 13px; background: #fbfcfd; }
.address-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 15px; }
.address-row-parts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.address-result-group { display: grid; gap: 7px; margin-top: 2px; }
.address-result-group label span { color: #8998a3; font-size: 10px; font-weight: 450; }
.address-status { min-height: 0; margin: 5px 0 0; color: #82919b; font-size: 10px; }
.address-status.is-error { color: #a6645b; }
.address-retry { min-height: 32px; margin-top: 5px; padding: 6px 10px; font-size: 10px; }
select:disabled { background: #f3f6f8; color: #9aa7b1; cursor: wait; }
input, select, textarea { width: 100%; min-height: 42px; padding: 10px 12px; border: 1px solid #dce5eb; border-radius: 10px; outline: none; background: #fff; color: #30485c; font-size: 13px; transition: border-color .14s ease, box-shadow .14s ease; }
textarea { min-height: 92px; resize: vertical; line-height: 1.55; }
input::placeholder, textarea::placeholder { color: #a4b0b9; }
input:focus, select:focus, textarea:focus { border-color: #8ca9b7; box-shadow: 0 0 0 3px rgba(112, 150, 166, .12); }
input[readonly] { background: #f6f8f9; color: #61778a; }
.form-group small { color: #83929e; font-size: 11px; }

.child-panel { margin: 17px 0 0; border: 1px solid #e3eaee; background: #fbfcfd; box-shadow: none; }
.child-panel h3 { font-size: 14px; }
.child-row-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 13px; }
.child-row-heading h4 { margin: 0; color: #466276; font-size: 13px; }
.identitas-anak.panel { margin: 12px 0; padding: 16px; border: 1px solid #e1e8ed; background: #fff; box-shadow: none; }

.primary-btn, .secondary-btn, .danger-btn { display: inline-flex; min-height: 39px; align-items: center; justify-content: center; gap: 7px; padding: 9px 15px; border: 1px solid transparent; border-radius: 10px; cursor: pointer; font-size: 12px; font-weight: 650; text-decoration: none; }
.backup-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; align-items: start; }
.backup-panel h3, .backup-help h3, .backup-journal h3 { margin-bottom: 8px; }
.backup-panel > p, .backup-help p, .backup-journal p { color: var(--muted); font-size: 12px; }
.backup-counts { display: flex; flex-wrap: wrap; gap: 8px; margin: 18px 0; }
.backup-counts span { padding: 6px 10px; border-radius: 999px; background: var(--blue-soft); color: #456176; font-size: 11px; font-weight: 650; }
.backup-note { margin-top: 15px; }
.backup-file-label { display: block; margin: 15px 0 6px; font-size: 12px; font-weight: 650; }
.backup-preview { display: grid; gap: 10px; margin-top: 14px; overflow-wrap: anywhere; }
.backup-preview p, .backup-preview ul { margin: 0; font-size: 12px; }
.backup-preview ul { padding-left: 20px; color: #9b554d; }
.backup-message { margin: 14px 0; padding: 0; color: var(--muted); font-size: 12px; }
.backup-message:not(:empty) { padding: 11px 14px; border-radius: 10px; background: #edf2f5; }
.backup-message.success { background: #e8f1ed; color: #315f4e; }
.backup-message.error { background: #fbefed; color: #8c4f48; }
.backup-journal { border-color: #ead8b3; background: #fffaf0; }
.backup-help ol { padding-left: 21px; color: #536a7b; font-size: 12px; }
.backup-help li { margin: 5px 0; }
.primary-btn:disabled { opacity: .6; cursor: wait; }
.primary-btn { background: var(--navy); color: #fff; }
.primary-btn:hover { background: var(--navy-soft); }
.secondary-btn { border-color: #dfe7ec; background: #f1f5f7; color: #456176; }
.secondary-btn:hover { background: #e9eff2; }
.danger-btn { border-color: #f0dede; background: #fbf1f0; color: #a15f5b; }
.danger-btn:hover { background: #f7e8e7; }

.table-wrap { width: 100%; overflow-x: auto; border: 1px solid #e8edf0; border-radius: 12px; }
table { width: 100%; border-collapse: collapse; font-size: 12px; }
th, td { padding: 12px 13px; border-bottom: 1px solid #edf1f3; text-align: left; vertical-align: middle; }
th { background: #f7f9fa; color: #617587; font-size: 10px; font-weight: 750; letter-spacing: .035em; white-space: nowrap; }
td { color: #4b6173; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #fbfcfc; }
.actions { display: flex; flex-wrap: wrap; gap: 6px; }
.empty { padding: 26px 15px; color: #8997a2; text-align: center; font-size: 12px; }

.preview-posita { padding-left: 23px; color: #455d70; }
.preview-posita li { margin: 0 0 10px; padding-left: 4px; }
.preview-petitum p { margin: 7px 0; color: #455d70; }
.sidebar-footer, .nav-btn, .nav-group-toggle { user-select: none; }

@media (max-width: 1120px) {
    .backup-grid { grid-template-columns: 1fr; }
    .sidebar { flex-basis: 238px; width: 238px; }
    .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .dashboard-grid, .lower-grid { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 760px) {
    .app { display: block; }
    .sidebar { position: relative; width: 100%; height: auto; max-height: none; padding: 15px 14px 13px; overflow: visible; }
    .brand { margin: 0 4px 13px; }
    .brand-icon { width: 41px; height: 41px; flex-basis: 41px; border-radius: 13px; }
    .brand-icon svg { width: 32px; height: 32px; }
    .menu-label, .sidebar-footer { display: none; }
    nav { display: flex; gap: 5px; overflow-x: auto; padding: 0 0 3px; scrollbar-width: thin; }
    .nav-btn, .nav-group-toggle { width: auto; min-width: max-content; min-height: 38px; padding: 8px 10px; border-radius: 9px; font-size: 11px; }
    .nav-icon { width: 16px; height: 16px; flex-basis: 16px; }
    .nav-sub-link { min-height: 38px; padding-left: 10px; }
    .nav-group { display: flex; position: relative; }
    .nav-group-toggle .nav-chevron { margin-left: 0; }
    .nav-submenu { position: absolute; z-index: 8; top: calc(100% + 5px); left: 0; min-width: 190px; padding: 7px; border: 1px solid rgba(255,255,255,.12); border-radius: 12px; background: var(--navy-deep); box-shadow: 0 12px 25px rgba(8, 25, 39, .28); }
    .nav-submenu .nav-btn { width: 100%; }
    .nav-group.collapsed .nav-submenu { display: none; }
    .topbar { position: static; min-height: 68px; padding: 14px 20px; }
    #page-content { padding: 23px 18px 34px; }
    .panel { padding: 18px; }
}

@media (max-width: 520px) {
    .topbar { align-items: flex-start; }
    .topbar h2 { font-size: 16px; }
    .topbar p { max-width: 220px; font-size: 10px; }
    .admin-label { padding: 7px 9px; font-size: 10px; }
    .stats { gap: 10px; }
    .stat-card { min-height: 126px; padding: 14px; }
    .stat-card h2 { font-size: 26px; }
    .stat-card small { font-size: 9px; }
    .stat-icon { width: 30px; height: 30px; }
    .form-grid, .address-grid { grid-template-columns: minmax(0, 1fr); gap: 0; }
    .address-form-group { grid-column: auto; }
    .panel { padding: 16px; border-radius: 14px; }
    .quick-action { min-height: 55px; }
    th, td { padding: 10px; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; }
}
