:root {
  --green-primary: #2d6a4f;
  --green-light: #52b788;
  --green-dark: #1b4332;
  --green-accent: #95d5b2;
  --bg-light: #f8f9fa;
  --bg-white: #ffffff;
  --text-dark: #1a1a1a;
  --text-gray: #6c757d;
  --gold: #ffd700;
  --red: #dc3545;
  --orange: #fd7e14;
}

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

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

.view[hidden] { display: none !important; }

/* LOGIN */
.login-view {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--green-dark) 0%, var(--green-primary) 100%);
  padding: 20px;
}

.login-card {
  width: 100%;
  max-width: 380px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 20px;
  padding: 40px 30px;
  text-align: center;
}

.brand-logo {
  display: inline-block;
  background: white;
  border-radius: 12px;
  padding: 10px 18px;
  margin-bottom: 20px;
}
.brand-logo img { display: block; height: 32px; width: auto; }
.brand-logo-small { padding: 6px 12px; margin-bottom: 0; }
.brand-logo-small img { height: 20px; }

.login-card h1 {
  color: white;
  font-size: 30px;
  font-weight: 800;
  letter-spacing: -0.5px;
  margin-bottom: 8px;
}

.login-card .subtitle {
  color: var(--green-accent);
  font-size: 15px;
  margin-bottom: 36px;
  font-weight: 500;
}

#login-form label {
  display: block;
  color: white;
  text-align: left;
  margin-bottom: 8px;
  font-weight: 600;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

#login-form input {
  width: 100%;
  padding: 16px;
  border: 2px solid var(--green-accent);
  border-radius: 12px;
  font-size: 18px;
  text-align: center;
  background: rgba(255, 255, 255, 0.95);
  font-weight: 600;
  letter-spacing: 1px;
  margin-bottom: 20px;
}

#login-form input:focus {
  outline: none;
  border-color: var(--gold);
  box-shadow: 0 0 0 4px rgba(255, 215, 0, 0.2);
}

#login-btn {
  width: 100%;
  padding: 16px;
  background: var(--gold);
  color: var(--green-dark);
  border: none;
  border-radius: 12px;
  font-size: 16px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  cursor: pointer;
}

#login-btn:disabled { opacity: 0.6; cursor: default; }
#login-btn:not(:disabled):hover { filter: brightness(1.05); }

.error-msg {
  margin-top: 16px;
  color: #ffb4b4;
  font-weight: 600;
  font-size: 14px;
}

.dashboard-view .error-msg { color: var(--red); background: #fdeaea; padding: 12px 16px; border-radius: 10px; }

/* DASHBOARD */
.topbar {
  background: var(--green-dark);
  color: white;
  padding: 16px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.topbar-brand { display: flex; align-items: center; gap: 12px; font-weight: 800; font-size: 18px; }

.topbar-user { display: flex; align-items: center; gap: 16px; font-weight: 600; }

.link-btn {
  background: none;
  border: 1px solid var(--green-accent);
  color: white;
  padding: 6px 14px;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 600;
}
.link-btn:hover { background: rgba(255, 255, 255, 0.1); }

.content {
  max-width: 1000px;
  margin: 0 auto;
  padding: 24px 20px 60px;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 32px;
}

.info-banner {
  display: flex;
  align-items: center;
  gap: 8px;
  justify-content: center;
  background: #eefaf1;
  color: var(--green-dark);
  border: 1px solid var(--green-accent);
  border-radius: 12px;
  padding: 12px 16px;
  font-size: 14px;
  font-weight: 600;
  text-align: center;
  margin-bottom: 24px;
}
.info-banner-icon {
  font-size: 16px;
  flex-shrink: 0;
}

.stat-card {
  background: var(--bg-white);
  border-radius: 16px;
  padding: 20px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.06);
}

.stat-points { background: linear-gradient(135deg, var(--green-primary), var(--green-dark)); color: white; }
.stat-points .stat-label { color: var(--green-accent); }

.stat-label { font-size: 13px; text-transform: uppercase; letter-spacing: 0.5px; color: var(--text-gray); font-weight: 700; margin-bottom: 8px; }
.stat-value { font-size: 32px; font-weight: 800; }

/* VELOCÍMETRO DE PODIUM */
.gauge-top { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 2px; }
.gauge-title { font-size: 13px; text-transform: uppercase; letter-spacing: 0.5px; color: var(--text-gray); font-weight: 700; }
.gauge-status-inline { font-size: 13px; font-weight: 800; color: var(--text-dark); }
.gauge-status-inline.is-in { color: #1b7a3d; }

.gauge-svg { width: 100%; height: auto; display: block; margin-top: 2px; }
.gauge-track { fill: none; stroke: #dde4e0; }
.gauge-progress { fill: none; } /* stroke fijado inline: cada gauge referencia su propio <linearGradient> */
.gauge-needle { stroke: var(--green-dark); stroke-linecap: round; }
.gauge-hub { fill: var(--green-dark); }
.gauge-endlabel { font-size: 10px; fill: var(--text-gray); font-family: inherit; }
.gauge-podium-dot { fill: var(--bg-white); stroke: #b3861a; stroke-width: 2.5; }

.gauge-readout { text-align: center; margin-top: -6px; }
.gauge-number { font-size: 26px; font-weight: 800; color: var(--text-dark); line-height: 1; }
.gauge-number small { font-size: 13px; font-weight: 600; color: var(--text-gray); }
.gauge-caption { font-size: 12.5px; color: var(--text-gray); margin-top: 4px; }

.semaforo-counts { display: flex; gap: 10px; flex-wrap: wrap; }
.badge { padding: 6px 12px; border-radius: 999px; font-weight: 700; font-size: 14px; display: inline-flex; align-items: center; gap: 6px; }
.badge-verde { background: #e6f6ec; color: #1b7a3d; }
.badge-amarillo { background: #fff8e1; color: #a56c00; }
.badge-rojo { background: #fdeaea; color: #b3261e; }

.division-block { margin-bottom: 28px; }
.division-title {
  font-size: 18px;
  font-weight: 800;
  color: var(--green-dark);
  margin-bottom: 12px;
  padding-bottom: 6px;
  border-bottom: 3px solid var(--green-accent);
}

.familias-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 12px;
}

.familia-card {
  background: var(--bg-white);
  border-radius: 12px;
  padding: 14px 16px;
  box-shadow: 0 1px 6px rgba(0, 0, 0, 0.06);
  border-left: 5px solid var(--text-gray);
}
.familia-card.semaforo-verde { border-left-color: var(--green-light); }
.familia-card.semaforo-amarillo { border-left-color: var(--gold); }
.familia-card.semaforo-rojo { border-left-color: var(--red); }

.familia-card.familia-clickable {
  cursor: pointer;
  transition: transform 120ms ease, box-shadow 120ms ease;
}
.familia-card.familia-clickable:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}
.familia-card.familia-clickable .familia-nombre::after {
  content: ' ⭐';
  font-size: 12px;
}

.familia-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.familia-nombre { font-weight: 700; font-size: 14px; }
.familia-icon { font-size: 16px; }

.familia-bar-track { background: #edf0ee; border-radius: 999px; height: 8px; overflow: hidden; margin-bottom: 6px; }
.familia-bar-fill { height: 100%; border-radius: 999px; }
.familia-bar-fill.semaforo-verde { background: var(--green-light); }
.familia-bar-fill.semaforo-amarillo { background: var(--gold); }
.familia-bar-fill.semaforo-rojo { background: var(--red); }

.familia-detalle { font-size: 12px; color: var(--text-gray); }

.updated-note { margin-top: 40px; text-align: center; color: var(--text-gray); font-size: 12px; }

.empty-state { color: var(--text-gray); font-size: 14px; padding: 20px; text-align: center; }

/* CATÁLOGO DE PREMIOS */
.catalogo-section { margin: 32px 0; text-align: center; }

.secondary-btn {
  background: var(--green-dark);
  color: white;
  border: none;
  padding: 14px 24px;
  border-radius: 12px;
  font-weight: 700;
  font-size: 15px;
  cursor: pointer;
}
.secondary-btn:hover { filter: brightness(1.1); }

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 100;
}
.modal-overlay[hidden] { display: none !important; }

.modal-box {
  background: var(--bg-white);
  border-radius: 16px;
  max-width: 640px;
  width: 100%;
  max-height: 85vh;
  overflow-y: auto;
  padding: 24px;
}

.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 4px; }
.modal-header h2 { color: var(--green-dark); font-size: 20px; }

.modal-close {
  background: none;
  border: none;
  font-size: 18px;
  cursor: pointer;
  color: var(--text-gray);
  padding: 4px 8px;
}
.modal-close:hover { color: var(--text-dark); }

.modal-sub { color: var(--text-gray); font-size: 13px; margin-bottom: 18px; }

.modal-box-small { max-width: 420px; }
.familia-mensaje-text {
  margin-top: 14px;
  padding: 14px 16px;
  background: var(--bg-light);
  border-radius: 12px;
  font-size: 15px;
  line-height: 1.5;
  color: var(--text-dark);
}

.catalogo-list { display: flex; flex-direction: column; gap: 10px; }

.premio-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 14px;
  border-radius: 12px;
  background: var(--bg-light);
  border-left: 5px solid var(--text-gray);
}
.premio-row.conseguible { border-left-color: var(--green-light); background: #eefaf1; }

.premio-icon { font-size: 22px; flex-shrink: 0; }

.premio-info { flex: 1; min-width: 0; }
.premio-nombre { font-weight: 700; font-size: 14px; }

.premio-estado { text-align: right; font-size: 13px; font-weight: 700; white-space: nowrap; }
.premio-estado.conseguible { color: #1b7a3d; }
.premio-estado.pendiente { color: var(--text-gray); }
.premio-puntos-necesarios { font-size: 11px; color: var(--text-gray); font-weight: 500; }
