/*
 * Gaya mengikuti Filament (v3): permukaan terang, border tipis, radius 8-12px,
 * bayangan minimal, tipografi rapat. Nama variabel & class tidak diubah.
 *
 * Catatan nilai variabel:
 *   --navy   = permukaan sidebar (putih, seperti Filament)
 *   --navy-2 = permukaan hover/aktif yang lebih redup
 */
:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --navy: #ffffff;
    --navy-2: #f3f4f6;
    --bg: #f9fafb;
    --text: #030712;
    --muted: #6b7280;
    --border: #e5e7eb;
    --sidebar-w: 260px;

    /* token tambahan (internal) */
    --ring: rgba(3, 7, 18, .08);
    --primary-soft: #eff6ff;
    --radius: 8px;
    --radius-lg: 12px;
    --shadow-sm: 0 1px 2px rgba(3, 7, 18, .05);
}

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    background: var(--bg);
    color: var(--text);
    -webkit-font-smoothing: antialiased;
}

:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

/* ========== LOGIN ========== */
.guest-wrap {
    min-height: 100vh;
    background: var(--bg);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px 16px;
}
.login-card {
    width: 100%;
    max-width: 420px;
    background: #fff;
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-sm), 0 0 0 1px var(--ring);
}
.login-head {
    text-align: center;
    color: var(--text);
    padding: 36px 28px 8px;
    background: transparent;
}
.login-head::after { content: none; }
.login-logo {
    width: 48px;
    height: 48px;
    margin: 0 auto 16px;
    border-radius: var(--radius);
    background: var(--primary);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
}
.login-head h1 { font-size: 22px; font-weight: 700; letter-spacing: -.01em; margin: 0 0 4px; }
.login-head p { margin: 0; color: var(--muted); font-size: 14px; }
.login-body { padding: 24px 28px 28px; }
.login-label {
    text-align: center;
    font-size: 13px;
    font-weight: 500;
    color: var(--muted);
    margin-bottom: 16px;
}
.role-btn {
    width: 100%;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px 8px;
    font-weight: 500;
    font-size: 14px;
    color: var(--text);
    transition: border-color .15s, background-color .15s;
}
.role-btn i { display: block; font-size: 22px; color: var(--muted); margin-bottom: 6px; transition: color .15s; }
.role-btn:hover {
    border-color: var(--primary);
    background: var(--primary-soft);
}
.role-btn:hover i { color: var(--primary); }
.login-note { text-align: center; color: var(--muted); font-size: 13px; margin: 20px 0 0; }

/* ========== SIDEBAR ========== */
.sidebar {
    position: fixed;
    top: 0; bottom: 0; left: 0;
    width: var(--sidebar-w);
    background: var(--navy);
    color: var(--muted);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    z-index: 1040;
    transition: transform .25s ease;
}
.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    height: 64px;
    padding: 0 20px;
    border-bottom: 1px solid var(--border);
}
.brand-icon {
    width: 32px; height: 32px;
    border-radius: var(--radius);
    background: var(--primary);
    color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-size: 16px;
}
.brand-title { color: var(--text); font-weight: 700; font-size: 16px; line-height: 1.2; letter-spacing: -.01em; }
.brand-sub { font-size: 12px; color: var(--muted); }

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
}
.avatar {
    width: 36px; height: 36px;
    border-radius: 50%;
    background: var(--primary-soft);
    color: var(--primary-dark);
    font-weight: 600;
    font-size: 13px;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}
.user-name { color: var(--text); font-weight: 600; font-size: 14px; line-height: 1.3; }
.role-badge {
    display: inline-block;
    margin-top: 2px;
    font-size: 12px;
    font-weight: 500;
    color: var(--primary-dark);
    background: var(--primary-soft);
    padding: 1px 8px;
    border-radius: 6px;
    box-shadow: inset 0 0 0 1px rgba(37, 99, 235, .2);
}

.sidebar-nav { flex: 1; overflow-y: auto; padding: 16px 12px; }
.nav-item-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 12px;
    margin-bottom: 2px;
    border-radius: var(--radius);
    color: #374151;
    font-weight: 500;
    font-size: 14px;
    text-decoration: none;
    transition: background-color .15s, color .15s;
}
.nav-item-link i { font-size: 18px; width: 22px; text-align: center; color: #9ca3af; transition: color .15s; }
.nav-item-link:hover { background: var(--navy-2); color: var(--text); }
.nav-item-link:hover i { color: #6b7280; }
.nav-item-link.active { background: var(--navy-2); color: var(--primary); }
.nav-item-link.active i { color: var(--primary); }

.sidebar-footer { padding: 12px; border-top: 1px solid var(--border); }
.logout-btn {
    width: 100%;
    background: transparent;
    border: 0;
    color: #dc2626;
    font-weight: 500;
    padding: 8px 12px;
    border-radius: var(--radius);
    text-align: left;
}
.logout-btn:hover { background: #fef2f2; }

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(3, 7, 18, .4);
    z-index: 1030;
}
.sidebar-overlay.show { display: block; }

@media (max-width: 991.98px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.show { transform: translateX(0); }
}
@media (min-width: 992px) {
    .main { margin-left: var(--sidebar-w); }
    .sidebar-overlay { display: none !important; }
}

/* ========== TOPBAR & CONTENT ========== */
.topbar {
    position: sticky;
    top: 0;
    z-index: 1020;
    height: 64px;
    background: #fff;
    border-bottom: 1px solid var(--border);
    padding: 0 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}
.topbar h2 { font-size: 16px; font-weight: 600; margin: 0; }
.menu-toggle {
    border: 1px solid var(--border);
    background: #fff;
    border-radius: var(--radius);
    width: 36px; height: 36px;
    font-size: 18px;
    color: var(--muted);
}
.menu-toggle:hover { background: var(--navy-2); }
.role-switch {
    background: #fff;
    color: var(--text);
    border: 1px solid var(--border);
    font-weight: 500;
    border-radius: var(--radius);
    padding: 6px 12px;
    box-shadow: var(--shadow-sm);
}
.role-switch:hover { background: var(--navy-2); color: var(--text); }

.content { padding: 32px 24px; }

/* ========== CARDS ========== */
.card-box {
    background: #fff;
    border-radius: var(--radius-lg);
    padding: 20px;
    height: 100%;
    box-shadow: var(--shadow-sm), 0 0 0 1px var(--ring);
}
.stat-label {
    font-size: 14px;
    font-weight: 500;
    color: var(--muted);
}
.stat-value { font-size: 30px; font-weight: 700; letter-spacing: -.02em; line-height: 1.2; margin: 6px 0; }
.stat-sub { font-size: 13px; color: #059669; font-weight: 500; }

.card-color {
    position: relative;
    overflow: hidden;
    border-radius: var(--radius-lg);
    padding: 20px;
    height: 100%;
    box-shadow: var(--shadow-sm), 0 0 0 1px var(--ring);
}
.card-color.blue { background: var(--primary-soft); color: var(--primary-dark); }
.card-color.orange { background: #fff7ed; color: #c2410c; }
.card-color .big-icon {
    position: absolute;
    right: 16px; bottom: 8px;
    font-size: 56px;
    opacity: .14;
}
.card-color .stat-label { color: inherit; opacity: .85; }
.card-color .stat-value { font-size: 28px; }
.card-color p { margin: 0; font-size: 13px; opacity: .85; }

/* ========== PHASE 2: PAGE, TABLE, FORM ========== */
.btn { border-radius: var(--radius); font-weight: 600; font-size: 14px; padding: 8px 14px; }
.btn-sm { padding: 5px 10px; font-size: 13px; border-radius: 6px; }
.btn-primary {
    --bs-btn-bg: var(--primary);
    --bs-btn-border-color: var(--primary);
    --bs-btn-hover-bg: var(--primary-dark);
    --bs-btn-hover-border-color: var(--primary-dark);
    --bs-btn-active-bg: var(--primary-dark);
    --bs-btn-active-border-color: var(--primary-dark);
    box-shadow: var(--shadow-sm);
}
.btn-soft {
    background: #fff;
    border: 1px solid var(--border);
    color: var(--text);
    box-shadow: var(--shadow-sm);
}
.btn-soft:hover { background: var(--navy-2); border-color: #d1d5db; }

.page-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 24px;
}
.page-head h4 { font-size: 24px; font-weight: 700; letter-spacing: -.02em; margin: 0; }

.card-box.flush { padding: 0; overflow: hidden; height: auto; }
.card-toolbar { padding: 16px 20px; border-bottom: 1px solid var(--border); }

.table-modern { margin: 0; font-size: 14px; }
.table-modern thead th {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
    background: var(--bg);
    border-bottom: 1px solid var(--border);
    padding: 12px 20px;
    white-space: nowrap;
}
.table-modern tbody td {
    padding: 14px 20px;
    vertical-align: middle;
    border-bottom: 1px solid var(--border);
}
.table-modern tbody tr:last-child td { border-bottom: 0; }
.table-modern tbody tr:hover { background: var(--bg); }

.avatar-sm {
    width: 36px; height: 36px;
    border-radius: 50%;
    background: var(--primary-soft);
    color: var(--primary-dark);
    font-weight: 600;
    font-size: 13px;
    display: inline-flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}

.code-pill {
    display: inline-block;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-weight: 600;
    font-size: 13px;
    color: var(--primary-dark);
    background: var(--primary-soft);
    padding: 2px 8px;
    border-radius: 6px;
    box-shadow: inset 0 0 0 1px rgba(37, 99, 235, .2);
}

.form-label { font-weight: 500; font-size: 14px; margin-bottom: 6px; }
.form-control, .form-select {
    border-radius: var(--radius);
    border-color: #d1d5db;
    padding: 8px 12px;
    font-size: 14px;
    box-shadow: var(--shadow-sm);
}
.form-control:focus, .form-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 1px var(--primary);
}

.empty-state { text-align: center; padding: 48px 20px; color: var(--muted); }
.empty-state i { font-size: 32px; color: #9ca3af; display: block; margin-bottom: 8px; }

.detail-row { display: flex; justify-content: space-between; gap: 16px; padding: 12px 0; border-bottom: 1px solid var(--border); }
.detail-row:last-child { border-bottom: 0; }
.detail-row .k { color: var(--muted); font-size: 14px; }
.detail-row .v { font-weight: 500; text-align: right; }

.referral-card .code {
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 28px;
    font-weight: 700;
    letter-spacing: .04em;
    color: var(--primary-dark);
}

/* ========== PHASE 3-7 ========== */
.badge-soft {
    display: inline-block;
    font-size: 12px;
    font-weight: 500;
    padding: 2px 8px;
    border-radius: 6px;
    white-space: nowrap;
}
.badge-soft.green  { background: #f0fdf4; color: #15803d; box-shadow: inset 0 0 0 1px rgba(22, 163, 74, .2); }
.badge-soft.gray   { background: #f9fafb; color: #4b5563; box-shadow: inset 0 0 0 1px rgba(107, 114, 128, .2); }
.badge-soft.orange { background: #fff7ed; color: #c2410c; box-shadow: inset 0 0 0 1px rgba(234, 88, 12, .2); }
.badge-soft.red    { background: #fef2f2; color: #b91c1c; box-shadow: inset 0 0 0 1px rgba(220, 38, 38, .2); }
.badge-soft.blue   { background: var(--primary-soft); color: var(--primary-dark); box-shadow: inset 0 0 0 1px rgba(37, 99, 235, .2); }

.progress-mini, .bar-track {
    background: #e5e7eb;
    border-radius: 99px;
    overflow: hidden;
}
.progress-mini { width: 70px; height: 6px; }
.bar-track { height: 8px; width: 100%; }
.progress-mini span, .bar-track span {
    display: block;
    height: 100%;
    background: var(--primary);
    border-radius: 99px;
}

.check-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
}
.check-row:last-child { border-bottom: 0; }
.check-row .ok { color: #16a34a; }
.check-row .no { color: #d1d5db; }

.date-box {
    width: 56px;
    flex-shrink: 0;
    text-align: center;
    background: var(--bg);
    border-radius: var(--radius);
    padding: 6px 0;
    color: var(--text);
    box-shadow: inset 0 0 0 1px var(--border);
}
.date-box .d { font-size: 20px; font-weight: 700; line-height: 1.1; }
.date-box .m { font-size: 12px; font-weight: 500; color: var(--muted); }

.q-card {
    background: #fff;
    border-radius: var(--radius-lg);
    padding: 16px;
    margin-bottom: 12px;
    box-shadow: var(--shadow-sm), 0 0 0 1px var(--ring);
}
.q-num {
    width: 28px; height: 28px;
    border-radius: 6px;
    background: var(--primary-soft);
    color: var(--primary-dark);
    font-weight: 600;
    font-size: 13px;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}

.table-modern .form-select { min-width: 130px; }

/* ========== AUTH ========== */
a.role-btn {
    display: block;
    text-align: center;
    text-decoration: none;
}
.login-body .btn-soft { border-radius: var(--radius); }

/* ========== FORM PUBLIK ========== */
.public-wrap {
    min-height: 100vh;
    background: var(--navy);
    padding: 32px 16px 48px;
}
.public-inner { max-width: 720px; margin: 0 auto; }
.public-inner .q-card { margin-bottom: 14px; }

.note-warn {
    background: #fff7ed;
    border: 1px solid #fed7aa;
    color: #9a3412;
    border-radius: 12px;
    padding: 12px 16px;
    font-size: 14px;
    margin: 16px 22px;
}
.card-toolbar .count { font-weight: 700; }

/* ========== TIPE ARMADA ========== */
.armada-tile {
    text-align: center;
    background: #eff6ff;
    border-radius: 16px;
    padding: 16px 8px;
    color: var(--primary-dark);
}
.armada-tile.orange { background: #fff7ed; color: #c2410c; }
.armada-tile i { font-size: 26px; }
.armada-tile .n { font-size: 32px; font-weight: 800; line-height: 1.1; }
.armada-tile .l { font-size: 13px; font-weight: 600; }

@media (max-width: 575.98px) {
    .content { padding: 20px 14px; }
    .topbar { padding: 0 14px; }
    .page-head h4 { font-size: 20px; }
    .stat-value { font-size: 26px; }
}

@media (prefers-reduced-motion: reduce) {
    * { transition: none !important; }
}