/* ==================================================================
   GRC — Gobierno, riesgo y cumplimiento: hoja de estilos base.
   Tokens de color con contraste AA verificado (texto ≥ 4.5:1 y
   bordes de controles ≥ 3:1) en tema claro y oscuro.
   ================================================================== */

:root {
  --bg: #EFF2F5;
  --surface: #FFFFFF;
  --surface-2: #E6EBF0;
  --ink: #1C2631;
  --muted: #566475;
  --line: #CFD7E0;
  --line-strong: #7A8796;
  --primary: #2E5C8A;
  --primary-hover: #244B72;
  --on-primary: #FFFFFF;
  --amber: #8A5700;
  --amber-soft: #FBEFD9;
  --danger: #A23A30;
  --danger-soft: #F7E3E0;
  --ok: #2F7350;
  --ok-soft: #E2F0E8;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, .06);
  --shadow: 0 1px 3px rgba(16, 24, 40, .08), 0 4px 12px rgba(16, 24, 40, .05);
  --shadow-lg: 0 12px 32px rgba(16, 24, 40, .16);
  --font: "Atkinson Hyperlegible", "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  color-scheme: light;
}

/* Tema oscuro: automático (sistema) salvo que se elija «claro», o forzado con data-theme="dark". */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #12171D;
    --surface: #1A2129;
    --surface-2: #232C36;
    --ink: #E3E8EE;
    --muted: #9AA7B5;
    --line: #2F3A46;
    --line-strong: #6A7889;
    --primary: #7FA9D6;
    --primary-hover: #9BBCE0;
    --on-primary: #0F1A26;
    --amber: #E3AB52;
    --amber-soft: #3A2D17;
    --danger: #E58A80;
    --danger-soft: #3B2421;
    --ok: #7CC49C;
    --ok-soft: #1D2A23;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .3);
    --shadow: 0 1px 3px rgba(0, 0, 0, .35), 0 4px 12px rgba(0, 0, 0, .2);
    --shadow-lg: 0 12px 32px rgba(0, 0, 0, .5);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #12171D;
  --surface: #1A2129;
  --surface-2: #232C36;
  --ink: #E3E8EE;
  --muted: #9AA7B5;
  --line: #2F3A46;
  --line-strong: #6A7889;
  --primary: #7FA9D6;
  --primary-hover: #9BBCE0;
  --on-primary: #0F1A26;
  --amber: #E3AB52;
  --amber-soft: #3A2D17;
  --danger: #E58A80;
  --danger-soft: #3B2421;
  --ok: #7CC49C;
  --ok-soft: #1D2A23;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .3);
  --shadow: 0 1px 3px rgba(0, 0, 0, .35), 0 4px 12px rgba(0, 0, 0, .2);
  --shadow-lg: 0 12px 32px rgba(0, 0, 0, .5);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--primary); outline-offset: 2px; }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .5rem; }
p { margin: 0 0 .75rem; }
a { color: var(--primary); }
kbd {
  font: inherit;
  font-size: .78rem;
  padding: 0 .35rem;
  border: 1px solid var(--line-strong);
  border-bottom-width: 2px;
  border-radius: 4px;
  color: var(--muted);
}

/* ---------------- Barra superior ---------------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: .55rem 1.25rem;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}
.marca {
  display: flex;
  align-items: center;
  gap: .55rem;
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--ink);
  text-decoration: none;
  line-height: 1.15;
}
.marca svg { flex: none; }
.marca-texto { display: flex; flex-direction: column; }
.marca-sub { font-size: .75rem; font-weight: 400; color: var(--muted); }
.topbar-acciones { display: flex; align-items: center; gap: .35rem; margin-left: auto; }
.hamburguesa { margin-left: -.4rem; min-width: 44px; }
.avatar-boton { padding: .2rem; border-radius: 999px; min-height: 40px; }

/* ---------------- Menú hamburguesa: panel lateral (<dialog>) ---------------- */
.menu-lateral {
  position: fixed;
  inset: 0 auto 0 0;
  margin: 0;
  width: min(320px, 88vw);
  max-width: none;
  height: 100dvh;
  max-height: 100dvh;
  padding: 0;
  border: 0;
  border-right: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow-lg);
  display: none;
  flex-direction: column;
  overflow-y: auto;
}
.menu-lateral[open] { display: flex; animation: deslizar-menu .2s ease-out; }
.menu-lateral::backdrop { background: rgba(8, 12, 20, .45); }
@keyframes deslizar-menu { from { transform: translateX(-100%); } to { transform: none; } }
body:has(.menu-lateral[open]) { overflow: hidden; }
.menu-lateral-cabecera {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .5rem;
  padding: .55rem .6rem .55rem 1rem;
  border-bottom: 1px solid var(--line);
}
.menu-lateral-nav { flex: 1; display: flex; flex-direction: column; gap: .15rem; padding: .75rem; }
.lateral-titulo {
  margin: .9rem .7rem .3rem;
  font-size: .76rem;
  font-weight: 700;
  letter-spacing: .05em;
  text-transform: uppercase;
  color: var(--muted);
}
.lateral-enlace {
  display: flex;
  align-items: center;
  gap: .7rem;
  width: 100%;
  min-height: 44px;
  padding: .45rem .7rem;
  border: 0;
  border-radius: 8px;
  background: none;
  color: var(--ink);
  font-weight: 700;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
}
.lateral-enlace svg { flex: none; color: var(--muted); }
.lateral-enlace:hover { background: var(--surface-2); }
.lateral-enlace[aria-current="page"] {
  background: color-mix(in srgb, var(--primary) 12%, transparent);
  color: var(--primary);
  box-shadow: inset 3px 0 0 var(--primary);
}
.lateral-enlace[aria-current="page"] svg { color: var(--primary); }
.lateral-enlace.inactivo { color: var(--muted); font-weight: 400; cursor: default; }
.lateral-enlace.inactivo:hover { background: none; }
.menu-lateral-pie { display: flex; flex-direction: column; gap: .2rem; padding: .75rem; border-top: 1px solid var(--line); }
.menu-lateral-pie form { margin: 0; }
.lateral-tema { display: flex; flex-direction: column; gap: .35rem; margin-bottom: .6rem; }
.lateral-tema .lateral-titulo { margin: .1rem .7rem 0; }
.lateral-tema .seg { display: flex; border: 1.5px solid var(--line-strong); border-radius: 8px; overflow: hidden; }
.lateral-tema .seg button {
  flex: 1;
  min-height: 38px;
  padding: .35rem .3rem;
  border: 0;
  background: var(--surface);
  color: var(--muted);
  font-size: .85rem;
  font-weight: 700;
  cursor: pointer;
}
.lateral-tema .seg button + button { border-left: 1px solid var(--line); }
.lateral-tema .seg button:hover { color: var(--ink); }
.lateral-tema .seg button[aria-pressed="true"] { background: var(--primary); color: var(--on-primary); }
.lateral-usuario {
  display: flex;
  align-items: center;
  gap: .6rem;
  padding: .6rem;
  margin-bottom: .25rem;
  border-radius: 10px;
  background: var(--surface-2);
}
.lateral-usuario-datos { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.25; }
.lateral-usuario-datos strong,
.lateral-usuario-datos .correo { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lateral-usuario-datos .correo { font-size: .82rem; color: var(--muted); }

/* ---------------- Menús desplegables ---------------- */
details.menu { position: relative; }
details.menu > summary { list-style: none; cursor: pointer; }
details.menu > summary::-webkit-details-marker { display: none; }
.menu-panel {
  position: absolute;
  right: 0;
  top: calc(100% + .35rem);
  z-index: 40;
  min-width: 230px;
  padding: .35rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
}
.menu-panel.izquierda { right: auto; left: 0; }
.menu-item {
  display: flex;
  align-items: center;
  gap: .55rem;
  width: 100%;
  min-height: 40px;
  padding: .4rem .65rem;
  border: 0;
  border-radius: 6px;
  background: none;
  color: var(--ink);
  text-decoration: none;
  text-align: left;
  font-weight: 700;
  cursor: pointer;
}
.menu-item:hover, .menu-item:focus-visible { background: var(--surface-2); }
.menu-panel form { margin: 0; }
.chevron { transition: transform .15s; }
details[open] > summary .chevron { transform: rotate(180deg); }

.avatar {
  flex: none;
  width: 30px;
  height: 30px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  background: var(--primary);
  color: var(--on-primary);
  font-size: .8rem;
  font-weight: 700;
  letter-spacing: .02em;
}

/* ---------------- Contenido ---------------- */
.contenido {
  flex: 1;
  width: 100%;
  max-width: 1100px;
  margin: 0 auto;
  padding: 1.5rem 1.25rem 3rem;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 1.5rem;
  box-shadow: var(--shadow);
}
.panel + .panel { margin-top: 1.25rem; }
.panel.angosto { max-width: 460px; margin: 2rem auto; }
.panel-cabecera {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1.25rem;
}
.panel-cabecera h1 { font-size: 1.6rem; }
.lead { color: var(--muted); margin: 0; max-width: 60ch; }
.hint { color: var(--muted); font-size: .9rem; margin: .35rem 0 0; }

/* ---------------- Formularios ---------------- */
label.fl, .fl { display: block; font-weight: 700; margin: 0 0 .35rem; }
input[type="text"], input[type="email"], input[type="password"], input[type="search"],
select, textarea {
  width: 100%;
  background: var(--surface);
  border: 1.5px solid var(--line-strong);
  border-radius: 8px;
  padding: .6rem .7rem;
  min-height: 44px;
}
textarea { min-height: 90px; resize: vertical; line-height: 1.45; }
input:hover, select:hover, textarea:hover { border-color: var(--primary); }
input[aria-invalid="true"], textarea[aria-invalid="true"] { border-color: var(--danger); }
.error-campo { color: var(--danger); font-size: .9rem; font-weight: 700; margin: .3rem 0 0; }
.formulario { display: flex; flex-direction: column; gap: .9rem; }
.formulario.tarjeta {
  margin-top: .75rem;
  padding: 1rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-2);
  min-width: min(420px, 90vw);
}
.acciones-form { display: flex; gap: .6rem; flex-wrap: wrap; }

/* Contraseña con botón «Mostrar» (lo agrega app.js) */
.campo-password { position: relative; display: block; }
.campo-password input { padding-right: 5.5rem; }
.campo-password .ver-password {
  position: absolute;
  right: .3rem;
  top: 50%;
  transform: translateY(-50%);
  min-height: 34px;
  padding: .2rem .6rem;
  border: 0;
  border-radius: 6px;
  background: none;
  color: var(--primary);
  font-weight: 700;
  font-size: .88rem;
  cursor: pointer;
}
.campo-password .ver-password:hover { background: var(--surface-2); }

.filtros {
  display: flex;
  flex-wrap: wrap;
  gap: .6rem;
  align-items: center;
  margin-bottom: 1rem;
}
.filtros input[type="search"] { flex: 1 1 260px; width: auto; }
.filtros select { flex: 0 1 200px; width: auto; }

/* ---------------- Botones ---------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .45rem;
  min-height: 44px;
  padding: .55rem 1rem;
  border-radius: 8px;
  border: 1.5px solid var(--line-strong);
  background: var(--surface);
  cursor: pointer;
  font-weight: 700;
  white-space: nowrap;
  text-decoration: none;
  color: var(--ink);
}
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--primary); border-color: var(--primary); color: var(--on-primary); box-shadow: var(--shadow-sm); }
.btn.primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--surface-2); }
.btn.small { min-height: 36px; padding: .35rem .7rem; font-size: .9rem; }
.btn.icono { padding-left: .5rem; padding-right: .5rem; min-width: 36px; }
.btn.warn { color: var(--danger); }
.btn.peligro { background: var(--danger); border-color: var(--danger); color: var(--surface); }
.btn.peligro:hover { background: color-mix(in srgb, var(--danger) 85%, var(--ink)); }
.btn:disabled { opacity: .55; cursor: not-allowed; }

.inline { display: inline-flex; align-items: center; gap: .35rem; margin: 0; }

/* ---------------- "Nuevo proceso" plegable ---------------- */
details.nuevo-proceso summary { list-style: none; cursor: pointer; }
details.nuevo-proceso summary::-webkit-details-marker { display: none; }

/* ---------------- Tablas ---------------- */
.tabla-scroll { overflow-x: auto; position: relative; }
.tabla { width: 100%; border-collapse: collapse; }
.tabla th, .tabla td {
  text-align: left;
  padding: .7rem .6rem;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}
.tabla th { color: var(--muted); font-size: .9rem; white-space: nowrap; }
.tabla td.der, .tabla th.der { text-align: right; }
.tabla .sub { display: block; color: var(--muted); font-size: .88rem; margin-top: .15rem; }
.tabla tr[data-href] { cursor: pointer; }
.tabla tbody tr:hover { background: color-mix(in srgb, var(--primary) 5%, transparent); }
.acciones-celda { white-space: nowrap; }
.acciones-celda form { margin-left: .3rem; }
.tabla a.enlace-proceso { color: inherit; text-decoration: none; }
.tabla tr:hover a.enlace-proceso, .tabla a.enlace-proceso:focus-visible { color: var(--primary); text-decoration: underline; }
.tabla .celda-comentario { max-width: 340px; }
.tabla time { white-space: nowrap; }

.resumen-lista {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: .5rem;
  color: var(--muted);
  font-size: .9rem;
  margin: 0 0 .5rem;
}

/* ---------------- Etiquetas de estado ---------------- */
.badge {
  display: inline-block;
  padding: .15rem .6rem;
  border-radius: 999px;
  font-size: .85rem;
  font-weight: 700;
  border: 1.5px solid var(--line);
  white-space: nowrap;
}
.estado-borrador { background: var(--amber-soft); border-color: var(--amber); color: var(--amber); }
.estado-publicado { background: var(--ok-soft); border-color: var(--ok); color: var(--ok); }
.estado-archivado { background: var(--surface-2); color: var(--muted); }
.badge-rol { background: var(--surface-2); color: var(--muted); }

/* ---------------- Tipos de proceso: color (contraste AA en ambos temas) ---------------- */
.tipo-azul { --tipo: #2E5C8A; --tipo-suave: #E3ECF5; }
.tipo-verde { --tipo: #2F7350; --tipo-suave: #E2F0E8; }
.tipo-ambar { --tipo: #8A5700; --tipo-suave: #FBEFD9; }
.tipo-morado { --tipo: #6B4A9B; --tipo-suave: #EFE8F7; }
.tipo-rojo { --tipo: #A23A30; --tipo-suave: #F7E3E0; }
.tipo-turquesa { --tipo: #1F6B70; --tipo-suave: #DDF0F0; }
.tipo-gris { --tipo: #4F5B69; --tipo-suave: #E6EBF0; }
.tipo-rosa { --tipo: #9C3D6B; --tipo-suave: #F8E4EE; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .tipo-azul { --tipo: #7FA9D6; --tipo-suave: #1C2835; }
  :root:not([data-theme="light"]) .tipo-verde { --tipo: #7CC49C; --tipo-suave: #1D2A23; }
  :root:not([data-theme="light"]) .tipo-ambar { --tipo: #E3AB52; --tipo-suave: #3A2D17; }
  :root:not([data-theme="light"]) .tipo-morado { --tipo: #B79BE0; --tipo-suave: #2A2238; }
  :root:not([data-theme="light"]) .tipo-rojo { --tipo: #E58A80; --tipo-suave: #3B2421; }
  :root:not([data-theme="light"]) .tipo-turquesa { --tipo: #6FC4C9; --tipo-suave: #16302F; }
  :root:not([data-theme="light"]) .tipo-gris { --tipo: #A3AFBC; --tipo-suave: #232C36; }
  :root:not([data-theme="light"]) .tipo-rosa { --tipo: #E59BBF; --tipo-suave: #3A2230; }
}
:root[data-theme="dark"] .tipo-azul { --tipo: #7FA9D6; --tipo-suave: #1C2835; }
:root[data-theme="dark"] .tipo-verde { --tipo: #7CC49C; --tipo-suave: #1D2A23; }
:root[data-theme="dark"] .tipo-ambar { --tipo: #E3AB52; --tipo-suave: #3A2D17; }
:root[data-theme="dark"] .tipo-morado { --tipo: #B79BE0; --tipo-suave: #2A2238; }
:root[data-theme="dark"] .tipo-rojo { --tipo: #E58A80; --tipo-suave: #3B2421; }
:root[data-theme="dark"] .tipo-turquesa { --tipo: #6FC4C9; --tipo-suave: #16302F; }
:root[data-theme="dark"] .tipo-gris { --tipo: #A3AFBC; --tipo-suave: #232C36; }
:root[data-theme="dark"] .tipo-rosa { --tipo: #E59BBF; --tipo-suave: #3A2230; }
.badge-tipo {
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  background: var(--tipo-suave, var(--surface-2));
  border-color: var(--tipo, var(--line));
  color: var(--tipo, var(--muted));
}
.badge-tipo .icono-tipo { flex: none; }
.codigo-proceso {
  font-family: ui-monospace, "Cascadia Mono", Consolas, monospace;
  font-size: .82rem;
  font-weight: 700;
  color: var(--muted);
  letter-spacing: .02em;
  white-space: nowrap;
}

/* ---------------- Avisos ---------------- */
.aviso {
  display: flex;
  align-items: flex-start;
  gap: .6rem;
  padding: .75rem .85rem .75rem 1rem;
  border-radius: 10px;
  margin-bottom: 1rem;
  border: 1.5px solid var(--line);
  transition: opacity .25s;
}
.aviso.ocultando { opacity: 0; }
.aviso-ok, .aviso-aviso, .aviso-error { color: var(--ink); }
.aviso-ok { background: var(--ok-soft); border-color: var(--ok); }
.aviso-aviso { background: var(--amber-soft); border-color: var(--amber); }
.aviso-error { background: var(--danger-soft); border-color: var(--danger); }
.aviso-ok::before, .aviso-aviso::before, .aviso-error::before {
  content: "";
  flex: none;
  width: 20px;
  height: 20px;
  margin-top: .1rem;
  background: currentColor;
  -webkit-mask: var(--icono) center / contain no-repeat;
  mask: var(--icono) center / contain no-repeat;
}
.aviso-ok::before {
  color: var(--ok);
  --icono: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3E%3Cpath fill-rule='evenodd' d='M10 1.5a8.5 8.5 0 1 0 0 17 8.5 8.5 0 0 0 0-17zM14.2 7.8l-5 5.2a.9.9 0 0 1-1.3 0l-2.1-2.1a.9.9 0 1 1 1.3-1.3l1.5 1.5 4.3-4.6a.9.9 0 1 1 1.3 1.3z'/%3E%3C/svg%3E");
}
.aviso-aviso::before {
  color: var(--amber);
  --icono: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3E%3Cpath fill-rule='evenodd' d='M8.7 2.3a1.5 1.5 0 0 1 2.6 0l7.4 13.2A1.5 1.5 0 0 1 17.4 18H2.6a1.5 1.5 0 0 1-1.3-2.5zM10 7a1 1 0 0 0-1 1v4a1 1 0 0 0 2 0V8a1 1 0 0 0-1-1zm0 9.2a1.2 1.2 0 1 0 0-2.4 1.2 1.2 0 0 0 0 2.4z'/%3E%3C/svg%3E");
}
.aviso-error::before {
  color: var(--danger);
  --icono: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3E%3Cpath fill-rule='evenodd' d='M10 1.5a8.5 8.5 0 1 0 0 17 8.5 8.5 0 0 0 0-17zM7.4 6.1a.9.9 0 0 0-1.3 1.3L8.7 10l-2.6 2.6a.9.9 0 1 0 1.3 1.3l2.6-2.6 2.6 2.6a.9.9 0 0 0 1.3-1.3L11.3 10l2.6-2.6a.9.9 0 0 0-1.3-1.3L10 8.7z'/%3E%3C/svg%3E");
}
.aviso-texto { flex: 1; min-width: 0; display: flex; flex-wrap: wrap; align-items: center; gap: .35rem .6rem; }
.aviso strong { font-weight: 700; }
.aviso-cerrar {
  flex: none;
  width: 30px;
  height: 30px;
  margin: -.2rem -.2rem -.2rem 0;
  border: 0;
  border-radius: 6px;
  background: none;
  color: var(--muted);
  cursor: pointer;
  display: grid;
  place-items: center;
}
.aviso-cerrar:hover { background: color-mix(in srgb, var(--ink) 8%, transparent); color: var(--ink); }

/* ---------------- Aviso flotante (toast) ---------------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(1.25rem + env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%) translateY(20px);
  background: var(--ink);
  color: var(--bg);
  padding: .6rem 1rem;
  border-radius: 8px;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s, transform .2s;
  font-weight: 700;
  z-index: 50;
  max-width: min(92vw, 480px);
  text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); pointer-events: auto; }
.toast-accion {
  margin-left: .6rem;
  border: 0;
  background: none;
  padding: 0;
  font: inherit;
  font-weight: 700;
  color: inherit;
  text-decoration: underline;
  cursor: pointer;
}

/* ---------------- Modales ---------------- */
.modal {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0;
  width: min(460px, 92vw);
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow-lg);
}
.modal::backdrop { background: rgba(8, 12, 20, .5); }
.modal-cuerpo {
  padding: 1.1rem 1.15rem 1.15rem;
  display: flex;
  flex-direction: column;
  gap: .4rem;
}
.modal-cuerpo h3 { margin: 0 0 .2rem; font-size: 1.15rem; }
.modal-acciones {
  display: flex;
  justify-content: flex-end;
  gap: .5rem;
  margin-top: .7rem;
}

/* ---------------- Paginación ---------------- */
.paginacion { display: flex; gap: .35rem; flex-wrap: wrap; margin-top: 1.25rem; }
.pag {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 40px;
  min-height: 40px;
  padding: 0 .6rem;
  border: 1.5px solid var(--line);
  border-radius: 8px;
  text-decoration: none;
  color: var(--ink);
  font-weight: 700;
}
.pag:hover { background: var(--surface-2); }
.pag.actual { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }

/* ---------------- Acceso (login) ---------------- */
.acceso {
  max-width: 430px;
  margin: 3rem auto 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 1.75rem;
  box-shadow: var(--shadow);
}
.acceso-marca {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .4rem;
  margin: 0 0 1.25rem;
  text-align: center;
}
.acceso-marca strong { font-size: 1.3rem; }
.acceso-marca span { color: var(--muted); font-size: .9rem; }
.acceso h1 { font-size: 1.6rem; }

/* ---------------- Inicio (tablero) ---------------- */
.contadores {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: .75rem;
  margin: 0 0 1.25rem;
}
.contador {
  display: flex;
  flex-direction: column;
  gap: .1rem;
  padding: .85rem 1rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-2);
  color: var(--ink);
  text-decoration: none;
}
a.contador:hover { border-color: var(--primary); }
.contador .cifra { font-size: 1.75rem; font-weight: 700; line-height: 1.1; }
.contador .etiqueta { color: var(--muted); font-size: .9rem; font-weight: 700; }
.columnas {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 1.25rem;
}
.columnas h2 { font-size: 1.1rem; }
.lista-recientes { list-style: none; margin: 0; padding: 0; }
.lista-recientes li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: .75rem;
  padding: .55rem 0;
  border-bottom: 1px solid var(--line);
}
.lista-recientes li:last-child { border-bottom: 0; }
.lista-recientes a { font-weight: 700; color: var(--ink); text-decoration: none; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lista-recientes a:hover { color: var(--primary); text-decoration: underline; }
.lista-recientes .meta { flex: none; display: flex; align-items: center; gap: .5rem; color: var(--muted); font-size: .85rem; }
.modulos {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: .9rem;
}
.modulo {
  display: flex;
  flex-direction: column;
  gap: .5rem;
  padding: 1.1rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  color: var(--ink);
  text-decoration: none;
  box-shadow: var(--shadow-sm);
}
a.modulo:hover { border-color: var(--primary); box-shadow: var(--shadow); }
.modulo h3 { margin: 0; font-size: 1.05rem; display: flex; flex-direction: column-reverse; align-items: flex-start; gap: .45rem; }
.modulo p { margin: 0; color: var(--muted); font-size: .92rem; }
.modulo.inactivo { background: transparent; border-style: dashed; box-shadow: none; }
.modulo.inactivo h3 { color: var(--muted); }

/* ---------------- Estados vacíos ---------------- */
.vacio {
  border: 1.5px dashed var(--line);
  border-radius: 10px;
  padding: 1.25rem;
  color: var(--muted);
}
.vacio-grande {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .5rem;
  text-align: center;
  padding: 2.5rem 1.25rem;
  border: 1.5px dashed var(--line);
  border-radius: 12px;
}
.vacio-grande svg { opacity: .75; margin-bottom: .25rem; }
.vacio-grande h2 { font-size: 1.25rem; margin: 0; }
.vacio-grande p { color: var(--muted); max-width: 48ch; margin: 0 0 .5rem; }

/* ---------------- Configuración ---------------- */
.migas { display: flex; flex-wrap: wrap; gap: .35rem; align-items: center; margin: 0 0 .4rem; font-size: .88rem; color: var(--muted); }
.migas a { color: var(--muted); }
.tabla-tipos td { vertical-align: middle; }
.tabla-tipos tr.inactivo td:not(.acciones-celda) { opacity: .6; }
.tabla-tipos tr.arrastrando { opacity: .4; }
.tabla-tipos tr.soltar-antes td { box-shadow: inset 0 3px 0 var(--primary); }
.tabla-tipos tr.soltar-despues td { box-shadow: inset 0 -3px 0 var(--primary); }
.tabla-tipos .asa-fila { cursor: grab; color: var(--muted); width: 1.5rem; }
.icono-redondo {
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: var(--tipo-suave);
  color: var(--tipo);
  border: 1.5px solid var(--tipo);
}
.seccion-form { border: 1px solid var(--line); border-radius: 10px; padding: 1rem 1.1rem 1.1rem; margin: 0 0 1rem; }
.seccion-form > legend { padding: 0 .35rem; font-weight: 700; }
.seccion-form .hint:first-of-type { margin-top: 0; }
.dos-columnas { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: .9rem; }
.selector-opciones { display: flex; flex-wrap: wrap; gap: .45rem; border: 0; margin: 0; padding: 0; }
.selector-opciones label {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  min-height: 40px;
  padding: .3rem .7rem .3rem .45rem;
  border: 1.5px solid var(--line);
  border-radius: 999px;
  cursor: pointer;
  font-weight: 700;
  font-size: .88rem;
}
.selector-opciones input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.selector-opciones label:has(input:checked) { border-color: var(--primary); box-shadow: 0 0 0 2px var(--primary); }
.selector-opciones label:has(input:focus-visible) { outline: 3px solid var(--primary); outline-offset: 2px; }
.muestra-color { width: 22px; height: 22px; border-radius: 999px; background: var(--tipo); border: 3px solid var(--tipo-suave); box-shadow: 0 0 0 1px var(--tipo); }
.selector-iconos label { padding: .3rem .7rem; }
.vista-previa {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .6rem;
  padding: .7rem .9rem;
  border-radius: 10px;
  background: var(--surface-2);
}
.plantilla-vista { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 1rem; margin: .5rem 0 .9rem; }
.plantilla-vista h3 { font-size: .95rem; margin: 0 0 .35rem; }
.plantilla-vista ol, .plantilla-vista ul { margin: 0; padding-left: 1.3rem; }
.plantilla-vista li { margin: .15rem 0; }
.plantilla-vista .pregunta { list-style: "? "; color: var(--amber); }
/* Usuarios y roles */
.persona { display: flex; align-items: center; gap: .6rem; }
.tabla tr.inactivo td { color: var(--muted); }
.tabla .centro { text-align: center; }
.matriz-permisos tbody th { text-align: left; font-weight: 700; color: var(--ink); white-space: normal; }
.matriz-permisos code, .lead code { font-size: .82rem; }
.permiso-si {
  display: inline-grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 999px;
  background: var(--ok-soft);
  border: 1.5px solid var(--ok);
  color: var(--ok);
  font-weight: 700;
}
.permiso-no { color: var(--muted); }
.opciones-rol { display: grid; gap: .5rem; }
.opcion-rol {
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: .6rem;
  padding: .7rem .85rem;
  border: 1.5px solid var(--line);
  border-radius: 10px;
  cursor: pointer;
}
.opcion-rol input { margin-top: .25rem; accent-color: var(--primary); width: 18px; height: 18px; flex: none; }
.opcion-rol .sub { display: block; color: var(--muted); font-size: .88rem; }
.opcion-rol:has(input:checked) { border-color: var(--primary); box-shadow: 0 0 0 2px var(--primary); background: color-mix(in srgb, var(--primary) 6%, transparent); }
.password-temporal { border: 2px solid var(--amber); background: var(--amber-soft); }
.valor-temporal { display: flex; flex-wrap: wrap; align-items: center; gap: .75rem; margin: .75rem 0 .25rem; }
.valor-temporal code {
  font-family: ui-monospace, "Cascadia Mono", Consolas, monospace;
  font-size: 1.4rem;
  font-weight: 700;
  letter-spacing: .06em;
  padding: .4rem .8rem;
  border-radius: 8px;
  background: var(--surface);
  border: 1.5px dashed var(--amber);
  user-select: all;
}
.fila-accion { display: flex; flex-wrap: wrap; gap: .6rem; align-items: flex-end; }
.fila-accion > div { flex: 1 1 260px; }

.pie {
  border-top: 1px solid var(--line);
  padding: .9rem 1.25rem;
  color: var(--muted);
  font-size: .9rem;
  text-align: center;
  background: var(--surface);
}
.pie p { margin: 0; }

/* ---------------- Responsive ---------------- */
@media (max-width: 720px) {
  .contenido { padding: 1rem .75rem 2rem; }
  .panel { padding: 1rem; }
  .filtros select { flex: 1 1 140px; }
  .panel-cabecera { flex-direction: column; align-items: stretch; }
  .topbar { padding: .45rem .75rem; gap: .5rem; }
  .marca-sub { display: none; }
  .tabla th, .tabla td { padding: .55rem .45rem; }
  .tabla .col-opcional { display: none; }
}

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