/* Plan de Rodamiento — sistema visual
   Una familia (Inter), cinco tamaños, color solo donde informa:
   azul = acción y "en curso"; verde = finalizado / al día;
   ámbar = por vencer / falta / atención; rojo = vencido / error. */

@font-face { font-family: 'Inter'; font-weight: 400; font-display: swap; src: url('/fuentes/inter-400.woff2') format('woff2'); }
@font-face { font-family: 'Inter'; font-weight: 500; font-display: swap; src: url('/fuentes/inter-500.woff2') format('woff2'); }
@font-face { font-family: 'Inter'; font-weight: 600; font-display: swap; src: url('/fuentes/inter-600.woff2') format('woff2'); }
@font-face { font-family: 'Inter'; font-weight: 700; font-display: swap; src: url('/fuentes/inter-700.woff2') format('woff2'); }

:root {
  /* Tipografía: escala corta */
  --fuente: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --t-1: 0.8125rem;  /* 13: etiquetas, ayudas, tablas densas */
  --t-2: 0.9375rem;  /* 15: texto base */
  --t-3: 1.125rem;   /* 18: títulos de sección */
  --t-4: 1.5rem;     /* 24: título de página */
  --t-5: 2rem;       /* 32: cifras clave */

  /* Espacios (múltiplos de 4) */
  --e-1: 4px; --e-2: 8px; --e-3: 12px; --e-4: 16px; --e-5: 24px; --e-6: 32px; --e-7: 48px;
  --radio: 8px; --radio-s: 6px;

  /* Neutros */
  --fondo: #f4f5f7;
  --superficie: #ffffff;
  --superficie-2: #f8f9fa;
  --tinta: #17212b;
  --tinta-2: #4d5866;
  --tinta-3: #6b7683;
  --linea: #dde1e6;
  --linea-2: #c8ced5;

  /* Color con significado */
  --accion: #1d4f91;
  --accion-hover: #173f75;
  --accion-suave: #e8eef7;
  --ok: #0f6b45;
  --ok-suave: #e6f3ec;
  --atencion: #8a4b00;
  --atencion-borde: #d99a3d;
  --atencion-suave: #fdf3e3;
  --peligro: #b3261e;
  --peligro-suave: #fbeceb;

  --sombra: 0 1px 2px rgba(23, 33, 43, .06), 0 1px 3px rgba(23, 33, 43, .08);
  --sombra-alta: 0 12px 32px rgba(23, 33, 43, .18);
  --foco: 0 0 0 3px rgba(29, 79, 145, .35);
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; font-family: var(--fuente); font-size: var(--t-2); line-height: 1.5; color: var(--tinta);
  background: var(--fondo); font-feature-settings: 'tnum' 1, 'cv11' 1;
}
h1, h2, h3 { margin: 0; line-height: 1.25; font-weight: 600; }
h1 { font-size: var(--t-4); letter-spacing: -0.01em; }
h2 { font-size: var(--t-3); }
h3 { font-size: var(--t-2); }
p { margin: 0; }
a { color: var(--accion); }
small, .t-1 { font-size: var(--t-1); }
.suave { color: var(--tinta-2); }
.tenue { color: var(--tinta-3); }
.num { font-variant-numeric: tabular-nums; }
.oculto { display: none !important; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Botones */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--e-2);
  min-height: 40px; padding: 0 var(--e-4); border-radius: var(--radio-s); border: 1px solid var(--linea-2);
  background: var(--superficie); color: var(--tinta); font: inherit; font-weight: 500; cursor: pointer;
  text-decoration: none; white-space: nowrap; transition: background .12s, border-color .12s;
}
.btn:hover { background: var(--superficie-2); border-color: var(--tinta-3); }
.btn:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, a:focus-visible, [tabindex]:focus-visible {
  outline: none; box-shadow: var(--foco);
}
.btn[disabled] { opacity: .55; cursor: not-allowed; }
.btn-primario { background: var(--accion); border-color: var(--accion); color: #fff; }
.btn-primario:hover { background: var(--accion-hover); border-color: var(--accion-hover); }
.btn-peligro { color: var(--peligro); border-color: #e3b4b0; }
.btn-peligro:hover { background: var(--peligro-suave); border-color: var(--peligro); }
.btn-plano { border-color: transparent; background: transparent; color: var(--accion); padding: 0 var(--e-2); }
.btn-plano:hover { background: var(--accion-suave); border-color: transparent; }
.btn-s { min-height: 32px; padding: 0 var(--e-3); font-size: var(--t-1); }
.btn-l { min-height: 52px; font-size: var(--t-3); font-weight: 600; padding: 0 var(--e-5); }
.btn .icono { width: 18px; height: 18px; flex: none; }
.btn.cargando { position: relative; color: transparent !important; pointer-events: none; }
.btn.cargando::after {
  content: ''; position: absolute; width: 18px; height: 18px; border-radius: 50%;
  border: 2px solid currentColor; border-color: var(--tinta-3) transparent var(--tinta-3) transparent; animation: girar .8s linear infinite;
}
.btn-primario.cargando::after { border-color: #fff transparent #fff transparent; }
@keyframes girar { to { transform: rotate(360deg); } }

/* Formularios */
.campo { display: flex; flex-direction: column; gap: var(--e-1); min-width: 0; }
.campo > label, .etiqueta { font-size: var(--t-1); font-weight: 500; color: var(--tinta-2); }
.campo .ayuda { font-size: var(--t-1); color: var(--tinta-3); }
input[type=text], input[type=email], input[type=password], input[type=date], input[type=number], input[type=search], input[type=tel], select, textarea {
  width: 100%; min-height: 40px; padding: var(--e-2) var(--e-3); border: 1px solid var(--linea-2); border-radius: var(--radio-s);
  background: var(--superficie); color: var(--tinta); font: inherit;
}
textarea { min-height: 80px; resize: vertical; }
input[aria-invalid=true], select[aria-invalid=true] { border-color: var(--peligro); }
.casilla { display: inline-flex; align-items: center; gap: var(--e-2); cursor: pointer; font-size: var(--t-2); }
.casilla input { width: 18px; height: 18px; accent-color: var(--accion); margin: 0; }

/* Mensajes y estados */
.aviso {
  display: flex; gap: var(--e-3); align-items: flex-start; padding: var(--e-3) var(--e-4); border-radius: var(--radio);
  border: 1px solid var(--linea); background: var(--superficie-2); font-size: var(--t-2);
}
.aviso .icono { width: 20px; height: 20px; flex: none; margin-top: 1px; }
.aviso-error { background: var(--peligro-suave); border-color: #f0c2bf; color: #7a1a15; }
.aviso-atencion { background: var(--atencion-suave); border-color: #f1d3a6; color: #5c3300; }
.aviso-ok { background: var(--ok-suave); border-color: #b9dcc9; color: #0b4a30; }
.aviso-info { background: var(--accion-suave); border-color: #c5d5ec; color: #133766; }
.aviso strong { font-weight: 600; }

.etq {
  display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 var(--e-2); border-radius: 999px;
  font-size: var(--t-1); font-weight: 500; white-space: nowrap; background: var(--superficie-2); color: var(--tinta-2); border: 1px solid var(--linea);
}
.etq::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: currentColor; opacity: .9; }
.etq-curso { color: var(--accion); background: var(--accion-suave); border-color: #c5d5ec; }
.etq-ok { color: var(--ok); background: var(--ok-suave); border-color: #b9dcc9; }
.etq-atencion { color: var(--atencion); background: var(--atencion-suave); border-color: #f1d3a6; }
.etq-peligro { color: var(--peligro); background: var(--peligro-suave); border-color: #f0c2bf; }
.etq-neutra::before { display: none; }
.etqs { display: inline-flex; flex-wrap: wrap; gap: var(--e-1); }

.vacio { text-align: center; padding: var(--e-7) var(--e-4); color: var(--tinta-2); }
.vacio h3 { font-size: var(--t-3); color: var(--tinta); margin-bottom: var(--e-2); }
.vacio p { max-width: 46ch; margin: 0 auto var(--e-4); }
.vacio .icono-grande { width: 40px; height: 40px; color: var(--tinta-3); margin-bottom: var(--e-3); }

.esqueleto { background: linear-gradient(90deg, #eceef1 0%, #f6f7f9 50%, #eceef1 100%); background-size: 200% 100%; animation: brillo 1.2s infinite; border-radius: var(--radio-s); }
@keyframes brillo { to { background-position: -200% 0; } }

/* Tarjetas */
.tarjeta { background: var(--superficie); border: 1px solid var(--linea); border-radius: var(--radio); box-shadow: var(--sombra); }
.tarjeta-cuerpo { padding: var(--e-5); }

/* Tablas */
.tabla-marco { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.tabla { width: 100%; border-collapse: collapse; font-size: var(--t-1); }
.tabla th { text-align: left; font-weight: 600; color: var(--tinta-2); padding: var(--e-3) var(--e-4); border-bottom: 1px solid var(--linea); background: var(--superficie-2); white-space: nowrap; }
.tabla td { padding: var(--e-3) var(--e-4); border-bottom: 1px solid var(--linea); vertical-align: top; }
.tabla tbody tr:last-child td { border-bottom: 0; }
.tabla tr.clic { cursor: pointer; }
.tabla tr.clic:hover td { background: #f9fafb; }
.tabla .der { text-align: right; }
.tabla .nw { white-space: nowrap; }
.tabla .fuerte { font-weight: 600; color: var(--tinta); font-size: var(--t-2); }
.tabla td .sub { display: block; color: var(--tinta-3); }

/* Diálogo */
dialog {
  border: 0; padding: 0; border-radius: 12px; box-shadow: var(--sombra-alta); width: min(560px, calc(100vw - 32px));
  max-height: calc(100vh - 48px); color: var(--tinta); background: var(--superficie);
}
dialog.ancho { width: min(880px, calc(100vw - 32px)); }
dialog::backdrop { background: rgba(23, 33, 43, .45); }
.dialogo-cab { display: flex; justify-content: space-between; align-items: center; gap: var(--e-3); padding: var(--e-4) var(--e-5); border-bottom: 1px solid var(--linea); position: sticky; top: 0; background: var(--superficie); z-index: 1; }
.dialogo-cuerpo { padding: var(--e-5); display: flex; flex-direction: column; gap: var(--e-4); }
.dialogo-pie { display: flex; justify-content: flex-end; gap: var(--e-2); padding: var(--e-4) var(--e-5); border-top: 1px solid var(--linea); position: sticky; bottom: 0; background: var(--superficie); flex-wrap: wrap; }

/* Notificación breve */
.brindis {
  position: fixed; left: 50%; bottom: var(--e-5); transform: translateX(-50%) translateY(20px); opacity: 0; z-index: 100;
  background: var(--tinta); color: #fff; padding: var(--e-3) var(--e-4); border-radius: var(--radio); box-shadow: var(--sombra-alta);
  font-size: var(--t-2); max-width: calc(100vw - 32px); transition: opacity .2s, transform .2s; pointer-events: none;
}
.brindis.visible { opacity: 1; transform: translateX(-50%) translateY(0); }
.brindis.error { background: var(--peligro); }

.icono { width: 20px; height: 20px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* Lista de advertencias de documentos */
.advertencias { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: var(--e-2); }
.adv { display: flex; gap: var(--e-3); align-items: flex-start; padding: var(--e-3); border-radius: var(--radio-s); border: 1px solid; font-size: var(--t-1); }
.adv .icono { width: 18px; height: 18px; flex: none; margin-top: 1px; }
.adv span { display: block; font-weight: 500; }
.adv small { display: block; margin-top: 2px; opacity: .85; }
.adv-peligro { background: var(--peligro-suave); border-color: #f0c2bf; color: #7a1a15; }
.adv-atencion { background: var(--atencion-suave); border-color: #f1d3a6; color: #5c3300; }
