/* =====================================================================
   Clay — design system backoffice agregator payment.
   Token warna & bayangan diambil dari gaya gensflo.com:
   latar lavender, aksen ungu (primary) + biru + mint, bayangan lembut
   periwinkle, garis putih di tepi atas, tombol "empuk" yang turun saat ditekan.
   ===================================================================== */

:root {
  --bg: #f1eefa;
  --surface: #fdfcff;
  --surface2: #ebe7f8;
  --ink: #2b2a40;
  --muted: #6f6a8e;
  --line: rgba(108, 92, 225, .14);
  --primary: #7355e8;
  --primary-d: #5b46cc;
  --mint: #66bfae;
  --mint-d: #2f9d85;
  --blue: #4f7df7;
  --blue-d: #3a63e0;
  --amber-d: #b7791f;
  --rose-d: #d0476b;
  --sh: 104, 92, 180;
  --hi: rgba(255, 255, 255, .9);
  --r: 24px;
  --r-btn: 14px;
  --r-sm: 16px;
  --clay: 0 12px 26px rgba(var(--sh), .16), inset 0 2px 0 var(--hi);
  --clay-lift: 0 18px 34px rgba(var(--sh), .24), inset 0 2px 0 var(--hi);
  --clay-in: inset 0 2px 6px rgba(var(--sh), .16);
  --pill-needs: #dde6ff;   --pill-needs-ink: #3a63e0;
  --pill-na: #f1e4ea;      --pill-na-ink: #9a3b5a;
  --pill-created: #ebe7f8; --pill-created-ink: #6f6a8e;
  --pill-pending: #fdf0d8; --pill-pending-ink: #a3660e;
  --pill-paid: #d6efe8;    --pill-paid-ink: #2f9d85;
  --pill-expired: #ecebf2; --pill-expired-ink: #6f6a8e;
  --pill-failed: #fbe0e6;  --pill-failed-ink: #c23a5e;
  --pill-cancelled: #ecebf2; --pill-cancelled-ink: #57536f;
  --sidebar-w: 256px;
}

:root[data-theme="dark"] {
  --bg: #16151f;
  --surface: #232132;
  --surface2: #1c1b2a;
  --ink: #eceafb;
  --muted: #a8a2c8;
  --line: rgba(216, 208, 255, .10);
  --sh: 0, 0, 0;
  --hi: rgba(226, 220, 255, .10);
  --primary-d: #b39bff;
  --mint-d: #8adcc8;
  --blue-d: #8fb0ff;
  --amber-d: #f2c46b;
  --rose-d: #ff8fab;
  --pill-needs: #232f52;   --pill-needs-ink: #8fb0ff;
  --pill-na: #3a2331;      --pill-na-ink: #f0a3bd;
  --pill-created: #2a283b; --pill-created-ink: #a8a2c8;
  --pill-pending: #3a3020; --pill-pending-ink: #f2c46b;
  --pill-paid: #1d3a34;    --pill-paid-ink: #7fdec7;
  --pill-expired: #2a283b; --pill-expired-ink: #a8a2c8;
  --pill-failed: #3d2230;  --pill-failed-ink: #ff8fab;
  --pill-cancelled: #2a283b; --pill-cancelled-ink: #c9c4e4;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: "Nunito", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-weight: 700;
  color: var(--ink);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  background:
    radial-gradient(800px 460px at 88% -6%, #e3dbff 0%, transparent 58%),
    radial-gradient(680px 420px at -6% 14%, #dfe8fd 0%, transparent 55%),
    var(--bg);
  background-attachment: fixed;
}
:root[data-theme="dark"] body {
  background:
    radial-gradient(800px 460px at 88% -6%, #2a2447 0%, transparent 58%),
    radial-gradient(680px 420px at -6% 14%, #1e2038 0%, transparent 55%),
    var(--bg);
  background-attachment: fixed;
}
a { color: inherit; text-decoration: none; }
code, .mono { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: .86em; font-weight: 600; }
h1, h2, h3 { font-weight: 900; letter-spacing: -.01em; line-height: 1.15; }
h1 { font-size: clamp(24px, 3vw, 30px); }
h2 { font-size: 19px; }
h3 { font-size: 16px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ---------- ikon ---------- */
.ico { width: 20px; height: 20px; flex: none; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.ico-tile {
  width: 38px; height: 38px; border-radius: 13px; display: grid; place-items: center; flex: none;
  background: var(--surface); box-shadow: 0 6px 12px rgba(var(--sh), .2), inset 0 2px 0 var(--hi);
}

/* ---------- kerangka ---------- */
.shell { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); min-height: 100vh; }
/* Anak grid default-nya min-width:auto -> tabel lebar bisa mendorong halaman melebar. */
.shell > *, .grid > *, .stack > * { min-width: 0; }
.sidebar {
  position: sticky; top: 0; height: 100vh; padding: 22px 16px; display: flex; flex-direction: column; gap: 18px;
  border-right: 1px solid var(--line);
  background: color-mix(in srgb, var(--bg) 70%, transparent);
  backdrop-filter: blur(10px);
}
.brand { display: flex; align-items: center; gap: 11px; font-weight: 900; font-size: 19px; padding: 4px 6px; }
.brand .mark {
  width: 40px; height: 40px; border-radius: 14px; display: grid; place-items: center; color: #fff; transform: rotate(-6deg);
  background: linear-gradient(180deg, var(--blue), var(--primary));
  box-shadow: 0 8px 15px rgba(115, 85, 232, .4), inset 0 2px 0 rgba(255, 255, 255, .4), inset 0 -4px 7px rgba(0, 0, 0, .14);
}
.brand small { display: block; font-size: 11px; color: var(--muted); font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.env-badge {
  font-size: 11px; font-weight: 900; letter-spacing: .08em; text-transform: uppercase; padding: 5px 10px;
  border-radius: 999px; align-self: flex-start; margin-left: 6px;
}
.env-local { background: var(--pill-created); color: var(--pill-created-ink); }
.env-staging { background: var(--pill-pending); color: var(--pill-pending-ink); }
.env-production { background: var(--pill-paid); color: var(--pill-paid-ink); }
/* Penanda uang sungguhan: sandbox tenang, production mencolok. */
.pill-mode-sandbox { background: var(--pill-needs); color: var(--pill-needs-ink); }
.pill-mode-production { background: var(--pill-failed); color: var(--pill-failed-ink); }

.nav { display: flex; flex-direction: column; gap: 6px; }
.nav a {
  display: flex; align-items: center; gap: 12px; padding: 9px 10px; border-radius: 16px; color: var(--muted); font-weight: 800;
  transition: background .15s, color .15s;
}
.nav a:hover { color: var(--ink); background: var(--surface2); }
.nav a.active { color: var(--ink); background: var(--surface); box-shadow: var(--clay); }
.nav a.active .ico-tile { background: linear-gradient(180deg, #9b7bff, #7355e8); color: #fff; }
.nav .count { margin-left: auto; font-size: 12px; font-weight: 900; padding: 2px 9px; border-radius: 999px; background: var(--pill-failed); color: var(--pill-failed-ink); }
.sidebar-foot { margin-top: auto; display: flex; flex-direction: column; gap: 10px; }

.main { min-width: 0; padding: 26px clamp(16px, 3vw, 36px) 60px; }
.topbar { display: flex; align-items: center; gap: 14px; margin-bottom: 22px; flex-wrap: wrap; }
.topbar .title { flex: 1; min-width: 200px; }
.topbar .title p { color: var(--muted); font-size: 14px; margin-top: 4px; }
.crumbs { font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.crumbs a:hover { color: var(--primary-d); }

/* ---------- tombol ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; cursor: pointer; white-space: nowrap;
  font: inherit; font-weight: 900; font-size: 14px; padding: 10px 18px; border-radius: var(--r-btn);
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  box-shadow: 0 7px 14px rgba(var(--sh), .26), inset 0 2px 0 var(--hi), inset 0 -4px 7px rgba(var(--sh), .14);
  transition: transform .1s ease, box-shadow .1s ease;
}
.btn:active { transform: translateY(3px); box-shadow: 0 3px 7px rgba(var(--sh), .24), inset 0 2px 0 var(--hi), inset 0 -2px 4px rgba(var(--sh), .12); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .5; cursor: not-allowed; transform: none; }
.btn-primary {
  background: linear-gradient(180deg, #9b7bff, #7355e8); color: #fff; border-color: rgba(255, 255, 255, .28);
  text-shadow: 0 1px 1px rgba(63, 48, 150, .4);
  box-shadow: 0 9px 16px rgba(115, 85, 232, .4), inset 0 2px 0 rgba(255, 255, 255, .45), inset 0 -5px 9px rgba(0, 0, 0, .15);
}
.btn-mint {
  background: linear-gradient(180deg, #7fd6c4, #3fae95); color: #fff; border-color: rgba(255, 255, 255, .28);
  text-shadow: 0 1px 1px rgba(20, 90, 75, .4);
  box-shadow: 0 9px 16px rgba(63, 174, 149, .36), inset 0 2px 0 rgba(255, 255, 255, .45), inset 0 -5px 9px rgba(0, 0, 0, .13);
}
.btn-danger {
  background: linear-gradient(180deg, #f28aa6, #d0476b); color: #fff; border-color: rgba(255, 255, 255, .28);
  text-shadow: 0 1px 1px rgba(120, 30, 60, .4);
  box-shadow: 0 9px 16px rgba(208, 71, 107, .34), inset 0 2px 0 rgba(255, 255, 255, .4), inset 0 -5px 9px rgba(0, 0, 0, .13);
}
.btn-sm { font-size: 13px; padding: 7px 12px; border-radius: 12px; }
.btn-icon { width: 40px; height: 40px; padding: 0; border-radius: 14px; }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }

/* ---------- kartu ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--clay); padding: 20px; }
.card + .card { margin-top: 18px; }
.card-head { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.card-head h2 { flex: 1; }
.card-head > span, dl.kv dd, .mono { overflow-wrap: anywhere; }
.inset { background: var(--surface2); border-radius: var(--r-sm); box-shadow: var(--clay-in); padding: 14px 16px; }
.grid { display: grid; gap: 18px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-main { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); align-items: start; }
.grid-2 { align-items: start; }
.stack > * + * { margin-top: 18px; }

/* ---------- ubin statistik ---------- */
.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; margin-bottom: 18px; }
.stats.stats-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--clay); padding: 16px 18px; display: flex; gap: 14px; align-items: center; min-width: 0; }
.stat > div { min-width: 0; }
.stat .num { font-size: clamp(20px, 1.9vw, 26px); font-weight: 900; line-height: 1.1; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stat .lbl { font-size: 13px; color: var(--muted); font-weight: 800; }
.stat.tone-mint .ico-tile { color: var(--mint-d); }
.stat.tone-amber .ico-tile { color: var(--amber-d); }
.stat.tone-rose .ico-tile { color: var(--rose-d); }
.stat.tone-blue .ico-tile { color: var(--blue-d); }
.stat.tone-primary .ico-tile { color: var(--primary-d); }

/* ---------- pill status ---------- */
.pill { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 900; padding: 4px 11px; border-radius: 999px; white-space: nowrap; box-shadow: inset 0 2px 0 rgba(255, 255, 255, .45); }
.pill::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; opacity: .8; }
.pill-needs_confirmation { background: var(--pill-needs); color: var(--pill-needs-ink); }
.pill-not_available { background: var(--pill-na); color: var(--pill-na-ink); }
.pill-created { background: var(--pill-created); color: var(--pill-created-ink); }
.pill-pending { background: var(--pill-pending); color: var(--pill-pending-ink); }
.pill-paid, .pill-succeeded, .pill-processed, .pill-active { background: var(--pill-paid); color: var(--pill-paid-ink); }
.pill-expired, .pill-ignored { background: var(--pill-expired); color: var(--pill-expired-ink); }
.pill-failed, .pill-dead, .pill-rejected, .pill-suspended, .pill-review { background: var(--pill-failed); color: var(--pill-failed-ink); }
.pill-cancelled { background: var(--pill-cancelled); color: var(--pill-cancelled-ink); }
.pill-queued, .pill-running, .pill-received, .pill-passthrough { background: var(--pill-needs); color: var(--pill-needs-ink); }

/* ---------- tabel ---------- */
.table-wrap { overflow-x: auto; margin: 0 -6px; padding: 0 6px; }
table.tbl { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 14px; }
.tbl th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 900; padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.tbl th a { display: inline-flex; gap: 4px; align-items: center; }
.tbl th a:hover, .tbl th a.sorted { color: var(--primary-d); }
.tbl td { padding: 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl tbody tr { transition: background .12s; }
.tbl tbody tr:hover { background: color-mix(in srgb, var(--surface2) 70%, transparent); }
.tbl .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tbl .strong { font-weight: 900; }
.tbl a.rowlink { font-weight: 900; color: var(--primary-d); }
.empty { text-align: center; padding: 34px 12px; color: var(--muted); }

/* ---------- form ---------- */
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 13px; font-weight: 900; color: var(--muted); }
.field .help { font-size: 12px; color: var(--muted); font-weight: 700; }
.field .err { font-size: 12px; color: var(--rose-d); font-weight: 800; }
input[type="text"], input[type="email"], input[type="url"], input[type="number"], input[type="password"], input[type="search"], input[type="date"], select, textarea {
  font: inherit; font-weight: 700; font-size: 14px; color: var(--ink); width: 100%;
  background: var(--surface2); border: 1px solid var(--line); border-radius: 13px; padding: 10px 13px;
  box-shadow: var(--clay-in); outline: none; transition: border-color .15s, box-shadow .15s;
}
textarea { min-height: 90px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--primary); box-shadow: var(--clay-in), 0 0 0 3px rgba(115, 85, 232, .18); }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.form-grid .span-2 { grid-column: 1 / -1; }
.check { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; }

.filters { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px 14px; align-items: end; }
.filters .field-q { grid-column: 1 / -1; }
.filters .filter-actions { grid-column: 1 / -1; justify-content: flex-end; }
.filters .field label { font-size: 12px; }

/* ---------- pesan ---------- */
.messages { display: flex; flex-direction: column; gap: 10px; margin-bottom: 18px; }
.msg { border-radius: 16px; padding: 12px 16px; font-size: 14px; box-shadow: var(--clay); border: 1px solid var(--line); background: var(--surface); display: flex; gap: 10px; align-items: flex-start; }
.msg-success { border-left: 5px solid var(--mint-d); }
.msg-error { border-left: 5px solid var(--rose-d); }
.msg-warning { border-left: 5px solid var(--amber-d); }
.msg-info { border-left: 5px solid var(--blue-d); }
.secret-box { margin-top: 8px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.secret-box code { background: var(--surface2); box-shadow: var(--clay-in); padding: 8px 12px; border-radius: 12px; word-break: break-all; }

/* ---------- daftar definisi ---------- */
dl.kv { display: grid; grid-template-columns: minmax(120px, 36%) 1fr; gap: 10px 14px; font-size: 14px; }
dl.kv dt { color: var(--muted); font-weight: 800; }
dl.kv dd { word-break: break-word; }

/* ---------- timeline ---------- */
.timeline { list-style: none; position: relative; padding-left: 26px; }
.timeline::before { content: ""; position: absolute; left: 9px; top: 6px; bottom: 6px; width: 3px; border-radius: 3px; background: var(--surface2); box-shadow: var(--clay-in); }
.timeline li { position: relative; padding-bottom: 16px; }
.timeline li:last-child { padding-bottom: 0; }
.timeline li::before {
  content: ""; position: absolute; left: -23px; top: 5px; width: 14px; height: 14px; border-radius: 50%;
  background: linear-gradient(180deg, #9b7bff, #7355e8); box-shadow: 0 3px 6px rgba(115, 85, 232, .4), inset 0 1px 0 rgba(255, 255, 255, .5);
}
.timeline .when { font-size: 12px; color: var(--muted); }
.timeline .what { font-size: 14px; }

/* ---------- lain-lain ---------- */
.alert-review { border-left: 5px solid var(--rose-d); }
pre.json { background: var(--surface2); box-shadow: var(--clay-in); border-radius: 14px; padding: 12px 14px; font-size: 12px; overflow: auto; max-height: 320px; white-space: pre-wrap; word-break: break-all; font-family: ui-monospace, Consolas, monospace; font-weight: 600; }
details summary { cursor: pointer; font-weight: 900; color: var(--primary-d); }
details[open] summary { margin-bottom: 10px; }
.pager { display: flex; gap: 8px; align-items: center; justify-content: flex-end; margin-top: 16px; flex-wrap: wrap; }
.divider { height: 1px; background: var(--line); margin: 16px 0; }
.bar { height: 10px; border-radius: 999px; background: var(--surface2); box-shadow: var(--clay-in); overflow: hidden; }
.bar > span { display: block; height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--blue), var(--primary)); }

/* ---------- login ---------- */
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.auth-card { width: 100%; max-width: 400px; }
.auth-card .brand { justify-content: center; margin-bottom: 18px; font-size: 22px; }

/* ---------- tombol tema ---------- */
.theme-toggle .sun { display: none; }
:root[data-theme="dark"] .theme-toggle .sun { display: block; }
:root[data-theme="dark"] .theme-toggle .moon { display: none; }

/* ---------- responsif ---------- */
@media (max-width: 1100px) {
  .filters, .stats, .stats.stats-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 960px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: sticky; z-index: 20; height: auto; flex-direction: row; align-items: center; padding: 10px 14px; gap: 10px; border-right: 0; border-bottom: 1px solid var(--line); overflow-x: auto; }
  .sidebar .brand > span:last-child, .env-badge, .sidebar-foot .who { display: none; }
  .shell { grid-template-columns: minmax(0, 1fr); }
  .nav { flex-direction: row; gap: 4px; }
  .nav a { padding: 6px; }
  .nav a span.label { display: none; }
  .sidebar-foot { margin: 0 0 0 auto; flex-direction: row; }
  .grid-2, .grid-3, .grid-main { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .form-grid, .filters, .stats, .stats.stats-4 { grid-template-columns: 1fr; }
  .main { padding: 18px 16px 48px; }
  dl.kv { grid-template-columns: 1fr; gap: 2px 0; }
  dl.kv dd { margin-bottom: 8px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
