:root {
  --color-white: #ffffff;
  --color-plaster: #f6f4f8;
  --color-ink: #1a1c22;
  --color-muted: #5e6472;
  --color-line: #e6e2ec;
  --color-primary: #5a3d8a;
  --color-primary-soft: #ede8f5;
  --color-warning: #b45309;
  --color-warning-soft: #f8ebd8;
  --color-success: #0f7a4a;
  --color-success-soft: #d8f0e4;
  --color-info: #2f4d8a;
  --color-info-soft: #e0e7f5;
  --color-night: #141318;
  --color-night-surface: #1e1c24;
  --color-night-muted: #a8a3b3;
  --color-night-line: #2e2b36;
  --font-sans: "Source Sans 3", system-ui, sans-serif;
  --font-serif: "Source Serif 4", Georgia, serif;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-pill: 999px;
  --bg: var(--color-plaster);
  --surface: var(--color-white);
  --text: var(--color-ink);
  --text-muted: var(--color-muted);
  --stroke: var(--color-line);
}

[data-theme="dark"] {
  --bg: var(--color-night);
  --surface: var(--color-night-surface);
  --text: var(--color-white);
  --text-muted: var(--color-night-muted);
  --stroke: var(--color-night-line);
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  font-size: 16px;
  line-height: 24px;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}
a { color: var(--color-primary); text-decoration: none; }
button, input, textarea, select { font: inherit; color: inherit; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 20px 48px;
  background: var(--surface);
  border-bottom: 1px solid var(--stroke);
}
.brand { display: flex; align-items: baseline; gap: 12px; }
.brand-title {
  font-family: var(--font-serif);
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 28px;
  color: var(--text);
}
.brand-sub { font-size: 14px; color: var(--text-muted); line-height: 20px; }
.top-actions { display: flex; align-items: center; gap: 16px; flex-shrink: 0; }

.saldo-chip {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 10px 16px;
  background: var(--bg);
  border-radius: var(--radius-md);
}
.saldo-chip .label {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
  line-height: 16px;
}
.saldo-chip .value {
  font-family: var(--font-serif);
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 22px;
}
.saldo-chip .divider { width: 1px; height: 32px; background: var(--stroke); flex-shrink: 0; }

.icon-btn {
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: var(--radius-pill);
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text);
}
.user { display: flex; align-items: center; gap: 10px; }
.avatar {
  width: 32px; height: 32px; border-radius: 999px;
  background: var(--color-primary); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700; flex-shrink: 0;
}

.page { max-width: 1120px; margin: 0 auto; padding: 36px 48px 48px; width: 100%; flex: 1; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 28px; }
.page-head h1 {
  font-family: var(--font-serif);
  font-size: 32px;
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 38px;
  margin: 0 0 8px;
}
.page-head p { margin: 0; color: var(--text-muted); }
.page-head-actions { display: flex; gap: 10px; flex-shrink: 0; flex-wrap: wrap; }

.btn {
  display: inline-flex; align-items: center; justify-content: center;
  height: 44px; padding: 0 20px; border-radius: var(--radius-pill);
  border: 0; cursor: pointer; font-weight: 600; font-size: 15px;
}
.btn-primary { background: var(--color-primary); color: #fff; }
.btn-ghost { background: transparent; color: var(--text-muted); }
.btn-danger { background: var(--color-warning-soft); color: var(--color-warning); }

.tabs {
  display: flex; width: fit-content; gap: 4px; padding: 4px;
  background: var(--surface); border-radius: var(--radius-pill); margin-bottom: 28px;
}
.tabs a {
  display: flex; align-items: center; height: 36px; padding: 0 16px;
  border-radius: var(--radius-pill); color: var(--text-muted); font-weight: 500; font-size: 14px;
}
.tabs a.active { background: var(--text); color: var(--bg); font-weight: 600; }
[data-theme="dark"] .tabs a.active { background: #fff; color: var(--color-ink); }

.list { background: var(--surface); border-radius: var(--radius-md); overflow: hidden; }
.row, .list-head {
  display: flex; align-items: center; padding: 18px 24px;
  border-bottom: 1px solid var(--stroke); color: inherit;
}
.list-head { padding: 14px 24px; }
.list-head span {
  font-size: 12px; font-weight: 600; letter-spacing: 0.06em;
  text-transform: uppercase; color: var(--text-muted);
}
.col-date { width: 110px; flex-shrink: 0; color: var(--text-muted); font-size: 14px; font-weight: 500; }
.col-desc { flex: 1; min-width: 0; padding-right: 16px; }
.col-desc strong { display: block; font-size: 16px; line-height: 22px; }
.col-desc small { color: var(--text-muted); font-size: 14px; }
.col-when { width: 140px; flex-shrink: 0; font-size: 14px; font-weight: 500; }
.col-valor {
  width: 140px; flex-shrink: 0; text-align: right; padding-right: 16px;
  font-family: var(--font-serif); font-size: 18px; font-weight: 600; letter-spacing: -0.02em;
}
.col-estado { width: 160px; flex-shrink: 0; }
.col-go { width: 28px; flex-shrink: 0; color: var(--text-muted); text-align: right; }
.row:last-child { border-bottom: 0; }
.row:hover { background: color-mix(in srgb, var(--bg) 60%, transparent); }

.badge {
  display: inline-flex; align-items: center; height: 26px; padding: 0 10px;
  border-radius: var(--radius-pill); font-size: 12px; font-weight: 600;
}
.badge-warning { background: var(--color-warning-soft); color: var(--color-warning); }
.badge-info { background: var(--color-info-soft); color: var(--color-info); }
.badge-primary { background: var(--color-primary-soft); color: var(--color-primary); }
.badge-success { background: var(--color-success-soft); color: var(--color-success); }

.cards { display: none; }
.card {
  background: var(--surface); border-radius: var(--radius-md); padding: 16px; margin-bottom: 10px;
}
.card-top { display: flex; justify-content: space-between; gap: 12px; }
.card .amount { font-family: var(--font-serif); font-size: 22px; font-weight: 600; letter-spacing: -0.02em; margin-top: 10px; }

.form-card, .panel {
  background: var(--surface); border-radius: var(--radius-md); padding: 32px;
  max-width: 560px;
}
.section-title {
  font-size: 12px; font-weight: 600; letter-spacing: 0.06em;
  text-transform: uppercase; color: var(--text-muted);
}
.choice-grid { display: flex; flex-direction: column; gap: 10px; }
.choice-card {
  display: flex; gap: 12px; align-items: flex-start;
  padding: 14px 16px; border: 1px solid var(--stroke); border-radius: var(--radius-sm);
  background: var(--bg); cursor: pointer;
}
.choice-card:has(input:checked) {
  border-color: var(--color-primary);
  background: var(--color-primary-soft);
}
.choice-card input { margin-top: 4px; }
.choice-card strong { display: block; font-weight: 600; color: var(--text); }
.choice-card small { display: block; color: var(--text-muted); font-size: 14px; line-height: 20px; margin-top: 2px; }
.help-text {
  font-size: 14px; line-height: 22px; color: var(--text-muted);
  margin: 0 0 16px;
}
.help-text ul { margin: 0; padding-left: 18px; }
.help-text li { margin-bottom: 6px; }
.help-text li:last-child { margin-bottom: 0; }
.creds-box {
  background: var(--bg); border-radius: var(--radius-sm); padding: 16px; margin-bottom: 16px;
}
.btn-inline {
  border: 0; background: transparent; color: var(--color-primary);
  font-size: 13px; font-weight: 600; cursor: pointer; padding: 0 4px;
}
.form-grid { display: flex; gap: 12px; }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; flex: 1; }
.field label {
  font-size: 12px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-muted);
}
.field input, .field textarea, .field select {
  background: var(--bg); border: 1px solid var(--stroke); border-radius: var(--radius-sm);
  padding: 12px 14px; min-height: 48px; width: 100%;
}
.field ul { list-style: none; padding: 0; margin: 0; }
.field li { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.field input[type="radio"], .field input[type="file"], .field input[type="checkbox"] {
  width: auto; min-height: 0;
}
.errorlist { color: var(--color-warning); font-size: 14px; padding-left: 18px; }
.actions { display: flex; justify-content: flex-end; gap: 10px; flex-wrap: wrap; }

.detail-grid { display: flex; gap: 24px; align-items: flex-start; flex-wrap: wrap; }
.card-virtual {
  flex: 1; min-width: 280px;
  background: var(--color-ink); color: #fff; border-radius: var(--radius-md); padding: 24px;
}
[data-theme="dark"] .card-virtual { background: #000; }
.card-virtual .kicker {
  font-size: 12px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--color-night-muted);
}
.pan { font-family: var(--font-serif); font-size: 22px; letter-spacing: 0.08em; margin: 16px 0; }
.card-meta { display: flex; gap: 24px; margin-bottom: 16px; }
.copy-row { display: flex; gap: 8px; flex-wrap: wrap; }
.copy-row button {
  height: 32px; padding: 0 12px; border: 0; border-radius: var(--radius-pill);
  background: rgba(255,255,255,0.12); color: #fff; cursor: pointer; font-size: 12px; font-weight: 600;
}
.upload-panel { flex: 1; min-width: 280px; background: var(--surface); border-radius: var(--radius-md); padding: 24px; }
.drop {
  display: flex; align-items: center; justify-content: center; min-height: 120px;
  border: 1px dashed var(--stroke); border-radius: var(--radius-sm); background: var(--bg);
  color: var(--color-primary); font-weight: 600;
}

.messages { list-style: none; padding: 0 48px; margin: 16px auto 0; max-width: 1120px; }
.messages li { padding: 12px 16px; border-radius: var(--radius-sm); background: var(--color-primary-soft); color: var(--color-primary); margin-bottom: 8px; }
.messages .warning { background: var(--color-warning-soft); color: var(--color-warning); }
.messages .error { background: var(--color-warning-soft); color: var(--color-warning); }

.login-wrap { min-height: 0; flex: 1; display: flex; align-items: center; justify-content: center; padding: 24px; }
.help-block { background: var(--surface); border-radius: var(--radius-md); padding: 32px; max-width: 640px; }
.help-block address { font-style: normal; line-height: 28px; margin: 16px 0; }
.setup-steps { padding-left: 20px; margin: 0 0 16px; }
.setup-steps li { margin-bottom: 10px; }
.qr-wrap {
  background: #fff; padding: 16px; border-radius: var(--radius-md);
  width: fit-content; margin: 0 auto 8px;
}
.qr-wrap img { display: block; width: 220px; height: 220px; }
.secret-key {
  font-family: ui-monospace, monospace; letter-spacing: 0.08em;
  background: var(--bg); padding: 10px 12px; border-radius: var(--radius-sm);
  word-break: break-all;
}
.backup-codes {
  list-style: none; padding: 0; margin: 0 0 24px;
  font-family: ui-monospace, monospace; font-size: 16px;
  columns: 2; gap: 16px;
}
.backup-codes li { margin-bottom: 8px; }
.otp-wide input[name="otp_token"],
.otp-wide input[name="token"] {
  font-size: 22px; letter-spacing: 0.24em; text-align: center;
}

.bottom-nav { display: none; }
.empty { padding: 48px 24px; color: var(--text-muted); text-align: center; }
.site-footer {
  text-align: center;
  padding: 16px 24px 24px;
  color: var(--text-muted);
  font-size: 13px;
  line-height: 20px;
}
.site-footer a {
  color: var(--text-muted);
  text-decoration: underline;
  text-underline-offset: 3px;
}
.site-footer a:hover { color: var(--color-primary); }

@media (max-width: 800px) {
  .topbar { padding: 12px 20px; }
  .brand-sub, .top-actions .user span, .list-head, .col-date, .col-when, .col-go { display: none; }
  .page { padding: 20px 20px 24px; }
  .page-head h1 { font-size: 26px; }
  .saldo-chip { gap: 12px; padding: 8px 12px; }
  .saldo-chip .divider { display: none; }
  .tabs { display: none; }
  .list { background: transparent; }
  .row { display: none; }
  .cards { display: block; }
  .bottom-nav {
    display: flex; position: fixed; left: 0; right: 0; bottom: 0;
    justify-content: space-around; padding: 10px 8px 24px;
    background: var(--surface); border-top: 1px solid var(--stroke);
  }
  .bottom-nav a { color: var(--text-muted); font-size: 14px; font-weight: 500; }
  .bottom-nav a.active { color: var(--text); font-weight: 700; }
  .form-grid { flex-direction: column; }
  .site-footer { padding: 12px 20px 88px; }
  .login-wrap + .site-footer { padding-bottom: 24px; }
}
