/* ══════════════════════════════════════════════════════════════
   PORTAL · estilos compartidos
   Sistema de diseño CIMA v1.0 (mismos tokens que Correos y
   Membresías). Lo usan las páginas del portal; los sistemas NO
   necesitan cargarlo (el toast y la píldora "← Plataforma" traen
   sus propios estilos desde portal.js).
══════════════════════════════════════════════════════════════ */

:root {
  --brand-primary: #0F2DAA;
  --brand-primary-dark: #0a1f7a;
  --brand-primary-light: #e8ecf8;
  --brand-primary-xlight: #f0f3fc;
  --brand-accent: #ED1268;
  --brand-accent-dark: #c40d57;
  --brand-accent-light: #fde8f1;

  --gris-50: #f9fafb;
  --gris-100: #f3f4f8;
  --gris-200: #e5e7ef;
  --gris-300: #d1d5e0;
  --gris-400: #9198b0;
  --gris-500: #6b7494;
  --gris-700: #3d4468;
  --gris-900: #111827;
  --blanco: #ffffff;

  --verde: #059669;    --verde-light: #ecfdf5;
  --rojo: #dc2626;     --rojo-light: #fef2f2;
  --amarillo: #b45309; --amarillo-light: #fffbeb;

  --font: 'Manrope', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --radio: 10px;
  --radio-lg: 16px;
  --radio-xl: 20px;
  --radio-pill: 50px;
  --header-h: 64px;
  --sombra: 0 1px 3px rgba(0,0,0,0.06), 0 2px 12px rgba(15,45,170,0.05);
  --sombra-lg: 0 20px 60px rgba(0,0,0,0.15);
  --foco: 0 0 0 3px rgba(15,45,170,0.18);

  /* alias usados por los sistemas */
  --azul: var(--brand-primary);
  --azul-dark: var(--brand-primary-dark);
  --azul-light: var(--brand-primary-light);
  --azul-xlight: var(--brand-primary-xlight);
  --magenta: var(--brand-accent);
  --magenta-dark: var(--brand-accent-dark);
  --magenta-light: var(--brand-accent-light);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font);
  background: var(--gris-100);
  color: var(--gris-900);
  line-height: 1.5;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
button, input, select, textarea { font-family: var(--font); font-size: inherit; color: inherit; }
a { color: var(--brand-primary); }
img { max-width: 100%; }

:focus-visible { outline: 3px solid rgba(15,45,170,0.4); outline-offset: 2px; }

.sr-only {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}
.saltar {
  position: absolute; left: 16px; top: -60px; z-index: 300;
  background: var(--brand-primary); color: #fff; padding: 10px 16px;
  border-radius: var(--radio); font-weight: 700; font-size: 14px; text-decoration: none;
}
.saltar:focus { top: 12px; }

/* ── BOTONES ──────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 9px 18px; border-radius: var(--radio); border: none;
  font-family: var(--font); font-size: 14px; font-weight: 600; line-height: 1.3;
  cursor: pointer; text-decoration: none; white-space: nowrap;
  transition: background 0.12s, transform 0.08s, opacity 0.12s;
}
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; transform: none; }
.btn svg { width: 16px; height: 16px; flex-shrink: 0; }
.btn-primary { background: var(--brand-primary); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--brand-primary-dark); }
.btn-magenta { background: var(--brand-accent); color: #fff; }
.btn-magenta:hover:not(:disabled) { background: var(--brand-accent-dark); }
.btn-ghost { background: var(--gris-100); color: var(--gris-700); }
.btn-ghost:hover:not(:disabled) { background: var(--gris-200); }
.btn-outline { background: #fff; color: var(--brand-primary); box-shadow: inset 0 0 0 1.5px var(--gris-200); }
.btn-outline:hover:not(:disabled) { box-shadow: inset 0 0 0 1.5px var(--brand-primary); }
.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-lg { padding: 13px 20px; font-size: 15px; font-weight: 700; border-radius: 12px; }
.btn-block { width: 100%; }

.link-btn {
  background: none; border: none; padding: 4px 2px; cursor: pointer;
  color: var(--brand-primary); font-size: 13px; font-weight: 600; text-decoration: none;
}
.link-btn:hover:not(:disabled) { text-decoration: underline; }
.link-btn:disabled { color: var(--gris-400); cursor: not-allowed; }

/* ── FORMULARIOS ──────────────────────────────────────────── */
.field { margin-bottom: 18px; }
.field > label, .flabel, fieldset.field > legend {
  display: block; font-size: 13px; font-weight: 600; color: var(--gris-700); margin-bottom: 6px;
}
fieldset.field { border: none; min-width: 0; }
.input {
  width: 100%; padding: 9px 14px;
  font-family: var(--font); font-size: 14px;
  border: 1.5px solid var(--gris-200); border-radius: var(--radio);
  background: var(--gris-50); color: var(--gris-900);
  outline: none; transition: border-color 0.12s, background 0.12s, box-shadow 0.12s;
}
.input::placeholder { color: var(--gris-400); }
.input:focus { border-color: var(--brand-primary); background: #fff; box-shadow: var(--foco); }
.input:disabled { opacity: 0.6; cursor: not-allowed; }
.input-lg { padding: 12px 16px; font-size: 15px; border-radius: 12px; }
select.input { cursor: pointer; }
.hint { font-size: 12px; color: var(--gris-500); margin-top: 6px; }
.check { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--gris-700); cursor: pointer; }
.check input { width: 16px; height: 16px; accent-color: var(--brand-primary); cursor: pointer; }

/* ── MENSAJES / AVISOS ────────────────────────────────────── */
.msg { padding: 12px 16px; border-radius: var(--radio); font-size: 14px; font-weight: 500; margin-bottom: 20px; line-height: 1.5; }
.msg-error { background: #fef0f3; color: #b0104f; border: 1px solid #f9c9d8; }
.msg-ok { background: #f0faf4; color: #166534; border: 1px solid #bbf7d0; }
.msg-info { background: var(--brand-primary-xlight); color: var(--brand-primary); border: 1px solid var(--brand-primary-light); }

.aviso {
  display: flex; align-items: flex-start; gap: 12px;
  border-radius: var(--radio); padding: 12px 16px; font-size: 14px; line-height: 1.5; margin-bottom: 20px;
}
.aviso > div { flex: 1; min-width: 0; }
.aviso-amarillo { background: var(--amarillo-light); color: var(--amarillo); border: 1px solid #fde68a; }
.aviso-rojo { background: var(--rojo-light); color: var(--rojo); border: 1px solid #fecaca; }
.aviso-azul { background: var(--brand-primary-xlight); color: var(--brand-primary); border: 1px solid var(--brand-primary-light); }
.aviso-verde { background: var(--verde-light); color: var(--verde); border: 1px solid #a7f3d0; }
.aviso-cerrar {
  background: none; border: none; cursor: pointer; color: inherit; opacity: 0.7;
  font-size: 20px; line-height: 1; padding: 0 4px;
}
.aviso-cerrar:hover { opacity: 1; }

/* ── BADGES ───────────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center; padding: 3px 10px; border-radius: 20px;
  font-size: 12px; font-weight: 600; white-space: nowrap; line-height: 1.4;
}
.badge-verde { background: var(--verde-light); color: var(--verde); }
.badge-rojo { background: var(--rojo-light); color: var(--rojo); }
.badge-azul { background: var(--brand-primary-xlight); color: var(--brand-primary); }
.badge-magenta { background: var(--brand-accent-light); color: var(--brand-accent-dark); }
.badge-gris { background: var(--gris-200); color: var(--gris-500); }
.badge-amarillo { background: var(--amarillo-light); color: var(--amarillo); }
.badge-blanco { background: rgba(255,255,255,0.18); color: #fff; }

/* ── CARGA ────────────────────────────────────────────────── */
.spinner {
  width: 22px; height: 22px; border-radius: 50%;
  border: 3px solid var(--gris-200); border-top-color: var(--brand-primary);
  animation: girar 0.8s linear infinite; flex-shrink: 0;
}
@keyframes girar { to { transform: rotate(360deg); } }
.cargando { display: flex; align-items: center; justify-content: center; gap: 12px; padding: 36px 16px; color: var(--gris-500); font-size: 14px; }
.skeleton {
  background: linear-gradient(90deg, var(--gris-200) 25%, var(--gris-100) 37%, var(--gris-200) 63%);
  background-size: 400% 100%; animation: brillo 1.4s ease infinite; border-radius: 8px;
}
@keyframes brillo { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }
@media (prefers-reduced-motion: reduce) {
  .spinner, .skeleton { animation: none; }
  .btn, .input, .sistema-card { transition: none; }
}

/* ══════════════════════════════════════════════════════════════
   LOGIN Y RESTABLECER
══════════════════════════════════════════════════════════════ */
.auth-body { display: flex; align-items: center; justify-content: center; padding: 24px 16px; }
.auth-wrap { width: 100%; max-width: 440px; }
.auth-marca { text-align: center; margin-bottom: 28px; }
.auth-marca img { display: block; width: 260px; max-width: 80%; height: auto; margin: 0 auto; }
.auth-marca-sub {
  font-size: 12px; font-weight: 700; letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--gris-500); margin-top: 12px;
}
.auth-marca-sistemas { font-size: 13px; color: var(--gris-400); margin-top: 2px; }
.auth-card {
  background: var(--blanco); border-radius: var(--radio-xl); padding: 40px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06), 0 4px 24px rgba(15,45,170,0.06);
}
.auth-card h1 { font-size: 20px; font-weight: 700; color: var(--gris-900); margin-bottom: 4px; }
.auth-card .sub { font-size: 14px; color: var(--gris-500); margin-bottom: 26px; }
.auth-card .btn-block { margin-top: 4px; }
.auth-extra { text-align: center; margin-top: 16px; }
.auth-barra { height: 4px; border-radius: var(--radio-pill); margin-top: 28px; background: linear-gradient(90deg, var(--brand-primary), var(--brand-accent)); }
.auth-pie { text-align: center; font-size: 12px; color: var(--gris-400); margin-top: 22px; line-height: 1.6; }
.auth-cuenta {
  font-size: 13px; color: var(--gris-700); background: var(--gris-50); border: 1px solid var(--gris-200);
  border-radius: var(--radio); padding: 10px 14px; margin-bottom: 20px; overflow-wrap: anywhere;
}
.auth-icono {
  width: 52px; height: 52px; border-radius: 16px; display: flex; align-items: center; justify-content: center;
  margin: 0 auto 16px; background: var(--brand-accent-light); color: var(--brand-accent);
}
.auth-icono svg { width: 26px; height: 26px; }
.auth-icono.ok { background: var(--verde-light); color: var(--verde); }
.auth-centro { text-align: center; }
.auth-acciones { display: flex; flex-direction: column; gap: 10px; margin-top: 8px; }
@media (max-width: 480px) {
  .auth-card { padding: 28px 22px; }
}

/* ══════════════════════════════════════════════════════════════
   PÁGINAS CON ENCABEZADO (inicio, admin)
══════════════════════════════════════════════════════════════ */
.app-header { position: sticky; top: 0; z-index: 50; background: var(--blanco); }
.app-header-inner {
  max-width: 1240px; margin: 0 auto; min-height: var(--header-h);
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 10px 28px;
}
.barra-marca { height: 3px; background: linear-gradient(90deg, var(--brand-primary), var(--brand-accent)); }
.app-brand { display: inline-flex; align-items: center; gap: 12px; text-decoration: none; min-width: 0; border-radius: 6px; }
.app-brand img { display: block; height: 24px; width: auto; }
.app-brand-sub {
  font-size: 11px; font-weight: 700; letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--gris-500); border-left: 1.5px solid var(--gris-200); padding-left: 12px; line-height: 1.2;
}
.app-user { display: flex; align-items: center; gap: 12px; min-width: 0; }
.app-user-text { display: flex; flex-direction: column; align-items: flex-end; min-width: 0; line-height: 1.3; }
.app-user-text strong { font-size: 13px; font-weight: 700; color: var(--gris-900); max-width: 240px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.app-user-text span { font-size: 12px; color: var(--gris-500); max-width: 240px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.avatar {
  width: 34px; height: 34px; border-radius: 50%; background: var(--brand-accent); color: #fff;
  display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 14px; flex-shrink: 0;
}
.app-main { max-width: 1240px; margin: 0 auto; padding: 32px 28px 64px; }
/* Páginas con tablas anchas (panel de administración) */
.pagina-ancha .app-header-inner, .pagina-ancha .app-main { max-width: 1480px; }
.app-pie { text-align: center; font-size: 12px; color: var(--gris-400); padding: 0 16px 32px; }

.page-top { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 24px; flex-wrap: wrap; }
.saludo { font-size: 28px; font-weight: 800; letter-spacing: -0.6px; line-height: 1.2; overflow-wrap: anywhere; }
.page-title { font-size: 24px; font-weight: 800; letter-spacing: -0.5px; line-height: 1.25; }
.page-desc { font-size: 14px; color: var(--gris-500); margin-top: 6px; max-width: 640px; }
.page-acciones { display: flex; gap: 10px; flex-wrap: wrap; }

@media (max-width: 640px) {
  .app-header-inner { padding: 10px 16px; gap: 10px; }
  .app-brand { flex-direction: column; align-items: flex-start; gap: 3px; }
  .app-brand img { height: 20px; }
  .app-brand-sub { border-left: none; padding-left: 0; font-size: 10px; }
  .app-user-text { display: none; }
  .avatar { width: 30px; height: 30px; font-size: 13px; }
  .app-main { padding: 22px 16px 48px; }
  .saludo { font-size: 24px; }
  .page-title { font-size: 21px; }
  .page-acciones, .page-acciones .btn { width: 100%; }
}

/* ── SELECTOR DE SISTEMAS ─────────────────────────────────── */
.sistemas-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 20px; }
@media (max-width: 400px) { .sistemas-grid { grid-template-columns: 1fr; } }
.sistema-card {
  position: relative; display: flex; flex-direction: column; gap: 16px; min-height: 210px;
  padding: 26px; border-radius: var(--radio-lg); background: var(--blanco); box-shadow: var(--sombra);
  text-decoration: none; color: var(--gris-900); border: 1.5px solid transparent;
  transition: transform 0.15s, box-shadow 0.15s, border-color 0.15s;
}
.sistema-card:hover { transform: translateY(-2px); box-shadow: 0 6px 24px rgba(15,45,170,0.12); border-color: var(--brand-primary-light); }
.sistema-card:focus-visible { outline: 3px solid rgba(15,45,170,0.45); outline-offset: 3px; }
.sistema-card-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.sistema-ico {
  width: 52px; height: 52px; border-radius: 14px; display: flex; align-items: center; justify-content: center;
  background: var(--brand-primary-xlight); color: var(--brand-primary); flex-shrink: 0;
}
.sistema-ico svg { width: 26px; height: 26px; }
.sistema-nombre { font-size: 19px; font-weight: 800; letter-spacing: -0.3px; line-height: 1.25; }
.sistema-desc { font-size: 14px; color: var(--gris-500); margin-top: 4px; }
.sistema-ir {
  margin-top: auto; display: inline-flex; align-items: center; gap: 6px;
  font-size: 14px; font-weight: 700; color: var(--brand-primary);
}
.sistema-ir span { transition: transform 0.15s; }
.sistema-card:hover .sistema-ir span { transform: translateX(3px); }
.sistema-card-admin { background: var(--brand-primary); color: #fff; }
.sistema-card-admin:hover { border-color: transparent; box-shadow: 0 8px 28px rgba(15,45,170,0.35); }
.sistema-card-admin .sistema-ico { background: rgba(255,255,255,0.14); color: #fff; }
.sistema-card-admin .sistema-desc { color: rgba(255,255,255,0.72); }
.sistema-card-admin .sistema-ir { color: #fff; }
.sistema-card-admin::after {
  content: ''; position: absolute; left: 26px; right: 26px; bottom: 0; height: 3px;
  border-radius: 3px 3px 0 0; background: var(--brand-accent);
}
.sistema-skel { min-height: 210px; border-radius: var(--radio-lg); }

.empty-state { text-align: center; padding: 48px 24px; color: var(--gris-500); background: var(--blanco); border-radius: var(--radio-lg); box-shadow: var(--sombra); }
.empty-state svg { width: 44px; height: 44px; margin: 0 auto 14px; display: block; color: var(--gris-300); }
.empty-state p { font-size: 15px; font-weight: 600; color: var(--gris-700); margin-bottom: 4px; }
.empty-state span { font-size: 13px; }
.empty-state .btn { margin-top: 16px; }

/* ── MÉTRICAS ─────────────────────────────────────────────── */
.metric-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 16px; margin-bottom: 20px; }
.metric-card { background: var(--blanco); border-radius: var(--radio-lg); padding: 18px 22px; box-shadow: var(--sombra); min-width: 0; }
.metric-label { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--gris-400); margin-bottom: 8px; }
.metric-value { font-size: 30px; font-weight: 800; color: var(--gris-900); letter-spacing: -1px; line-height: 1; }
.metric-value.azul { color: var(--brand-primary); }
.metric-value.magenta { color: var(--brand-accent); }
.metric-sub { font-size: 12px; color: var(--gris-500); margin-top: 6px; }
@media (max-width: 480px) {
  .metric-grid { grid-template-columns: 1fr 1fr; gap: 12px; }
  .metric-card { padding: 14px 16px; }
  .metric-value { font-size: 24px; }
}

/* ── AYUDA DE ROLES ───────────────────────────────────────── */
.ayuda { background: var(--blanco); border-radius: var(--radio-lg); box-shadow: var(--sombra); margin-bottom: 20px; }
.ayuda > summary {
  list-style: none; cursor: pointer; padding: 16px 22px; font-size: 14px; font-weight: 700; color: var(--gris-900);
  display: flex; align-items: center; justify-content: space-between; gap: 12px; border-radius: var(--radio-lg);
}
.ayuda > summary::-webkit-details-marker { display: none; }
.ayuda > summary::after { content: '+'; font-size: 20px; font-weight: 600; color: var(--gris-400); line-height: 1; }
.ayuda[open] > summary::after { content: '−'; }
.ayuda-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 14px; padding: 0 22px 20px; }
.ayuda-item { background: var(--gris-50); border: 1px solid var(--gris-200); border-radius: var(--radio); padding: 14px 16px; font-size: 13px; color: var(--gris-700); }
.ayuda-item h3 { font-size: 13px; font-weight: 800; color: var(--gris-900); margin-bottom: 6px; }
.ayuda-item ul { list-style: none; display: flex; flex-direction: column; gap: 4px; }
.ayuda-item strong { color: var(--gris-900); }

/* ── TABLA DE PERSONAS ────────────────────────────────────── */
.table-card { background: var(--blanco); border-radius: var(--radio-lg); box-shadow: var(--sombra); overflow: hidden; }
.table-header {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  padding: 16px 22px; border-bottom: 1px solid var(--gris-200);
}
.table-header-title { font-size: 15px; font-weight: 700; }
.table-header-sub { font-size: 12px; color: var(--gris-500); }
.buscador { position: relative; width: 300px; max-width: 100%; }
.buscador svg { position: absolute; left: 12px; top: 50%; width: 16px; height: 16px; transform: translateY(-50%); color: var(--gris-400); pointer-events: none; }
.buscador .input { padding-left: 36px; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th {
  font-size: 12px; font-weight: 600; color: var(--gris-500); text-transform: uppercase; letter-spacing: 0.05em;
  padding: 12px 16px; text-align: left; background: var(--gris-50); border-bottom: 1px solid var(--gris-200); white-space: nowrap;
}
td { padding: 12px 16px; font-size: 14px; color: var(--gris-700); border-bottom: 1px solid var(--gris-100); vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: var(--gris-50); }
th.centro, td.centro { text-align: center; }

.tabla-usuarios th, .tabla-usuarios td { padding-left: 12px; padding-right: 12px; }
.tabla-usuarios th:first-child, .tabla-usuarios td:first-child { padding-left: 20px; }
.tabla-usuarios th:last-child, .tabla-usuarios td:last-child { padding-right: 20px; }
.tabla-usuarios .col-persona { min-width: 270px; }
.tabla-usuarios .col-rol { min-width: 150px; }
.tabla-usuarios th.col-rol { white-space: normal; }
.tabla-usuarios .col-rol .select-rol { min-width: 138px; }
.tabla-usuarios .col-acciones { text-align: right; white-space: nowrap; }
.tabla-usuarios tr.inactivo .input-inline,
.tabla-usuarios tr.inactivo .persona-email { opacity: 0.6; }
.tabla-usuarios tr.guardando { opacity: 0.75; }
.input-inline {
  padding: 6px 10px; font-weight: 700; color: var(--gris-900);
  background: transparent; border-color: transparent;
}
.input-inline:hover { border-color: var(--gris-200); background: var(--gris-50); }
.input-inline:focus { background: #fff; }
.persona-email { font-size: 13px; color: var(--gris-500); padding: 0 10px; display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.persona-email > span:first-child { overflow-wrap: anywhere; min-width: 0; }
.ultimo { font-size: 13px; white-space: nowrap; }

.select-rol { padding: 7px 10px; font-size: 13px; font-weight: 600; }
.select-rol[data-valor=""] { color: var(--gris-500); }
.select-rol[data-valor="usuario"] { color: var(--brand-primary); background: var(--brand-primary-xlight); border-color: var(--brand-primary-light); }
.select-rol[data-valor="admin"] { color: var(--brand-accent-dark); background: var(--brand-accent-light); border-color: #f9c9d8; }

.fila-vacia td { text-align: center; padding: 36px 16px; color: var(--gris-500); }

/* Interruptor accesible (checkbox con role="switch") */
.switch { position: relative; display: inline-flex; align-items: center; vertical-align: middle; cursor: pointer; }
.switch input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; z-index: 1; }
.switch-track {
  position: relative; width: 40px; height: 23px; border-radius: 50px; background: var(--gris-300);
  transition: background 0.15s; flex-shrink: 0;
}
.switch-track::after {
  content: ''; position: absolute; top: 3px; left: 3px; width: 17px; height: 17px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,0.25); transition: transform 0.15s;
}
.switch input:checked + .switch-track { background: var(--verde); }
.switch-magenta input:checked + .switch-track { background: var(--brand-accent); }
.switch input:checked + .switch-track::after { transform: translateX(17px); }
.switch input:focus-visible + .switch-track { outline: 3px solid rgba(15,45,170,0.4); outline-offset: 2px; }
.switch input:disabled { cursor: not-allowed; pointer-events: none; }
.switch input:disabled + .switch-track { opacity: 0.45; }
.switch.bloqueado { cursor: help; }
@media (prefers-reduced-motion: reduce) { .switch-track, .switch-track::after { transition: none; } }

/* Tabla → tarjetas en pantallas angostas */
@media (max-width: 900px) {
  .tabla-usuarios thead { display: none; }
  .tabla-usuarios, .tabla-usuarios tbody, .tabla-usuarios tr, .tabla-usuarios td { display: block; width: 100%; }
  .tabla-usuarios tr[hidden] { display: none !important; }
  .tabla-usuarios tbody tr { padding: 14px 16px 10px; border-bottom: 1px solid var(--gris-200); }
  .tabla-usuarios tbody tr:last-child { border-bottom: none; }
  .tabla-usuarios tbody tr:hover td { background: transparent; }
  .tabla-usuarios td {
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    padding: 7px 0; border: none; min-width: 0 !important;
  }
  .tabla-usuarios td:first-child, .tabla-usuarios td:last-child { padding-left: 0; padding-right: 0; }
  .tabla-usuarios td[data-label]::before {
    content: attr(data-label); font-size: 12px; font-weight: 700; color: var(--gris-500);
    text-transform: uppercase; letter-spacing: 0.04em; flex-shrink: 0;
  }
  .tabla-usuarios td.col-persona { display: block; padding-bottom: 10px; }
  .tabla-usuarios td.col-persona .input-inline { font-size: 15px; padding-left: 0; padding-right: 0; }
  .tabla-usuarios td.col-persona .input-inline:focus,
  .tabla-usuarios td.col-persona .input-inline:hover { padding-left: 10px; padding-right: 10px; }
  .tabla-usuarios td.col-persona .persona-email { padding: 0; }
  .tabla-usuarios .select-rol { width: auto; min-width: 150px; max-width: 60%; }
  .tabla-usuarios td.col-acciones { justify-content: flex-end; }
  .tabla-usuarios td.col-acciones:empty { display: none; }
  .tabla-usuarios .fila-vacia td { display: block; }
  .table-header { padding: 14px 16px; }
  .buscador { width: 100%; }
}

/* ── MODAL ────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0; z-index: 200; background: rgba(17,24,39,0.45);
  display: flex; align-items: flex-start; justify-content: center; padding: 24px 16px; overflow-y: auto;
}
.modal {
  width: 100%; max-width: 520px; margin: auto; background: #fff; border-radius: var(--radio-lg);
  box-shadow: var(--sombra-lg); overflow: hidden;
}
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 18px 24px; border-bottom: 1px solid var(--gris-200); }
.modal-head h2 { font-size: 16px; font-weight: 700; }
.modal-close { background: none; border: none; font-size: 24px; color: var(--gris-400); cursor: pointer; line-height: 1; padding: 2px 8px; border-radius: 8px; }
.modal-close:hover { color: var(--gris-900); background: var(--gris-100); }
.modal-body { padding: 22px 24px; }
.modal-footer { display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; padding: 14px 24px; border-top: 1px solid var(--gris-200); background: var(--gris-50); }
.rol-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--gris-100); }
.rol-row:last-of-type { border-bottom: none; }
.rol-row label { font-size: 14px; font-weight: 600; color: var(--gris-900); }
.rol-row .select-rol { width: 170px; flex-shrink: 0; }
.resultado { text-align: center; padding: 8px 0; }
.resultado .auth-icono { margin-bottom: 14px; }
.resultado h3 { font-size: 17px; font-weight: 800; margin-bottom: 8px; }
.resultado p { font-size: 14px; color: var(--gris-700); overflow-wrap: anywhere; }
.resultado .aviso { text-align: left; margin: 16px 0 0; }
body.modal-abierto { overflow: hidden; }
@media (max-width: 480px) {
  .modal-head, .modal-body, .modal-footer { padding-left: 18px; padding-right: 18px; }
  .modal-footer .btn { flex: 1; }
  .rol-row .select-rol { width: 150px; }
}
