@import url('https://fonts.googleapis.com/css2?family=Ancizar+Serif:wght@500;600;700&family=Archivo:wght@400;500;600;700&display=swap');

/* ══════════════════════════════════════════════════════════════════════════
   Sistema de diseño — Canvas Risk Dashboard · CEIPA
   Paleta oficial del brand book. Superficies oscuras en azul profundo
   (#160B6C), nunca negro neutro: el negro no es de la marca.
   Menta y limón son casi luminiscentes y NO sirven como texto sobre blanco;
   sobre fondo claro se usan sus variantes oscuras.
   ══════════════════════════════════════════════════════════════════════════ */

:root {
  /* ── Marca ─────────────────────────────────────────────────────────────── */
  --azul-real:      #354EE7;   /* acción principal */
  --azul-profundo:  #160B6C;   /* superficies oscuras y texto */
  --verde-menta:    #95FFF5;   /* acento sobre oscuro */
  --naranja:        #FF5A1D;   /* alertas */
  --limon:          #C4FF00;   /* alta energía, con cuentagotas */

  /* Variantes accesibles sobre blanco (menta y limón no pasan contraste) */
  --menta-oscuro:   #0B4F4A;
  --limon-oscuro:   #5B7800;
  --naranja-oscuro: #C03D08;

  /* ── Superficies ───────────────────────────────────────────────────────── */
  --bg:        #FFFFFF;
  --bg-app:    #F4F5FC;   /* cromo de la app, tintado del azul de marca */
  --surface:   #FFFFFF;
  --surface-2: #F7F8FD;   /* cabeceras de tabla, paneles */
  --surface-3: #EEF0FA;   /* estados hover sobre superficie 2 */

  /* ── Texto (tintado del azul de marca, nunca gris neutro) ──────────────── */
  --text:      #160B6C;   /* 15.2:1 sobre blanco */
  --text-2:    #5A5F8F;   /* 6.2:1 — secundario */
  --text-3:    #6E7396;   /* 4.6:1 — terciario; medido en navegador */

  /* ── Bordes ────────────────────────────────────────────────────────────── */
  --border:      #E4E6F4;
  --border-fuerte: #CDD1EA;

  /* ── Acción ────────────────────────────────────────────────────────────── */
  --accion:        var(--azul-real);   /* 6.3:1 sobre blanco */
  --accion-hover:  #2A3FC4;
  --accion-suave:  #EDEFFE;
  --accion-borde:  #C3CAF9;

  /* ── Semáforo de riesgo ────────────────────────────────────────────────── */
  --alto:        #CE2B06;   /* 4.6:1 sobre su propio fondo tintado */
  --alto-bg:     #FDECE8;
  --medio:       var(--naranja);
  --medio-texto: var(--naranja-oscuro);   /* 5.2:1 — el naranja puro no pasa */
  --medio-bg:    #FFEEE6;
  --bajo:        var(--limon-oscuro);     /* 4.6:1 sobre su propio fondo tintado */
  --bajo-bg:     #F2F6E0;
  --ok:          var(--menta-oscuro);     /* 9.7:1 */
  --ok-bg:       #E3F4F2;

  /* ── Tipografía ────────────────────────────────────────────────────────── */
  --sans:  'Archivo', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  --serif: 'Ancizar Serif', Georgia, 'Times New Roman', serif;

  /* Escala fija (razón ~1.15). Producto no lleva tipografía fluida. */
  --t-2xs: 0.6875rem;  /* 11px */
  --t-xs:  0.75rem;    /* 12px */
  --t-sm:  0.8125rem;  /* 13px */
  --t-base:0.875rem;   /* 14px */
  --t-md:  1rem;       /* 16px */
  --t-lg:  1.125rem;   /* 18px */
  --t-xl:  1.375rem;   /* 22px */
  --t-2xl: 1.75rem;    /* 28px */

  /* ── Espaciado (base 4px) ──────────────────────────────────────────────── */
  --s-1: 4px;  --s-2: 8px;  --s-3: 12px; --s-4: 16px;
  --s-5: 20px; --s-6: 24px; --s-8: 32px; --s-10: 40px;

  /* ── Radios ────────────────────────────────────────────────────────────── */
  --r-sm: 6px; --r-md: 10px; --r-lg: 14px; --r-full: 999px;

  /* ── Sombras (desplazamiento + desenfoque suave, tintadas de marca) ─────── */
  --sh-sm: 0 1px 2px rgba(22,11,108,.06), 0 1px 1px rgba(22,11,108,.04);
  --sh-md: 0 4px 12px rgba(22,11,108,.08), 0 1px 3px rgba(22,11,108,.05);
  --sh-lg: 0 16px 40px rgba(22,11,108,.14), 0 4px 12px rgba(22,11,108,.07);

  /* ── Curvas ────────────────────────────────────────────────────────────── */
  --ease-out:    cubic-bezier(0.23, 1, 0.32, 1);
  --ease-in-out: cubic-bezier(0.77, 0, 0.175, 1);
  --ease-drawer: cubic-bezier(0.32, 0.72, 0, 1);

  --panel-w: 460px;
}

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

html { -webkit-text-size-adjust: 100%; }

body {
  font-family: var(--sans);
  font-size: var(--t-base);
  line-height: 1.5;
  color: var(--text);
  background: var(--bg-app);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ══ Superficies del navegador ═══════════════════════════════════════════
   Selección, cursor, barras y anillos de foco vienen sin diseño por defecto.
   Vestirlos con la paleta es lo que separa una página construida de una
   ensamblada.                                                              */

::selection { background: var(--accion); color: #fff; }

:root { caret-color: var(--accion); accent-color: var(--accion); }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--border-fuerte);
  border-radius: var(--r-full);
  border: 3px solid var(--bg);
  background-clip: padding-box;
}
::-webkit-scrollbar-thumb:hover { background: var(--text-3); background-clip: padding-box; }
* { scrollbar-width: thin; scrollbar-color: var(--border-fuerte) transparent; }

:focus-visible {
  outline: 2px solid var(--accion);
  outline-offset: 2px;
  border-radius: var(--r-sm);
}
:focus:not(:focus-visible) { outline: none; }

/* Cifras alineadas en columna en todo dato numérico */
table, .tabular, input[type="date"], .metrica-val, .stat-n { font-variant-numeric: tabular-nums; }

a { color: var(--accion); text-underline-offset: 3px; text-decoration-thickness: 1px; }

/* ══ Tipografía ══════════════════════════════════════════════════════════
   Archivo carga toda la interfaz (etiquetas, datos, botones): una tipografía
   editorial en celdas de tabla sería ruido. Ancizar Serif se reserva para la
   identidad — título de la app, nombre del estudiante, títulos de modal.     */

.serif { font-family: var(--serif); font-weight: 600; letter-spacing: -0.01em; }

h1, h2, h3 { font-weight: 600; letter-spacing: -0.015em; text-wrap: balance; }

.etiqueta {
  font-size: var(--t-2xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-2);
}

/* ══ Iconos ══════════════════════════════════════════════════════════════
   Un solo sistema: trazo 1.5, sin relleno, extremos redondeados.            */
.ic {
  width: 16px; height: 16px;
  flex-shrink: 0;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.ic-sm { width: 14px; height: 14px; }
.ic-lg { width: 20px; height: 20px; }

/* ══ Botones ═════════════════════════════════════════════════════════════ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s-2);
  padding: 8px 14px;
  border-radius: var(--r-sm);
  border: 1px solid transparent;
  font-family: inherit;
  font-size: var(--t-sm);
  font-weight: 500;
  line-height: 1.2;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition: background-color 140ms ease, border-color 140ms ease,
              color 140ms ease, transform 160ms var(--ease-out);
}
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }

.btn-primario { background: var(--accion); color: #fff; }
@media (hover: hover) and (pointer: fine) {
  .btn-primario:hover:not(:disabled) { background: var(--accion-hover); }
}

.btn-neutro { background: var(--surface); color: var(--text); border-color: var(--border-fuerte); }
@media (hover: hover) and (pointer: fine) {
  .btn-neutro:hover:not(:disabled) { background: var(--surface-2); border-color: var(--text-3); }
}

.btn-fantasma { background: transparent; color: var(--text-2); }
@media (hover: hover) and (pointer: fine) {
  .btn-fantasma:hover:not(:disabled) { background: var(--surface-3); color: var(--text); }
}

.btn-peligro { background: var(--alto-bg); color: var(--alto); border-color: #F5C9BF; }
@media (hover: hover) and (pointer: fine) {
  .btn-peligro:hover:not(:disabled) { background: #FBDDD5; }
}

.btn-icono { padding: 7px; border-radius: var(--r-sm); }

/* ══ Campos ══════════════════════════════════════════════════════════════ */
.campo { display: block; }
.campo > label,
label.etiqueta { display: block; margin-bottom: var(--s-2); }

input[type=text], input[type=email], input[type=password],
input[type=date], textarea, select {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border-fuerte);
  border-radius: var(--r-sm);
  background: var(--surface);
  color: var(--text);
  font-family: inherit;
  font-size: var(--t-base);
  line-height: 1.4;
  transition: border-color 140ms ease, box-shadow 140ms ease;
}
input::placeholder, textarea::placeholder { color: var(--text-3); }
input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--accion);
  box-shadow: 0 0 0 3px var(--accion-suave);
}
textarea { resize: vertical; min-height: 68px; }

select {
  appearance: none;
  padding-right: 30px;
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%235A5F8F' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 9px center;
  background-size: 15px;
  cursor: pointer;
}

/* ══ Tarjeta ═════════════════════════════════════════════════════════════ */
.tarjeta {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-sm);
}

/* ══ Semáforo de riesgo ══════════════════════════════════════════════════
   Punto de color + palabra. El color nunca carga el significado solo.       */
.riesgo {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 9px 3px 7px;
  border-radius: var(--r-full);
  font-size: var(--t-2xs);
  font-weight: 700;
  letter-spacing: .04em;
}
.riesgo::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex-shrink: 0; }
.riesgo-alto  { background: var(--alto-bg);  color: var(--alto); }
.riesgo-medio { background: var(--medio-bg); color: var(--medio-texto); }
.riesgo-bajo  { background: var(--bajo-bg);  color: var(--bajo); }
.riesgo-ok    { background: var(--ok-bg);    color: var(--ok); }

/* Color del dato según umbral */
.v-critico { color: var(--alto); }
.v-malo    { color: var(--medio-texto); }
.v-regular { color: var(--bajo); }
.v-bien    { color: var(--ok); }

/* ══ Estados de contenido ════════════════════════════════════════════════ */
.estado {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: var(--s-3); padding: 64px var(--s-5); text-align: center; color: var(--text-2);
}
.estado svg { width: 32px; height: 32px; color: var(--text-3); }
.estado p { font-size: var(--t-md); color: var(--text); font-weight: 500; }
.estado small { font-size: var(--t-sm); color: var(--text-2); max-width: 46ch; }

.girador {
  width: 26px; height: 26px;
  border: 2.5px solid var(--accion-borde);
  border-top-color: var(--accion);
  border-radius: 50%;
  animation: girar .6s linear infinite;
}
@keyframes girar { to { transform: rotate(360deg); } }

/* Esqueleto de carga — no un girador en medio del contenido */
.esqueleto {
  background: linear-gradient(90deg, var(--surface-2) 25%, var(--surface-3) 37%, var(--surface-2) 63%);
  background-size: 400% 100%;
  animation: brillo 1.4s ease infinite;
  border-radius: var(--r-sm);
}
@keyframes brillo { from { background-position: 100% 50%; } to { background-position: 0 50%; } }

/* ══ Movimiento reducido ═════════════════════════════════════════════════
   Menos movimiento, no cero: se conservan color y opacidad, se quita
   desplazamiento.                                                          */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
  .btn:active { transform: none; }
  .girador { animation: girar 1s linear infinite !important; }
}
