:root{font-family:Segoe UI,Arial,sans-serif;color:#173831;background:#f4f7f5;font-size:14px}*{box-sizing:border-box}body{margin:0}header{height:88px;display:flex;align-items:center;gap:16px;padding:0 30px;background:white;border-bottom:1px solid #dde7e1}.brand{width:44px;height:44px;border-radius:14px;background:#17634f;color:white;font-size:32px;line-height:40px;text-align:center;font-weight:700}.brand span{font-size:15px}h1{font-size:25px;margin:0;letter-spacing:-1px}small,.muted{color:#72877e}header small{font-size:12px}.pilot{margin-left:auto;font-size:11px;font-weight:700;letter-spacing:1.5px;border:1px solid #cbded4;padding:10px 14px;border-radius:20px}.notice{padding:11px 30px;background:#fff5df;color:#7b642f;font-size:12px;border-bottom:1px solid #ecdfbd}main{display:grid;grid-template-columns:255px 330px 1fr;height:calc(100dvh - 127px);min-height:520px}aside{padding:25px 20px;border-right:1px solid #dce5e0}h2{font-size:16px;margin:0 0 10px}.muted{font-size:12px}.slot{margin:16px 0;padding:16px;background:white;border:1px solid #dae5df;border-radius:12px}.slot h3{font-size:14px;margin:0 0 10px}.status{display:block;font-size:12px;margin-bottom:12px;color:#687e73}.connected{color:#15805b}.slot img{width:100%;border-radius:8px}.slot .number{font-size:12px;display:block;margin-bottom:8px;overflow-wrap:anywhere}.slot .error{font-size:11px;color:#a74136;overflow-wrap:anywhere}button{border:0;border-radius:7px;background:#17634f;color:white;padding:11px 15px;cursor:pointer;font:inherit;font-weight:600}button:hover{background:#104c3d}button:disabled{opacity:.5;cursor:default}.secondary{background:#edf3ef;color:#486457;font-size:12px;margin-top:8px}.secondary:hover{background:#e1ebe5}.guide{font-size:12px;color:#74867d;line-height:1.6;margin-top:30px}.guide b{color:#456153}.inbox{background:white;border-right:1px solid #dce5e0;overflow:hidden;display:flex;flex-direction:column}.inbox-head{padding:26px 20px 18px}#count{font-size:12px;background:#ecf2ee;padding:3px 7px;border-radius:7px;margin-left:6px}input,select,textarea{font:inherit;border:1px solid #d9e3dc;border-radius:7px;padding:10px;background:#f8faf8;color:#173831}input,select{width:100%;margin-top:10px}select{font-size:12px}.chat-list{overflow:auto}.chat{border:0;border-radius:0;border-bottom:1px solid #eef2ef;background:white;color:#173831;display:block;text-align:left;width:100%;padding:17px 20px;font-weight:400}.chat:hover,.chat.selected{background:#eef6f0}.chat strong{display:block;font-size:14px}.chat p{font-size:12px;color:#7c8d83;margin:6px 0;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.chip{font-size:10px;color:#397760;background:#e2f0e7;padding:3px 6px;border-radius:4px}.unread{float:right;color:#17634f}.conversation{min-width:0;display:flex;flex-direction:column}#conversation-head{padding:25px 30px;border-bottom:1px solid #dce5e0;background:#fbfcfa;min-height:91px}#conversation-head p{margin:0}#messages{flex:1;overflow:auto;padding:25px 30px}.empty{text-align:center;margin:12vh auto 0;color:#84988c;font-size:13px;line-height:1.8;max-width:430px}.empty h2{color:#486b59;font-size:21px}.symbol{font-size:44px;color:#4f8468;margin-bottom:18px}.message{max-width:80%;width:fit-content;white-space:pre-wrap;overflow-wrap:anywhere;padding:12px 16px;background:white;border:1px solid #e0e8e1;border-radius:12px;margin:10px 0;color:#274d3a}.message.mine{margin-left:auto;background:#dcefe2;border-color:#d1e5d7}.message small{display:block;text-align:right;font-size:10px;margin-top:6px}#composer{padding:18px 26px;background:white;border-top:1px solid #dce5e0}#composer[hidden]{display:none}#sending-from{display:block;font-size:12px;margin-bottom:10px;color:#17634f}.compose-row{display:flex;gap:12px;margin-bottom:8px}textarea{flex:1;resize:vertical;min-width:0}.compose-row button{align-self:center}#feedback{position:fixed;bottom:15px;left:25px;max-width:520px;background:#713b30;color:white;border-radius:8px;padding:12px;box-shadow:0 3px 15px #0002}#feedback:empty{display:none}@media(max-width:1050px){main{grid-template-columns:210px 260px 1fr}.pilot{display:none}aside{padding:20px 12px}#messages{padding:15px}}@media(max-width:760px){main{display:block;height:auto}aside{display:flex;flex-wrap:wrap;gap:10px}aside>h2,aside>.muted,.guide{display:none}#slots{display:flex;gap:12px;width:100%}.slot{width:50%}.slot img{max-width:180px}.inbox{max-height:330px}.conversation{height:650px}.notice{padding:10px 20px}header{padding:0 20px}}
/* Fixed viewport shell: only the three content panes scroll. */
html,body{height:100%;overflow:hidden}
body{height:100dvh;display:flex;flex-direction:column}
header{flex:0 0 72px;height:72px}
.notice{flex:0 0 auto}
main{flex:1 1 0;min-height:0;height:auto;overflow:hidden;grid-template-columns:230px 300px minmax(0,1fr)}
main>aside,.inbox,.conversation{min-height:0;height:100%;overflow:hidden}
main>aside{display:block;overflow-y:auto}
.inbox-head,#conversation-head,#composer{flex:0 0 auto}
.chat-list,#messages{flex:1 1 0;min-height:0;overflow-y:auto;overscroll-behavior:contain}
#conversation-head{min-height:0;padding:16px 22px;overflow-wrap:anywhere}
#messages{padding:16px 22px}
#composer{padding:12px 18px}
#composer textarea{resize:none;max-height:110px;min-height:58px;background:white}
#composer small{font-size:10px}
#feedback{bottom:auto;top:76px;left:auto;right:12px;max-width:min(450px,90vw);z-index:10;pointer-events:none}
.panel-nav{display:none;flex:0 0 auto;padding:6px 10px;gap:6px;background:white;border-bottom:1px solid #dce5e0}
.panel-nav button{padding:8px 10px;background:#edf3ef;color:#486457;font-size:12px}
.view-numbers [data-view=numbers],.view-inbox [data-view=inbox],.view-chat [data-view=chat]{background:#17634f;color:white}
@media(max-width:1150px){
 .panel-nav{display:flex}.pilot{display:none}
 main{display:grid;grid-template-columns:310px minmax(0,1fr)}
 main>aside{display:none}
 body.view-numbers main{grid-template-columns:1fr}
 body.view-numbers main>aside{display:block}
 body.view-numbers .inbox,body.view-numbers .conversation{display:none}
 #slots{display:flex;gap:12px;flex-wrap:wrap}.slot{width:250px;max-width:100%}.slot img{max-width:220px}
 aside>h2,aside>.muted,.guide{display:block}.guide{max-width:500px}
}
@media(max-width:800px){
 header{flex-basis:52px;height:52px;padding:0 14px;gap:10px}.brand{width:32px;height:32px;font-size:24px;line-height:30px;border-radius:9px}h1{font-size:20px}header small{display:none}
 .notice{font-size:10px;padding:6px 14px;line-height:1.35}
 main{display:flex;min-height:0;height:auto}
 main>.inbox,main>.conversation{width:100%;max-height:none;height:100%}
 main>.conversation{display:none}
 body.view-chat main>.conversation{display:flex}
 body.view-chat main>.inbox{display:none}
 body.view-numbers main>aside{width:100%;height:100%;display:block;overflow:auto}
 .inbox-head{padding:12px 16px}.inbox-head h2{margin-bottom:0}
 #conversation-head{padding:10px 14px}#conversation-head h2{margin-bottom:4px;font-size:14px}
 #conversation-head p{font-size:10px}
 #messages{padding:10px 14px}.message{max-width:90%;font-size:13px}
 #composer{padding:9px 12px;padding-bottom:max(9px,env(safe-area-inset-bottom))}
 #sending-from{font-size:11px;margin-bottom:6px}.compose-row{gap:8px;margin-bottom:4px}
 .compose-row button{padding:12px}#composer small{display:none}
 .empty{margin:5vh auto 0;padding:0 12px}
}
@media(max-height:500px){header{display:none}.notice{display:none}#conversation-head{padding:7px 12px}#composer{padding:6px 12px}#composer textarea{min-height:44px;height:44px}.panel-nav{padding:4px 10px}}
#composer .keyboard-help{display:block;font-size:11px;color:#557365}
.chat{position:relative;padding-right:38px}.pending-dot{position:absolute;right:15px;top:20px;width:11px;height:11px;background:#25d366;border-radius:50%;box-shadow:0 0 0 2px #fff}
.receipt-duplicate{white-space:normal;margin-top:8px;padding:8px;border-radius:6px;background:#fff0c4;color:#795214;font-size:12px;font-weight:600}.receipt-unavailable{font-size:10px;color:#7b817d;margin-top:5px}
.toolbar{display:flex;gap:6px;align-items:center;flex:0 0 auto;padding:5px 12px;background:white;border-bottom:1px solid #dce5e0;overflow-x:auto}.toolbar button{font-size:11px;padding:7px 10px;white-space:nowrap}.toolbar #who{font-size:11px;margin-right:auto}.alerts{flex:0 0 auto;max-height:58px;overflow-y:auto;font-size:11px;background:#fff0ce;color:#78541b}.alerts div:empty{display:none}.alerts div:not(:empty){padding:5px 14px}.inbox-options{padding:0 14px 10px;flex:0 0 auto}.inbox-options label{display:flex;align-items:center;font-size:12px;gap:7px}.inbox-options input{width:auto;margin:0}.inbox-options select{margin-top:5px;padding:6px}.chat-tag{display:block;font-size:10px;color:#6b5f82;margin-top:7px}#quick-reply{margin:0 0 6px;padding:6px;font-size:11px}#conversation-head select{width:auto;max-width:100%;padding:4px;font-size:11px;margin:6px 0 0}.backup-link{display:block;font-size:12px;color:#17634f;margin:12px 0}dialog{color:#173831;border:1px solid #d6e3d9;border-radius:12px;padding:24px;width:min(620px,94vw);max-height:88dvh;overflow:auto}dialog::backdrop{background:#17383199}dialog label{display:block;margin:12px 0}dialog button{margin:5px 4px 5px 0}dialog h2{margin:18px 0 8px}dialog table{width:100%;border-collapse:collapse;font-size:13px}dialog td,dialog th{text-align:left;padding:9px;border-bottom:1px solid #d6e3d9}.reply-editor{border:1px solid #d6e3d9;border-radius:8px;padding:10px;margin:10px 0}.reply-editor textarea{display:block;width:100%;margin-top:8px;min-height:70px}#auth-error{color:#a74136;font-size:13px}.operator .slot button{display:none}#manage[hidden]{display:none}
@media(max-height:650px){#composer{padding:7px 12px}#composer textarea{min-height:44px;height:44px}#conversation-head{padding:6px 12px}.inbox-head{padding:10px 14px}.toolbar{padding:3px 8px}.alerts{max-height:38px}.keyboard-help{font-size:10px!important}#quick-reply{padding:3px;margin-bottom:3px}}

/* Recordatorio discreto, separado de los errores de conexión. */
.alerts{background:transparent;color:inherit}.alerts #line-alert:not(:empty){background:#fff0ce;color:#78541b}.alerts #reply-alert:not(:empty){display:inline-block;margin:4px 12px;padding:3px 9px;border-radius:12px;background:#eef3f1;color:#52665e;font-size:11px;line-height:16px}


.chat-time{float:right;font-size:10px;color:#65786f;margin:0 0 6px 10px}.chat strong{display:block;overflow-wrap:anywhere}.log-scroll{max-height:55vh;overflow:auto}#attention-open[hidden]{display:none}#attention-dialog{width:min(880px,94vw)}

#line-alert:not(:empty){font-weight:600}.connection-details{font-size:11px;margin:8px 0;overflow-wrap:anywhere}.connection-details summary{cursor:pointer;color:#63776e}

#alias-editor{display:flex;align-items:center;gap:8px;flex-wrap:wrap;margin-top:8px}#alias-editor input{width:200px;max-width:100%;margin:0;padding:6px}#alias-editor button{font-size:12px;padding:7px}#alias-editor small{flex-basis:100%;font-size:11px}
.chat-image{display:block;max-width:100%;max-height:320px;object-fit:contain;border-radius:8px;margin:8px 0}.image-viewer{max-width:94vw;max-height:94vh;padding:16px;border:0;border-radius:12px;overflow:auto}.image-viewer img{display:block;max-width:100%;height:auto;margin-top:12px}.image-viewer a{margin-left:18px}.image-viewer::backdrop{background:#000a}.image-error{color:#9a2b25;font-size:13px}
.chat-pdf{display:block;width:min(560px,70vw);height:520px;max-width:100%;border:1px solid #ddd;border-radius:8px;margin:8px 0}
/* Tema nocturno: conserva fotos, comprobantes y códigos QR originales. */
:root[data-theme=dark]{color-scheme:dark;background:#111b21;color:#e1ebe7}
[data-theme=dark] header,[data-theme=dark] .toolbar,[data-theme=dark] .panel-nav,[data-theme=dark] .inbox,[data-theme=dark] #composer,[data-theme=dark] #conversation-head,[data-theme=dark] dialog{background:#18262c;color:#e1ebe7;border-color:#35474d}
[data-theme=dark] aside{border-color:#35474d}
[data-theme=dark] .slot,[data-theme=dark] .message{background:#202f36;color:#e1ebe7;border-color:#3a4d52}
[data-theme=dark] .message.mine{background:#174c40;border-color:#286354}
[data-theme=dark] .chat{background:#18262c;color:#e1ebe7;border-color:#2b3d43}
[data-theme=dark] .chat:hover,[data-theme=dark] .chat.selected{background:#29443f}
[data-theme=dark] input,[data-theme=dark] select,[data-theme=dark] textarea,[data-theme=dark] #composer textarea{background:#111e24;color:#e1ebe7;border-color:#496058}
[data-theme=dark] input::placeholder,[data-theme=dark] textarea::placeholder{color:#9cafaa}
[data-theme=dark] small,[data-theme=dark] .muted,[data-theme=dark] .status,[data-theme=dark] .chat p,[data-theme=dark] .chat-time,[data-theme=dark] .guide,[data-theme=dark] .connection-details summary,[data-theme=dark] .receipt-unavailable,[data-theme=dark] #composer .keyboard-help{color:#afc1b9}
[data-theme=dark] .connected,[data-theme=dark] #sending-from,[data-theme=dark] .unread,[data-theme=dark] a{color:#86dabb}
[data-theme=dark] button{background:#226e57;color:#fff}
[data-theme=dark] button:hover{background:#2a8067}
[data-theme=dark] .secondary,[data-theme=dark] .panel-nav button{background:#30463f;color:#d5e8df}
[data-theme=dark] .secondary:hover{background:#3b574d}
[data-theme=dark] .view-numbers [data-view=numbers],[data-theme=dark] .view-inbox [data-view=inbox],[data-theme=dark] .view-chat [data-view=chat]{background:#226e57;color:#fff}
[data-theme=dark] .notice,[data-theme=dark] .alerts #line-alert:not(:empty),[data-theme=dark] .receipt-duplicate{background:#3a3220;color:#edd69e;border-color:#5b4e2d}
[data-theme=dark] #count,[data-theme=dark] .chip,[data-theme=dark] .alerts #reply-alert:not(:empty){background:#294239;color:#c2dccf}
[data-theme=dark] .chat-tag{color:#d0bce9}
[data-theme=dark] .slot .error,[data-theme=dark] #auth-error,[data-theme=dark] .image-error{color:#ffb1a5}
[data-theme=dark] .empty,[data-theme=dark] .empty h2,[data-theme=dark] .symbol,[data-theme=dark] .guide b{color:#afc9bc}
[data-theme=dark] dialog td,[data-theme=dark] dialog th,[data-theme=dark] .reply-editor,[data-theme=dark] .chat-pdf{border-color:#496058}
[data-theme=dark] .pending-dot{box-shadow:0 0 0 2px #18262c}
[data-theme=dark] :focus-visible{outline:2px solid #8fe3c4;outline-offset:2px}
#theme-toggle{flex-shrink:0}
/* En escritorio, las conexiones también tienen su propia sección. */
@media(min-width:1151px){
 .panel-nav{display:flex}
 main{grid-template-columns:360px minmax(0,1fr)}
 main>aside{display:none}
 body.view-numbers main{grid-template-columns:1fr}
 body.view-numbers main>aside{display:block}
 body.view-numbers .inbox,body.view-numbers .conversation{display:none}
 #slots{display:flex;gap:12px;flex-wrap:wrap}
 .slot{width:250px;max-width:100%}
 .slot img{max-width:220px}
}
/* Mensajes sin leer: señal persistente y legible en ambos temas. */
/* Más espacio para contactos sin reducir la vista móvil de ancho completo. */
@media(min-width:801px) and (min-height:651px){
 .inbox-head{padding:16px 18px 12px}
}
.chat.has-unread{background:#eee8ff;border-left:6px solid #7538d1;padding-left:14px}
.chat.has-unread:hover,.chat.has-unread.selected{background:#dfd0ff}
.chat.has-unread strong{font-weight:800;color:#3b176a}
.chat.has-unread p{color:#48375e;font-weight:600}
.chat .unread{display:inline-block;float:none;background:#7030c3;color:#fff;border-radius:6px;padding:5px 8px;margin:8px 0 0 7px;font-size:11px;font-weight:800;letter-spacing:.3px}
.pending-label{display:inline-block;background:#ffe2b3;color:#773900;border-radius:5px;padding:4px 6px;margin:8px 0 0 7px;font-size:10px;font-weight:800}
.chat.awaiting-reply:not(.has-unread){border-left:4px solid #e18a17;padding-left:16px}
[data-theme=dark] .chat.has-unread{background:#342547;border-left-color:#c293ff}
[data-theme=dark] .chat.has-unread:hover,[data-theme=dark] .chat.has-unread.selected{background:#4c3269}
[data-theme=dark] .chat.has-unread strong{color:#fff}
[data-theme=dark] .chat.has-unread p{color:#e4d4f5}
[data-theme=dark] .chat .unread{background:#c39aff;color:#241137}
[data-theme=dark] .pending-label{background:#694512;color:#ffe1a9}

/* Divisor ajustable; en móvil se mantiene una sola sección a pantalla completa. */
@media(min-width:801px){
 body:not(.view-numbers) main{grid-template-columns:var(--inbox-width,310px) minmax(0,1fr)}
 .inbox{position:relative;min-width:0}
 .inbox-resizer{position:absolute;inset:0 0 0 auto;width:9px;z-index:2;cursor:col-resize;touch-action:none;background:transparent;border:0;border-radius:0;padding:0}
 .inbox-resizer::after{content:'';position:absolute;top:40%;bottom:40%;left:3px;width:3px;border-radius:3px;background:#91a99f}
 .inbox-resizer:hover,.inbox-resizer:focus-visible{background:#7538d133;outline:2px solid #9761d5;outline-offset:-2px}
 body.resizing-inbox,body.resizing-inbox *{cursor:col-resize!important;user-select:none!important}
}
@media(min-width:1151px){body:not(.view-numbers) main{grid-template-columns:var(--inbox-width,360px) minmax(0,1fr)}}
@media(max-width:800px){.inbox-resizer{display:none}}

.chat-entry-unread{background:#eee8ff;border-bottom:1px solid #d9c8f1}
.chat-entry-unread .chat{border-bottom:0;padding-bottom:6px}
.chat-read-actions{display:flex;align-items:center;gap:8px;flex-wrap:wrap;padding:0 14px 12px 14px;border-left:6px solid #7538d1}
.chat-read-actions .unread{float:none;background:#7030c3;color:#fff;border-radius:6px;padding:5px 8px;font-size:11px;font-weight:800}
.mark-read-inline{font-size:11px;padding:6px 8px;background:#fff;color:#54228c;border:1px solid #b58edb}
.mark-read-inline:hover{background:#e0cff6;color:#351358}
[data-theme=dark] .chat-entry-unread{background:#342547;border-bottom-color:#59416f}
[data-theme=dark] .chat-read-actions{border-left-color:#c293ff}
[data-theme=dark] .mark-read-inline{background:#49325f;color:#f0e3ff;border-color:#a77ccf}
[data-theme=dark] .mark-read-inline:hover{background:#62447e}
