:root {
    --navy-900: #0c1b33;
    --navy-800: #11254a;
    --navy-700: #16315e;
    --accent: #2f6fed;
    --accent-light: #eaf1fe;
    --bg: #f3f5f9;
    --surface: #ffffff;
    --border: #e4e8f0;
    --text: #1b2333;
    --text-muted: #6b7385;
    --success: #15803d;
    --success-bg: #ecfdf5;
    --warn: #b45309;
    --warn-bg: #fffbeb;
    --danger: #dc2626;
    --danger-bg: #fef2f2;
    --wa: #25d366;
    --reguler: #7c3aed;
    --reguler-bg: #f5f3ff;
    --radius-sm: 6px;
    --radius: 10px;
    --radius-lg: 16px;
    --shadow-sm: 0 1px 2px rgba(12, 27, 51, 0.06);
    --shadow: 0 4px 16px rgba(12, 27, 51, 0.08);
}

* { box-sizing: border-box; }

html, body { max-width: 100%; overflow-x: hidden; }

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    margin: 0;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); }

/* Topbar */
.topbar {
    background: linear-gradient(135deg, var(--navy-900), var(--navy-700));
    color: #fff;
    padding: 14px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
    box-shadow: 0 2px 10px rgba(12, 27, 51, 0.18);
}
.topbar-brand { display: flex; align-items: center; gap: 12px; text-decoration: none; color: #fff; }
.topbar-logo { height: 38px; width: auto; display: block; }
.topbar-title { font-weight: 600; font-size: 0.98rem; display: flex; flex-direction: column; line-height: 1.25; padding-left: 12px; border-left: 1px solid rgba(255,255,255,0.25); }
.topbar-title small { font-weight: 400; font-size: 0.72rem; color: #b9c6e6; }
.topbar-user { font-size: 0.88rem; display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.topbar-nav { display: flex; gap: 14px; }
.topbar-link { color: #cfdcfb; text-decoration: none; font-weight: 500; }
.topbar-link:hover { color: #fff; text-decoration: underline; }
.topbar-pill {
    background: rgba(255, 255, 255, 0.1);
    padding: 5px 12px;
    border-radius: 999px;
    color: #e7ecf8;
}
.topbar-logout { color: #fff; text-decoration: none; font-weight: 600; opacity: 0.85; }
.topbar-logout:hover { opacity: 1; text-decoration: underline; }

/* Bottom app-nav (mobile only, lihat media query di bawah) */
.bottom-nav {
    display: none;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 900;
    background: var(--surface);
    border-top: 1px solid var(--border);
    box-shadow: 0 -2px 14px rgba(12, 27, 51, 0.1);
    padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
}
.bottom-nav-link {
    flex: 1 1 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    padding: 6px 2px;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.66rem;
    font-weight: 600;
    line-height: 1.1;
}
.bottom-nav-link .nav-icon { width: 21px; height: 21px; flex-shrink: 0; }
.bottom-nav-link.active { color: var(--accent); background: var(--accent-light); }
.bottom-nav-link:active { color: var(--accent); }

/* Layout */
.container { max-width: 1120px; margin: 0 auto; padding: 28px 20px 64px; }
h1 { font-size: 1.5rem; font-weight: 700; margin: 0 0 18px; letter-spacing: -0.01em; }
h2 { font-size: 1.05rem; font-weight: 700; margin: 0 0 14px; color: var(--navy-800); }

/* Cards */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px 24px;
    margin-bottom: 18px;
    box-shadow: var(--shadow-sm);
}
.card.highlight { border-color: var(--accent); background: var(--accent-light); }

/* Forms */
.form-narrow { max-width: 440px; }
.form-narrow label, .berkas-item label { display: block; margin-top: 14px; margin-bottom: 4px; font-weight: 600; font-size: 0.88rem; color: var(--navy-800); }
.form-narrow input,
.form-narrow select,
.berkas-item input[type=file],
.berkas-item input[type=text],
.input {
    width: 100%;
    max-width: 440px;
    padding: 9px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.95rem;
    font-family: inherit;
    background: #fff;
    color: var(--text);
    transition: border-color 0.15s, box-shadow 0.15s;
}
.form-narrow input:focus,
.form-narrow select:focus,
.berkas-item input:focus,
.input:focus,
.filter-bar input:focus,
.filter-bar select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-light);
}
.input-sm { width: 110px; max-width: 110px; padding: 7px 10px; border: 1px solid var(--border); border-radius: var(--radius-sm); font-size: 0.88rem; }

/* Buttons */
.btn {
    display: inline-block;
    padding: 10px 20px;
    border-radius: var(--radius-sm);
    text-decoration: none;
    font-weight: 600;
    border: none;
    cursor: pointer;
    font-size: 0.92rem;
    transition: background 0.15s, transform 0.05s, box-shadow 0.15s;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--accent); color: #fff; margin-top: 18px; box-shadow: var(--shadow-sm); }
.btn-primary:hover { background: #2459c9; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #b91c1c; }
.btn-wa { background: var(--wa); color: #fff; box-shadow: var(--shadow-sm); }
.btn-wa:hover { background: #1fb858; }
.btn-link { background: none; border: none; color: var(--accent); text-decoration: none; cursor: pointer; padding: 0; font-size: 0.88rem; font-weight: 600; }
.btn-link:hover { text-decoration: underline; }
.text-danger { color: var(--danger) !important; }
.inline-form { display: inline; margin-left: 10px; }

.action-row { display: flex; align-items: center; gap: 12px; margin: 12px 0; flex-wrap: wrap; }
.hint { color: var(--text-muted); font-size: 0.85rem; }

/* Tables */
.table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: var(--radius);
    scrollbar-width: thin;
    scrollbar-color: var(--border) transparent;
}
.table-wrap::-webkit-scrollbar { height: 8px; }
.table-wrap::-webkit-scrollbar-track { background: transparent; }
.table-wrap::-webkit-scrollbar-thumb { background: var(--border); border-radius: 999px; }
.table-wrap::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }
.table {
    width: 100%;
    border-collapse: collapse;
    background: var(--surface);
    border-radius: var(--radius);
    overflow: hidden;
}
.table th {
    text-align: left;
    padding: 11px 14px;
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--text-muted);
    background: #f8f9fc;
    border-bottom: 1px solid var(--border);
}
.table td {
    text-align: left;
    padding: 12px 14px;
    border-bottom: 1px solid var(--border);
    font-size: 0.9rem;
    vertical-align: middle;
}
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr:hover { background: #f8faff; }

/* Badges */
.badge {
    display: inline-block;
    background: #eef1f6;
    color: var(--text-muted);
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 0.78rem;
    font-weight: 600;
}
.badge-ok { background: var(--success-bg); color: var(--success); }
.badge-warn { background: var(--warn-bg); color: var(--warn); }
.badge-cancelled { background: var(--danger-bg); color: var(--danger); }
.badge-wajib { background: var(--danger-bg); color: var(--danger); padding: 2px 9px; border-radius: 999px; font-size: 0.72rem; font-weight: 700; margin-left: 6px; }
.badge-opsional { background: #eef1f6; color: var(--text-muted); padding: 2px 9px; border-radius: 999px; font-size: 0.72rem; font-weight: 700; margin-left: 6px; }
.badge-stale { background: var(--warn-bg); color: var(--warn); padding: 2px 9px; border-radius: 999px; font-size: 0.72rem; font-weight: 700; margin-left: 6px; }
.badge-reguler { background: var(--reguler-bg); color: var(--reguler); }
.badge-full-online { background: var(--accent-light); color: var(--accent); }

/* Pagination */
.pagination { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 12px; }
.page-link { display: inline-flex; align-items: center; justify-content: center; min-width: 32px; height: 32px; padding: 0 8px; border: 1px solid var(--border); border-radius: var(--radius-sm); font-size: 0.85rem; font-weight: 600; color: var(--text-muted); text-decoration: none; background: var(--surface); }
.page-link:hover { background: var(--accent-light); color: var(--accent); }
.page-link.active { background: var(--accent); color: #fff; border-color: var(--accent); }

/* Split dashboard: Reguler & Full Online. Selalu ditumpuk vertikal (bukan
   2 kolom) supaya tiap tabel selalu dapat lebar penuh container -- tabel
   pendaftar butuh ~900px+ untuk 7-8 kolom tanpa scroll, dan itu tidak akan
   pernah cukup kalau dibagi 2 kolom berdampingan. */
.split-dashboard { display: grid; grid-template-columns: 1fr; gap: 28px; }
.split-col h2 { margin-top: 0; margin-bottom: 12px; font-size: 1rem; }

/* Filters */
.filter-bar { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 18px; align-items: center; }
.filter-bar input, .filter-bar select {
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.88rem;
    background: var(--surface);
}

/* Stats */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 14px; }
.stat-box { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; text-align: center; box-shadow: var(--shadow-sm); }
.stat-box .num { font-size: 1.9rem; font-weight: 800; color: var(--navy-800); letter-spacing: -0.02em; }
.stat-box .label { font-size: 0.8rem; color: var(--text-muted); margin-top: 4px; }

/* Flash messages */
.flash { padding: 12px 16px; border-radius: var(--radius-sm); margin-bottom: 18px; font-size: 0.9rem; font-weight: 500; }
.flash-success { background: var(--success-bg); color: var(--success); }
.flash-error { background: var(--danger-bg); color: var(--danger); }

/* Upload checklist */
.berkas-item { margin-bottom: 20px; padding-bottom: 16px; border-bottom: 1px solid var(--border); }
.berkas-item:last-child { border-bottom: none; margin-bottom: 0; padding-bottom: 0; }
.status-ok { color: var(--success); font-weight: 600; }
.status-bad { color: var(--danger); font-weight: 600; }
.status-pending { color: var(--warn); font-weight: 600; }
.status-loading { color: var(--accent); font-weight: 600; }
.status-loading::before {
    content: "";
    display: inline-block;
    width: 13px;
    height: 13px;
    margin-right: 7px;
    border: 2px solid var(--accent-light);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
    vertical-align: middle;
}
@keyframes spin { to { transform: rotate(360deg); } }
.progress { font-weight: 700; color: var(--navy-800); }

/* Modal */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(12, 27, 51, 0.72);
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 16px;
    box-sizing: border-box;
}
.modal-overlay.open { display: flex; }
.modal-box {
    background: #fff;
    border-radius: var(--radius);
    padding: 40px 16px 16px;
    width: 100%;
    max-width: 900px;
    max-height: 100%;
    position: relative;
    display: flex;
    box-sizing: border-box;
    overflow: auto;
    box-shadow: var(--shadow);
}
.modal-close {
    position: absolute;
    top: 6px;
    right: 10px;
    background: #f1f3f8;
    border: none;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    font-size: 1.4rem;
    line-height: 1;
    cursor: pointer;
    color: var(--text-muted);
}
.modal-close:hover { background: var(--border); color: var(--text); }
#preview-content { width: 100%; display: flex; justify-content: center; }
#preview-content img { max-width: 100%; max-height: 80vh; display: block; object-fit: contain; border-radius: var(--radius-sm); }
#preview-content iframe { width: 100%; height: 75vh; border: none; border-radius: var(--radius-sm); }

/* Tablet ke bawah: sembunyikan nav teks di topbar & tombol keluar, digantikan bottom-nav */
@media (max-width: 720px) {
    .topbar-nav, .topbar-logout { display: none; }
    .topbar-user { gap: 8px; }
    .topbar-pill { font-size: 0.76rem; padding: 4px 10px; }
    .bottom-nav { display: flex; }
    body.has-bottom-nav .container { padding-bottom: 88px; }
}

@media (max-width: 600px) {
    .topbar { padding: 10px 14px; }
    .topbar-logo { height: 26px; }
    .topbar-title { padding-left: 8px; }
    .container { padding: 16px 12px 48px; }
    .card { padding: 14px 16px; border-radius: var(--radius); }
    h1 { font-size: 1.22rem; }
    .modal-overlay { padding: 0; }
    .modal-box { max-width: 100%; height: 100%; max-height: 100%; border-radius: 0; }
    #preview-content iframe { height: 100%; }
    .table-wrap { border-radius: var(--radius-sm); }
    .table th, .table td { padding: 9px 10px; font-size: 0.83rem; }

    /* Form & filter jadi tumpuk penuh-lebar, lebih terasa seperti aplikasi */
    .form-narrow, .form-narrow input, .form-narrow select, .input { max-width: 100%; }
    .filter-bar { flex-direction: column; align-items: stretch; gap: 8px; }
    .filter-bar input, .filter-bar select { width: 100%; }
    .filter-bar .btn-link { text-align: center; padding: 8px 0; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); }
    .btn, .btn-primary { width: 100%; text-align: center; }
    .action-row { flex-direction: column; align-items: stretch; }
    .action-row .btn { width: 100%; text-align: center; }
    .inline-form { display: block; margin: 8px 0 0; }
    .inline-form .input-sm { width: 100%; max-width: 100%; margin-bottom: 6px; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); }

    /* Tabel daftar pendaftar -> kartu bertumpuk, tidak perlu scroll ke samping lagi */
    .table-wrap.cards-on-mobile { overflow-x: visible; border-radius: 0; }
    .cards-on-mobile table, .cards-on-mobile tbody, .cards-on-mobile tr, .cards-on-mobile td { display: block; width: 100%; }
    .cards-on-mobile thead { display: none; }
    .cards-on-mobile tbody tr {
        background: var(--surface);
        border: 1px solid var(--border);
        border-radius: var(--radius);
        margin-bottom: 12px;
        padding: 4px 14px;
        box-shadow: var(--shadow-sm);
    }
    .cards-on-mobile td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        gap: 12px;
        text-align: right;
        padding: 10px 0;
        border-bottom: 1px solid var(--border);
        font-size: 0.88rem;
    }
    .cards-on-mobile td:last-child { border-bottom: none; }
    .cards-on-mobile td[data-label]::before {
        content: attr(data-label);
        font-weight: 700;
        font-size: 0.68rem;
        text-transform: uppercase;
        letter-spacing: 0.03em;
        color: var(--text-muted);
        text-align: left;
        flex-shrink: 0;
    }
    .cards-on-mobile td.table-empty { display: block; text-align: left; padding: 14px 0; }
}
