:root {
    --bg: #0f172a;
    --bg-soft: #1e293b;
    --surface: #ffffff;
    --surface-2: #f8fafc;
    --border: #e2e8f0;
    --text: #0f172a;
    --muted: #64748b;
    --primary: #0ea5e9;
    --primary-dark: #0284c7;
    --accent: #14b8a6;
    --accent-dark: #0d9488;
    --shadow: 0 10px 30px rgba(15, 23, 42, .08);
    --radius: 14px;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    color: var(--text);
    background:
        radial-gradient(1200px 500px at 10% -10%, rgba(14,165,233,.18), transparent),
        radial-gradient(1000px 500px at 100% 0%, rgba(20,184,166,.16), transparent),
        #eef2f7;
    min-height: 100vh;
}

.topbar {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 16px;
    padding: 18px 28px;
    background: linear-gradient(120deg, #0c4a6e, #0e7490);
    color: #e0f2fe;
    box-shadow: var(--shadow);
}

.user-box {
    position: absolute;
    top: 50%;
    right: 24px;
    transform: translateY(-50%);
    display: flex;
    align-items: center;
    gap: 12px;
}
.user-name { font-size: 13px; font-weight: 600; color: #e0f2fe; white-space: nowrap; }
.btn-logout {
    background: rgba(255,255,255,.14);
    color: #fff;
    border: 1px solid rgba(255,255,255,.28);
    text-decoration: none;
    padding: 8px 14px;
}
.btn-logout:hover { background: rgba(255,255,255,.26); color: #fff; }

.logos { display: flex; align-items: center; gap: 16px; }
.logo-img {
    height: 44px;
    width: auto;
    object-fit: contain;
    background: #fff;
    padding: 5px 8px;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(15,23,42,.18);
}

/* "didukung oleh AKKII" support text */
.support-text {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    font-weight: 600;
    color: #e0f2fe;
    background: rgba(255,255,255,.12);
    border: 1px solid rgba(255,255,255,.24);
    border-radius: 999px;
    padding: 5px 12px;
    white-space: nowrap;
}
.support-text strong { color: #fff; }

.brand { display: flex; align-items: center; justify-content: center; gap: 16px; text-align: center; }
.brand h1 { margin: 0; font-size: 20px; font-weight: 700; letter-spacing: -.2px; }
.brand p { margin: 2px 0 0; font-size: 12.5px; opacity: .85; }
.brand code { background: rgba(255,255,255,.15); padding: 1px 6px; border-radius: 6px; }
.brand p a { color: #fff; text-decoration: underline; text-underline-offset: 2px; font-weight: 600; }
.brand p a:hover { color: #bae6fd; }

main {
    max-width: 1200px;
    margin: 26px auto;
    padding: 0 20px 60px;
    display: flex;
    flex-direction: column;
    gap: 22px;
}

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 22px;
}

.filters-head, .results-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}
.filters-head h2 { margin: 0; font-size: 16px; }
.filters-actions { display: flex; align-items: center; gap: 10px; }

.btn-apply {
    background: linear-gradient(120deg, var(--primary), var(--primary-dark));
    color: #fff;
    box-shadow: 0 6px 16px rgba(14,165,233,.35);
}
.btn-apply:hover { box-shadow: 0 8px 22px rgba(14,165,233,.45); }

.filter-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 14px;
}

.field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 500; color: var(--muted); }
.field select {
    appearance: none;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--surface-2) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2364748b' d='M3 4.5 6 8l3-3.5z'/%3E%3C/svg%3E") no-repeat right 12px center;
    font-size: 14px;
    color: var(--text);
    cursor: pointer;
    transition: border-color .15s, box-shadow .15s;
}
.field select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(14,165,233,.15);
}

.btn {
    border: none;
    border-radius: 10px;
    padding: 10px 16px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: transform .08s, background .15s, box-shadow .15s;
}
.btn:active { transform: translateY(1px); }
.btn-export {
    background: linear-gradient(120deg, var(--accent), var(--accent-dark));
    color: #fff;
    box-shadow: 0 6px 16px rgba(13,148,136,.35);
}
.btn-export:hover { box-shadow: 0 8px 22px rgba(13,148,136,.45); }
.btn-export:disabled { opacity: .6; cursor: progress; }
.btn-ghost {
    background: var(--surface-2);
    color: var(--muted);
    border: 1px solid var(--border);
}
.btn-ghost:hover:not(:disabled) { background: #eef2f7; color: var(--text); }
.btn-ghost:disabled { opacity: .45; cursor: not-allowed; }

.summary { font-size: 14px; color: var(--muted); }
.summary strong { color: var(--primary-dark); font-size: 18px; }
.page-size { font-size: 13px; color: var(--muted); }
.page-size select { margin: 0 4px; padding: 6px 8px; border-radius: 8px; border: 1px solid var(--border); }

.table-wrap { position: relative; overflow-x: auto; border: 1px solid var(--border); border-radius: 12px; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
thead th {
    position: sticky; top: 0;
    background: #f1f5f9;
    text-align: left;
    padding: 11px 14px;
    font-weight: 600;
    color: #334155;
    white-space: nowrap;
    border-bottom: 1px solid var(--border);
}
tbody td { padding: 10px 14px; border-bottom: 1px solid #f1f5f9; white-space: nowrap; }
tbody tr:hover { background: #f8fafc; }
tbody tr:last-child td { border-bottom: none; }

.empty, .loading {
    padding: 40px;
    text-align: center;
    color: var(--muted);
    font-size: 14px;
}
.hidden { display: none !important; }
.loading { position: absolute; inset: 0; background: rgba(255,255,255,.7); display: flex; align-items: center; justify-content: center; }
.spinner {
    width: 34px; height: 34px;
    border: 3px solid #cbd5e1;
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 18px;
    margin-top: 16px;
    font-size: 13.5px;
    color: var(--muted);
}

.toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    background: #0f172a;
    color: #fff;
    padding: 12px 20px;
    border-radius: 10px;
    font-size: 13.5px;
    box-shadow: var(--shadow);
    z-index: 50;
    opacity: 1;
    transition: opacity .3s;
}
.toast.hidden { opacity: 0; pointer-events: none; }

/* ------------------------- Admin Panel ------------------------- */

.admin-subnav {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 8px;
}
.admin-subnav a {
    padding: 9px 16px;
    border-radius: 9px;
    font-size: 14px;
    font-weight: 600;
    color: var(--muted);
    text-decoration: none;
    transition: background .15s, color .15s;
}
.admin-subnav a:hover { background: var(--surface-2); color: var(--text); }
.admin-subnav a.active {
    background: linear-gradient(120deg, var(--primary), var(--primary-dark));
    color: #fff;
}

.section-desc { font-size: 13.5px; color: var(--muted); margin: 2px 2px 4px; }

.card-title { margin: 0 0 14px; font-size: 15px; color: var(--text); }

.admin-grid { display: grid; grid-template-columns: 360px 1fr; gap: 22px; align-items: start; }
.admin-cols { display: grid; grid-template-columns: 320px 1fr; gap: 22px; align-items: start; }
@media (max-width: 900px) {
    .admin-grid, .admin-cols { grid-template-columns: 1fr; }
}

.admin-form { display: flex; flex-direction: column; gap: 14px; }
.admin-form .field span { margin-bottom: 0; }
.admin-form input, .admin-toolbar input, .admin-toolbar select {
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--surface-2);
    font-size: 14px;
    color: var(--text);
}
.admin-form input:focus, .admin-toolbar input:focus, .admin-toolbar select:focus {
    outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(14,165,233,.15);
}

.admin-toolbar { display: flex; flex-wrap: wrap; gap: 14px; align-items: flex-end; margin-bottom: 16px; }
.admin-toolbar .field { min-width: 180px; }
.toolbar-actions { display: flex; gap: 10px; }

.auth-msg {
    border-radius: 10px;
    padding: 11px 14px;
    font-size: 13.5px;
    margin-bottom: 4px;
}
.auth-ok { background: #ecfdf5; color: #047857; border: 1px solid #a7f3d0; }
.auth-err { background: #fef2f2; color: #b91c1c; border: 1px solid #fecaca; }

.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 11.5px;
    font-weight: 600;
    text-transform: capitalize;
}
.badge-admin { background: #e0f2fe; color: #0369a1; }
.badge-user  { background: #f1f5f9; color: #475569; }
.badge-danger { background: #fee2e2; color: #b91c1c; }

.link-btn {
    background: none; border: none; padding: 0; cursor: pointer;
    font-size: 13px; font-weight: 600; color: var(--primary-dark);
    font-family: inherit;
}
.link-btn:hover { text-decoration: underline; }
.link-btn.danger { color: #dc2626; }

.muted { color: #94a3b8; }
.nowrap { white-space: nowrap; }
.empty-cell { text-align: center; color: var(--muted); padding: 24px; }
.ua-cell { color: var(--muted); font-size: 12.5px; }

.stat-chips { display: flex; flex-wrap: wrap; gap: 14px; margin-bottom: 4px; }
.stat-chip {
    flex: 1 1 160px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 16px 18px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.stat-chip .num { font-size: 26px; font-weight: 700; color: var(--primary-dark); }
.stat-chip .lbl { font-size: 12.5px; color: var(--muted); }

.pw-wrap { max-width: 460px; margin: 0 auto; width: 100%; }
.pw-card { display: flex; flex-direction: column; gap: 14px; }
.pw-card .field span { margin-bottom: 0; }
.pw-card input {
    padding: 11px 13px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--surface-2);
    font-size: 15px;
    color: var(--text);
    width: 100%;
}
.pw-card input:focus {
    outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(14,165,233,.15);
}
.pw-card .btn-apply { justify-content: center; }
.pw-actions { display: flex; gap: 10px; margin-top: 4px; }
.pw-actions .btn { flex: 1 1 auto; justify-content: center; }

/* ------------------------- Login ------------------------- */

.login-body {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background:
        radial-gradient(900px 500px at 15% 0%, rgba(14,165,233,.28), transparent),
        radial-gradient(900px 500px at 100% 100%, rgba(20,184,166,.28), transparent),
        linear-gradient(135deg, #0c4a6e, #0e7490 60%, #0d9488);
}
.login-wrap { width: 100%; max-width: 420px; }
.login-card {
    background: var(--surface);
    border-radius: 18px;
    box-shadow: 0 24px 60px rgba(8, 47, 73, .35);
    overflow: hidden;
}

/* Gradient header band */
.login-head {
    background: linear-gradient(120deg, #0c4a6e, #0e7490);
    padding: 28px 28px 22px;
    text-align: center;
    color: #e0f2fe;
}
.login-logos {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-bottom: 16px;
}
.login-logos .logo-img {
    height: 46px;
    background: #fff;
    border-radius: 10px;
    padding: 6px 8px;
    box-shadow: 0 4px 12px rgba(8,47,73,.25);
}
.login-head .support-text { margin-bottom: 14px; }
.login-head h1 {
    margin: 0;
    font-size: 19px;
    font-weight: 700;
    line-height: 1.3;
    color: #fff;
    letter-spacing: -.2px;
}
.login-head-sub { margin: 6px 0 0; font-size: 12.5px; opacity: .85; }

/* Form area */
.login-form { padding: 26px 28px 8px; }
.login-sub { margin: 0 0 20px; font-size: 13.5px; color: var(--muted); text-align: center; }

.login-field { display: block; text-align: left; margin-bottom: 16px; }
.login-field span { display: block; font-size: 13px; font-weight: 600; color: var(--text); margin-bottom: 7px; }
.login-field input {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: 11px;
    background: var(--surface-2);
    font-size: 15px;
    color: var(--text);
    transition: border-color .15s, box-shadow .15s, background .15s;
}
.login-field input::placeholder { color: #94a3b8; }
.login-field input:focus {
    outline: none;
    background: #fff;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(14,165,233,.15);
}
.login-btn { width: 100%; justify-content: center; margin-top: 4px; padding: 13px; font-size: 15px; border-radius: 11px; }

.login-error {
    background: #fef2f2;
    color: #b91c1c;
    border: 1px solid #fecaca;
    border-radius: 10px;
    padding: 11px 13px;
    font-size: 13px;
    margin-bottom: 16px;
    text-align: center;
}

.login-foot {
    margin: 0;
    padding: 16px 28px 22px;
    text-align: center;
    font-size: 11.5px;
    color: #94a3b8;
}

@media (max-width: 480px) {
    .login-head h1 { font-size: 17px; }
    .login-logos .logo-img { height: 40px; }
    .login-head, .login-form { padding-left: 20px; padding-right: 20px; }
}

/* ------------------------- Responsive ------------------------- */

/* Tablet & below */
@media (max-width: 768px) {
    .topbar { padding: 14px 18px; }
    .brand h1 { font-size: 17px; }
    .logo-img { height: 38px; }
    main { margin: 18px auto; padding: 0 14px 48px; gap: 16px; }
    .card { padding: 18px; }
}

/* Phones */
@media (max-width: 640px) {
    .topbar {
        flex-direction: column;
        align-items: center;
        gap: 12px;
        padding: 14px 16px;
    }
    .brand { flex-direction: column; align-items: center; gap: 12px; }
    .logos { flex-wrap: wrap; gap: 10px; justify-content: center; }
    .user-box {
        position: static;
        transform: none;
        width: 100%;
        justify-content: center;
        order: 3;
    }
    .logo-img { height: 34px; }
    .brand h1 { font-size: 16px; }
    .brand p { font-size: 11.5px; }

    main { padding: 0 10px 40px; }
    .card { padding: 14px; border-radius: 12px; }

    /* Stack section headers and let actions wrap full width */
    .filters-head { flex-direction: column; align-items: stretch; gap: 12px; }
    .filters-actions { width: 100%; flex-wrap: wrap; }
    .filters-actions .btn { flex: 1 1 auto; justify-content: center; }

    /* Single column filters */
    .filter-grid { grid-template-columns: 1fr; }

    /* 16px prevents iOS Safari from auto-zooming on focus */
    .field select { font-size: 16px; padding: 12px; }

    .results-head { flex-direction: column; align-items: stretch; gap: 10px; }
    .page-size { display: flex; }

    /* Tighter table on small screens */
    thead th { padding: 9px 10px; }
    tbody td { padding: 8px 10px; }
    table { font-size: 12.5px; }

    .pagination { gap: 10px; flex-wrap: wrap; }
    .pagination .btn { flex: 1 1 auto; justify-content: center; }
    #pageInfo { order: -1; width: 100%; text-align: center; }

    .toast { left: 12px; right: 12px; transform: none; text-align: center; }
    .toast.hidden { transform: none; }
}
