:root {
  --brand-light: #2e7d6b;
  --brand-dark: #7fd1bc;
  --brand-text-light: #ffffff;
  --brand-text-dark: #0b3b30;
  --bg-light: #fbfaf6;
  --bg-dark: #121614;
  --card-light: #ffffff;
  --card-dark: #1c2220;
  --text-light: #1d2421;
  --text-dark: #e6ece9;
  --muted-light: #5a6662;
  --muted-dark: #a3b0ab;
  --error-light: #b3261e;
  --error-dark: #ffb4ab;
  --code-bg-light: #cdefe4;
  --code-bg-dark: #0f3a30;

  --brand: var(--brand-light);
  --brand-text: var(--brand-text-light);
  --bg: var(--bg-light);
  --card: var(--card-light);
  --text: var(--text-light);
  --muted: var(--muted-light);
  --error: var(--error-light);
  --code-bg: var(--code-bg-light);

  @media (prefers-color-scheme: dark) {
    --brand: var(--brand-dark);
    --brand-text: var(--brand-text-dark);
    --bg: var(--bg-dark);
    --card: var(--card-dark);
    --text: var(--text-dark);
    --muted: var(--muted-dark);
    --error: var(--error-dark);
    --code-bg: var(--code-bg-dark);
  }

  color-scheme: light dark;
  accent-color: var(--brand);
  font-family: system-ui, sans-serif;
  line-height: 1.45;
  background: var(--bg);
  color: var(--text);
}

* { box-sizing: border-box; }
body { margin: 0; }
[hidden] { display: none !important; }

.visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip-path: inset(50%); white-space: nowrap;
}

.bar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0.75rem 1rem; background: var(--card);
  border-bottom: 1px solid color-mix(in srgb, var(--muted) 25%, transparent);
}
.bar h1 { margin: 0; font-size: 1.25rem; display: flex; align-items: center; gap: 0.5rem; }
.bar-actions { display: flex; align-items: center; gap: 0.75rem; }

main { max-width: 40rem; margin: 0 auto; padding: 1rem; }

.card {
  background: var(--card); border-radius: 12px; padding: 1rem 1.25rem; margin-block: 1rem;
  box-shadow: 0 1px 3px rgb(0 0 0 / 0.08);
}

h2 { font-size: 1.15rem; }
h3 { margin: 0; font-size: 1.1rem; }

form { display: grid; gap: 0.35rem; }
label { font-weight: 600; margin-top: 0.5rem; }
input, select, button { font: inherit; }
input, select {
  padding: 0.6rem 0.7rem; border-radius: 8px;
  border: 1px solid color-mix(in srgb, var(--muted) 60%, transparent);
  background: var(--bg); color: var(--text); min-height: 44px;
}

button {
  min-height: 44px; padding: 0.55rem 1rem; border-radius: 999px; border: 1px solid var(--brand);
  background: var(--brand); color: var(--brand-text); font-weight: 600; cursor: pointer;
}
button.secondary { background: transparent; color: var(--brand); }
button.link { background: none; border: none; color: var(--brand); padding: 0.25rem; min-height: auto; text-decoration: underline; }
button:disabled { opacity: 0.6; cursor: progress; }
.row { display: flex; gap: 0.75rem; margin-top: 0.5rem; }

/* Errores solo después de tocar el campo (o al intentar enviar) */
.field-error { display: none; color: var(--error); margin: 0; font-size: 0.9rem; }
input:user-invalid { border-color: var(--error); }
input:user-invalid + .field-error,
form.tried input:invalid + .field-error { display: block; }

.status { min-height: 1.5em; color: var(--muted); margin: 0; }
.status.error { color: var(--error); }

.student header { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; flex-wrap: wrap; }
.student .devices, .student .used { color: var(--muted); margin: 0.25rem 0; }
.student .balance { margin: 0.75rem 0 0; font-size: 1.1rem; }
.student .balance .value { font-size: 2rem; }
.link-box { margin-top: 1rem; }
.code { margin-top: 0.75rem; padding: 0.75rem 1rem; border-radius: 8px; background: var(--code-bg); }
.code p { margin: 0.25rem 0; }
.code-value { font-size: 2.25rem; font-weight: 700; letter-spacing: 0.3em; font-variant-numeric: tabular-nums; }

summary { font-weight: 600; cursor: pointer; min-height: 32px; }
