:root {
  --bg: #0b1020;
  --surface: #141a30;
  --surface-2: #1a2140;
  --border: #232b4d;
  --text: #e6e9f5;
  --muted: #8b94b8;
  --accent: #5eead4;
  --accent-2: #818cf8;
  --good: #22c55e;
  --warn: #fbbf24;
  --bad: #ef4444;
  --shadow: 0 10px 30px rgba(0,0,0,0.35);
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button { font: inherit; cursor: pointer; }

.topbar {
  display: flex; justify-content: space-between; align-items: center;
  padding: 16px 28px; background: rgba(15,22,48,0.85);
  border-bottom: 1px solid var(--border); backdrop-filter: blur(8px);
  position: sticky; top: 0; z-index: 5;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark {
  width: 40px; height: 40px; border-radius: 10px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  display: grid; place-items: center; font-weight: 700; color: #0b1020; font-size: 20px;
}
.brand-title { font-weight: 600; font-size: 18px; }
.brand-sub { font-size: 12px; color: var(--muted); }
.topnav a { padding: 6px 12px; border-radius: 8px; color: var(--muted); }
.topnav a.active, .topnav a:hover { color: var(--text); background: var(--surface); text-decoration: none; }

.container { max-width: 1100px; margin: 0 auto; padding: 28px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.big { font-size: 40px; font-weight: 700; letter-spacing: -0.02em; margin-top: 4px; }

.card-pane {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 16px; padding: 24px; box-shadow: var(--shadow);
}
.summary {
  display: flex; justify-content: space-between; align-items: flex-end; gap: 24px;
  margin-bottom: 28px; flex-wrap: wrap;
}
.summary-meta { display: flex; gap: 28px; }
.summary-meta > div > div { font-size: 18px; font-weight: 600; margin-top: 2px; }

.section-head {
  display: flex; justify-content: space-between; align-items: center;
  margin: 24px 0 14px;
}
.section-head h2 { margin: 0; font-size: 18px; font-weight: 600; }
.btn-ghost {
  background: transparent; color: var(--muted); border: 1px solid var(--border);
  padding: 6px 12px; border-radius: 8px;
}
.btn-ghost:hover { color: var(--text); background: var(--surface); }

.cards-grid {
  display: grid; gap: 18px; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
}
.cc {
  position: relative; aspect-ratio: 1.586 / 1; border-radius: 16px; padding: 22px;
  color: #fff; cursor: pointer; overflow: hidden;
  background: linear-gradient(135deg, #4f46e5 0%, #06b6d4 100%);
  box-shadow: var(--shadow); transition: transform .15s ease;
  display: flex; flex-direction: column; justify-content: space-between;
}
.cc:hover { transform: translateY(-2px); }
.cc.var-1 { background: linear-gradient(135deg, #4f46e5, #06b6d4); }
.cc.var-2 { background: linear-gradient(135deg, #db2777, #f59e0b); }
.cc.var-3 { background: linear-gradient(135deg, #059669, #06b6d4); }
.cc.var-4 { background: linear-gradient(135deg, #7c3aed, #ec4899); }
.cc.var-5 { background: linear-gradient(135deg, #0f172a, #475569); }
.cc-top { display: flex; justify-content: space-between; align-items: flex-start; }
.cc-chip {
  width: 38px; height: 28px; border-radius: 5px;
  background: linear-gradient(135deg, #fcd34d, #f59e0b);
  border: 1px solid rgba(0,0,0,0.2);
}
.cc-brand { font-weight: 700; letter-spacing: 0.04em; opacity: 0.9; }
.cc-num { font-family: 'SF Mono', ui-monospace, monospace; font-size: 18px; letter-spacing: 0.12em; }
.cc-bal-label { font-size: 11px; opacity: 0.8; text-transform: uppercase; letter-spacing: 0.1em; }
.cc-bal { font-size: 26px; font-weight: 700; margin-top: 2px; }
.cc-bottom { display: flex; justify-content: space-between; align-items: flex-end; }
.cc-meta { font-size: 12px; opacity: 0.85; }

.tx-list { padding: 0; }
.tx-row {
  display: grid; grid-template-columns: 1fr auto auto; gap: 12px; align-items: center;
  padding: 14px 20px; border-bottom: 1px solid var(--border);
}
.tx-row:last-child { border-bottom: 0; }
.tx-merch { font-weight: 500; }
.tx-card { color: var(--muted); font-size: 12px; font-family: 'SF Mono', ui-monospace, monospace; }
.tx-amount { font-variant-numeric: tabular-nums; font-weight: 600; }
.tx-date { color: var(--muted); font-size: 12px; }
.empty { padding: 30px; text-align: center; color: var(--muted); }

/* Modal */
.modal {
  position: fixed; inset: 0; background: rgba(7,11,28,0.7);
  display: grid; place-items: center; z-index: 50; padding: 16px;
  backdrop-filter: blur(4px);
}
.modal[hidden] { display: none; }
.modal-inner {
  position: relative; background: var(--surface); border: 1px solid var(--border);
  border-radius: 18px; padding: 28px; width: min(420px, 100%); box-shadow: var(--shadow);
}
.modal-close {
  position: absolute; top: 10px; right: 12px; background: transparent; color: var(--muted);
  border: 0; font-size: 24px; line-height: 1; padding: 4px 8px; border-radius: 6px;
}
.modal-close:hover { color: var(--text); background: var(--surface-2); }
.qr-wrap {
  background: #fff; padding: 14px; border-radius: 12px; margin: 16px auto;
  width: fit-content;
}
.modal h3 { margin: 0 0 4px; }

/* Public card view */
.publiccard {
  max-width: 460px; margin: 60px auto; padding: 0 16px;
}
.publiccard .cc { aspect-ratio: 1.586 / 1; cursor: default; }
.balance-block {
  text-align: center; margin: 24px 0; padding: 28px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 16px;
}
.balance-block .label { color: var(--muted); font-size: 13px; text-transform: uppercase; letter-spacing: 0.1em; }
.balance-block .value { font-size: 56px; font-weight: 700; margin-top: 6px; letter-spacing: -0.03em; }

/* Admin */
.login-card { max-width: 380px; margin: 80px auto; }
.login-card .card-pane { text-align: center; }
.field { display: block; width: 100%; margin: 12px 0;
  background: var(--surface-2); border: 1px solid var(--border); color: var(--text);
  padding: 12px 14px; border-radius: 10px; font-size: 15px;
}
.field:focus { outline: 2px solid var(--accent-2); outline-offset: -2px; }
.btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #0b1020; font-weight: 600; border: 0; padding: 12px 16px;
  border-radius: 10px; width: 100%; font-size: 15px;
}
.btn-primary:hover { filter: brightness(1.05); }
.btn-good, .btn-bad {
  border: 0; padding: 8px 14px; border-radius: 8px; font-weight: 600; font-size: 13px;
}
.btn-good { background: var(--good); color: #062712; }
.btn-bad { background: var(--bad); color: #2b0707; }
.btn-good:hover, .btn-bad:hover { filter: brightness(1.08); }

.tabs { display: flex; gap: 6px; margin: 0 0 16px; border-bottom: 1px solid var(--border); }
.tab { background: transparent; border: 0; color: var(--muted);
  padding: 10px 14px; border-bottom: 2px solid transparent; }
.tab.active { color: var(--text); border-color: var(--accent); }

.pill { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 11px;
  text-transform: uppercase; letter-spacing: 0.05em; }
.pill.pending { background: rgba(251,191,36,0.15); color: var(--warn); }
.pill.approved { background: rgba(34,197,94,0.15); color: var(--good); }
.pill.declined, .pill.failed { background: rgba(239,68,68,0.15); color: var(--bad); }
.pill.authorized { background: rgba(34,197,94,0.15); color: var(--good); }

.row-actions { display: flex; gap: 8px; }
.muted-card { padding: 30px; text-align: center; color: var(--muted); }

/* form for charge */
.charge-form { display: grid; gap: 12px; margin-top: 12px;
  grid-template-columns: 1fr 1fr 1fr auto; align-items: end; }
.charge-form label { font-size: 12px; color: var(--muted); display: block; }
.charge-form .field { margin: 4px 0 0; }
.charge-form .btn-primary { width: auto; }
@media (max-width: 720px) { .charge-form { grid-template-columns: 1fr; } }
