/* ============================================================
   DESIGN TOKENS
   ============================================================ */

:root {
  /* Colors */
  --ink:          #0f172a;
  --paper:        #ffffff;
  --surface:      #f8fafc;
  --accent:       #6366f1;
  --accent-hover: #4f46e5;
  --accent-light: #818cf8;
  --accent-glow:  rgba(99, 102, 241, .12);
  --muted:        #64748b;
  --border:       #e2e8f0;
  --border-hover: #cbd5e1;

  /* Typography */
  --font-body: 'Inter', system-ui, -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;

  /* Layout */
  --max-w:     1200px;
  --content-w: 720px;
  /* Alto de la barra superior. Es position:fixed, así que toda vista que empiece
     en el borde de la página tiene que descontarlo o su primer elemento queda
     debajo de la barra. */
  --topbar-h:  60px;

  /* Shape */
  --radius:    12px;
  --radius-lg: 20px;
}


/* ============================================================
   RESET & BASE
   ============================================================ */

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

html {
  scroll-behavior: smooth;
  font-size: 16px;
}

body {
  font-family: var(--font-body);
  color: var(--ink);
  background: var(--surface);
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  color: var(--accent-hover);
}


/* ============================================================
   COMPONENTS
   ============================================================ */

/* — Topbar -------------------------------------------------- */

.topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  height: var(--topbar-h);
  background: rgba(255, 255, 255, .8);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  transition: box-shadow .3s;
}

.topbar.scrolled {
  box-shadow: 0 1px 12px rgba(0, 0, 0, .06);
}

.topbar-inner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  max-width: var(--max-w);
  padding: 0 2rem;
}

.topbar-inner > a {
  display: flex;
  align-items: center;
}

.topbar-inner > a img {
  height: 32px;
  width: auto;
}

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

/* Botón hamburguesa (oculto en escritorio) */
.nav-toggle { display: none; }

.nav-toggle-btn {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  width: 42px;
  height: 42px;
  padding: 9px;
  border-radius: 8px;
  cursor: pointer;
}

.nav-toggle-btn span {
  display: block;
  width: 100%;
  height: 2px;
  border-radius: 2px;
  background: var(--ink);
  transition: transform .25s ease, opacity .2s ease;
}

.topbar a {
  padding: .4rem .75rem;
  border-radius: 8px;
  color: var(--muted);
  font-size: .85rem;
  font-weight: 500;
  text-decoration: none;
  transition: color .2s;
}

.topbar a:hover {
  color: var(--ink);
  background: var(--accent-glow);
}

/* Auth buttons (Iniciar sesión / Regístrate) */
.topbar a.btn-auth {
  border: 1px solid var(--border);
  color: var(--ink);
}

.topbar a.btn-auth:first-of-type {
  margin-left: .4rem;
}

.topbar a.btn-auth:hover {
  border-color: var(--border-hover);
  background: var(--surface);
  color: var(--ink);
}

.topbar a.btn-auth-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--paper);
  font-weight: 600;
}

.topbar a.btn-auth-primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
  color: var(--paper);
}

/* Menú hamburguesa en móvil */
@media (max-width: 768px) {
  .topbar-inner {
    padding: 0 1rem;
  }

  .nav-toggle-btn {
    display: flex;
  }

  .topbar-inner nav {
    display: none;
    position: absolute;
    top: 60px;
    left: 0;
    right: 0;
    flex-direction: column;
    align-items: stretch;
    gap: .15rem;
    padding: .6rem 1rem 1rem;
    background: rgba(255, 255, 255, .98);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
    box-shadow: 0 8px 24px rgba(0, 0, 0, .08);
  }

  .nav-toggle:checked ~ nav {
    display: flex;
  }

  .topbar-inner nav a {
    padding: .7rem .75rem;
    font-size: .95rem;
  }

  .topbar a.btn-auth {
    text-align: center;
  }

  .topbar a.btn-auth:first-of-type {
    margin-left: 0;
    margin-top: .35rem;
  }

  /* Animación a "X" al abrir */
  .nav-toggle:checked ~ .nav-toggle-btn span:nth-child(1) {
    transform: translateY(7px) rotate(45deg);
  }

  .nav-toggle:checked ~ .nav-toggle-btn span:nth-child(2) {
    opacity: 0;
  }

  .nav-toggle:checked ~ .nav-toggle-btn span:nth-child(3) {
    transform: translateY(-7px) rotate(-45deg);
  }
}

/* Cartel de aviso de Auth0 (errores de login, p. ej. correo sin verificar) */
.auth-banner {
  position: fixed;
  top: 60px;
  left: 0;
  right: 0;
  z-index: 99;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  padding: .8rem 1.5rem;
  background: #fffbeb;
  color: #92400e;
  border-bottom: 1px solid #fde68a;
  font-size: .9rem;
  font-weight: 500;
  box-shadow: 0 4px 16px rgba(0, 0, 0, .06);
  animation: auth-banner-in .25s ease;
}

@keyframes auth-banner-in {
  from { transform: translateY(-100%); opacity: 0; }
  to   { transform: translateY(0); opacity: 1; }
}

.auth-banner-msg {
  max-width: var(--content-w);
  line-height: 1.4;
}

.auth-banner-close {
  flex-shrink: 0;
  background: none;
  border: none;
  cursor: pointer;
  color: #92400e;
  font-size: 1.35rem;
  line-height: 1;
  padding: 0 .25rem;
  transition: opacity .2s;
}

.auth-banner-close:hover {
  opacity: .65;
}

/* Mostrar/ocultar según estado de sesión (lo gestiona /js/auth.js) */
.auth-authed { display: none; }
body.is-authed .auth-anon { display: none; }
body.is-authed .auth-authed { display: inline-block; }

/* Ficha de usuario (/cuenta) */
.account-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--paper);
  padding: 2rem;
  margin-top: 1rem;
  box-shadow: 0 4px 24px rgba(0, 0, 0, .04);
}

/* Pestañas de "Mi cuenta": el perfil (account-card) queda arriba siempre
   visible y estas pestañas alternan los paneles de abajo. */
.account-tabs {
  margin-top: 2rem;
}

.account-tabs-nav {
  display: flex;
  flex-wrap: wrap;
  gap: .25rem;
  border-bottom: 1px solid var(--border);
}

.account-tab {
  appearance: none;
  border: none;
  background: none;
  font: inherit;
  font-weight: 600;
  font-size: .95rem;
  color: var(--muted);
  padding: .7rem 1.1rem;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: color .15s ease, border-color .15s ease;
}

.account-tab:hover {
  color: var(--ink);
}

.account-tab.is-active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.account-tab:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

.account-panel {
  margin-top: 1.5rem;
}

.account-panel[hidden] {
  display: none;
}

/* La primera cabecera de cada panel no necesita el margen superior amplio que
   tienen las secciones cuando van apiladas en una sola columna. */
.account-panel > .panel-heading:first-child {
  margin-top: 0;
}

.cm-empty {
  color: var(--muted);
}

.account-avatar {
  width: 88px;
  height: 88px;
  border-radius: 50%;
  object-fit: cover;
  border: 3px solid var(--accent-glow);
  display: block;
}

.account-name {
  margin: 1rem 0 1.5rem;
  font-size: 1.5rem;
  letter-spacing: -.02em;
}

.account-fields {
  display: grid;
  grid-template-columns: minmax(140px, max-content) 1fr;
  gap: .65rem 1.5rem;
  margin: 0;
}

.account-fields dt {
  color: var(--muted);
  font-size: .8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
  align-self: center;
}

.account-fields dd {
  margin: 0;
  color: var(--ink);
  font-size: .95rem;
  word-break: break-word;
}

/* Acciones de la cuenta (cerrar sesión), dentro del bloque del usuario. */
.account-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 1.5rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border);
}

/* Lista de conectores MCP en la cuenta */
.account-services {
  list-style: none;
  margin: 0;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

/* Secciones de conectores en /cuenta (mismas que la página /conectores/). */
.service-group {
  margin-top: 1.5rem;
}

.service-group:first-child {
  margin-top: 1rem;
}

.service-group-title {
  margin: 0 0 .5rem;
  font-size: .9rem;
  font-weight: 700;
  color: var(--ink);
}

.service-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: .85rem 1.1rem;
  border-bottom: 1px solid var(--border);
}

.account-services .service-item:last-child {
  border-bottom: none;
}

.service-name {
  font-size: .95rem;
  font-weight: 500;
  color: var(--ink);
  text-decoration: none;
  /* Crece para empujar el badge y el contador de uso hacia la derecha. */
  flex: 1 1 auto;
}

a.service-name:hover {
  color: var(--accent);
  text-decoration: underline;
}

.service-badge {
  flex-shrink: 0;
  font-size: .72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
  padding: .25rem .6rem;
  border-radius: 999px;
}

.service-item.is-on .service-badge {
  background: #dcfce7;
  color: #166534;
}

.service-item.is-off .service-badge {
  background: #f1f5f9;
  color: #64748b;
}

/* Toggle de habilitar/deshabilitar conector (self-service en /cuenta). */
.service-toggle-wrap {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  gap: .5rem;
}

.service-toggle-label {
  font-size: .72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--muted);
  /* Ancho fijo (cabe "Deshabilitado") para que el switch quede siempre en la
     misma columna, sin correrse entre estados habilitado/deshabilitado. */
  width: 7.5rem;
  text-align: right;
}

.service-item.is-on .service-toggle-label {
  color: #166534;
}

/* Slider switch */
.service-toggle {
  position: relative;
  flex-shrink: 0;
  width: 42px;
  height: 24px;
  padding: 0;
  border: none;
  border-radius: 999px;
  background: #cbd5e1;
  cursor: pointer;
  transition: background .15s ease;
}

.service-toggle::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 2px rgba(0, 0, 0, .25);
  transition: transform .15s ease;
}

.service-item.is-on .service-toggle {
  background: #16a34a;
}

.service-item.is-on .service-toggle::after {
  transform: translateX(18px);
}

.service-toggle:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.service-toggle:disabled {
  opacity: .6;
  cursor: default;
}

/* Aviso: los cambios de conectores requieren volver a iniciar sesión. */
.services-relogin-notice {
  margin: .75rem 0 0;
  padding: .7rem .9rem;
  border: 1px solid #fde68a;
  background: #fffbeb;
  border-radius: var(--radius);
  color: #92400e;
  font-size: .86rem;
}

.service-item.is-off .service-name {
  color: var(--muted);
}

/* Contador de uso por conector (cuántas consultas ha hecho el usuario). */
.service-usage {
  flex-shrink: 0;
  font-size: .78rem;
  font-weight: 500;
  color: var(--muted);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.service-usage.is-zero {
  font-style: italic;
  opacity: .75;
}

/* Bolsa de consultas (/cuenta) */
.credits-card {
  margin: 1rem 0 0;
  padding: 1.4rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--paper);
}

.credits-card.is-empty {
  border-color: #fecaca;
  background: #fef2f2;
}

.credits-metrics {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
}

.credit-metric {
  flex: 1 1 180px;
  display: flex;
  flex-direction: column;
  gap: .25rem;
  padding: 1rem 1.1rem;
  border-radius: var(--radius);
  background: var(--surface);
}

.credit-value {
  font-size: 2.2rem;
  font-weight: 800;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
}

.credit-metric.credit-balance .credit-value {
  color: var(--accent);
}

.credits-card.is-empty .credit-metric.credit-balance .credit-value {
  color: #dc2626;
}

.credit-label {
  font-size: .82rem;
  color: var(--muted);
}

.credits-bar {
  margin-top: 1.1rem;
  height: 8px;
  border-radius: 999px;
  background: var(--border);
  overflow: hidden;
}

.credits-bar-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 999px;
  transition: width .3s ease;
}

/* Cuando hay algún consumo, mostrar al menos una franja visible aunque el
   porcentaje sea muy bajo. */
.credits-bar-fill.has-usage {
  min-width: 4px;
}

.credits-caption {
  margin: .55rem 0 0;
  font-size: .82rem;
  color: var(--muted);
}

.credits-empty-msg {
  margin: .8rem 0 0;
  font-size: .86rem;
  font-weight: 500;
  color: #b91c1c;
}

/* Historial de pagos (/cuenta) */
.payment-history > p {
  color: var(--muted);
}

.payments-table {
  width: 100%;
  margin-top: 1rem;
  border-collapse: collapse;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--paper);
  font-size: .92rem;
}

.payments-table th,
.payments-table td {
  padding: .7rem .9rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.payments-table thead th {
  font-size: .78rem;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--muted);
  background: var(--surface);
}

.payments-table tbody tr:last-child td {
  border-bottom: none;
}

.payments-table .pay-amount {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}

.payments-table .pay-credits {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

/* Metadata personal por conector (/cuenta) */
.connector-metadata > p {
  color: var(--muted);
}

.cm-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  padding: 1.5rem 1.75rem;
  margin-top: 1.25rem;
}

.cm-title {
  margin: 0 0 1rem;
  font-size: 1.1rem;
  letter-spacing: -.01em;
}

.cm-field {
  margin-bottom: 1.1rem;
}

.cm-label {
  display: block;
  color: var(--muted);
  font-size: .8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
  margin-bottom: .4rem;
}

.cm-input {
  width: 100%;
  box-sizing: border-box;
  padding: .65rem .85rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-mono, 'JetBrains Mono', monospace);
  font-size: .95rem;
}

.cm-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.cm-toggle {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  margin-top: .45rem;
  font-size: .82rem;
  color: var(--muted);
  cursor: pointer;
}

.cm-help {
  margin: .45rem 0 0;
  font-size: .85rem;
  color: var(--muted);
}

.cm-actions {
  display: flex;
  gap: .6rem;
  margin-top: .35rem;
  flex-wrap: wrap;
}

.cm-save {
  padding: .55rem 1.2rem;
  border: 1px solid var(--accent);
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-family: var(--font-body);
  font-size: .9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all .2s;
}

.cm-save:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}

.cm-delete {
  padding: .55rem 1.1rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--paper);
  color: var(--muted);
  font-family: var(--font-body);
  font-size: .9rem;
  font-weight: 500;
  cursor: pointer;
  transition: all .2s;
}

.cm-delete:hover {
  border-color: var(--border-hover);
  color: var(--ink);
}

.cm-status {
  margin: .85rem 0 0;
  font-size: .9rem;
  min-height: 1.2em;
}

.cm-status.is-ok {
  color: #166534;
}

.cm-status.is-error {
  color: #b91c1c;
}

.logout-btn {
  padding: .55rem 1.1rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: .9rem;
  font-weight: 500;
  cursor: pointer;
  transition: all .2s;
}

.logout-btn:hover {
  border-color: var(--border-hover);
  background: var(--surface);
}

@media (max-width: 768px) {
  .account-fields {
    grid-template-columns: 1fr;
    gap: .15rem;
  }
  .account-fields dd {
    margin-bottom: .65rem;
  }
}


/* — Masthead ----------------------------------------------- */

.masthead {
  position: relative;
  overflow: hidden;
  margin-top: var(--topbar-h);
  padding: 5rem 2rem 4rem;
  background: var(--paper);
  text-align: center;
}

.masthead::before {
  content: '';
  position: absolute;
  top: -50%;
  left: 50%;
  transform: translateX(-50%);
  width: 800px;
  height: 800px;
  background: radial-gradient(circle, var(--accent-glow) 0%, transparent 70%);
  pointer-events: none;
}

.masthead-label {
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  margin-bottom: 1rem;
  padding: .35rem 1rem;
  border-radius: 100px;
  background: var(--accent-glow);
  color: var(--accent);
  font-size: .75rem;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.masthead h1 {
  position: relative;
  margin-bottom: 1rem;
  line-height: 1;
  cursor: pointer;
}

.masthead h1 img {
  max-width: clamp(240px, 40vw, 420px);
  height: auto;
}

.masthead-tagline {
  max-width: 540px;
  margin: 0 auto;
  color: var(--muted);
  font-size: 1.1rem;
  font-weight: 400;
  line-height: 1.6;
}

.masthead-rule {
  display: none;
}


/* — Hero ---------------------------------------------------- */

.hero {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 3rem 2rem 4rem;
}

.hero-text h2 {
  margin-bottom: 1rem;
  font-size: 1.75rem;
  font-weight: 700;
  line-height: 1.3;
  letter-spacing: -.02em;
}

.hero-text p {
  margin-bottom: 2rem;
  color: var(--muted);
  font-size: .95rem;
  line-height: 1.7;
}

.hero-tabs {
  margin-top: 2rem;
}

.tab-nav {
  display: flex;
  gap: .5rem;
  margin-bottom: 1.5rem;
}

.tab-btn {
  padding: .4rem 1.1rem;
  border: 1px solid var(--border);
  border-radius: 100px;
  background: transparent;
  color: var(--muted);
  font-family: var(--font-body);
  font-size: .8rem;
  font-weight: 600;
  cursor: pointer;
  transition: all .2s;
}

.tab-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.tab-btn.active {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

.hero-chart {
  position: relative;
  height: 260px;
  margin-bottom: 1.75rem;
}

.hero-stat-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: .75rem;
}

@media (max-width: 768px) {
  .hero-chart {
    height: 200px;
  }

  .hero-stat-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

.stat-card {
  padding: 1.25rem 1.5rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--paper);
  transition: all .25s;
}

.stat-card:hover {
  border-color: var(--accent);
  box-shadow: 0 4px 20px var(--accent-glow);
}

.stat-card .num {
  font-size: 1.75rem;
  font-weight: 800;
  line-height: 1;
  letter-spacing: -.03em;
  background: linear-gradient(135deg, var(--ink), var(--accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.stat-card .label {
  margin-top: .35rem;
  color: var(--muted);
  font-size: .7rem;
  font-weight: 500;
  letter-spacing: .06em;
  text-transform: uppercase;
}


/* — Sections ------------------------------------------------ */

.section {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 2rem 2rem 4rem;
}

.section-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 2rem;
  padding-bottom: 0;
  border: none;
}

.section-header h2 {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -.02em;
}

.section-header .tag {
  padding: 4px 10px;
  border-radius: 100px;
  background: var(--accent-glow);
  color: var(--accent);
  font-size: .65rem;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
}


/* — Search bar ---------------------------------------------- */

.search-bar {
  position: relative;
  display: flex;
  align-items: center;
  gap: .5rem;
  margin-bottom: 1.5rem;
  padding: .5rem 1rem;
  border: 1px solid var(--border);
  border-radius: 100px;
  background: var(--paper);
  transition: border-color .2s, box-shadow .2s;
}

.search-bar:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.search-icon {
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  fill: var(--muted);
}

.search-bar input {
  flex: 1;
  border: none;
  outline: none;
  background: transparent;
  color: var(--ink);
  font-family: var(--font-body);
  font-size: .9rem;
}

.search-bar input::placeholder {
  color: var(--muted);
  opacity: .7;
}

.search-clear {
  padding: 0 .25rem;
  border: none;
  background: none;
  color: var(--muted);
  font-size: 1.25rem;
  line-height: 1;
  cursor: pointer;
  transition: color .2s;
}

.search-clear:hover {
  color: var(--ink);
}

.search-btn {
  padding: .45rem 1.1rem;
  border: none;
  border-radius: 100px;
  background: var(--accent);
  color: #fff;
  font-family: var(--font-body);
  font-size: .8rem;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
  transition: background .2s;
}

.search-btn:hover {
  background: var(--accent-hover);
}


/* — Articles grid ------------------------------------------- */

.articles-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 1.25rem;
}

.loading {
  padding: 3rem;
  color: var(--muted);
  text-align: center;
}

.placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  grid-column: 1 / -1;
  min-height: 120px;
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  color: var(--muted);
  font-size: .85rem;
}


/* — Article card -------------------------------------------- */

.article-card {
  position: relative;
  display: block;
  overflow: hidden;
  padding: 1.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--paper);
  color: inherit;
  text-decoration: none;
  cursor: pointer;
  transition: all .3s cubic-bezier(.4, 0, .2, 1);
}

.article-card:hover {
  border-color: var(--accent);
  transform: translateY(-4px);
  box-shadow: 0 12px 40px var(--accent-glow);
}

.article-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 3px;
  background: linear-gradient(90deg, var(--accent), var(--accent-light));
  transform: scaleX(0);
  transform-origin: left;
  transition: transform .4s cubic-bezier(.4, 0, .2, 1);
}

.article-card:hover::before {
  transform: scaleX(1);
}

.article-card .date {
  margin-bottom: .75rem;
  color: var(--muted);
  font-size: .7rem;
  font-weight: 500;
  letter-spacing: .06em;
  text-transform: uppercase;
}

.article-card h3 {
  margin-bottom: .5rem;
  color: var(--ink);
  font-size: 1.2rem;
  font-weight: 700;
  line-height: 1.3;
  letter-spacing: -.01em;
}

.article-card p {
  color: var(--muted);
  font-size: .85rem;
  line-height: 1.6;
}

.article-card .card-tag {
  display: inline-block;
  margin-top: 1rem;
  padding: 3px 10px;
  border: none;
  border-radius: 100px;
  background: var(--accent-glow);
  color: var(--accent);
  font-size: .6rem;
  font-weight: 600;
  letter-spacing: .06em;
  text-transform: uppercase;
}


/* — Pagination ---------------------------------------------- */

.pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
  gap: .5rem;
  margin-top: 2rem;
}

.pagination button {
  padding: .5rem 1rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: .85rem;
  font-weight: 500;
  cursor: pointer;
  transition: all .2s;
}

.pagination button:hover {
  border-color: var(--accent);
  background: var(--accent-glow);
  color: var(--accent);
}

.pagination button.active {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

.pagination button:disabled {
  border-color: var(--border);
  background: var(--paper);
  color: var(--muted);
  opacity: .4;
  cursor: default;
}


/* — About band ---------------------------------------------- */

.about-band {
  position: relative;
  overflow: hidden;
  margin-top: 2rem;
  padding: 5rem 2rem;
  background: var(--ink);
  color: var(--paper);
}

.about-band::before {
  content: '';
  position: absolute;
  top: -40%;
  right: -20%;
  width: 600px;
  height: 600px;
  background: radial-gradient(circle, rgba(99, 102, 241, .15) 0%, transparent 70%);
  pointer-events: none;
}

.about-inner {
  position: relative;
  max-width: var(--content-w);
  margin: 0 auto;
}

.about-inner h2 {
  margin-bottom: 1.5rem;
  font-size: 2.25rem;
  font-weight: 800;
  letter-spacing: -.03em;
}

.about-inner p {
  margin-bottom: 1rem;
  color: #94a3b8;
  font-size: .95rem;
  line-height: 1.7;
}

.about-inner a {
  color: var(--accent-light);
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-color: rgba(129, 140, 248, .4);
}

.about-inner a:hover {
  text-decoration-color: var(--accent-light);
}

.sources-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  column-gap: 2.5rem;
  margin-top: 1.75rem;
}

@media (max-width: 768px) {
  .sources-grid {
    grid-template-columns: 1fr;
  }
}

.source-row {
  display: flex;
  flex-direction: column;
  gap: .2rem;
  padding: .65rem 0;
  border-bottom: 1px solid rgba(255, 255, 255, .06);
  color: inherit;
  text-decoration: none;
  transition: border-color .2s;
}

.source-name {
  color: var(--paper);
  font-size: .85rem;
  font-weight: 600;
}

.source-desc {
  color: #94a3b8;
  font-size: .75rem;
  line-height: 1.45;
}

.source-links {
  display: flex;
  flex-wrap: wrap;
  gap: .25rem 1.25rem;
  margin-top: .35rem;
}

.source-links a {
  font-size: .72rem;
  font-weight: 500;
  white-space: nowrap;
}


/* — Footer -------------------------------------------------- */

footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 2.5rem 2rem;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: .8rem;
}

footer a {
  color: var(--muted);
  font-weight: 500;
  text-decoration: none;
}

footer a:hover {
  color: var(--accent);
}

footer .disclaimer {
  width: 100%;
  margin-top: .5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: .72rem;
  line-height: 1.6;
  opacity: .75;
}


/* — Article view -------------------------------------------- */

.article-view {
  display: none;
  max-width: var(--content-w);
  margin: 0 auto;
  /* La barra es fixed y no ocupa espacio en el flujo: sin sumarla acá, el enlace
     "Volver a publicaciones" quedaba pegado a su borde inferior. */
  padding: calc(var(--topbar-h) + 2.5rem) 2rem 5rem;
}

.article-view .back {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  margin-bottom: 2rem;
  padding: .4rem .75rem;
  border-radius: 8px;
  color: var(--accent);
  font-size: .8rem;
  font-weight: 600;
  text-decoration: none;
  transition: background .2s;
}

.article-view .back:hover {
  background: var(--accent-glow);
}

.article-view .meta {
  display: flex;
  flex-wrap: wrap;
  gap: 1.5rem;
  margin-bottom: 1rem;
  color: var(--muted);
  font-size: .75rem;
  font-weight: 500;
  letter-spacing: .05em;
  text-transform: uppercase;
}

.article-view .rendered h1 {
  margin-bottom: .75rem;
  font-size: clamp(2rem, 5vw, 2.75rem);
  font-weight: 800;
  line-height: 1.15;
  letter-spacing: -.03em;
}

.article-view .rendered h2 {
  margin: 2.5rem 0 1rem;
  font-size: 1.5rem;
  font-weight: 700;
  line-height: 1.25;
  letter-spacing: -.02em;
}

.article-view .rendered h3 {
  margin: 2rem 0 .75rem;
  font-size: 1.15rem;
  font-weight: 700;
}

.article-view .rendered p {
  margin-bottom: 1rem;
  font-size: 1rem;
  line-height: 1.75;
}

.article-view .rendered ul,
.article-view .rendered ol {
  margin: 0 0 1rem 1.5rem;
}

.article-view .rendered li {
  margin-bottom: .5rem;
  font-size: .95rem;
}

.article-view .rendered blockquote {
  margin: 1.5rem 0;
  padding: .75rem 1.25rem;
  border-left: 3px solid var(--accent);
  border-radius: 0 var(--radius) var(--radius) 0;
  background: var(--accent-glow);
  color: var(--muted);
}

.article-view .rendered table {
  width: 100%;
  margin: 1.5rem 0;
  border-collapse: collapse;
  font-size: .85rem;
}

.article-view .rendered th {
  padding: .5rem .75rem;
  border-bottom: 2px solid var(--ink);
  color: var(--muted);
  font-size: .7rem;
  font-weight: 600;
  letter-spacing: .06em;
  text-align: left;
  text-transform: uppercase;
}

.article-view .rendered td {
  padding: .5rem .75rem;
  border-bottom: 1px solid var(--border);
}

.article-view .rendered code {
  padding: 2px 6px;
  border-radius: 6px;
  background: var(--accent-glow);
  color: var(--accent);
  font-family: var(--font-mono);
  font-size: .85em;
}

.article-view .rendered pre {
  overflow-x: auto;
  margin: 1.5rem 0;
  padding: 1.5rem;
  border-radius: var(--radius);
  background: var(--ink);
  color: #94a3b8;
  font-size: .8rem;
  line-height: 1.7;
}

.article-view .rendered pre code {
  padding: 0;
  background: none;
  color: inherit;
}

.article-view .rendered hr {
  margin: 2rem 0;
  border: none;
  border-top: 1px solid var(--border);
}

.article-view .rendered img {
  max-width: 100%;
  margin: 1.5rem 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.article-view .rendered strong {
  font-weight: 700;
}


/* — Podcast player ------------------------------------------ */

.podcast-player {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: .75rem;
  margin-bottom: 2rem;
  padding: .75rem 1.25rem;
  border: 1px solid rgba(99, 102, 241, .2);
  border-radius: 100px;
  background: var(--accent-glow);
}

.podcast-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  border: none;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  transition: background .2s, transform .15s;
}

.podcast-btn:hover {
  background: var(--accent-hover);
  transform: scale(1.05);
}

.podcast-btn:active {
  transform: scale(.95);
}

.podcast-btn svg {
  width: 18px;
  height: 18px;
  fill: currentColor;
}

.podcast-btn.playing {
  background: var(--accent-hover);
}

.podcast-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.podcast-label {
  color: var(--ink);
  font-size: .8rem;
  font-weight: 600;
}

.podcast-status {
  color: var(--muted);
  font-size: .7rem;
}

.podcast-progress {
  flex: 1;
  overflow: hidden;
  min-width: 80px;
  height: 4px;
  border-radius: 100px;
  background: rgba(99, 102, 241, .15);
}

.podcast-progress-bar {
  width: 0%;
  height: 100%;
  border-radius: 100px;
  background: var(--accent);
  transition: width .3s;
}

.podcast-voice-row {
  display: flex;
  align-items: center;
  gap: .4rem;
}

.podcast-voice-label {
  font-size: .7rem;
  font-weight: 600;
  color: var(--muted);
  white-space: nowrap;
}

.podcast-voice-select {
  font-family: var(--font-body);
  font-size: .7rem;
  color: var(--ink);
  background: var(--paper);
  border: 1px solid var(--border);
  border-radius: 100px;
  padding: .2rem .65rem;
  cursor: pointer;
  max-width: 200px;
  outline: none;
  transition: border-color .2s;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath fill='%2364748b' d='M0 0l5 6 5-6z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right .55rem center;
  padding-right: 1.6rem;
}

.podcast-voice-select:hover,
.podcast-voice-select:focus {
  border-color: var(--accent);
}


/* ============================================================
   ANIMATIONS & UTILITIES
   ============================================================ */

@keyframes fadeUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.fade-in {
  animation: fadeUp .6s cubic-bezier(.4, 0, .2, 1) both;
}


/* ============================================================
   UNIDADES DE ANUNCIO (Google AdSense)
   ============================================================ */

/* El bloque nace sin alto reservado, sin marco y sin etiqueta: hasta que AdSense
   confirme que consiguió un anuncio no se sabe si habrá algo que mostrar, y una
   unidad nueva o sin inventario vuelve vacía. Reservar el espacio por adelantado
   dejaba un recuadro enorme con la palabra "Publicidad" y nada adentro. El marco
   lo agrega .is-filled, que ads.js pone recién cuando llega el anuncio. */
.ad-unit {
  display: flex;
  flex-direction: column;
  gap: .4rem;
  margin: 1.5rem 0;
}

/* El display:flex de arriba es una regla de autor y le gana a la regla [hidden]
   de la hoja del navegador, así que sin esto el bloque que ads.js esconde cuando
   el anuncio vuelve vacío seguiría ocupando su alto: no se ve nada, pero queda
   un vacío entre el contenido y lo que sigue. */
.ad-unit[hidden] {
  display: none;
}

/* El <ins> tiene que nacer con ancho real: AdSense mide el contenedor al hacer
   el push y, si lo encuentra en cero, no llena la unidad nunca. */
.ad-unit .adsbygoogle {
  display: block;
  width: 100%;
}

/* La política de AdSense pide que el anuncio se distinga del contenido: la
   etiqueta va discreta, pero legible. Solo aparece si hay anuncio. */
.ad-label {
  display: none;
  font-size: .68rem;
  font-weight: 500;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--muted);
  opacity: .7;
}

.ad-unit.is-filled .ad-label {
  display: block;
}

/* La franja del home va bajo la grilla, a lo ancho de la sección. Dentro de la
   grilla no funciona: el número de columnas es responsivo, así que un bloque de
   fila completa insertado a media fila empuja el anuncio a la fila siguiente y
   deja las celdas restantes vacías. */
.ad-unit-home {
  margin: 2rem 0 .5rem;
}

.ad-unit-home.is-filled {
  padding: 1rem 1.25rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--paper);
}

.ad-unit-articulo {
  margin: 2.5rem 0;
}

.ad-unit-articulo.is-filled {
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}


/* ============================================================
   HUINCHA DE WHATSAPP (panel "Saldo y pagos" de /cuenta)
   ============================================================ */

/* Misma línea y mismo enlace prellenado que el botón flotante: invita a recargar
   la bolsa cuando el usuario se quedó sin consultas. */
.wa-strip {
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-top: 1.25rem;
  padding: 1.1rem 1.25rem;
  border-radius: var(--radius);
  background: linear-gradient(135deg, #128c7e, #25d366);
  box-shadow: 0 10px 24px rgba(18, 140, 126, .28);
  color: #fff;
  text-decoration: none;
  transition: transform .25s ease, box-shadow .25s ease;
}

/* Brillo diagonal que recorre la huincha para llamar la atención. */
.wa-strip::after {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  width: 45%;
  background: linear-gradient(100deg, transparent, rgba(255, 255, 255, .28), transparent);
  transform: translateX(-160%);
  animation: waStripShine 5s ease-in-out 1.5s infinite;
  pointer-events: none;
}

@keyframes waStripShine {
  0%   { transform: translateX(-160%); }
  35%  { transform: translateX(320%); }
  100% { transform: translateX(320%); }
}

.wa-strip:hover {
  transform: translateY(-2px);
  box-shadow: 0 14px 30px rgba(18, 140, 126, .38);
}

.wa-strip-icon {
  flex: none;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: rgba(255, 255, 255, .18);
  color: #fff;
}

.wa-strip-text {
  flex: 1 1 auto;
  font-size: .88rem;
  line-height: 1.45;
  color: rgba(255, 255, 255, .9);
}

.wa-strip-text strong {
  display: block;
  font-size: 1.02rem;
  font-weight: 700;
  color: #fff;
}

.wa-strip-cta {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  padding: .6rem 1.1rem;
  border-radius: 999px;
  background: #fff;
  color: #0b6b5f;
  font-size: .85rem;
  font-weight: 700;
  white-space: nowrap;
}

@media (max-width: 640px) {
  .wa-strip {
    flex-wrap: wrap;
    gap: .85rem;
  }

  .wa-strip-text {
    flex: 1 1 60%;
  }

  .wa-strip-cta {
    flex: 1 1 100%;
    justify-content: center;
  }
}

@media (prefers-reduced-motion: reduce) {
  .wa-strip::after {
    animation: none;
  }

  .wa-strip:hover {
    transform: none;
  }
}


/* ============================================================
   WHATSAPP FLOTANTE (solo sección privada)
   ============================================================ */

/* El botón solo existe en /cuenta/ (la sección privada del sitio) y, además,
   solo se muestra cuando auth.js confirma la sesión marcando <body> con
   "is-authed". Así nunca aparece en las páginas públicas ni en el instante
   previo a que se resuelva la autenticación. */

.wa-float {
  position: fixed;
  right: 24px;
  bottom: calc(24px + env(safe-area-inset-bottom, 0px));
  z-index: 900;
  display: none;
  align-items: center;
  gap: 12px;
  text-decoration: none;
}

body.is-authed .wa-float {
  display: flex;
}

.wa-float-bubble {
  max-width: 250px;
  background: var(--paper);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .75rem 1rem;
  font-size: .82rem;
  line-height: 1.45;
  color: var(--muted);
  box-shadow: 0 10px 30px rgba(15, 23, 42, .12);
  opacity: 0;
  transform: translateX(12px) scale(.96);
  transform-origin: right center;
  transition: opacity .25s ease, transform .25s ease;
  pointer-events: none;
  animation: waBubbleIn .4s ease 2s forwards;
}

@keyframes waBubbleIn {
  to {
    opacity: 1;
    transform: translateX(0) scale(1);
  }
}

.wa-float-bubble strong {
  display: block;
  color: var(--ink);
  font-size: .9rem;
  margin-bottom: .15rem;
}

.wa-float-btn {
  position: relative;
  flex: none;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: var(--paper);
  background: linear-gradient(135deg, #25d366, #128c7e);
  box-shadow: 0 8px 24px rgba(37, 211, 102, .45);
  transition: transform .25s ease, box-shadow .25s ease;
}

.wa-float-pulse {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: #25d366;
  z-index: -1;
  animation: waPulse 2.4s ease-out infinite;
}

@keyframes waPulse {
  0%   { transform: scale(1);   opacity: .55; }
  70%  { transform: scale(1.9); opacity: 0; }
  100% { transform: scale(1.9); opacity: 0; }
}

.wa-float:hover .wa-float-btn {
  transform: scale(1.07);
  box-shadow: 0 10px 30px rgba(37, 211, 102, .6);
}

.wa-float:hover .wa-float-bubble {
  opacity: 1;
  transform: translateX(0) scale(1);
}

@media (max-width: 768px) {
  .wa-float {
    right: 16px;
    bottom: calc(20px + env(safe-area-inset-bottom, 0px));
  }

  .wa-float-bubble {
    display: none;
  }

  .wa-float-btn {
    width: 56px;
    height: 56px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .wa-float-pulse {
    animation: none;
  }

  .wa-float-bubble {
    animation: none;
    opacity: 1;
    transform: none;
  }
}
