:root {
  --ink: #16213a;
  --paper: #f4f6fb;
  --card: #ffffff;
  --teal: #00b8a0;
  --teal-dark: #009484;
  --coral: #ff6b4a;
  --coral-dark: #e5502f;
  --violet: #7c5cfc;
  --violet-dark: #6342e8;
  --line: #e6e9f5;
  --muted: #6b7280;
  --ok: #16a34a;
  --danger: #e11d48;
  --radius: 16px;
  --font-display: 'Poppins', 'Segoe UI', sans-serif;
  --font-body: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
}

/* ---------- Topbar ---------- */
.topbar {
  background: linear-gradient(120deg, var(--teal) 0%, var(--violet) 100%);
  color: #fff;
}
.topbar-inner {
  max-width: 1040px;
  margin: 0 auto;
  padding: 18px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.3rem;
  letter-spacing: 0.01em;
}
.brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 11px;
  background: rgba(255,255,255,0.22);
  font-weight: 800;
  font-size: 1.1rem;
  backdrop-filter: blur(4px);
}
.topbar-right { display: flex; align-items: center; gap: 14px; }
.espacios-pill {
  background: rgba(255,255,255,0.18);
  padding: 7px 16px;
  border-radius: 999px;
  font-size: 0.88rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.user-chip { font-size: 0.88rem; opacity: 0.95; }
.topbar-link {
  color: #fff;
  text-decoration: none;
  font-size: 0.88rem;
  font-weight: 600;
  background: rgba(0,0,0,0.15);
  padding: 7px 14px;
  border-radius: 999px;
  transition: background 0.15s ease;
}
.topbar-link:hover { background: rgba(0,0,0,0.28); }

/* ---------- Tabs ---------- */
.tabs {
  max-width: 1040px;
  margin: 0 auto;
  display: flex;
  gap: 4px;
  padding: 16px 20px 0;
  border-bottom: 1px solid var(--line);
}
.tab-btn {
  background: none;
  border: none;
  padding: 11px 18px;
  font-size: 0.95rem;
  font-family: var(--font-body);
  color: var(--muted);
  cursor: pointer;
  border-bottom: 3px solid transparent;
  margin-bottom: -1px;
  border-radius: 8px 8px 0 0;
  transition: color 0.15s ease, background 0.15s ease;
}
.tab-btn:hover { background: rgba(0,184,160,0.08); color: var(--teal-dark); }
.tab-btn.active {
  color: var(--violet-dark);
  border-bottom-color: var(--violet);
  font-weight: 700;
}

.container {
  max-width: 1040px;
  margin: 0 auto;
  padding: 26px 20px 60px;
}

.tab-panel { display: none; }
.tab-panel.active { display: block; animation: fadeIn 0.25s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: translateY(0); } }

/* ---------- Cards ---------- */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 20px;
  box-shadow: 0 2px 10px rgba(22, 33, 58, 0.03);
  transition: box-shadow 0.2s ease;
}
.card:hover { box-shadow: 0 6px 20px rgba(22, 33, 58, 0.07); }
.card-accent-teal { border-top: 4px solid var(--teal); }
.card-accent-coral { border-top: 4px solid var(--coral); }
.card h2 {
  margin-top: 0;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.12rem;
  color: var(--ink);
}

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; margin-bottom: 20px; }

label {
  display: block;
  font-size: 0.82rem;
  color: var(--muted);
  margin: 12px 0 5px;
  font-weight: 600;
}
input, select {
  width: 100%;
  padding: 11px 14px;
  border: 1.5px solid var(--line);
  border-radius: 10px;
  font-size: 0.95rem;
  background: #fbfcff;
  color: var(--ink);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
input:focus, select:focus {
  outline: none;
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(0,184,160,0.15);
}

.btn {
  margin-top: 18px;
  border: none;
  border-radius: 999px;
  padding: 13px 22px;
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  width: 100%;
  transition: transform 0.12s ease, box-shadow 0.12s ease, background 0.15s ease;
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn-primary { background: var(--teal); color: #fff; box-shadow: 0 4px 14px rgba(0,184,160,0.3); }
.btn-primary:hover { background: var(--teal-dark); box-shadow: 0 6px 18px rgba(0,184,160,0.38); }
.btn-accent { background: var(--coral); color: #fff; box-shadow: 0 4px 14px rgba(255,107,74,0.3); }
.btn-accent:hover { background: var(--coral-dark); box-shadow: 0 6px 18px rgba(255,107,74,0.38); }

.msg { margin-top: 10px; font-size: 0.88rem; min-height: 1.2em; font-weight: 600; }
.msg.ok { color: var(--ok); }
.msg.error { color: var(--danger); }

table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); }
th { color: var(--muted); font-weight: 700; font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.04em; }
tbody tr:hover { background: rgba(0,184,160,0.04); }
.table-wrap { overflow-x: auto; }
.empty-state { color: var(--muted); font-size: 0.9rem; padding: 14px 0; }

.badge { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 0.74rem; font-weight: 700; }
.badge-yes { background: #d7f7ee; color: var(--teal-dark); }
.badge-no { background: #f0efe9; color: var(--muted); }
.badge-vencido { background: #ffe1d9; color: var(--coral-dark); }

/* ---------- Stat cards (reportes) ---------- */
.stat-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  display: flex;
  flex-direction: column;
  border-left: 5px solid var(--line);
  transition: transform 0.15s ease;
}
.stat-card:hover { transform: translateY(-2px); }
.stat-teal { border-left-color: var(--teal); }
.stat-coral { border-left-color: var(--coral); }
.stat-violet { border-left-color: var(--violet); }
.stat-label { font-size: 0.76rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; font-weight: 700; }
.stat-value { font-family: var(--font-display); font-weight: 700; font-size: 1.9rem; color: var(--ink); margin-top: 6px; }
.stat-sub { font-size: 0.82rem; color: var(--muted); margin-top: 2px; }

.bars { display: flex; align-items: flex-end; gap: 12px; height: 150px; padding-top: 10px; }
.bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; }
.bar { width: 100%; background: linear-gradient(180deg, var(--violet) 0%, var(--teal) 100%); border-radius: 6px 6px 0 0; min-height: 3px; }
.bar-label { font-size: 0.72rem; color: var(--muted); margin-top: 6px; font-weight: 600; }

.link-btn {
  background: none;
  border: none;
  color: var(--danger);
  cursor: pointer;
  font-size: 0.85rem;
  text-decoration: underline;
  font-weight: 600;
}

/* ---------- Login / Setup ---------- */
.auth-body {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--teal) 0%, var(--violet) 100%);
  padding: 20px;
}
.auth-card {
  background: #fff;
  border-radius: 20px;
  padding: 40px 36px;
  max-width: 380px;
  width: 100%;
  box-shadow: 0 20px 50px rgba(22,33,58,0.25);
  text-align: center;
}
.auth-logo {
  width: 52px;
  height: 52px;
  border-radius: 15px;
  background: linear-gradient(135deg, var(--teal), var(--violet));
  color: #fff;
  font-weight: 800;
  font-size: 1.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 16px;
}
.auth-card h1 {
  font-family: var(--font-display);
  font-size: 1.3rem;
  margin: 0 0 6px;
  color: var(--ink);
}
.auth-sub { color: var(--muted); font-size: 0.9rem; margin-bottom: 6px; }
.auth-card form { text-align: left; }
.auth-back {
  display: inline-block;
  margin-top: 18px;
  font-size: 0.85rem;
  color: var(--muted);
  text-decoration: none;
}
.auth-back:hover { color: var(--teal-dark); }
.auth-card code { background: var(--paper); padding: 2px 6px; border-radius: 4px; font-size: 0.85em; }

/* ---------- Página pública ---------- */
.public-hero { display: flex; justify-content: center; padding-top: 60px; }
.public-card {
  background: #fff;
  border-radius: 24px;
  padding: 48px 40px;
  text-align: center;
  max-width: 420px;
  width: 100%;
  box-shadow: 0 12px 40px rgba(22,33,58,0.08);
}
.public-eyebrow {
  display: inline-block;
  background: linear-gradient(120deg, var(--teal), var(--violet));
  color: #fff;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 5px 14px;
  border-radius: 999px;
  margin-bottom: 18px;
}
.public-number {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 4.2rem;
  color: var(--ink);
  line-height: 1;
}
.public-sub { color: var(--muted); margin-top: 8px; font-size: 1rem; }
.public-progress {
  margin-top: 24px;
  height: 10px;
  background: var(--paper);
  border-radius: 999px;
  overflow: hidden;
}
.public-progress-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--teal), var(--coral));
  border-radius: 999px;
  transition: width 0.4s ease;
}
.public-updated { margin-top: 14px; font-size: 0.78rem; color: var(--muted); }

@media (max-width: 640px) {
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .tabs { overflow-x: auto; }
  .public-number { font-size: 3.2rem; }
}

/* ---------- Indicador "en vivo" ---------- */
.live-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #fff;
  margin-right: 5px;
  animation: blink 1.6s ease-in-out infinite;
}
@keyframes blink {
  0%, 100% { opacity: 1; box-shadow: 0 0 0 0 rgba(255,255,255,0.5); }
  50% { opacity: 0.5; box-shadow: 0 0 0 4px rgba(255,255,255,0); }
}

/* ---------- Pulso del número al actualizar ---------- */
.public-number.pulse { animation: numberPulse 0.5s ease; }
@keyframes numberPulse {
  0% { transform: scale(1); }
  30% { transform: scale(1.12); color: var(--teal-dark); }
  100% { transform: scale(1); }
}

/* ---------- Botón flotante de WhatsApp ---------- */
.whatsapp-float {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 58px;
  height: 58px;
  border-radius: 50%;
  background: #25D366;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 8px 24px rgba(37,211,102,0.4);
  animation: floatBounce 2.4s ease-in-out infinite;
  transition: transform 0.15s ease;
  z-index: 50;
}
.whatsapp-float:hover { transform: scale(1.08); }
@keyframes floatBounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}

/* ---------- Íconos de pestañas ---------- */
.tab-icon { margin-right: 4px; }

/* ---------- Sección de información pública ---------- */
.info-section { padding-top: 8px; }
.info-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 18px;
  margin-bottom: 24px;
}
.info-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 24px;
  text-align: center;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.info-card:hover { transform: translateY(-3px); box-shadow: 0 10px 28px rgba(22,33,58,0.08); }
.info-icon { font-size: 1.8rem; margin-bottom: 10px; }
.info-card h3 {
  font-family: var(--font-display);
  font-size: 1.02rem;
  margin: 0 0 8px;
  color: var(--ink);
}
.info-card p { color: var(--muted); font-size: 0.92rem; line-height: 1.5; margin: 0 0 8px; }
.info-link { color: var(--teal-dark); font-weight: 700; font-size: 0.88rem; text-decoration: none; }
.info-link:hover { text-decoration: underline; }
.info-note { display: block; font-size: 0.76rem; color: var(--muted); font-style: italic; margin-top: 4px; }

.map-wrap {
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--line);
  box-shadow: 0 2px 10px rgba(22,33,58,0.03);
}

/* ---------- Footer ---------- */
.site-footer {
  background: var(--ink);
  color: rgba(255,255,255,0.85);
  margin-top: 40px;
  padding: 40px 0 24px;
}
.footer-inner { display: flex; flex-direction: column; gap: 24px; }
.footer-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.15rem;
  color: #fff;
}
.footer-brand .brand-mark {
  background: linear-gradient(135deg, var(--teal), var(--violet));
}
.footer-cols {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 24px;
  border-top: 1px solid rgba(255,255,255,0.12);
  padding-top: 24px;
}
.footer-cols h4 {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: rgba(255,255,255,0.55);
  margin: 0 0 10px;
}
.footer-cols p { margin: 0 0 8px; font-size: 0.9rem; line-height: 1.5; }
.footer-cols a {
  color: #fff;
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 600;
}
.footer-cols a:hover { text-decoration: underline; color: var(--teal); }
.footer-copy {
  font-size: 0.78rem;
  color: rgba(255,255,255,0.45);
  margin: 8px 0 0;
}

@media (max-width: 640px) {
  .info-grid, .footer-cols { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  .live-dot, .whatsapp-float, .public-number.pulse, .tab-panel.active { animation: none !important; }
}
