:root {
  --brand: #4f46e5;
  --brand-soft: color-mix(in srgb, var(--brand) 10%, #fff);
  --side: #0f172a;
  --side-2: color-mix(in srgb, var(--side) 88%, var(--on-side-strong));
  /* set from the admin's Branding page; see applyTheme() in app.js */
  --grad-from: #4f46e5;
  --grad-to: #0ea5a4;
  --grad-angle: 135deg;
  --grad: linear-gradient(var(--grad-angle), var(--grad-from), var(--grad-to));
  --on-brand: #fff;
  --on-grad: #fff;
  --on-side: #cbd5e1;
  --on-side-strong: #fff;
  --on-side-dim: #94a3b8;
  --text: #0f172a;
  --muted: #64748b;
  --line: #e2e8f0;
  --bg: #f6f7fb;
  --card: #fff;
  --ok: #059669;
  --ok-soft: #ecfdf5;
  --bad: #dc2626;
  --bad-soft: #fef2f2;
  --warn: #b45309;
  --warn-soft: #fffbeb;
  --radius: 12px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font-family: Inter, system-ui, sans-serif; font-size: 14px; color: var(--text); background: var(--bg); }
a { color: var(--brand); text-decoration: none; }
button { font: inherit; cursor: pointer; }
input, select, textarea { font: inherit; }
svg.i { width: 16px; height: 16px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }

/* ---------- layout ---------- */
.shell { display: grid; grid-template-columns: 250px 1fr; min-height: 100vh; }
.side { background: var(--side); color: var(--on-side); padding: 14px 10px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.side .me { display: flex; gap: 10px; align-items: center; background: var(--side-2); border-radius: 10px; padding: 10px; margin-bottom: 14px; }
.avatar { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; color: var(--on-grad);
  background: var(--grad); flex: none; }
.me b { display: block; color: var(--on-side-strong); font-size: 13px; }
.me small { font-size: 11px; color: var(--on-side-dim); word-break: break-all; }
.nav-sec { font-size: 10px; letter-spacing: .08em; text-transform: uppercase; color: var(--on-side-dim); margin: 16px 10px 6px; font-weight: 600; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; color: var(--on-side); font-size: 13px; }
.nav a:hover { background: var(--side-2); color: var(--on-side-strong); }
.nav a.on { background: var(--brand); color: var(--on-brand); }
.nav a .count { margin-left: auto; background: #f59e0b; color: #111; border-radius: 99px; font-size: 10px; padding: 1px 7px; font-weight: 700; }
.main { min-width: 0; display: flex; flex-direction: column; }
.top { display: flex; align-items: center; gap: 12px; padding: 12px 24px; background: #fff; border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
.top .brand { font-weight: 800; font-size: 16px; display: flex; gap: 8px; align-items: center; }
.top .brand .logo { width: 26px; height: 26px; border-radius: 8px; background: var(--grad); display: grid; place-items: center; color: var(--on-grad); }
.brand-img { height: 32px; width: auto; max-width: 150px; object-fit: contain; display: block; }
.top .grow { flex: 1; }
.pill-bal { background: var(--brand); color: var(--on-brand); border-radius: 99px; padding: 5px 12px; font-weight: 700; font-size: 12px; display: flex; gap: 6px; align-items: center; }
.burger { display: none; background: none; border: 0; padding: 4px; }
.acct { position: relative; }
.acct-btn { border: 0; padding: 0; cursor: pointer; font: inherit; font-weight: 700; }
.acct-btn:hover, .acct-btn[aria-expanded="true"] { box-shadow: 0 0 0 3px var(--brand-soft); }
.acct-btn:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.acct-menu { position: absolute; right: 0; top: calc(100% + 8px); width: 240px; background: #fff; border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 10px 28px rgba(15,23,42,.14); padding: 6px; }
.acct-h { padding: 8px 10px 10px; border-bottom: 1px solid var(--line); margin-bottom: 6px; }
.acct-h b { display: block; font-size: 13px; }
.acct-h small { display: block; font-size: 11px; color: var(--muted); word-break: break-all; margin-bottom: 6px; }
.acct-menu a { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; color: var(--text); font-size: 13px; }
.acct-menu a:hover { background: var(--brand-soft); color: var(--brand); }
.content { padding: 24px; max-width: 1400px; width: 100%; }
.page-h h1 { margin: 0; font-size: 20px; }
.page-h p { margin: 2px 0 18px; color: var(--muted); font-size: 12px; }
.footer { margin-top: auto; padding: 14px 24px; color: var(--muted); font-size: 11px; }

/* ---------- cards ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; margin-bottom: 18px; }
.card-h { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 13px; text-transform: uppercase; letter-spacing: .03em; margin-bottom: 14px; }
.card-h .grow { flex: 1; }
.card-h svg { color: var(--brand); }
.wallet { border-radius: var(--radius); padding: 22px; color: var(--on-grad); margin-bottom: 18px; display: flex; align-items: center; gap: 16px;
  background: radial-gradient(circle at 85% 20%, rgba(255,255,255,.18), transparent 40%), var(--grad); }
.wallet .lbl { font-size: 11px; opacity: .85; display: flex; gap: 6px; align-items: center; }
.wallet .amt { font-size: 30px; font-weight: 800; letter-spacing: -.02em; margin: 4px 0; }
.wallet .sub { font-size: 11px; opacity: .85; }
.wallet .grow { flex: 1; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; margin-bottom: 18px; }
.stat { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; display: flex; align-items: flex-start; }
.stat .k { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; font-weight: 600; }
.stat .v { font-size: 24px; font-weight: 800; margin: 6px 0 2px; }
.stat .s { font-size: 11px; color: var(--muted); }
.stat .ic { margin-left: auto; width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; background: var(--brand-soft); color: var(--brand); }
.quick { display: flex; gap: 8px; align-items: center; margin-bottom: 18px; flex-wrap: wrap; }
.quick .lbl { font-size: 11px; color: var(--muted); font-weight: 700; letter-spacing: .05em; text-transform: uppercase; margin-right: 4px; }

/* auto-fit + a width cap (from --n, the number of cards) keeps 1–3 cards from leaving a ragged gap or stretching across the page */
.svc-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; max-width: min(100%, calc(var(--n, 99) * 240px + (var(--n, 99) - 1) * 12px)); }
.svc { position: relative; border: 1px solid var(--line); border-radius: 10px; padding: 18px 10px 14px; text-align: center; background: #fff; color: var(--text);
  transition: .15s; display: flex; flex-direction: column; align-items: center; gap: 8px; font-size: 12px; font-weight: 600; }
.svc:hover { border-color: var(--brand); box-shadow: 0 6px 18px color-mix(in srgb, var(--brand) 14%, transparent); transform: translateY(-1px); }
.svc .ic { width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center; color: #fff; background: var(--grad); }
.svc .ic svg { color: var(--on-grad); }
.svc .price { font-size: 11px; color: var(--muted); font-weight: 500; }
.svc .tag { position: absolute; top: 8px; right: 8px; font-size: 9px; font-weight: 700; padding: 1px 6px; border-radius: 4px; background: var(--brand-soft); color: var(--brand); }
.svc.off { opacity: .45; pointer-events: none; }

/* ---------- table ---------- */
.tbl-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; padding: 10px 12px; background: #f8fafc; font-weight: 600; white-space: nowrap; }
td { padding: 12px; border-top: 1px solid var(--line); font-size: 13px; vertical-align: middle; }
td.num { font-variant-numeric: tabular-nums; font-weight: 600; white-space: nowrap; }
.cr { color: var(--ok); } .db { color: var(--bad); } .zero { color: var(--muted); }
.empty { text-align: center; color: var(--muted); padding: 30px; }
.sub-t { color: var(--muted); font-size: 11px; }

.badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 99px; font-size: 11px; font-weight: 600; white-space: nowrap; }
.b-completed, .b-approved, .b-active { background: var(--ok-soft); color: var(--ok); }
.b-no_record, .b-failed, .b-declined, .b-rejected, .b-suspended { background: var(--bad-soft); color: var(--bad); }
.b-pending { background: var(--warn-soft); color: var(--warn); }
.b-refunded, .b-admin { background: var(--brand-soft); color: var(--brand); }
.b-user { background: #f1f5f9; color: var(--muted); }

/* ---------- forms / buttons ---------- */
.btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: #fff; color: var(--text); padding: 8px 14px; border-radius: 8px; font-weight: 600; font-size: 13px; }
.btn:hover { border-color: var(--brand); color: var(--brand); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--on-brand); }
.btn.primary:hover { filter: brightness(1.08); color: var(--on-brand); }
.btn.ok { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn.danger { background: #fff; border-color: #fecaca; color: var(--bad); }
.btn.white { background: #fff; color: var(--brand); border: 0; }
.btn.sm { padding: 5px 10px; font-size: 12px; }
.btn:disabled { opacity: .6; cursor: wait; }
.form { display: grid; gap: 14px; max-width: 480px; }
.form.wide { max-width: none; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); align-items: end; }
label.f { display: grid; gap: 6px; font-size: 12px; font-weight: 600; color: #334155; }
label.f input, label.f select, label.f textarea { border: 1px solid #cbd5e1; border-radius: 8px; padding: 10px 12px; background: #fff; font-weight: 400; }
label.f input:focus, label.f select:focus, label.f textarea:focus { outline: 2px solid var(--brand-soft); border-color: var(--brand); }
.hint { font-size: 11px; color: var(--muted); font-weight: 400; }
.search { border: 1px solid #cbd5e1; border-radius: 8px; padding: 8px 12px; min-width: 240px; }
.tabs { display: flex; gap: 6px; margin-bottom: 14px; }
.tabs button { border: 1px solid var(--line); background: #fff; padding: 6px 12px; border-radius: 99px; font-size: 12px; font-weight: 600; color: var(--muted); }
.tabs button.on { background: var(--brand); color: var(--on-brand); border-color: var(--brand); }
.notice { background: var(--warn-soft); border: 1px solid #fde68a; color: #92400e; padding: 10px 14px; border-radius: 10px; font-size: 12px; margin-bottom: 16px; }
.result { background: #f8fafc; border: 1px solid var(--line); border-radius: 10px; padding: 14px; margin-top: 16px; }
.result dl { display: grid; grid-template-columns: 160px 1fr; gap: 6px 12px; margin: 0; }
.result dt { color: var(--muted); font-size: 12px; text-transform: capitalize; }
.result dd { margin: 0; font-weight: 600; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row .grow { flex: 1; min-width: 0; }
.row .grow .search { flex: 1; }
.role-sel { border: 1px solid #cbd5e1; border-radius: 6px; padding: 4px 6px; font-size: 12px; background: #fff; }
.skeleton { height: 64px; border-radius: 10px; background: linear-gradient(90deg, #f1f5f9 25%, #e2e8f0 50%, #f1f5f9 75%); background-size: 200% 100%; animation: shimmer 1.2s infinite linear; }
@keyframes shimmer { to { background-position: -200% 0; } }
.switch { position: relative; display: inline-block; width: 38px; height: 22px; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span { position: absolute; inset: 0; background: #cbd5e1; border-radius: 99px; transition: .15s; cursor: pointer; }
.switch span::before { content: ''; position: absolute; width: 16px; height: 16px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: .15s; }
.switch input:checked + span { background: var(--ok); }
.switch input:checked + span::before { transform: translateX(16px); }
.switch input:focus-visible + span { outline: 2px solid var(--brand); outline-offset: 2px; }
tr.hidden-svc td:first-child b { color: var(--muted); }

/* ---------- auth ---------- */
.auth { min-height: 100vh; display: grid; grid-template-columns: 1fr 1fr; }
.art { position: relative; overflow: hidden; background: var(--grad); color: var(--on-grad); padding: 48px; display: flex; flex-direction: column; justify-content: center; }
.art h2 { font-size: 34px; margin: 0 0 12px; letter-spacing: -.02em; white-space: pre-line; overflow-wrap: anywhere; }
.art p { opacity: .85; max-width: 420px; line-height: 1.6; white-space: pre-line; overflow-wrap: anywhere; }
.art-c { position: relative; z-index: 1; }
.art-brand { display: flex; gap: 10px; align-items: center; font-weight: 800; font-size: 18px; margin-bottom: 40px; }
.art-logo { width: 32px; height: 32px; border-radius: 9px; background: rgba(255,255,255,.15); display: grid; place-items: center; }
.art-img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
/* a picture can be any colour, so its text is always white on a dark scrim */
.art.has-img { color: #fff; }
.art.has-img::after { content: ''; position: absolute; inset: 0; background: linear-gradient(to top, rgba(15,23,42,.82), rgba(15,23,42,.35)); }
.art.preview { padding: 24px; min-height: 260px; border-radius: 10px; }
.art.preview h2 { font-size: 22px; }
.art.preview p { font-size: 12px; }
.art.preview .art-brand { margin-bottom: 20px; font-size: 14px; }
.brand-form { display: grid; gap: 14px; }
.color-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; }
label.f input[type=color] { height: 42px; padding: 4px; width: 100%; cursor: pointer; }
.grad-bar { height: 42px; border-radius: 10px; background: var(--grad); }
.brand-split { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 18px; align-items: start; }
.logo-box { width: 180px; height: 72px; border: 1px dashed #cbd5e1; border-radius: 10px; display: grid; place-items: center; background: #fff; }
.save-bar { position: sticky; bottom: 0; background: var(--bg); padding: 12px 0; }
.auth .panel { display: grid; place-items: center; padding: 32px; }
.auth .box { width: 100%; max-width: 380px; }
.auth .box h1 { font-size: 22px; margin: 0 0 4px; }
.auth .box > p { color: var(--muted); margin: 0 0 22px; }
.auth .form { max-width: none; }

/* ---------- toast / modal ---------- */
.toast { position: fixed; bottom: 20px; right: 20px; background: var(--side); color: var(--on-side-strong); padding: 12px 16px; border-radius: 10px; z-index: 50; max-width: 360px; box-shadow: 0 10px 30px rgba(0,0,0,.2); }
.toast.err { background: var(--bad); }
.modal { position: fixed; inset: 0; background: rgba(15,23,42,.5); display: grid; place-items: center; z-index: 40; padding: 16px; }
.modal[hidden] { display: none; }
.modal-card { background: #fff; border-radius: 14px; padding: 22px; width: 100%; max-width: 460px; max-height: 90vh; overflow: auto; }
.modal-card h3 { margin: 0 0 4px; }
.modal-card .sub-t { margin-bottom: 16px; display: block; }

@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: fixed; left: -270px; width: 260px; z-index: 30; transition: left .2s; }
  .side.open { left: 0; }
  .burger { display: block; }
  .auth { grid-template-columns: 1fr; }
  .auth .art { padding: 28px 20px; min-height: 220px; }
  .auth .art h2 { font-size: 24px; }
  .auth .art-brand { margin-bottom: 20px; }
  .content { padding: 16px; }
}
