/* Brand light — see spec §5.6 */
:root {
  --bg: #eef2f6; --card: #ffffff; --line: #dfe5ec; --text: #1c2b3a; --muted: #5b6675;
  --primary: #30546F; --primary-ink: #ffffff; --success: #1e7b34; --danger: #b3261e;
  --chip-off: #ffffff; --seg-bg: #e3e8ee; --disabled: #b9c3cf; --logo-tile: transparent;
  --radius: 12px; --radius-lg: 14px; --tap: 44px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1720; --card: #1a2532; --line: #263445; --text: #f2f5f8; --muted: #9aa7b6;
    --primary: #4796de; --primary-ink: #0b1220; --chip-off: #1a2532; --seg-bg: #263445;
    --disabled: #3a4a5c; --logo-tile: #ffffff;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg); color: var(--text);
  font: 16px/1.35 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-text-size-adjust: 100%;
}
button, input { font: inherit; color: inherit; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
[hidden] { display: none !important; }

.app {
  max-width: 440px; margin: 0 auto; min-height: 100%;
  min-height: 100dvh;
  padding: max(12px, env(safe-area-inset-top)) 14px max(14px, env(safe-area-inset-bottom));
  display: flex; flex-direction: column; gap: 10px;
}

/* Header */
.logo { display: block; width: 100%; height: auto; max-height: 64px; object-fit: contain; object-position: left center;
  background: var(--logo-tile); border-radius: var(--radius); padding: 0; }
@media (prefers-color-scheme: dark) { .logo { padding: 6px 10px; } }
.header-row { display: flex; justify-content: space-between; align-items: center; margin-top: 2px; }
.kicker { font-size: 12px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); }
.pill { border: 0; border-radius: 999px; padding: 6px 10px; font-size: 12px; font-weight: 600; min-height: 32px; cursor: default; }
.pill::before { content: ""; display: inline-block; width: 7px; height: 7px; border-radius: 50%; margin-right: 6px; background: currentColor; vertical-align: 1px; }
.pill--ok { background: #e3f2e7; color: var(--success); }
.pill--off { background: #fbe9e7; color: var(--danger); cursor: pointer; }
.pill--wait { background: var(--seg-bg); color: var(--muted); }
.pill--busy { background: #fff4e0; color: #8a5a00; }

/* Cards & form */
.form { display: flex; flex-direction: column; gap: 10px; flex: 1; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); }
.amount-card { padding: 12px 14px; }
.amount-card:focus-within { border-color: var(--primary); }
.lbl { display: block; font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.amount { font-size: 40px; font-weight: 700; letter-spacing: -.02em; line-height: 1.1; }
.amount .cur, .amount .cents { font-size: 22px; vertical-align: top; color: var(--muted); }
.custom-wrap { display: flex; align-items: baseline; gap: 4px; }
.custom-wrap .cur { font-size: 22px; color: var(--muted); }
#custom-input { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; padding: 0;
  font-size: 40px; font-weight: 700; letter-spacing: -.02em; line-height: 1.1; }
.field-error { margin: 6px 0 0; font-size: 12px; color: var(--danger); }

.chips { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; margin: 0; padding: 0; border: 0; }
.chip { position: relative; display: block; }
.chip input { position: absolute; opacity: 0; inset: 0; margin: 0; }
.chip span { display: flex; align-items: center; justify-content: center; min-height: var(--tap);
  border: 1px solid var(--line); border-radius: 10px; background: var(--chip-off); font-size: 14px; font-weight: 600; }
.chip input:checked + span { background: var(--primary); color: var(--primary-ink); border-color: var(--primary); }
.chip input:focus-visible + span { outline: 2px solid var(--primary); outline-offset: 2px; }

.row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 14px; min-height: 56px; cursor: pointer; }
.row-text { display: flex; flex-direction: column; }
.row-title { font-size: 15px; font-weight: 600; }
.row-sub { font-size: 12px; color: var(--muted); }
.switch { appearance: none; -webkit-appearance: none; width: 44px; height: 26px; border-radius: 999px; background: var(--disabled);
  position: relative; margin: 0; flex: none; cursor: pointer; transition: background .15s; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; transition: left .15s; }
.switch:checked { background: var(--primary); }
.switch:checked::after { left: 21px; }
.switch:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

.seg { display: flex; margin: 0; padding: 3px; border: 0; border-radius: 10px; background: var(--seg-bg); }
.seg label { flex: 1; position: relative; }
.seg input { position: absolute; opacity: 0; inset: 0; margin: 0; }
.seg span { display: flex; align-items: center; justify-content: center; min-height: 38px; border-radius: 8px; font-size: 14px; }
.seg input:checked + span { background: var(--card); font-weight: 600; box-shadow: 0 1px 2px rgba(0,0,0,.08); }
.seg input:focus-visible + span { outline: 2px solid var(--primary); }

.field { display: flex; flex-direction: column; gap: 6px; }
.input { width: 100%; min-height: 48px; padding: 10px 14px; border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--card); font-size: 16px; outline: 0; }
.input:focus { border-color: var(--primary); }
.input[aria-invalid="true"] { border-color: var(--danger); }
.help { margin: 0 4px; font-size: 12px; color: var(--muted); }

.notice { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 12px;
  border-radius: var(--radius); font-size: 14px; }
.notice--busy { background: #fff4e0; color: #5b3d00; border: 1px solid #f3d9a4; }
.notice--lost { background: #fbe9e7; color: var(--danger); border: 1px solid #f2c4bf; }

/* Buttons */
.btn { min-height: 52px; padding: 0 18px; border-radius: var(--radius-lg); border: 1px solid transparent; font-size: 16px; font-weight: 700; cursor: pointer; }
.btn--primary { background: var(--primary); color: var(--primary-ink); width: 100%; }
.btn--primary:disabled { background: var(--disabled); color: #fff; cursor: not-allowed; }
.btn--ghost { background: transparent; color: var(--primary); border-color: var(--line); width: 100%; }
.btn--sm { min-height: 36px; width: auto; padding: 0 12px; font-size: 13px; white-space: nowrap; }
.btn:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.cta { margin-top: auto; display: flex; flex-direction: column; gap: 8px; }
.fine { margin: 0; text-align: center; font-size: 12px; color: var(--muted); }
.fine--warn { color: var(--danger); }

/* Status view */
.status { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: 10px; padding: 12px 0; }
.status-icon { width: 72px; height: 72px; border-radius: 50%; display: grid; place-items: center; font-size: 36px; color: #fff; }
.status-icon--spin { border: 6px solid var(--line); border-top-color: var(--primary); animation: spin .9s linear infinite; }
.status-icon--ok { background: var(--success); }
.status-icon--bad { background: var(--danger); }
@keyframes spin { to { transform: rotate(360deg); } }
.status-amount { font-size: 40px; font-weight: 700; letter-spacing: -.02em; }
.status-title { margin: 0; font-size: 20px; font-weight: 700; }
.status-message { margin: 0; max-width: 300px; font-size: 14px; color: var(--muted); white-space: pre-line; }
.status-actions { width: 100%; display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
@media (prefers-reduced-motion: reduce) { .status-icon--spin { animation: none; } }
