:root {
  --navy: #0B1F3A;
  --navy-2: #13294B;
  --gold: #C9A227;
  --gold-deep: #9A7B1E;
  --bg: #F4F1EA;
  --surface: #FFFFFF;
  --surface-2: #F8F6F1;
  --text: #16202E;
  --muted: #5E6878;
  --line: #E2DDD2;
  --good: #1E7A4C;
  --good-bg: #E6F4EC;
  --bad: #A8322D;
  --bad-bg: #FBEAE8;
  --warn-bg: #FFF5D6;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(11, 31, 58, .06), 0 8px 24px rgba(11, 31, 58, .08);
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #08121F;
    --surface: #0F1D30;
    --surface-2: #132439;
    --text: #E8ECF2;
    --muted: #97A3B5;
    --line: #22344D;
    --good: #5FCB94;
    --good-bg: #0F2B20;
    --bad: #F08A84;
    --bad-bg: #331616;
    --warn-bg: #2E2610;
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 8px 24px rgba(0,0,0,.35);
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
a { color: var(--gold-deep); }
@media (prefers-color-scheme: dark) { a { color: var(--gold); } }

.sandbox-banner {
  background: repeating-linear-gradient(-45deg, #C9A227, #C9A227 14px, #B8921C 14px, #B8921C 28px);
  color: #0B1F3A;
  text-align: center;
  font-weight: 700;
  font-size: 12.5px;
  letter-spacing: .08em;
  text-transform: uppercase;
  padding: 7px 16px;
}
.topbar {
  background: var(--navy);
  color: #fff;
  border-bottom: 3px solid var(--gold);
}
.topbar-inner {
  max-width: 1180px;
  margin: 0 auto;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 14px;
}
.brand { display: flex; align-items: center; gap: 12px; color: #fff; text-decoration: none; }
.brand img { height: 52px; width: auto; display: block; }
.brand-mark {
  width: 40px; height: 40px; border-radius: 10px;
  background: linear-gradient(145deg, var(--gold), var(--gold-deep));
  color: var(--navy); font-weight: 800; display: grid; place-items: center; font-size: 15px;
}
.brand-name { white-space: nowrap; font-weight: 800; letter-spacing: .06em; font-size: 17px; line-height: 1.1; }
.brand-name span { color: var(--gold); }
.brand-sub { font-size: 11px; color: #AFC0D8; letter-spacing: .12em; text-transform: uppercase; }
.topbar .secure { margin-left: auto; font-size: 12.5px; color: #C7D3E3; display: flex; align-items: center; gap: 6px; }

main { flex: 1; width: 100%; max-width: 1180px; margin: 0 auto; padding: 28px 16px 40px; }

.checkout { display: grid; grid-template-columns: 330px 1fr; gap: 22px; align-items: start; }
@media (max-width: 820px) { .checkout { grid-template-columns: 1fr; } }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.summary { padding: 22px; position: sticky; top: 20px; }
@media (max-width: 820px) { .summary { position: static; } }
.summary .label { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; }
.summary .amount { font-size: 34px; font-weight: 800; letter-spacing: -.01em; margin: 4px 0 14px; color: var(--text); }
.summary dl { margin: 0; display: grid; grid-template-columns: auto 1fr; gap: 8px 14px; font-size: 14px; }
.summary dt { color: var(--muted); }
.summary dd { margin: 0; text-align: right; overflow-wrap: anywhere; }
.summary .mono { font-family: var(--mono); font-size: 13px; }
.timer {
  margin-top: 16px; padding: 10px 12px; border-radius: 10px; background: var(--surface-2);
  font-size: 13px; color: var(--muted); display: flex; justify-content: space-between;
}
.timer strong { color: var(--text); font-variant-numeric: tabular-nums; }

.pay { padding: 0; overflow: hidden; }
.tabs { display: flex; border-bottom: 1px solid var(--line); background: var(--surface-2); }
.tabs button {
  flex: 1; border: 0; background: transparent; padding: 15px 10px; font: inherit; font-weight: 600;
  color: var(--muted); cursor: pointer; border-bottom: 3px solid transparent; margin-bottom: -1px;
}
.tabs button[aria-selected="true"] { color: var(--text); border-bottom-color: var(--gold); background: var(--surface); }
.panel { padding: 24px; }
.panel[hidden] { display: none; }
.panel h2 { margin: 0 0 4px; font-size: 18px; }
.panel p.lead { margin: 0 0 18px; color: var(--muted); font-size: 14px; }

label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; }
input[type=text], input[type=tel], input[type=password] {
  width: 100%; padding: 12px 13px; font: inherit; color: var(--text); background: var(--surface);
  border: 1px solid var(--line); border-radius: 10px; outline: none; transition: border-color .15s, box-shadow .15s;
}
input:focus { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(201, 162, 39, .22); }
.field { margin-bottom: 14px; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.mono-input { font-family: var(--mono) !important; letter-spacing: .06em; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 0; border-radius: 10px; padding: 13px 18px; font: inherit; font-weight: 700; cursor: pointer;
  text-decoration: none;
}
.btn-primary { background: var(--navy); color: #fff; width: 100%; font-size: 16px; }
.btn-primary:hover { background: var(--navy-2); }
@media (prefers-color-scheme: dark) { .btn-primary { background: var(--gold); color: var(--navy); } .btn-primary:hover { background: #D8B23A; } }
.btn-ghost { background: transparent; color: var(--muted); border: 1px solid var(--line); }
.btn-ghost:hover { color: var(--text); }
.btn-good { background: var(--good); color: #fff; }
.btn-bad { background: transparent; color: var(--bad); border: 1px solid currentColor; }
.btn-sm { padding: 7px 11px; font-size: 13px; border-radius: 8px; }

.alert { padding: 11px 13px; border-radius: 10px; font-size: 14px; margin-bottom: 16px; }
.alert-bad { background: var(--bad-bg); color: var(--bad); }
.alert-warn { background: var(--warn-bg); }

.helper { margin-top: 20px; border-top: 1px dashed var(--line); padding-top: 16px; }
.helper summary { cursor: pointer; font-weight: 600; font-size: 14px; }
.helper table { width: 100%; border-collapse: collapse; margin-top: 10px; font-size: 13.5px; }
.helper td { padding: 7px 4px; border-bottom: 1px solid var(--line); }
.helper td:first-child { font-family: var(--mono); white-space: nowrap; }
.helper td:last-child { text-align: right; }
.hint { font-size: 12.5px; color: var(--muted); margin-top: 8px; }

.banks { display: grid; gap: 10px; margin-bottom: 18px; }
.bank {
  display: flex; align-items: center; gap: 12px; padding: 13px 14px; border: 1px solid var(--line);
  border-radius: 10px; cursor: pointer; font-weight: 500; font-size: 14.5px;
}
.bank:has(input:checked) { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(201,162,39,.18); }
.bank input { accent-color: var(--gold-deep); }
.bank .chip {
  width: 34px; height: 34px; border-radius: 8px; background: var(--navy); color: var(--gold);
  display: grid; place-items: center; font-weight: 800; font-size: 12px; flex: none;
}

.qr-wrap { display: flex; gap: 22px; align-items: center; flex-wrap: wrap; }
.qr {
  width: 176px; height: 176px; padding: 12px; background: #fff; border-radius: 12px; border: 1px solid var(--line);
  flex: none;
}
.qr svg { width: 100%; height: 100%; display: block; }
.qr-actions { display: grid; gap: 10px; flex: 1; min-width: 200px; }

.foot { color: var(--muted); font-size: 12.5px; text-align: center; padding: 20px 16px 28px; border-top: 1px solid var(--line); }
.foot strong { color: var(--text); }

.center { max-width: 480px; margin: 20px auto; padding: 30px 28px; text-align: center; }
.center h1 { font-size: 22px; margin: 12px 0 6px; }
.center p { color: var(--muted); margin: 0 0 20px; }
.badge-icon { width: 54px; height: 54px; border-radius: 50%; display: grid; place-items: center; margin: 0 auto; font-size: 26px; font-weight: 800; }
.tone-good { background: var(--good-bg); color: var(--good); }
.tone-bad { background: var(--bad-bg); color: var(--bad); }
.tone-neutral { background: var(--surface-2); color: var(--muted); }
.otp-input { text-align: center; font-size: 26px !important; letter-spacing: .5em; font-family: var(--mono) !important; }
.stack { display: grid; gap: 10px; }

/* dashboard */
.dash h1 { font-size: 22px; margin: 0 0 4px; }
.dash .sub { color: var(--muted); margin: 0 0 22px; }
.dash section { margin-bottom: 24px; padding: 20px; }
.dash h2 { font-size: 15px; margin: 0 0 12px; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); }
.table-scroll { overflow-x: auto; }
.dash table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.dash th { text-align: left; font-weight: 600; color: var(--muted); padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.dash td { padding: 9px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.dash td.mono, .dash code { font-family: var(--mono); font-size: 12.5px; }
.pill { display: inline-block; padding: 2px 9px; border-radius: 99px; font-size: 12px; font-weight: 600; background: var(--surface-2); color: var(--muted); }
.pill.succeeded, .pill.ok { background: var(--good-bg); color: var(--good); }
.pill.failed, .pill.expired, .pill.cancelled, .pill.err { background: var(--bad-bg); color: var(--bad); }
.pill.processing, .pill.awaiting_otp, .pill.pending { background: var(--warn-bg); color: var(--text); }
.pill.refunded, .pill.partially_refunded { background: #E8EEF8; color: #2A4D80; }
@media (prefers-color-scheme: dark) { .pill.refunded, .pill.partially_refunded { background: #182A44; color: #9DBCE8; } }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
@media (max-width: 820px) { .grid-2 { grid-template-columns: 1fr; } }
pre.code { background: var(--navy); color: #E3E9F2; padding: 14px; border-radius: 10px; font: 12.5px/1.55 var(--mono); overflow-x: auto; margin: 0; }
.empty { color: var(--muted); font-size: 14px; padding: 8px 0; }

@media (max-width: 520px) { .topbar .secure span { display: none; } .tabs button { font-size: 14px; padding: 13px 6px; } }

/* ── v2: navigation and admin pages ───────────────────────── */
.mainnav { margin-left: auto; display: flex; gap: 4px; flex-wrap: wrap; }
.mainnav a { color: #C7D3E3; text-decoration: none; padding: 8px 12px; border-radius: 8px; font-weight: 600; font-size: 14px; }
.mainnav a:hover { color: #fff; background: rgba(255,255,255,.06); }
.mainnav a[aria-current="page"] { color: var(--navy); background: var(--gold); }
.mainnav .muted-link { font-weight: 500; opacity: .8; }
@media (max-width: 720px) { .topbar-inner { flex-wrap: wrap; } .mainnav { margin-left: 0; width: 100%; } }
.page-head { display: flex; justify-content: space-between; gap: 16px; align-items: flex-start; flex-wrap: wrap; margin-bottom: 18px; }
.page-head .sub { margin-bottom: 0; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.inline-filter { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
select, .inline-filter input[type=text] {
  padding: 9px 11px; font: inherit; color: var(--text); background: var(--surface);
  border: 1px solid var(--line); border-radius: 10px; }
select { padding-right: 28px; }
.field select { width: 100%; padding: 12px 13px; }
.stats { display: grid; grid-template-columns: repeat(5, 1fr); gap: 14px; margin-bottom: 22px; }
@media (max-width: 820px) { .stats { grid-template-columns: repeat(2, 1fr); } }
.stat { padding: 16px 18px; display: flex; flex-direction: column; gap: 4px; text-decoration: none; color: inherit; }
.stat span { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .07em; }
.stat strong { font-size: 26px; font-variant-numeric: tabular-nums; }
.section-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 8px; }
.section-head h2 { margin: 0; }
.crumb { font-size: 13px; color: var(--muted); margin: 0 0 6px; }
.alert-good { background: var(--good-bg); color: var(--good); }
.kv { display: grid; grid-template-columns: minmax(130px, auto) 1fr; gap: 9px 16px; margin: 0; font-size: 14px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }
.wrap { overflow-wrap: anywhere; white-space: normal !important; }
.copy { user-select: all; }
.small { font-size: 12.5px; }
.muted { color: var(--muted); font-weight: 400; }
.mono { font-family: var(--mono); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 18px; padding: 22px; }
.form-grid .full { grid-column: 1 / -1; }
@media (max-width: 720px) { .form-grid { grid-template-columns: 1fr; } }
.form-grid .btns { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; }
.form-grid .btns .btn-primary { width: auto; }
.check { display: flex; gap: 9px; align-items: center; font-weight: 500; font-size: 14px; margin: 8px 0 12px; }
.check input { accent-color: var(--gold-deep); width: 16px; height: 16px; }
fieldset { border: 1px solid var(--line); border-radius: 12px; padding: 16px 18px 6px; margin: 6px 0 14px;
  display: grid; grid-template-columns: 1fr 1fr; gap: 0 18px; }
fieldset[hidden] { display: none; }
@media (max-width: 720px) { fieldset { grid-template-columns: 1fr; } }
legend { font-weight: 700; font-size: 13px; padding: 0 6px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.wa-card { border: 1px solid var(--line); border-radius: 12px; margin-bottom: 14px; padding: 18px; }
.merchant-line { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap;
  padding-bottom: 14px; margin-bottom: 14px; border-bottom: 1px solid var(--line); }
.gw-chip { font-size: 11.5px; font-weight: 600; padding: 3px 9px; border-radius: 99px; background: var(--surface-2); color: var(--muted); }
details.delivery { border-top: 1px solid var(--line); padding: 10px 0; }
details.delivery summary { cursor: pointer; font-size: 14px; }
details.delivery pre { margin-top: 8px; white-space: pre-wrap; overflow-wrap: anywhere; max-height: 300px; overflow-y: auto; }
.row input { width: 100%; padding: 10px 12px; font: inherit; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); color: var(--text); }
.refund-row { grid-template-columns: 1fr 1fr auto; }

/* mail */
.maillist { list-style: none; margin: 0; padding: 0; }
.maillist li a { display: grid; grid-template-columns: 220px 1fr auto; grid-template-areas: "from subject meta" "from to meta";
  gap: 2px 16px; padding: 13px 18px; border-bottom: 1px solid var(--line); text-decoration: none; color: var(--text); }
.maillist li a:hover { background: var(--surface-2); }
.maillist li.unseen .ml-subject, .maillist li.unseen .ml-from { font-weight: 700; }
.ml-from { grid-area: from; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ml-subject { grid-area: subject; }
.ml-to { grid-area: to; font-size: 12.5px; color: var(--muted); }
.ml-meta { grid-area: meta; font-size: 12.5px; color: var(--muted); text-align: right; white-space: nowrap; }
@media (max-width: 720px) { .maillist li a { grid-template-columns: 1fr; grid-template-areas: "from" "subject" "to" "meta"; } .ml-meta { text-align: left; } }
.mail-frame { width: 100%; height: 560px; border: 0; background: #fff; display: block; }
.mailtext { white-space: pre-wrap; font: 14px/1.6 var(--mono); margin: 0; overflow-wrap: anywhere; }
table.headers { width: 100%; font-size: 13px; border-collapse: collapse; }
table.headers td { padding: 6px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.headers td:first-child { color: var(--muted); white-space: nowrap; }

/* whatsapp */
.wa-layout { display: grid; grid-template-columns: 320px 1fr; min-height: 560px; overflow: hidden; }
@media (max-width: 820px) { .wa-layout { grid-template-columns: 1fr; } }
.wa-list { border-right: 1px solid var(--line); background: var(--surface-2); overflow-y: auto; max-height: 640px; }
.wa-new { display: grid; gap: 8px; padding: 14px; border-bottom: 1px solid var(--line); }
.wa-new input { padding: 9px 11px; font: inherit; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); color: var(--text); }
.wa-conv { display: grid; gap: 3px; padding: 12px 14px; border-bottom: 1px solid var(--line); text-decoration: none; color: var(--text); font-size: 14px; }
.wa-conv:hover, .wa-conv.active { background: var(--surface); }
.wa-conv.active { box-shadow: inset 3px 0 0 var(--gold); }
.wa-prev { color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wa-chat { display: flex; flex-direction: column; min-width: 0; }
.wa-head { padding: 14px 18px; border-bottom: 1px solid var(--line); }
.wa-msgs { flex: 1; overflow-y: auto; max-height: 470px; padding: 18px; display: flex; flex-direction: column; gap: 10px;
  background: radial-gradient(circle at 1px 1px, rgba(154,123,30,.09) 1px, transparent 0) 0 0 / 18px 18px; }
.bubble { max-width: 72%; padding: 9px 12px 7px; border-radius: 12px; font-size: 14.5px; box-shadow: 0 1px 1px rgba(0,0,0,.06); }
.bubble.out { align-self: flex-end; background: #DCF3D8; color: #10301A; border-bottom-right-radius: 4px; }
.bubble.in { align-self: flex-start; background: var(--surface); border: 1px solid var(--line); border-bottom-left-radius: 4px; }
@media (prefers-color-scheme: dark) { .bubble.out { background: #1D4A33; color: #E3F5E9; } }
.b-text { white-space: pre-wrap; overflow-wrap: anywhere; }
.b-tag { display: inline-block; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; opacity: .6; margin-top: 3px; }
.b-meta { font-size: 11.5px; opacity: .65; margin-top: 4px; text-align: right; }
.tick.read { color: #2B7BD6; font-weight: 700; }
.tick.failed { color: var(--bad); font-weight: 700; }
.wa-compose { display: flex; gap: 8px; padding: 12px; border-top: 1px solid var(--line); flex-wrap: wrap; }
.wa-compose input[name=text] { flex: 1; min-width: 180px; padding: 10px 12px; font: inherit; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); color: var(--text); }
.wa-compose .wa-name { width: 130px; padding: 10px 12px; font: inherit; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); color: var(--text); }
.wa-buttons { width: 100%; display: flex; gap: 8px; flex-wrap: wrap; }

/* v2.1: subscriptions and Curlec */
.alert-info { background: #E8EEF8; color: #2A4D80; }
.pill.active, .pill.captured, .pill.paid { background: var(--good-bg); color: var(--good); }
.pill.created, .pill.authenticated, .pill.authorized, .pill.attempted { background: var(--surface-2); color: var(--text); }
.pill.halted { background: var(--bad-bg); color: var(--bad); }
.pill.completed, .pill.paused { background: #E8EEF8; color: #2A4D80; }
.clockbar { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; padding: 14px 18px; margin-bottom: 22px; }
.clockbar .now { font-variant-numeric: tabular-nums; }
.clockbar .now strong { font-size: 18px; }
.clockbar form { display: flex; gap: 8px; flex-wrap: wrap; margin-left: auto; }
.clockbar .offset { font-size: 12.5px; color: var(--muted); }
.timeline { list-style: none; margin: 0; padding: 0; font-size: 14px; }
.timeline li { display: grid; grid-template-columns: 160px 1fr; gap: 12px; padding: 7px 0; border-bottom: 1px solid var(--line); }
.timeline li span { color: var(--muted); font-variant-numeric: tabular-nums; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }
.btn-row form { margin: 0; }
