@import url("assets/fonts/fonts.css");

:root {
  --azul: #0050a0;
  --azul-600: #003f80;
  --azul-50: #e8f0fa;
  --noche: #071e3d;
  --noche-2: #0c2a52;
  --noche-line: rgba(255, 255, 255, .1);
  --rojo: #e1061b;
  --rojo-50: #fdecee;
  --amarillo: #f2b705;
  --amarillo-50: #fff6d9;
  --amarillo-ink: #7a5a00;
  --verde: #13985a;
  --verde-50: #e5f5ec;
  --negra: #16181d;
  --ink: #0e1b2c;
  --muted: #54627a;
  --line: #d9e0ea;
  --papel: #eef2f7;
  --surface: #ffffff;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(7, 30, 61, .06), 0 8px 24px -12px rgba(7, 30, 61, .18);
  --sans: "Overpass", "Helvetica Neue", Arial, sans-serif;
  --mono: "Overpass Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.45;
  color: var(--ink);
  background: var(--papel);
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid var(--amarillo); outline-offset: 2px; border-radius: 6px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.mono { font-family: var(--mono); font-feature-settings: "tnum"; }
[hidden] { display: none !important; }

/* ---------- Shell ---------- */
.app {
  display: grid;
  grid-template-columns: 248px minmax(0, 1fr);
  grid-template-rows: 64px minmax(0, 1fr);
  min-height: 100vh;
  background: linear-gradient(90deg, var(--noche) 248px, var(--papel) 248px);
}
.topbar {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 0 20px;
  background: var(--noche);
  color: #fff;
  border-bottom: 1px solid var(--noche-line);
  position: sticky;
  top: 0;
  z-index: 30;
}
.brand { display: flex; align-items: center; gap: 14px; min-width: 0; }
.brand img { height: 30px; width: auto; display: block; }
.brand-sep { width: 1px; height: 28px; background: var(--noche-line); }
.brand-title { font-weight: 800; letter-spacing: .01em; font-size: 14px; line-height: 1.15; }
.brand-title small { display: block; font-weight: 500; color: #9fb3cf; font-size: 12px; letter-spacing: .02em; }
.topbar .spacer { flex: 1; }
.feed-status {
  display: flex; align-items: center; gap: 8px;
  font-size: 12.5px; color: #c9d6e8;
  padding: 7px 12px; border: 1px solid var(--noche-line); border-radius: 999px;
}
.pulse { width: 8px; height: 8px; border-radius: 50%; background: #3ddc84; box-shadow: 0 0 0 0 rgba(61, 220, 132, .6); animation: pulse 2s infinite; }
@keyframes pulse { 70% { box-shadow: 0 0 0 8px rgba(61, 220, 132, 0); } 100% { box-shadow: 0 0 0 0 rgba(61, 220, 132, 0); } }
.clock { font-family: var(--mono); font-size: 13px; color: #fff; text-align: right; line-height: 1.2; }
.clock small { display: block; color: #9fb3cf; font-size: 11px; font-family: var(--sans); }
.synthetic {
  font-size: 11.5px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase;
  color: var(--noche); background: var(--amarillo); padding: 6px 10px; border-radius: 6px; white-space: nowrap;
}
.menu-btn { display: none; background: none; border: 1px solid var(--noche-line); color: #fff; border-radius: 10px; width: 44px; height: 44px; }

.sidebar {
  background: var(--noche);
  color: #c9d6e8;
  padding: 18px 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  position: sticky;
  top: 64px;
  height: calc(100vh - 64px);
  overflow-y: auto;
}
.nav-label { font-size: 11px; letter-spacing: .12em; text-transform: uppercase; color: #6f87a8; padding: 14px 12px 6px; }
.nav-btn {
  display: flex; align-items: center; gap: 12px;
  width: 100%; min-height: 44px; padding: 0 12px;
  background: none; border: 0; border-radius: 10px;
  color: inherit; text-align: left; font-weight: 600; font-size: 14.5px;
}
.nav-btn svg { width: 19px; height: 19px; flex: none; opacity: .85; }
.nav-btn:hover { background: var(--noche-2); color: #fff; }
.nav-btn[aria-current="page"] { background: var(--azul); color: #fff; }
.nav-btn .count {
  margin-left: auto; font-family: var(--mono); font-size: 12px;
  background: rgba(255, 255, 255, .12); padding: 2px 8px; border-radius: 999px;
}
.nav-btn .count.hot { background: var(--rojo); color: #fff; }
.agents-box { margin-top: auto; padding: 14px; border: 1px solid var(--noche-line); border-radius: 12px; font-size: 13px; }
.agents-box h3 { margin: 0 0 10px; font-size: 12px; letter-spacing: .1em; text-transform: uppercase; color: #6f87a8; }
.agent-row { display: flex; align-items: center; gap: 10px; padding: 6px 0; }
.agent-row b { color: #fff; font-weight: 700; display: block; font-size: 13.5px; }
.agent-row span { font-size: 12px; color: #9fb3cf; }
.agent-dot { width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; background: var(--noche-2); flex: none; }
.agent-dot svg { width: 16px; height: 16px; color: var(--amarillo); }

.main { padding: 26px 28px 60px; min-width: 0; }
.view { animation: viewIn .35s ease both; }
@keyframes viewIn { from { opacity: 0; transform: translateY(6px); } }
.view-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin-bottom: 20px; flex-wrap: wrap; }
.eyebrow { font-family: var(--mono); font-size: 12px; letter-spacing: .08em; text-transform: uppercase; color: var(--azul); margin: 0 0 6px; }
.view-head h1 { margin: 0; font-size: clamp(26px, 2.6vw, 36px); line-height: 1.05; font-weight: 900; letter-spacing: -.02em; }
.view-head p { margin: 6px 0 0; color: var(--muted); max-width: 60ch; }

/* ---------- Primitives ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); min-width: 0; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 18px 0; flex-wrap: wrap; }
.card-head h2 { margin: 0; font-size: 16px; font-weight: 800; }
.card-head .hint { color: var(--muted); font-size: 13px; }
.card-body { padding: 16px 18px 18px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 0 16px;
  border-radius: 10px; border: 1px solid var(--line);
  background: var(--surface); font-weight: 700; font-size: 14px; white-space: nowrap;
}
.btn svg { width: 17px; height: 17px; }
.btn:hover { border-color: var(--azul); color: var(--azul); }
.btn-primary { background: var(--azul); border-color: var(--azul); color: #fff; }
.btn-primary:hover { background: var(--azul-600); color: #fff; }
.btn-danger { background: var(--rojo); border-color: var(--rojo); color: #fff; }
.btn-danger:hover { background: #b90516; color: #fff; border-color: #b90516; }
.btn-ghost { background: transparent; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.chip {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; font-weight: 700; padding: 3px 9px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--papel); white-space: nowrap;
}
.iris { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 800; padding: 3px 9px 3px 7px; border-radius: 6px; white-space: nowrap; }
.iris::before { content: ""; width: 9px; height: 9px; border-radius: 50%; background: currentColor; }
.iris-roja { background: var(--rojo-50); color: var(--rojo); }
.iris-amarilla { background: var(--amarillo-50); color: var(--amarillo-ink); }
.iris-amarilla::before { background: var(--amarillo); }
.iris-verde { background: var(--verde-50); color: var(--verde); }
.iris-negra { background: #e6e7ea; color: var(--negra); }
.decision { font-size: 12px; font-weight: 700; padding: 3px 9px; border-radius: 6px; background: var(--azul-50); color: var(--azul); white-space: nowrap; }
.decision.human { background: #efe9fb; color: #5b3aa8; }
.decision.batch { background: var(--papel); color: var(--muted); }
.decision.drop { background: var(--papel); color: var(--muted); text-decoration: line-through; }

.field { display: grid; gap: 6px; }
.field label, .field legend { font-size: 13px; font-weight: 700; }
.field input[type="text"], .field input[type="number"], .field input[type="search"], .field select, .field textarea {
  min-height: 44px; padding: 10px 12px; border: 1px solid #b9c4d4; border-radius: 10px; background: #fff; width: 100%;
}
.field textarea { min-height: 84px; resize: vertical; }
.seg { display: flex; flex-wrap: wrap; gap: 8px; border: 0; padding: 0; margin: 0; }
.seg legend { margin-bottom: 6px; }
.seg label { position: relative; }
.seg input { position: absolute; opacity: 0; inset: 0; }
.seg span {
  display: inline-flex; align-items: center; min-height: 44px; padding: 0 14px;
  border: 1px solid #b9c4d4; border-radius: 10px; font-weight: 700; font-size: 14px; cursor: pointer; background: #fff;
}
.seg input:checked + span { background: var(--azul); border-color: var(--azul); color: #fff; }
.seg input:focus-visible + span { outline: 3px solid var(--amarillo); outline-offset: 2px; }

/* ---------- Control center ---------- */
.kpis { display: grid; grid-template-columns: 1.35fr repeat(3, 1fr); gap: 14px; margin-bottom: 14px; }
.kpi { padding: 16px 18px; }
.kpi .label { font-size: 13px; color: var(--muted); font-weight: 600; }
.kpi .value { font-size: 34px; font-weight: 900; letter-spacing: -.03em; line-height: 1.05; margin-top: 6px; font-feature-settings: "tnum"; }
.kpi .value small { font-size: 15px; font-weight: 700; color: var(--muted); letter-spacing: 0; }
.kpi .delta { font-size: 12.5px; margin-top: 6px; color: var(--muted); }
.kpi .delta b { color: var(--verde); }
.kpi-hero { background: var(--noche); color: #fff; border-color: var(--noche); position: relative; overflow: hidden; }
.kpi-hero .label { color: #9fb3cf; }
.coverage { display: flex; align-items: baseline; gap: 14px; margin-top: 6px; flex-wrap: wrap; }
.coverage .now { font-size: 44px; font-weight: 900; letter-spacing: -.04em; line-height: 1; }
.coverage .before { font-size: 13px; color: #9fb3cf; }
.coverage .before s { color: #fff; font-weight: 700; }
.cov-bar { display: grid; grid-template-columns: repeat(50, 1fr); gap: 2px; margin-top: 12px; }
.cov-bar i { height: 12px; border-radius: 2px; background: rgba(255, 255, 255, .14); }
.cov-bar i.on { background: var(--amarillo); }
.cov-bar i.base { background: #fff; }
.cov-legend { display: flex; gap: 14px; font-size: 11.5px; color: #9fb3cf; margin-top: 8px; flex-wrap: wrap; }
.cov-legend span::before { content: ""; display: inline-block; width: 9px; height: 9px; border-radius: 2px; margin-right: 6px; vertical-align: -1px; }
.cov-legend .l-base::before { background: #fff; }
.cov-legend .l-on::before { background: var(--amarillo); }

.cc-grid { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr); gap: 14px; }
.map-card { position: relative; overflow: hidden; }
.map-wrap { position: relative; padding: 6px 10px 12px; }
.map-wrap svg { width: 100%; height: auto; display: block; }
.map-legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12.5px; color: var(--muted); padding: 0 18px 16px; }
.map-legend span { display: inline-flex; align-items: center; gap: 6px; }
.map-legend i { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.road { fill: none; stroke: #c8d3e2; stroke-width: 7; stroke-linecap: round; stroke-linejoin: round; }
.road-center { fill: none; stroke: #fff; stroke-width: 1.6; stroke-dasharray: 6 7; stroke-linecap: round; }
.city circle { fill: var(--noche); }
.city text { font-family: var(--sans); font-size: 12px; font-weight: 700; fill: var(--ink); paint-order: stroke; stroke: var(--papel); stroke-width: 4px; }
.sea { fill: #dbe7f5; }
.land { fill: #f6f8fb; stroke: #d9e0ea; }
.sea-label { font-family: var(--mono); font-size: 11px; letter-spacing: .3em; fill: #7c96b8; }
.bus-dot { cursor: pointer; }
.bus-dot circle.halo { opacity: .25; transform-box: fill-box; transform-origin: center; animation: halo 1.8s ease-out infinite; }
@keyframes halo { from { transform: scale(.6); opacity: .5; } to { transform: scale(2.2); opacity: 0; } }
.map-tip {
  position: absolute; pointer-events: none; background: var(--noche); color: #fff; font-size: 12.5px;
  padding: 8px 10px; border-radius: 8px; transform: translate(-50%, calc(-100% - 12px)); white-space: nowrap; box-shadow: var(--shadow);
}

.stream { display: flex; flex-direction: column; }
.stream-list { list-style: none; margin: 0; padding: 4px 10px 12px; overflow-y: auto; flex: 1 1 0; min-height: 0; }
.stream-item {
  display: grid; grid-template-columns: 58px minmax(0, 1fr) auto; gap: 10px; align-items: center;
  padding: 10px 8px; border-bottom: 1px dashed var(--line); font-size: 13.5px;
}
.stream-item.new { animation: slideIn .5s ease both; }
@keyframes slideIn { from { opacity: 0; transform: translateY(-8px); background: var(--amarillo-50); } }
.stream-item time { font-family: var(--mono); font-size: 12px; color: var(--muted); }
.stream-item .what { min-width: 0; }
.stream-item .what b { display: block; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stream-item .what span { color: var(--muted); font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block; }
.stream-item .tags { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }

.funnel { margin-top: 14px; }
.funnel-row { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 0; }
.funnel-step { padding: 16px 18px; position: relative; border-right: 1px dashed var(--line); }
.funnel-step:last-child { border-right: 0; }
.funnel-step .n { font-size: 26px; font-weight: 900; letter-spacing: -.02em; font-feature-settings: "tnum"; }
.funnel-step .t { font-size: 13px; font-weight: 700; }
.funnel-step .d { font-size: 12px; color: var(--muted); margin-top: 2px; }
.funnel-step .who { position: absolute; top: 14px; right: 14px; font-family: var(--mono); font-size: 10.5px; color: var(--azul); text-transform: uppercase; letter-spacing: .06em; }
.funnel-bars { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); padding: 0 18px 18px; gap: 18px; }
.funnel-bars div { height: 6px; border-radius: 3px; background: var(--azul-50); position: relative; overflow: hidden; }
.funnel-bars div i { position: absolute; inset: 0 auto 0 0; background: var(--azul); border-radius: 3px; transition: width 1s ease; }

/* ---------- Lane (signature) ---------- */
.lane { position: relative; display: grid; grid-template-columns: repeat(5, 1fr); padding: 26px 4px 4px; }
.lane::before {
  content: ""; position: absolute; left: 10%; right: 10%; top: 38px; height: 10px; border-radius: 5px; background: #2a3441;
}
.lane::after {
  content: ""; position: absolute; left: 10%; right: 10%; top: 42px; height: 2px;
  background: repeating-linear-gradient(90deg, var(--amarillo) 0 14px, transparent 14px 26px);
}
.lane-progress { position: absolute; left: 10%; top: 38px; height: 10px; border-radius: 5px; background: var(--azul); z-index: 1; transition: width .8s ease; }
.lane-stop { position: relative; z-index: 2; display: grid; justify-items: center; text-align: center; gap: 8px; font-size: 12px; }
.lane-stop .node {
  width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center;
  background: #fff; border: 3px solid #2a3441; margin-top: -9px;
}
.lane-stop .node svg { width: 15px; height: 15px; }
.lane-stop.done .node { background: var(--azul); border-color: var(--azul); color: #fff; }
.lane-stop.current .node { background: var(--amarillo); border-color: var(--noche); color: var(--noche); box-shadow: 0 0 0 5px rgba(242, 183, 5, .3); }
.lane-stop b { font-size: 12.5px; }
.lane-stop span { color: var(--muted); font-size: 11.5px; font-family: var(--mono); }

/* ---------- Queue ---------- */
.queue-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr); gap: 14px; align-items: start; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; padding: 14px 16px; border-bottom: 1px solid var(--line); align-items: center; }
.filter-btn {
  min-height: 40px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--line); background: #fff;
  font-weight: 700; font-size: 13px; display: inline-flex; align-items: center; gap: 7px;
}
.filter-btn[aria-pressed="true"] { background: var(--noche); color: #fff; border-color: var(--noche); }
.filter-btn i { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }
.filter-search { margin-left: auto; min-width: 180px; flex: 1 1 180px; max-width: 260px; }
.filter-search input { min-height: 40px; padding: 8px 12px; border: 1px solid #b9c4d4; border-radius: 999px; width: 100%; background: #fff; }
.queue-list { list-style: none; margin: 0; padding: 0; max-height: calc(100vh - 250px); min-height: 420px; overflow-y: auto; }
.q-item { border-bottom: 1px solid var(--line); }
.q-btn {
  width: 100%; display: grid; grid-template-columns: 44px minmax(0, 1fr) auto; gap: 12px; align-items: center;
  padding: 12px 16px; background: none; border: 0; text-align: left; min-height: 64px;
}
.q-btn:hover { background: #f7f9fc; }
.q-btn[aria-selected="true"] { background: var(--azul-50); box-shadow: inset 4px 0 0 var(--azul); }
.score {
  width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center;
  font-family: var(--mono); font-weight: 700; font-size: 15px; color: #fff; background: var(--negra);
}
.score.s-roja { background: var(--rojo); }
.score.s-amarilla { background: var(--amarillo); color: var(--noche); }
.score.s-verde { background: var(--verde); }
.q-main b { display: block; font-size: 14.5px; }
.q-main span { display: block; color: var(--muted); font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.q-side { display: grid; justify-items: end; gap: 4px; font-size: 12px; color: var(--muted); }
.q-side time { font-family: var(--mono); }
.empty { padding: 40px 20px; text-align: center; color: var(--muted); }
.empty b { display: block; color: var(--ink); font-size: 16px; margin-bottom: 4px; }

.detail { position: sticky; top: 84px; }
.detail-top { padding: 18px 20px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.detail-top h2 { margin: 6px 0 2px; font-size: 22px; font-weight: 900; letter-spacing: -.01em; }
.detail-top p { margin: 0; color: var(--muted); font-size: 13.5px; }
.detail-section { padding: 16px 20px; border-bottom: 1px solid var(--line); }
.detail-section:last-child { border-bottom: 0; }
.detail-section h3 { margin: 0 0 10px; font-size: 12px; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); font-family: var(--mono); font-weight: 500; }
.facts { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin: 0; }
.facts div { min-width: 0; }
.facts dt { font-size: 12px; color: var(--muted); }
.facts dd { margin: 2px 0 0; font-weight: 700; font-size: 14px; overflow-wrap: anywhere; }
.evidence {
  position: relative; border-radius: 12px; overflow: hidden; background: #0b1624; aspect-ratio: 16 / 7; color: #fff;
  display: grid; align-content: end;
}
.evidence .scene { position: absolute; inset: 0; }
.evidence .scene svg { width: 100%; height: 100%; display: block; }
.evidence .band {
  position: relative; margin: 10px; padding: 8px 12px; border-radius: 8px; background: rgba(7, 30, 61, .92);
  display: flex; gap: 12px; flex-wrap: wrap; justify-content: space-between; font-size: 12.5px;
}
.evidence .band b { font-family: var(--mono); font-weight: 700; }
.evidence .rec { position: absolute; top: 10px; left: 12px; font-family: var(--mono); font-size: 11.5px; display: flex; gap: 8px; align-items: center; background: rgba(0, 0, 0, .45); padding: 4px 8px; border-radius: 6px; }
.evidence .rec i { width: 8px; height: 8px; border-radius: 50%; background: var(--rojo); }
.reasoning { margin: 0; padding: 0; list-style: none; display: grid; gap: 8px; }
.reasoning li { display: grid; grid-template-columns: 22px minmax(0, 1fr); gap: 8px; font-size: 13.5px; }
.reasoning li svg { width: 16px; height: 16px; color: var(--azul); margin-top: 2px; }
.agent-note { background: var(--azul-50); border-radius: 10px; padding: 12px 14px; font-size: 13.5px; margin-top: 12px; }
.agent-note b { color: var(--azul); }
.actions { display: flex; gap: 10px; flex-wrap: wrap; }
.history { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; font-size: 13px; }
.history li { display: grid; grid-template-columns: 58px minmax(0, 1fr); gap: 10px; }
.history time { font-family: var(--mono); color: var(--muted); font-size: 12px; }

/* ---------- Calls ---------- */
.calls-layout { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr); gap: 14px; align-items: start; }
.call-stage { background: var(--noche); color: #fff; border-color: var(--noche); overflow: hidden; }
.call-top { display: flex; gap: 16px; justify-content: space-between; align-items: center; padding: 18px 20px; border-bottom: 1px solid var(--noche-line); flex-wrap: wrap; }
.call-top h2 { margin: 0; font-size: 20px; font-weight: 900; }
.call-top p { margin: 2px 0 0; color: #9fb3cf; font-size: 13px; }
.call-state { font-family: var(--mono); font-size: 13px; padding: 6px 10px; border-radius: 8px; background: var(--noche-2); display: inline-flex; gap: 8px; align-items: center; }
.call-state i { width: 8px; height: 8px; border-radius: 50%; background: #9fb3cf; }
.call-state.live i { background: #3ddc84; animation: pulse 2s infinite; }
.wave { display: flex; align-items: center; gap: 3px; height: 56px; padding: 0 20px; }
.wave i { flex: 1; background: #2c4b77; border-radius: 2px; height: 10%; transition: height .15s ease; }
.wave.live i { background: var(--amarillo); }
.transcript { list-style: none; margin: 0; padding: 8px 20px 20px; display: grid; gap: 10px; min-height: 300px; max-height: 420px; overflow-y: auto; }
.msg { max-width: 82%; padding: 10px 13px; border-radius: 12px; font-size: 14px; animation: slideIn .4s ease both; }
.msg small { display: block; font-family: var(--mono); font-size: 11px; opacity: .7; margin-bottom: 3px; }
.msg.agent { background: var(--noche-2); border: 1px solid var(--noche-line); }
.msg.driver { background: #fff; color: var(--ink); justify-self: end; }
.msg.system { justify-self: center; max-width: 100%; background: transparent; color: #9fb3cf; font-family: var(--mono); font-size: 12px; padding: 2px; }
.call-foot { padding: 16px 20px; border-top: 1px solid var(--noche-line); display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.call-foot .btn { background: var(--noche-2); color: #fff; border-color: var(--noche-line); }
.call-foot .btn-primary { background: var(--amarillo); color: var(--noche); border-color: var(--amarillo); }
.call-result { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; padding: 0 20px 18px; }
.call-result div { background: var(--noche-2); border-radius: 10px; padding: 10px 12px; font-size: 12px; color: #9fb3cf; }
.call-result b { display: block; color: #fff; font-size: 14px; margin-top: 2px; }
.call-list { list-style: none; margin: 0; padding: 0; }
.call-list li { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px; padding: 12px 18px; border-top: 1px solid var(--line); align-items: center; }
.call-list li b { display: block; font-size: 14px; }
.call-list li span { font-size: 12.5px; color: var(--muted); }
.call-list .res { font-size: 12px; font-weight: 700; }
.res.ok { color: var(--verde); }
.res.no { color: var(--rojo); }
.res.wait { color: var(--amarillo-ink); }

.auto-badge { display: inline-flex; align-items: center; gap: 8px; font-size: 12.5px; font-weight: 800; color: var(--noche); background: var(--amarillo); padding: 6px 10px; border-radius: 8px; }
.auto-badge svg { width: 15px; height: 15px; }
.btn-y { background: var(--amarillo); border-color: var(--amarillo); color: var(--noche); }
.btn-y:hover { background: #ffc81f; color: var(--noche); border-color: #ffc81f; }

/* Live call widget (visible outside Llamadas) */
.live-call {
  position: fixed; right: 20px; bottom: calc(20px + env(safe-area-inset-bottom, 0px)); z-index: 50; width: 340px;
  background: var(--noche); color: #fff; border: 1px solid var(--noche-line); border-radius: 16px; padding: 16px;
  box-shadow: 0 24px 60px -18px rgba(7, 30, 61, .6); display: grid; gap: 6px; animation: slideIn .4s ease both;
}
.live-call b { font-size: 16px; }
.lc-top { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 4px; }
.lc-badge { font-size: 11px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; color: var(--noche); background: var(--amarillo); padding: 4px 8px; border-radius: 6px; }
.lc-live { font-family: var(--mono); font-size: 12px; color: #9fb3cf; display: inline-flex; gap: 6px; align-items: center; }
.lc-live i { width: 8px; height: 8px; border-radius: 50%; background: #9fb3cf; }
.lc-live.on i { background: #3ddc84; animation: pulse 2s infinite; }
.lc-why { font-size: 12.5px; color: #9fb3cf; }
.lc-wave { display: flex; gap: 3px; align-items: center; height: 26px; margin: 4px 0; }
.lc-wave i { flex: 1; height: 20%; background: #2c4b77; border-radius: 2px; }
.lc-wave.on i { background: var(--amarillo); animation: wv 1s ease-in-out infinite; }
.lc-wave.on i:nth-child(3n) { animation-delay: -.3s; } .lc-wave.on i:nth-child(3n+1) { animation-delay: -.6s; } .lc-wave.on i:nth-child(4n) { animation-duration: .8s; }
@keyframes wv { 0%, 100% { height: 20%; } 50% { height: 95%; } }
.lc-line { margin: 2px 0 8px; font-size: 13.5px; background: var(--noche-2); border-radius: 10px; padding: 9px 11px; }
.lc-line small { display: block; font-family: var(--mono); font-size: 11px; color: #9fb3cf; margin-bottom: 2px; }
@media (max-width: 560px) { .live-call { left: 12px; right: 12px; width: auto; bottom: calc(12px + env(safe-area-inset-bottom, 0px)); } }

/* ---------- Review ---------- */
.review-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.review-card .card-body { display: grid; gap: 14px; }
.review-why { background: #efe9fb; color: #3c2475; border-radius: 10px; padding: 12px 14px; font-size: 13.5px; }
.review-done { background: var(--verde-50); color: #0c5c37; border-radius: 10px; padding: 12px 14px; font-size: 13.5px; font-weight: 600; }
.error { color: var(--rojo); font-size: 13px; font-weight: 700; min-height: 1em; margin: 0; }

/* ---------- Drivers ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; min-width: 760px; }
th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 700; padding: 12px 16px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 12px 16px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
.level { font-size: 12px; font-weight: 800; padding: 3px 9px; border-radius: 6px; }
.level-1 { background: var(--papel); color: var(--muted); }
.level-2 { background: var(--amarillo-50); color: var(--amarillo-ink); }
.level-3 { background: var(--rojo-50); color: var(--rojo); }
.spark { display: flex; gap: 2px; align-items: flex-end; height: 24px; }
.spark i { width: 7px; background: var(--azul); border-radius: 2px 2px 0 0; opacity: .85; }

/* ---------- Reports ---------- */
.reports-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.chart svg { width: 100%; height: auto; display: block; }
.chart text { font-family: var(--sans); font-size: 11px; fill: var(--muted); }
.chart .bar-before { fill: #c8d3e2; }
.chart .bar-now { fill: var(--azul); }
.hbar { display: grid; gap: 10px; }
.hbar-row { display: grid; grid-template-columns: 150px minmax(0, 1fr) 48px; gap: 10px; align-items: center; font-size: 13px; }
.hbar-row .track { height: 10px; background: var(--papel); border-radius: 5px; overflow: hidden; }
.hbar-row .track i { display: block; height: 100%; border-radius: 5px; }
.hbar-row b { text-align: right; font-family: var(--mono); font-size: 12.5px; }
.legend { display: flex; gap: 14px; font-size: 12.5px; color: var(--muted); flex-wrap: wrap; }
.legend span::before { content: ""; display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 6px; vertical-align: -1px; background: var(--c); }
.stat-row { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.stat-row div { background: var(--papel); border-radius: 10px; padding: 12px 14px; }
.stat-row b { display: block; font-size: 22px; font-weight: 900; }
.stat-row span { font-size: 12.5px; color: var(--muted); }

/* ---------- Params ---------- */
.params-grid { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); gap: 14px; align-items: start; }
.rule { display: grid; grid-template-columns: minmax(0, 1fr) 150px 150px; gap: 12px; align-items: center; padding: 12px 18px; border-top: 1px solid var(--line); }
.rule b { display: block; font-size: 14px; }
.rule span { font-size: 12.5px; color: var(--muted); }
.rule select, .rule input { min-height: 44px; border: 1px solid #b9c4d4; border-radius: 10px; padding: 0 10px; background: #fff; width: 100%; }
.switch-row { display: flex; justify-content: space-between; gap: 16px; align-items: center; padding: 12px 0; border-top: 1px solid var(--line); }
.switch-row:first-child { border-top: 0; }
.switch-row b { display: block; font-size: 14px; }
.switch-row span { font-size: 12.5px; color: var(--muted); }
.switch { position: relative; width: 52px; height: 30px; flex: none; }
.switch input { position: absolute; inset: 0; opacity: 0; cursor: pointer; margin: 0; }
.switch i { position: absolute; inset: 0; border-radius: 999px; background: #b9c4d4; transition: background .2s; pointer-events: none; }
.switch i::after { content: ""; position: absolute; left: 4px; top: 4px; width: 22px; height: 22px; border-radius: 50%; background: #fff; transition: transform .2s; }
.switch input:checked + i { background: var(--azul); }
.switch input:checked + i::after { transform: translateX(22px); }
.switch input:focus-visible + i { outline: 3px solid var(--amarillo); outline-offset: 2px; }
.script-box { background: var(--papel); border-radius: 10px; padding: 14px; font-size: 14px; line-height: 1.55; }
.script-box mark { background: var(--amarillo-50); color: var(--amarillo-ink); padding: 0 4px; border-radius: 4px; font-weight: 700; }

/* ---------- Modal & toast ---------- */
dialog { border: 0; border-radius: 16px; padding: 0; width: min(560px, calc(100vw - 32px)); box-shadow: 0 30px 80px -20px rgba(7, 30, 61, .5); }
dialog::backdrop { background: rgba(7, 30, 61, .55); }
.modal-head { padding: 18px 20px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: start; gap: 12px; }
.modal-head h2 { margin: 0; font-size: 19px; font-weight: 900; }
.modal-head p { margin: 2px 0 0; color: var(--muted); font-size: 13px; }
.modal-body { padding: 18px 20px; display: grid; gap: 16px; }
.modal-foot { padding: 14px 20px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 10px; flex-wrap: wrap; }
.icon-btn { width: 44px; height: 44px; border-radius: 10px; border: 1px solid var(--line); background: #fff; display: grid; place-items: center; flex: none; }
.icon-btn svg { width: 18px; height: 18px; }
.toast {
  position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%);
  background: var(--noche); color: #fff; padding: 12px 16px; border-radius: 12px; font-size: 14px; font-weight: 600;
  display: flex; gap: 10px; align-items: center; box-shadow: var(--shadow); z-index: 60; max-width: calc(100vw - 32px);
  animation: slideIn .3s ease both;
}
.toast svg { width: 18px; height: 18px; color: var(--amarillo); flex: none; }

/* ---------- Responsive ---------- */
@media (max-width: 1180px) {
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .cc-grid, .queue-layout, .calls-layout, .params-grid { grid-template-columns: minmax(0, 1fr); }
  .detail { position: static; }
  .stream-list { flex: none; max-height: 420px; }
  .queue-list { max-height: 460px; min-height: 0; }
  .funnel-row, .funnel-bars { grid-template-columns: repeat(5, minmax(0, 1fr)); }
}
@media (max-width: 900px) {
  .app { grid-template-columns: minmax(0, 1fr); background: var(--papel); }
  .sidebar {
    position: fixed; top: 64px; left: 0; bottom: 0; width: min(300px, 86vw); z-index: 40; height: auto;
    transform: translateX(-100%); transition: transform .25s ease;
  }
  .sidebar.open { transform: none; box-shadow: 20px 0 60px rgba(0, 0, 0, .3); }
  .menu-btn { display: grid; place-items: center; }
  .feed-status, .brand-sep, .brand-title { display: none; }
  .main { padding: 20px 16px 60px; }
  .review-grid, .reports-grid { grid-template-columns: minmax(0, 1fr); }
  .funnel-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .funnel-step { border-right: 0; border-bottom: 1px dashed var(--line); }
  .funnel-bars { display: none; }
  .facts { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .rule { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .rule > div:first-child { grid-column: 1 / -1; }
}
@media (max-width: 560px) {
  .topbar { gap: 10px; padding: 0 12px; }
  .brand img { height: 24px; }
  .clock small { display: none; }
  .synthetic { font-size: 10px; padding: 5px 7px; }
  .kpis { grid-template-columns: minmax(0, 1fr); }
  .lane { grid-template-columns: repeat(5, minmax(0, 1fr)); }
  .lane-stop span { display: none; }
  .lane-stop b { font-size: 11px; }
  .call-result, .stat-row { grid-template-columns: minmax(0, 1fr); }
  .hbar-row { grid-template-columns: 110px minmax(0, 1fr) 40px; }
  .msg { max-width: 94%; }
  .filter-search { max-width: none; margin-left: 0; }
  .q-btn { grid-template-columns: 40px minmax(0, 1fr); }
  .q-side { grid-column: 2; justify-items: start; grid-auto-flow: column; gap: 8px; }
  .score { width: 40px; height: 40px; }
  .funnel-step .who { position: static; display: block; margin-bottom: 4px; }
  .stream-item { grid-template-columns: minmax(0, 1fr) auto; }
  .stream-item time { grid-column: 1 / -1; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
}
@media (max-width: 560px) { .toast { top: calc(76px + env(safe-area-inset-top, 0px)); bottom: auto; } }
@media (max-width: 560px) { .lc-line { display: none; } .live-call { padding: 12px; } }
