/* ═══════════════════════════════════════════════
   National Bank Of Spain — Whitish Theme
═══════════════════════════════════════════════ */

:root {
  --bg:          #f4f6f9;
  --surface:     #ffffff;
  --surface2:    #f8fafc;
  --border:      #e2e8f0;
  --border2:     #cbd5e0;
  --text:        #1a202c;
  --text2:       #4a5568;
  --text3:       #718096;
  --accent:      #2b6cb0;
  --accent-h:    #2c5282;
  --accent-l:    #ebf8ff;
  --green:       #276749;
  --green-bg:    #f0fff4;
  --green-bd:    #9ae6b4;
  --red:         #c53030;
  --red-bg:      #fff5f5;
  --red-bd:      #feb2b2;
  --yellow:      #744210;
  --yellow-bg:   #fffff0;
  --yellow-bd:   #faf089;
  --gold:        #d4a017;
  --shadow:      0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.05);
  --shadow-md:   0 4px 6px rgba(0,0,0,.07), 0 2px 4px rgba(0,0,0,.05);
  --shadow-lg:   0 10px 25px rgba(0,0,0,.08), 0 4px 10px rgba(0,0,0,.05);
  --radius:      10px;
  --radius-lg:   16px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}

/* ── Nav ──────────────────────────────────────── */
nav {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 60px;
  box-shadow: var(--shadow);
  position: sticky; top: 0; z-index: 100;
}

.nav-brand {
  display: flex; align-items: center; gap: .6rem;
  font-weight: 700; font-size: 1.1rem; color: var(--accent);
  text-decoration: none;
}

.nav-brand .logo-icon { font-size: 1.4rem; }

.nav-links { display: flex; align-items: center; gap: .25rem; }

.nav-links a {
  text-decoration: none; color: var(--text2); font-size: .9rem;
  padding: .4rem .85rem; border-radius: 6px; transition: all .15s;
}

.nav-links a:hover { background: var(--accent-l); color: var(--accent); }
.nav-links a.active { background: var(--accent-l); color: var(--accent); font-weight: 600; }

.nav-user {
  display: flex; align-items: center; gap: .75rem;
}

.nav-balance {
  background: var(--green-bg); color: var(--green);
  border: 1px solid var(--green-bd);
  padding: .3rem .8rem; border-radius: 20px; font-size: .85rem; font-weight: 700;
}

.btn-logout {
  background: none; border: 1px solid var(--border2); color: var(--text2);
  padding: .3rem .8rem; border-radius: 6px; cursor: pointer; font-size: .85rem;
  transition: all .15s;
}
.btn-logout:hover { background: var(--red-bg); color: var(--red); border-color: var(--red-bd); }

/* ── Buttons ──────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  padding: .6rem 1.4rem; border-radius: 8px; border: none; cursor: pointer;
  font-size: .95rem; font-weight: 600; transition: all .15s; text-decoration: none;
}

.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-h); transform: translateY(-1px); box-shadow: 0 4px 12px rgba(43,108,176,.3); }

.btn-outline {
  background: transparent; border: 2px solid var(--accent); color: var(--accent);
}
.btn-outline:hover { background: var(--accent); color: #fff; }

.btn-danger { background: var(--red); color: #fff; }
.btn-danger:hover { background: #9b2c2c; }

.btn-success { background: var(--green); color: #fff; }
.btn-success:hover { background: #22543d; }

.btn-sm { padding: .35rem .85rem; font-size: .85rem; }
.btn-full { width: 100%; }

.btn:disabled { opacity: .5; cursor: not-allowed; transform: none !important; }

/* ── Cards ────────────────────────────────────── */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.5rem;
}

.card-header {
  display: flex; align-items: center; justify-content: space-between;
  padding-bottom: 1rem; margin-bottom: 1rem; border-bottom: 1px solid var(--border);
}

.card-title { font-weight: 700; font-size: 1rem; color: var(--text); }

/* ── Forms ────────────────────────────────────── */
.form-group { margin-bottom: 1rem; }
.form-label { display: block; font-size: .85rem; font-weight: 600; color: var(--text2); margin-bottom: .35rem; }

.form-input {
  width: 100%; padding: .65rem 1rem; border: 1.5px solid var(--border);
  border-radius: 8px; font-size: .95rem; background: var(--surface2);
  color: var(--text); transition: border-color .15s;
  font-family: inherit;
}
.form-input:focus { outline: none; border-color: var(--accent); background: #fff; box-shadow: 0 0 0 3px rgba(43,108,176,.1); }
.form-input::placeholder { color: var(--text3); }

.form-hint { font-size: .8rem; color: var(--text3); margin-top: .3rem; }

/* ── Alerts ───────────────────────────────────── */
.alert {
  padding: .8rem 1rem; border-radius: 8px; font-size: .9rem;
  display: flex; align-items: flex-start; gap: .5rem; margin-bottom: 1rem;
}
.alert-error { background: var(--red-bg); color: var(--red); border: 1px solid var(--red-bd); }
.alert-success { background: var(--green-bg); color: var(--green); border: 1px solid var(--green-bd); }
.alert-info { background: var(--accent-l); color: var(--accent); border: 1px solid #bee3f8; }
.alert-warn { background: var(--yellow-bg); color: var(--yellow); border: 1px solid var(--yellow-bd); }
.alert.hidden { display: none; }

/* ── Page layout ──────────────────────────────── */
.page { max-width: 1100px; margin: 0 auto; padding: 2rem 1.5rem; }
.page-sm { max-width: 440px; margin: 0 auto; padding: 2rem 1.5rem; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem; }
.grid-3 { display: grid; grid-template-columns: repeat(3,1fr); gap: 1.25rem; }

@media (max-width: 768px) {
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .page { padding: 1.25rem 1rem; }
}

/* ── Stat card ────────────────────────────────── */
.stat-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 1.25rem 1.5rem;
}
.stat-label { font-size: .8rem; font-weight: 600; color: var(--text3); text-transform: uppercase; letter-spacing: .05em; }
.stat-value { font-size: 1.8rem; font-weight: 800; color: var(--text); margin: .2rem 0; }
.stat-sub { font-size: .85rem; color: var(--text3); }
.stat-card.green { border-top: 3px solid #38a169; }
.stat-card.blue  { border-top: 3px solid var(--accent); }
.stat-card.red   { border-top: 3px solid #e53e3e; }
.stat-card.gold  { border-top: 3px solid var(--gold); }

/* ── Table ────────────────────────────────────── */
.table-wrap { overflow-x: auto; border-radius: var(--radius); border: 1px solid var(--border); }
table { width: 100%; border-collapse: collapse; }
thead th { background: var(--surface2); font-size: .8rem; font-weight: 700; color: var(--text3); text-transform: uppercase; letter-spacing: .04em; padding: .75rem 1rem; text-align: left; border-bottom: 1px solid var(--border); }
tbody td { padding: .75rem 1rem; font-size: .9rem; border-bottom: 1px solid var(--border); }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--surface2); }

.badge {
  display: inline-block; padding: .2rem .6rem; border-radius: 20px;
  font-size: .75rem; font-weight: 700;
}
.badge-green { background: var(--green-bg); color: var(--green); }
.badge-red   { background: var(--red-bg); color: var(--red); }
.badge-blue  { background: var(--accent-l); color: var(--accent); }
.badge-gold  { background: #fffbeb; color: #92400e; }
.badge-gray  { background: #f7fafc; color: var(--text3); border: 1px solid var(--border); }

/* ── Hero (index page) ────────────────────────── */
.hero {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 5rem 2rem 4rem;
  text-align: center;
}

.hero-tagline {
  display: inline-block; background: var(--red-bg); color: var(--red);
  border: 1px solid var(--red-bd); border-radius: 20px;
  padding: .3rem 1rem; font-size: .85rem; font-weight: 700; margin-bottom: 1.5rem;
}

.hero h1 {
  font-size: 3rem; font-weight: 900; color: var(--text); line-height: 1.15;
  margin-bottom: 1.25rem;
}

.hero h1 span { color: var(--accent); }

.hero p { font-size: 1.15rem; color: var(--text2); max-width: 560px; margin: 0 auto 2rem; }

.hero-actions { display: flex; gap: 1rem; justify-content: center; flex-wrap: wrap; }

.vault-meter {
  max-width: 540px; margin: 3rem auto 0;
  background: var(--surface2); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1.25rem 1.5rem;
}

.vault-label { display: flex; justify-content: space-between; font-size: .85rem; font-weight: 600; color: var(--text2); margin-bottom: .6rem; }

.progress-track { background: var(--border); border-radius: 99px; height: 12px; overflow: hidden; }
.progress-fill { height: 100%; border-radius: 99px; transition: width 1s ease; background: linear-gradient(90deg, #38a169, #2b6cb0); }

/* ── Challenge card ───────────────────────────── */
.challenge-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 1.25rem; }

.challenge-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 1.4rem; display: flex; flex-direction: column; gap: .75rem;
  transition: box-shadow .15s, transform .15s;
}
.challenge-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }
.challenge-card.solved { border-left: 4px solid #38a169; }

.challenge-top { display: flex; align-items: flex-start; justify-content: space-between; }
.challenge-title { font-weight: 700; font-size: 1rem; }
.challenge-diff-easy   { color: #2f855a; }
.challenge-diff-medium { color: #c05621; }
.challenge-diff-hard   { color: #c53030; }

.challenge-reward { font-size: 1.5rem; font-weight: 900; color: var(--green); }
.challenge-sub { font-size: .75rem; color: var(--text3); }

.challenge-desc { font-size: .9rem; color: var(--text2); flex: 1; }

.hint-toggle {
  background: none; border: 1px solid var(--border2); border-radius: 6px;
  padding: .35rem .8rem; font-size: .82rem; cursor: pointer; color: var(--text3);
  transition: all .15s;
}
.hint-toggle:hover { background: var(--yellow-bg); color: var(--yellow); border-color: var(--yellow-bd); }

.hint-box { background: var(--yellow-bg); border: 1px solid var(--yellow-bd); border-radius: 6px; padding: .7rem .9rem; font-size: .85rem; color: var(--yellow); display: none; }
.hint-box.visible { display: block; }

.challenge-footer { display: flex; align-items: center; gap: .75rem; }
.challenge-footer input { flex: 1; }

/* ── Leaderboard ──────────────────────────────── */
.lb-rank { font-weight: 800; font-size: 1.1rem; }
.lb-rank-1 { color: #d4a017; }
.lb-rank-2 { color: #718096; }
.lb-rank-3 { color: #c05621; }

/* ── Auth pages ───────────────────────────────── */
.auth-page {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  padding: 2rem; background: var(--bg);
}

.auth-box {
  width: 100%; max-width: 420px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); padding: 2.5rem;
}

.auth-logo { text-align: center; margin-bottom: 2rem; }
.auth-logo .icon { font-size: 2.5rem; }
.auth-logo h1 { font-size: 1.4rem; font-weight: 800; color: var(--text); margin-top: .5rem; }
.auth-logo p { font-size: .88rem; color: var(--text3); margin-top: .25rem; }

.auth-divider { text-align: center; margin: 1.25rem 0; color: var(--text3); font-size: .85rem; position: relative; }
.auth-divider::before, .auth-divider::after { content: ''; position: absolute; top: 50%; width: 42%; height: 1px; background: var(--border); }
.auth-divider::before { left: 0; }
.auth-divider::after { right: 0; }

.auth-link { text-align: center; margin-top: 1.25rem; font-size: .9rem; color: var(--text3); }
.auth-link a { color: var(--accent); font-weight: 600; text-decoration: none; }
.auth-link a:hover { text-decoration: underline; }

/* ── Spinner ──────────────────────────────────── */
.spinner {
  width: 18px; height: 18px; border: 2px solid rgba(255,255,255,.3);
  border-top-color: #fff; border-radius: 50%; animation: spin .7s linear infinite;
  display: none;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Empty state ──────────────────────────────── */
.empty-state { text-align: center; padding: 3rem 1rem; color: var(--text3); }
.empty-state .icon { font-size: 2.5rem; margin-bottom: .75rem; }
.empty-state p { font-size: .95rem; }

/* ── Misc ─────────────────────────────────────── */
.section-title { font-size: 1.1rem; font-weight: 700; color: var(--text); margin-bottom: 1rem; }
.text-center { text-align: center; }
.text-green { color: var(--green); }
.text-red   { color: var(--red); }
.text-blue  { color: var(--accent); }
.text-muted { color: var(--text3); }
.font-mono { font-family: 'Consolas', 'Courier New', monospace; font-size: .85rem; }
.gap-1 { gap: .5rem; }
.mt-1 { margin-top: .5rem; }
.mt-2 { margin-top: 1rem; }
.mb-1 { margin-bottom: .5rem; }
.mb-2 { margin-bottom: 1rem; }
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.w-full { width: 100%; }

/* ── Toast ────────────────────────────────────── */
#toast-container { position: fixed; bottom: 1.5rem; right: 1.5rem; z-index: 9999; display: flex; flex-direction: column; gap: .5rem; }
.toast {
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
  box-shadow: var(--shadow-lg); padding: .85rem 1.2rem; font-size: .9rem;
  display: flex; align-items: center; gap: .6rem; min-width: 260px;
  animation: slideIn .25s ease;
}
.toast-success { border-left: 4px solid #38a169; }
.toast-error   { border-left: 4px solid #e53e3e; }
.toast-info    { border-left: 4px solid var(--accent); }
@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
