/* CIMAP · Componentes — estilos compartidos (misma base que Seguridad) */
:root {
  --carbon: #121417; --grafito: #1E2228; --acero: #3A414B; --gris: #5A616B;
  --papel: #F5F3EF; --linea: #E2DED6; --ambar: #F2A900; --ambar-suave: #FFF4D6;
  --alerta: #B42318; --alerta-suave: #FDECEA; --ok: #1E7B45; --ok-suave: #E6F4EC; --azul: #1D4ED8; --azul-suave: #E8EEFC;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--papel); color: var(--carbon); font-family: 'IBM Plex Sans', system-ui, -apple-system, 'Segoe UI', sans-serif; font-size: 15px; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: inherit; }
.wrap { max-width: 1200px; margin: 0 auto; padding: 0 24px; }
.wrap.angosto { max-width: 780px; }
.mono { font-family: 'IBM Plex Mono', monospace; }
:focus-visible { outline: 3px solid var(--ambar); outline-offset: 2px; }
header.cab { background: var(--carbon); color: var(--papel); border-bottom: 6px solid var(--ambar); }
header.cab .wrap { padding-top: 30px; padding-bottom: 22px; display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; }
header.cab.con-tabs .wrap { padding-bottom: 0; display: block; }
.cab-fila { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
.eyebrow { font-family: 'IBM Plex Mono', monospace; font-size: 12px; letter-spacing: .12em; color: var(--ambar); text-transform: uppercase; }
h1 { margin: 6px 0 4px; font-family: Archivo, sans-serif; font-weight: 800; font-size: clamp(26px, 4vw, 34px); letter-spacing: -.02em; }
header.cab p { margin: 0; color: #C9CED5; max-width: 640px; }
.tabs { display: flex; gap: 4px; overflow-x: auto; }
.tab { background: none; border: 0; color: #C9CED5; padding: 12px 16px; border-radius: 10px 10px 0 0; cursor: pointer; font-weight: 600; white-space: nowrap; min-height: 44px; display: inline-flex; gap: 8px; align-items: center; text-decoration: none; }
.tab[aria-selected="true"] { background: var(--papel); color: var(--carbon); }
.badge { background: var(--ambar); color: var(--carbon); border-radius: 999px; font-size: 12px; padding: 1px 8px; font-family: 'IBM Plex Mono', monospace; }
.badge.mal { background: var(--alerta); color: #fff; }
main.wrap { padding-top: 22px; padding-bottom: 80px; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 0 16px; border-radius: 10px; border: 1px solid transparent; cursor: pointer; font-weight: 600; text-decoration: none; white-space: nowrap; background: none; }
.btn-ambar { background: var(--ambar); color: var(--carbon); } .btn-ambar:hover { background: #FFC21F; }
.btn-linea { border-color: #3A414B; color: var(--papel); } .btn-linea:hover { border-color: var(--ambar); }
.btn-pri { background: var(--carbon); color: var(--papel); } .btn-pri:hover { background: var(--grafito); }
.btn-sec { background: #fff; border-color: var(--linea); color: var(--carbon); } .btn-sec:hover { border-color: var(--acero); }
.btn-ok { background: var(--ok); color: #fff; }
.btn-mal { background: #fff; border-color: #EBC1BC; color: var(--alerta); } .btn-mal:hover { background: var(--alerta-suave); }
.btn-chico { min-height: 36px; padding: 0 12px; font-size: 14px; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }
.tarjeta { background: #fff; border: 1px solid var(--linea); border-radius: 14px; padding: 18px; margin-bottom: 14px; }
.tarjeta h2 { margin: 0 0 4px; font-family: Archivo, sans-serif; font-size: 18px; }
.tarjeta > .ayuda { display: block; margin-bottom: 14px; }
.campo { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.campo > .seg { align-self: flex-start; }
.campo:last-child { margin-bottom: 0; }
label, .etq { font-weight: 600; font-size: 14px; }
.ayuda, .sub { font-size: 13px; color: var(--gris); font-weight: 400; }
input[type=text], input[type=number], input[type=date], input[type=email], input[type=search], select, textarea { width: 100%; min-height: 46px; border: 1px solid var(--linea); border-radius: 10px; padding: 9px 12px; background: #fff; }
textarea { min-height: 80px; resize: vertical; line-height: 1.45; }
.invalido { border-color: var(--alerta) !important; background: var(--alerta-suave) !important; }
.dos { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.tres { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }
.barra { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.barra > .crece { flex: 1 1 240px; }
.buscar { position: relative; flex: 1 1 260px; }
.buscar input { padding-left: 40px; }
.buscar svg { position: absolute; left: 12px; top: 13px; color: var(--gris); pointer-events: none; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi { background: #fff; border: 1px solid var(--linea); border-radius: 14px; padding: 14px 16px; }
.kpi b { display: block; font-family: Archivo, sans-serif; font-size: 30px; line-height: 1.1; }
.kpi span { color: var(--gris); font-size: 13px; }
.kpi.alerta b { color: var(--alerta); } .kpi.ok b { color: var(--ok); }
.lista { background: #fff; border: 1px solid var(--linea); border-radius: 14px; overflow: hidden; }
.tabla { width: 100%; border-collapse: collapse; }
.tabla th { text-align: left; font-family: 'IBM Plex Mono', monospace; font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--gris); background: #FBFAF7; padding: 10px 14px; border-bottom: 1px solid var(--linea); white-space: nowrap; }
.tabla td { padding: 11px 14px; border-top: 1px solid var(--linea); vertical-align: top; }
.tabla tr:first-child td { border-top: 0; }
.tabla tbody tr.clic { cursor: pointer; } .tabla tbody tr.clic:hover { background: #FBFAF7; }
.tabla .num { text-align: right; font-family: 'IBM Plex Mono', monospace; white-space: nowrap; }
.scroll { overflow-x: auto; }
.vacio { padding: 32px; text-align: center; color: var(--gris); }
.chip { display: inline-block; font-size: 12px; padding: 2px 9px; border-radius: 999px; font-weight: 600; white-space: nowrap; }
.chip.ok { background: var(--ok-suave); color: var(--ok); } .chip.mal { background: var(--alerta-suave); color: var(--alerta); }
.chip.aviso { background: var(--ambar-suave); color: #8A5A00; padding: 2px 9px; border: 0; border-radius: 999px; margin: 0; font-size: 12px; } .chip.gris { background: #EEE; color: var(--gris); } .chip.azul { background: var(--azul-suave); color: var(--azul); }
.aviso { padding: 12px 14px; border-radius: 12px; font-size: 14px; margin-bottom: 14px; }
.aviso.info { background: var(--ambar-suave); border: 1px solid #F1D48A; } .aviso.error { background: var(--alerta-suave); border: 1px solid #EBC1BC; color: var(--alerta); }
.aviso.ok { background: var(--ok-suave); border: 1px solid #B9DEC8; color: #145A32; }
.esqueleto { height: 56px; border-top: 1px solid var(--linea); background: linear-gradient(90deg, #f3f1ec 0%, #fbfaf8 50%, #f3f1ec 100%); background-size: 200% 100%; animation: brillo 1.2s infinite; }
@keyframes brillo { to { background-position: -200% 0; } }
.seg { display: inline-flex; border: 1px solid var(--linea); border-radius: 10px; overflow: hidden; background: #fff; flex-wrap: wrap; }
.seg button, .seg label { border: 0; background: none; padding: 0 14px; min-height: 42px; cursor: pointer; font-weight: 600; color: var(--gris); display: inline-flex; align-items: center; position: relative; margin: 0; }
.seg input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.seg button[aria-pressed="true"], .seg label:has(input:checked) { background: var(--carbon); color: var(--papel); }
.opciones { display: flex; flex-wrap: wrap; gap: 8px; }
.opc { position: relative; }
.opc input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.opc span { display: inline-flex; align-items: center; min-height: 38px; padding: 0 13px; border-radius: 999px; border: 1px solid var(--linea); background: #fff; font-size: 14px; }
.opc input:checked + span { background: var(--ambar); border-color: var(--ambar); font-weight: 600; }
.opc input:focus-visible + span { outline: 3px solid var(--ambar); outline-offset: 2px; }
/* panel lateral y modales */
.velo { position: fixed; inset: 0; background: rgba(18,20,23,.45); z-index: 2147483646; }
.panel { position: fixed; top: 0; right: 0; bottom: 0; width: min(640px, 100%); background: #fff; z-index: 2147483647; display: flex; flex-direction: column; box-shadow: -10px 0 30px rgba(0,0,0,.15); }
.p-cab { padding: 18px 22px; border-bottom: 1px solid var(--linea); display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; }
.p-cab h2 { margin: 4px 0 0; font-family: Archivo, sans-serif; font-size: 22px; line-height: 1.2; }
.cerrar { background: none; border: 0; width: 44px; height: 44px; border-radius: 10px; cursor: pointer; font-size: 22px; color: var(--gris); flex-shrink: 0; }
.cerrar:hover { background: var(--papel); }
.p-cuerpo { padding: 18px 22px 24px; overflow-y: auto; flex: 1; }
.p-pie { padding: 12px 22px; border-top: 1px solid var(--linea); background: #FBFAF7; display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.modal { position: fixed; inset: 0; background: rgba(18,20,23,.55); display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 2147483647; }
.caja { background: #fff; border-radius: 16px; width: min(540px, 100%); max-height: calc(100vh - 32px); overflow-y: auto; padding: 22px; }
.caja h3 { margin: 0 0 8px; font-family: Archivo, sans-serif; font-size: 21px; }
.caja .acciones { display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; margin-top: 16px; }
.sec { font-family: 'IBM Plex Mono', monospace; font-size: 12px; letter-spacing: .1em; text-transform: uppercase; color: var(--gris); margin: 20px 0 8px; }
dl.datos { display: grid; grid-template-columns: 140px 1fr; gap: 6px 14px; margin: 0; }
dl.datos dt { color: var(--gris); } dl.datos dd { margin: 0; white-space: pre-wrap; word-break: break-word; }
.galeria { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 8px; }
.galeria figure { margin: 0; }
.galeria button { padding: 0; border: 1px solid var(--linea); border-radius: 10px; overflow: hidden; aspect-ratio: 1; cursor: zoom-in; background: #eee; width: 100%; }
.galeria img { width: 100%; height: 100%; object-fit: cover; display: block; }
.galeria figcaption { font-size: 12px; color: var(--gris); margin-top: 4px; }
.galeria .falta { display: flex; align-items: center; justify-content: center; height: 100%; font-size: 12px; color: var(--gris); padding: 6px; text-align: center; }
.visor { position: fixed; inset: 0; background: rgba(0,0,0,.9); z-index: 2147483647; display: flex; align-items: center; justify-content: center; padding: 20px; cursor: zoom-out; }
.visor img { max-width: 100%; max-height: 100%; border-radius: 8px; background: #fff; }
.pie-fijo { position: fixed; left: 0; right: 0; bottom: 0; background: rgba(245,243,239,.96); border-top: 1px solid var(--linea); padding: 12px 0 calc(12px + env(safe-area-inset-bottom)); z-index: 50; }
.pie-fijo .wrap { display: flex; gap: 12px; align-items: center; }
.pie-fijo .resumen { flex: 1; font-size: 14px; color: var(--gris); min-width: 0; }
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%) translateY(140%); background: var(--carbon); color: var(--papel); padding: 12px 18px; border-radius: 12px; z-index: 2147483647; transition: transform .2s; max-width: calc(100% - 32px); }
.toast:not(.ver) { visibility: hidden; } .toast.ver { transform: translateX(-50%) translateY(0); } .toast.error { background: var(--alerta); }
.graf { height: 260px; position: relative; }
@media (max-width: 760px) {
  .wrap { padding: 0 16px; }
  .dos, .tres { grid-template-columns: 1fr; gap: 0; }
  dl.datos { grid-template-columns: 1fr; } dl.datos dt { margin-top: 6px; }
  .tabla .col-m { display: none; }
  .pie-fijo .resumen { display: none; } .pie-fijo .btn-pri { flex: 1; }
}
@media (prefers-reduced-motion: reduce) { .toast { transition: none; } .esqueleto { animation: none; } }
@media print { header.cab, .barra, .tabs, .no-imprimir, nav, #cimap-nav, .toast { display: none !important; } body { background: #fff; } .lista, .tarjeta { border: 0; } }
body:has(.pie-fijo:not([hidden])) .toast { bottom: 92px; }

/* ---- Componentes ---- */
.rejilla-eq { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 10px; }
.eq { display: flex; flex-direction: column; gap: 8px; text-align: left; background: #fff; border: 1px solid var(--linea); border-radius: 14px; padding: 14px; cursor: pointer; border-left: 6px solid var(--ok); min-height: 120px; }
.eq:hover { border-color: var(--acero); }
.eq.aviso { border-left-color: var(--ambar); } .eq.mal { border-left-color: var(--alerta); } .eq.gris { border-left-color: #C9C4BA; }
.eq .num-eq { font-family: Archivo, sans-serif; font-weight: 800; font-size: 24px; line-height: 1; }
.eq .cuenta { display: flex; gap: 6px; flex-wrap: wrap; margin-top: auto; }
.vida { display: flex; align-items: center; gap: 8px; min-width: 130px; }
.vida .bar { flex: 1; height: 8px; background: var(--papel); border-radius: 4px; overflow: hidden; min-width: 60px; }
.vida .bar i { display: block; height: 100%; background: var(--ok); }
.vida .bar i.proximo { background: var(--ambar); } .vida .bar i.vencido { background: var(--alerta); }
.vida b { font-family: 'IBM Plex Mono', monospace; font-size: 13px; min-width: 42px; text-align: right; }
.grupo-tit { background: #FBFAF7; font-family: 'IBM Plex Mono', monospace; font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--gris); }
.matriz { border-collapse: separate; border-spacing: 0; font-size: 13px; }
.matriz th, .matriz td { border-bottom: 1px solid var(--linea); border-right: 1px solid var(--linea); padding: 6px 8px; white-space: nowrap; }
.matriz thead th { position: sticky; top: 0; background: #FBFAF7; font-family: 'IBM Plex Mono', monospace; font-size: 12px; z-index: 1; }
.matriz tbody th { position: sticky; left: 0; background: #fff; text-align: left; font-weight: 600; max-width: 260px; overflow: hidden; text-overflow: ellipsis; z-index: 1; }
.matriz td { text-align: right; font-family: 'IBM Plex Mono', monospace; cursor: pointer; }
.matriz td.ok { background: #F2FAF5; } .matriz td.proximo { background: var(--ambar-suave); } .matriz td.vencido { background: var(--alerta-suave); color: var(--alerta); font-weight: 600; }
.matriz td.vacio-c { background: #FAFAF8; color: #C9C4BA; cursor: default; }
.leyenda { display: flex; gap: 14px; flex-wrap: wrap; font-size: 13px; color: var(--gris); margin: 8px 0 14px; }
.leyenda span::before { content: ''; display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; background: var(--c); }
.panel.ancho { width: min(1040px, 100%); }
.acc-fila { display: flex; gap: 6px; flex-wrap: wrap; }
.mini-kpis { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.cel-horas small { display: block; color: var(--gris); font-size: 11px; font-family: 'IBM Plex Sans', sans-serif; }

#pTabla tr.padre > td { background: #FFFDF8; }
#pTabla tr.padre > td:first-child { border-left: 4px solid var(--ambar); }
#pTabla tr.hijo > td { background: #FCFBF9; font-size: 14px; }
#pTabla tr.hijo > td:first-child { padding-left: 34px; border-left: 4px solid #F1D48A; }
#pTabla tr.hijo b { font-weight: 500; }
.rama { color: #B7B2A8; margin-right: 6px; font-family: 'IBM Plex Mono', monospace; }
.plegar { border: 0; background: none; cursor: pointer; width: 28px; height: 28px; margin: -4px 4px -4px -6px; border-radius: 6px; font-size: 14px; color: var(--gris); }
.plegar:hover { background: var(--papel); }

.matriz tr.cond-grupo th { position: sticky; left: 0; background: #FBFAF7; font-family: 'IBM Plex Mono', monospace; font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--gris); text-align: left; font-weight: 500; }
.matriz tr.cond-mayor th { font-weight: 700; border-left: 4px solid var(--ambar); }
.matriz tr.cond-hijo th { font-weight: 400; padding-left: 22px; border-left: 4px solid #F1D48A; color: var(--acero); }

.lnk { background: none; border: 0; padding: 0; color: var(--azul); text-decoration: underline; text-underline-offset: 3px; cursor: pointer; font-size: inherit; text-align: left; }
.lnk:hover { color: var(--tinta, #111); }
.lnk:focus-visible { outline: 2px solid var(--ambar); outline-offset: 2px; border-radius: 3px; }
