/* CSP Cockpit — Redesign A. Control-room UI: single dark theme, teal =
   brand/AI, green = health. Sentence-case labels, 10.5px type floor,
   mono reserved for real data (times, ids, counts, confidence). */

:root {
  --bg: #0c1317;
  --surface: #131e24;
  --surface-2: #1a2830;
  --chat-bg: #0a1114;
  --chat-chrome: #0e181d;
  --line: #24343d;
  --line-2: #2e404a;
  --ink: #e8f0f2;
  --ink-2: #b6c6cd;
  --muted: #8da2ab;
  --faint: #54636b;
  --teal: #46b7c0;
  --teal-ink: #06222b;
  --green: #46c28e;
  --amber: #d9a24a;
  --red: #e0837b;
  --hot: #e0895a;
  --bubble-out: #14493d;
  --bubble-in: #1e2b32;
  --mono: "Cascadia Mono", Consolas, "SF Mono", ui-monospace, monospace;
  --ui: "Segoe UI", -apple-system, system-ui, "Helvetica Neue", sans-serif;
  --radius: 8px;
  --focus: 2px solid var(--teal);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 13.5px/1.5 var(--ui);
  -webkit-font-smoothing: antialiased;
}
.hidden { display: none !important; }
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.faint { color: var(--faint); }

/* focus ring on everything interactive */
:where(button, input, textarea, a, [tabindex], [role="option"], [role="tab"]):focus-visible {
  outline: var(--focus);
  outline-offset: 2px;
  border-radius: 5px;
}
button { font: inherit; cursor: pointer; border: 0; background: none; color: inherit; }
button.primary {
  background: var(--teal); color: var(--teal-ink); font-weight: 650;
  border-radius: 6px; padding: 8px 15px; min-height: 34px;
}
button.ghost {
  background: transparent; color: var(--ink-2); border: 1px solid var(--line);
  border-radius: 6px; padding: 6px 12px; min-height: 30px;
}
button.ghost:hover { border-color: var(--line-2); color: var(--ink); }
button:disabled { opacity: .5; cursor: not-allowed; }
kbd.kbd, .kbd {
  font: 10.5px/1 var(--mono); color: var(--muted); background: var(--surface-2);
  border: 1px solid var(--line); border-radius: 4px; padding: 2px 5px;
}

.brand { font-weight: 750; letter-spacing: .01em; font-size: 14px; white-space: nowrap; }
.brand span { color: var(--teal); font-weight: 500; }

/* ░░ LOGIN ░░ */
.login { position: fixed; inset: 0; z-index: 40; display: grid; place-items: center; background: var(--bg); }
.login-card {
  width: 370px; background: var(--surface); border: 1px solid var(--line);
  border-radius: 12px; padding: 30px; display: flex; flex-direction: column; gap: 13px;
}
.login-card p { margin: 0; color: var(--ink-2); font-size: 12.5px; }
.key-field { position: relative; display: flex; }
.key-field input {
  flex: 1; background: var(--surface-2); border: 1px solid var(--line); color: var(--ink);
  border-radius: 6px; padding: 10px 40px 10px 12px; font: 13px var(--mono);
}
.reveal {
  position: absolute; right: 4px; top: 4px; bottom: 4px; width: 34px; border-radius: 5px;
  color: var(--muted);
}
.reveal::before { content: "👁"; font-size: 14px; }
.reveal.on { color: var(--teal); }
.login-error { color: var(--red); font-size: 12.5px; min-height: 17px; display: flex; align-items: center; gap: 6px; }
.login-error:not(:empty)::before { content: "⚠"; }
.login-hint { color: var(--faint); font-size: 12px; text-decoration: underline dotted; cursor: help; }

/* ░░ SHELL ░░ */
.app { height: 100%; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; gap: 16px; padding: 9px 16px;
  border-bottom: 1px solid var(--line); background: var(--surface); flex: none;
}
.tenant-chip {
  display: flex; align-items: center; gap: 7px; background: var(--surface-2);
  border: 1px solid var(--line); border-radius: 20px; padding: 4px 12px;
  font-size: 12.5px; color: var(--ink-2); min-height: 28px;
}
.quality-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--green); }
.quality-dot.yellow { background: var(--amber); } .quality-dot.red { background: var(--red); }
.quality-dot.unknown { background: var(--faint); }
.top-right { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.live-pill { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }
.live-pill .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--amber); transition: background .3s; }
.live-pill.on .dot { background: var(--green); }
.live-pill.off .dot { background: var(--red); }
.agent-avatar {
  width: 26px; height: 26px; border-radius: 50%; background: var(--teal); color: var(--teal-ink);
  display: grid; place-items: center; font: 700 11px var(--ui); text-transform: uppercase;
}

/* ░░ LAYOUT ░░ */
.layout {
  flex: 1; min-height: 0; position: relative;
  display: grid; grid-template-columns: 280px 300px minmax(480px, 1fr) 320px;
}
.pane { min-width: 0; overflow-y: auto; border-right: 1px solid var(--line); background: var(--bg); }
.pane:last-of-type { border-right: 0; }
.pane.chat { background: var(--chat-bg); overflow: hidden; }
.pane.inbox, .pane.crm, .pane.copilot { padding: 12px; }
.pane-head { display: flex; align-items: baseline; gap: 8px; margin-bottom: 11px; }
.pane-head h2 { margin: 0; font-size: 14px; font-weight: 650; }
.pane-head .stamp { margin-left: auto; font-size: 10.5px; color: var(--faint); }

.empty-state { color: var(--muted); font-size: 12.5px; padding: 20px 6px; line-height: 1.5; }
.empty-state p { margin: 0; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 11px 12px; margin-bottom: 11px; }
.card-h { display: flex; align-items: center; gap: 8px; font-size: 12px; font-weight: 600; color: var(--ink-2); margin-bottom: 9px; }
.card-h .card-hint { margin-left: auto; font-size: 11px; color: var(--faint); font-weight: 400; }
.card-h .counter { margin-left: auto; color: var(--muted); font-size: 11px; }
.pill { font: 600 10.5px var(--mono); letter-spacing: .04em; padding: 2px 7px; border-radius: 4px; }
.pill.green { color: var(--green); background: color-mix(in srgb, var(--green) 16%, transparent); }
.pill.amber { color: var(--amber); background: color-mix(in srgb, var(--amber) 16%, transparent); }
.pill.gray { color: var(--muted); background: var(--surface-2); }

/* ░ BANDEJA ░ */
.search-row { position: relative; display: flex; align-items: center; margin-bottom: 10px; }
.search-row .ic-search { position: absolute; left: 9px; width: 14px; height: 14px; color: var(--muted); pointer-events: none; }
.search-row input {
  flex: 1; background: var(--surface-2); border: 1px solid var(--line); color: var(--ink);
  border-radius: 7px; padding: 8px 44px 8px 30px; font-size: 12.5px;
}
.search-row .kbd { position: absolute; right: 7px; }
.filters { display: flex; gap: 6px; margin-bottom: 11px; }
.chip-filter {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 1px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 7px;
  padding: 6px 4px; min-height: 40px; color: var(--ink-2); font-size: 11.5px;
}
.chip-filter .cf-count { font: 700 14px var(--mono); color: var(--ink); }
.chip-filter.active { background: color-mix(in srgb, var(--teal) 15%, transparent); border-color: var(--teal); color: var(--teal); }
.chip-filter.active .cf-count { color: var(--teal); }

.conv-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.conv-list:focus-visible { outline: var(--focus); outline-offset: 3px; border-radius: 8px; }
.conv {
  background: var(--surface); border: 1px solid var(--line); border-radius: 8px;
  padding: 8px 10px; cursor: pointer; display: flex; flex-direction: column; gap: 3px;
}
.conv:hover { border-color: var(--line-2); }
.conv.active { background: var(--surface-2); border-color: var(--teal); box-shadow: 0 0 0 1px var(--teal); }
.conv-top { display: flex; align-items: baseline; gap: 7px; }
.conv-name { font-size: 13.5px; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conv-name.unanswered { font-weight: 700; }
.conv-name.answered { font-weight: 600; color: var(--ink-2); }
.unread-badge { background: var(--teal); color: var(--teal-ink); font: 700 10.5px var(--mono); border-radius: 9px; padding: 0 6px; min-width: 17px; text-align: center; }
.conv-time { font: 11px var(--mono); color: var(--muted); flex: none; }
.conv-preview { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conv-preview .you { color: var(--faint); }
.win { display: flex; align-items: center; gap: 6px; font-size: 11px; margin-top: 1px; }
.win .wdot { width: 7px; height: 7px; border-radius: 50%; flex: none; }
.win.open { color: var(--green); } .win.open .wdot { background: var(--green); }
.win.soon { color: var(--amber); } .win.soon .wdot { background: var(--amber); }
.win.closed { color: var(--red); } .win.closed .wdot { background: transparent; border: 1.5px solid var(--red); }
.win.none { color: var(--muted); } .win.none .wdot { background: transparent; border: 1.5px dashed var(--muted); }
/* F3: the person's live cadence on the inbox card */
.nurture { font-size: 11px; margin-top: 1px; color: var(--muted); }
.nurture.paused { color: var(--amber); }
/* F4: a held cadence step explains itself */
.cad-line.hold { color: var(--amber); }

/* ░ FICHA ░ */
.person-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.avatar { width: 38px; height: 38px; border-radius: 50%; background: var(--surface-2); border: 1px solid var(--line-2);
  display: grid; place-items: center; font: 700 14px var(--ui); color: var(--teal); flex: none; text-transform: uppercase; }
.person-name { font-size: 15px; font-weight: 700; }
.person-phone { font-size: 11px; color: var(--muted); margin-top: 1px; }

.frow { display: flex; align-items: baseline; gap: 8px; padding: 5px 0; border-bottom: 1px solid var(--line); }
.frow:last-child { border-bottom: 0; }
.frow .fk { font-size: 11px; color: var(--muted); flex: none; width: 42%; }
.frow .fv { font-size: 13px; font-weight: 600; flex: 1; text-align: right; overflow-wrap: anywhere; }
.frow .fv.empty { color: var(--faint); font-weight: 400; }
.prov { font: 600 10.5px var(--mono); color: var(--teal); text-decoration: underline dotted; cursor: help; margin-left: 6px; white-space: nowrap; }
.prov.origen { color: var(--amber); }

.sugg {
  border: 1px solid color-mix(in srgb, var(--amber) 45%, var(--line)); border-radius: 8px;
  padding: 9px 11px; margin-top: 10px; background: color-mix(in srgb, var(--amber) 7%, transparent);
}
.sugg .sk { font-size: 11px; color: var(--amber); margin-bottom: 3px; }
.sugg .sv { font-size: 13px; font-weight: 600; }
.sugg .quote { font-style: italic; color: var(--ink-2); font-size: 12px; border-left: 2px solid var(--line-2); padding-left: 8px; margin: 6px 0; }
.sugg .sconf { font: 10.5px var(--mono); color: var(--muted); }
.sugg .sactions { display: flex; gap: 7px; margin-top: 8px; }
.sugg .sactions button { min-height: 26px; padding: 3px 12px; font-size: 12px; border-radius: 6px; }
.sugg .accept { background: var(--teal); color: var(--teal-ink); font-weight: 650; }
.sugg .reject { border: 1px solid var(--line); color: var(--ink-2); }

/* funnel */
.stages { display: flex; gap: 3px; margin-bottom: 7px; }
.stage-seg { flex: 1; height: 6px; border-radius: 3px; background: var(--surface-2); }
.stage-seg.on { background: var(--teal); }
.stage-seg.lost { background: var(--red); }
.stage-name { font-size: 12.5px; color: var(--ink-2); }
.lead-origen { font-size: 11.5px; color: var(--muted); margin-top: 3px; }
.stage-actions { display: flex; gap: 7px; margin-top: 9px; flex-wrap: wrap; }
.stage-actions button { min-height: 28px; padding: 4px 11px; font-size: 12px; border-radius: 6px; }
.btn-neutral { background: var(--surface-2); color: var(--ink); border: 1px solid var(--line); }
.btn-win { border: 1px solid var(--green); color: var(--green); }
.btn-lost { border: 1px solid var(--red); color: var(--red); }

/* cadence */
.cad-line { font-size: 12.5px; color: var(--ink-2); margin: 4px 0; line-height: 1.45; }
.cad-line b { color: var(--ink); font-weight: 650; }
.cad-actions { margin-top: 9px; }
.cad-actions button { min-height: 28px; padding: 4px 12px; font-size: 12px; }
.enroll-btn { display: block; width: 100%; text-align: left; background: var(--surface-2); color: var(--ink); border: 1px solid var(--line); border-radius: 6px; padding: 6px 10px; margin-top: 6px; font-size: 12px; min-height: 30px; }

/* confirm block (funnel + salud) */
.confirm { border: 1px solid var(--line-2); border-radius: 8px; padding: 10px; margin-top: 9px; background: var(--surface-2); }
.confirm .c-sum { font-size: 12.5px; color: var(--ink-2); margin-bottom: 7px; }
.confirm label { font-size: 11px; color: var(--muted); display: block; margin-bottom: 3px; }
.confirm input, .confirm textarea { width: 100%; background: var(--surface); border: 1px solid var(--line); color: var(--ink); border-radius: 6px; padding: 7px 9px; font-size: 12.5px; font-family: var(--ui); }
.confirm .c-actions { display: flex; gap: 7px; margin-top: 9px; }
.confirm .c-actions button { min-height: 28px; padding: 4px 13px; font-size: 12px; border-radius: 6px; }

/* ░ CHAT ░ */
.chat-inner { height: 100%; display: flex; flex-direction: column; min-height: 0; }
.chat-header {
  display: flex; align-items: center; gap: 10px; padding: 10px 14px;
  background: var(--chat-chrome); border-bottom: 1px solid var(--line); flex: none;
}
/* The name is the header's most important datum: it may ellipsize but
   never vanish — everything decorative yields first (≤1500 rules). */
.ch-id { display: flex; align-items: center; gap: 9px; min-width: 120px; flex: 1 1 auto; }
.ch-name { font-size: 14px; font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stage-chip { font: 600 10.5px var(--mono); color: var(--ink-2); background: var(--surface-2); border: 1px solid var(--line); border-radius: 5px; padding: 1px 7px; white-space: nowrap; }
.window-chip { margin-left: auto; font: 11px var(--mono); display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.window-chip .wdot { width: 7px; height: 7px; border-radius: 50%; }
.window-chip.open { color: var(--green); } .window-chip.open .wdot { background: var(--green); }
.window-chip.soon { color: var(--amber); } .window-chip.soon .wdot { background: var(--amber); }
.window-chip.closed { color: var(--red); } .window-chip.closed .wdot { border: 1.5px solid var(--red); }
.window-chip.none { color: var(--muted); } .window-chip.none .wdot { border: 1.5px dashed var(--muted); }
.ch-nav { font-size: 11px; white-space: nowrap; }
.drawer-toggle { display: none; }
/* Exportar is not a drawer toggle (those only exist on narrow screens) —
   it stays visible at every width. */
#export-btn {
  display: inline-block; font-size: 11.5px; font-weight: 600; font-family: inherit;
  color: var(--muted); background: none; border: 1px solid var(--line);
  border-radius: 7px; padding: 6px 10px; cursor: pointer;
}
#export-btn:hover { color: var(--ink); border-color: var(--muted); }
/* ＋Cita is not a drawer toggle either — visible at every width. */
#cita-toggle { display: inline-flex; align-items: center; }

.messages {
  list-style: none; margin: 0; padding: 14px 16px; flex: 1; overflow-y: auto;
  display: flex; flex-direction: column; gap: 3px;
}
.msg { display: flex; flex-direction: column; max-width: 76%; }
.msg.in { align-self: flex-start; align-items: flex-start; }
.msg.out { align-self: flex-end; align-items: flex-end; }
.ai-tag { font: 10.5px var(--mono); color: var(--teal); margin: 5px 2px 2px; display: inline-flex; align-items: center; gap: 4px; }
.ai-tag .ic { width: 11px; height: 11px; }
/* Provenance chip: human sent it, the copiloto wrote (or seeded) it. */
.ai-tag.origin { color: var(--muted); }
.bubble { padding: 7px 11px 6px; border-radius: 10px; font-size: 13.5px; line-height: 1.42; white-space: pre-wrap; overflow-wrap: anywhere; }
.msg.in .bubble { background: var(--bubble-in); border-top-left-radius: 3px; }
.msg.out .bubble { background: var(--bubble-out); border-top-right-radius: 3px; }
.meta { font: 10.5px var(--mono); color: var(--muted); margin: 2px 3px 0; display: inline-flex; align-items: center; gap: 4px; }
.tick.read { color: var(--teal); }
.tick.failed { color: var(--red); }
.retry-link { color: var(--red); text-decoration: underline; cursor: pointer; font-family: var(--ui); }
.doc-card { display: flex; align-items: center; gap: 9px; background: color-mix(in srgb, var(--ink) 5%, transparent); border-radius: 7px; padding: 7px 9px; }
.doc-card .ic { width: 22px; height: 26px; color: var(--ink-2); flex: none; }
.doc-card .dn { font-size: 12.5px; font-weight: 600; }
.doc-card .dc { font-size: 11.5px; color: var(--muted); }

/* composer */
.composer { border-top: 1px solid var(--line); background: var(--chat-chrome); padding: 10px 14px 12px; flex: none; }
.composer-tabs { display: flex; gap: 4px; margin-bottom: 9px; }
.ctab { font-size: 12.5px; color: var(--ink-2); padding: 5px 11px; border-radius: 6px; min-height: 30px; border: 1px solid transparent; }
.ctab:hover { background: var(--surface-2); }
.ctab.active { background: var(--surface-2); border-color: var(--line); color: var(--ink); font-weight: 600; }
.tab-count { font: 700 10.5px var(--mono); color: var(--teal); margin-left: 2px; }
.policy-line { font-size: 11.5px; border-radius: 7px; padding: 6px 10px; margin-bottom: 9px; display: flex; align-items: center; gap: 7px; line-height: 1.4; }
.policy-line .pdot { width: 7px; height: 7px; border-radius: 50%; flex: none; }
.policy-line.ok { background: color-mix(in srgb, var(--green) 12%, transparent); color: var(--green); }
.policy-line.ok .pdot { background: var(--green); }
.policy-line.blocked { background: color-mix(in srgb, var(--amber) 12%, transparent); color: var(--amber); }
.policy-line.blocked .pdot { background: var(--amber); }
.policy-line b { color: inherit; font-weight: 700; }
.policy-line .plink { color: var(--teal); text-decoration: underline; cursor: pointer; margin-left: auto; white-space: nowrap; }

.drafts { display: flex; flex-direction: column; gap: 5px; margin-bottom: 9px; }
.draft { display: flex; gap: 8px; align-items: flex-start; border: 1px dashed var(--line-2); border-radius: 7px; padding: 6px 9px; cursor: pointer; }
.draft:hover { border-color: var(--teal); }
.draft .dk { font: 700 10.5px var(--mono); color: var(--teal); background: var(--surface-2); border-radius: 4px; padding: 1px 5px; flex: none; margin-top: 1px; }
.draft .dt { font-size: 12.5px; color: var(--ink-2); flex: 1; }
.draft .why { color: var(--teal); text-decoration: underline; font-size: 11px; cursor: pointer; margin-top: 3px; display: inline-block; }
.draft .rationale { font-size: 11.5px; color: var(--muted); font-style: italic; margin-top: 4px; }

.send-row { display: flex; gap: 8px; align-items: flex-end; }
.send-row textarea { flex: 1; resize: none; background: var(--surface-2); border: 1px solid var(--line); color: var(--ink); border-radius: 8px; padding: 9px 11px; font: 13.5px var(--ui); }
.send-btn { min-width: 46px; min-height: 40px; display: grid; place-items: center; }
.send-btn .ic { width: 17px; height: 17px; }
.composer-hint { font-size: 11px; margin-top: 7px; }

.templates-list, .artifacts-list { display: flex; flex-direction: column; gap: 7px; max-height: 260px; overflow-y: auto; }
.tpl { border: 1px solid var(--line); border-radius: 8px; padding: 9px 11px; cursor: pointer; }
.tpl:hover { border-color: var(--line-2); }
.tpl.sel { border-color: var(--teal); background: var(--surface-2); }
.tpl-top { display: flex; align-items: center; gap: 8px; }
.tpl-name { font-size: 12.5px; font-weight: 600; font-family: var(--mono); }
.cat-chip { font: 10.5px var(--mono); text-transform: uppercase; letter-spacing: .04em; padding: 1px 6px; border-radius: 4px; margin-left: auto; }
.cat-chip.marketing { color: var(--hot); background: color-mix(in srgb, var(--hot) 15%, transparent); }
.cat-chip.utility { color: var(--teal); background: color-mix(in srgb, var(--teal) 15%, transparent); }
/* I-13: the send is never blind — exact body, variables filled live. */
.tpl-preview {
  margin-top: 8px; padding: 8px 11px; border-radius: 10px 10px 10px 3px;
  background: var(--bubble-in); font-size: 12.5px; line-height: 1.45;
  white-space: pre-wrap; overflow-wrap: anywhere;
}
.tpl-preview .tpl-hole {
  color: var(--amber); font-family: var(--mono); font-size: 11.5px;
  border: 1px dashed var(--amber); border-radius: 4px; padding: 0 3px;
}
.artifact-card.gated { opacity: .55; cursor: not-allowed; }
.tpl-vars { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }
.tpl-vars label { font: 10.5px var(--mono); color: var(--muted); }
.tpl-vars input { background: var(--surface); border: 1px solid var(--line); color: var(--ink); border-radius: 6px; padding: 6px 9px; font-size: 12.5px; }
.tpl-send { margin-top: 9px; }
.artifact-card { display: flex; align-items: center; gap: 10px; border: 1px solid var(--line); border-radius: 8px; padding: 9px 11px; }
.artifact-card .ic { width: 18px; height: 22px; color: var(--ink-2); flex: none; }
.artifact-card .an { font-size: 12.5px; font-weight: 600; }
.artifact-card .ad { font-size: 11.5px; color: var(--muted); }
.artifact-cap { width: 100%; margin-top: 8px; background: var(--surface); border: 1px solid var(--line); color: var(--ink); border-radius: 6px; padding: 6px 9px; font: 12px var(--ui); }
.artifact-send-row { display: flex; justify-content: flex-end; margin-top: 8px; }

/* ░ COPILOTO ░ */
.cop-card { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 11px 12px; margin-bottom: 11px; }
.cop-card.dead { border-style: dashed; }
.cc-h { display: flex; align-items: center; gap: 8px; font-size: 12px; font-weight: 600; color: var(--ink-2); margin-bottom: 8px; }
.cc-h .refresh { margin-left: auto; color: var(--muted); width: 24px; height: 24px; display: grid; place-items: center; border-radius: 5px; }
.cc-h .refresh:hover { color: var(--teal); background: var(--surface-2); }
.cc-h .refresh .ic { width: 14px; height: 14px; }
.cc-text { font-size: 12.5px; color: var(--ink-2); line-height: 1.5; white-space: pre-wrap; }

.pulse-top { display: flex; align-items: center; gap: 12px; margin-bottom: 9px; }
.pulse-num { font: 800 26px var(--mono); }
.pulse-label { font: 700 11px var(--mono); letter-spacing: .05em; padding: 2px 9px; border-radius: 5px; }
.pulse-label.caliente { color: var(--hot); background: color-mix(in srgb, var(--hot) 16%, transparent); }
.pulse-label.tibio { color: var(--amber); background: color-mix(in srgb, var(--amber) 16%, transparent); }
.pulse-label.frio { color: #7ea6b3; background: color-mix(in srgb, #7ea6b3 15%, transparent); }
.pulse-horizon { margin-left: auto; font-size: 11.5px; color: var(--ink-2); text-align: right; }
.pulse-bar { position: relative; height: 8px; border-radius: 4px; overflow: hidden; display: flex; }
.pulse-bar .band { height: 100%; }
.pulse-bar .b1 { flex: 34; background: color-mix(in srgb, #7ea6b3 30%, var(--surface-2)); }
.pulse-bar .b2 { flex: 33; background: color-mix(in srgb, var(--amber) 30%, var(--surface-2)); }
.pulse-bar .b3 { flex: 33; background: color-mix(in srgb, var(--hot) 30%, var(--surface-2)); }
.pulse-marker { position: absolute; top: -2px; width: 3px; height: 12px; background: var(--ink); border-radius: 2px; box-shadow: 0 0 0 2px var(--surface); }
.pulse-rationale { font-size: 12px; color: var(--muted); margin-top: 8px; line-height: 1.5; }

.nba-kind { font: 10.5px var(--mono); letter-spacing: .04em; color: var(--teal); border: 1px solid var(--line); border-radius: 5px; padding: 1px 7px; }
.nba-headline { font-size: 13px; font-weight: 700; color: var(--ink); margin: 7px 0 4px; }
.nba-detail { font-size: 12px; color: var(--ink-2); line-height: 1.5; }
.nba-actions { display: flex; gap: 7px; margin-top: 9px; }
.nba-actions button { min-height: 28px; padding: 4px 12px; font-size: 12px; border-radius: 6px; }
.nba-actions .primary { background: var(--teal); color: var(--teal-ink); font-weight: 650; }
.nba-actions .skip { border: 1px solid var(--line); color: var(--muted); }

.ctx-grid { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; font-size: 12px; }
.ctx-grid dt { color: var(--muted); }
.ctx-grid dd { margin: 0; color: var(--ink-2); }

.salud-status { display: flex; align-items: center; gap: 7px; font-size: 12.5px; font-weight: 600; margin-bottom: 7px; }
.salud-status .sdot { width: 8px; height: 8px; border-radius: 50%; }
.salud-status.activo { color: var(--green); } .salud-status.activo .sdot { background: var(--green); }
.salud-status.riesgo { color: var(--amber); } .salud-status.riesgo .sdot { background: var(--amber); }
.salud-status.elegible { color: var(--red); } .salud-status.elegible .sdot { background: var(--red); }
.salud-crit { list-style: none; margin: 0; padding: 0; }
.salud-crit li { font-size: 12px; padding: 2px 0; color: var(--ink-2); display: flex; gap: 7px; }
.salud-crit .met { color: var(--red); } .salud-crit .unmet { color: var(--muted); }
.salud-btn { margin-top: 9px; border: 1px solid var(--red); color: var(--red); border-radius: 6px; padding: 4px 12px; min-height: 28px; font-size: 12px; }

/* ░░ FOOTER ░░ */
.statusbar { flex: none; height: 26px; background: var(--chat-chrome); border-top: 1px solid var(--line);
  display: flex; align-items: center; justify-content: space-between; padding: 0 14px; font-size: 11px; }
.sb-left { display: flex; align-items: center; gap: 14px; }
.sb-live { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); }
.sb-live .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--amber); }
.sb-live.on .dot { background: var(--green); } .sb-live.off .dot { background: var(--red); }
.sb-right { font-size: 10.5px; }

/* toast */
.toast { position: fixed; bottom: 40px; left: 50%; transform: translateX(-50%); z-index: 50;
  background: var(--surface-2); border: 1px solid var(--line-2); color: var(--ink);
  border-radius: 8px; padding: 9px 16px; font-size: 13px; box-shadow: 0 10px 30px rgba(0,0,0,.5); }
.toast.error { border-color: var(--red); color: var(--red); }

.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; }

/* ░░ RESPONSIVE DRAWERS ░░ */
.scrim { position: absolute; inset: 0; background: rgba(0,0,0,.5); z-index: 8; }
/* Mid-desktop: the chat pane bottoms out at 480px — the header sheds by
   priority (name > ventana > cita > asignación; the stage lives in the
   funnel card, the export is an audit affordance) so the customer's
   name keeps its 120px minimum. */
@media (max-width: 1500px) {
  .ch-nav, .assign-label, #export-btn, #chat-stage { display: none; }
  .assign-select { max-width: 130px; }
}
@media (max-width: 1240px) {
  .layout { grid-template-columns: 280px 300px minmax(480px, 1fr); }
  .pane.copilot {
    position: absolute; top: 0; right: 0; bottom: 0; width: 320px; z-index: 9;
    border-left: 1px solid var(--line-2); transform: translateX(100%); transition: transform .18s ease;
  }
  body.copilot-open .pane.copilot { transform: translateX(0); }
  .chat-header #copilot-toggle { display: inline-flex; }
  .ch-nav { display: none; }
}
@media (max-width: 1000px) {
  .layout { grid-template-columns: 280px minmax(480px, 1fr); }
  .pane.crm {
    position: absolute; top: 0; left: 0; bottom: 0; width: 300px; z-index: 9;
    border-right: 1px solid var(--line-2); transform: translateX(-100%); transition: transform .18s ease;
  }
  body.crm-open .pane.crm { transform: translateX(0); }
  .chat-header #crm-toggle { display: inline-flex; }
}
@media (prefers-reduced-motion: reduce) {
  .pane.copilot, .pane.crm, .pane.chat { transition: none; }
}

/* ══ Trabajo (work queue, Elements 1.3 screen 2) ══ */

.view-toggle {
  display: flex; gap: 4px; padding: 0 12px 8px;
}
.vtab {
  flex: 1; padding: 5px 8px; border: 1px solid var(--line); border-radius: var(--radius);
  background: transparent; color: var(--muted); font: 600 12px/1.2 var(--ui); cursor: pointer;
}
.vtab.active { background: var(--surface-2); color: var(--ink); border-color: var(--line-2); }
.vtab .tab-count { color: var(--teal); font-family: var(--mono); margin-left: 2px; }

.work-list { list-style: none; margin: 0; padding: 4px 8px 12px; overflow-y: auto; flex: 1; }
.work-item {
  padding: 9px 10px; margin-bottom: 6px; border: 1px solid var(--line);
  border-radius: var(--radius); background: var(--surface); cursor: pointer;
}
.work-item:hover { border-color: var(--line-2); }
.work-item.active { border-color: var(--teal); }
.wi-top { display: flex; align-items: center; gap: 8px; }
.wi-name { font-weight: 600; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wi-reason { color: var(--muted); font-size: 12px; margin-top: 3px; }
.wi-due { color: var(--amber); font-family: var(--mono); font-size: 11px; }
.wi-check {
  border: 1px solid var(--line); background: transparent; color: var(--muted);
  border-radius: 6px; width: 24px; height: 24px; cursor: pointer; line-height: 1;
}
.wi-check:hover { color: var(--green); border-color: var(--green); }
.work-empty { color: var(--faint); padding: 18px 10px; font-size: 12.5px; list-style: none; }

.kind-pill {
  font: 600 10.5px/1 var(--ui); letter-spacing: .2px; padding: 4px 7px;
  border-radius: 999px; white-space: nowrap;
}
.kind-pill.k-reply_pending { background: #1d3a44; color: #9fd8e0; }
.kind-pill.k-new_lead { background: #17352a; color: #8fdcb8; }
.kind-pill.k-handoff { background: #3a2d1d; color: #ecc48d; }
.kind-pill.k-nurture_ready { background: #24303e; color: #a9c4e8; }
.kind-pill.k-appointment { background: #3a2334; color: #e8a9d4; }
.kind-pill.k-alert { background: #402224; color: #f0a3a8; }
.kind-pill.k-disqualification { background: #33272e; color: #d3a9c0; }

/* RF-34: the four-queue grouping of the bandeja */
.wq-head {
  display: flex; align-items: baseline; justify-content: space-between;
  padding: 10px 4px 4px; font: 700 10.5px/1 var(--ui); letter-spacing: 1.1px;
  text-transform: uppercase; color: var(--faint); list-style: none;
}
.wq-head:first-child { padding-top: 4px; }
.wq-count { font-family: var(--mono); font-weight: 600; color: var(--muted); }

/* Declared lead facts (modelo · ciudad · forma de pago) — the opener. */
.wi-facts {
  color: var(--ink-2); font-size: 12px; font-weight: 600; margin-top: 4px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
/* RF-35: enough context to act without opening the chat */
.wi-summary {
  color: var(--faint); font-size: 11.5px; margin-top: 4px; line-height: 1.35;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.wi-src {
  font: 600 10px/1 var(--mono); color: var(--muted); border: 1px solid var(--line);
  border-radius: 4px; padding: 2px 5px; white-space: nowrap;
}

/* RF-32 hybrid: the routing proposal rides on the card */
.wi-proposal {
  display: flex; align-items: center; gap: 8px; margin-top: 7px; padding-top: 7px;
  border-top: 1px dashed var(--line);
}
.wi-prop-text { flex: 1; font-size: 12px; color: var(--ink); }
.wi-prop-why { display: block; color: var(--faint); font-size: 11px; margin-top: 1px; }
.wi-accept {
  border: 1px solid var(--teal); color: var(--teal); background: transparent;
  border-radius: 6px; padding: 4px 10px; font: 600 11.5px var(--ui); cursor: pointer;
  white-space: nowrap;
}
.wi-accept:hover { background: var(--teal); color: #08252a; }
.wi-accept.danger { border-color: var(--red, #e5484d); color: var(--red, #e5484d); }
.wi-accept.danger:hover { background: var(--red, #e5484d); color: #fff; }
/* I-04: reassign affordance on the card head. */
.wi-reassign {
  border: 1px solid var(--line); background: transparent; color: var(--muted);
  border-radius: 6px; width: 24px; height: 24px; cursor: pointer; line-height: 1;
}
.wi-reassign:hover { color: var(--teal); border-color: var(--teal); }
/* I-08 / I-04: inline two-step confirm — no irreversible action in one click. */
.wi-confirm {
  margin-top: 8px; padding: 8px 10px; border: 1px solid var(--line);
  border-radius: 8px; background: var(--surface);
  display: flex; flex-direction: column; gap: 7px;
}
.wc-title { font-size: 11.5px; color: var(--muted); }
.wi-confirm input, .wi-confirm select {
  background: var(--bg, transparent); border: 1px solid var(--line); color: var(--ink);
  border-radius: 6px; padding: 5px 8px; font-size: 12px; width: 100%;
}
.wc-actions { display: flex; gap: 7px; }
.wc-cancel {
  border: 1px solid var(--line); background: transparent; color: var(--muted);
  border-radius: 6px; padding: 4px 10px; font: 600 11.5px var(--ui); cursor: pointer;
}
.wc-cancel:hover { color: var(--ink); }
/* I-05: three-state SLA — a calm border and an explicit chip. */
.work-item.sla-atrisk { border-left: 3px solid var(--amber); }
.work-item.sla-breached { border-left: 3px solid var(--red, #e5484d); }
.sla-chip { font: 600 10.5px var(--mono); padding: 1px 6px; border-radius: 4px; white-space: nowrap; }
.sla-chip.atrisk { color: var(--amber); background: color-mix(in srgb, var(--amber) 15%, transparent); }
.sla-chip.breached { color: var(--red, #e5484d); background: color-mix(in srgb, var(--red, #e5484d) 15%, transparent); }
.tf-clear {
  border: 1px solid var(--line); background: transparent; color: var(--muted);
  border-radius: 6px; width: 20px; height: 20px; cursor: pointer; line-height: 1;
  margin-left: 6px; vertical-align: 1px;
}
.tf-clear:hover { color: var(--ink); border-color: var(--line-2); }

/* RF-37: Equipo — the coordinator's load matrix over the four queues */
.team-view { overflow-y: auto; flex: 1; padding: 4px 8px 12px; }
.team-head, .team-row {
  display: flex; align-items: center; justify-content: space-between;
  width: 100%; gap: 8px; padding: 7px 8px;
}
.team-head { color: var(--faint); font: 700 10px/1 var(--mono); padding-bottom: 2px; }
.team-layer {
  font: 700 10.5px/1 var(--ui); letter-spacing: 1.1px; text-transform: uppercase;
  color: var(--faint); padding: 10px 4px 4px;
}
.team-row {
  border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface);
  cursor: pointer; margin-bottom: 5px; text-align: left; color: var(--ink); font: inherit;
}
.team-row:hover { border-color: var(--line-2); }
.team-row.unassigned { border-style: dashed; }
.tr-who { min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.tr-name { font-weight: 600; font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tr-sub { color: var(--faint); font-size: 10.5px; }
.tr-cells { display: flex; align-items: center; gap: 2px; flex-shrink: 0; }
.tr-cell {
  width: 22px; text-align: center; font: 600 11px/1 var(--mono); color: var(--muted);
}
.tr-cell.overdue { color: var(--amber); }
.tr-total {
  width: 26px; text-align: right; font: 700 12px/1 var(--mono); color: var(--teal);
}

/* assign control in the chat header */
.assign-wrap { display: inline-flex; align-items: center; gap: 6px; margin-left: 8px; }
.assign-label { color: var(--faint); font-size: 11px; }
.assign-select {
  background: var(--surface-2); color: var(--ink-2); border: 1px solid var(--line);
  border-radius: 6px; font: 12px var(--ui); padding: 3px 6px; max-width: 170px;
}

/* ══════════════ Alternativas (SHORTLIST.md) ══════════════ */
.sl-state { font-size: 11.5px; color: var(--muted); margin-bottom: 8px; }
.sl-item { border: 1px solid var(--line); border-radius: 8px; padding: 9px 10px; margin-bottom: 7px; }
.sl-item.proposed { border-style: dashed; border-color: var(--teal); }
.sl-top { display: flex; align-items: baseline; gap: 8px; }
.sl-name { font-size: 13px; font-weight: 600; flex: 1; }
.sl-price { font-size: 11.5px; color: var(--ink-2); }
.sl-version { font-size: 11.5px; color: var(--muted); margin-top: 1px; }
.sl-evidence { font-size: 11px; color: var(--teal); margin-top: 5px; display: flex; align-items: center; gap: 5px; }
.sl-evidence .ic { width: 11px; height: 11px; flex: none; }
.sl-fit { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.sl-note {
  font: 10.5px var(--mono); color: var(--muted); background: var(--surface-2);
  border-radius: 4px; padding: 1px 6px; cursor: help;
}
.sl-note.ok { color: var(--green); background: color-mix(in srgb, var(--green) 14%, transparent); }
.sl-note.bad { color: var(--amber); background: color-mix(in srgb, var(--amber) 14%, transparent); }
.sl-actions { display: flex; gap: 6px; margin-top: 8px; }

/* ══════════════ Workbench (cockpit P2 — Dirección A) ══════════════ */
.workbench { display: grid; grid-template-columns: 208px 1fr; min-height: 0; flex: 1; }
.wb-side {
  background: var(--chat-chrome); border-right: 1px solid var(--line);
  display: flex; flex-direction: column; gap: 4px; padding: 14px 10px;
}
.wb-side-label { font: 600 11px var(--ui); color: var(--faint); text-transform: uppercase; letter-spacing: .06em; padding: 0 8px 6px; }
.wb-nav {
  display: flex; align-items: center; gap: 7px; min-height: 34px; border-radius: 8px;
  border: 1px solid transparent; background: transparent; color: var(--muted);
  font: 600 13px var(--ui); padding: 6px 10px; cursor: pointer; text-align: left;
}
.wb-nav.active { background: var(--surface-2); border-color: var(--line-2); color: var(--ink); }
.wb-count { font: 11px var(--mono); color: var(--muted); margin-left: auto; }
.wb-sla { font: 10.5px var(--mono); color: var(--amber); background: rgba(217,162,74,.14); border-radius: 9px; padding: 1px 7px; }
.wb-side-foot { margin-top: auto; border-top: 1px solid var(--line); padding: 10px 8px 0; font-size: 11px; color: var(--faint); }
.wb-side-foot .teal { color: var(--teal); }
.wb-main { min-width: 0; overflow-y: auto; padding: 18px 22px; }
.wb-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.wb-head h1 { font-size: 19px; font-weight: 700; margin: 0 0 2px; }
.wb-sub { font-size: 12.5px; color: var(--muted); }
.wb-doctrine { font-size: 12px; color: var(--faint); margin: 6px 0 12px; }
.wb-ticker {
  display: inline-flex; align-items: center; gap: 7px; background: var(--surface);
  border: 1px solid var(--line); border-radius: 20px; padding: 5px 12px;
  font-size: 12px; color: var(--muted); white-space: nowrap;
}
.wb-ticker .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--teal); }
.wb-batchbars { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 12px; align-items: center; }
.wb-batchbar {
  display: inline-flex; align-items: center; gap: 10px; background: var(--surface);
  border: 1px solid var(--line-2); border-radius: 8px; padding: 9px 12px; font-size: 12.5px;
}
.wb-batchbar .why { font-size: 11px; color: var(--muted); }
.wb-batchcap { font-size: 11px; color: var(--faint); }
.wb-board { display: grid; grid-template-columns: repeat(4, minmax(255px, 1fr)); gap: 12px; align-items: start; }
.wb-col-head { display: flex; align-items: center; gap: 8px; margin: 0 0 8px; }
.wb-col-head .lbl { font-size: 13px; font-weight: 700; }
.wb-col-head .n { font: 11.5px var(--mono); color: var(--muted); }
.wb-risknote { font: 10.5px var(--mono); border-radius: 9px; padding: 1px 7px; }
.wb-risknote.overdue { color: var(--red); background: rgba(224,131,123,.12); }
.wb-risknote.atrisk { color: var(--amber); background: rgba(217,162,74,.12); }
.wb-empty { border: 1px dashed var(--line); border-radius: 10px; padding: 14px 12px; font-size: 12px; color: var(--faint); }
.wb-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: 10px;
  padding: 11px 12px; margin-bottom: 10px; cursor: pointer;
}
.wb-card.previewing, .wb-card.kfocus { border-color: var(--teal); }
.wb-card .r1 { display: flex; align-items: baseline; gap: 8px; }
.wb-card .nm { font-size: 13.5px; font-weight: 700; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wb-card .pscore { font: 10.5px var(--mono); color: var(--faint); }
.wb-chips { display: flex; flex-wrap: wrap; gap: 5px; margin: 5px 0; }
.wb-chip { font: 600 10.5px var(--ui); border-radius: 5px; padding: 3px 7px; }
.wb-chip.src { color: #9fd8e0; background: #1d3a44; }
.wb-chip.preq { color: #8fdcb8; background: #17352a; }
.wb-chip.crudo { color: #ecc48d; background: #3a2d1d; }
/* F7: campaign-of-origin chip (CTWA attribution) */
.wb-chip.camp { color: #c9b8f0; background: #2b2340; }
.wb-summary { font-size: 12.5px; color: var(--ink-2); line-height: 1.45; }
.wb-slaline { font: 11.5px var(--mono); color: var(--muted); margin-top: 6px; }
.wb-slaline.atrisk { color: var(--amber); background: rgba(217,162,74,.12); border-radius: 6px; padding: 3px 7px; display: inline-block; }
.wb-slaline.breached { color: var(--red); background: rgba(224,131,123,.1); border-radius: 6px; padding: 3px 7px; display: inline-block; }
.wb-prop { border-top: 1px dashed var(--line-2); margin-top: 9px; padding-top: 8px; font-size: 12px; }
.wb-prop .who { font-weight: 700; }
.wb-prop .why { font-size: 11px; color: var(--muted); margin: 2px 0 7px; }
.wb-actions { display: flex; gap: 7px; flex-wrap: wrap; }
.wb-ghost {
  border: 1px solid var(--teal); color: var(--teal); background: transparent;
  border-radius: 6px; padding: 4px 10px; font: 600 11.5px var(--ui); cursor: pointer;
}
.wb-ghost:hover { background: var(--teal); color: var(--teal-ink); }
.wb-ghost.neutral { border-color: var(--line); color: var(--ink-2); }
.wb-ghost.neutral:hover { background: var(--surface-2); color: var(--ink); }
.wb-ghost.danger { border-color: var(--red); color: var(--red); }
.wb-ghost.danger:hover { background: var(--red); color: #fff; }
.wb-others { margin-top: 7px; display: flex; flex-direction: column; gap: 4px; }
.wb-other {
  display: flex; align-items: center; gap: 8px; background: var(--chat-chrome);
  border: 1px solid var(--line); border-radius: 6px; padding: 6px 9px;
  font-size: 12px; color: var(--ink-2); cursor: pointer;
}
.wb-other:hover { border-color: var(--teal); }
.wb-other .load { margin-left: auto; font: 11px var(--mono); color: var(--muted); }
.wb-argos { display: inline-block; margin-top: 6px; color: var(--teal); font-size: 12px; cursor: pointer; }
/* Equipo */
.wb-team { max-width: 980px; }
.wb-trow-head, .wb-trow { display: grid; grid-template-columns: 220px repeat(4, 86px) 92px 82px 1fr; align-items: center; }
.wb-trow-head { font-size: 11.5px; color: var(--muted); padding: 6px 10px; }
.wb-trow-head .risk { color: var(--amber); }
.wb-trow-head .venc { color: var(--red); }
.wb-tlayer { font-size: 12px; font-weight: 700; color: var(--muted); margin: 14px 0 6px; }
.wb-trow { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 9px 10px; margin-bottom: 6px; }
.wb-trow.unassigned { border-style: dashed; }
.wb-trow .who .nm { font-size: 13px; font-weight: 600; display: block; }
.wb-trow .who .sub { font-size: 11px; color: var(--faint); }
.wb-tcell { font: 12px var(--mono); color: var(--ink-2); text-align: center; }
.wb-tcell.risk { color: var(--amber); }
.wb-tcell.venc { color: var(--red); }
.wb-carga { display: flex; align-items: center; gap: 8px; justify-content: flex-end; }
.wb-capbar { width: 100%; max-width: 130px; height: 5px; border-radius: 3px; background: var(--surface-2); overflow: hidden; }
.wb-capfill { height: 100%; background: var(--teal); }
.wb-capfill.warn { background: var(--amber); }
.wb-capfill.hot { background: var(--red); }
.wb-move {
  grid-column: 1 / -1; background: var(--surface); border: 1px solid var(--line-2);
  border-radius: 8px; padding: 10px 12px; margin-top: 8px;
  display: flex; flex-direction: column; gap: 7px; font-size: 12.5px;
}
.wb-move .targets { display: flex; flex-wrap: wrap; gap: 6px; }
.wb-move .cap { font-size: 11px; color: var(--faint); }
/* Preview slide-over */
.wb-scrim { position: fixed; inset: 0; background: rgba(4,8,10,.55); z-index: 40; }
.wb-preview {
  position: fixed; top: 0; right: 0; bottom: 0; width: 430px; z-index: 41;
  background: var(--chat-bg); border-left: 1px solid var(--line-2);
  display: flex; flex-direction: column;
}
.wbp-head { display: flex; align-items: center; gap: 8px; padding: 10px 14px; border-bottom: 1px solid var(--line); }
.wbp-name { font-size: 14px; font-weight: 700; flex: 1; }
.wbp-summary { padding: 8px 14px; font-size: 12.5px; color: var(--ink-2); border-bottom: 1px solid var(--line); }
.wbp-messages { flex: 1; overflow-y: auto; margin: 0; padding: 12px 14px; list-style: none; display: flex; flex-direction: column; gap: 8px; }
.wbp-foot { padding: 10px 14px; border-top: 1px solid var(--line); display: flex; flex-direction: column; gap: 8px; }
/* Cita (I-17) */
.cita-chip { font: 600 10.5px var(--ui); color: #e8a9d4; background: #3a2334; border-radius: 5px; padding: 3px 7px; white-space: nowrap; }
.cita-strip {
  display: flex; align-items: center; gap: 8px; padding: 8px 14px;
  background: var(--chat-chrome); border-bottom: 1px solid var(--line); flex-wrap: wrap;
}
.cita-strip .cs-label { font-size: 12px; color: var(--muted); }
.cita-strip input {
  background: var(--surface-2); border: 1px solid var(--line); color: var(--ink);
  border-radius: 7px; padding: 6px 9px; font-size: 12.5px;
}
.cita-strip .cs-title { flex: 1; min-width: 180px; }
/* Thread provenance (I-14/15) */
.day-sep { align-self: center; font: 10.5px var(--mono); color: var(--faint);
  background: var(--surface); border: 1px solid var(--surface-2); border-radius: 20px; padding: 3px 12px; list-style: none; }
.trail-line { align-self: center; font-size: 11px; color: var(--muted); list-style: none; display: flex; align-items: center; gap: 6px; text-align: center; }
.trail-line .dot { width: 5px; height: 5px; border-radius: 50%; background: var(--teal); flex: none; }
.author-tag { font: 10.5px var(--mono); color: var(--muted); margin: 5px 2px 2px; }
/* Undo toast action */
.toast .undo { margin-left: 10px; color: var(--teal); cursor: pointer; font-weight: 700; }
/* 1280 graceful step (REVIEW #9) */
@media (max-width: 1359px) {
  .workbench { grid-template-columns: 64px 1fr; }
  .wb-side-label, .wb-side-foot, .wb-count, .wb-sla { display: none; }
  .wb-nav { justify-content: center; font-size: 11px; padding: 6px 4px; }
  .wb-board { grid-template-columns: repeat(4, minmax(235px, 1fr)); gap: 10px; }
}

/* ══════════════ Móvil ≤720px (COCKPIT_MOVIL.md M1) ══════════════
   One pane at a time. The bandeja is the home screen; the chat slides
   over it (body.chat-open); ficha and copiloto are the same drawers as
   on narrow desktops, now full width. */
.ch-break { display: none; }
@media (max-width: 720px) {
  /* The bandeja owns the single column; everything else overlays it.
     overflow hidden: the off-screen chat pane must not widen the page. */
  .layout { grid-template-columns: 1fr; overflow: hidden; }
  .pane { border-right: 0; }
  .pane.chat {
    position: absolute; inset: 0; z-index: 7;
    transform: translateX(100%); transition: transform .18s ease;
  }
  body.chat-open .pane.chat { transform: translateX(0); }
  .pane.crm, .pane.copilot { width: 100%; border-left: 0; border-right: 0; }
  #back-to-inbox { display: inline-flex; }

  /* Chrome slims down; the statusbar's row goes back to the content. */
  .topbar { gap: 8px; padding: 8px 10px; }
  .brand span, #agent-avatar { display: none; }
  .live-pill .txt { display: none; }
  .top-right { gap: 8px; }
  .tenant-chip { max-width: 44vw; min-width: 0; }
  .tenant-chip #tenant-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .statusbar { display: none; }
  .login-card { width: min(370px, calc(100vw - 32px)); }

  /* The keyboard must not cover the composer (app.js keeps --vvh live). */
  .app { height: var(--vvh, 100%); }
  .composer { padding-bottom: calc(12px + env(safe-area-inset-bottom)); }
  /* M3: pull-to-refresh would kill the live WebSocket session; scroll
     stays inside each pane and never chains into the page. */
  html, body { overscroll-behavior-y: none; }
  .messages, .pane, .wb-main, .wb-team, .filters, .wb-side { overscroll-behavior: contain; }

  /* Chat header: row 1 = volver · quién · ventana (the glance row);
     row 2 = acciones (ficha · cita · asignación · copiloto). */
  .chat-header { flex-wrap: wrap; gap: 6px 8px; padding: 8px 10px; }
  .ch-break { display: block; flex-basis: 100%; height: 0; }
  .ch-nav, #export-btn, .assign-label { display: none; }
  #crm-toggle, #cita-toggle, .assign-wrap, #copilot-toggle { order: 1; }
  /* basis 0: the row-wrap decision sees ch-id as small, so the window
     chip stays on row 1; grow then hands ch-id the leftover middle.
     The cita chip yields to the name (the strip and queue carry it). */
  .ch-id { flex: 1 1 0; min-width: 90px; }
  #chat-cita { display: none; }
  #chat-window { min-width: 0; overflow: hidden; }
  .assign-wrap { margin-left: 0; }
  .assign-select { max-width: 118px; min-height: 42px; }
  .chat-header .drawer-toggle { min-height: 42px; }

  /* Touch: inputs at 16px kill iOS focus-zoom; targets reach 44px. */
  .app input, .app select, .app textarea, .login input { font-size: 16px; }
  .conv { padding: 11px 12px; }
  .chip-filter { min-height: 48px; }
  .vtab, .ctab, .wb-nav { min-height: 42px; }
  .sugg .sactions button, .stage-actions button, .cad-actions button,
  .sl-actions button, .confirm .c-actions button { min-height: 44px; padding: 8px 14px; }
  /* id: button.primary (0,1,1) out-specifies .send-btn (0,1,0) */
  #send-btn { min-height: 48px; min-width: 52px; }
  .work-list li.work-item, .team-row { padding: 11px 12px; }
  .wi-check, .wi-reassign { min-width: 44px; min-height: 44px; }
  .msg { max-width: 88%; }
  .filters { overflow-x: auto; }

  /* Workbench mínimo: rail arriba, colas en acordeón, Equipo desplaza. */
  .workbench { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .wb-side {
    flex-direction: row; align-items: center; gap: 6px;
    border-right: 0; border-bottom: 1px solid var(--line);
    padding: 8px 10px; overflow-x: auto;
  }
  .wb-nav { flex: none; }
  .wb-main { padding: 12px; }
  .wb-board { grid-template-columns: 1fr; }
  .wb-col-head { cursor: pointer; min-height: 44px; }
  .wb-col-head::after { content: "▾"; color: var(--faint); margin-left: auto; }
  .wb-col.collapsed .wb-col-head::after { content: "▸"; }
  .wb-col.collapsed .wb-card, .wb-col.collapsed .wb-empty { display: none; }
  .wb-preview { width: 100%; }
  .wb-team { overflow-x: auto; }
  .wb-trow-head, .wb-trow { min-width: 720px; }
}
