:root {
  --bg: #f4f5f7;
  --card: #fff;
  --text: #1a1d21;
  --muted: #6b7280;
  --border: #e3e5e8;
  --accent: #006aff; /* Square blue */
  --ok: #0e8a4f;
  --warn: #b45309;
  --err: #c0262d;
  --radius: 10px;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
}
.wrap { max-width: 980px; margin: 0 auto; padding: 32px 16px; }
.narrow { max-width: 480px; }
h1 { font-size: 22px; margin: 0 0 4px; }
h2 { font-size: 16px; margin: 0 0 12px; }
.sub { color: var(--muted); margin: 0 0 24px; }
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 20px;
}
label { display: block; font-weight: 600; font-size: 13px; margin: 12px 0 4px; }
input, select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font: inherit;
  background: #fff;
}
input:focus, select:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.row { display: flex; gap: 12px; }
.row > * { flex: 1; }
button {
  background: var(--accent);
  color: #fff;
  border: 0;
  border-radius: 6px;
  padding: 10px 16px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}
button:disabled { opacity: 0.5; cursor: not-allowed; }
button.ghost { background: transparent; color: var(--accent); border: 1px solid var(--border); }
button.small { padding: 5px 10px; font-size: 13px; }
.full { width: 100%; margin-top: 16px; padding: 14px; font-size: 16px; }
.plan-row { display: flex; gap: 8px; align-items: end; margin-top: 8px; }
.plan-row > :first-child { flex: 0 0 110px; }
.plan-row > :nth-child(2) { flex: 1; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; }
.badge { display: inline-block; padding: 2px 8px; border-radius: 99px; font-size: 12px; font-weight: 600; background: #eef; }
.badge.open { background: #e8f0ff; color: var(--accent); }
.badge.paid { background: #e3f6ec; color: var(--ok); }
.badge.in_plan { background: #fff4e0; color: var(--warn); }
.badge.failed { background: #fde8e8; color: var(--err); }
.muted { color: var(--muted); }
.link-box { display: flex; gap: 8px; margin-top: 12px; }
.link-box input { font-family: ui-monospace, monospace; font-size: 13px; }
.option {
  display: flex; gap: 12px; align-items: flex-start;
  border: 1px solid var(--border); border-radius: 8px;
  padding: 14px; margin-bottom: 10px; cursor: pointer;
}
.option:has(input:checked) { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.option input { width: auto; margin-top: 3px; }
.option .title { font-weight: 600; }
.amount-big { font-size: 34px; font-weight: 700; margin: 4px 0; }
.msg { margin-top: 12px; padding: 10px 12px; border-radius: 6px; display: none; }
.msg.err { display: block; background: #fde8e8; color: var(--err); }
.msg.ok { display: block; background: #e3f6ec; color: var(--ok); }
.schedule { margin: 8px 0 0; padding: 0; list-style: none; font-size: 13px; }
.schedule li { display: flex; justify-content: space-between; padding: 2px 0; }
#card-container { min-height: 90px; margin-top: 8px; }
.secure { text-align: center; color: var(--muted); font-size: 12px; margin-top: 12px; }
@media (max-width: 640px) { .row { flex-direction: column; gap: 0; } }

/* Digital wallets */
#apple-pay-button {
  -webkit-appearance: -apple-pay-button;
  -apple-pay-button-type: pay;
  -apple-pay-button-style: black;
  height: 48px; width: 100%; margin-bottom: 10px; cursor: pointer; border-radius: 6px;
}
#google-pay-button { height: 48px; width: 100%; margin-bottom: 10px; }
.divider { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 13px; margin: 18px 0 6px; }
.divider::before, .divider::after { content: ""; flex: 1; border-top: 1px solid var(--border); }

/* Admin navigation */
.topnav { background: var(--card); border-bottom: 1px solid var(--border); }
.topnav-inner { max-width: 980px; margin: 0 auto; padding: 0 16px; display: flex; align-items: center; gap: 24px; min-height: 56px; flex-wrap: wrap; }
.brand { font-weight: 700; color: var(--text); text-decoration: none; }
.brand span { color: var(--muted); font-weight: 500; font-size: 13px; }
.topnav nav { display: flex; gap: 4px; flex-wrap: wrap; }
.topnav nav a { color: var(--muted); text-decoration: none; padding: 8px 12px; border-radius: 6px; font-weight: 500; }
.topnav nav a:hover { background: var(--bg); color: var(--text); }
.topnav nav a[aria-current="page"] { color: var(--accent); background: #e8f0ff; }

.table-card { overflow-x: auto; }
table.rules input, table.rules select { padding: 7px 9px; min-width: 90px; }
table.rules td { vertical-align: middle; }
.check { display: flex; align-items: center; gap: 8px; font-weight: 500; margin: 12px 0 4px; }
.check input { width: auto; }
.inline { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }

/* Cancel / refund */
.badge.canceled { background: #eceef1; color: var(--muted); }
.badge.scheduled { background: #e8f0ff; color: var(--accent); }
.badge.refunded { background: #f3e8ff; color: #7e22ce; }
.actions { display: flex; flex-direction: column; gap: 6px; align-items: stretch; }
button.danger { color: var(--err); }
button.linkish { background: none; border: 0; padding: 0 0 0 6px; color: var(--accent); font-size: 12px; font-weight: 600; }
.badge.waived { background: #fef3c7; color: #92400e; }
.badge.credited { background: #e0f2fe; color: #0369a1; }
dialog { border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; width: min(520px, calc(100vw - 32px)); }
dialog::backdrop { background: rgb(0 0 0 / 0.35); }
.preview { margin-top: 14px; padding: 10px 12px; background: var(--bg); border-radius: 6px; font-size: 13px; }
.preview ul { margin: 0; padding-left: 18px; }

/* Payment link cards */
.link-card { padding: 18px 20px; }
.lc-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; }
.lc-title > div:first-child { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 16px; }
.lc-amount { font-size: 20px; font-weight: 700; white-space: nowrap; }
.small-text { font-size: 13px; margin-top: 2px; }
.lc-stats { display: flex; flex-wrap: wrap; gap: 8px 28px; margin: 14px 0 6px; font-weight: 600; font-variant-numeric: tabular-nums; }
.lc-stats span { display: block; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.03em; color: var(--muted); }
.lc-body { margin-top: 12px; overflow-x: auto; }
.lc-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--border); }
table.sched { font-size: 14px; font-variant-numeric: tabular-nums; }
table.sched th, table.sched td { padding: 7px 10px 7px 0; white-space: nowrap; vertical-align: middle; }
table.sched th:first-child, table.sched td:first-child { width: 28px; }
table.sched td.note { white-space: normal; width: 100%; font-size: 13px; }
table.sched .num { text-align: right; }
table.sched td.line-action { text-align: right; padding-right: 0; }
table.sched td.line-action .linkish + .linkish { margin-left: 10px; }
table.sched tr:last-child td { border-bottom: 0; }
.credits { list-style: none; margin: 10px 0 0; padding: 10px 0 0; border-top: 1px dashed var(--border); font-size: 13px; color: var(--muted); }
.credits li { display: flex; justify-content: space-between; gap: 16px; padding: 2px 0; }
.credits .num { white-space: nowrap; font-variant-numeric: tabular-nums; }
button.linkish { padding: 0; }
@media (max-width: 640px) {
  .lc-head { flex-direction: column; gap: 4px; }
  table.sched td.note { display: none; }
  table.sched th:nth-child(5) { display: none; }
  table.sched th, table.sched td { padding-right: 8px; }
  table.sched td.num s { display: block; font-size: 12px; }
  .lc-stats { gap: 8px 20px; }
}

/* Data page */
.tabs { display: flex; gap: 4px; flex-wrap: wrap; margin-bottom: 16px; border-bottom: 1px solid var(--border); }
.tabs button { background: none; color: var(--muted); border-radius: 0; padding: 8px 12px; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs button[aria-selected="true"] { color: var(--accent); border-bottom-color: var(--accent); }
.sub-tabs { margin-bottom: 0; border-bottom: 0; }
.sub-tabs button { border: 1px solid var(--border); border-radius: 99px; padding: 5px 12px; font-size: 13px; margin: 0; }
.sub-tabs button[aria-selected="true"] { background: #e8f0ff; border-color: var(--accent); }
.count { color: var(--muted); font-weight: 500; margin-left: 2px; }
.tab-panel[hidden] { display: none; }
code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; background: var(--bg); padding: 1px 5px; border-radius: 4px; }
ul.plain { margin: 0; padding-left: 18px; }
table.schema td.type { font-family: ui-monospace, Menlo, monospace; font-size: 12px; color: var(--warn); white-space: nowrap; }
table.schema td:first-child { white-space: nowrap; }
table.data { font-size: 13px; font-variant-numeric: tabular-nums; }
table.data td, table.data th { white-space: nowrap; padding-right: 14px; }
table.data .num { text-align: right; }
pre.json { margin: 0; max-height: 70vh; overflow: auto; font: 12px/1.5 ui-monospace, Menlo, monospace; white-space: pre; }
.er { overflow-x: auto; text-align: center; min-height: 120px; }
.er svg { max-width: 100%; height: auto; }
.key { font-size: 10px; font-weight: 700; padding: 1px 5px; border-radius: 4px; vertical-align: 1px; }
.key.pk { background: #fef3c7; color: #92400e; }
.key.fk { background: #e0f2fe; color: #0369a1; }
