/* KIRA — brutalista, minimal, en vivo. */
:root {
  --bg: #0c0c0c;
  --bg2: #121211;
  --fg: #ecebe6;
  --dim: #7d7c76;
  --tenue: #4a4945;
  --linea: #262624;
  --acido: #d4ff00;
  --rojo: #ff3d1f;
  --ambar: #ffb000;
  --mono: "JetBrains Mono", "IBM Plex Mono", "SFMono-Regular", "Cascadia Mono", Consolas, ui-monospace, monospace;
  --borde: 1px solid var(--linea);
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html { background: var(--bg); color: var(--fg); font: 13px/1.5 var(--mono); -webkit-font-smoothing: antialiased; }
body { min-height: 100vh; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
button:focus-visible, input:focus-visible, textarea:focus-visible { outline: 2px solid var(--acido); outline-offset: 2px; }
[hidden] { display: none !important; }
::selection { background: var(--acido); color: var(--bg); }
.eti { font-size: 10px; letter-spacing: .16em; color: var(--dim); }

/* ---------- login ---------- */
.login { min-height: 100vh; display: grid; place-content: center; padding: 24px; gap: 8px; }
.login__marca { font-size: clamp(72px, 18vw, 200px); font-weight: 800; letter-spacing: -.06em; line-height: .85; }
.login__marca span, .barra__marca span { color: var(--acido); }
.login__sub { letter-spacing: .3em; color: var(--dim); margin-bottom: 40px; }
.login__form { display: grid; gap: 10px; max-width: 420px; }
.login__form input { background: transparent; border: 0; border-bottom: 2px solid var(--fg); color: var(--fg); font: 24px var(--mono); padding: 8px 0; }
.login__form button { justify-self: start; background: var(--fg); color: var(--bg); padding: 12px 22px; font-weight: 700; letter-spacing: .12em; margin-top: 8px; }
.login__form button:hover { background: var(--acido); }
.login__error { color: var(--rojo); min-height: 1.5em; }

/* ---------- barra ---------- */
.barra { position: sticky; top: 0; z-index: 5; display: grid; grid-template-columns: 1fr auto auto auto; align-items: center; gap: 24px; padding: 14px 20px; border-bottom: var(--borde); background: rgba(12,12,12,.92); backdrop-filter: blur(6px); }
.barra__marca { font-weight: 800; font-size: 18px; letter-spacing: -.02em; }
.barra__reloj { color: var(--dim); font-variant-numeric: tabular-nums; letter-spacing: .06em; }
.barra__salir { color: var(--tenue); font-size: 11px; letter-spacing: .14em; }
.barra__salir:hover { color: var(--fg); }
.vivo { display: flex; align-items: center; gap: 8px; font-size: 11px; letter-spacing: .18em; }
.vivo i { width: 8px; height: 8px; background: var(--acido); display: block; animation: latir 1.6s steps(2) infinite; }
.vivo--off i { background: var(--rojo); animation: none; }
.vivo--off { color: var(--rojo); }
@keyframes latir { 50% { opacity: .15; } }

/* ---------- kpis ---------- */
.kpis { display: grid; grid-template-columns: repeat(4, 1fr); border-bottom: var(--borde); }
.kpi { text-align: left; padding: 18px 20px 16px; border-right: var(--borde); display: grid; gap: 2px; transition: background .15s; }
.kpi:last-child { border-right: 0; }
.kpi:hover { background: var(--bg2); }
.kpi__n { font-size: clamp(40px, 6vw, 76px); font-weight: 800; line-height: .95; letter-spacing: -.05em; font-variant-numeric: tabular-nums; }
.kpi__l { font-size: 10px; letter-spacing: .18em; color: var(--dim); }
.kpi--rojo.activo .kpi__n { color: var(--rojo); }
.kpi--ambar.activo .kpi__n { color: var(--ambar); }
.kpi--acido.activo .kpi__n { color: var(--acido); }

/* ---------- grilla principal ---------- */
.grilla { display: grid; grid-template-columns: minmax(0, 1.65fr) minmax(320px, 1fr); border-bottom: var(--borde); }
.bloque { padding: 20px; min-width: 0; }
.bloque--equipo { border-right: var(--borde); }
.bloque__t { font-size: 11px; letter-spacing: .22em; font-weight: 700; margin-bottom: 16px; display: flex; gap: 12px; align-items: baseline; }
.bloque__t small { font-weight: 400; color: var(--tenue); letter-spacing: .08em; text-transform: none; }

/* agentes */
.agentes { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0; border-top: var(--borde); border-left: var(--borde); }
.agente { position: relative; border-right: var(--borde); border-bottom: var(--borde); padding: 14px 14px 12px; text-align: left; display: grid; gap: 6px; min-height: 150px; align-content: start; overflow: hidden; transition: background .15s; }
.agente:hover { background: var(--bg2); }
.agente--kira { grid-column: 1 / -1; min-height: 120px; }
.agente__cab { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.agente__nombre { font-size: 22px; font-weight: 800; letter-spacing: -.03em; line-height: 1; }
.agente--kira .agente__nombre { font-size: 34px; }
.agente__area { font-size: 10px; letter-spacing: .12em; color: var(--tenue); text-transform: uppercase; }
.estado { font-size: 10px; letter-spacing: .16em; padding: 2px 6px; border: 1px solid var(--tenue); color: var(--dim); white-space: nowrap; }
.agente--trabajando .estado { border-color: var(--acido); color: var(--bg); background: var(--acido); }
.agente--esperando .estado { border-color: var(--ambar); color: var(--bg); background: var(--ambar); animation: latir 1s steps(2) infinite; }
.agente--error .estado { border-color: var(--rojo); color: var(--bg); background: var(--rojo); }
.agente--colgado .estado { border-color: var(--ambar); color: var(--ambar); }
.agente__tarea { color: var(--fg); min-height: 1.5em; overflow-wrap: anywhere; }
.agente--libre .agente__tarea { color: var(--tenue); }
.agente__ultima { color: var(--dim); font-size: 11px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.agente__pie { display: flex; gap: 14px; font-size: 10px; color: var(--tenue); letter-spacing: .08em; margin-top: auto; padding-top: 6px; }
.agente__pie b { color: var(--dim); font-weight: 600; }
.agente__barra { position: absolute; left: 0; bottom: 0; height: 2px; width: 100%; background: transparent; }
.agente--trabajando .agente__barra { background: linear-gradient(90deg, transparent, var(--acido), transparent); background-size: 40% 100%; background-repeat: no-repeat; animation: barrer 1.4s linear infinite; }
@keyframes barrer { from { background-position: -40% 0; } to { background-position: 140% 0; } }
.agente.seleccionado { outline: 2px solid var(--fg); outline-offset: -2px; }

/* bandeja */
.bandeja { list-style: none; display: grid; gap: 0; border-top: var(--borde); max-height: 520px; overflow: auto; }
.item { border-bottom: var(--borde); padding: 12px 0 12px 14px; position: relative; display: grid; gap: 4px; }
.item::before { content: ""; position: absolute; left: 0; top: 12px; bottom: 12px; width: 3px; background: var(--tenue); }
.item--pregunta::before, .item--urgente::before, .item--error::before { background: var(--rojo); }
.item--espera::before, .item--alerta::before { background: var(--ambar); }
.item--propuesta::before { background: var(--fg); }
.item__tipo { font-size: 10px; letter-spacing: .16em; color: var(--dim); display: flex; gap: 10px; }
.item--pregunta .item__tipo, .item--urgente .item__tipo, .item--error .item__tipo { color: var(--rojo); }
.item--espera .item__tipo, .item--alerta .item__tipo { color: var(--ambar); }
.item__texto { overflow-wrap: anywhere; }
.item__acciones { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 4px; }
.boton { border: 1px solid var(--fg); padding: 4px 10px; font-size: 10px; letter-spacing: .14em; font-weight: 700; }
.boton:hover { background: var(--fg); color: var(--bg); }
.boton--si { border-color: var(--acido); color: var(--acido); }
.boton--si:hover { background: var(--acido); color: var(--bg); }
.boton--no { border-color: var(--rojo); color: var(--rojo); }
.boton--no:hover { background: var(--rojo); color: var(--bg); }
.enviada { font-size: 10px; letter-spacing: .14em; color: var(--acido); }
.vacio { color: var(--tenue); padding: 18px 0; }

/* pestañas */
.pestanas { display: flex; border-bottom: var(--borde); overflow-x: auto; }
.pestanas button { padding: 14px 20px; font-size: 11px; letter-spacing: .2em; color: var(--dim); border-right: var(--borde); white-space: nowrap; }
.pestanas button[aria-selected="true"] { color: var(--bg); background: var(--fg); font-weight: 700; }
.tab { padding: 20px; min-height: 360px; }
.tab--doble { display: grid; grid-template-columns: 240px minmax(0, 1fr); gap: 28px; }

/* feed */
.feed__filtros { display: flex; gap: 12px; align-items: baseline; margin-bottom: 10px; font-size: 11px; }
#filtro-limpiar { color: var(--rojo); font-size: 10px; letter-spacing: .14em; }
.feed { list-style: none; font-size: 12px; border-top: var(--borde); max-height: 560px; overflow: auto; }
.ev { display: grid; grid-template-columns: 72px 120px minmax(0, 1fr); gap: 12px; padding: 5px 0; border-bottom: 1px solid #1a1a19; align-items: baseline; }
.ev__hora { color: var(--tenue); font-variant-numeric: tabular-nums; }
.ev__agente { font-weight: 700; letter-spacing: .06em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ev__txt { color: var(--dim); overflow-wrap: anywhere; }
.ev--delegacion .ev__txt { color: var(--fg); }
.ev--reporte .ev__txt { color: var(--acido); }
.ev--fede .ev__txt { color: var(--fg); font-weight: 600; }
.ev--espera .ev__txt { color: var(--ambar); }
.ev--error .ev__txt, .ev--alerta .ev__txt, .ev--pregunta .ev__txt { color: var(--rojo); }
.ev--sesion .ev__txt, .ev--fin .ev__txt { color: var(--tenue); }
.ev--nuevo { animation: entrar .9s ease-out; }
@keyframes entrar { from { background: rgba(212,255,0,.18); } to { background: transparent; } }
.ev__det { grid-column: 3; color: var(--dim); font-size: 11px; white-space: pre-wrap; border-left: 2px solid var(--acido); padding: 4px 0 4px 10px; margin: 2px 0 6px; max-height: 220px; overflow: auto; }

/* tablero */
.tablero__filtros { display: flex; gap: 0; flex-wrap: wrap; margin-bottom: 16px; border: var(--borde); width: fit-content; }
.tablero__filtros button { padding: 6px 12px; font-size: 10px; letter-spacing: .14em; color: var(--dim); border-right: var(--borde); }
.tablero__filtros button:last-child { border-right: 0; }
.tablero__filtros button[aria-pressed="true"] { background: var(--fg); color: var(--bg); font-weight: 700; }
.tablero { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); border-top: var(--borde); border-left: var(--borde); }
.prop { border-right: var(--borde); border-bottom: var(--borde); padding: 14px; display: grid; gap: 8px; align-content: start; }
.prop__cab { display: flex; justify-content: space-between; gap: 8px; font-size: 10px; letter-spacing: .12em; color: var(--dim); }
.prop__area { color: var(--bg); background: var(--fg); padding: 0 6px; font-weight: 700; }
.prop--urgente .prop__area { background: var(--rojo); }
.prop__titulo { font-size: 15px; font-weight: 700; line-height: 1.3; }
.prop__estado { font-size: 11px; color: var(--dim); }
.prop--cerrada { opacity: .45; }
.prop details summary { cursor: pointer; font-size: 10px; letter-spacing: .14em; color: var(--dim); list-style: none; }
.prop details summary::before { content: "+ "; }
.prop details[open] summary::before { content: "− "; }
.prop details .md { margin-top: 8px; font-size: 12px; }

/* índice + markdown */
.indice { list-style: none; border-top: var(--borde); align-self: start; position: sticky; top: 70px; max-height: 70vh; overflow: auto; }
.indice button { display: block; width: 100%; text-align: left; padding: 8px 0; border-bottom: var(--borde); color: var(--dim); font-size: 12px; }
.indice button:hover { color: var(--fg); }
.indice button.activo { color: var(--fg); font-weight: 700; }
.indice .grupo { font-size: 10px; letter-spacing: .18em; color: var(--tenue); padding: 14px 0 4px; }
.md { max-width: 900px; overflow-wrap: anywhere; }
.md h1 { font-size: 28px; letter-spacing: -.03em; line-height: 1.1; margin: 0 0 16px; }
.md h2 { font-size: 13px; letter-spacing: .16em; text-transform: uppercase; margin: 26px 0 10px; padding-top: 10px; border-top: var(--borde); }
.md h3 { font-size: 14px; margin: 18px 0 6px; }
.md p, .md ul, .md ol { margin: 0 0 10px; }
.md ul, .md ol { padding-left: 20px; }
.md li { margin: 2px 0; }
.md code { background: var(--bg2); border: var(--borde); padding: 0 4px; font-size: 12px; }
.md pre { background: var(--bg2); border: var(--borde); padding: 10px; overflow: auto; margin: 0 0 10px; }
.md pre code { border: 0; padding: 0; }
.md table { border-collapse: collapse; margin: 0 0 12px; font-size: 12px; display: block; overflow-x: auto; }
.md th, .md td { border: var(--borde); padding: 5px 8px; text-align: left; vertical-align: top; }
.md th { color: var(--dim); font-weight: 600; letter-spacing: .04em; }
.md strong { color: #fff; }
.md hr { border: 0; border-top: var(--borde); margin: 16px 0; }
.md a { color: var(--acido); }

/* pie */
.pie { display: flex; justify-content: space-between; gap: 16px; padding: 14px 20px; border-top: var(--borde); font-size: 10px; letter-spacing: .1em; color: var(--tenue); }

/* diálogo */
.dialogo { margin: auto; background: var(--bg); color: var(--fg); border: 1px solid var(--fg); padding: 22px; width: min(560px, 92vw); }
.dialogo::backdrop { background: rgba(0,0,0,.75); }
.dialogo h3 { font-size: 17px; margin: 6px 0 14px; }
.dialogo textarea { width: 100%; background: var(--bg2); color: var(--fg); border: var(--borde); font: 13px var(--mono); padding: 10px; resize: vertical; }
.dialogo__acciones { display: flex; justify-content: flex-end; gap: 8px; margin-top: 12px; }
.dialogo__acciones button { border: 1px solid var(--fg); padding: 8px 14px; font-size: 11px; letter-spacing: .12em; font-weight: 700; }
.dialogo__acciones button:not(.sec) { background: var(--fg); color: var(--bg); }

/* ---------- responsive ---------- */
@media (max-width: 1100px) {
  .agentes { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 860px) {
  .grilla { grid-template-columns: 1fr; }
  .bloque--equipo { border-right: 0; border-bottom: var(--borde); }
  .kpis { grid-template-columns: repeat(2, 1fr); }
  .kpi:nth-child(2) { border-right: 0; }
  .kpi:nth-child(-n+2) { border-bottom: var(--borde); }
  .tab--doble { grid-template-columns: 1fr; }
  .indice { position: static; max-height: 220px; }
  .barra { grid-template-columns: 1fr auto; gap: 10px; }
  .barra__reloj { grid-column: 1; font-size: 11px; }
  .barra__salir { grid-row: 2; justify-self: end; }
  .ev { grid-template-columns: 58px 84px minmax(0, 1fr); gap: 8px; }
  .pie { flex-direction: column; }
}
@media (max-width: 520px) {
  .agentes { grid-template-columns: 1fr; }
  .bloque, .tab { padding: 14px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
