:root {
  --bg: #0d1117; --surface: #141a22; --surface2: #1a222d; --line: #243040;
  --text: #e2e8f0; --muted: #8593a6; --accent: #7aa2f7; --accent-ink: #0b1220;
  --ok: #4ade9a; --warn: #f2c14e; --bad: #f47174;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
  --sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Inter, Roboto, "Helvetica Neue", Arial, sans-serif;
}
* { box-sizing: border-box; }
html { color-scheme: dark; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.55 var(--sans); -webkit-font-smoothing: antialiased; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 22px; font-weight: 600; margin: 28px 0 18px; letter-spacing: -.01em; }
h2 { font-size: 15px; font-weight: 600; margin: 0 0 14px; color: var(--text); }
p { margin: 0 0 12px; }
.wrap { max-width: 1080px; margin: 0 auto; padding: 0 20px; }
.muted { color: var(--muted); }
.mono { font-family: var(--mono); }
.right { text-align: right; }
.num { font-variant-numeric: tabular-nums; }

.topbar { border-bottom: 1px solid var(--line); background: var(--bg); position: sticky; top: 0; z-index: 5; }
.bar { display: flex; align-items: center; gap: 24px; height: 56px; }
.brand { color: var(--text); font-weight: 650; letter-spacing: -.01em; }
.brand:hover { text-decoration: none; }
.nav { display: flex; gap: 4px; flex: 1; overflow-x: auto; }
.nav a { color: var(--muted); padding: 6px 12px; border-radius: 8px; white-space: nowrap; }
.nav a:hover { color: var(--text); text-decoration: none; background: var(--surface); }
.nav a.on { color: var(--text); background: var(--surface2); }
main { padding-bottom: 64px; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 20px; }
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.section { margin-top: 24px; }
@media (max-width: 800px) { .g2, .g3, .g4 { grid-template-columns: 1fr; } .bar { gap: 10px; } }

.balance { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; padding: 28px; }
.balance .label { color: var(--muted); font-size: 14px; }
.balance .amount { font-size: 48px; line-height: 1.05; font-weight: 600; letter-spacing: -.03em; font-variant-numeric: tabular-nums; }
.balance .amount small { font-size: 20px; color: var(--muted); font-weight: 500; margin-left: 6px; letter-spacing: 0; }

.kv { display: grid; grid-template-columns: 1fr auto; gap: 9px 16px; margin: 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; }
.kv dd.big { font-weight: 600; }
.pos { color: var(--ok); } .neg { color: var(--bad); }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { color: var(--muted); font-weight: 500; font-size: 13px; white-space: nowrap; }
tbody tr:last-child td { border-bottom: 0; }
td.right, th.right { text-align: right; }
.table-wrap { overflow-x: auto; }
.card.flush { padding: 0; }
.card.flush h2 { padding: 18px 20px 0; }
.card.flush th:first-child, .card.flush td:first-child { padding-left: 20px; }
.card.flush th:last-child, .card.flush td:last-child { padding-right: 20px; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 1px solid var(--line);
  background: var(--surface2); color: var(--text); padding: 9px 16px; border-radius: 8px; font: inherit; cursor: pointer; }
.btn:hover { border-color: #33445a; text-decoration: none; }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--bad); }
.btn.sm { padding: 5px 11px; font-size: 13px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

input, select { background: var(--bg); color: var(--text); border: 1px solid var(--line); border-radius: 8px;
  padding: 9px 12px; font: inherit; min-width: 0; }
input:focus, select:focus { outline: none; border-color: var(--accent); }
input.sm { padding: 5px 9px; font-size: 13px; }
label.field { display: flex; flex-direction: column; gap: 6px; color: var(--muted); font-size: 13px; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; }
.row.center { align-items: center; }
form.inline { display: inline; }

.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; border: 1px solid var(--line); color: var(--muted); }
.badge.success, .badge.paid, .badge.credited { color: var(--ok); border-color: #1f5a41; }
.badge.canceled, .badge.expired, .badge.failed, .badge.unmatched { color: var(--bad); border-color: #5c2a2c; }
.badge.waiting, .badge.pending, .badge.buying, .badge.canceling { color: var(--warn); border-color: #5c4a1c; }

.alert { border: 1px solid var(--line); background: var(--surface); border-radius: 10px; padding: 12px 16px; margin-bottom: 16px; }
.alert.err { border-color: #5c2a2c; color: #ffb3b5; }
.alert.ok { border-color: #1f5a41; color: #a7f0cb; }
.alert.warn { border-color: #5c4a1c; color: #f6dc9a; }

.copy { display: flex; align-items: center; gap: 10px; background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 8px 8px 8px 12px; }
.copy code { font-family: var(--mono); font-size: 14px; overflow-wrap: anywhere; flex: 1; }
.key-box code { color: var(--ok); }

.login { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login .card { width: 100%; max-width: 400px; padding: 28px; }
.login h1 { margin: 0 0 6px; }
.login form { display: grid; gap: 12px; margin-top: 18px; }

.invoice { display: grid; grid-template-columns: 180px 1fr; gap: 24px; align-items: start; }
.invoice img { width: 180px; height: 180px; border-radius: 8px; background: #fff; }
.invoice .sum { font-size: 34px; font-weight: 600; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
@media (max-width: 640px) { .invoice { grid-template-columns: 1fr; } }

pre { background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 14px 16px; overflow-x: auto;
  font: 13px/1.6 var(--mono); margin: 10px 0 18px; }
code.i { font-family: var(--mono); font-size: 13px; background: var(--surface2); padding: 1px 6px; border-radius: 5px; }
.doc h2 { margin-top: 28px; font-size: 17px; }
.doc h3 { margin: 22px 0 6px; font-size: 14px; }
.method { font-family: var(--mono); font-size: 13px; color: var(--accent); }
@media (prefers-reduced-motion: no-preference) { .btn { transition: border-color .15s, filter .15s; } }
.mb8 { margin-bottom: 8px; } .mb16 { margin-bottom: 16px; } .mb20 { margin-bottom: 20px; }
.mt16 { margin-top: 16px; } .grow { flex: 1; min-width: 160px; }
.w-xs { width: 84px; } .w-sm { width: 110px; } .w-md { width: 180px; }
.hint { font-size: 13px; color: var(--muted); }
.amount-sm { font-size: 26px; font-weight: 600; letter-spacing: -.02em; font-variant-numeric: tabular-nums; margin-top: 4px; }
