:root { --navy: #0A2A5E; --azul: #0E4AA4; --nar: #F58220; --verde: #146C43; --rojo: #B42318; --fondo: #F3F6FB; --borde: #E1E7F0; --txt: #15233D; --sub: #5B6B86; --burbuja: #DCF3E4; }
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { font-family: 'Plus Jakarta Sans', system-ui, sans-serif; color: var(--txt); background: var(--fondo); font-size: 14px; }
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 40px; padding: 0 16px; border-radius: 10px; border: 1px solid var(--borde); background: #fff; color: var(--navy); font-weight: 700; cursor: pointer; }
.btn.pri { background: var(--nar); border-color: var(--nar); color: var(--navy); }
.btn.azul { background: var(--azul); border-color: var(--azul); color: #fff; }
.btn.sec { background: #fff; }
.btn.ancho { width: 100%; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.ico { width: 38px; height: 38px; border-radius: 10px; border: 0; background: transparent; color: var(--sub); cursor: pointer; display: inline-flex; align-items: center; justify-content: center; font-size: 16px; flex: none; }
.ico:hover { background: rgba(10,42,94,.07); color: var(--navy); }
.av { width: 40px; height: 40px; border-radius: 50%; background: var(--navy); color: #fff; font-weight: 800; display: inline-flex; align-items: center; justify-content: center; flex: none; font-size: 14px; }

/* Login */
.login { min-height: 100%; display: flex; align-items: center; justify-content: center; padding: 20px; background: linear-gradient(135deg, var(--navy), var(--azul)); }
.login-box { width: 100%; max-width: 380px; background: #fff; border-radius: 20px; padding: 30px 26px; box-shadow: 0 20px 50px rgba(0,0,0,.25); display: flex; flex-direction: column; gap: 14px; }
.login-logo { width: 64px; height: 64px; border-radius: 18px; background: #25D366; color: #fff; display: flex; align-items: center; justify-content: center; font-size: 36px; margin: 0 auto; }
.login-box h1 { margin: 0; text-align: center; font-size: 24px; color: var(--navy); }
.login-box p { margin: -6px 0 6px; text-align: center; color: var(--sub); }
label { display: flex; flex-direction: column; gap: 5px; font-size: 12px; font-weight: 700; color: var(--sub); }
label input, label textarea, label select { min-height: 42px; padding: 9px 12px; border: 1px solid #CBD5E3; border-radius: 10px; background: #fff; font-size: 14px; font-weight: 500; color: var(--txt); }
label input:focus, label textarea:focus, textarea:focus, input:focus, select:focus { outline: none; border-color: var(--azul); box-shadow: 0 0 0 3px rgba(14,74,164,.15); }
.login-err { color: var(--rojo); text-align: center; min-height: 18px; font-weight: 600; }

/* Estructura */
.app { display: grid; grid-template-columns: 360px 1fr; height: 100vh; height: 100dvh; }
.app.con-info { grid-template-columns: 360px 1fr 320px; }
.lista { background: #fff; border-right: 1px solid var(--borde); display: flex; flex-direction: column; min-height: 0; }
.lista-h { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 12px 12px; background: var(--navy); color: #fff; }
.lista-h .yo { display: flex; align-items: center; gap: 10px; min-width: 0; }
.lista-h .yo .av { background: var(--nar); color: var(--navy); }
.lista-h .yo b { display: block; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lista-h .yo small { display: block; font-size: 12px; color: #C7D4EE; }
.lista-h .ico { color: #C7D4EE; }
.lista-h .ico:hover { background: rgba(255,255,255,.12); color: #fff; }
#bDisp.on i { color: #34D399; }
#bDisp i { color: #94A3B8; font-size: 12px; }
.lista-acc { display: flex; gap: 2px; }
.aviso-conf { margin: 10px 12px 0; padding: 10px 12px; border-radius: 10px; background: #FFF4E5; color: #8A4B00; font-size: 13px; }
.aviso-conf a { color: var(--azul); font-weight: 700; }
.filtros { display: flex; gap: 6px; padding: 10px 12px 0; overflow-x: auto; }
.filtros button { border: 1px solid var(--borde); background: #fff; border-radius: 99px; padding: 6px 12px; font-size: 13px; font-weight: 700; color: var(--sub); cursor: pointer; white-space: nowrap; display: inline-flex; gap: 6px; align-items: center; }
.filtros button.on { background: var(--navy); border-color: var(--navy); color: #fff; }
.filtros em { font-style: normal; background: var(--nar); color: var(--navy); border-radius: 99px; padding: 0 6px; font-size: 11px; }
.buscar { margin: 10px 12px; position: relative; }
.buscar i { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--sub); font-size: 13px; }
.buscar input { width: 100%; min-height: 40px; padding: 8px 12px 8px 34px; border: 1px solid var(--borde); border-radius: 10px; background: var(--fondo); }
.convs { list-style: none; margin: 0; padding: 0; overflow-y: auto; flex: 1; }
.convs li { display: flex; gap: 10px; padding: 12px; border-bottom: 1px solid #F0F3F8; cursor: pointer; align-items: center; }
.convs li:hover { background: #F7F9FC; }
.convs li.sel { background: #EAF1FC; }
.convs .tx { flex: 1; min-width: 0; }
.convs .l1 { display: flex; justify-content: space-between; gap: 8px; }
.convs .l1 b { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--navy); }
.convs .l1 time { font-size: 11px; color: var(--sub); white-space: nowrap; }
.convs .l2 { display: flex; justify-content: space-between; gap: 8px; align-items: center; margin-top: 2px; }
.convs .l2 span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--sub); font-size: 13px; }
.convs .nl { background: #25D366; color: #fff; border-radius: 99px; min-width: 20px; height: 20px; padding: 0 6px; font-size: 11px; font-weight: 800; display: inline-flex; align-items: center; justify-content: center; }
.convs .asesor { font-size: 11px; color: var(--azul); font-weight: 700; margin-top: 2px; display: block; }
.convs .vacia { padding: 30px 16px; text-align: center; color: var(--sub); cursor: default; display: block; }

.chat { display: flex; flex-direction: column; min-width: 0; min-height: 0; background: #EFEAE2; }
.vacio { margin: auto; text-align: center; color: var(--sub); padding: 20px; }
.vacio i { font-size: 64px; color: #25D366; }
.vacio h2 { color: var(--navy); margin: 10px 0 6px; }
.chat-in { display: flex; flex-direction: column; height: 100%; min-height: 0; }
.chat-h { display: flex; align-items: center; gap: 10px; padding: 10px 14px; background: #fff; border-bottom: 1px solid var(--borde); }
.chat-t { flex: 1; min-width: 0; cursor: pointer; }
.chat-t b { display: block; color: var(--navy); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-t small { display: block; color: var(--sub); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-acc { display: flex; gap: 4px; align-items: center; }
.chat-acc select { min-height: 36px; border: 1px solid var(--borde); border-radius: 9px; padding: 0 8px; background: #fff; max-width: 190px; font-size: 13px; font-weight: 600; color: var(--navy); }
.msgs { flex: 1; overflow-y: auto; padding: 16px 6%; display: flex; flex-direction: column; gap: 4px; }
.dia { align-self: center; background: #fff; color: var(--sub); font-size: 12px; font-weight: 700; padding: 4px 12px; border-radius: 8px; margin: 10px 0 6px; box-shadow: 0 1px 1px rgba(0,0,0,.06); }
.msg { max-width: 72%; padding: 7px 10px 6px; border-radius: 10px; background: #fff; box-shadow: 0 1px 1px rgba(0,0,0,.08); position: relative; word-wrap: break-word; overflow-wrap: anywhere; white-space: pre-wrap; line-height: 1.45; }
.msg.in { align-self: flex-start; border-top-left-radius: 2px; }
.msg.out { align-self: flex-end; background: var(--burbuja); border-top-right-radius: 2px; }
.msg.sys { align-self: center; background: #FFF4D6; color: #6B4B00; font-size: 12px; box-shadow: none; max-width: 90%; text-align: center; }
.msg .meta { display: flex; justify-content: flex-end; align-items: center; gap: 5px; font-size: 11px; color: #667085; margin-top: 3px; white-space: nowrap; }
.msg .por { font-size: 11px; font-weight: 700; color: var(--azul); margin-bottom: 2px; display: block; white-space: normal; }
.msg .por.cel { color: var(--verde); }
.msg .tick.read { color: #34B7F1; }
.msg .tick.failed { color: var(--rojo); }
.msg .err { display: block; font-size: 12px; color: var(--rojo); margin-top: 4px; white-space: normal; }
.msg img.media { display: block; max-width: 280px; max-height: 320px; border-radius: 8px; margin-bottom: 4px; cursor: zoom-in; background: #f2f2f2; }
.msg video, .msg audio { max-width: 280px; display: block; margin-bottom: 4px; }
.msg a.doc { display: flex; align-items: center; gap: 10px; padding: 10px; border-radius: 8px; background: rgba(0,0,0,.05); color: var(--navy); text-decoration: none; font-weight: 700; margin-bottom: 4px; white-space: normal; }
.msg a.doc i { font-size: 22px; color: var(--rojo); }
.msg a { color: var(--azul); }
.ventana { background: #FFF4E5; color: #8A4B00; padding: 10px 14px; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; font-size: 13px; border-top: 1px solid #F5D9B5; }
.ventana .btn { min-height: 34px; }
.compo { display: flex; align-items: flex-end; gap: 6px; padding: 10px 12px; background: #F0F2F5; }
.compo textarea { flex: 1; resize: none; max-height: 140px; min-height: 42px; border: 0; border-radius: 12px; padding: 11px 14px; background: #fff; line-height: 1.4; }
.compo .enviar { width: 44px; height: 44px; border-radius: 50%; border: 0; background: #25D366; color: #fff; font-size: 17px; cursor: pointer; flex: none; }
.compo .enviar:disabled { background: #A7B4C6; }

.info { background: #fff; border-left: 1px solid var(--borde); display: flex; flex-direction: column; min-height: 0; }
.info header { display: flex; justify-content: space-between; align-items: center; padding: 14px 16px; border-bottom: 1px solid var(--borde); color: var(--navy); }
.info-b { padding: 16px; display: flex; flex-direction: column; gap: 12px; overflow-y: auto; }

.modal { position: fixed; inset: 0; background: rgba(10,22,46,.55); display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 50; }
.modal-box { width: 100%; max-width: 640px; max-height: calc(100vh - 32px); background: #fff; border-radius: 16px; display: flex; flex-direction: column; overflow: hidden; }
.modal-box header { display: flex; justify-content: space-between; align-items: center; padding: 14px 18px; border-bottom: 1px solid var(--borde); color: var(--navy); font-size: 16px; }
.modal-b { padding: 18px; overflow-y: auto; display: flex; flex-direction: column; gap: 12px; }
.modal-box footer { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 18px; border-top: 1px solid var(--borde); flex-wrap: wrap; }
.modal-box footer:empty { display: none; }
.tabs { display: flex; gap: 6px; flex-wrap: wrap; }
.tabs button { border: 1px solid var(--borde); background: #fff; border-radius: 99px; padding: 6px 14px; font-weight: 700; color: var(--sub); cursor: pointer; }
.tabs button.on { background: var(--navy); color: #fff; border-color: var(--navy); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.caja { background: var(--fondo); border-radius: 12px; padding: 12px 14px; font-size: 13px; line-height: 1.5; }
.caja code { background: #fff; border: 1px solid var(--borde); border-radius: 6px; padding: 2px 6px; font-size: 12px; word-break: break-all; }
.copiar { display: flex; gap: 6px; }
.copiar input { flex: 1; }
.fila-ag { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid #F0F3F8; }
.fila-ag .tx { flex: 1; }
.fila-ag small { display: block; color: var(--sub); }
.sw { position: relative; width: 46px; height: 26px; flex: none; }
.sw input { opacity: 0; width: 0; height: 0; }
.sw span { position: absolute; inset: 0; background: #CBD5E3; border-radius: 99px; cursor: pointer; transition: .2s; }
.sw span::before { content: ''; position: absolute; width: 20px; height: 20px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: .2s; }
.sw input:checked + span { background: #25D366; }
.sw input:checked + span::before { transform: translateX(20px); }
.ok-t { color: var(--verde); font-weight: 700; }
.err-t { color: var(--rojo); font-weight: 700; }
.evento { font-size: 12px; border-bottom: 1px solid #F0F3F8; padding: 6px 0; word-break: break-all; }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(20px); background: var(--navy); color: #fff; padding: 12px 18px; border-radius: 12px; font-weight: 600; opacity: 0; pointer-events: none; transition: .25s; z-index: 60; max-width: calc(100vw - 32px); }
.toast.on { opacity: 1; transform: translateX(-50%); }
.toast.error { background: var(--rojo); }
.solo-movil { display: none; }
.ver-img { position: fixed; inset: 0; background: rgba(0,0,0,.85); display: flex; align-items: center; justify-content: center; z-index: 70; cursor: zoom-out; }
.ver-img img { max-width: 94vw; max-height: 94vh; border-radius: 8px; }

@media (max-width: 1100px) { .app.con-info { grid-template-columns: 320px 1fr; } .app.con-info .info { position: fixed; right: 0; top: 0; bottom: 0; width: min(340px, 100vw); z-index: 40; box-shadow: -10px 0 30px rgba(0,0,0,.15); } }
@media (max-width: 760px) {
  .app, .app.con-info { grid-template-columns: 1fr; }
  .app .chat { display: none; }
  .app.en-chat .lista { display: none; }
  .app.en-chat .chat { display: flex; }
  .solo-movil { display: inline-flex; }
  .msgs { padding: 12px 10px; }
  .msg { max-width: 86%; }
  .chat-acc select { max-width: 110px; }
  .grid2 { grid-template-columns: 1fr; }
}
