/* Marca ISCOM (fuente de verdad: src/IscomToolkit.Core/Branding.cs). El rojo de marca es para la interfaz y los botones;
   el estado "mal" del semáforo sigue usando --bad (#B91C1C), con palabra y fondo propios para que no se confundan. */
:root {
  --brand: #AD1216; --brand-dark: #8A0E11; --brand-light: #FBECEC;
  --ink: #1F2937; --muted: #6B7280; --line: #E5E7EB; --bg: #F8FAFC;
  --ok: #15803D; --ok-bg: #DCFCE7; --warn: #B45309; --warn-bg: #FEF3C7; --warn-dot: #F59E0B; --bad: #B91C1C; --bad-bg: #FEE2E2; --gris: #9CA3AF; --gris-bg: #F3F4F6;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body { font-family: "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif; font-size: 14px; color: var(--ink); background: var(--bg); line-height: 1.4; }
a { color: var(--ink); text-decoration: underline; text-decoration-color: var(--line); text-underline-offset: 2px; }
a:hover { color: var(--brand); text-decoration-color: var(--brand); }
h2 { font-size: 22px; font-weight: 600; margin: 0 0 4px; }
h3 { font-size: 15px; font-weight: 600; margin: 0 0 10px; }
h4 { margin: 0; }
.sub { color: var(--muted); font-size: 13px; margin: 0 0 16px; }

/* ---------- cabecera y navegación ---------- */
/* Cabecera blanca con el logotipo, línea vertical fina, nombre del producto y subtítulo; borde inferior rojo de marca. */
header.top { background: #fff; color: var(--ink); padding: 0 24px; display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 64px; flex-wrap: wrap; border-bottom: 4px solid var(--brand); }
header.top .brand { display: flex; align-items: center; gap: 14px; padding: 10px 0; }
header.top .brand a { text-decoration: none; display: flex; align-items: center; gap: 14px; color: var(--ink); }
header.top .brand img { height: 38px; width: auto; display: block; }
header.top .brand .sep { width: 1px; height: 40px; background: var(--line); }
header.top .brand h1 { font-size: 18px; font-weight: 600; margin: 0; line-height: 1.2; }
header.top .brand small { display: block; font-size: 12px; color: var(--muted); }
header.top nav.secciones { display: flex; gap: 2px; align-self: stretch; }
header.top nav.secciones a { color: var(--muted); padding: 0 14px; display: flex; align-items: center; border-bottom: 3px solid transparent; margin-bottom: -4px; font-weight: 500; text-decoration: none; }
header.top nav.secciones a:hover { color: var(--ink); background: var(--bg); }
header.top nav.secciones a.active { color: var(--ink); border-bottom-color: var(--brand); font-weight: 600; }
header.top nav.secciones a .ico { margin-right: 6px; }
header.top nav.secciones a.active .ico { color: var(--brand); }
header.top form.buscar { display: flex; align-items: center; gap: 6px; border: 1px solid var(--line); border-radius: 20px; padding: 4px 12px; background: var(--bg); color: var(--muted); margin-left: auto; }
header.top form.buscar:focus-within { border-color: var(--brand); background: #fff; }
header.top form.buscar input { border: 0; background: transparent; font: inherit; font-size: 13px; width: 210px; outline: none; color: var(--ink); }
.ico { width: 18px; height: 18px; vertical-align: -4px; flex: none; }
.ico.grande { width: 28px; height: 28px; }
details.ayuda { background: var(--brand-light); border-radius: 8px; padding: 0; margin: 0 0 14px; font-size: 13px; }
details.ayuda summary { cursor: pointer; padding: 9px 14px; font-weight: 600; color: var(--brand); list-style: none; display: flex; align-items: center; gap: 6px; }
details.ayuda summary::-webkit-details-marker { display: none; }
details.ayuda summary::after { content: "Mostrar"; margin-left: auto; font-weight: 400; font-size: 12px; color: var(--muted); }
details.ayuda[open] summary::after { content: "Ocultar"; }
details.ayuda > div { padding: 0 14px 10px; color: var(--ink); }
details.ayuda p { margin: 6px 0; }
.filtros { display: flex; flex-wrap: wrap; gap: 8px 14px; align-items: center; margin-bottom: 12px; }
.filtros label { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.filtros select { font: inherit; font-size: 13px; padding: 6px 8px; border: 1px solid var(--line); border-radius: 6px; background: #fff; color: var(--ink); max-width: 240px; }
.resultado h3 { display: flex; align-items: center; gap: 8px; }
.resultado h3 .n { font-size: 12px; color: var(--muted); font-weight: 400; }
header.top .right { display: flex; align-items: center; gap: 12px; font-size: 12px; color: var(--muted); padding: 10px 0; }
header.top button { background: #fff; border: 1px solid var(--line); color: var(--ink); padding: 5px 11px; border-radius: 6px; cursor: pointer; font: inherit; font-size: 13px; }
header.top button:hover { border-color: var(--brand); color: var(--brand); }
nav.migas { max-width: 1180px; margin: 0 auto; padding: 14px 16px 0; font-size: 13px; color: var(--muted); display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
nav.migas a { color: var(--muted); text-decoration: none; }
nav.migas a:hover { color: var(--brand); text-decoration: underline; }
nav.migas span.sep { color: var(--gris); }
nav.migas b { color: var(--ink); font-weight: 600; }
footer.iscom { max-width: 1180px; margin: 0 auto; display: flex; align-items: center; gap: 12px; padding: 14px 16px 28px; color: var(--muted); font-size: 12px; border-top: 1px solid var(--line); }
footer.iscom img { height: 16px; width: auto; }

main { max-width: 1180px; margin: 0 auto; padding: 16px 16px 48px; }
.cabecera { display: flex; flex-wrap: wrap; gap: 12px 24px; align-items: flex-start; justify-content: space-between; margin-bottom: 14px; }
.cabecera h2 { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.cabecera .acciones { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.card { background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 16px; margin-bottom: 14px; }
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.toolbar input[type=search] { padding: 8px 10px; border: 1px solid var(--line); border-radius: 6px; font: inherit; min-width: 220px; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; margin-bottom: 14px; }
.kpi { background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 12px 14px; }
.kpi b { display: block; font-size: 24px; font-weight: 600; color: var(--ink); line-height: 1.2; }
.kpi span { font-size: 12px; color: var(--muted); }
.kpi.rojo b { color: var(--bad); } .kpi.amarillo b { color: var(--warn); } .kpi.verde b { color: var(--ok); } .kpi.brand b { color: var(--brand); }
a.kpi { display: block; color: inherit; } a.kpi:hover { text-decoration: none; border-color: var(--brand); }

/* filtros tipo "chip" */
.chips { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.chips .etq { font-size: 12px; color: var(--muted); margin-right: 2px; }
.chip { background: #fff; border: 1px solid var(--line); border-radius: 20px; padding: 4px 12px; font: inherit; font-size: 13px; cursor: pointer; color: var(--ink); }
.chip:hover { border-color: var(--brand); }
.chip.active { background: var(--brand); border-color: var(--brand); color: #fff; }
.chip .n { opacity: .7; font-size: 12px; margin-left: 4px; }

/* ---------- tablas ---------- */
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 12px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .02em; white-space: nowrap; }
tr.link { cursor: pointer; }
tr.link:hover td { background: var(--brand-light); }
td.num, th.num { text-align: right; white-space: nowrap; }
.small { font-size: 12px; color: var(--muted); }
.mono { font-family: Consolas, "Cascadia Mono", monospace; font-size: 12px; }
.muted { color: var(--muted); }
.empty { padding: 32px 16px; text-align: center; color: var(--muted); }
.empty b { display: block; color: var(--ink); font-size: 15px; margin-bottom: 4px; }
.empty.ok b { color: var(--ok); }

/* ---------- semáforo ---------- */
.dot { display: inline-block; width: 12px; height: 12px; border-radius: 50%; vertical-align: middle; margin-right: 6px; background: var(--gris); flex: none; }
.dot.verde { background: var(--ok); } .dot.amarillo { background: var(--warn-dot); } .dot.rojo { background: var(--bad); }
.pill { display: inline-block; padding: 2px 9px; border-radius: 10px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.pill.verde { background: var(--ok-bg); color: var(--ok); } .pill.amarillo { background: var(--warn-bg); color: var(--warn); }
.pill.rojo { background: var(--bad-bg); color: var(--bad); } .pill.gris { background: var(--gris-bg); color: var(--muted); }
.pill.at { background: var(--brand-light); color: var(--brand); font-weight: 600; }
.pills { display: inline-flex; flex-wrap: wrap; gap: 4px; margin-top: 2px; }
.at-row .btn { margin-left: 8px; }
.dup-grupo { margin-bottom: 18px; }
.dup-grupo h3 { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.dup-grupo .nota { font-size: 12px; color: var(--muted); margin: 0 0 8px; }
.pill.ok { background: var(--ok-bg); color: var(--ok); } .pill.advertencias { background: var(--warn-bg); color: var(--warn); } .pill.errores { background: var(--bad-bg); color: var(--bad); }
.bar { height: 8px; background: var(--line); border-radius: 4px; overflow: hidden; min-width: 90px; }
.bar i { display: block; height: 100%; background: var(--ok); }
.bar.amarillo i { background: var(--warn-dot); } .bar.rojo i { background: var(--bad); }
.pct { display: flex; align-items: center; gap: 8px; white-space: nowrap; }
.score { display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: 50%; font-weight: 700; font-size: 13px; color: #fff; background: var(--gris); vertical-align: middle; margin-right: 6px; flex: none; }
.score.verde { background: var(--ok); } .score.amarillo { background: #D97706; } .score.rojo { background: var(--bad); }
.score.grande { width: 64px; height: 64px; font-size: 24px; }
.leyenda { font-size: 12px; color: var(--muted); display: flex; flex-wrap: wrap; gap: 6px 16px; margin: 10px 0 0; }
.leyenda span { display: inline-flex; align-items: center; gap: 4px; }

/* ---------- alertas ---------- */
.alerta td:first-child { white-space: nowrap; }
.alerta .donde { font-weight: 600; }
.alerta .donde .small { font-weight: 400; }
.alerta.rojo td:first-child { border-left: 4px solid var(--bad); }
.alerta.amarillo td:first-child { border-left: 4px solid var(--warn-dot); }
.alerta td.ver { white-space: nowrap; text-align: right; }
.tipo { display: inline-flex; align-items: center; gap: 3px; font-size: 11px; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); background: var(--gris-bg); border-radius: 4px; padding: 1px 6px; }
.tipo .ico, .btn .ico { width: 13px; height: 13px; vertical-align: -2px; }

/* ---------- tarjetas de equipo ---------- */
.equipos { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; }
.equipo { background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 14px; border-left: 5px solid var(--gris); display: flex; flex-direction: column; gap: 6px; }
.equipo.verde { border-left-color: var(--ok); } .equipo.amarillo { border-left-color: var(--warn-dot); } .equipo.rojo { border-left-color: var(--bad); }
.equipo h4 { font-size: 15px; font-weight: 600; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.equipo h4 a { color: var(--ink); text-decoration: none; }
.equipo h4 a:hover { color: var(--brand); text-decoration: underline; }
.equipo .meta { font-size: 12px; color: var(--muted); }
.equipo .datos { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin: 4px 0; }
.equipo .dato { background: var(--bg); border-radius: 6px; padding: 6px 8px; font-size: 12px; }
.equipo .dato b { display: block; font-size: 13px; font-weight: 600; color: var(--ink); }
.equipo .dato span { color: var(--muted); }
.equipo .motivo { font-size: 12px; color: var(--muted); }
.equipo .motivo.rojo { color: var(--bad); } .equipo .motivo.amarillo { color: var(--warn); }
.equipo .pie { margin-top: auto; display: flex; justify-content: flex-end; }

/* ---------- pestañas ---------- */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 14px; overflow-x: auto; }
.tabs button, .tabs a { background: none; border: 0; border-bottom: 3px solid transparent; padding: 9px 14px; font: inherit; font-size: 14px; color: var(--muted); cursor: pointer; white-space: nowrap; text-decoration: none; }
.tabs button.active, .tabs a.active { color: var(--brand); border-bottom-color: var(--brand); font-weight: 600; }
.tabs .n { background: var(--gris-bg); color: var(--muted); border-radius: 10px; padding: 0 7px; font-size: 11px; margin-left: 5px; }
.hidden { display: none !important; }

/* ---------- ventanas y detalle ---------- */
.modal-bg { position: fixed; inset: 0; background: rgba(31,41,55,.45); display: grid; place-items: center; padding: 16px; z-index: 10; }
.modal { background: #fff; border-radius: 10px; width: min(960px, 100%); max-height: 90vh; overflow: auto; padding: 20px; }
.modal header { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 12px; }
.modal header button { background: #fff; border: 1px solid var(--line); border-radius: 6px; padding: 6px 12px; cursor: pointer; font: inherit; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 12px; }
dl { margin: 0; display: grid; grid-template-columns: max-content 1fr; gap: 4px 12px; font-size: 13px; }
dt { color: var(--muted); } dd { margin: 0; }
ul.motivos { margin: 0; padding-left: 18px; }
ul.motivos li { margin: 2px 0; }

/* ---------- auditoría: plan de acción ---------- */
.sev { display: inline-block; padding: 2px 8px; border-radius: 4px; font-size: 11px; font-weight: 700; color: #fff; text-transform: uppercase; letter-spacing: .03em; white-space: nowrap; }
.sev.Critica { background: #b91c1c; } .sev.Alta { background: #c2410c; } .sev.Media { background: #b45309; } .sev.Baja { background: #1d4ed8; } .sev.Info { background: #6b7280; }
.hallazgo { border: 1px solid var(--line); border-left: 4px solid var(--gris); border-radius: 8px; padding: 10px 12px; margin-bottom: 8px; display: grid; grid-template-columns: auto 1fr; gap: 10px; background: #fff; }
.hallazgo.Critica { border-left-color: #b91c1c; } .hallazgo.Alta { border-left-color: #c2410c; } .hallazgo.Media { border-left-color: #b45309; } .hallazgo.Baja { border-left-color: #1d4ed8; } .hallazgo.Info { border-left-color: #6b7280; }
.hallazgo.atendido { opacity: .6; background: var(--bg); }
.hallazgo.atendido h4 .titulo { text-decoration: line-through; }
.hallazgo h4 { font-size: 14px; font-weight: 600; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.hallazgo p { margin: 3px 0; font-size: 13px; }
.hallazgo .check { padding-top: 2px; }
.hallazgo .check input { width: 18px; height: 18px; cursor: pointer; }
.hallazgo .quien { font-size: 12px; color: var(--ok); }
details.rutina { border: 1px solid var(--line); border-radius: 8px; margin-bottom: 8px; background: #fff; }
details.rutina summary { cursor: pointer; padding: 8px 12px; font-weight: 600; font-size: 13px; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
details.rutina > div { padding: 0 12px 10px; overflow-x: auto; }
.tag { display: inline-block; padding: 1px 7px; border-radius: 10px; font-size: 11px; background: var(--brand-light); color: var(--brand); font-weight: 600; }
.tag.nuevo { background: var(--bad-bg); color: var(--bad); } .tag.persiste { background: var(--warn-bg); color: var(--warn); }
.secreto { user-select: all; }

/* ---------- agente ligero ---------- */
.agente-card { border: 1px solid var(--line); border-left: 5px solid var(--gris); border-radius: 8px; padding: 12px 14px; background: #fff; display: flex; flex-direction: column; gap: 8px; }
.agente-card.verde { border-left-color: var(--ok); } .agente-card.amarillo { border-left-color: var(--warn-dot); }
.agente-card h3 { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin: 0; }
.agente-card h3 .ico { color: var(--brand); }
.agente-card p { margin: 0; }
table.alertas-agente td.detalle { max-width: 420px; overflow-wrap: anywhere; }
tr.alerta-ag.rojo td:first-child { border-left: 4px solid var(--bad); }
tr.alerta-ag.amarillo td:first-child { border-left: 4px solid var(--warn-dot); }
tr.alerta-ag.resuelta td { color: var(--muted); background: var(--bg); }
tr.alerta-ag.resuelta td b { font-weight: 500; }

/* ---------- formularios y botones ---------- */
.login { max-width: 380px; margin: 60px auto; }
.login label { display: block; font-size: 13px; font-weight: 600; margin: 12px 0 4px; }
.login input { width: 100%; padding: 9px 10px; border: 1px solid var(--line); border-radius: 6px; font: inherit; }
.btn-primary { background: var(--brand); color: #fff; border: 1px solid var(--brand); border-radius: 6px; padding: 8px 14px; font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; display: inline-block; }
.btn-primary:hover { background: var(--brand-dark); text-decoration: none; }
.btn { background: #fff; color: var(--ink); border: 1px solid var(--line); border-radius: 6px; padding: 7px 12px; font: inherit; cursor: pointer; text-decoration: none; display: inline-block; }
.btn:hover { border-color: var(--brand); color: var(--brand); text-decoration: none; }
.btn.danger { color: var(--bad); border-color: var(--bad); }
.btn.danger:hover { background: var(--bad-bg); }
.ayuda { background: var(--brand-light); }
tr.link:hover td { background: var(--brand-light); }
a.kpi { text-decoration: none; }
td a, th a { text-decoration-color: var(--line); }
.btn-sm { padding: 3px 9px; font-size: 12px; }
.error { color: var(--bad); font-size: 13px; margin-top: 10px; }
footer { text-align: center; font-size: 12px; color: var(--muted); padding: 24px; }
.ayuda { background: var(--brand-light); border-radius: 8px; padding: 10px 14px; font-size: 13px; color: var(--ink); margin-bottom: 14px; }
.ayuda b { color: var(--brand); }

/* utilidades (la CSP no permite atributos style= generados salvo el ancho de la barra) */
.mt10 { margin-top: 10px; } .mt14 { margin-top: 14px; } .mt16 { margin-top: 16px; }
.c-bad { color: var(--bad) !important; } .c-warn { color: var(--warn) !important; } .c-ok { color: var(--ok) !important; }
.link-light { color: #CFE0FF; }
.nowrap { white-space: nowrap; }

@media (max-width: 900px) {
  header.top form.buscar { order: 4; width: 100%; margin: 0 0 10px; }
  header.top form.buscar input { width: 100%; }
}
@media (max-width: 760px) {
  th.hide, td.hide { display: none; }
  header.top { padding: 0 12px; }
  header.top nav.secciones { order: 3; width: 100%; overflow-x: auto; }
  header.top nav.secciones a { padding: 10px 10px; margin-bottom: 0; }
  header.top nav.secciones a .ico { margin-right: 4px; }
  header.top .brand h1 { font-size: 15px; }
  header.top .brand img { height: 30px; }
  header.top .brand small { display: none; }
  main { padding: 12px 12px 40px; }
  .equipo .datos { grid-template-columns: 1fr 1fr; }
  .alerta td.ver { text-align: left; }
  .kpis { grid-template-columns: 1fr 1fr; }
  .kpi b { font-size: 20px; }
}
/* En pantallas angostas, las tablas marcadas como .tarjetas se apilan: cada renglón es una tarjeta y cada celda lleva su etiqueta (data-l). */
@media (max-width: 640px) {
  table.tarjetas thead { display: none; }
  table.tarjetas, table.tarjetas tbody, table.tarjetas tr, table.tarjetas td { display: block; width: 100%; }
  table.tarjetas tr { border: 1px solid var(--line); border-radius: 8px; margin-bottom: 10px; padding: 6px 10px; background: #fff; }
  table.tarjetas tr.alerta.rojo { border-left: 4px solid var(--bad); } table.tarjetas tr.alerta.amarillo { border-left: 4px solid var(--warn-dot); }
  table.tarjetas tr.alerta td:first-child { border-left: 0; }
  table.tarjetas tr.alerta-ag td:first-child { border-left: 0; }
  table.tarjetas tr.alerta-ag.rojo { border-left: 4px solid var(--bad); } table.tarjetas tr.alerta-ag.amarillo { border-left: 4px solid var(--warn-dot); }
  table.alertas-agente td.detalle { max-width: none; }
  table.tarjetas td { border: 0; padding: 4px 0; display: flex; gap: 10px; align-items: baseline; text-align: left !important; }
  table.tarjetas td[data-l]::before { content: attr(data-l); flex: 0 0 34%; font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .02em; }
  table.tarjetas td.hide { display: flex; }
  table.tarjetas td.ver, table.tarjetas td.num:last-child { justify-content: flex-end; }
  table.tarjetas td .small { display: inline; }
  table.tarjetas td.empty { display: block; }
}
