:root {
  --bg: #f4f5f7;
  --panel: #ffffff;
  --panel-2: #f9fafb;
  --ink: #111827;
  --ink-2: #374151;
  --muted: #6b7280;
  --line: #e5e7eb;
  --line-2: #eef0f3;
  --accent: #0e9f6e;
  --accent-2: #0b8a5f;
  --accent-soft: #e7f6ef;
  --side: #0d1b1e;
  --side-ink: #b7c4c6;
  --side-hi: #ffffff;
  --amber: #b45309; --amber-soft: #fef3c7;
  --red: #dc2626; --red-soft: #fee2e2;
  --blue: #1d4ed8; --blue-soft: #dbeafe;
  --violet: #6d28d9; --violet-soft: #ede9fe;
  --green: #047857; --green-soft: #d1fae5;
  --s1: #2a78d6; --s2: #eb6834;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(16,24,40,.05), 0 1px 3px rgba(16,24,40,.06);
  --shadow-lg: 0 12px 40px rgba(16,24,40,.18);
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font: 14px/1.45 var(--font); color: var(--ink); background: var(--bg); -webkit-font-smoothing: antialiased; }
a { color: var(--accent-2); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0; line-height: 1.2; }
h1 { font-size: 22px; font-weight: 700; letter-spacing: -.01em; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
h3 { font-size: 15px; font-weight: 650; display: flex; align-items: center; gap: 6px; }
h4 { font-size: 13px; font-weight: 650; color: var(--ink-2); }
p { margin: .4em 0; }
code, .mono { font-family: var(--mono); font-size: 12.5px; }
code { background: var(--line-2); padding: 1px 5px; border-radius: 5px; }
pre { background: #0f172a; color: #e2e8f0; padding: 12px 14px; border-radius: 10px; overflow: auto; font: 12px/1.5 var(--mono); }
small, .small { font-size: 12px; }
.muted { color: var(--muted); }
.center { text-align: center; }
.pre { white-space: pre-wrap; }
.pad { padding: 4px 18px 16px; }
.mt { margin-top: 16px; }
.t-amber { color: var(--amber); } .t-red { color: var(--red); } .t-green { color: var(--green); }
.ico { flex: none; }
[hidden] { display: none !important; }

/* ---------- Botones y formularios ---------- */
.btn { display: inline-flex; align-items: center; gap: 6px; height: 36px; padding: 0 14px; border-radius: 9px; border: 1px solid var(--line); background: var(--panel); color: var(--ink); font: 600 13.5px var(--font); cursor: pointer; white-space: nowrap; text-decoration: none !important; transition: background .12s, border-color .12s, box-shadow .12s; }
.btn:hover { background: var(--panel-2); border-color: #d1d5db; }
.btn:disabled { opacity: .55; cursor: default; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-2); }
.btn.danger { background: var(--red); border-color: var(--red); color: #fff; }
.btn.danger.ghost { background: transparent; color: var(--red); border-color: #f3c4c4; }
.btn.warn { background: #f59e0b; border-color: #f59e0b; color: #1f1300; }
.btn.ghost { background: transparent; }
.btn.small { height: 30px; padding: 0 10px; font-size: 12.5px; border-radius: 8px; }
.btn.tiny { height: 22px; padding: 0 6px; font-size: 11px; border-radius: 6px; }
.btn.block { width: 100%; justify-content: center; height: 42px; }
.icon-btn { display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: 8px; border: 0; background: transparent; color: var(--muted); cursor: pointer; }
.icon-btn:hover { background: var(--line-2); color: var(--ink); }
.icon-btn.danger:hover { background: var(--red-soft); color: var(--red); }
input, select, textarea { font: 14px var(--font); color: var(--ink); background: #fff; border: 1px solid #d6dae0; border-radius: 9px; padding: 8px 11px; width: 100%; outline: none; transition: border-color .12s, box-shadow .12s; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(14,159,110,.15); }
textarea { resize: vertical; }
select { height: 36px; padding: 0 10px; }
.form { display: grid; gap: 12px; }
.form label { display: grid; gap: 5px; font-weight: 600; font-size: 12.5px; color: var(--ink-2); }
.form label small { font-weight: 400; color: var(--muted); }
.form label.check { display: flex; align-items: center; gap: 8px; font-weight: 500; }
.form label.check input { width: auto; }
.form.compact { gap: 9px; }
.grid-form { grid-template-columns: 1fr 1fr; }
.grid-form .span-2 { grid-column: 1 / -1; }
.form-sec { margin-top: 6px; padding-top: 10px; border-top: 1px solid var(--line); }
.form-error { color: var(--red); background: var(--red-soft); padding: 8px 10px; border-radius: 8px; margin: 0; }
.search { position: relative; display: flex; align-items: center; }
.search .ico { position: absolute; left: 10px; color: var(--muted); }
.search input { padding-left: 32px; height: 36px; }

/* ---------- Insignias ---------- */
.badge { display: inline-flex; align-items: center; height: 20px; padding: 0 8px; border-radius: 99px; font-size: 11.5px; font-weight: 650; background: var(--line-2); color: var(--ink-2); text-transform: capitalize; vertical-align: middle; }
.badge.green { background: var(--green-soft); color: var(--green); }
.badge.blue { background: var(--blue-soft); color: var(--blue); }
.badge.amber { background: var(--amber-soft); color: var(--amber); }
.badge.violet { background: var(--violet-soft); color: var(--violet); }
.badge.gray { background: #eceef1; color: #6b7280; }
.pill { display: inline-flex; align-items: center; gap: 3px; height: 19px; padding: 0 7px; border-radius: 6px; font-size: 11px; font-weight: 600; background: var(--line-2); color: var(--ink-2); }
.pill.amber { background: var(--amber-soft); color: var(--amber); }
.pill.violet { background: var(--violet-soft); color: var(--violet); }
.avatar { display: inline-grid; place-items: center; flex: none; width: 38px; height: 38px; border-radius: 50%; color: #fff; font-weight: 700; font-size: 13px; }
.avatar.sm { width: 30px; height: 30px; font-size: 11px; }

/* ---------- Acceso ---------- */
body.auth { background: var(--side); }
.auth-wrap { min-height: 100%; display: grid; grid-template-columns: minmax(340px, 460px) 1fr; }
.auth-card { background: #fff; padding: 48px 44px; display: flex; flex-direction: column; justify-content: center; gap: 18px; }
.auth-card h1 { font-size: 24px; margin-top: 18px; }
.auth-side { color: #dce7e8; padding: 64px; display: flex; flex-direction: column; justify-content: center; background: radial-gradient(1200px 500px at 20% 0%, rgba(14,159,110,.35), transparent 60%), var(--side); }
.auth-side h2 { font-size: 34px; line-height: 1.15; max-width: 520px; color: #fff; letter-spacing: -.02em; }
.auth-side ul { list-style: none; padding: 0; margin: 28px 0 0; display: grid; gap: 14px; font-size: 15px; }
.auth-side li { display: flex; gap: 10px; align-items: center; }
.auth-side .ico { color: #34d399; }
.brand { display: flex; align-items: center; gap: 10px; }
.brand .logo { width: 34px; height: 34px; flex: none; }
.brand.big .logo { width: 44px; height: 44px; }
.brand strong { display: block; font-size: 15px; }
.brand span { display: block; font-size: 12px; color: var(--muted); }

/* ---------- Estructura ---------- */
body.app { display: grid; grid-template-columns: 236px 1fr; height: 100vh; overflow: hidden; }
.sidebar { background: var(--side); color: var(--side-ink); display: flex; flex-direction: column; padding: 16px 12px; gap: 14px; overflow-y: auto; }
.sidebar .brand { padding: 2px 6px 10px; }
.sidebar .brand strong { color: #fff; }
.sidebar .brand span { color: #7f9496; }
.sidebar nav { display: grid; gap: 2px; }
.sidebar nav a { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; color: var(--side-ink); font-weight: 550; text-decoration: none; }
.sidebar nav a:hover { background: rgba(255,255,255,.06); color: #fff; }
.sidebar nav a.active { background: rgba(14,159,110,.18); color: #fff; }
.sidebar nav a.active .ico { color: #34d399; }
.nav-sep { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: #5f7577; padding: 14px 10px 4px; }
.nav-badge { margin-left: auto; font-style: normal; background: var(--accent); color: #fff; font-size: 11px; font-weight: 700; min-width: 20px; height: 20px; border-radius: 99px; display: grid; place-items: center; padding: 0 6px; }
.me { margin-top: auto; display: flex; align-items: center; gap: 4px; border-top: 1px solid rgba(255,255,255,.08); padding-top: 12px; }
.me-btn { flex: 1; display: flex; align-items: center; gap: 9px; background: none; border: 0; color: inherit; cursor: pointer; text-align: left; padding: 4px; border-radius: 8px; min-width: 0; }
.me-btn:hover { background: rgba(255,255,255,.06); }
.me-btn .avatar { width: 32px; height: 32px; font-size: 12px; }
.me-txt { min-width: 0; }
.me-txt strong { display: block; color: #fff; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.me-txt small { color: #7f9496; }
.me .icon-btn { color: var(--side-ink); }
.me .icon-btn:hover { background: rgba(255,255,255,.08); color: #fff; }
.mobile-menu { display: none; }
#view { overflow-y: auto; min-width: 0; }
.page { padding: 26px 30px 40px; max-width: 1320px; margin: 0 auto; display: grid; gap: 18px; align-content: start; }
.page.narrow { max-width: 920px; }
.page-full { max-width: none; height: 100%; grid-template-rows: auto 1fr; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; }
.head-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.head-actions select { width: auto; }
.head-actions .search input { width: 230px; }
.crumb { display: inline-flex; align-items: center; gap: 4px; color: var(--muted); font-weight: 600; font-size: 13px; margin-bottom: -8px; }
.offline-bar { display: none; position: fixed; bottom: 14px; left: 50%; transform: translateX(-50%); background: #111827; color: #fff; padding: 8px 14px; border-radius: 99px; font-size: 12.5px; z-index: 40; }
body.offline .offline-bar { display: block; }
.loading { display: grid; place-items: center; height: 60vh; }
.loading span { width: 28px; height: 28px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--accent); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Tarjetas ---------- */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); min-width: 0; position: relative; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 14px 18px 10px; }
.link { font-weight: 600; font-size: 13px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); display: grid; gap: 2px; color: inherit; text-decoration: none !important; transition: border-color .12s, transform .12s; }
a.stat:hover { border-color: #b7e4d2; transform: translateY(-1px); }
.stat span { color: var(--muted); font-size: 12.5px; font-weight: 600; }
.stat strong { font-size: 28px; font-weight: 750; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.stat small { color: var(--muted); }
.list { list-style: none; margin: 0; padding: 0 8px 10px; }
.list li { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 8px; }
.list li:hover { background: var(--panel-2); }
.list li a, .list li > span { display: grid; min-width: 0; color: inherit; text-decoration: none; }
.list li a span, .list li > span > span { color: var(--muted); font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list li small { text-align: right; flex: none; }
.warn-card { border-color: #f6d999; background: #fffbeb; }
.legend { display: flex; gap: 12px; font-size: 12px; color: var(--ink-2); }
.legend span { display: inline-flex; align-items: center; gap: 5px; }
.legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.chart { position: relative; padding: 0 14px 12px; }
.chart svg { width: 100%; height: auto; display: block; }
.chart .grid { stroke: var(--line-2); stroke-width: 1; }
.chart .axis { fill: var(--muted); font-size: 10.5px; font-family: var(--font); }
.chart g[data-tip]:hover rect { fill: rgba(17,24,39,.04); }
.chart-tip { position: absolute; pointer-events: none; background: #111827; color: #fff; font-size: 12px; padding: 7px 10px; border-radius: 8px; line-height: 1.45; white-space: nowrap; z-index: 2; }
.funnel { display: grid; gap: 9px; padding: 6px 18px 18px; }
.funnel-row { display: grid; grid-template-columns: 96px 1fr 34px; align-items: center; gap: 10px; font-size: 13px; }
.funnel-row b { text-align: right; font-variant-numeric: tabular-nums; }
.funnel .bar { height: 12px; background: var(--line-2); border-radius: 6px; overflow: hidden; }
.funnel .bar i { display: block; height: 100%; border-radius: 6px; min-width: 2px; }
.st-nuevo { background: #64748b; } .st-contactado { background: #2a78d6; } .st-demo { background: #7c3aed; }
.st-propuesta { background: #eda100; } .st-negociacion { background: #eb6834; } .st-ganado { background: #0e9f6e; } .st-perdido { background: #c0c4cb; }
.empty { text-align: center; padding: 56px 20px; color: var(--muted); display: grid; justify-items: center; gap: 8px; }
.empty h4 { font-size: 15px; color: var(--ink); }
.empty p { max-width: 420px; margin: 0; }
.empty .ico { color: #c2c8cf; }
.alert { display: flex; align-items: center; gap: 8px; padding: 10px 14px; border-radius: 10px; font-weight: 500; }
.alert.amber { background: var(--amber-soft); color: #78350f; }
.alert.blue { background: var(--blue-soft); color: #1e3a8a; }

/* ---------- Tablas ---------- */
.table-card { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: 12px; font-weight: 650; color: var(--muted); padding: 11px 14px; border-bottom: 1px solid var(--line); background: var(--panel-2); white-space: nowrap; }
.table td { padding: 11px 14px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tr[data-href] { cursor: pointer; }
.table tbody tr:hover { background: #fafbfc; }
.table tr.hl td { background: #fffbeb; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table .detail { max-width: 360px; font-size: 12px; color: var(--muted); word-break: break-word; }
.row-actions { white-space: nowrap; text-align: right; }
.user-cell { display: flex; gap: 10px; align-items: center; }
.facts { display: grid; grid-template-columns: 150px 1fr; gap: 8px 12px; margin: 0; }
.facts dt { color: var(--muted); font-size: 12.5px; }
.facts dd { margin: 0; word-break: break-word; }

/* ---------- Bots ---------- */
.bot-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); gap: 16px; }
.bot-card { padding: 16px 18px; display: grid; gap: 6px; color: inherit; text-decoration: none !important; transition: border-color .12s, transform .12s; }
.bot-card:hover { border-color: #b7e4d2; transform: translateY(-1px); }
.bc-top { display: flex; justify-content: space-between; align-items: center; }
.bot-ico { width: 40px; height: 40px; border-radius: 10px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); }
.bot-card h3 { font-size: 16px; margin-top: 6px; }
.bot-card p { margin: 0; }
.bc-stats { display: flex; gap: 14px; font-size: 12.5px; color: var(--ink-2); margin: 4px 0; }
.corner { position: absolute; top: 16px; right: 90px; }
.endpoint { display: flex; align-items: center; justify-content: space-between; gap: 8px; background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; padding: 4px 4px 4px 10px; margin-top: 6px; }
.endpoint code { background: none; padding: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.keybox { display: grid; gap: 10px; }
.secret-val { display: flex; gap: 8px; align-items: center; background: #0f172a; border-radius: 10px; padding: 10px 10px 10px 14px; }
.secret-val code { background: none; color: #a7f3d0; padding: 0; flex: 1; word-break: break-all; }
.secret-val code.wrap { white-space: pre-wrap; max-height: 260px; overflow: auto; }

/* ---------- Modales y avisos ---------- */
.modal-wrap { position: fixed; inset: 0; background: rgba(15,23,42,.45); display: grid; place-items: center; z-index: 50; padding: 20px; animation: fade .12s; }
.modal { background: #fff; border-radius: 14px; width: min(480px, 100%); max-height: calc(100vh - 40px); display: flex; flex-direction: column; box-shadow: var(--shadow-lg); animation: pop .14s; }
.modal-wide { width: min(720px, 100%); }
.modal header { display: flex; justify-content: space-between; align-items: center; padding: 16px 18px 8px 22px; }
.modal header h3 { font-size: 17px; }
.modal-body { padding: 8px 22px 16px; overflow-y: auto; }
.modal footer { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 18px; border-top: 1px solid var(--line); background: var(--panel-2); border-radius: 0 0 14px 14px; }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { transform: translateY(6px) scale(.98); opacity: 0; } }
#toasts { position: fixed; top: 16px; right: 16px; display: grid; gap: 8px; z-index: 60; }
.toast { background: #111827; color: #fff; padding: 10px 14px; border-radius: 10px; box-shadow: var(--shadow-lg); font-weight: 500; max-width: 380px; transition: opacity .4s, transform .4s; border-left: 4px solid var(--accent); }
.toast-error { border-left-color: var(--red); }
.toast-info { border-left-color: var(--s1); }
.toast.out { opacity: 0; transform: translateX(10px); }

/* ---------- Bandeja ---------- */
.view-inbox { overflow: hidden; }
.inbox { display: grid; grid-template-columns: 340px 1fr 300px; height: 100vh; }
.inbox-list { background: var(--panel); border-right: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; }
.inbox-list header { padding: 16px 14px 10px; display: grid; gap: 10px; border-bottom: 1px solid var(--line); }
.inbox-list h2 { font-size: 19px; }
.filter-tabs { display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; }
.filter-tabs button { border: 0; background: var(--line-2); color: var(--ink-2); font: 600 12px var(--font); height: 28px; padding: 0 10px; border-radius: 99px; cursor: pointer; white-space: nowrap; display: inline-flex; gap: 5px; align-items: center; }
.filter-tabs button.on { background: var(--ink); color: #fff; }
.filter-tabs em { font-style: normal; opacity: .7; }
.conv-list { list-style: none; margin: 0; padding: 6px; overflow-y: auto; flex: 1; }
.conv { display: flex; gap: 10px; padding: 10px; border-radius: 10px; cursor: pointer; }
.conv:hover { background: var(--panel-2); }
.conv.active { background: var(--accent-soft); }
.conv-main { flex: 1; min-width: 0; display: grid; gap: 2px; }
.conv-top { display: flex; justify-content: space-between; gap: 8px; }
.conv-top strong { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 600; }
.conv.unread .conv-top strong { font-weight: 800; }
.conv-top time { font-size: 11.5px; color: var(--muted); white-space: nowrap; }
.conv-preview { color: var(--muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv.unread .conv-preview { color: var(--ink); }
.conv-meta { display: flex; gap: 6px; align-items: center; font-size: 11.5px; min-width: 0; }
.conv-meta .muted { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.unread-dot { margin-left: auto; font-style: normal; background: var(--accent); color: #fff; font-weight: 700; font-size: 11px; min-width: 19px; height: 19px; border-radius: 99px; display: grid; place-items: center; padding: 0 5px; }
.list-empty { padding: 30px; text-align: center; color: var(--muted); list-style: none; }
.chat { display: flex; flex-direction: column; min-width: 0; min-height: 0; background: #efeae2; background-image: radial-gradient(rgba(0,0,0,.035) 1px, transparent 1px); background-size: 18px 18px; }
.chat > .empty { margin: auto; }
.chat-head { display: flex; align-items: center; gap: 10px; padding: 10px 14px; background: var(--panel); border-bottom: 1px solid var(--line); }
.chat-head .back { display: none; }
.chat-title { flex: 1; min-width: 0; display: grid; }
.chat-title strong { font-size: 15px; }
.chat-title span { color: var(--muted); font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-actions { display: flex; gap: 6px; align-items: center; }
.mode-banner { display: flex; align-items: center; gap: 8px; padding: 7px 16px; font-size: 12.5px; }
.mode-banner.bot { background: var(--violet-soft); color: #4c1d95; }
.mode-banner.human { background: var(--amber-soft); color: #78350f; }
.msgs { flex: 1; overflow-y: auto; padding: 16px 6%; display: flex; flex-direction: column; gap: 4px; }
.load-more { align-self: center; margin-bottom: 8px; }
.day-sep { align-self: center; margin: 10px 0 6px; }
.day-sep span { background: #fff; color: var(--muted); font-size: 11.5px; font-weight: 600; padding: 4px 10px; border-radius: 8px; box-shadow: var(--shadow); text-transform: capitalize; }
.sys-msg { align-self: center; background: #fff8e1; color: #7c5b00; font-size: 12px; padding: 5px 12px; border-radius: 8px; margin: 6px 0; text-align: center; max-width: 80%; box-shadow: var(--shadow); }
.msg { display: flex; flex-direction: column; max-width: min(72%, 560px); }
.msg.in { align-self: flex-start; }
.msg.bot, .msg.agent, .msg.note { align-self: flex-end; align-items: flex-end; }
.msg-who { font-size: 11px; font-weight: 650; color: #54656f; display: flex; align-items: center; gap: 3px; margin: 6px 6px 2px; }
.bubble { padding: 7px 10px 5px; border-radius: 10px; box-shadow: 0 1px .5px rgba(11,20,26,.13); word-wrap: break-word; overflow-wrap: anywhere; }
.msg.in .bubble { background: #fff; border-top-left-radius: 3px; }
.msg.bot .bubble { background: #d9fdd3; border-top-right-radius: 3px; }
.msg.agent .bubble { background: #cfe9ff; border-top-right-radius: 3px; }
.msg.note .bubble { background: #fff4c4; border: 1px dashed #e0c25a; }
.bubble img { max-width: 260px; max-height: 260px; border-radius: 7px; display: block; margin-bottom: 4px; }
.bubble .file { display: inline-flex; gap: 5px; align-items: center; }
.msg-time { font-size: 10.5px; color: #667781; text-align: right; margin-top: 2px; display: flex; gap: 4px; justify-content: flex-end; align-items: center; }
.m-err { color: var(--red); font-weight: 700; }
.m-err-txt { font-size: 11.5px; color: var(--red); margin-top: 3px; }
.composer { background: var(--panel); border-top: 1px solid var(--line); padding: 8px 12px 12px; }
.composer.note-mode { background: #fffbea; }
.compose-tabs { display: flex; gap: 4px; align-items: center; margin-bottom: 6px; }
.compose-tabs button { border: 0; background: none; font: 600 12.5px var(--font); color: var(--muted); padding: 4px 10px; border-radius: 7px; cursor: pointer; }
.compose-tabs button.on { background: var(--line-2); color: var(--ink); }
.note-mode .compose-tabs button.on { background: #fde68a; }
#compose { display: flex; gap: 8px; align-items: flex-end; }
#compose textarea { resize: none; min-height: 40px; max-height: 160px; line-height: 1.4; }
#compose .btn { height: 40px; width: 44px; justify-content: center; padding: 0; }
.window-closed { display: flex; gap: 8px; align-items: center; background: var(--line-2); color: var(--ink-2); padding: 10px 12px; border-radius: 9px; font-size: 13px; }
.contact-panel { background: var(--panel); border-left: 1px solid var(--line); overflow-y: auto; padding: 0 16px 20px; }
.contact-panel header { display: flex; justify-content: space-between; align-items: center; padding: 16px 0 10px; }
.contact-panel header .icon-btn { display: none; }
.panel-sec { border-top: 1px solid var(--line); margin-top: 16px; padding-top: 14px; display: grid; gap: 8px; }
.kv { display: flex; justify-content: space-between; align-items: center; font-size: 13px; }
.kv span { color: var(--muted); }
.lbl { display: grid; gap: 4px; font-size: 12.5px; font-weight: 600; color: var(--ink-2); }
.lead-chip { display: flex; align-items: center; gap: 6px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; color: var(--ink); font-weight: 600; }

/* ---------- CRM ---------- */
.view-crm { overflow: hidden; }
.view-crm .page { height: 100%; padding-bottom: 16px; }
.kanban { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(250px, 1fr); gap: 12px; overflow-x: auto; min-height: 0; padding-bottom: 6px; }
.col { background: #eceef2; border-radius: 12px; display: flex; flex-direction: column; min-height: 0; transition: background .12s, box-shadow .12s; }
.col.over { background: #dff3ea; box-shadow: inset 0 0 0 2px var(--accent); }
.col header { display: flex; align-items: center; gap: 7px; padding: 12px 12px 8px; font-size: 13px; }
.col header em { font-style: normal; color: var(--muted); font-weight: 600; }
.col header small { margin-left: auto; color: var(--muted); font-weight: 600; }
.col .dot { width: 9px; height: 9px; border-radius: 50%; }
.col-body { padding: 4px 8px 10px; display: grid; gap: 8px; align-content: start; overflow-y: auto; flex: 1; }
.col-empty { text-align: center; color: #9aa1ab; font-size: 12px; padding: 16px 0; }
.lead-card { background: #fff; border-radius: 10px; padding: 10px 12px; box-shadow: var(--shadow); cursor: grab; display: grid; gap: 5px; border: 1px solid transparent; transition: border-color .12s, transform .12s; }
.lead-card:hover { border-color: #b7e4d2; }
.lead-card.dragging { opacity: .45; transform: rotate(1.5deg); }
.lc-top { display: flex; justify-content: space-between; gap: 6px; }
.lc-top strong { font-size: 13.5px; }
.lc-val { font-size: 12px; color: var(--green); white-space: nowrap; }
.lc-sub { font-size: 12.5px; color: var(--ink-2); }
.lc-tags { display: flex; gap: 4px; flex-wrap: wrap; }
.lc-next { font-size: 12px; display: flex; gap: 4px; align-items: center; color: var(--ink-2); }
.lc-foot { display: flex; justify-content: space-between; font-size: 11.5px; }
.drawer-wrap { position: fixed; inset: 0; background: rgba(15,23,42,.35); z-index: 45; display: flex; justify-content: flex-end; animation: fade .12s; }
.drawer { width: min(520px, 100%); background: #fff; height: 100%; display: flex; flex-direction: column; box-shadow: var(--shadow-lg); animation: slide .16s; }
@keyframes slide { from { transform: translateX(30px); opacity: 0; } }
.drawer > header { display: flex; justify-content: space-between; gap: 10px; padding: 20px 22px 10px; }
.drawer h2 { font-size: 20px; }
.stage-bar { display: flex; gap: 3px; padding: 0 22px 12px; flex-wrap: wrap; }
.stage-bar button { border: 1px solid var(--line); background: #fff; font: 600 11.5px var(--font); color: var(--muted); padding: 5px 9px; border-radius: 7px; cursor: pointer; }
.stage-bar button:hover { border-color: #b9c0ca; color: var(--ink); }
.stage-bar button.on { color: #fff; border-color: transparent; }
.st-bg-nuevo { background: #64748b !important; } .st-bg-contactado { background: #2a78d6 !important; } .st-bg-demo { background: #7c3aed !important; }
.st-bg-propuesta { background: #b98000 !important; } .st-bg-negociacion { background: #d4561f !important; } .st-bg-ganado { background: #0e9f6e !important; } .st-bg-perdido { background: #8b929c !important; }
.drawer-body { overflow-y: auto; padding: 4px 22px 30px; display: grid; gap: 18px; align-content: start; }
.quick { display: flex; gap: 6px; flex-wrap: wrap; }
.block { display: grid; gap: 8px; }
.block > p { margin: 0; }
.act-form { display: grid; grid-template-columns: 110px 1fr auto; gap: 6px; }
.act-form select, .act-form input { height: 32px; font-size: 13px; }
.timeline { list-style: none; margin: 0; padding: 0 0 0 14px; border-left: 2px solid var(--line); display: grid; gap: 12px; }
.timeline li { position: relative; font-size: 13px; }
.timeline li::before { content: ''; position: absolute; left: -20px; top: 5px; width: 10px; height: 10px; border-radius: 50%; background: #cbd2da; border: 2px solid #fff; }
.timeline li.tl-etapa::before { background: var(--s1); }
.timeline li.tl-bot::before { background: var(--violet); }
.timeline li.tl-llamada::before, .timeline li.tl-whatsapp::before { background: var(--accent); }
.timeline small { display: block; color: var(--muted); margin-top: 2px; }

/* ---------- Integración ---------- */
.steps { margin: 0; padding: 0 0 0 22px; display: grid; gap: 22px; }
.steps li::marker { font-weight: 800; color: var(--accent); }
.steps h3 { margin-bottom: 4px; }
.snippet { border: 1px solid var(--line); border-radius: 10px; background: #fff; margin-top: 10px; }
.snippet-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px 12px; }
.snippet-head p { margin: 2px 0 0; }
.api-ref h4 { margin-top: 16px; font-family: var(--mono); font-size: 13px; color: var(--accent-2); }

/* ---------- Responsivo ---------- */
@media (max-width: 1180px) {
  .inbox { grid-template-columns: 300px 1fr; }
  .contact-panel { position: fixed; right: 0; top: 0; bottom: 0; width: 320px; z-index: 30; box-shadow: var(--shadow-lg); transform: translateX(100%); transition: transform .18s; }
  .inbox.panel-open .contact-panel { transform: none; }
  .contact-panel header .icon-btn { display: inline-grid; }
  .grid-3 { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 860px) {
  body.app { grid-template-columns: 1fr; }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: 250px; z-index: 35; transform: translateX(-100%); transition: transform .18s; }
  body.nav-open .sidebar { transform: none; box-shadow: var(--shadow-lg); }
  .mobile-menu { display: inline-grid; position: fixed; top: 10px; left: 10px; z-index: 34; background: #fff; box-shadow: var(--shadow); }
  .page { padding: 58px 16px 30px; }
  .grid-2, .grid-3, .grid-form, .auth-wrap { grid-template-columns: 1fr; }
  .auth-side { display: none; }
  .auth-card { padding: 36px 24px; }
  .inbox { grid-template-columns: 1fr; }
  .inbox-list header { padding-top: 56px; }
  .inbox .chat { display: none; }
  .inbox.show-chat .inbox-list { display: none; }
  .inbox.show-chat .chat { display: flex; }
  .chat-head .back { display: inline-grid; }
  .chat-actions .btn span { display: none; }
  .msgs { padding: 12px; }
  .msg { max-width: 88%; }
  .head-actions .search input { width: 100%; }
  .facts { grid-template-columns: 1fr; gap: 2px; }
  .facts dd { margin-bottom: 8px; }
  .inbox.show-chat ~ .mobile-menu, body:has(.show-chat) .mobile-menu { display: none; }
}
#d-del { justify-self: start; }
