/* ═══════════════════════════════════════════════════════
   Golf Pro Studio · Global Styles
   ═══════════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&family=Cormorant+Garamond:wght@400;500;600;700&display=swap');

:root {
  --green-main:  #01411F;
  --green-dark:  #012A14;
  --green-light: #EBF0ED;
  --green-mid:   #C0D0C7;
  --gold:        #B18D3C;
  --gold-dark:   #856A2D;
  --gold-light:  #F6F1E8;
  --text-main:   #111827;
  --text-muted:  #6B7280;
  --background:  #F8FAF9;
  --white:       #FFFFFF;
  --border:      #DDE7E1;
  --red:         #DC2626;
  --yellow:      #D97706;
  --font-brand:  'Cormorant Garamond', serif;
  --sidebar-w:   220px;
  --header-h:    60px;
  --mobile-nav:  60px;
  --radius:      10px;
  --shadow:      0 1px 4px rgba(0,0,0,.07), 0 4px 16px rgba(0,0,0,.05);
  --shadow-md:   0 4px 24px rgba(0,0,0,.10);
}

/* ─── Reset ─── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 14px; }
body { font-family: 'Inter', sans-serif; background: var(--background); color: var(--text-main); line-height: 1.5; -webkit-font-smoothing: antialiased; }
a { color: inherit; text-decoration: none; }
button { cursor: pointer; font-family: inherit; }
input, textarea, select { font-family: inherit; }
img { display: block; max-width: 100%; }

/* ─── Scrollbar ─── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* ═══════════════════════════════════════════════════════
   LAYOUT
   ═══════════════════════════════════════════════════════ */

/* ─── App shell ─── */
.app-shell {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* ─── Sidebar ─── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--white);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  transition: width .2s;
  overflow: hidden;
  z-index: 100;
}

.sidebar.collapsed {
  width: 60px;
}

.sidebar-logo {
  height: var(--header-h);
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 14px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.sidebar-logo-icon {
  /* mark.png es la ilustración apaisada del logo real (bola+swoosh+bandera,
     790×240, fondo transparente) — no un icono cuadrado, así que aquí no lleva
     ni caja ni border-radius: se deja que el ancho siga al alto y no se recorta
     ni deforma nada, a diferencia del favicon.svg cuadrado que sustituye. Más
     baja que antes (era 32px de icono cuadrado) para dejarle sitio al texto
     "Golf Pro Studio" completo en los 220px de sidebar. */
  height: 22px;
  display: flex;
  align-items: center;
  flex-shrink: 0;
}
.sidebar-logo-icon img { height: 100%; width: auto; object-fit: contain; }

.sidebar-logo-text {
  font-family: var(--font-brand);
  font-size: 17px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
}

/* ─── Wordmark "Golf Pro Studio": Pro en negrita/verde, Studio en fino/dorado ─── */
.wordmark-light { font-weight: 400; color: var(--gold-dark); }
.brand-tagline {
  font-size: 10px;
  font-weight: 700;
  color: var(--gold-dark);
  text-transform: uppercase;
  letter-spacing: .1em;
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 12px 8px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  white-space: nowrap;
  transition: background .15s, color .15s;
  cursor: pointer;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
}

.nav-item:hover { background: var(--green-light); color: var(--green-dark); }
.nav-item.active { background: var(--green-light); color: var(--green-dark); font-weight: 600; }

.nav-item svg { width: 18px; height: 18px; flex-shrink: 0; }
.nav-item span { overflow: hidden; }

.sidebar-footer {
  padding: 12px 8px;
  border-top: 1px solid var(--border);
}

.sidebar-promo {
  background: var(--green-light);
  border-radius: 10px;
  padding: 14px;
  margin-bottom: 8px;
  text-align: center;
}

.sidebar-promo p { font-size: 11px; color: var(--text-muted); margin: 4px 0 10px; }
.sidebar-promo strong { font-size: 12px; color: var(--green-dark); }

/* ─── Main content ─── */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ─── Header ─── */
.app-header {
  height: var(--header-h);
  background: var(--white);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 16px;
  flex-shrink: 0;
}

.header-collapse-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  padding: 6px;
  border-radius: 6px;
}

.header-collapse-btn:hover { background: var(--background); }

/* Oculto por defecto: el buscador y/o el sidebar ya llevan la marca en
   pantallas más anchas. Se activa por media query en el único ancho donde
   ninguno de los dos está visible — ver el bloque @media (max-width: 480px). */
.header-mobile-logo {
  display: none;
  align-items: center;
  gap: 6px;
  font-family: var(--font-brand);
  font-size: 15px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
}
.header-mobile-logo img { height: 20px; width: auto; object-fit: contain; flex-shrink: 0; }

.header-search {
  flex: 1;
  max-width: 400px;
  position: relative;
}

.header-search input {
  width: 100%;
  background: var(--background);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 14px 8px 36px;
  font-size: 13px;
  color: var(--text-main);
  outline: none;
  transition: border .15s;
}

.header-search input:focus { border-color: var(--green-main); }
.header-search input::placeholder { color: var(--text-muted); }

.header-search svg {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  color: var(--text-muted);
}

.header-kbd {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  background: var(--border);
  color: var(--text-muted);
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 4px;
  font-weight: 500;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-left: auto;
}

/* Selector rápido de idioma en la cabecera */
.lang-switch { display: flex; border: 1px solid var(--border); border-radius: 7px; overflow: hidden; }
.lang-switch-opt {
  background: none; border: none; padding: 6px 10px; font-size: 11.5px; font-weight: 700;
  color: var(--text-muted); cursor: pointer; font-family: inherit; letter-spacing: .03em;
}
.lang-switch-opt.active { background: var(--green-main); color: #fff; }


.header-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 10px;
  border-radius: 8px;
  cursor: pointer;
  background: none;
  border: none;
}

.header-user:hover { background: var(--background); }

.user-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--green-light);
  border: 2px solid var(--green-mid);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 13px;
  color: var(--green-dark);
  overflow: hidden;
  flex-shrink: 0;
}

.user-avatar img { width: 100%; height: 100%; object-fit: cover; }

.user-info { text-align: left; }
.user-name { font-size: 13px; font-weight: 600; white-space: nowrap; }
.user-role { font-size: 11px; color: var(--text-muted); }

/* ─── Page content ─── */
.page-content {
  flex: 1;
  overflow-y: auto;
  padding: 28px 24px;
}

/* ─── Views ─── */
.view { display: none; }
.view.active { display: block; }

/* ─── Mobile nav ─── */
.mobile-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--mobile-nav);
  background: var(--white);
  border-top: 1px solid var(--border);
  z-index: 200;
}

.mobile-nav-inner {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  width: 100%;
  height: 100%;
}

.mobile-nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 10px;
  font-weight: 500;
  padding: 6px 4px;
  cursor: pointer;
  width: 100%;
}

.mobile-nav-item svg { width: 20px; height: 20px; }
.mobile-nav-item.active { color: var(--green-main); }

/* ═══════════════════════════════════════════════════════
   COMPONENTS
   ═══════════════════════════════════════════════════════ */

/* ─── Buttons ─── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 9px 18px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  border: none;
  transition: all .15s;
  cursor: pointer;
  white-space: nowrap;
}

.btn svg { width: 16px; height: 16px; }

.btn-primary { background: var(--green-main); color: #fff; }
.btn-primary:hover { background: var(--green-dark); }

.btn-secondary { background: var(--white); color: var(--text-main); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--background); }

.btn-ghost { background: none; color: var(--text-muted); border: none; }
.btn-ghost:hover { background: var(--background); color: var(--text-main); }

.btn-danger { background: #FEF2F2; color: var(--red); border: 1px solid #FECACA; }
.btn-danger:hover { background: #FEE2E2; }

.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-lg { padding: 12px 24px; font-size: 15px; }

.btn:disabled { opacity: .5; cursor: not-allowed; }

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

/* ─── Stats cards ─── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  display: flex;
  align-items: flex-start;
  gap: 14px;
}

.stat-icon {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  background: var(--green-light);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.stat-icon svg { width: 22px; height: 22px; color: var(--green-main); }

.stat-body {}
.stat-label { font-size: 12px; color: var(--text-muted); font-weight: 500; }
.stat-value { font-size: 28px; font-weight: 800; color: var(--text-main); line-height: 1.1; margin: 3px 0; }

.stat-change {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 600;
  color: var(--green-main);
}

.stat-change.down { color: var(--red); }
.stat-meta { font-size: 11px; color: var(--text-muted); margin-top: 2px; }

/* ─── Section headers ─── */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.section-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 8px;
}

.section-title svg { width: 18px; height: 18px; color: var(--green-main); }

/* ─── Dashboard grid ─── */
/* ─── Banner de patrocinador ───
   Va entre las estadísticas y la rejilla del dashboard: es un descanso natural
   del scroll y no compite con ningún botón de acción.

   El alto se reserva con aspect-ratio ANTES de que cargue la imagen, para que
   el contenido de abajo no dé un salto al aparecer el anuncio. En escritorio se
   usa un creativo apaisado (tipo 970×90) y en móvil uno más compacto (320×100),
   que es lo que hace que se vea bien en ambos sitios: no es la misma imagen
   estirada, son dos piezas distintas. */
.sponsor-slot {
  margin-bottom: 24px;
}
.sponsor-slot[hidden] { display: none; }

/* El alto se fija AQUÍ, en el contenedor, con aspect-ratio — no en el <img>.
   Motivo real: en iOS Safari, cuando una imagen no carga (404), el "icono roto
   + texto alternativo" puede ignorar por completo el tamaño que le pusiéramos
   al <img> y crecer hasta ocupar cientos de píxeles (así se vio en un pantallazo
   real: una caja enorme en blanco con el icono roto arriba). Poniendo el tamaño
   en el contenedor — que no tiene ninguna imagen que pueda fallar — y colocando
   el <img> ABSOLUTO por dentro, el hueco no puede crecer pase lo que pase con
   la imagen. Además, `handleSponsorError` en script.js oculta el banner entero en
   cuanto detecta el fallo, así que ni siquiera debería llegar a verse el icono
   roto: esto es un cinturón de seguridad para el peor de los casos. */
.sponsor-banner {
  display: block;
  position: relative;
  /* Reducido de 90 a 52 de alto a petición: ocupaba demasiado en escritorio. */
  aspect-ratio: 970 / 52;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  text-decoration: none;
  transition: box-shadow .18s ease, transform .18s ease;
}
.sponsor-banner:hover      { box-shadow: var(--shadow-md); transform: translateY(-1px); }
.sponsor-banner:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}

.sponsor-banner picture {
  position: absolute;
  inset: 0;
  display: block;
}

.sponsor-banner img {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Etiqueta obligatoria: el usuario tiene que poder distinguir el anuncio del
   contenido propio de la app de un vistazo. */
.sponsor-label {
  position: absolute;
  top: 6px;
  left: 8px;
  z-index: 2;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--text-muted);
  background: rgba(255,255,255,.86);
  backdrop-filter: blur(2px);
  padding: 2px 7px;
  border-radius: 20px;
  pointer-events: none;
}

/* Móvil y tablet estrecha: creativo vertical más alto y compacto */
@media (max-width: 768px) {
  .sponsor-slot { margin-bottom: 16px; }
  .sponsor-banner { aspect-ratio: 320 / 100; }
  .sponsor-label { font-size: 8.5px; top: 5px; left: 6px; }
}

.dashboard-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 16px;
  margin-bottom: 24px;
}

.dashboard-grid-bottom {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 16px;
}

/* ─── Tables ─── */
.table-wrap { overflow-x: auto; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

th {
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .04em;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
}

td {
  padding: 12px 12px;
  border-bottom: 1px solid var(--border);
  color: var(--text-main);
  vertical-align: middle;
}

tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--background); }

/* ─── Badges ─── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
}

.badge-green  { background: var(--green-light); color: var(--green-dark); }
.badge-yellow { background: #FFFBEB; color: #92400E; }
.badge-red    { background: #FEF2F2; color: #991B1B; }
.badge-gray   { background: var(--background); color: var(--text-muted); }

.badge::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

/* ─── Forms ─── */
.form-group { margin-bottom: 16px; }

.form-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: .04em;
}

.form-control {
  width: 100%;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 13px;
  color: var(--text-main);
  outline: none;
  transition: border .15s, box-shadow .15s;
}

.form-control:focus {
  border-color: var(--green-main);
  box-shadow: 0 0 0 3px rgba(0,122,61,.10);
}

.form-control::placeholder { color: var(--text-muted); }

textarea.form-control { min-height: 120px; resize: vertical; }
select.form-control { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236B7280' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 32px; }

.form-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

/* ─── Modal ─── */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: fadeIn .15s;
}

.modal-backdrop.hidden { display: none; }

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.modal {
  background: var(--white);
  border-radius: 14px;
  padding: 28px;
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-md);
  animation: slideUp .2s;
}

.modal-lg { max-width: 720px; }

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

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.modal-title { font-size: 17px; font-weight: 700; }

.modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  padding: 4px;
  border-radius: 6px;
  font-size: 20px;
  line-height: 1;
}

.modal-close:hover { background: var(--background); color: var(--text-main); }

.modal-footer {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}

/* ─── Avatar initials ─── */
.avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--green-light);
  border: 2px solid var(--green-mid);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 13px;
  color: var(--green-dark);
  flex-shrink: 0;
  overflow: hidden;
}

.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar-sm { width: 28px; height: 28px; font-size: 11px; }
.avatar-lg { width: 52px; height: 52px; font-size: 18px; }

/* ─── Toast ─── */
.toast-container {
  position: fixed;
  bottom: 80px;
  right: 20px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  background: var(--text-main);
  color: #fff;
  padding: 12px 18px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 500;
  box-shadow: var(--shadow-md);
  animation: slideUp .2s;
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 240px;
}

.toast.success { background: var(--green-dark); }
.toast.error   { background: var(--red); }
.toast.warning { background: var(--yellow); }

/* ─── Progress bars ─── */
.progress-bar {
  height: 6px;
  background: var(--green-light);
  border-radius: 3px;
  overflow: hidden;
  margin-top: 6px;
}

.progress-fill {
  height: 100%;
  background: var(--green-main);
  border-radius: 3px;
  transition: width .4s;
}

/* ─── Transcription ─── */
.transcript-line {
  display: flex;
  gap: 10px;
  margin-bottom: 10px;
}

.transcript-time {
  font-size: 11px;
  color: var(--green-main);
  font-weight: 600;
  min-width: 38px;
  padding-top: 2px;
}

.transcript-text {
  font-size: 13px;
  color: var(--text-main);
  line-height: 1.6;
}

/* ─── Recording ─── */
.recording-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--red);
}

.rec-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--red);
  animation: pulse 1s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: .3; }
}

/* ─── Confirmación por pulsación larga (pausar/detener grabación) ─── */
.hold-confirm { position: relative; overflow: hidden; user-select: none; -webkit-user-select: none; touch-action: manipulation; }
.hold-fill {
  position: absolute; inset: 0;
  background: rgba(255,255,255,.4);
  transform-origin: left; transform: scaleX(0);
}
.hold-confirm.holding .hold-fill { transition: transform var(--hold-ms, 700ms) linear; transform: scaleX(1); }
.hold-label { position: relative; z-index: 1; }

/* ─── Sesión: aviso de grabación interrumpida ─── */
.recording-draft-banner {
  display: flex; align-items: center; gap: 12px;
  background: var(--gold-light); border: 1px solid var(--gold);
  border-radius: 10px; padding: 12px 16px; margin: 0 0 16px;
}
.recording-draft-banner-icon { font-size: 20px; flex-shrink: 0; }
.recording-draft-banner-text { flex: 1; font-size: 13px; color: var(--text-main); }
.recording-draft-banner-actions { display: flex; gap: 8px; flex-shrink: 0; }
@media (max-width: 640px) {
  .recording-draft-banner { align-items: flex-start; flex-wrap: wrap; padding: 12px; }
  .recording-draft-banner-text { min-width: calc(100% - 44px); }
  .recording-draft-banner-actions { width: 100%; flex-wrap: wrap; }
  .recording-draft-banner-actions .btn { flex: 1 1 auto; justify-content: center; }
}

/* ─── Session types ─── */
.session-type-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

.session-type-card {
  border: 2px solid var(--border);
  border-radius: 10px;
  padding: 14px;
  cursor: pointer;
  transition: all .15s;
}

.session-type-card:hover { border-color: var(--green-main); background: var(--green-light); }
.session-type-card.selected { border-color: var(--green-main); background: var(--green-light); }
.session-type-card .type-icon { font-size: 20px; margin-bottom: 6px; }
.session-type-card .type-name { font-size: 13px; font-weight: 600; }

/* ─── Audio input options ─── */
.audio-options {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

.audio-option {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 18px;
  text-align: center;
  cursor: pointer;
  transition: all .15s;
  background: var(--white);
}

.audio-option:hover { border-color: var(--green-main); background: var(--green-light); }
.audio-option.selected { border-color: var(--green-main); background: var(--green-light); }
.audio-option svg { width: 28px; height: 28px; color: var(--green-main); margin: 0 auto 8px; }
.audio-option .opt-title { font-size: 13px; font-weight: 600; }
.audio-option .opt-sub { font-size: 11px; color: var(--text-muted); margin-top: 2px; }

/* ─── Metrics bars ─── */
.metric-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.metric-label {
  width: 100px;
  font-size: 12px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 6px;
}

.metric-label svg { width: 14px; height: 14px; color: var(--green-main); }

.metric-bar-wrap {
  flex: 1;
  height: 8px;
  background: var(--green-light);
  border-radius: 4px;
  overflow: hidden;
}

.metric-bar-fill {
  height: 100%;
  background: var(--green-main);
  border-radius: 4px;
}

.metric-value {
  width: 60px;
  text-align: right;
  font-size: 13px;
  font-weight: 700;
}

/* ─── Plan weeks ─── */
.plan-weeks { display: flex; flex-direction: column; gap: 8px; }

.plan-week {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}

.plan-week:last-child { border-bottom: none; }

.plan-week-icon {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: var(--green-light);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.plan-week-icon svg { width: 18px; height: 18px; color: var(--green-main); }

.plan-week-info { flex: 1; }
.plan-week-title { font-size: 13px; font-weight: 600; }
.plan-week-sub { font-size: 11px; color: var(--text-muted); }

.plan-week-status {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.plan-week-status.done { background: var(--green-main); color: #fff; }
.plan-week-status.partial { border: 2px solid var(--green-main); position: relative; overflow: hidden; }
.plan-week-status.todo { background: var(--background); border: 2px solid var(--border); }

/* ─── Empty state ─── */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-muted);
}

.empty-state svg {
  width: 48px;
  height: 48px;
  color: var(--border);
  margin: 0 auto 14px;
}

.empty-state h3 { font-size: 16px; font-weight: 600; color: var(--text-main); margin-bottom: 6px; }
.empty-state p { font-size: 13px; margin-bottom: 20px; }

/* ─── Loading spinner ─── */
.spinner {
  width: 20px;
  height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--green-main);
  border-radius: 50%;
  animation: spin .7s linear infinite;
  flex-shrink: 0;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ─── Consent modal ─── */
.consent-modal-icon {
  width: 56px;
  height: 56px;
  background: var(--green-light);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 16px;
}

.consent-modal-icon svg { width: 28px; height: 28px; color: var(--green-main); }

/* ─── Page header ─── */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}

.page-title { font-size: 22px; font-weight: 800; }
.page-subtitle { font-size: 13px; color: var(--text-muted); margin-top: 3px; }

/* ─── Analysis result ─── */
.analysis-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
}

.analysis-header {
  background: var(--green-dark);
  color: #fff;
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.analysis-title { font-size: 16px; font-weight: 700; }
.analysis-cat { font-size: 11px; color: rgba(255,255,255,.7); margin-top: 3px; }

.analysis-body { padding: 20px; }
.analysis-section { margin-bottom: 16px; }
.analysis-section-title { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--text-muted); margin-bottom: 8px; }

/* ─── Dropdown ─── */
.dropdown { position: relative; }

.dropdown-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow-md);
  min-width: 160px;
  z-index: 500;
  overflow: hidden;
}

.dropdown-menu.hidden { display: none; }

.dropdown-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  font-size: 13px;
  color: var(--text-main);
  cursor: pointer;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
}

.dropdown-item:hover { background: var(--background); }
.dropdown-item.danger { color: var(--red); }
.dropdown-item svg { width: 16px; height: 16px; }

/* ─── Tabs ─── */
.tabs {
  display: flex;
  border-bottom: 2px solid var(--border);
  margin-bottom: 20px;
  gap: 4px;
}

.tab {
  padding: 10px 18px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  border: none;
  background: none;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: all .15s;
}

.tab:hover { color: var(--green-main); }
.tab.active { color: var(--green-main); border-bottom-color: var(--green-main); }

/* ─── Search bar ─── */
.search-bar {
  position: relative;
  flex: 1;
}

.search-bar input {
  width: 100%;
  padding: 9px 14px 9px 38px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
  background: var(--white);
  outline: none;
}

.search-bar input:focus { border-color: var(--green-main); }

.search-bar svg {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  color: var(--text-muted);
}

/* ─── Landing page ─── */
.landing-body { background: var(--white); }

.landing-hero {
  position: relative;
  overflow: hidden;
  background:
    radial-gradient(ellipse 900px 480px at 50% -10%, rgba(177,141,60,.10), transparent 60%),
    linear-gradient(160deg, var(--green-dark) 0%, var(--green-main) 60%, #0B4A28 100%);
  color: #fff;
  padding: 148px 24px 116px;
  text-align: center;
}

.hero-swoosh {
  position: absolute;
  top: -12%;
  right: -6%;
  width: 620px;
  max-width: 70vw;
  height: auto;
  opacity: .09;
  pointer-events: none;
}
.hero-swoosh-2 {
  position: absolute;
  bottom: -18%;
  left: -10%;
  width: 520px;
  max-width: 60vw;
  height: auto;
  opacity: .06;
  pointer-events: none;
}

.landing-logo { display: flex; align-items: center; justify-content: center; gap: 12px; margin-bottom: 40px; }
.landing-logo-icon { width: 52px; height: 52px; background: rgba(255,255,255,.2); border-radius: 12px; display: flex; align-items: center; justify-content: center; font-size: 26px; }
.landing-logo-text { font-size: 24px; font-weight: 800; }
.landing-logo-text strong { color: rgba(255,255,255,.7); }

.hero-eyebrow-gold {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  font-size: 12px;
  font-weight: 700;
  color: var(--gold);
  text-transform: uppercase;
  letter-spacing: .2em;
  margin-bottom: 28px;
}
.hero-eyebrow-gold::before, .hero-eyebrow-gold::after { content: ''; width: 36px; height: 1px; background: rgba(177,141,60,.55); }

.landing-hero h1 {
  position: relative;
  font-family: var(--font-brand);
  font-size: 70px;
  font-weight: 600;
  line-height: 1.1;
  letter-spacing: -.01em;
  margin-bottom: 26px;
}
.landing-hero h1 em { font-style: normal; color: rgba(255,255,255,.66); font-weight: 500; }

.landing-hero p { position: relative; font-size: 17.5px; color: rgba(255,255,255,.78); max-width: 540px; margin: 0 auto 42px; line-height: 1.7; font-weight: 400; }

.landing-cta { position: relative; display: flex; gap: 14px; justify-content: center; flex-wrap: wrap; }

.btn-white { background: var(--gold); color: var(--green-dark); font-weight: 700; }
.btn-white:hover { background: #C6A24D; }

.btn-outline-white { background: transparent; color: #fff; border: 1px solid rgba(255,255,255,.32); font-weight: 500; }
.btn-outline-white:hover { background: rgba(255,255,255,.08); border-color: rgba(255,255,255,.55); }

.hero-note { position: relative; margin-top: 30px; font-size: 12px; color: rgba(255,255,255,.42); letter-spacing: .03em; }

.landing-features { padding: 128px 24px 120px; max-width: 1140px; margin: 0 auto; }

.features-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 44px 36px; margin-top: 60px; }

.feature-card { padding: 0; }

.feature-icon {
  width: 54px; height: 54px;
  border: 1px solid var(--green-mid);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 22px;
  color: var(--green-main);
  transition: border-color .2s, background-color .2s;
}
.feature-icon svg { width: 22px; height: 22px; stroke-width: 1.4; }
.feature-card:hover .feature-icon { border-color: var(--gold); background: var(--gold-light); }

.feature-card h3 { font-family: var(--font-brand); font-size: 20px; font-weight: 700; margin-bottom: 9px; color: var(--text-main); }
.feature-card p { font-size: 13.5px; color: var(--text-muted); line-height: 1.75; }

.landing-steps { background: var(--green-light); padding: 128px 24px 120px; }

.steps-grid { position: relative; display: grid; grid-template-columns: repeat(5, 1fr); gap: 20px; max-width: 1080px; margin: 60px auto 0; }
.steps-grid::before {
  content: '';
  position: absolute;
  top: 23px; left: 11%; right: 11%; height: 1px;
  background-image: linear-gradient(90deg, var(--gold) 40%, transparent 40%);
  background-size: 12px 1px;
  opacity: .55;
}

.step-item { position: relative; text-align: center; }
.step-num {
  position: relative; z-index: 1;
  width: 46px; height: 46px;
  background: var(--white);
  border: 1.5px solid var(--gold);
  color: var(--green-dark);
  border-radius: 50%;
  font-family: var(--font-brand);
  font-weight: 700; font-size: 21px;
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 18px;
}
.step-item h4 { font-size: 13.5px; font-weight: 700; margin-bottom: 7px; color: var(--text-main); }
.step-item p { font-size: 12px; color: var(--text-muted); line-height: 1.65; }

.landing-footer { background: var(--green-dark); color: rgba(255,255,255,.5); text-align: center; padding: 34px 24px; font-size: 12px; border-top: 1px solid rgba(177,141,60,.22); }

/* ─── Login ─── */
.login-body { background: var(--background); min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }

.login-card { background: var(--white); border: 1px solid var(--border); border-radius: 16px; padding: 40px; width: 100%; max-width: 420px; box-shadow: var(--shadow-md); }

.login-logo { text-align: center; margin-bottom: 32px; }
.login-logo-icon { width: 56px; height: 56px; border-radius: 14px; overflow: hidden; display: flex; align-items: center; justify-content: center; margin: 0 auto 12px; }
.login-logo-icon img { width: 100%; height: 100%; }
.login-logo-text { font-family: var(--font-brand); font-size: 30px; font-weight: 700; }

.login-tabs { display: flex; gap: 0; margin-bottom: 28px; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.login-tab { flex: 1; padding: 10px; font-size: 13px; font-weight: 600; text-align: center; background: none; border: none; color: var(--text-muted); cursor: pointer; }
.login-tab.active { background: var(--green-main); color: #fff; }

.login-footer { text-align: center; margin-top: 20px; font-size: 12px; color: var(--text-muted); }
.login-footer a { color: var(--green-main); font-weight: 600; }

/* ═══════════════════════════════════════════════════════
   RESPONSIVE
   ═══════════════════════════════════════════════════════ */

@media (max-width: 1024px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .dashboard-grid { grid-template-columns: 1fr 1fr; }
  .dashboard-grid-bottom { grid-template-columns: 1fr 1fr; }
  .features-grid { grid-template-columns: 1fr 1fr; }
  .steps-grid { grid-template-columns: repeat(3, 1fr); }
  .steps-grid::before { display: none; }
  .landing-hero h1 { font-size: 52px; }
}

@media (max-width: 768px) {
  /* Layout */
  .sidebar { display: none; }
  .mobile-nav { display: flex; }
  .page-content { padding: 12px; padding-bottom: calc(var(--mobile-nav) + 12px); }

  /* Detalle de sesión: campos de edición en una sola columna */
  #detail-edit-fields { grid-template-columns: 1fr !important; }

  /* Header móvil */
  .app-header { padding: 0 12px; gap: 10px; }
  .header-collapse-btn { display: none; }
  .header-search { max-width: none; flex: 1; }
  .header-kbd { display: none; }
  .header-search input { font-size: 14px; padding: 8px 12px 8px 34px; }
  .user-info { display: none; }
  .header-user { padding: 4px; }
  .user-avatar { width: 36px; height: 36px; font-size: 15px; }

  /* Nav móvil — centrado */
  .mobile-nav-inner {
    display: flex;
    width: 100%;
    justify-content: space-around;
    align-items: stretch;
  }
  .mobile-nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-width: 0;
  }

  /* Dashboard */
  .stats-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .dashboard-grid { grid-template-columns: 1fr; }
  .dashboard-grid-bottom { grid-template-columns: 1fr; }

  /* Cards y listas */
  .card { border-radius: 10px; }
  .section-header { flex-wrap: wrap; gap: 8px; }
  .section-header .btn { font-size: 12px; padding: 6px 12px; }

  /* Tablas — ocultar columnas marcadas en móvil */
  .col-hide-mobile { display: none; }
  #students-table-body tr td:nth-child(4),
  #students-table-body tr td:nth-child(5),
  #sessions-table-body tr td:nth-child(4) { display: none; }

  /* Botones de acción: más compactos */
  .data-table .btn-sm, #students-table .btn-sm, #sessions-table .btn-sm {
    padding: 4px 8px; font-size: 11px;
  }

  /* Formularios */
  .form-grid-2 { grid-template-columns: 1fr; }
  /* Las cuatro entradas principales caben mejor en una matriz 2 × 2.
     En una sola columna obligaban a recorrer casi una pantalla completa. */
  .audio-options { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .session-type-grid { grid-template-columns: 1fr; }

  /* Modales */
  .modal-overlay { padding: 0; align-items: flex-end; }
  .modal {
    border-radius: 16px 16px 0 0;
    max-height: 92vh;
    overflow-y: auto;
    padding: 20px 16px 32px;
    width: 100%;
    max-width: 100%;
  }

  /* Tablas en móvil: cada fila se convierte en una tarjeta.
     Una tabla con scroll lateral deja los botones de acción fuera de
     pantalla, así que en móvil se apila todo en vertical. */
  .table-wrap { overflow-x: visible; }

  .data-table thead,
  #students-table thead,
  #sessions-table thead,
  #dashboard-students-table thead { display: none; }   /* las cabeceras no aplican al apilar */

  .data-table, .data-table tbody, .data-table tr, .data-table td,
  #students-table, #students-table tbody, #students-table tr, #students-table td,
  #sessions-table, #sessions-table tbody, #sessions-table tr, #sessions-table td,
  #dashboard-students-table, #dashboard-students-table tbody,
  #dashboard-students-table tr, #dashboard-students-table td {
    display: block;
    width: 100%;
  }

  .data-table tr,
  #students-table tbody tr,
  #sessions-table tbody tr,
  #dashboard-students-table tbody tr {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 12px 14px;
    margin-bottom: 10px;
  }

  .data-table td,
  #students-table td,
  #sessions-table td,
  #dashboard-students-table td {
    border: none;
    padding: 3px 0;
    font-size: 13px;
    white-space: normal;          /* el texto largo puede partir línea */
    text-align: left !important;
  }

  /* La celda de acciones: botones en fila, sin recortar */
  .data-table tbody td:last-child,
  #students-table tbody td:last-child,
  #sessions-table tbody td:last-child {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding-top: 10px;
    margin-top: 8px;
    border-top: 1px solid var(--border);
  }
  /* Los botones se ajustan a su texto y saltan de línea si hace falta:
     forzarlos todos al mismo ancho recortaba etiquetas como «+ Sesión». */
  .data-table tbody td:last-child .btn,
  #students-table tbody td:last-child .btn,
  #sessions-table tbody td:last-child .btn {
    flex: 0 1 auto;
    justify-content: center;
    white-space: nowrap;
    padding: 7px 12px;
  }

  /* Las celdas vacías no dejan huecos sueltos */
  .data-table td:empty,
  #students-table td:empty,
  #sessions-table td:empty,
  #dashboard-students-table td:empty { display: none; }

  /* Fichas de alumnos */
  .students-grid { grid-template-columns: 1fr; }

  /* Landing */
  .landing-hero { padding: 108px 20px 88px; }
  .landing-hero h1 { font-size: 38px; }
  .landing-features, .landing-steps { padding-left: 20px; padding-right: 20px; }
  .features-grid { grid-template-columns: 1fr; }
  .steps-grid { grid-template-columns: 1fr 1fr; }
  .hero-eyebrow-gold { font-size: 10.5px; letter-spacing: .14em; }
  .hero-eyebrow-gold::before, .hero-eyebrow-gold::after { width: 22px; }

  /* Página de perfil alumno */
  .profile-tabs { overflow-x: auto; -webkit-overflow-scrolling: touch; white-space: nowrap; }
  .profile-tab { flex-shrink: 0; }
}

@media (max-width: 480px) {
  /* Stats en 1 columna en pantallas muy pequeñas */
  .stats-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
  .stat-card { padding: 14px; }
  .stat-value { font-size: 24px; }
  .stat-label { font-size: 11px; }

  /* Header más compacto */
  .app-header { padding: 0 10px; }
  .header-search { display: none; }
  .header-mobile-logo { display: flex; }

  /* Modal full screen en móvil pequeño */
  .modal { padding: 16px 14px 28px; }
  .modal-footer { flex-direction: column; gap: 8px; }
  .modal-footer .btn { width: 100%; justify-content: center; }

  /* Botones grandes */
  .btn-lg { width: 100%; justify-content: center; }

  /* Nav items más compactos */
  .mobile-nav-item { font-size: 9px; gap: 2px; }
  .mobile-nav-item svg { width: 18px; height: 18px; }
}

/* ═══════════════════════════════════════════════════════════
   MÓDULO REDES SOCIALES
═══════════════════════════════════════════════════════════ */

/* Sub-navegación */
.social-subnav {
  display: flex;
  gap: 4px;
  margin-bottom: 24px;
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
}
.social-tab {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  padding: 10px 16px;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  white-space: nowrap;
  transition: color .15s, border-color .15s;
  margin-bottom: -1px;
}
.social-tab:hover { color: var(--text-main); }
.social-tab.active { color: var(--green-main); border-bottom-color: var(--green-main); }

/* Paneles de sub-tab */
.social-panel { display: none; }
.social-panel.active { display: block; animation: socialFade .25s ease; }
@keyframes socialFade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

/* CTA principal del panel */
.social-hero-cta {
  display: flex;
  align-items: center;
  gap: 16px;
  background: linear-gradient(135deg, var(--green-main), var(--green-dark));
  border-radius: var(--radius);
  padding: 24px 28px;
  cursor: pointer;
  margin-bottom: 20px;
  box-shadow: var(--shadow);
  transition: transform .15s, box-shadow .15s;
}
.social-hero-cta:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.social-hero-arrow {
  font-size: 26px;
  color: #fff;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: rgba(255,255,255,.18);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: transform .15s;
}
.social-hero-cta:hover .social-hero-arrow { transform: translateX(4px); }

/* Widgets */
.social-widgets {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 16px;
}
.social-widgets-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
@media (max-width: 900px) { .social-widgets-3 { grid-template-columns: 1fr 1fr; } }
@media (max-width: 640px) { .social-widgets-3 { grid-template-columns: 1fr; } }
.social-widget { min-height: 120px; }
.social-widget-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}
.social-widget-title { font-size: 13.5px; font-weight: 700; color: var(--text-main); }
.social-empty-mini { font-size: 12.5px; color: var(--text-muted); padding: 8px 0; }

/* Placeholder */
.social-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 48px 24px;
}

/* Campo de color de marca */
.brand-color-field { display: flex; gap: 8px; align-items: center; }
.brand-color-field input[type="color"] {
  width: 44px;
  height: 40px;
  padding: 2px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  cursor: pointer;
  flex-shrink: 0;
}
.brand-color-field .form-control { flex: 1; font-family: monospace; text-transform: uppercase; }

/* Toggle de marca */
.brand-toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  font-size: 13.5px;
  color: var(--text-main);
}
.brand-toggle input { width: 18px; height: 18px; cursor: pointer; accent-color: var(--green-main); }

/* Tags de marca */
.brand-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.brand-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  padding: 4px 10px;
  background: var(--green-light);
  color: var(--green-dark);
  border-radius: 16px;
  font-weight: 500;
}
.brand-tag button {
  background: none;
  border: none;
  color: var(--green-dark);
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  padding: 0;
  opacity: .6;
}
.brand-tag button:hover { opacity: 1; }

@media (max-width: 640px) {
  .social-widgets { grid-template-columns: 1fr; }
}

/* ═══════════════════════════════════════════════════════════
   PROGRESO DE GENERACIÓN DE FICHA
═══════════════════════════════════════════════════════════ */
.cardprog-spinner {
  width: 44px;
  height: 44px;
  margin: 8px auto 0;
  border: 3px solid var(--green-light);
  border-top-color: var(--green-main);
  border-radius: 50%;
  animation: cardprogSpin .9s linear infinite;
}
@keyframes cardprogSpin { to { transform: rotate(360deg); } }

.cardprog-track {
  height: 6px;
  background: var(--green-light);
  border-radius: 20px;
  overflow: hidden;
  margin-top: 18px;
}
.cardprog-bar {
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--green-main), var(--green-dark));
  border-radius: 20px;
  transition: width .5s ease;
}

@media (prefers-reduced-motion: reduce) {
  .cardprog-spinner { animation-duration: 2.5s; }
  .cardprog-bar { transition: none; }
}

/* ═══════════════════════════════════════════════════════════
   BUSCADOR Y ETIQUETAS DE FICHAS (perfil del alumno)
═══════════════════════════════════════════════════════════ */
.cards-search {
  position: relative;
  display: flex;
  align-items: center;
}
.cards-search svg {
  position: absolute;
  left: 11px;
  width: 15px;
  height: 15px;
  color: var(--text-muted);
  pointer-events: none;
}
.cards-search input {
  width: 100%;
  padding: 9px 32px 9px 34px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
  font-family: inherit;
  color: var(--text-main);
  background: var(--white);
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.cards-search input:focus {
  border-color: var(--green-main);
  box-shadow: 0 0 0 3px rgba(0,122,61,.1);
}
.cards-search button {
  position: absolute;
  right: 8px;
  border: none;
  background: none;
  color: var(--text-muted);
  font-size: 14px;
  cursor: pointer;
  padding: 2px 4px;
  line-height: 1;
  display: none;
}
.cards-search button:hover { color: var(--text-main); }
.cards-search.has-text button { display: block; }

/* Etiquetas por categoría */
.cards-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}
.cards-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  padding: 5px 11px;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: var(--white);
  color: var(--text-muted);
  cursor: pointer;
  transition: all .15s;
  font-family: inherit;
}
.cards-tag:hover {
  border-color: var(--green-main);
  color: var(--green-main);
}
.cards-tag.active {
  background: var(--green-main);
  border-color: var(--green-main);
  color: #fff;
}
.cards-tag .tag-count {
  font-size: 10.5px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 10px;
  background: var(--green-light);
  color: var(--green-dark);
  font-variant-numeric: tabular-nums;
}
.cards-tag.active .tag-count {
  background: rgba(255,255,255,.24);
  color: #fff;
}

/* ═══════════════════════════════════════════════════════════
   REDES SOCIALES · ASISTENTE DE CREACIÓN
═══════════════════════════════════════════════════════════ */
.wiz-steps { display: flex; gap: 6px; margin-bottom: 18px; flex-wrap: wrap; }
.wiz-step {
  display: flex; align-items: center; gap: 7px;
  font-size: 12.5px; font-weight: 600; color: var(--text-muted);
  padding: 7px 13px; border-radius: 20px; background: var(--white);
  border: 1px solid var(--border); transition: all .15s;
}
.wiz-step.active { border-color: var(--green-main); color: var(--green-main); }
.wiz-step.done { background: var(--green-light); border-color: var(--green-mid); color: var(--green-dark); }
.wiz-num {
  width: 19px; height: 19px; border-radius: 50%;
  background: var(--border); color: var(--white);
  display: flex; align-items: center; justify-content: center;
  font-size: 10.5px; font-weight: 800; flex-shrink: 0;
}
.wiz-step.active .wiz-num { background: var(--green-main); }
.wiz-step.done .wiz-num { background: var(--green-main); }

.wiz-panel { display: none; }
.wiz-panel.active { display: block; animation: socialFade .25s ease; }
.wiz-nav { display: flex; justify-content: space-between; align-items: center; margin-top: 16px; gap: 10px; }

/* Fuentes */
.src-tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 14px; overflow-x: auto; }
.src-tab {
  background: none; border: none; border-bottom: 2px solid transparent;
  padding: 8px 12px; font-size: 12.5px; font-weight: 600; color: var(--text-muted);
  cursor: pointer; white-space: nowrap; margin-bottom: -1px; font-family: inherit;
}
.src-tab:hover { color: var(--text-main); }
.src-tab.active { color: var(--green-main); border-bottom-color: var(--green-main); }

.src-list { max-height: 240px; overflow-y: auto; display: flex; flex-direction: column; gap: 6px; }
.src-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 11px; border: 1px solid var(--border); border-radius: 8px;
  cursor: pointer; transition: all .12s; background: var(--white);
}
.src-item:hover { border-color: var(--green-main); background: var(--green-light); }
.src-item.sel { border-color: var(--green-main); background: var(--green-light); }
.src-check {
  width: 17px; height: 17px; border-radius: 4px; border: 1.5px solid var(--border);
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
  font-size: 11px; color: var(--white); background: var(--white);
}
.src-item.sel .src-check { background: var(--green-main); border-color: var(--green-main); }
.src-title { font-size: 12.5px; font-weight: 600; color: var(--text-main); }
.src-sub { font-size: 11px; color: var(--text-muted); margin-top: 1px; }
.src-empty { font-size: 12.5px; color: var(--text-muted); padding: 20px; text-align: center; }

.wiz-selected { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.wiz-chip {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 11.5px; font-weight: 500; padding: 4px 10px;
  background: var(--green-main); color: #fff; border-radius: 16px;
}
.wiz-chip button { background: none; border: none; color: #fff; cursor: pointer; font-size: 13px; line-height: 1; padding: 0; opacity: .75; }
.wiz-chip button:hover { opacity: 1; }

/* Objetivo y formato */
.sr-only {
  position: absolute !important; width: 1px !important; height: 1px !important;
  padding: 0 !important; margin: -1px !important; overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important; white-space: nowrap !important; border: 0 !important;
}
.objective-guidance {
  display: flex; align-items: flex-start; gap: 10px; margin: 0 0 16px;
  padding: 11px 13px; border: 1px solid #d7e7df; border-radius: 10px;
  background: #f5faf7; color: var(--green-dark);
}
.objective-guidance-icon { font-size: 17px; line-height: 1.25; }
.objective-guidance div { display: flex; flex-direction: column; gap: 2px; }
.objective-guidance strong { font-size: 12px; }
.objective-guidance span:not(.objective-guidance-icon) { font-size: 11.5px; line-height: 1.45; color: var(--text-muted); }
.obj-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.obj-opt, .fmt-opt {
  position: relative;
  display: flex; flex-direction: column; align-items: flex-start; gap: 4px;
  padding: 13px; border: 1.5px solid var(--border); border-radius: 10px;
  background: var(--white); cursor: pointer; text-align: left;
  transition: all .15s; font-family: inherit;
}
.obj-opt:hover, .fmt-opt:hover { border-color: var(--green-main); }
.obj-opt.active, .fmt-opt.active { border-color: var(--green-main); background: var(--green-light); }
.obj-ico { font-size: 19px; }
.obj-name { font-size: 12.5px; font-weight: 700; color: var(--text-main); }
.obj-desc { font-size: 11px; color: var(--text-muted); line-height: 1.4; }
.objective-role {
  position: absolute; top: 8px; right: 8px; padding: 2px 7px;
  border-radius: 999px; background: var(--green-main); color: #fff;
  font-size: 8.5px; font-weight: 800; letter-spacing: .04em; text-transform: uppercase;
}
.objective-secondary {
  margin-top: 16px; padding: 15px; border: 1px solid var(--border);
  border-radius: 11px; background: #fbfcfb;
}
.objective-secondary-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.objective-secondary-head > div { display: flex; flex-direction: column; gap: 2px; }
.objective-secondary-head strong { font-size: 12.5px; color: var(--text-main); }
.objective-secondary-head span { font-size: 10.5px; color: var(--text-muted); }
.objective-optional { padding: 3px 8px; border-radius: 999px; background: var(--green-light); color: var(--green-main) !important; font-weight: 700; }
.objective-recommendations { display: flex; align-items: center; flex-wrap: wrap; gap: 7px; }
.objective-recommendations > span { font-size: 10.5px; color: var(--text-muted); }
.objective-rec {
  border: 1px solid var(--green-mid); border-radius: 999px; padding: 6px 11px;
  background: #fff; color: var(--green-dark); font: 600 10.5px/1.2 inherit; cursor: pointer;
}
.objective-rec:hover, .objective-rec.active { background: var(--green-main); border-color: var(--green-main); color: #fff; }
.objective-secondary-note { margin-top: 9px; font-size: 10.5px; line-height: 1.45; color: var(--text-muted); }
.objective-secondary-note.active { color: var(--green-main); font-weight: 600; }
.format-objective-summary {
  margin: -2px 0 14px; padding: 8px 10px; border-radius: 8px;
  background: var(--green-light); color: var(--green-dark); font-size: 11.5px;
}
.format-objective-summary span { margin-left: 3px; padding: 2px 6px; border-radius: 999px; background: #fff; color: var(--text-muted); font-size: 9px; text-transform: uppercase; letter-spacing: .04em; }

.fmt-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.net-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.net-opt {
  display: flex; align-items: center; justify-content: center; gap: 7px;
  padding: 12px; border: 1.5px solid var(--border); border-radius: 10px;
  background: var(--white); cursor: pointer; font-size: 12.5px; font-weight: 600;
  color: var(--text-main); font-family: inherit; transition: all .15s;
}
.net-opt svg { width: 17px; height: 17px; }
.net-opt.active { border-color: var(--green-main); background: var(--green-light); color: var(--green-main); }
.net-opt.disabled { opacity: .45; cursor: not-allowed; font-size: 11px; color: var(--text-muted); }

.slides-row { display: flex; align-items: center; gap: 14px; }
.slides-row input[type="range"] { flex: 1; accent-color: var(--green-main); }
.slides-val {
  min-width: 34px; text-align: center; font-weight: 800; font-size: 15px;
  color: var(--green-main); font-variant-numeric: tabular-nums;
}

/* Vista previa */
.prev-wrap { display: grid; grid-template-columns: 320px 1fr; gap: 18px; align-items: start; }
.ig-mock {
  border: 1px solid var(--border); border-radius: 12px; overflow: hidden;
  background: var(--white); box-shadow: var(--shadow);
}
.ig-bar { display: flex; align-items: center; gap: 8px; padding: 9px 11px; }
.ig-ava { width: 27px; height: 27px; border-radius: 50%; background: var(--green-main); color: #fff; display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 800; overflow: hidden; }
.ig-ava img { width: 100%; height: 100%; object-fit: cover; }
.ig-user { font-size: 12px; font-weight: 700; color: var(--text-main); }
.ig-img { width: 100%; aspect-ratio: 1/1; object-fit: cover; background: var(--green-light); display: block; }
.ig-img.story { aspect-ratio: 9/16; }
.ig-actions { display: flex; gap: 12px; padding: 9px 11px; font-size: 16px; }
.ig-caption { padding: 0 11px 12px; font-size: 12px; color: var(--text-main); line-height: 1.5; white-space: pre-wrap; }
.ig-tags { color: var(--green-main); font-size: 11.5px; }
.ig-img-wrap { position: relative; }
.ig-arrow {
  position: absolute; top: 50%; transform: translateY(-50%);
  width: 30px; height: 30px; border-radius: 50%; border: none;
  background: rgba(0,0,0,.45); color: #fff; font-size: 16px; line-height: 1;
  display: flex; align-items: center; justify-content: center; cursor: pointer;
  z-index: 2; transition: background .15s;
}
.ig-arrow:hover { background: rgba(0,0,0,.65); }
.ig-arrow-left { left: 8px; }
.ig-arrow-right { right: 8px; }
.ig-slide-count {
  position: absolute; top: 8px; right: 8px; z-index: 2;
  background: rgba(0,0,0,.45); color: #fff; font-size: 10.5px; font-weight: 700;
  padding: 2px 8px; border-radius: 10px;
}

.prev-field { margin-bottom: 14px; }
.prev-label { font-size: 10.5px; font-weight: 800; color: var(--text-muted); letter-spacing: .09em; text-transform: uppercase; margin-bottom: 5px; }
.emoji-picker-wrap { position: relative; display: inline-block; }
.emoji-panel {
  position: absolute; z-index: 20; top: 100%; left: 0; margin-top: 6px;
  display: grid; grid-template-columns: repeat(8, 1fr); gap: 2px;
  background: var(--white); border: 1px solid var(--border); border-radius: 10px;
  box-shadow: var(--shadow); padding: 8px; width: 232px;
}
.emoji-panel button {
  border: none; background: transparent; font-size: 18px; padding: 4px;
  border-radius: 6px; cursor: pointer; line-height: 1;
}
.emoji-panel button:hover { background: var(--bg); }
.prev-why { background: var(--green-light); border: 1px solid var(--green-mid); border-radius: 8px; padding: 11px 13px; font-size: 12px; color: var(--green-dark); line-height: 1.5; }

/* ═══════════════════════════════════════════════════════════
   REDES SOCIALES · BIBLIOTECA
═══════════════════════════════════════════════════════════ */
.lib-filters { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.lib-filters .form-control { font-size: 12.5px; padding: 8px 10px; }
.lib-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.lib-card {
  border: 1px solid var(--border); border-radius: 10px; overflow: hidden;
  background: var(--white); display: flex; flex-direction: column;
  transition: box-shadow .15s, transform .15s;
}
.lib-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }
.lib-thumb { width: 100%; aspect-ratio: 1/1; object-fit: cover; background: var(--green-light); display: block; }
.lib-thumb-ph { width: 100%; aspect-ratio: 1/1; background: var(--green-light); display: flex; align-items: center; justify-content: center; font-size: 26px; }
.lib-body { padding: 11px 12px; flex: 1; display: flex; flex-direction: column; gap: 6px; }
.lib-head { font-size: 12.5px; font-weight: 700; color: var(--text-main); line-height: 1.35; }
.lib-meta { font-size: 10.5px; color: var(--text-muted); display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.lib-acts { display: flex; gap: 5px; padding: 0 12px 11px; flex-wrap: wrap; }
.lib-acts .btn { font-size: 11px; padding: 5px 8px; }

.st-chip { font-size: 10px; font-weight: 700; padding: 2px 7px; border-radius: 10px; white-space: nowrap; }
.st-generating { background: #FEF3C7; color: #92400E; }
.st-draft      { background: #F3F4F6; color: #4B5563; }
.st-scheduled  { background: #DBEAFE; color: #1E40AF; }
.st-published  { background: var(--green-light); color: var(--green-main); }
.st-error      { background: #FEE2E2; color: var(--red); }
.st-archived   { background: #F3F4F6; color: #9CA3AF; }

/* ═══════════════════════════════════════════════════════════
   REDES SOCIALES · CALENDARIO
═══════════════════════════════════════════════════════════ */
.cal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; gap: 10px; flex-wrap: wrap; }
.cal-nav { display: flex; align-items: center; gap: 8px; }
.cal-title { font-size: 15px; font-weight: 800; color: var(--text-main); min-width: 150px; text-align: center; text-transform: capitalize; }
.cal-views { display: flex; gap: 4px; }
.cal-view {
  background: none; border: 1px solid var(--border); border-radius: 7px;
  padding: 6px 13px; font-size: 12.5px; font-weight: 600; color: var(--text-muted);
  cursor: pointer; font-family: inherit;
}
.cal-view.active { background: var(--green-main); border-color: var(--green-main); color: #fff; }

.cal-legend { display: flex; gap: 14px; flex-wrap: wrap; margin-bottom: 12px; font-size: 11px; color: var(--text-muted); }
.cal-legend span { display: flex; align-items: center; gap: 5px; }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.dot-scheduled { background: #3B82F6; }
.dot-published { background: var(--green-main); }
.dot-draft     { background: #9CA3AF; }
.dot-error     { background: var(--red); }

/* minmax(0,1fr) para que las 7 columnas puedan encoger en móvil */
.cal-month { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 1px; background: var(--border); border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.cal-dow { background: var(--background); padding: 7px 4px; text-align: center; font-size: 10.5px; font-weight: 800; color: var(--text-muted); text-transform: uppercase; letter-spacing: .06em; }
.cal-day { background: var(--white); min-height: 88px; padding: 5px; display: flex; flex-direction: column; gap: 3px; }
.cal-day.out { background: #FAFBFA; }
.cal-day.today .cal-daynum { background: var(--green-main); color: #fff; }
.cal-daynum {
  font-size: 11px; font-weight: 700; color: var(--text-muted);
  width: 20px; height: 20px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-variant-numeric: tabular-nums;
}
.cal-ev {
  font-size: 10px; padding: 3px 5px; border-radius: 4px; cursor: pointer;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  border-left: 3px solid; background: var(--background); color: var(--text-main);
}
.cal-ev:hover { filter: brightness(.96); }
.cal-ev.scheduled { border-color: #3B82F6; background: #EFF6FF; }
.cal-ev.published { border-color: var(--green-main); background: var(--green-light); }
.cal-ev.draft     { border-color: #9CA3AF; }
.cal-ev.error     { border-color: var(--red); background: #FEF2F2; }

.cal-week { display: flex; flex-direction: column; gap: 8px; }
.cal-wday { display: grid; grid-template-columns: 100px 1fr; gap: 12px; padding: 10px; border: 1px solid var(--border); border-radius: 8px; }
.cal-wday.today { border-color: var(--green-main); background: var(--green-light); }
.cal-wdate { font-size: 12px; font-weight: 700; color: var(--text-main); text-transform: capitalize; }
.cal-wevs { display: flex; flex-direction: column; gap: 5px; }

@media (max-width: 900px) {
  .prev-wrap { grid-template-columns: 1fr; }
  .lib-grid { grid-template-columns: repeat(2, 1fr); }
  .obj-grid, .net-grid { grid-template-columns: repeat(2, 1fr); }
  .lib-filters { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 640px) {
  .lib-grid, .fmt-grid, .obj-grid, .net-grid { grid-template-columns: 1fr; }
  .cal-day { min-height: 64px; }
  .cal-wday { grid-template-columns: 1fr; }
}

/* ═══════════════════════════════════════════════════════════
   MÓVIL · CORRECCIONES DE DESBORDE Y PWA
   Las rejillas con `1fr` no pueden encoger por debajo del ancho
   de su contenido: por eso se salían de la pantalla y quedaban
   recortadas. `minmax(0,1fr)` sí permite que encojan.
═══════════════════════════════════════════════════════════ */

/* Nada debe provocar scroll lateral en toda la app */
html, body { max-width: 100%; overflow-x: hidden; }
.page-content, .view { min-width: 0; max-width: 100%; }

@media (max-width: 768px) {

  /* ── Rejillas: permitir que encojan ───────────────────── */
  .stats-grid,
  .dashboard-grid,
  .dashboard-grid-bottom,
  .form-grid-2,
  .students-grid,
  .audio-options,
  .session-type-grid { grid-template-columns: minmax(0, 1fr); }

  .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }

  /* ── Módulo Redes Sociales ────────────────────────────── */
  .social-widgets,
  .lib-grid,
  .obj-grid,
  .fmt-grid,
  .net-grid,
  .prev-wrap        { grid-template-columns: minmax(0, 1fr); }
  .lib-filters      { grid-template-columns: repeat(2, minmax(0, 1fr)); }

  .social-widget    { min-width: 0; }
  .social-widget-head { flex-wrap: wrap; gap: 6px; }

  /* Sub-navegación: se desliza en horizontal sin barra visible */
  .social-subnav { -webkit-overflow-scrolling: touch; scrollbar-width: none; }
  .social-subnav::-webkit-scrollbar { display: none; }
  .social-tab { padding: 10px 12px; font-size: 13px; }

  /* Asistente de creación */
  .wiz-steps { gap: 5px; }
  .wiz-step  { font-size: 11.5px; padding: 6px 10px; }
  .wiz-nav   { flex-direction: column-reverse; gap: 8px; }
  .wiz-nav .btn { width: 100%; justify-content: center; }
  .src-tabs { scrollbar-width: none; }
  .src-tabs::-webkit-scrollbar { display: none; }
  .src-list { max-height: 260px; }

  /* Vista previa: la maqueta de Instagram no debe desbordar */
  .ig-mock { max-width: 100%; }
  .prev-wrap > div { min-width: 0; }

  /* Calendario: el mes cabe entero, los eventos se reducen */
  .cal-head   { flex-direction: column; align-items: stretch; }
  .cal-nav    { justify-content: space-between; }
  .cal-views  { justify-content: center; }
  .cal-day    { min-height: 58px; padding: 3px; }
  .cal-daynum { font-size: 10px; width: 17px; height: 17px; }
  .cal-ev     { font-size: 8.5px; padding: 2px 3px; }
  .cal-dow    { font-size: 9px; padding: 5px 2px; }
  .cal-wday   { grid-template-columns: minmax(0, 1fr); }

  /* Biblioteca: las acciones no se recortan */
  .lib-acts { gap: 6px; }
  .lib-acts .btn { flex: 1 1 auto; justify-content: center; }

  /* Cabecera de modal: nombre y botones se apilan en vez de
     salirse por la derecha (el botón ✕ quedaba fuera de pantalla). */
  .modal-header { flex-wrap: wrap; gap: 10px; }
  .modal-header > div { min-width: 0; max-width: 100%; }
  .modal-header > div:last-child { width: 100%; flex-wrap: wrap; }
  .modal-header > div:last-child .btn { flex: 1 1 auto; justify-content: center; }
  /* El aspa vuelve a su sitio: arriba a la derecha, sin ocupar fila */
  #modal-student-profile .modal-header { position: relative; padding-right: 34px; }
  #modal-student-profile .modal-close { position: absolute; top: 0; right: 0; }

  /* Pestañas de modales (perfil del alumno, sesión): se deslizan
     en horizontal en vez de salirse de la pantalla. */
  .tabs {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    flex-wrap: nowrap;
    scrollbar-width: none;
  }
  .tabs::-webkit-scrollbar { display: none; }
  .tabs .tab { flex-shrink: 0; white-space: nowrap; }

  /* Las tarjetas de Conocimientos son 3 líneas de texto (sin icono):
     con flex en fila se salían de la tarjeta, deben apilarse. */
  #view-knowledge .stat-card { flex-direction: column; align-items: flex-start; gap: 2px; }
  #view-knowledge .stat-sub { font-size: 11px; line-height: 1.35; }

  /* Zona táctil mínima: con el dedo, los botones de 27-30px se fallan
     constantemente. 40px es el mínimo cómodo en cualquier smartphone. */
  .btn, .btn-sm, .mobile-nav-item, .tab, .social-tab, .src-tab {
    min-height: 40px;
  }
  .btn-sm { padding-top: 8px; padding-bottom: 8px; }
  /* Los botones de solo icono se mantienen cuadrados */
  .btn-icon, .modal-close { min-width: 40px; }

  /* ── Cabeceras de sección y botones ───────────────────── */
  .page-header {
    flex-direction: column;
    align-items: stretch;
    flex-wrap: nowrap;
    gap: 10px;
  }
  .page-header .btn { width: 100%; justify-content: center; }
  /* Solo los grupos de acciones que ya son flex deben envolver. El selector
     anterior convertía también el bloque título/subtítulo en una fila. */
  .page-header > div { width: 100%; min-width: 0; }
  .page-header > div[style*="display:flex"],
  .page-header > div[style*="display: flex"] {
    flex-wrap: wrap;
    gap: 8px;
  }
  .section-header .btn { flex: 1 1 auto; justify-content: center; }

  /* Rejilla de tarjetas de Conocimientos: su mínimo de 320px no cabe
     en pantallas pequeñas */
  #cards-grid { grid-template-columns: minmax(0, 1fr) !important; }

  /* Lista de documentos de Conocimientos: rejillas y tarjetas en línea
     cuyo contenido no encogía y desbordaba en pantallas estrechas */
  #view-knowledge div[style*="display:grid"] { grid-template-columns: minmax(0, 1fr) !important; }
  #view-knowledge .card { flex-wrap: wrap; min-width: 0; }
  #view-knowledge .card > * { min-width: 0; }

  /* Rejillas de dos columnas escritas en línea dentro de los modales:
     en móvil se apilan (si no, no pueden encoger y desbordan) */
  .modal [style*="grid-template-columns:1fr 1fr"],
  .modal [style*="grid-template-columns: 1fr 1fr"],
  .modal [style*="repeat(4,1fr)"],
  .modal [style*="repeat(4, 1fr)"] { grid-template-columns: minmax(0, 1fr) !important; }

  /* Los campos de formulario nunca se salen.
     16px es obligatorio: por debajo, iOS y algunos Android hacen zoom
     automático al enfocar el campo y descolocan toda la pantalla. */
  .form-control, .cards-search input, input, select, textarea,
  .search-bar input, .header-search input {
    max-width: 100%;
    font-size: 16px;
  }

  /* Modales: ocupan la pantalla desde abajo, con margen para el notch */
  .modal { padding-bottom: calc(32px + env(safe-area-inset-bottom, 0px)); }
}

/* ── PWA instalada: respetar el área segura del iPhone ──────
   El indicador de inicio (la barra inferior) tapaba la
   navegación; el notch tapaba la cabecera. */
@supports (padding: env(safe-area-inset-bottom)) {
  @media (max-width: 768px) {
    .mobile-nav {
      height: calc(var(--mobile-nav) + env(safe-area-inset-bottom, 0px));
      padding-bottom: env(safe-area-inset-bottom, 0px);
    }
    .page-content {
      padding-bottom: calc(var(--mobile-nav) + env(safe-area-inset-bottom, 0px) + 12px);
      padding-left:  max(12px, env(safe-area-inset-left));
      padding-right: max(12px, env(safe-area-inset-right));
    }
  }
}

/* Pantallas muy estrechas (iPhone SE y similares) */
@media (max-width: 400px) {
  .app-header { padding-inline: 8px; gap: 6px; }
  .header-mobile-logo { min-width: 0; flex: 1 1 auto; gap: 4px; font-size: 13px; }
  .header-mobile-logo img { height: 18px; }
  .header-mobile-logo > span {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .header-actions { flex: 0 0 auto; gap: 6px; }
  .lang-switch-opt { padding: 6px 7px; }
  .header-user { padding: 2px; }
  .user-avatar { width: 32px; height: 32px; }

  .mobile-nav-item { font-size: 8.5px; padding-inline: 1px !important; }
  .mobile-nav-item svg { width: 19px; height: 19px; }
  .lib-filters { grid-template-columns: minmax(0, 1fr); }
  .page-title { font-size: 21px; }
}

/* Smartphone: navegación y contenido sin elementos ocultos fuera de pantalla. */
@media (max-width: 480px) {
  .card { padding: 16px; }
  #view-students > .card:last-child { padding: 12px; }

  /* El menú de Redes deja de depender de un desplazamiento horizontal poco
     visible y presenta siempre sus cinco destinos. */
  .social-subnav {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px;
    border-bottom: 0;
    overflow: visible;
  }
  .social-tab {
    width: 100%;
    min-width: 0;
    justify-content: center;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 8px 6px;
    font-size: 12px;
  }
  .social-tab.active {
    border-color: var(--green-main);
    background: var(--green-light);
  }
  .social-tab:last-child:nth-child(odd) { grid-column: 1 / -1; }

  /* Perfil del alumno: cuatro pestañas en una cuadrícula 2 × 2. */
  #modal-student-profile .tabs {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    overflow: visible;
    white-space: normal;
  }
  #modal-student-profile .tabs .tab {
    min-width: 0;
    padding: 9px 3px;
    font-size: 11.5px;
    text-align: center;
  }
  #profile-cards-grid {
    grid-template-columns: minmax(0, 1fr) !important;
  }

  #modal-session-detail .modal-header { position: relative; padding-right: 36px; }
  #modal-session-detail .modal-close { position: absolute; top: 0; right: 0; }
  #modal-session-detail .tabs {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    overflow: visible;
  }
  #modal-session-detail .tabs .tab {
    min-width: 0;
    padding: 9px 4px;
    font-size: 11.5px;
    text-align: center;
  }
}

@media (max-width: 360px) {
  /* Las tarjetas estadísticas conservan dos columnas, pero el icono ya no
     roba la mitad del ancho disponible al texto. */
  .stat-card { flex-direction: column; gap: 8px; padding: 12px; }
  .stat-icon { width: 36px; height: 36px; border-radius: 9px; }
  .stat-icon svg { width: 19px; height: 19px; }
  .stat-value { font-size: 23px; }
}

/* ═══════════════════════════════════════════════════════════
   MODAL DE PUBLICACIÓN · pasos del flujo manual
═══════════════════════════════════════════════════════════ */
.pub-step {
  display: flex;
  gap: 12px;
  padding: 13px 0;
  border-bottom: 1px solid var(--border);
}
.pub-step-num {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--green-main);
  color: #fff;
  font-size: 12px;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.pub-step-title { font-size: 13.5px; font-weight: 700; color: var(--text-main); }
.pub-step-sub   { font-size: 12px; color: var(--text-muted); line-height: 1.45; margin-top: 2px; }
.pub-actions    { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }

/* Estado "toca publicar": planificada cuya fecha ya pasó */
.st-due { background: #FEF3C7; color: #92400E; }
.lib-card-due { border-color: #FDE68A; box-shadow: 0 0 0 2px rgba(253,230,138,.35); }
.cal-ev.due { border-color: #D97706; background: #FEF3C7; }
.dot-due { background: #D97706; }


/* ─── Créditos ──────────────────────────────────────────────────────────────
   El saldo es lo primero que se mira, así que va grande y aparte. El resto
   (en qué se ha ido, qué cuesta cada cosa) se lee después. */
.nav-saldo {
  margin-left: auto;
  font-size: 11px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--gold-dark);
  background: var(--gold-light);
  padding: 2px 8px;
  border-radius: 10px;
}
.nav-saldo:empty { display: none; }
.nav-saldo.agotandose { color: #8a1c1c; background: #fdecec; }

.cr-resumen {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}
.cr-tarjeta {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}
.cr-tarjeta.principal {
  background: var(--green-main);
  border-color: var(--green-main);
  color: var(--white);
}
.cr-cifra {
  font-size: 34px;
  font-weight: 700;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}
.cr-etiqueta {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
}
.cr-tarjeta.principal .cr-etiqueta { color: rgba(255,255,255,.75); }

.cr-barra {
  height: 6px;
  border-radius: 3px;
  background: rgba(255,255,255,.25);
  margin-top: 14px;
  overflow: hidden;
}
.cr-barra > span {
  display: block;
  height: 100%;
  background: var(--gold);
  border-radius: 3px;
}

.cr-columnas {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}
@media (max-width: 860px) { .cr-columnas { grid-template-columns: 1fr; } }

.cr-linea {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.cr-linea:last-child { border-bottom: none; }
.cr-linea-nombre { flex: 1; font-size: 13px; font-weight: 600; }
.cr-linea-detalle { font-size: 12px; color: var(--text-muted); font-weight: 400; }
.cr-linea-valor {
  font-size: 14px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--green-main);
  white-space: nowrap;
}

/* Proporción del gasto por acción, para ver de un vistazo dónde se va. */
.cr-proporcion {
  height: 4px;
  border-radius: 2px;
  background: var(--green-light);
  margin-top: 5px;
}
.cr-proporcion > span {
  display: block;
  height: 100%;
  border-radius: 2px;
  background: var(--green-main);
}

.cr-mov {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 20px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.cr-mov:last-child { border-bottom: none; }
.cr-mov-desc { flex: 1; min-width: 0; }
.cr-mov-desc strong { display: block; font-weight: 600; }
.cr-mov-desc span { font-size: 12px; color: var(--text-muted); }
.cr-mov-credi {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: #8a1c1c;
  white-space: nowrap;
}
.cr-mov-credi.suma { color: var(--green-main); }
.cr-mov-saldo {
  font-size: 12px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  min-width: 74px;
  text-align: right;
}
@media (max-width: 620px) { .cr-mov-saldo { display: none; } }

.cr-vacio {
  padding: 28px 20px;
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
}
