:root {
  --naranja: #ff8c1a;
  --naranja-fuerte: #e26a00;
  --azul: #1f4e78;
  --azul-claro: #2e75b6;
  --fondo: #fff8f0;
  --texto: #222;
  --verde: #2e7d32;
  --gris: #888;
  --borde: #eadfce;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  background: var(--fondo);
  color: var(--texto);
}

.container {
  max-width: 480px;
  margin: 0 auto;
  padding: 16px 16px 40px;
}

.topbar {
  background: linear-gradient(90deg, var(--azul), var(--azul-claro));
  color: #fff;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 10;
}

.topbar .brand { font-weight: 700; font-size: 17px; }
.topbar .logout-link, .topbar .back-link {
  color: #fff;
  text-decoration: none;
  font-size: 14px;
  opacity: 0.9;
}

/* --- Login --- */
.login-body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: linear-gradient(160deg, var(--azul) 0%, var(--naranja-fuerte) 100%);
}
.login-card {
  background: #fff;
  border-radius: 16px;
  padding: 32px 24px;
  width: 90%;
  max-width: 340px;
  text-align: center;
  box-shadow: 0 10px 30px rgba(0,0,0,0.25);
}
.login-emblem { font-size: 42px; margin-bottom: 8px; }
.login-card h1 { margin: 0 0 4px; font-size: 22px; color: var(--azul); }
.muted { color: var(--gris); font-size: 14px; }
.login-card form { margin-top: 20px; display: flex; flex-direction: column; gap: 12px; }
.login-card input[type="password"] {
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid var(--borde);
  font-size: 16px;
}
.error { color: #c0392b; font-size: 13px; margin: 8px 0 0; }

button, .btn-primary, .btn-secondary {
  cursor: pointer;
  border: none;
  border-radius: 10px;
  font-size: 15px;
  font-weight: 600;
  padding: 13px 16px;
}
.login-card button, .btn-primary {
  background: var(--naranja);
  color: #fff;
}
.login-card button:active, .btn-primary:active { background: var(--naranja-fuerte); }

.btn-block {
  display: block;
  text-align: center;
  text-decoration: none;
  margin-top: 18px;
}

.btn-secondary {
  background: var(--azul-claro);
  color: #fff;
  margin-top: 14px;
}

/* --- Progreso --- */
.progress-card {
  background: #fff;
  border-radius: 14px;
  padding: 18px;
  margin-top: 16px;
  border: 1px solid var(--borde);
}
.progress-card h2 { margin: 0 0 12px; font-size: 16px; color: var(--azul); }

.progress-numbers {
  display: flex;
  justify-content: space-between;
  margin-bottom: 14px;
}
.progress-numbers > div { text-align: center; flex: 1; }
.progress-numbers .big {
  display: block;
  font-size: 20px;
  font-weight: 700;
  color: var(--naranja-fuerte);
}
.progress-numbers .small {
  display: block;
  font-size: 11px;
  color: var(--gris);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.progress-bar {
  background: #f0e6d6;
  border-radius: 999px;
  height: 14px;
  overflow: hidden;
}
.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--naranja), var(--naranja-fuerte));
  transition: width 0.4s ease;
}
.progress-percent {
  margin: 10px 0 0;
  font-size: 13px;
  color: var(--gris);
  text-align: center;
}

/* --- Frase --- */
.phrase-card {
  background: var(--azul);
  color: #fff;
  border-radius: 14px;
  padding: 20px;
  margin-top: 16px;
  text-align: center;
}
.phrase-character {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--naranja);
  font-weight: 700;
  margin: 0 0 8px;
}
.phrase-text {
  font-size: 16px;
  line-height: 1.4;
  margin: 0;
  min-height: 48px;
}
#btnOtraFrase:disabled { opacity: 0.5; cursor: not-allowed; }

/* --- Lista --- */
.list-hint { margin-top: 14px; }
.char-list {
  list-style: none;
  margin: 12px 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.char-row {
  display: flex;
  align-items: center;
  gap: 12px;
  background: #fff;
  border: 1px solid var(--borde);
  border-radius: 10px;
  padding: 10px 12px;
  transition: background 0.2s ease;
}
.char-row.saved {
  background: #eaf7ec;
  border-color: #bfe3c4;
}

.char-check { position: relative; display: inline-block; width: 24px; height: 24px; flex-shrink: 0; }
.char-check input { position: absolute; opacity: 0; width: 24px; height: 24px; margin: 0; cursor: pointer; }
.checkmark {
  position: absolute;
  top: 0; left: 0;
  width: 24px; height: 24px;
  border-radius: 6px;
  border: 2px solid #c9c0ad;
  background: #fff;
  pointer-events: none;
}
.char-check input:checked + .checkmark {
  background: var(--verde);
  border-color: var(--verde);
}
.char-check input:checked + .checkmark::after {
  content: "";
  position: absolute;
  left: 7px; top: 3px;
  width: 6px; height: 11px;
  border: solid #fff;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

.char-info { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.char-num { font-size: 11px; color: var(--gris); }
.char-name { font-size: 14px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.char-date { font-size: 11px; color: var(--verde); }
.char-amount { font-size: 13px; color: var(--naranja-fuerte); font-weight: 700; white-space: nowrap; }
