/* =====================================================================
   base.css — Sistem desain bersama (publik + admin)
   Navy (primer) · Emas (aksen) · Poppins · mode terang/gelap
   Warna primer/aksen dapat diganti dari Pengaturan (variabel --brand / --accent)
   ===================================================================== */
:root {
  --brand: #0B2A5B;
  --brand-700: color-mix(in srgb, var(--brand) 82%, #000);
  --brand-600: color-mix(in srgb, var(--brand) 88%, #fff);
  --brand-400: color-mix(in srgb, var(--brand) 60%, #fff);
  --brand-100: color-mix(in srgb, var(--brand) 10%, #fff);
  --brand-50: color-mix(in srgb, var(--brand) 5%, #fff);
  --brand-ink: #ffffff;
  --accent: #F5B700;
  --accent-600: color-mix(in srgb, var(--accent) 85%, #000);
  --accent-100: color-mix(in srgb, var(--accent) 16%, #fff);
  --accent-ink: #1C1400;

  --bg: #F5F8FC;
  --bg-soft: #EAF1FB;
  --surface: #FFFFFF;
  --surface-2: #F8FAFD;
  --line: #E2E8F2;
  --line-strong: #CBD5E3;
  --ink: #0F1B33;
  --ink-2: #33415C;
  --muted: #5B6B85;
  --link: var(--brand);
  --brand-text: var(--brand);          /* teks berwarna brand (kontras di kedua mode) */

  --ok: #15803D;   --ok-bg: #E7F6EC;
  --warn: #B45309; --warn-bg: #FEF3E2;
  --bad: #B91C1C;  --bad-bg: #FDECEC;
  --info: #1D4ED8; --info-bg: #E8EFFD;
  --violet: #6D28D9; --violet-bg: #F1EAFE;

  --r-sm: 8px; --r: 12px; --r-lg: 18px; --r-xl: 24px;
  --sh-1: 0 1px 2px rgba(15, 27, 51, .06), 0 1px 3px rgba(15, 27, 51, .05);
  --sh-2: 0 4px 16px rgba(15, 27, 51, .08);
  --sh-3: 0 18px 48px rgba(11, 42, 91, .16);
  --focus: 0 0 0 3px color-mix(in srgb, var(--accent) 55%, transparent);
  --t: 180ms cubic-bezier(.2, .7, .3, 1);
  --font: 'Poppins', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --mono: ui-monospace, 'SFMono-Regular', Menlo, Consolas, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #07101E; --bg-soft: #0C1830; --surface: #0F1B30; --surface-2: #13223B; --line: #22344F; --line-strong: #2F4566;
    --ink: #E8EEF8; --ink-2: #C3D0E4; --muted: #93A5C1;
    --brand-100: color-mix(in srgb, var(--brand) 40%, #0F1B30); --brand-50: color-mix(in srgb, var(--brand) 25%, #0F1B30);
    --brand-text: color-mix(in srgb, var(--brand) 35%, #fff); --link: var(--accent);
    --ok: #4ADE80; --ok-bg: #0F2A1B; --warn: #FBBF24; --warn-bg: #2B2110; --bad: #F87171; --bad-bg: #2E1416;
    --info: #93B4FF; --info-bg: #13244A; --violet: #C4B5FD; --violet-bg: #231A45;
    --accent-100: color-mix(in srgb, var(--accent) 18%, #0F1B30);
    --sh-1: 0 1px 2px rgba(0, 0, 0, .4); --sh-2: 0 6px 20px rgba(0, 0, 0, .35); --sh-3: 0 18px 48px rgba(0, 0, 0, .5);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #07101E; --bg-soft: #0C1830; --surface: #0F1B30; --surface-2: #13223B; --line: #22344F; --line-strong: #2F4566;
  --ink: #E8EEF8; --ink-2: #C3D0E4; --muted: #93A5C1;
  --brand-100: color-mix(in srgb, var(--brand) 40%, #0F1B30); --brand-50: color-mix(in srgb, var(--brand) 25%, #0F1B30);
  --brand-text: color-mix(in srgb, var(--brand) 35%, #fff); --link: var(--accent);
  --ok: #4ADE80; --ok-bg: #0F2A1B; --warn: #FBBF24; --warn-bg: #2B2110; --bad: #F87171; --bad-bg: #2E1416;
  --info: #93B4FF; --info-bg: #13244A; --violet: #C4B5FD; --violet-bg: #231A45;
  --accent-100: color-mix(in srgb, var(--accent) 18%, #0F1B30);
  --sh-1: 0 1px 2px rgba(0, 0, 0, .4); --sh-2: 0 6px 20px rgba(0, 0, 0, .35); --sh-3: 0 18px 48px rgba(0, 0, 0, .5);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; scroll-padding-top: 84px; }
body { margin: 0; font-family: var(--font); font-size: 15px; line-height: 1.6; color: var(--ink); background: var(--bg); -webkit-font-smoothing: antialiased; transition: background var(--t), color var(--t); overflow-x: hidden; }
img, svg { display: block; max-width: 100%; }
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
h1, h2, h3, h4 { margin: 0 0 .4em; line-height: 1.22; color: var(--ink); letter-spacing: -.01em; }
h1 { font-size: clamp(28px, 4.4vw, 46px); font-weight: 700; }
h2 { font-size: clamp(22px, 3vw, 32px); font-weight: 700; }
h3 { font-size: 18px; font-weight: 600; }
p { margin: 0 0 1em; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: none; box-shadow: var(--focus); border-radius: 6px; }
::selection { background: color-mix(in srgb, var(--accent) 45%, transparent); }
.sr-only { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--muted); }
.mono { font-family: var(--mono); letter-spacing: .02em; }
.hidden { display: none !important; }
.ico { width: 20px; height: 20px; flex: none; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; display: inline-block; vertical-align: middle; }
.ico-sm { width: 16px; height: 16px; } .ico-lg { width: 26px; height: 26px; } .ico-xl { width: 34px; height: 34px; }

/* ---------- Tombol ---------- */
.btn { --b: var(--brand); display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 10px 18px; border-radius: 12px;
  border: 1.5px solid transparent; background: var(--b); color: var(--brand-ink); font-weight: 600; font-size: 14.5px; cursor: pointer; white-space: nowrap;
  transition: transform var(--t), background var(--t), box-shadow var(--t), border-color var(--t), color var(--t); text-decoration: none !important; user-select: none; }
.btn:hover { background: var(--brand-700); box-shadow: var(--sh-2); }
.btn:active { transform: translateY(1px); }
.btn[disabled], .btn.is-loading { opacity: .6; pointer-events: none; }
.btn-accent { background: var(--accent); color: var(--accent-ink); }
.btn-accent:hover { background: var(--accent-600); color: var(--accent-ink); }
.btn-outline { background: transparent; color: var(--brand-text); border-color: color-mix(in srgb, var(--brand-text) 55%, transparent); }
.btn-outline:hover { background: var(--brand-50); color: var(--brand-text); box-shadow: none; }
.btn-ghost { background: transparent; color: var(--ink-2); border-color: transparent; }
.btn-ghost:hover { background: var(--surface-2); box-shadow: none; }
.btn-light { background: var(--surface); color: var(--ink); border-color: var(--line); }
.btn-light:hover { background: var(--surface-2); box-shadow: var(--sh-1); }
.btn-danger { background: var(--bad); color: #fff; }
.btn-danger:hover { background: color-mix(in srgb, var(--bad) 85%, #000); }
.btn-sm { min-height: 36px; padding: 6px 12px; font-size: 13.5px; border-radius: 10px; }
.btn-xs { min-height: 30px; padding: 4px 10px; font-size: 12.5px; border-radius: 8px; gap: 6px; }
.btn-lg { min-height: 52px; padding: 12px 24px; font-size: 16px; border-radius: 14px; }
.btn-block { width: 100%; }
.btn-icon { width: 44px; padding: 0; }
.btn-icon.btn-sm { width: 36px; }
.btn .spin { width: 18px; height: 18px; border: 2.5px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Formulir ---------- */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; min-width: 0; }
.field > label, .label { font-weight: 600; font-size: 13.5px; color: var(--ink-2); }
.req { color: var(--bad); margin-left: 2px; }
.help { font-size: 12.5px; color: var(--muted); }
.err { font-size: 12.5px; color: var(--bad); display: flex; gap: 6px; align-items: flex-start; }
.input, .select, .textarea { width: 100%; min-height: 44px; padding: 10px 14px; border-radius: 11px; border: 1.5px solid var(--line-strong); background: var(--surface); color: var(--ink);
  transition: border-color var(--t), box-shadow var(--t); font-size: 15px; }
.textarea { min-height: 96px; resize: vertical; line-height: 1.5; }
.input::placeholder, .textarea::placeholder { color: color-mix(in srgb, var(--muted) 75%, transparent); }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--brand-400); box-shadow: var(--focus); }
.is-invalid .input, .is-invalid .select, .is-invalid .textarea, .input.is-invalid { border-color: var(--bad); background: color-mix(in srgb, var(--bad-bg) 60%, var(--surface)); }
.is-valid .input { border-color: color-mix(in srgb, var(--ok) 60%, var(--line-strong)); }
.select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24' fill='none' stroke='%235B6B85' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 40px; }
.input-group { display: flex; align-items: stretch; }
.input-group .addon { display: flex; align-items: center; padding: 0 12px; border: 1.5px solid var(--line-strong); border-right: 0; border-radius: 11px 0 0 11px; background: var(--surface-2); color: var(--muted); font-weight: 600; font-size: 14px; }
.input-group .input { border-radius: 0 11px 11px 0; }
.grid-2 { display: grid; gap: 0 16px; grid-template-columns: 1fr; }
@media (min-width: 640px) { .grid-2 { grid-template-columns: 1fr 1fr; } .span-2 { grid-column: 1 / -1; } }
.choice { display: flex; align-items: center; gap: 10px; min-height: 44px; padding: 10px 14px; border: 1.5px solid var(--line-strong); border-radius: 11px; cursor: pointer; background: var(--surface); transition: border-color var(--t), background var(--t); }
.choice:hover { border-color: var(--brand-400); }
.choice input { width: 18px; height: 18px; accent-color: var(--brand); margin: 0; flex: none; }
.choice:has(input:checked) { border-color: var(--brand); background: var(--brand-50); }
.choices { display: grid; gap: 8px; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); }

/* Saklar */
.switch { position: relative; display: inline-flex; align-items: center; gap: 10px; cursor: pointer; user-select: none; min-height: 32px; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch .track { width: 44px; height: 24px; border-radius: 99px; background: var(--line-strong); position: relative; transition: background var(--t); flex: none; }
.switch .track::after { content: ''; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.3); transition: transform var(--t); }
.switch input:checked + .track { background: var(--ok); }
.switch input:checked + .track::after { transform: translateX(20px); }
.switch input:focus-visible + .track { box-shadow: var(--focus); }
.switch input:disabled + .track { opacity: .45; }

/* ---------- Kartu, badge, chip ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--sh-1); }
.card-pad { padding: 20px; }
@media (min-width: 768px) { .card-pad { padding: 24px; } }
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 99px; font-size: 12px; font-weight: 600; line-height: 1.5; white-space: nowrap; background: var(--surface-2); color: var(--ink-2); border: 1px solid var(--line); }
.badge::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .85; }
.badge.no-dot::before { display: none; }
.b-ok { background: var(--ok-bg); color: var(--ok); border-color: transparent; }
.b-warn { background: var(--warn-bg); color: var(--warn); border-color: transparent; }
.b-bad { background: var(--bad-bg); color: var(--bad); border-color: transparent; }
.b-info { background: var(--info-bg); color: var(--info); border-color: transparent; }
.b-violet { background: var(--violet-bg); color: var(--violet); border-color: transparent; }
.b-gold { background: var(--accent-100); color: color-mix(in srgb, var(--accent) 50%, var(--ink)); border-color: transparent; }
.b-brand { background: var(--brand-50); color: var(--brand-text); border-color: transparent; }
.chip { display: inline-flex; align-items: center; gap: 6px; min-height: 34px; padding: 4px 12px; border-radius: 99px; border: 1.5px solid var(--line-strong); background: var(--surface); font-size: 13px; font-weight: 500; cursor: pointer; color: var(--ink-2); transition: all var(--t); }
.chip:hover { border-color: var(--brand-400); }
.chip.active { background: var(--brand); border-color: var(--brand); color: #fff; }
.chip .n { font-size: 11.5px; padding: 0 7px; border-radius: 99px; background: color-mix(in srgb, currentColor 14%, transparent); }

/* ---------- Tabel ---------- */
.table-wrap { width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; border-radius: var(--r); }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { text-align: left; font-weight: 600; font-size: 12.5px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); padding: 12px 14px; background: var(--surface-2); border-bottom: 1px solid var(--line); white-space: nowrap; }
.table td { padding: 12px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tbody tr { transition: background var(--t); }
.table tbody tr:hover { background: var(--brand-50); }
.table tr:last-child td { border-bottom: 0; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }

/* ---------- Toast, modal, drawer ---------- */
.toasts { position: fixed; z-index: 2000; right: 16px; top: 16px; display: flex; flex-direction: column; gap: 10px; width: min(380px, calc(100vw - 32px)); pointer-events: none; }
.toast { pointer-events: auto; display: flex; gap: 12px; align-items: flex-start; padding: 14px 16px; border-radius: 14px; background: var(--surface); color: var(--ink); box-shadow: var(--sh-3); border: 1px solid var(--line); border-left: 4px solid var(--info); animation: toastIn .25s ease; font-size: 14px; }
.toast.ok { border-left-color: var(--ok); } .toast.bad { border-left-color: var(--bad); } .toast.warn { border-left-color: var(--warn); }
.toast .ico { margin-top: 1px; } .toast.ok .ico { color: var(--ok); } .toast.bad .ico { color: var(--bad); } .toast.warn .ico { color: var(--warn); } .toast.info .ico { color: var(--info); }
.toast-x { margin-left: auto; background: none; border: 0; color: var(--muted); cursor: pointer; padding: 2px; }
@keyframes toastIn { from { opacity: 0; transform: translateY(-8px) scale(.98); } }
.overlay { position: fixed; inset: 0; z-index: 1500; background: rgba(7, 16, 30, .55); backdrop-filter: blur(3px); display: flex; align-items: center; justify-content: center; padding: 16px; animation: fadeIn .2s ease; }
@keyframes fadeIn { from { opacity: 0; } }
.modal { width: min(560px, 100%); max-height: calc(100dvh - 32px); display: flex; flex-direction: column; background: var(--surface); border-radius: var(--r-xl); box-shadow: var(--sh-3); border: 1px solid var(--line); animation: pop .22s cubic-bezier(.2,.8,.3,1.1); overflow: hidden; }
.modal.wide { width: min(880px, 100%); } .modal.xwide { width: min(1100px, 100%); }
@keyframes pop { from { opacity: 0; transform: translateY(10px) scale(.97); } }
.modal-head { display: flex; align-items: center; gap: 12px; padding: 18px 22px; border-bottom: 1px solid var(--line); }
.modal-head h3 { margin: 0; font-size: 17px; flex: 1; min-width: 0; }
.modal-body { padding: 20px 22px; overflow-y: auto; }
.modal-foot { display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; padding: 14px 22px; border-top: 1px solid var(--line); background: var(--surface-2); }
.drawer-ov { justify-content: flex-end; padding: 0; }
.drawer { width: min(640px, 100%); height: 100dvh; background: var(--surface); display: flex; flex-direction: column; box-shadow: var(--sh-3); animation: slideIn .25s cubic-bezier(.2,.8,.3,1); }
@keyframes slideIn { from { transform: translateX(40px); opacity: 0; } }
@media (max-width: 640px) { .overlay:not(.drawer-ov) { align-items: flex-end; padding: 0; } .modal { border-radius: 22px 22px 0 0; max-height: 92dvh; width: 100%; } }

/* ---------- Skeleton & kosong ---------- */
.sk { background: linear-gradient(90deg, var(--surface-2) 25%, var(--line) 45%, var(--surface-2) 65%); background-size: 300% 100%; animation: sk 1.3s infinite linear; border-radius: 10px; }
@keyframes sk { from { background-position: 100% 0; } to { background-position: -100% 0; } }
.empty { text-align: center; padding: 48px 20px; color: var(--muted); }
.empty .ico-wrap { width: 64px; height: 64px; margin: 0 auto 14px; display: grid; place-items: center; border-radius: 20px; background: var(--brand-50); color: var(--brand-text); }
.empty h3 { color: var(--ink); }

/* ---------- Tab / segmen ---------- */
.seg { display: inline-flex; padding: 4px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px; gap: 4px; flex-wrap: wrap; }
.seg button { min-height: 36px; padding: 6px 14px; border: 0; background: transparent; border-radius: 9px; cursor: pointer; font-weight: 500; font-size: 14px; color: var(--muted); transition: all var(--t); }
.seg button.active { background: var(--surface); color: var(--ink); box-shadow: var(--sh-1); font-weight: 600; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs button { padding: 12px 16px; border: 0; background: none; cursor: pointer; font-weight: 500; color: var(--muted); border-bottom: 2.5px solid transparent; margin-bottom: -1px; white-space: nowrap; display: inline-flex; gap: 8px; align-items: center; }
.tabs button.active { color: var(--brand-text); border-bottom-color: var(--accent); font-weight: 600; }

/* ---------- Gambar thumbnail ---------- */
.thumb { position: relative; overflow: hidden; background: radial-gradient(circle at 82% 18%, color-mix(in srgb, var(--accent) 24%, transparent), transparent 55%), linear-gradient(135deg, var(--brand-600), var(--brand-700)); }
.thumb img { width: 100%; height: 100%; object-fit: cover; transition: transform .5s ease, opacity .3s; }
.thumb .ph { position: absolute; inset: 0; display: grid; place-items: center; color: rgba(255, 255, 255, .9); }
.thumb .ph .ico { width: 38px; height: 38px; stroke-width: 1.6; }
.pattern { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='56' height='56' viewBox='0 0 56 56'%3E%3Cg fill='none' stroke='%23ffffff' stroke-opacity='.10' stroke-width='1.2'%3E%3Cpath d='M28 4l7 17 17 7-17 7-7 17-7-17-17-7 17-7z'/%3E%3Ccircle cx='28' cy='28' r='9'/%3E%3C/g%3E%3C/svg%3E"); }
.thumb.pattern { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='56' height='56' viewBox='0 0 56 56'%3E%3Cg fill='none' stroke='%23ffffff' stroke-opacity='.10' stroke-width='1.2'%3E%3Cpath d='M28 4l7 17 17 7-17 7-7 17-7-17-17-7 17-7z'/%3E%3Ccircle cx='28' cy='28' r='9'/%3E%3C/g%3E%3C/svg%3E"), radial-gradient(circle at 82% 18%, color-mix(in srgb, var(--accent) 24%, transparent), transparent 55%), linear-gradient(135deg, var(--brand-600), var(--brand-700)); }

/* ---------- Loader halaman ---------- */
.page-loader { position: fixed; inset: 0; z-index: 3000; display: grid; place-items: center; background: color-mix(in srgb, var(--bg) 80%, transparent); backdrop-filter: blur(2px); }
.loader-card { display: flex; flex-direction: column; align-items: center; gap: 14px; padding: 28px 32px; border-radius: 20px; background: var(--surface); box-shadow: var(--sh-3); text-align: center; max-width: 320px; }
.loader-card .spin { width: 40px; height: 40px; border: 4px solid var(--brand-100); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; }
.topbar-progress { position: fixed; top: 0; left: 0; height: 3px; z-index: 3000; background: var(--accent); width: 0; transition: width .3s ease, opacity .3s; box-shadow: 0 0 8px var(--accent); }

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