:root {
  --navy: #1f3655; --navy-2: #2c3f5f; --navy-3: #16283f;
  --pink: #ff006a; --cyan: #1db3c2; --orange: #fe5b00;
  --bg: #f3f5f9; --card: #fff; --line: #e3e8ef; --text: #1b2a3d; --muted: #6b7a90;
  --ok: #17a95b; --warn: #f5a524; --err: #e5484d;
  --r: 12px; --shadow: 0 1px 2px rgba(16,32,56,.06), 0 4px 16px rgba(16,32,56,.06);
  font-family: 'Montserrat', system-ui, -apple-system, 'Segoe UI', sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font-size: 14px; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--cyan); }
.hidden { display: none !important; }

/* ---------- Login ---------- */
.login { min-height: 100vh; display: grid; place-items: center; background: url(img/bg.svg) center/cover; padding: 20px; }
.login-card { width: min(400px, 100%); background: rgba(255,255,255,.97); border-radius: 18px; padding: 34px 30px; box-shadow: 0 20px 60px rgba(0,0,0,.25); }
.login-card .logo-navy { width: 220px; height: 50px; margin: 0 auto 6px; }
.login-card p.sub { text-align: center; color: var(--muted); margin: 0 0 22px; }

/* ---------- Layout ---------- */
.app { display: grid; grid-template-columns: 230px 1fr; height: 100vh; }
.side { background: var(--navy); color: #fff; display: flex; flex-direction: column; padding: 18px 12px; position: relative; overflow: hidden; }
.side::after { content: ''; position: absolute; left: -60px; bottom: -60px; width: 220px; height: 220px; background: linear-gradient(135deg, var(--pink) 0 50%, var(--orange) 50%); transform: rotate(45deg); opacity: .9; pointer-events: none; }
.side .brand { padding: 4px 8px 22px; }
.side .brand img { width: 170px; display: block; }
.nav { display: flex; flex-direction: column; gap: 3px; position: relative; z-index: 1; }
.nav a { display: flex; align-items: center; gap: 11px; padding: 10px 12px; border-radius: 10px; color: #c9d4e4; text-decoration: none; font-weight: 600; font-size: 13.5px; }
.nav a:hover { background: var(--navy-2); color: #fff; }
.nav a.on { background: #fff; color: var(--navy); }
.nav a .ico { width: 20px; text-align: center; font-size: 16px; }
.nav a .badge { margin-left: auto; }
.side .me { margin-top: auto; position: relative; z-index: 1; padding: 10px; background: rgba(0,0,0,.22); border-radius: 10px; font-size: 12.5px; backdrop-filter: blur(4px); }
.side .me b { display: block; }
.side .me button { background: none; border: 0; color: #fff; text-decoration: underline; cursor: pointer; padding: 0; margin-top: 4px; font-size: 12px; }
.main { overflow: auto; min-width: 0; }
.page { padding: 24px 28px; }
.page-head { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head h1 { font-size: 22px; margin: 0; font-weight: 800; color: var(--navy); }
.page-head .grow { flex: 1; }
.accent { display: inline-block; width: 26px; height: 5px; border-radius: 3px; background: linear-gradient(90deg, var(--pink), var(--orange)); margin-right: 8px; vertical-align: middle; }

/* ---------- Controles ---------- */
.btn { border: 0; border-radius: 10px; padding: 9px 15px; font-weight: 700; cursor: pointer; background: var(--navy); color: #fff; display: inline-flex; align-items: center; gap: 7px; white-space: nowrap; }
.btn:hover { filter: brightness(1.1); }
.btn.pink { background: var(--pink); } .btn.cyan { background: var(--cyan); } .btn.orange { background: var(--orange); }
.btn.ghost { background: #fff; color: var(--navy); border: 1px solid var(--line); }
.btn.sm { padding: 6px 10px; font-size: 12.5px; border-radius: 8px; }
.btn:disabled { opacity: .55; cursor: default; }
.input, select.input, textarea.input { width: 100%; border: 1px solid var(--line); border-radius: 10px; padding: 9px 12px; background: #fff; outline: none; }
.input:focus { border-color: var(--cyan); box-shadow: 0 0 0 3px rgba(29,179,194,.18); }
textarea.input { resize: vertical; min-height: 80px; line-height: 1.45; }
label.f { display: block; font-size: 12px; font-weight: 700; color: var(--muted); margin: 12px 0 5px; text-transform: uppercase; letter-spacing: .03em; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
.card { background: var(--card); border-radius: var(--r); box-shadow: var(--shadow); padding: 18px; }
.badge { display: inline-block; min-width: 20px; padding: 1px 7px; border-radius: 20px; font-size: 11px; font-weight: 800; background: var(--pink); color: #fff; text-align: center; }
.badge.gray { background: #e8edf3; color: var(--muted); }
.chip { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 20px; font-size: 11px; font-weight: 700; background: #eef2f7; color: var(--navy); }
.chip.ai { background: rgba(29,179,194,.14); color: #0e7e8a; }
.chip.human { background: rgba(255,0,106,.12); color: var(--pink); }
.muted { color: var(--muted); }
.err { color: var(--err); font-size: 13px; margin-top: 8px; }
.empty { text-align: center; color: var(--muted); padding: 40px 10px; }
.tabs { display: inline-flex; background: #e8edf3; border-radius: 10px; padding: 3px; gap: 2px; }
.tabs button { border: 0; background: none; padding: 6px 12px; border-radius: 8px; font-weight: 700; cursor: pointer; color: var(--muted); font-size: 12.5px; }
.tabs button.on { background: #fff; color: var(--navy); box-shadow: var(--shadow); }
table.t { width: 100%; border-collapse: collapse; }
table.t th { text-align: left; font-size: 11.5px; text-transform: uppercase; color: var(--muted); padding: 10px; border-bottom: 1px solid var(--line); letter-spacing: .03em; }
table.t td { padding: 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.t tr.click { cursor: pointer; } table.t tr.click:hover td { background: #f8fafc; }
.src { font-size: 15px; }
.switch { position: relative; display: inline-block; width: 38px; height: 22px; flex: none; }
.switch input { display: none; }
.switch span { position: absolute; inset: 0; background: #cfd7e2; border-radius: 22px; cursor: pointer; transition: .2s; }
.switch span::before { content: ''; position: absolute; width: 16px; height: 16px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: .2s; }
.switch input:checked + span { background: var(--cyan); }
.switch input:checked + span::before { transform: translateX(16px); }

/* ---------- Bandeja ---------- */
.inbox { display: grid; grid-template-columns: 330px 1fr 300px; height: 100vh; }
.inbox .list { border-right: 1px solid var(--line); background: #fff; display: flex; flex-direction: column; min-height: 0; }
.inbox .list-head { padding: 16px 14px 10px; border-bottom: 1px solid var(--line); }
.inbox .list-head h2 { margin: 0 0 10px; font-size: 18px; color: var(--navy); }
.filters { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; }
.filters button { border: 1px solid var(--line); background: #fff; border-radius: 20px; padding: 4px 10px; font-size: 12px; font-weight: 700; cursor: pointer; color: var(--muted); }
.filters button.on { background: var(--navy); color: #fff; border-color: var(--navy); }
.convs { overflow: auto; flex: 1; }
.conv { display: flex; gap: 10px; padding: 12px 14px; border-bottom: 1px solid #f0f3f7; cursor: pointer; }
.conv:hover { background: #f8fafc; } .conv.on { background: #eaf7f9; border-left: 3px solid var(--cyan); padding-left: 11px; }
.avatar { width: 40px; height: 40px; border-radius: 50%; flex: none; display: grid; place-items: center; font-weight: 800; color: #fff; background: var(--navy); font-size: 15px; position: relative; }
.avatar .s { position: absolute; right: -3px; bottom: -3px; font-size: 13px; background: #fff; border-radius: 50%; width: 19px; height: 19px; display: grid; place-items: center; box-shadow: var(--shadow); }
.conv .info { flex: 1; min-width: 0; }
.conv .top { display: flex; gap: 6px; align-items: baseline; }
.conv .name { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1; }
.conv .time { font-size: 11px; color: var(--muted); }
.conv .last { color: var(--muted); font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin: 2px 0 4px; }
.chat { display: flex; flex-direction: column; min-height: 0; background: #eef1f5 url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='80' height='80'%3E%3Cpath d='M0 80L80 0' stroke='%23e2e7ee' stroke-width='1'/%3E%3C/svg%3E"); }
.chat-head { background: #fff; padding: 12px 18px; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 12px; }
.chat-head .who { flex: 1; min-width: 0; }
.chat-head .who b { display: block; font-size: 15px; }
.agent-toggle { display: flex; align-items: center; gap: 8px; font-size: 12.5px; font-weight: 700; background: #f3f6fa; padding: 6px 10px; border-radius: 10px; }
.msgs { flex: 1; overflow: auto; padding: 18px 22px; display: flex; flex-direction: column; gap: 6px; }
.msg { max-width: 68%; padding: 8px 12px 6px; border-radius: 12px; line-height: 1.42; white-space: pre-wrap; word-wrap: break-word; box-shadow: 0 1px 1px rgba(0,0,0,.05); }
.msg.in { background: #fff; align-self: flex-start; border-top-left-radius: 3px; }
.msg.out { background: #dff4f6; align-self: flex-end; border-top-right-radius: 3px; }
.msg.out.agente_ia { background: #e7f0ff; border: 1px solid #cfe0ff; }
.msg.sistema { align-self: center; background: #fff7e6; color: #8a5a00; font-size: 12.5px; max-width: 85%; text-align: center; }
.msg.error { background: #ffe9ea; }
.msg .meta { font-size: 10.5px; color: var(--muted); margin-top: 3px; text-align: right; }
.day-sep { align-self: center; font-size: 11px; background: #fff; padding: 3px 10px; border-radius: 10px; color: var(--muted); margin: 8px 0; }
.composer { background: #fff; padding: 10px 14px; border-top: 1px solid var(--line); }
.composer .row { display: flex; gap: 8px; align-items: flex-end; }
.composer textarea { flex: 1; min-height: 44px; max-height: 160px; resize: none; }
.composer .tools { display: flex; gap: 6px; margin-bottom: 8px; flex-wrap: wrap; }
.banner { padding: 9px 16px; font-size: 13px; font-weight: 600; display: flex; gap: 10px; align-items: center; }
.banner.human { background: rgba(255,0,106,.1); color: #b8004c; }
.side-panel { background: #fff; border-left: 1px solid var(--line); overflow: auto; padding: 16px; }
.side-panel h3 { font-size: 13px; text-transform: uppercase; color: var(--muted); margin: 18px 0 8px; letter-spacing: .04em; }
.side-panel h3:first-child { margin-top: 0; }
.kv { display: grid; grid-template-columns: 92px 1fr; gap: 6px 8px; font-size: 13px; }
.kv span:nth-child(odd) { color: var(--muted); }
.score { height: 7px; background: #e8edf3; border-radius: 6px; overflow: hidden; margin-top: 4px; }
.score i { display: block; height: 100%; background: linear-gradient(90deg, var(--cyan), var(--pink)); }
.nochat { display: grid; place-items: center; height: 100%; color: var(--muted); text-align: center; }
.nochat img { width: 90px; opacity: .25; margin-bottom: 10px; }

/* ---------- Embudo ---------- */
.board { display: flex; gap: 14px; overflow-x: auto; padding-bottom: 12px; align-items: flex-start; }
.col { background: #e9edf3; border-radius: var(--r); width: 270px; flex: none; display: flex; flex-direction: column; max-height: calc(100vh - 130px); }
.col-head { padding: 12px 14px 8px; font-weight: 800; display: flex; align-items: center; gap: 8px; color: var(--navy); }
.col-head .dot { width: 10px; height: 10px; border-radius: 50%; }
.col-head .sum { margin-left: auto; font-size: 11.5px; color: var(--muted); font-weight: 600; }
.col-body { padding: 4px 10px 12px; overflow: auto; flex: 1; min-height: 60px; display: flex; flex-direction: column; gap: 8px; }
.col.drop .col-body { background: rgba(29,179,194,.12); border-radius: 10px; }
.deal { background: #fff; border-radius: 10px; padding: 11px 12px; box-shadow: var(--shadow); cursor: grab; border-left: 4px solid var(--cyan); }
.deal b { display: block; margin-bottom: 2px; }
.deal .sm { font-size: 12px; color: var(--muted); }
.deal .foot { display: flex; justify-content: space-between; align-items: center; margin-top: 8px; font-size: 12px; }

/* ---------- Métricas ---------- */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; margin-bottom: 16px; }
.kpi { background: #fff; border-radius: var(--r); padding: 16px 18px; box-shadow: var(--shadow); position: relative; overflow: hidden; }
.kpi::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--c, var(--cyan)); }
.kpi .l { font-size: 12px; color: var(--muted); font-weight: 700; text-transform: uppercase; letter-spacing: .03em; }
.kpi .v { font-size: 28px; font-weight: 800; color: var(--navy); margin-top: 4px; }
.kpi .s { font-size: 12px; color: var(--muted); }
.charts { display: grid; grid-template-columns: 1.4fr 1fr; gap: 14px; }
.bars .bar { display: grid; grid-template-columns: 130px 1fr 60px; gap: 10px; align-items: center; margin: 9px 0; font-size: 13px; }
.bars .track { background: #eef2f7; border-radius: 6px; height: 14px; overflow: hidden; }
.bars .track i { display: block; height: 100%; border-radius: 6px; }
.spark { display: flex; align-items: flex-end; gap: 3px; height: 140px; padding-top: 10px; }
.spark div { flex: 1; background: var(--cyan); border-radius: 4px 4px 0 0; min-height: 2px; position: relative; }
.spark div:hover { background: var(--pink); }

/* ---------- Agente ---------- */
.agent-grid { display: grid; grid-template-columns: 1.2fr 1fr; gap: 16px; align-items: start; }
.kn { border: 1px solid var(--line); border-radius: 10px; padding: 11px 13px; margin-bottom: 8px; cursor: pointer; background: #fff; }
.kn:hover { border-color: var(--cyan); }
.kn .ttl { font-weight: 700; display: flex; gap: 8px; align-items: center; }
.kn .prev { color: var(--muted); font-size: 12.5px; margin-top: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kn.off { opacity: .5; }
.sim { display: flex; flex-direction: column; height: 560px; border-radius: var(--r); overflow: hidden; box-shadow: var(--shadow); }
.sim .sim-head { background: var(--navy); color: #fff; padding: 12px 16px; display: flex; align-items: center; gap: 10px; }
.sim .msgs { background: #eef1f5; }
.sim .composer { display: flex; gap: 8px; }
.sim-debug { font-size: 11.5px; background: #fff; border: 1px dashed var(--line); padding: 8px 10px; border-radius: 8px; color: var(--muted); align-self: stretch; white-space: pre-wrap; }

/* ---------- Modal / toast ---------- */
.modal-bg { position: fixed; inset: 0; background: rgba(15,28,46,.5); display: grid; place-items: center; z-index: 50; padding: 16px; }
.modal { background: #fff; border-radius: 16px; width: min(560px, 100%); max-height: 92vh; overflow: auto; padding: 22px 24px; box-shadow: 0 20px 60px rgba(0,0,0,.3); }
.modal h2 { margin: 0 0 6px; color: var(--navy); font-size: 19px; }
.modal .actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; }
.toasts { position: fixed; right: 18px; bottom: 18px; display: flex; flex-direction: column; gap: 8px; z-index: 60; }
.toast { background: var(--navy); color: #fff; padding: 11px 16px; border-radius: 10px; box-shadow: var(--shadow); font-weight: 600; max-width: 360px; border-left: 4px solid var(--cyan); animation: in .2s; }
.toast.err { border-left-color: var(--err); } .toast.pink { border-left-color: var(--pink); }
@keyframes in { from { transform: translateY(10px); opacity: 0; } }
.qr { text-align: center; } .qr img { width: 260px; height: 260px; border: 1px solid var(--line); border-radius: 12px; }
pre.code { background: var(--navy-3); color: #d8e3f2; padding: 12px; border-radius: 10px; overflow: auto; font-size: 12px; white-space: pre-wrap; word-break: break-all; }

@media (max-width: 1100px) { .inbox { grid-template-columns: 290px 1fr; } .inbox .side-panel { display: none; } .agent-grid, .charts { grid-template-columns: 1fr; } }
@media (max-width: 760px) {
  .app { grid-template-columns: 1fr; grid-template-rows: 1fr auto; }
  .side { order: 2; flex-direction: row; padding: 6px; } .side::after, .side .brand, .side .me { display: none; }
  .nav { flex-direction: row; justify-content: space-around; width: 100%; } .nav a { flex-direction: column; gap: 2px; font-size: 10px; padding: 6px; } .nav a .badge { display: none; }
  .inbox { grid-template-columns: 1fr; height: calc(100vh - 62px); } .inbox.has-chat .list { display: none; } .inbox:not(.has-chat) .chat { display: none; }
  .page { padding: 16px; } .grid2 { grid-template-columns: 1fr; } .msg { max-width: 86%; }
}
.agent-grid > *, .charts > * { min-width: 0; }
.side .me .muted { color: rgba(255,255,255,.75); }
.col { width: 255px; }
/* v2 */
.ticket { border: 1px solid var(--line); border-left: 4px solid var(--orange); border-radius: 10px; padding: 10px 12px; background: #fffaf5; font-size: 12.5px; }
.ticket.alta { border-left-color: var(--pink); background: #fff5f8; }
.ticket.baja { border-left-color: var(--cyan); background: #f4fbfc; }
.ticket b.h { display: block; font-size: 13px; margin-bottom: 4px; }
.ticket .row { margin: 3px 0; } .ticket .row span { color: var(--muted); }
.check { font-size: 12.5px; margin: 3px 0; } .check.ok { color: var(--ok); } .check.no { color: var(--muted); }
.prio { display:inline-block; padding: 1px 7px; border-radius: 20px; font-size: 10.5px; font-weight: 800; text-transform: uppercase; }
.prio.alta { background: var(--pink); color: #fff; } .prio.media { background: #ffe8d6; color: #b14400; } .prio.baja { background: #e3f6f8; color: #0e7e8a; }
.chip.k { background: #fff1d6; color: #8a5a00; } .chip.r { background: #efe9ff; color: #5b3fd1; } .chip.opt { background: #ffe9ea; color: var(--err); }
.tcard { background: #fff; border-radius: var(--r); box-shadow: var(--shadow); padding: 14px 16px; margin-bottom: 10px; display: grid; grid-template-columns: 1fr auto; gap: 8px 14px; }
.tcard .kv { grid-template-columns: 120px 1fr; }
.status-bar { display:flex; gap:10px; flex-wrap:wrap; font-size:12.5px; margin-bottom:12px; }
.status-bar span { background:#fff; border-radius:20px; padding:4px 10px; box-shadow: var(--shadow); }
.test { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; margin-bottom: 8px; background: #fff; }
.test .th { display: flex; gap: 8px; align-items: center; }
.test pre { white-space: pre-wrap; font-family: inherit; font-size: 12.5px; background: #f6f8fb; padding: 8px 10px; border-radius: 8px; margin: 8px 0 0; }
.verdict button { border: 1px solid var(--line); background: #fff; border-radius: 8px; padding: 3px 8px; cursor: pointer; font-size: 12px; font-weight: 700; }
.verdict button.on.pass { background: var(--ok); color: #fff; } .verdict button.on.fail { background: var(--orange); color: #fff; } .verdict button.on.critical { background: var(--err); color: #fff; }
.hours-grid { display:grid; grid-template-columns: 90px 1fr 1fr; gap:6px 10px; align-items:center; font-size:13px; }

.logo-navy { background: #1f3655; -webkit-mask: url(img/logo.webp) center/contain no-repeat; mask: url(img/logo.webp) center/contain no-repeat; }
.nochat .mark { width: 200px; height: 44px; margin: 0 auto 10px; opacity: .18; }
