:root {
  --bg: #f8fafc;
  --surface: #ffffff;
  --surface-muted: #f1f5f9;
  --border: #e2e8f0;
  --text: #0f172a;
  --text-muted: #475569;
  --primary: #1d4ed8;
  --primary-hover: #1e40af;
  --primary-soft: #eff6ff;
  --danger: #dc2626;
  --danger-bg: #fef2f2;
  --danger-border: #fecaca;
  --warn: #b45309;
  --warn-bg: #fffbeb;
  --warn-border: #fcd34d;
  --ok: #15803d;
  --ok-bg: #f0fdf4;
  --ok-border: #bbf7d0;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b1120;
    --surface: #111827;
    --surface-muted: #1e293b;
    --border: #334155;
    --text: #f8fafc;
    --text-muted: #94a3b8;
    --primary: #3b82f6;
    --primary-hover: #2563eb;
    --primary-soft: #172554;
    --danger: #f87171;
    --danger-bg: #450a0a;
    --danger-border: #991b1b;
    --warn: #fbbf24;
    --warn-bg: #451a03;
    --warn-border: #92400e;
    --ok: #4ade80;
    --ok-bg: #052e16;
    --ok-border: #166534;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  font-family: 'DM Sans', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

.mono {
  font-family: 'DM Mono', ui-monospace, SFMono-Regular, monospace;
  font-variant-numeric: tabular-nums;
}

.af-header {
  background: #1d4ed8;
  color: #ffffff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
}

.af-header-inner {
  max-width: 672px;
  margin: 0 auto;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.af-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 1rem;
  color: #ffffff;
  text-decoration: none;
}

.af-nav {
  display: flex;
  align-items: center;
  gap: 14px;
  font-size: 0.875rem;
}

.af-nav a {
  color: #dbeafe;
  text-decoration: none;
  transition: color 180ms ease;
}

.af-nav a:hover { color: #ffffff; }

.af-main {
  flex: 1;
  width: 100%;
  max-width: 672px;
  margin: 0 auto;
  padding: 28px 16px;
}

.af-main-center {
  display: flex;
  align-items: center;
  justify-content: center;
}

.af-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 24px;
  box-shadow: 0 4px 16px rgba(15, 23, 42, 0.06);
  margin-bottom: 18px;
  width: 100%;
}

.af-card-narrow { max-width: 440px; }

.af-title {
  margin: 0 0 6px;
  font-size: 1.375rem;
  font-weight: 700;
}

.af-subtitle {
  margin: 0 0 20px;
  font-size: 0.875rem;
  color: var(--text-muted);
}

.af-field { margin-bottom: 16px; }

.af-label {
  display: block;
  font-size: 0.875rem;
  font-weight: 600;
  margin-bottom: 6px;
}

.af-input {
  width: 100%;
  min-height: 48px;
  padding: 12px 14px;
  font-size: 1rem;
  font-family: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  transition: border-color 180ms ease, box-shadow 180ms ease;
}

.af-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.25);
}

.af-help {
  margin: 6px 0 0;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.af-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 48px;
  padding: 12px 18px;
  border-radius: 12px;
  font-size: 0.9375rem;
  font-weight: 600;
  font-family: inherit;
  text-decoration: none;
  border: 1px solid transparent;
  cursor: pointer;
  transition: background-color 180ms ease, border-color 180ms ease;
}

.af-btn-primary {
  background: var(--primary);
  color: #ffffff;
}

.af-btn-primary:hover { background: var(--primary-hover); }

.af-btn-secondary {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border);
}

.af-btn-secondary:hover { background: var(--surface-muted); }

.af-alert {
  border-radius: 12px;
  padding: 14px 16px;
  font-size: 0.875rem;
  margin-bottom: 16px;
  border: 1px solid transparent;
}

.af-alert-danger {
  background: var(--danger-bg);
  border-color: var(--danger-border);
  color: var(--danger);
}

.af-alert-warn {
  background: var(--warn-bg);
  border-color: var(--warn-border);
  color: var(--warn);
}

.af-alert-ok {
  background: var(--ok-bg);
  border-color: var(--ok-border);
  color: var(--ok);
}

.af-grid-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}

.af-stat {
  background: var(--surface-muted);
  border-radius: 12px;
  padding: 12px;
}

.af-stat-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin: 0 0 2px;
}

.af-stat-val {
  font-size: 0.9375rem;
  font-weight: 600;
  margin: 0;
  word-break: break-word;
}

.af-balance-box {
  background: var(--primary-soft);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.af-balance-amt {
  font-size: 1.5rem;
  font-weight: 700;
  margin: 0;
}

.af-qr-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 16px;
  background: #ffffff;
  border-radius: 14px;
  border: 1px solid var(--border);
  margin: 16px 0;
}

.af-qr-wrap svg {
  max-width: 240px;
  height: auto;
}

.af-footer {
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 14px 16px;
  text-align: center;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.af-footer a { color: inherit; }

@media (max-width: 480px) {
  .af-grid-2 { grid-template-columns: 1fr; }
}
