/* ============================================================================
   styles.css — Sociograma  ·  Estilo "cálido y cercano"
   Paleta: crema + teal (marca) + coral (acento). Claro por defecto + oscuro.
   ========================================================================== */

/* ---- Tema claro (por defecto) ------------------------------------------ */
:root {
  --bg: #faf8f5;
  --bg-2: #f3ede4;
  --surface: #ffffff;
  --surface-2: #f7f2ea;
  --border: #ece4d8;
  --border-strong: #ddd2c2;
  --text: #2b2723;
  --muted: #7c7368;

  --primary: #0d9488;        /* teal */
  --primary-dark: #0f766e;
  --primary-soft: #e7f6f3;
  --primary-softer: #f0faf8;

  --accent: #e07856;         /* coral */
  --accent-soft: #fdf1ec;
  --amber: #e6a24a;

  --success: #15a34a;
  --success-soft: #e9f7ee;
  --danger: #dc4b3e;
  --danger-soft: #fdeeec;
  --warn: #c9821f;
  --warn-soft: #fbf1df;

  --radius: 16px;
  --radius-sm: 10px;
  --shadow-sm: 0 1px 2px rgba(60, 45, 30, 0.05), 0 1px 3px rgba(60, 45, 30, 0.04);
  --shadow: 0 2px 6px rgba(60, 45, 30, 0.06), 0 6px 20px rgba(60, 45, 30, 0.05);
  --shadow-lg: 0 12px 40px rgba(60, 45, 30, 0.16);
  --ring: 0 0 0 3px rgba(13, 148, 136, 0.18);
}

/* ---- Tema oscuro (cuidado, tonos cálidos) ------------------------------ */
:root[data-theme="dark"] {
  --bg: #1b1815;
  --bg-2: #221e1a;
  --surface: #262220;
  --surface-2: #302b27;
  --border: #3a332d;
  --border-strong: #4a413a;
  --text: #f3ede4;
  --muted: #a89e92;

  --primary: #2dd4bf;
  --primary-dark: #14b8a6;
  --primary-soft: #123c38;
  --primary-softer: #16302d;

  --accent: #f0906e;
  --accent-soft: #3a251d;
  --amber: #eab260;

  --success: #4ade80;
  --success-soft: #14311f;
  --danger: #f0776a;
  --danger-soft: #3a201c;
  --warn: #e0a94a;
  --warn-soft: #3a2c14;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 12px 40px rgba(0, 0, 0, 0.5);
  --ring: 0 0 0 3px rgba(45, 212, 191, 0.25);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Nunito", ui-rounded, "Segoe UI", system-ui, -apple-system, sans-serif;
  background:
    radial-gradient(1200px 600px at 100% -10%, var(--bg-2), transparent 60%),
    var(--bg);
  color: var(--text);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

h1, h2, h3 { letter-spacing: -0.01em; }

/* ---- Topbar ------------------------------------------------------------- */
.topbar {
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(8px);
  border-bottom: 1px solid var(--border);
  padding: 0.7rem 1.25rem;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  position: sticky;
  top: 0;
  z-index: 50;
}
.topbar .logo {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 900;
  font-size: 1.2rem;
  letter-spacing: -0.03em;
}
.topbar .logo span { color: var(--primary); }
.topbar .logo .logo-mark {
  width: 30px; height: 30px;
  display: grid; place-items: center;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  border-radius: 9px;
  color: #fff;
  box-shadow: var(--shadow-sm);
}
.topbar .spacer { flex: 1; }

.container { max-width: 1120px; margin: 0 auto; padding: 1.5rem 1.25rem 3rem; }
.narrow { max-width: 640px; }

/* ---- Iconos ------------------------------------------------------------- */
.ico { width: 1.05em; height: 1.05em; display: inline-block; vertical-align: -0.15em; flex: none; }

/* ---- Tarjetas ----------------------------------------------------------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 1.4rem 1.5rem;
  margin-bottom: 1.1rem;
  transition: box-shadow 0.2s, transform 0.2s, border-color 0.2s;
}
.card h2 { margin: 0 0 0.2rem; font-size: 1.2rem; font-weight: 800; }
.card h3 { margin: 0 0 0.3rem; font-size: 1rem; font-weight: 800; }
.card h4 { margin: 0 0 0.2rem; font-size: 0.8rem; font-weight: 800; text-transform: uppercase; letter-spacing: 0.03em; color: var(--muted); }
.card .sub { color: var(--muted); font-size: 0.92rem; margin-bottom: 1.1rem; }
.fila-indice svg { transition: transform 0.15s; color: var(--muted); }
.fila-indice:hover { background: var(--primary-softer); }

/* Tarjeta de clase (clicable) */
.card-clase { cursor: default; }
.card-clase:hover { box-shadow: var(--shadow); transform: translateY(-2px); border-color: var(--border-strong); }

/* ---- Botones ------------------------------------------------------------ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  padding: 0.55rem 1rem;
  border-radius: var(--radius-sm);
  font-size: 0.92rem;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.15s ease;
  text-decoration: none;
  line-height: 1.2;
}
.btn:hover { background: var(--surface-2); border-color: var(--muted); transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: #fff;
  border-color: transparent;
  box-shadow: 0 2px 8px color-mix(in srgb, var(--primary) 35%, transparent);
}
/* Ojo: `.btn:hover` cambia el fondo a crema; aquí hay que volver a poner el
   degradado o el botón se queda blanco con texto blanco. */
.btn-primary:hover { background: linear-gradient(135deg, var(--primary), var(--primary-dark)); color: #fff; filter: brightness(1.08); border-color: transparent; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }
.btn-danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 35%, var(--border)); background: var(--surface); }
.btn-danger:hover { background: var(--danger-soft); border-color: var(--danger); }
.btn-sm { padding: 0.4rem 0.7rem; font-size: 0.85rem; }
.btn-icon { padding: 0.5rem; width: 2.3rem; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }
.btn-row { display: flex; gap: 0.55rem; flex-wrap: wrap; }

/* ---- Formularios -------------------------------------------------------- */
label { display: block; font-size: 0.85rem; font-weight: 700; margin-bottom: 0.35rem; color: var(--text); }
input[type="text"], input[type="number"], input[type="password"], input[type="email"], input[type="search"], select, textarea {
  width: 100%;
  padding: 0.6rem 0.8rem;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  font-family: inherit;
  background: var(--surface);
  color: var(--text);
  transition: border-color 0.15s, box-shadow 0.15s;
}
input::placeholder, textarea::placeholder { color: color-mix(in srgb, var(--muted) 75%, transparent); }
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: var(--ring);
}
textarea { resize: vertical; }
.field { margin-bottom: 1rem; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 1rem; }

/* ---- Tablas ------------------------------------------------------------- */
.tabla-wrap { overflow-x: auto; border-radius: var(--radius-sm); }
table.data { border-collapse: collapse; width: 100%; font-size: 0.9rem; }
table.data th, table.data td {
  border-bottom: 1px solid var(--border);
  padding: 0.6rem 0.7rem;
  text-align: left;
}
table.data thead th {
  background: var(--surface-2);
  font-weight: 800;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--muted);
  border-bottom: 1px solid var(--border-strong);
}
table.data tbody tr:hover { background: var(--primary-softer); }
table.data td.num, table.data th.num { text-align: center; }
table.data tbody tr:last-child td { border-bottom: none; }

/* Sociomatriz */
table.matriz { border-collapse: collapse; font-size: 0.8rem; }
table.matriz th, table.matriz td {
  border: 1px solid var(--border);
  width: 30px; height: 30px;
  text-align: center;
  padding: 2px;
}
table.matriz th { background: var(--surface-2); font-weight: 800; color: var(--muted); }
table.matriz td.diag { background: var(--surface-2); color: var(--muted); }
table.matriz td.pos { background: var(--success-soft); color: var(--success); font-weight: 800; }
table.matriz td.neg { background: var(--danger-soft); color: var(--danger); font-weight: 800; }
table.matriz td.mix { background: var(--warn-soft); color: var(--warn); font-weight: 800; }
/* Cabeceras de columna: nombre completo en vertical (antes se cortaba). */
table.matriz th.rot { height: auto; width: 30px; vertical-align: bottom; padding: 6px 2px; }
table.matriz th.rot span { writing-mode: vertical-rl; transform: rotate(180deg); white-space: nowrap; display: inline-block; }
table.matriz th.esquina { vertical-align: bottom; text-align: right; padding: 6px 8px; font-size: 0.72rem; font-weight: 700; white-space: nowrap; }
table.matriz th.fila-nombre { text-align: right; white-space: nowrap; padding: 2px 8px; position: sticky; left: 0; z-index: 1; }
table.matriz .nr { font-weight: 600; font-style: italic; font-size: 0.75em; }
table.matriz tr.fila-sinresp th.fila-nombre { color: var(--muted); font-style: italic; }
table.matriz td.sinresp { background: repeating-linear-gradient(45deg, transparent 0 4px, var(--surface-2) 4px 8px); }
table.matriz tfoot td { font-weight: 800; background: var(--surface-2); }
table.matriz tfoot tr:first-child td, table.matriz tfoot tr:first-child th { border-top: 2px solid var(--border-strong); }
table.matriz td.tot-pos { color: var(--success); }
table.matriz td.tot-neg { color: var(--danger); }
table.matriz .cruz { box-shadow: inset 0 0 0 100px color-mix(in srgb, var(--primary) 10%, transparent); }
table.matriz tr.cruz th.fila-nombre, table.matriz th.rot.cruz { color: var(--primary-dark); }
.matriz-wrap { cursor: zoom-in; }
.leg-pos, .leg-neg, .leg-mix { display: inline-block; min-width: 1.2em; text-align: center; font-weight: 900; border-radius: 4px; }
.leg-pos { color: var(--success); background: var(--success-soft); }
.leg-neg { color: var(--danger); background: var(--danger-soft); }
.leg-mix { color: var(--warn); background: var(--warn-soft); }
/* Sociomatriz en grande */
.modal-grande { padding: 1rem; }
.mg-caja { background: var(--surface); border-radius: var(--radius); width: min(1600px, 98vw); max-height: 96vh; display: flex; flex-direction: column; box-shadow: var(--shadow-lg); }
.mg-cab { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; padding: 0.9rem 1.2rem; border-bottom: 1px solid var(--border); }
.mg-tabla { overflow: auto; padding: 1rem; }
.mg-tabla table.matriz { font-size: 1rem; margin: 0 auto; }
.mg-tabla table.matriz th, .mg-tabla table.matriz td { width: 38px; height: 38px; }
.mg-tabla table.matriz th.rot { height: auto; }
.mg-tabla table.matriz thead th { position: sticky; top: 0; z-index: 2; }

/* ---- Chips / badges ----------------------------------------------------- */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  font-size: 0.74rem;
  font-weight: 800;
  color: #fff;
  letter-spacing: 0.01em;
}
.badge-estado { text-transform: capitalize; }
.pill {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.3rem 0.75rem;
  font-size: 0.83rem;
  font-weight: 700;
  color: var(--text);
}
.pill .ico { color: var(--primary); }
.pill code { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-weight: 800; letter-spacing: 0.05em; }

.codigo-clase {
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: 0.22em;
  color: var(--primary);
  background: var(--primary-soft);
  padding: 0.6rem 1.4rem;
  border-radius: var(--radius-sm);
  display: inline-block;
  text-indent: 0.22em;
}

/* ---- Tabs --------------------------------------------------------------- */
.tabs { display: flex; gap: 0.15rem; border-bottom: 2px solid var(--border); margin-bottom: 1.2rem; flex-wrap: wrap; }
.tab {
  padding: 0.6rem 1rem;
  border: none;
  background: none;
  color: var(--muted);
  font-weight: 800;
  font-size: 0.92rem;
  font-family: inherit;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: color 0.15s, border-color 0.15s;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); }

/* ---- Grafo -------------------------------------------------------------- */
#grafo {
  width: 100%; height: 560px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background:
    radial-gradient(circle at 20% 15%, var(--primary-softer), transparent 45%),
    var(--surface);
  color: var(--text);
}
.grafo-tip {
  position: absolute;
  z-index: 20;
  pointer-events: none;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  box-shadow: var(--shadow);
  padding: 0.5rem 0.7rem;
  font-size: 0.82rem;
  line-height: 1.45;
  max-width: 260px;
}
/* Etiquetas de nodo legibles sobre aristas/manchas (halo con el color de fondo) */
.nodo-label {
  fill: var(--text);
  paint-order: stroke;
  stroke: var(--surface);
  stroke-width: 3px;
  stroke-linejoin: round;
}
.grafo-zoom {
  position: absolute;
  right: 12px;
  bottom: 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  z-index: 15;
}
.grafo-zoom button {
  width: 36px;
  height: 36px;
  border-radius: 9px;
  border: 1px solid var(--border-strong);
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  color: var(--text);
  font-size: 1.2rem;
  font-weight: 800;
  line-height: 1;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: background 0.15s;
}
.grafo-zoom button:hover { background: var(--surface-2); }
/* Animación de entrada del grafo */
@keyframes nodo-in { from { opacity: 0; transform: scale(0.2); } to { opacity: 1; transform: scale(1); } }
@keyframes arista-in { from { opacity: 0; } to { opacity: 1; } }
.nodo-cont { animation: nodo-in 0.45s cubic-bezier(0.2, 0.8, 0.3, 1) both; }
#grafo .aristas path { animation: arista-in 0.6s ease both; animation-delay: 0.2s; }
@media (prefers-reduced-motion: reduce) {
  .nodo-cont, #grafo .aristas path { animation: none; }
}
/* Mapas estáticos (diana / islas / bienestar): SVG centrado y responsivo. */
.mapa-svg { width: 100%; overflow-x: auto; text-align: center; }
.mapa-svg svg { max-width: 100%; height: auto; }

.grafo-toolbar { display: flex; gap: 0.9rem; flex-wrap: wrap; align-items: center; margin-bottom: 0.85rem; }
.grafo-toolbar label { display: inline-flex; align-items: center; gap: 0.4rem; margin: 0; font-weight: 700; font-size: 0.88rem; }
.grafo-toolbar input[type="checkbox"] { accent-color: var(--primary); width: 1.05rem; height: 1.05rem; }
.leyenda { display: flex; gap: 0.9rem; flex-wrap: wrap; font-size: 0.82rem; margin-top: 0.7rem; color: var(--muted); }
.leyenda span { display: inline-flex; align-items: center; gap: 0.35rem; }
.leyenda .leyenda-cat { cursor: help; }
.leyenda .leyenda-cat:hover { color: var(--text); text-decoration: underline dotted; text-underline-offset: 3px; }
.dot { width: 12px; height: 12px; border-radius: 50%; display: inline-block; }

/* ---- KPIs --------------------------------------------------------------- */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(118px, 1fr)); gap: 0.85rem; }
.kpi {
  background: var(--surface);
  border: 1px solid var(--border);
  border-top: 3px solid var(--kpi, var(--primary));
  border-radius: var(--radius-sm);
  padding: 0.9rem 0.7rem;
  text-align: center;
}
.kpi .n { font-size: 1.9rem; font-weight: 900; line-height: 1; color: var(--kpi, var(--text)); }
.kpi .l { font-size: 0.76rem; color: var(--muted); font-weight: 700; margin-top: 0.3rem; }

/* ---- Estados / avisos --------------------------------------------------- */
.empty { text-align: center; color: var(--muted); padding: 2.5rem 1rem; }
.empty .empty-ico { color: var(--border-strong); margin-bottom: 0.5rem; }
/* Bloque normal con el icono flotando a la izquierda: con flex, cada trozo de
   texto suelto (p. ej. antes y después de una <b>) se volvía una columna. */
.aviso { padding: 0.75rem 1rem; border-radius: var(--radius-sm); font-size: 0.9rem; margin-bottom: 0.9rem; display: block; line-height: 1.5; }
.aviso::after { content: ''; display: block; clear: both; }
.aviso > svg.ico:first-child { float: left; margin: 0.15rem 0.5rem 0 0; }
.aviso > svg.ico:first-child + div { overflow: hidden; }
.aviso-info { background: var(--primary-soft); border: 1px solid color-mix(in srgb, var(--primary) 25%, transparent); color: var(--primary-dark); }
.aviso-ok { background: var(--success-soft); border: 1px solid color-mix(in srgb, var(--success) 30%, transparent); color: var(--success); }
.aviso-warn { background: var(--warn-soft); border: 1px solid color-mix(in srgb, var(--warn) 30%, transparent); color: var(--warn); }

/* ---- Formulario del alumno --------------------------------------------- */
.opciones-alumnos { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 0.6rem; }
.opcion-alumno {
  position: relative;
  border: 2px solid var(--border-strong);
  border-radius: 14px;
  padding: 0.8rem 0.6rem;
  text-align: center;
  cursor: pointer;
  font-weight: 800;
  font-size: 0.95rem;
  user-select: none;
  transition: all 0.14s;
  background: var(--surface);
}
.opcion-alumno:hover { border-color: var(--primary); transform: translateY(-2px); box-shadow: var(--shadow-sm); }
/* Selección neutra (igual en preguntas positivas y negativas) */
.opcion-alumno.sel { border-color: var(--primary); background: var(--primary-soft); color: var(--primary-dark); }
:root[data-theme="dark"] .opcion-alumno.sel { color: var(--primary); }
.opcion-alumno .rango {
  position: absolute; top: -9px; right: -9px;
  min-width: 22px; height: 22px; line-height: 22px;
  border-radius: 999px; font-size: 0.72rem; color: #fff; font-weight: 900;
  padding: 0 4px;
}
.opcion-alumno.sel .rango { background: var(--primary); }
.opcion-alumno.deshab { opacity: 0.35; pointer-events: none; }

/* Escala / emoji (autoinforme del alumno) */
.escala-opciones { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 0.6rem; }
.opcion-escala {
  border: 2px solid var(--border-strong);
  border-radius: 14px;
  padding: 0.9rem 0.5rem;
  text-align: center;
  cursor: pointer;
  user-select: none;
  transition: all 0.14s;
  background: var(--surface);
}
.opcion-escala:hover { border-color: var(--primary); transform: translateY(-2px); box-shadow: var(--shadow-sm); }
.opcion-escala.sel { border-color: var(--primary); background: var(--primary-soft); }
.opcion-escala .escala-emoji { display: block; font-size: 2rem; line-height: 1.1; }
.opcion-escala .escala-txt { display: block; font-size: 0.85rem; font-weight: 700; margin-top: 0.25rem; }

/* Dimensiones (etiquetas y agrupación en el panel) */
.dim-badge { display: inline-flex; align-items: center; gap: 0.3rem; padding: 0.15rem 0.6rem; border-radius: 999px; font-size: 0.74rem; font-weight: 800; color: #fff; }
.dim-group-title { display: flex; align-items: center; gap: 0.5rem; margin: 1.2rem 0 0.6rem; font-size: 0.95rem; font-weight: 800; }
.alerta-badge { display: inline-flex; align-items: center; gap: 0.25rem; padding: 0.12rem 0.5rem; border-radius: 999px; font-size: 0.72rem; font-weight: 800; color: #fff; }
.bienestar-bar { display: inline-block; width: 46px; height: 8px; border-radius: 999px; background: var(--surface-2); overflow: hidden; vertical-align: middle; }
.bienestar-bar > div { height: 100%; border-radius: 999px; }

.pregunta-num { font-size: 0.8rem; color: var(--primary); font-weight: 800; text-transform: uppercase; letter-spacing: 0.06em; }
.progreso { height: 8px; background: var(--surface-2); border-radius: 999px; overflow: hidden; margin: 0.9rem 0 1.3rem; }
.progreso > div { height: 100%; background: linear-gradient(90deg, var(--primary), var(--primary-dark)); transition: width 0.35s ease; border-radius: 999px; }

.hero-alumno { text-align: center; }
.hero-alumno .emoji-ok { width: 72px; height: 72px; margin: 0 auto 0.5rem; color: var(--success); }

/* ---- Modal -------------------------------------------------------------- */
.modal-bg { position: fixed; inset: 0; background: rgba(30, 22, 14, 0.45); backdrop-filter: blur(3px); display: flex; align-items: center; justify-content: center; z-index: 100; padding: 1rem; animation: fade 0.15s ease; }
.modal { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-lg); max-width: 520px; width: 100%; padding: 1.7rem; max-height: 90vh; overflow-y: auto; animation: pop 0.18s ease; }
.modal h2 { margin-top: 0; }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(0.98); } }
.hidden { display: none !important; }

/* ---- Responsive --------------------------------------------------------- */
@media (max-width: 640px) {
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .container { padding: 1rem 0.9rem 2rem; }
  .card { padding: 1.1rem; }
  .codigo-clase { font-size: 1.6rem; }
}

/* ---- Demo / carrusel de bienvenida (pantalla de acceso) ---------------- */
.demo {
  position: relative;
  margin-bottom: 1.1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.demo-viewport { overflow: hidden; }
.demo-track { display: flex; transition: transform 0.5s cubic-bezier(0.4, 0.8, 0.3, 1); }
.demo-slide { flex: 0 0 100%; min-width: 0; }
.demo-art {
  height: 232px;
  display: grid;
  place-items: center;
  background:
    radial-gradient(120% 90% at 15% 0%, var(--primary-softer), transparent 55%),
    linear-gradient(160deg, var(--surface-2), var(--surface));
  border-bottom: 1px solid var(--border);
  padding: 0.6rem;
}
.demo-art svg { width: 100%; height: 100%; max-width: 380px; display: block; }
.demo-caption { padding: 1.15rem 1.5rem 1.25rem; text-align: center; }
.demo-step {
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--primary);
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  margin-bottom: 0.45rem;
}
.demo-caption h3 { margin: 0 0 0.3rem; font-size: 1.12rem; font-weight: 800; }
.demo-caption p { margin: 0; color: var(--muted); font-size: 0.93rem; line-height: 1.5; min-height: 4.5em; } /* 3 líneas: la tarjeta no cambia de alto */
.demo-nav {
  position: absolute;
  top: 116px;
  transform: translateY(-50%);
  width: 38px; height: 38px;
  display: grid; place-items: center;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  background: color-mix(in srgb, var(--surface) 90%, transparent);
  color: var(--text);
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: background 0.15s, transform 0.15s, opacity 0.15s;
  z-index: 3;
}
.demo-nav:hover { background: var(--surface-2); transform: translateY(-50%) scale(1.06); }
.demo-nav.prev { left: 12px; }
.demo-nav.next { right: 12px; }
.demo-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.8rem;
  padding: 0 1.5rem 1.1rem;
}
.demo-dots { display: flex; gap: 0.4rem; }
.demo-dot {
  width: 8px; height: 8px;
  border-radius: 999px;
  border: none;
  padding: 0;
  background: var(--border-strong);
  cursor: pointer;
  transition: background 0.2s, width 0.2s;
}
.demo-dot.active { background: var(--primary); width: 22px; }
.demo-skip {
  background: none;
  border: none;
  color: var(--muted);
  font-family: inherit;
  font-weight: 700;
  font-size: 0.83rem;
  cursor: pointer;
  padding: 0.2rem 0.3rem;
}
.demo-skip:hover { color: var(--text); text-decoration: underline; text-underline-offset: 3px; }

/* Animaciones dentro de las ilustraciones */
@keyframes demo-pulse {
  0%   { transform: scale(0.9); opacity: 0.7; }
  70%  { transform: scale(1.7); opacity: 0; }
  100% { transform: scale(1.7); opacity: 0; }
}
@keyframes demo-float { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-4px); } }
@keyframes demo-dash { to { stroke-dashoffset: 0; } }
.demo-pulse-ring { transform-box: fill-box; transform-origin: center; animation: demo-pulse 2.2s ease-out infinite; }
.demo-floaty { transform-box: fill-box; transform-origin: center; animation: demo-float 3.4s ease-in-out infinite; }
.demo-edge { stroke-dasharray: 200; stroke-dashoffset: 200; animation: demo-dash 1s ease forwards; }
@media (prefers-reduced-motion: reduce) {
  .demo-track { transition: none; }
  .demo-pulse-ring, .demo-floaty, .demo-edge { animation: none; }
  .demo-edge { stroke-dashoffset: 0; }
}
@media (max-width: 640px) {
  .demo-art { height: 200px; }
  .demo-nav { top: 100px; }
  .demo-caption { padding: 1rem 1.1rem 1.1rem; }
  .demo-foot { padding: 0 1.1rem 1rem; }
}

/* ---- Impresión (informe PDF) ------------------------------------------- */
@media print {
  :root { --bg: #fff; }
  body { background: #fff; color: #000; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .topbar, .tabs, .btn, .grafo-toolbar, .grafo-zoom, .grafo-tip, #grafo-ficha, .no-print, .demo { display: none !important; }
  .card { box-shadow: none; border: 1px solid #ccc; page-break-inside: avoid; }
  .container { max-width: 100%; }
  .page-break { page-break-before: always; }

  /* Grafo en el PDF: se oculta el interactivo y se muestra la versión estática
     encuadrada (svgExport), escalada al ancho de la página. */
  #grafo { display: none !important; }
  #grafo-print { display: block !important; page-break-inside: avoid; text-align: center; }
  #grafo-print svg { width: 100% !important; height: auto !important; max-height: 560px; }

  /* Cada mapa estático en su propia página, escalado al ancho. */
  #r-diana .card, #r-islas .card, #r-bienestar .card { page-break-before: always; page-break-inside: avoid; }
  .mapa-svg { overflow: visible !important; }
  .mapa-svg svg { max-height: 640px; }

  /* Sociomatriz legible: su propia página, sin recortes, celdas y colores nítidos. */
  #r-matriz .card { page-break-before: always; }
  .tabla-wrap { overflow: visible !important; }
  table.matriz { font-size: 0.95rem; margin: 0.4rem auto 0; }
  table.matriz th, table.matriz td { width: 30px; height: 30px; border-color: #999; }
  table.matriz td.pos, table.matriz td.neg, table.matriz td.mix, table.matriz td.diag, table.matriz th { -webkit-print-color-adjust: exact; print-color-adjust: exact; }

  /* Impresión de una única ficha individual: oculta el resto de la app. */
  body.print-ficha .topbar,
  body.print-ficha #vista-lista,
  body.print-ficha #vista-grupo,
  body.print-ficha #vista-admin,
  body.print-ficha #vista-login,
  body.print-ficha #modal-root { display: none !important; }
  body.print-ficha #ficha-print { display: block !important; }
}

/* Instrucciones al alumno antes de la prueba */
.lista-consejos { margin: 0; padding-left: 1.2rem; }
.lista-consejos li { margin: 0.35rem 0; line-height: 1.5; }

/* Aviso flotante de errores al guardar (orientador) */
.toast { position: fixed; left: 50%; bottom: 1.2rem; transform: translateX(-50%); z-index: 9999; max-width: min(92vw, 520px); box-shadow: 0 6px 24px rgba(0,0,0,.18); }
@media print { .toast { display: none !important; } }

/* Vista «Clases» del administrador: filtros + centros desplegables */
.ac-filtros { display: flex; flex-wrap: wrap; gap: 0 0.9rem; align-items: flex-end; }
.ac-filtros .field { flex: 1; min-width: 140px; }
.ac-centro { padding-top: 0.9rem; padding-bottom: 0.9rem; }
.ac-cab { all: unset; box-sizing: border-box; width: 100%; display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; cursor: pointer; border-radius: var(--radius-sm); }
.ac-cab:focus-visible { box-shadow: var(--ring); }
.ac-nombre { font-weight: 800; font-size: 1.05rem; margin-right: auto; color: var(--text); }
.ac-flecha { display: inline-flex; color: var(--primary); transition: transform 0.15s; }
.ac-centro.abierto .ac-flecha { transform: rotate(90deg); }
.topbar .btn.nav-activo { background: var(--primary-soft); border-color: var(--primary); color: var(--primary-dark); }

/* Cuestionario: con qué nombre se está contestando */
.como-quien { font-size: 0.85rem; color: var(--muted); margin-bottom: 0.5rem; }
.como-quien a { color: var(--primary-dark); font-weight: 700; }

/* Recogida: enlace + QR, clave personal, ayuda */
.rec-compartir { display: grid; grid-template-columns: 1fr 170px; gap: 1.2rem; align-items: start; }
.rec-qr { background: #fff; border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 6px; }
.rec-qr svg { display: block; width: 100%; height: auto; }
.rec-planb { margin: 0.8rem 0 0; font-size: 0.85rem; }
.rec-planb code, code.clave { font-family: ui-monospace, Consolas, monospace; font-weight: 800; letter-spacing: 0.12em; }
.rec-check { display: flex; gap: 0.6rem; align-items: flex-start; margin-top: 0.8rem; cursor: pointer; line-height: 1.45; }
.rec-check input { accent-color: var(--primary); width: 1.1rem; height: 1.1rem; margin-top: 0.15rem; flex: none; }
.rec-ayuda { margin-top: 0.9rem; background: var(--surface-2); border-radius: var(--radius-sm); padding: 0.6rem 0.9rem; }
.rec-ayuda summary { cursor: pointer; font-weight: 800; }
.rec-ayuda ul { margin: 0.5rem 0 0.2rem; padding-left: 1.1rem; line-height: 1.5; }
.qr-proyeccion { align-items: center; justify-content: center; }
.qr-caja { background: var(--surface); border-radius: var(--radius); padding: 1.5rem 2rem; text-align: center; max-width: 95vw; box-shadow: var(--shadow-lg); }
.qr-grande { background: #fff; padding: 10px; border-radius: var(--radius-sm); display: inline-block; }
.qr-grande svg { width: min(70vh, 80vw); height: auto; display: block; }
@media (max-width: 640px) { .rec-compartir { grid-template-columns: 1fr; } .rec-qr { max-width: 200px; } }

/* Entradilla de 1º-2º de Primaria: letra más grande y aire entre frases */
.entradilla-ep1 p, .entradilla-ep1 .lista-consejos li { font-size: 1.12rem; line-height: 1.6; }
.entradilla-ep1 .lista-consejos li { margin: 0.5rem 0; }

/* ---- Pasos de la clase (1 Alumnos → … → 5 Resultados) ------------------- */
.pasos { display: flex; align-items: stretch; gap: 0; margin: 0 0 1.2rem; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); padding: 0.45rem; overflow-x: auto; }
.paso { flex: 1 1 0; min-width: 0; display: flex; align-items: center; justify-content: center; gap: 0.5rem; padding: 0.6rem 0.5rem; border: none; background: none; font: inherit; font-weight: 800; font-size: 0.95rem; color: var(--muted); cursor: pointer; border-radius: var(--radius-sm); position: relative; white-space: nowrap; transition: background 0.15s, color 0.15s; }
.paso + .paso::before { content: ''; position: absolute; left: -0.55rem; top: 50%; width: 1.1rem; height: 2px; background: var(--border-strong); }
.paso:hover { background: var(--surface-2); color: var(--text); }
.paso-n { flex: none; display: inline-grid; place-items: center; width: 1.75rem; height: 1.75rem; border-radius: 50%; border: 2px solid var(--border-strong); font-size: 0.85rem; background: var(--surface); }
.paso.hecho { color: var(--text); }
.paso.hecho .paso-n { background: var(--success); border-color: var(--success); color: #fff; }
.paso.activo { background: var(--primary-soft); color: var(--primary-dark); }
.paso.activo .paso-n { background: var(--primary); border-color: var(--primary); color: #fff; }
.paso:focus-visible { box-shadow: var(--ring); outline: none; }
@media (max-width: 640px) {
  .pasos { padding: 0.3rem; }
  .paso { flex-direction: column; gap: 0.2rem; font-size: 0.72rem; padding: 0.45rem 0.15rem; }
  .paso + .paso::before { display: none; }
}
.siguiente-paso { display: flex; justify-content: flex-end; margin: 0.4rem 0 1.4rem; }

/* ---- Cabecera de tarjeta: banda suave con icono --------------------------- */
.card-cab { display: flex; align-items: center; gap: 0.6rem; margin: -1.4rem -1.5rem 1rem; padding: 0.85rem 1.5rem; background: var(--primary-soft); border-bottom: 1px solid color-mix(in srgb, var(--primary) 18%, transparent); border-radius: var(--radius) var(--radius) 0 0; color: var(--primary-dark); }
.card-cab h2 { margin: 0; font-size: 1.22rem; color: var(--text); }
.card-cab .ico { flex: none; }
.card-cab-der { margin-left: auto; display: flex; gap: 0.5rem; align-items: center; }
.card-cab + .sub { margin-top: 0; }
:root[data-theme="dark"] .card-cab { color: var(--primary); }
@media print { .card-cab { background: none; border-bottom: 2px solid #ccc; margin: 0 0 0.8rem; padding: 0 0 0.4rem; } }

/* Alumnos: consejos plegables y números en los botones del listado */
.consejos-pd { display: block; }
.consejos-pd summary { cursor: pointer; display: flex; align-items: center; gap: 0.5rem; list-style: none; }
.consejos-pd summary::-webkit-details-marker { display: none; }
.consejos-pd summary::after { content: '▾'; margin-left: auto; transition: transform 0.15s; }
.consejos-pd:not([open]) summary::after { transform: rotate(-90deg); }
.num-mini { display: inline-grid; place-items: center; width: 1.25rem; height: 1.25rem; border-radius: 50%; font-size: 0.75rem; font-weight: 900; background: color-mix(in srgb, currentColor 18%, transparent); margin-right: 0.15rem; }

/* Recogida: guion para presentar el cuestionario a la clase */
.guion summary { cursor: pointer; font-weight: 800; color: var(--primary-dark); }
:root[data-theme="dark"] .guion summary { color: var(--primary); }
.guion-texto { background: var(--surface-2); border-left: 4px solid var(--primary); border-radius: var(--radius-sm); padding: 0.8rem 1rem 0.8rem 0.6rem; }
.guion-texto ul { margin: 0; padding-left: 1.3rem; }
.guion-texto li { margin: 0.45rem 0; line-height: 1.55; font-size: 1.02rem; }
.guion-proy { text-align: left; max-width: min(1000px, 95vw); max-height: 92vh; overflow: auto; }
.guion-proy ul { padding-left: 1.4rem; margin: 0; }
.guion-proy li { font-size: clamp(1.05rem, 2.2vw, 1.6rem); line-height: 1.5; margin: 0.55rem 0; }

/* ---- Ayudas: término con explicación al pasar el ratón o tocar ----------- */
.con-ayuda { border-bottom: 1px dotted currentColor; cursor: help; display: inline-flex; align-items: baseline; gap: 0.2em; }
.con-ayuda:focus-visible { outline: none; box-shadow: var(--ring); border-radius: 3px; }
.ayuda-i { display: inline-grid; place-items: center; width: 1.05em; height: 1.05em; border-radius: 50%; font-size: 0.7em; font-weight: 900; font-style: normal; background: var(--primary-soft); color: var(--primary-dark); border: 1px solid color-mix(in srgb, var(--primary) 35%, transparent); transform: translateY(-0.1em); text-transform: none; letter-spacing: 0; }
.ayuda-pop { position: absolute; z-index: 9998; background: var(--text); color: var(--surface); padding: 0.65rem 0.8rem; border-radius: var(--radius-sm); font-size: 0.86rem; line-height: 1.45; box-shadow: var(--shadow-lg); pointer-events: none; text-align: left; font-weight: 500; text-transform: none; letter-spacing: 0; }
.ayuda-pop b { display: block; margin-bottom: 0.15rem; font-size: 0.92rem; }
@media print { .ayuda-i, .ayuda-pop { display: none !important; } .con-ayuda { border-bottom: none; } }

/* ---- Resultados: resumen, índices y fichas -------------------------------- */
.kpi-btn { font: inherit; cursor: pointer; text-align: center; color: inherit; transition: transform 0.12s, box-shadow 0.12s; }
.kpi-btn:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.kpi-btn.activo { outline: 2px solid var(--primary); }
.kpi-lista { margin-top: 0.9rem; padding: 0.8rem 1rem; background: var(--surface-2); border-radius: var(--radius-sm); }
.chips-nombres, .chips-pares { display: flex; flex-wrap: wrap; gap: 0.35rem; margin-top: 0.5rem; }
.chip-nombre { font: inherit; font-weight: 700; font-size: 0.88rem; padding: 0.25rem 0.65rem; border-radius: 999px; border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); cursor: pointer; }
.chip-nombre:hover { border-color: var(--primary); color: var(--primary-dark); }
.chip-par { font-size: 0.85rem; padding: 0.2rem 0.6rem; border-radius: 999px; background: var(--surface-2); white-space: nowrap; }
.chips-pos .chip-par { background: var(--success-soft); }
.chips-neg .chip-par { background: var(--danger-soft); }
.lista-alertas { list-style: none; padding: 0; margin: 0.4rem 0 0; }
.lista-alertas li { padding: 0.55rem 0.7rem; border-radius: var(--radius-sm); margin-bottom: 0.4rem; background: var(--surface-2); }
.lista-alertas li.prioritaria { background: var(--danger-soft); border-left: 4px solid var(--danger); }
.la-cab { display: flex; flex-wrap: wrap; align-items: center; gap: 0.35rem; }
.pill-prio { font-size: 0.75rem; font-weight: 800; color: var(--danger); border: 1px solid var(--danger); border-radius: 999px; padding: 0.05rem 0.5rem; }
.tabla-indices th.th-orden { cursor: pointer; user-select: none; white-space: normal; line-height: 1.25; vertical-align: bottom; }
.tabla-indices th .con-ayuda { display: inline; }
.tabla-indices td, .tabla-indices th { padding-left: 0.5rem; padding-right: 0.5rem; }
/* La ficha desplegada no debe ensanchar la tabla: se ajusta al recuadro visible. */
.tabla-indices .detalle-indice > td > * { max-width: calc(100vw - 6rem); }
.tabla-indices th.th-orden:hover { color: var(--primary-dark); }
.tabla-indices .fila-indice:focus-visible { outline: 2px solid var(--primary); outline-offset: -2px; }
.tabla-indices .fila-indice.destacada { background: var(--primary-soft); }
td.nowrap { white-space: nowrap; }
.dato-fila { display: flex; justify-content: space-between; align-items: baseline; gap: 0.6rem; padding: 0.2rem 0; border-bottom: 1px dashed var(--border); }
.dato-fila > b { text-align: right; }
.dato-z { font-weight: 600; font-size: 0.85rem; color: var(--muted); }
.en-pocas { background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--primary); border-radius: var(--radius-sm); padding: 0.6rem 0.8rem; margin-bottom: 0.9rem; line-height: 1.55; }

.dato-fila.con-extra { border-bottom: none; }
.dato-extra { font-size: 0.82rem; color: var(--muted); font-weight: 600; text-align: right; padding: 0 0 0.25rem; border-bottom: 1px dashed var(--border); }

/* Marca «Mirada de grupo» */
.topbar .logo .logo-txt { color: var(--text); white-space: nowrap; }
.topbar .logo .logo-txt span { color: var(--primary); }
@media (max-width: 520px) { .topbar .logo { font-size: 1rem; } }

/* Clases de ejemplo */
.ejemplos-cab { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; margin: 1.6rem 0 0.7rem; padding: 0 0.2rem; }
.card-ejemplo { border-style: dashed; background: color-mix(in srgb, var(--primary-soft) 35%, var(--surface)); }
.pill-ejemplo { background: var(--accent-soft); color: var(--accent); border-color: color-mix(in srgb, var(--accent) 30%, transparent); font-weight: 800; }
.ejemplos-mostrar { text-align: center; margin: 1rem 0; }

/* Enlaces con los colores de la app (antes, el azul/morado del navegador) */
a { color: var(--primary-dark); text-underline-offset: 2px; }
a:hover { color: var(--primary); }
:root[data-theme="dark"] a { color: var(--primary); }
