:root {
  color-scheme: light;
  /* Tokens copiados de depi_auto_fe (colores/tipografía/radios reales de la app) */
  --brand: #f5885d;
  --brand-dark: #e13915;
  --btn-bg: #eb7d52;
  --btn-bg-hover: #f0521f;
  --btn-outline-hover-bg: #fff5f0;
  --btn-outline-active-bg: #ffe9dd;
  --ink: #323232;
  --muted: #6d6d6d;
  --placeholder: #b0b0b0;
  --border: #e7e7e7;
  --border-locked: #e5e5e5;
  --bg-locked: #f5f5f5;
  --divider: #d1d1d1;
  --page-bg: #faf7f5;
  --green: #1a9d5c;
  --green-dark: #12703f;
  --green-bg: #eafaf1;
  --red: #d0342c;
  --red-bg: #fdecea;
  --amber: #b7791f;
  --amber-bg: #fff8e6;
  --card-shadow: 2px 5px 32px 0 rgba(0, 0, 0, 0.18);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--page-bg);
  color: var(--ink);
  font-family: "Satoshi", -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  font-weight: 400;
  cursor: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' width='20' height='20'><circle cx='10' cy='10' r='7' fill='%23EB7D52' stroke='white' stroke-width='2'/></svg>") 10 10, auto;
}

button:not(:disabled),
.link-btn,
label[for],
.modal-overlay {
  cursor: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' width='26' height='26'><circle cx='13' cy='13' r='9' fill='none' stroke='%23EB7D52' stroke-width='2.5'/><circle cx='13' cy='13' r='3' fill='%23EB7D52'/></svg>") 13 13, pointer;
}

button:not(:disabled):active,
.link-btn:active,
label[for]:active {
  cursor: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' width='20' height='20'><circle cx='10' cy='10' r='7' fill='%23F0521F'/></svg>") 10 10, pointer;
}

input[type="text"],
input[type="password"] {
  cursor: text;
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image: url('background.jpg');
  background-size: cover;
  background-position: center;
  filter: blur(14px);
  transform: scale(1.1);
  z-index: -1;
}

.page {
  max-width: 480px;
  margin: 0 auto;
  padding: 28px 20px 28px;
}

.brand {
  width: 100%;
  background: #fff;
  border-bottom: 1px solid var(--divider);
  box-shadow: 0 2px 16px rgba(0, 0, 0, 0.05);
}

.brand-inner {
  max-width: 960px;
  margin: 0 auto;
  padding: 18px 32px;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 32px;
}

.brand-logo-liga {
  height: 44px;
  width: auto;
  display: block;
}

.brand-center-title {
  margin: 0;
  text-align: center;
  font-size: 19px;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--ink);
}

.brand-partner {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
  flex-shrink: 0;
}

.brand-partner-label {
  font-size: 10px;
  font-weight: 500;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.brand-logo {
  width: 96px;
  height: auto;
  display: block;
}

.card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 28px 24px 28px;
  box-shadow: var(--card-shadow);
}

h1 {
  margin: 0 0 4px;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--ink);
}

.hint {
  margin: 0 0 20px;
  font-size: 14px;
  color: var(--muted);
  letter-spacing: -0.02em;
}

label {
  display: block;
  font-size: 15px;
  font-weight: 400;
  color: var(--muted);
  letter-spacing: -0.03em;
  margin: 16px 0 6px;
}

input[type="text"],
input[type="password"] {
  width: 100%;
  min-height: 51px;
  padding: 0 16px;
  border-radius: 10px;
  border: 1px solid var(--border);
  font-family: inherit;
  font-size: 16px;
  font-weight: 400;
  letter-spacing: -0.03em;
  color: var(--ink);
  background: #fff;
  outline: none;
  transition: border-color 0.15s ease;
}

input[type="text"]::placeholder,
input[type="password"]::placeholder {
  color: var(--placeholder);
}

input[type="text"]:focus,
input[type="password"]:focus {
  border-color: var(--brand);
}

/* #id + .clase pesa más que [atributo] + :focus, así que esto gana incluso si
   el input sigue enfocado - el color de estado (válido/ya usado/no
   encontrado) debe primar sobre el simple foco una vez que hay un resultado. */
#code-input.ok {
  border-color: var(--green);
}

#code-input.warn {
  border-color: var(--amber);
}

#code-input.error {
  border-color: var(--red);
}

.input-wrap {
  position: relative;
}

#code-input {
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 700;
  padding-right: 46px;
}

.input-status-icon {
  position: absolute;
  top: 50%;
  right: 14px;
  transform: translateY(-50%);
  width: 24px;
  height: 24px;
  pointer-events: none;
}

.input-status-icon:not([hidden]) {
  display: block;
}

.input-status-icon svg {
  width: 100%;
  height: 100%;
}

.input-status-icon.ok {
  color: var(--green);
}

.input-status-icon.warn {
  color: var(--amber);
}

.input-status-icon.error {
  color: var(--red);
}

button[type="submit"] {
  width: 100%;
  margin-top: 22px;
  padding: 15px 20px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: var(--btn-bg);
  color: #fff;
  font-family: inherit;
  font-size: 16px;
  font-weight: 500;
  letter-spacing: -0.03em;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: background-color 0.15s ease, opacity 0.15s ease;
}

.spinner {
  width: 15px;
  height: 15px;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.65s linear infinite;
  flex-shrink: 0;
}

/* Mismo problema de especificidad que `.modal-overlay` (ver más abajo): un
   `display` fijo en la clase empata con `[hidden] { display: none }` del
   user-agent y gana por venir de la hoja del autor - el spinner se veía
   siempre, incluso en reposo. */
.spinner:not([hidden]) {
  display: inline-block;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

button[type="submit"]:hover {
  background: var(--btn-bg-hover);
}

button[type="submit"]:active {
  background: var(--btn-bg-hover);
}

button[type="submit"]:disabled {
  opacity: 0.5;
  pointer-events: none;
}

/* Modo "Registrar uso": mismo botón que "Validar", pero en verde - la etiqueta
   sola no se notaba lo suficiente como para distinguir que ahora SÍ va a
   registrar el canje al presionarlo (antes solo consultaba). */
#action-btn.action-btn-confirm {
  background: var(--green);
}

#action-btn.action-btn-confirm:hover,
#action-btn.action-btn-confirm:active {
  background: var(--green-dark);
}

.link-btn {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 15px;
  letter-spacing: -0.02em;
  cursor: pointer;
  padding: 4px;
  font-family: inherit;
}

.link-btn:hover {
  color: red;
  text-decoration: underline;
}

#logout-btn {
  display: block;
  margin: 20px 0 0 auto;
  width: fit-content;
}

.validate-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding-bottom: 14px;
}

.error {
  font-size: 13px;
  color: var(--red);
}

.result {
  margin-top: 10px;
  font-size: 13px;
  font-weight: 500;
  letter-spacing: -0.02em;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(24, 20, 18, 0.45);
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 100;
}

/* El plano `.modal-overlay { display: flex }` empataba en especificidad con la
   regla del user-agent `[hidden] { display: none }` y ganaba por venir de la
   hoja de estilos del autor - el popup se veía SIEMPRE, ignorando `hidden`.
   Escribir el display acá (mayor especificidad, y solo cuando no está hidden)
   resuelve el empate a favor de lo que sí queremos. */
.modal-overlay:not([hidden]) {
  display: flex;
}

.modal-box {
  width: 100%;
  max-width: 360px;
  background: #fff;
  border-radius: 18px;
  box-shadow: var(--card-shadow);
  padding: 26px 24px;
}

.modal-title {
  margin: 0 0 8px;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--ink);
}

.modal-text {
  margin: 0 0 22px;
  font-size: 14px;
  line-height: 1.5;
  color: var(--muted);
  letter-spacing: -0.02em;
}

.modal-text strong {
  color: var(--ink);
  letter-spacing: 0.04em;
}

.modal-actions {
  display: flex;
  gap: 12px;
}

.btn-outline {
  flex: 1;
  padding: 12px 16px;
  border: 1px solid var(--brand);
  border-radius: 6px;
  background: #fff;
  color: var(--brand);
  font-family: inherit;
  font-size: 15px;
  font-weight: 500;
  letter-spacing: -0.03em;
  cursor: pointer;
  transition: background-color 0.15s ease;
}

.btn-outline:hover {
  background: var(--btn-outline-hover-bg);
}

.btn-outline:active {
  background: var(--btn-outline-active-bg);
}

.btn-outline:disabled {
  opacity: 0.5;
  pointer-events: none;
}

.btn-confirm {
  flex: 1;
  padding: 12px 16px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: var(--btn-bg);
  color: #fff;
  font-family: inherit;
  font-size: 15px;
  font-weight: 500;
  letter-spacing: -0.03em;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: background-color 0.15s ease, opacity 0.15s ease;
}

.btn-confirm:hover {
  background: var(--btn-bg-hover);
}

.btn-confirm:disabled {
  opacity: 0.5;
  pointer-events: none;
}

.result.ok {
  color: var(--green);
}

.result.warn {
  color: var(--amber);
}

.result.error {
  color: var(--red);
}

.stats {
  margin-top: 28px;
  padding-top: 20px;
  border-top: 1px solid var(--divider);
}

.stats-row {
  display: flex;
  justify-content: space-between;
  font-size: 14px;
  font-weight: 500;
  letter-spacing: -0.02em;
  margin-bottom: 8px;
}

#stats-label {
  color: var(--muted);
  font-weight: 400;
}

.progress-track {
  height: 8px;
  border-radius: 999px;
  background: var(--bg-locked);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(to right, var(--brand), var(--brand-dark));
  transition: width 0.3s ease;
}

.history {
  margin-top: 22px;
}

.history-title {
  margin: 0 0 10px;
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.history-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 160px;
  overflow-y: auto;
}

.history-list li {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 12px;
  border-radius: 10px;
  background: var(--page-bg);
  font-size: 13px;
}

.history-list code {
  font-weight: 700;
  letter-spacing: 0.04em;
  font-family: inherit;
}

.history-list time {
  color: var(--muted);
  white-space: nowrap;
}

@media (max-width: 400px) {
  .page {
    padding: 20px 14px 48px;
  }

  .card {
    padding: 22px 18px 26px;
  }

  .brand-logo {
    width: 72px;
  }

  .brand-logo-liga {
    height: 32px;
  }

  .brand-center-title {
    font-size: 15px;
  }

  .brand-inner {
    gap: 10px;
    padding: 12px 14px;
  }

  .brand-partner-label {
    display: none;
  }
}
