:root {
  color-scheme: light dark;
  --bg: #f5f6f8;
  --card: #ffffff;
  --text: #14171c;
  --muted: #4b5563;
  --border: #c4cad3;
  --accent: #1d4ed8;
  --accent-text: #ffffff;
  --error: #b42318;
  --focus: #1d4ed8;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1116;
    --card: #171b22;
    --text: #eef1f5;
    --muted: #aab2bf;
    --border: #3a4250;
    --accent: #6b9bff;
    --accent-text: #0b1020;
    --error: #ff8a80;
    --focus: #9db9ff;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 16px;
  background: var(--bg);
  color: var(--text);
  font: 1rem/1.5 system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

.cartao {
  width: 100%;
  max-width: 24rem;
  padding: 28px 24px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
}

h1 { margin: 0 0 4px; font-size: 1.5rem; }
.sub { margin: 0 0 16px; color: var(--muted); }

form, section { display: grid; gap: 12px; }

label { font-weight: 600; }

input {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  font: inherit;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
}

#codigo { font-size: 1.5rem; letter-spacing: 0.3em; text-align: center; font-variant-numeric: tabular-nums; }

button {
  min-height: 44px;
  padding: 10px 16px;
  font: inherit;
  font-weight: 600;
  border-radius: 8px;
  cursor: pointer;
}

button.primario { color: var(--accent-text); background: var(--accent); border: 1px solid var(--accent); }
button.link { color: var(--text); background: transparent; border: 0; text-decoration: underline; }
button:disabled { opacity: 0.6; cursor: not-allowed; }

:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

.acoes { display: flex; flex-wrap: wrap; gap: 8px; justify-content: space-between; }

.msg { margin: 16px 0 0; min-height: 1.5em; }
.msg.erro { color: var(--error); font-weight: 600; }
[hidden] { display: none !important; }

@media (prefers-reduced-motion: no-preference) {
  button, input { transition: border-color 0.15s, opacity 0.15s; }
}
