:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --bg: #f6f7f9;
  --surface: #ffffff;
  --border: #e3e6ea;
  --text: #16191d;
  --muted: #6b7280;
  --ok: #059669;
  --ok-bg: #ecfdf5;
  --warn: #d97706;
  --warn-bg: #fffbeb;
  --err: #dc2626;
  --err-bg: #fef2f2;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.05), 0 4px 16px rgba(16, 24, 40, 0.06);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Layout ─────────────────────────────────────────────── */
.wrap { max-width: 1140px; margin: 0 auto; padding: 24px 20px 64px; }
.narrow { max-width: 560px; margin: 0 auto; padding: 40px 20px 64px; }

.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 20;
}
.topbar-inner {
  max-width: 1140px; margin: 0 auto; padding: 0 20px;
  display: flex; align-items: center; gap: 24px; min-height: 60px;
}
.brand { font-weight: 700; font-size: 1.05rem; letter-spacing: -0.01em; }
.brand img { height: 28px; vertical-align: middle; margin-right: 8px; }
.nav { display: flex; gap: 4px; flex: 1; flex-wrap: wrap; }
.nav a {
  padding: 7px 12px; border-radius: 8px; color: var(--muted);
  font-size: 0.9rem; font-weight: 500;
}
.nav a:hover { background: var(--bg); color: var(--text); text-decoration: none; }
.nav a.active { background: #eef4ff; color: var(--primary); }

/* ── Cards ──────────────────────────────────────────────── */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 22px; box-shadow: var(--shadow);
  margin-bottom: 18px;
}
.card h2 { margin: 0 0 4px; font-size: 1.05rem; letter-spacing: -0.01em; }
.card .sub { color: var(--muted); font-size: 0.87rem; margin: 0 0 18px; }

h1 { font-size: 1.5rem; letter-spacing: -0.02em; margin: 0 0 4px; }
.page-sub { color: var(--muted); margin: 0 0 22px; font-size: 0.92rem; }

/* ── Grid / stats ───────────────────────────────────────── */
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.grid-4 { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }

.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; }
.stat .label { color: var(--muted); font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.05em; font-weight: 600; }
.stat .value { font-size: 1.7rem; font-weight: 700; letter-spacing: -0.02em; margin-top: 4px; }
.stat .value.sm { font-size: 1.25rem; }

/* ── Forms ──────────────────────────────────────────────── */
.field { margin-bottom: 16px; }
.field label { display: block; font-weight: 600; font-size: 0.86rem; margin-bottom: 6px; }
.field .help { color: var(--muted); font-size: 0.79rem; margin-top: 5px; }

input[type=text], input[type=email], input[type=password], input[type=number],
input[type=url], select, textarea {
  width: 100%; padding: 10px 12px; border: 1px solid var(--border);
  border-radius: 9px; font-size: 0.93rem; font-family: inherit;
  background: var(--surface); color: var(--text);
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}
input[type=color] { width: 56px; height: 38px; padding: 3px; border: 1px solid var(--border); border-radius: 8px; }

.row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 620px) { .row { grid-template-columns: 1fr; } }

.check { display: flex; align-items: center; gap: 9px; }
.check input { width: 17px; height: 17px; accent-color: var(--primary); }
.check label { margin: 0; font-weight: 500; }

/* ── Buttons ────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 10px 18px; border-radius: 9px; border: 1px solid transparent;
  background: var(--primary); color: #fff; font-weight: 600; font-size: 0.92rem;
  cursor: pointer; font-family: inherit; text-decoration: none; transition: background .12s;
}
.btn:hover { background: var(--primary-dark); text-decoration: none; color: #fff; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-lg { width: 100%; padding: 14px; font-size: 1rem; }
.btn-ghost { background: var(--surface); border-color: var(--border); color: var(--text); }
.btn-ghost:hover { background: var(--bg); color: var(--text); }
.btn-sm { padding: 6px 11px; font-size: 0.83rem; }
.btn-danger { background: var(--err); }
.btn-danger:hover { background: #b91c1c; }

/* ── Tables ─────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; margin: 0 -22px -22px; }
table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
th {
  text-align: left; padding: 10px 14px; color: var(--muted);
  font-size: 0.74rem; text-transform: uppercase; letter-spacing: 0.05em;
  font-weight: 700; border-bottom: 1px solid var(--border); white-space: nowrap;
}
td { padding: 12px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: #fafbfc; }
.mono { font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace; font-size: 0.85em; }
.nowrap { white-space: nowrap; }

/* ── Badges ─────────────────────────────────────────────── */
.badge {
  display: inline-block; padding: 3px 9px; border-radius: 20px;
  font-size: 0.74rem; font-weight: 700; letter-spacing: 0.01em;
  background: #f1f3f5; color: var(--muted); white-space: nowrap;
}
.badge.paid { background: var(--ok-bg); color: var(--ok); }
.badge.pending { background: var(--warn-bg); color: var(--warn); }
.badge.processing { background: #eff6ff; color: var(--primary); }
.badge.declined, .badge.failed, .badge.expired,
.badge.cancelled, .badge.voided { background: var(--err-bg); color: var(--err); }

/* ── Alerts ─────────────────────────────────────────────── */
.alert { padding: 13px 16px; border-radius: 10px; font-size: 0.89rem; margin-bottom: 18px; border: 1px solid; }
.alert-ok { background: var(--ok-bg); border-color: #a7f3d0; color: #065f46; }
.alert-warn { background: var(--warn-bg); border-color: #fde68a; color: #92400e; }
.alert-err { background: var(--err-bg); border-color: #fecaca; color: #991b1b; }
.alert strong { display: block; margin-bottom: 3px; }

/* ── Página de pago (público) ───────────────────────────── */
.pay-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 16px; padding: 30px; box-shadow: var(--shadow);
}
.pay-head { text-align: center; margin-bottom: 26px; }
.pay-head img { max-height: 52px; margin-bottom: 12px; }
.pay-head .biz { font-weight: 700; font-size: 1.1rem; }
.pay-amount { text-align: center; padding: 22px 0; border-block: 1px solid var(--border); margin-bottom: 22px; }
.pay-amount .big { font-size: 2.4rem; font-weight: 800; letter-spacing: -0.03em; line-height: 1.1; }
.pay-amount .conv { color: var(--muted); font-size: 0.87rem; margin-top: 7px; }
.detail-row { display: flex; justify-content: space-between; gap: 16px; padding: 9px 0; font-size: 0.92rem; }
.detail-row .k { color: var(--muted); flex-shrink: 0; }
.detail-row .v { font-weight: 600; text-align: right; word-break: break-word; }
.pay-foot { text-align: center; margin-top: 22px; color: var(--muted); font-size: 0.79rem; }

.result-icon { font-size: 3.2rem; text-align: center; line-height: 1; margin-bottom: 14px; }
.spinner {
  width: 34px; height: 34px; margin: 0 auto 14px;
  border: 3px solid var(--border); border-top-color: var(--primary);
  border-radius: 50%; animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Diálogo de confirmación ────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0; z-index: 1000;
  background: rgba(16, 24, 40, 0.55);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.modal-overlay[hidden] { display: none; }
.modal {
  background: var(--surface); border-radius: var(--radius);
  padding: 26px; max-width: 480px; width: 100%;
  box-shadow: 0 20px 60px rgba(16, 24, 40, 0.3);
}
.modal h3 { margin: 0 0 10px; font-size: 1.15rem; letter-spacing: -0.01em; }
.modal-body { color: var(--muted); font-size: 0.92rem; margin-bottom: 18px; }
.modal-body dl { margin: 14px 0 0; display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; }
.modal-body dt { color: var(--muted); font-size: 0.83rem; }
.modal-body dd { margin: 0; font-weight: 600; color: var(--text); font-size: 0.88rem; }
.modal-type { margin-bottom: 18px; }
.modal-type label { display: block; font-size: 0.86rem; margin-bottom: 6px; }
.modal-type[hidden] { display: none; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; }

/* ── Utils ──────────────────────────────────────────────── */
.muted { color: var(--muted); }
.small { font-size: 0.83rem; }
.center { text-align: center; }
.right { text-align: right; }
.flex { display: flex; align-items: center; gap: 10px; }
.between { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.mt { margin-top: 18px; }
.mb { margin-bottom: 18px; }
.copy-box {
  display: flex; gap: 8px; align-items: stretch;
  background: var(--bg); border: 1px solid var(--border);
  border-radius: 9px; padding: 9px 12px;
}
.copy-box code { flex: 1; font-size: 0.83rem; word-break: break-all; align-self: center; }
.section-title {
  font-size: 0.76rem; text-transform: uppercase; letter-spacing: 0.07em;
  font-weight: 700; color: var(--muted); margin: 26px 0 12px;
  padding-bottom: 7px; border-bottom: 1px solid var(--border);
}
.section-title:first-child { margin-top: 0; }
pre.json {
  background: #0f172a; color: #e2e8f0; padding: 14px; border-radius: 9px;
  overflow-x: auto; font-size: 0.78rem; line-height: 1.5;
}
