/* ============ Dasar bersama: aplikasi pelanggan & panel admin ============ */
@font-face { font-family: "Nunito"; font-weight: 400; font-display: swap; src: url("/shared/fonts/nunito-latin-400-normal.woff2") format("woff2"); }
@font-face { font-family: "Nunito"; font-weight: 600; font-display: swap; src: url("/shared/fonts/nunito-latin-600-normal.woff2") format("woff2"); }
@font-face { font-family: "Nunito"; font-weight: 700; font-display: swap; src: url("/shared/fonts/nunito-latin-700-normal.woff2") format("woff2"); }
@font-face { font-family: "Nunito"; font-weight: 800; font-display: swap; src: url("/shared/fonts/nunito-latin-800-normal.woff2") format("woff2"); }

:root {
  --brand: #4f46e5;
  --brand-ink: #ffffff;
  --brand-soft: color-mix(in srgb, var(--brand) 12%, transparent);
  --brand-strong: color-mix(in srgb, var(--brand) 82%, black);
  --bg: #f4f5f9;
  --surface: #ffffff;
  --surface-2: #f8f9fc;
  --text: #151826;
  --text-2: #4a5068;
  --muted: #8a90a6;
  --line: #e6e8f0;
  --ok: #16a34a;
  --ok-soft: #dcfce7;
  --warn: #d97706;
  --warn-soft: #fef3c7;
  --bad: #dc2626;
  --bad-soft: #fee2e2;
  --info: #2563eb;
  --info-soft: #dbeafe;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(20, 24, 40, .05), 0 1px 1px rgba(20, 24, 40, .03);
  --shadow-lg: 0 12px 32px rgba(20, 24, 40, .16);
  --font: "Nunito", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  --mono: ui-monospace, "Cascadia Mono", Consolas, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e1017; --surface: #171a24; --surface-2: #1d2130; --text: #eceef5; --text-2: #b9bfd3; --muted: #7c8299;
    --line: #272b3a; --ok-soft: #10301c; --warn-soft: #33260b; --bad-soft: #3a1414; --info-soft: #132344;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4); --shadow-lg: 0 12px 32px rgba(0, 0, 0, .55); color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0e1017; --surface: #171a24; --surface-2: #1d2130; --text: #eceef5; --text-2: #b9bfd3; --muted: #7c8299;
  --line: #272b3a; --ok-soft: #10301c; --warn-soft: #33260b; --bad-soft: #3a1414; --info-soft: #132344;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4); --shadow-lg: 0 12px 32px rgba(0, 0, 0, .55); color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; min-height: 100vh; background: var(--bg); color: var(--text); font: 15px/1.5 var(--font); -webkit-font-smoothing: antialiased; }
h1, h2, h3, h4, p { margin: 0; }
h1 { font-size: 22px; font-weight: 800; letter-spacing: -.01em; }
h2 { font-size: 17px; font-weight: 800; }
h3 { font-size: 15px; font-weight: 800; }
a { color: var(--brand); text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
img { max-width: 100%; }
code, .mono { font-family: var(--mono); font-size: .92em; }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }

.icon { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; vertical-align: middle; }
.icon.sm { width: 16px; height: 16px; }
.icon.lg { width: 26px; height: 26px; }

.muted { color: var(--muted); }
.small { font-size: 13px; }
.xs { font-size: 12px; }
.bold { font-weight: 800; }
.num { font-variant-numeric: tabular-nums; }
.right { text-align: right; }
.center { text-align: center; }
.nowrap { white-space: nowrap; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pos { color: var(--ok); }
.neg { color: var(--bad); }
.grow { flex: 1; min-width: 0; }
.row { display: flex; align-items: center; gap: 10px; }
.row.wrap { flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.row.top { align-items: flex-start; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.stack.sm { gap: 6px; }
.stack.lg { gap: 18px; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.divider { height: 1px; background: var(--line); margin: 4px 0; }

/* ---------- Tombol ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 0 18px;
  border: 1px solid transparent; border-radius: 12px; background: var(--brand); color: var(--brand-ink);
  font-weight: 800; white-space: nowrap; transition: background .15s, opacity .15s;
}
.btn:hover { background: var(--brand-strong); }
.btn:disabled, .btn.is-loading { opacity: .6; cursor: not-allowed; }
.btn.is-loading .icon { animation: spin .8s linear infinite; }
.btn.block { width: 100%; }
.btn.sm { min-height: 34px; padding: 0 12px; border-radius: 9px; font-size: 13px; }
.btn.secondary { background: var(--surface); color: var(--text); border-color: var(--line); }
.btn.secondary:hover { background: var(--surface-2); }
.btn.soft { background: var(--brand-soft); color: var(--brand); }
.btn.soft:hover { background: color-mix(in srgb, var(--brand) 18%, transparent); }
.btn.ghost { background: transparent; color: var(--text-2); }
.btn.ghost:hover { background: var(--surface-2); }
.btn.danger { background: var(--bad); color: #fff; }
.btn.danger.soft { background: var(--bad-soft); color: var(--bad); }
.btn.ok { background: var(--ok); color: #fff; }
.icon-btn {
  display: inline-grid; place-items: center; width: 40px; height: 40px; flex: none; border: 0; border-radius: 12px;
  background: transparent; color: inherit;
}
.icon-btn:hover { background: var(--surface-2); }
.icon-btn.is-loading .icon { animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Form ---------- */
.field { display: flex; flex-direction: column; gap: 6px; }
.field > span, .label { font-size: 13px; font-weight: 700; color: var(--text-2); }
.field small { color: var(--muted); font-size: 12px; }
.input, .select, .textarea {
  width: 100%; min-height: 46px; padding: 10px 14px; border: 1.5px solid var(--line); border-radius: 12px;
  background: var(--surface); outline: 0; transition: border-color .15s;
}
.select { padding-right: 8px; }
.textarea { min-height: 96px; resize: vertical; }
.input:focus, .select:focus, .textarea:focus { border-color: var(--brand); }
.input.big { font-size: 20px; font-weight: 700; letter-spacing: .02em; }
.input-group { position: relative; display: flex; align-items: center; }
.input-group .input { padding-right: 48px; }
.input-group > .icon-btn, .input-group > .addon { position: absolute; right: 4px; }
.input-group > .addon { right: 10px; }
.check { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--brand); }
.switch { position: relative; display: inline-flex; align-items: center; gap: 10px; cursor: pointer; }
.switch input { appearance: none; width: 42px; height: 24px; border-radius: 999px; background: var(--line); position: relative; transition: background .15s; cursor: pointer; flex: none; }
.switch input::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: transform .15s; box-shadow: 0 1px 2px rgba(0,0,0,.2); }
.switch input:checked { background: var(--brand); }
.switch input:checked::after { transform: translateX(18px); }
.pin-input { letter-spacing: .6em; text-align: center; font-size: 24px; font-weight: 800; }

/* ---------- Kartu, daftar ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card.pad { padding: 16px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.card-body { padding: 16px; }
.list-item { display: flex; align-items: center; gap: 12px; width: 100%; padding: 13px 16px; border: 0; border-bottom: 1px solid var(--line); background: transparent; color: inherit; text-align: left; }
.list-item:last-child { border-bottom: 0; }
button.list-item:hover, a.list-item:hover { background: var(--surface-2); }
.card.list-item { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.card.list-item:hover { background: var(--surface-2); }
.list-item .title { font-weight: 700; }
.list-item .sub { color: var(--muted); font-size: 13px; }
.kv { display: grid; grid-template-columns: minmax(110px, 38%) 1fr; gap: 8px 14px; }
.kv dt { color: var(--muted); font-size: 13.5px; }
.kv dd { margin: 0; font-weight: 700; overflow-wrap: anywhere; }

/* ---------- Badge, chip ---------- */
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 800; white-space: nowrap; background: var(--surface-2); color: var(--text-2); }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.bad { background: var(--bad-soft); color: var(--bad); }
.badge.info { background: var(--info-soft); color: var(--info); }
.badge.brand { background: var(--brand-soft); color: var(--brand); }
.chips { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; min-height: 36px; padding: 0 14px; border: 1.5px solid var(--line); border-radius: 999px; background: var(--surface); color: var(--text-2); font-weight: 700; font-size: 13.5px; white-space: nowrap; }
.chip.is-active { border-color: var(--brand); background: var(--brand); color: var(--brand-ink); }
.chip .count { margin-left: 6px; opacity: .7; font-weight: 600; }
.seg { display: inline-flex; padding: 3px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--line); }
.seg button { border: 0; background: transparent; padding: 7px 14px; border-radius: 9px; font-weight: 700; color: var(--text-2); }
.seg button.is-active { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }

/* ---------- Status kosong, skeleton, alert ---------- */
.empty { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 40px 20px; text-align: center; color: var(--muted); }
.empty .icon { width: 40px; height: 40px; color: var(--muted); }
.empty strong { color: var(--text-2); font-size: 16px; }
.empty p { max-width: 360px; font-size: 14px; }
.skel { background: linear-gradient(90deg, var(--line) 25%, var(--surface-2) 37%, var(--line) 63%); background-size: 400% 100%; animation: skel 1.3s ease infinite; border-radius: 12px; }
@keyframes skel { from { background-position: 100% 50%; } to { background-position: 0 50%; } }
.alert { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: 12px; background: var(--info-soft); color: var(--info); font-size: 14px; }
.alert.warn { background: var(--warn-soft); color: var(--warn); }
.alert.danger { background: var(--bad-soft); color: var(--bad); }
.alert.ok { background: var(--ok-soft); color: var(--ok); }
.alert .icon { margin-top: 1px; }

/* ---------- Toast, dialog, sheet ---------- */
.toasts { position: fixed; left: 50%; bottom: calc(84px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 200; width: min(440px, calc(100vw - 24px)); display: flex; flex-direction: column; gap: 8px; pointer-events: none; }
.toast { padding: 12px 16px; border-radius: 12px; background: #1e2130; color: #fff; box-shadow: var(--shadow-lg); font-weight: 600; animation: pop .18s ease-out; }
.toast.error { background: #b42318; }
.toast.success { background: #15803d; }
@keyframes pop { from { transform: translateY(8px); opacity: 0; } }
.backdrop { position: fixed; inset: 0; z-index: 150; display: flex; align-items: flex-end; justify-content: center; background: rgba(10, 12, 20, .5); animation: fade .15s; }
@keyframes fade { from { opacity: 0; } }
.sheet { width: 100%; max-width: 560px; max-height: 92vh; display: flex; flex-direction: column; background: var(--surface); border-radius: 22px 22px 0 0; box-shadow: var(--shadow-lg); animation: rise .2s ease-out; }
@keyframes rise { from { transform: translateY(40px); opacity: .5; } }
.sheet-head { display: flex; align-items: center; gap: 10px; padding: 16px 12px 10px 20px; }
.sheet-head h2 { flex: 1; }
.sheet-body { flex: 1; overflow-y: auto; padding: 4px 20px 16px; }
.sheet-foot { padding: 12px 20px calc(14px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); }
.sheet.dialog { max-width: 420px; }
@media (min-width: 760px) {
  .backdrop { align-items: center; padding: 24px; }
  .sheet { border-radius: 20px; }
}

/* ---------- Tabel (desktop) ---------- */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { position: sticky; top: 0; padding: 10px 12px; background: var(--surface-2); color: var(--muted); font-size: 12px; font-weight: 800; text-align: left; text-transform: uppercase; letter-spacing: .04em; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table td { padding: 11px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr.clickable { cursor: pointer; }
.table tbody tr.clickable:hover td { background: var(--surface-2); }
.table .num { text-align: right; }
.pager { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px; border-top: 1px solid var(--line); }

.raw { margin-top: 8px; }
.raw summary { cursor: pointer; color: var(--muted); font-size: 13px; }
.raw pre { max-height: 300px; overflow: auto; padding: 12px; border-radius: 10px; background: var(--surface-2); font: 12px/1.5 var(--mono); white-space: pre-wrap; word-break: break-word; }
