*{box-sizing:border-box}body{margin:0;font-family:Arial,Helvetica,sans-serif;background:#dfe5e7;color:#202c33}.app{height:100vh;min-height:560px;max-width:1900px;margin:auto;background:#fff;display:grid;grid-template-columns:350px minmax(0,1fr) 310px;box-shadow:0 0 35px #24343b20}.left{display:flex;flex-direction:column;border-right:1px solid #d8dfe2;min-height:0;background:#fff}.brand{height:68px;display:flex;align-items:center;padding:0 18px;gap:12px;background:#f0f2f5;border-bottom:1px solid #e3e7e9}.logo{width:40px;height:40px;border-radius:50%;background:#087e70;color:white;display:grid;place-items:center;font-size:22px;font-weight:bold}.brand b,.brand small{display:block}.brand b{font-size:16px}.brand small{font-size:11px;color:#667781;margin-top:3px}.gear{margin-left:auto;text-decoration:none;color:#54656d;font-size:20px}.left-title{padding:18px 18px 10px;display:flex;align-items:center;justify-content:space-between}.left-title b{font-size:18px}.left-title span{font-size:11px;color:#667781}.search{margin:0 12px 10px;background:#f0f2f5;border-radius:8px;height:38px;display:flex;align-items:center;padding:0 12px;gap:10px;color:#667781}.search span{font-size:23px}.search input{border:0;outline:0;background:transparent;width:100%;font-size:13px}.filters{display:flex;flex-wrap:wrap;gap:6px;padding:0 12px 10px;border-bottom:1px solid #e7ebed;overflow:visible;align-content:flex-start}.filters button{flex:0 0 auto}.filters button{border:0;background:#f0f2f5;border-radius:16px;padding:7px 12px;color:#54656d;font-size:11px;white-space:nowrap;cursor:pointer}.filters button.active{background:#d9fdd3;color:#176b37}.chats{overflow:auto;flex:1}.chat{min-height:78px;padding:12px 15px;display:flex;gap:12px;text-decoration:none;color:inherit;border-bottom:1px solid #f0f2f5}.chat:hover,.chat.selected{background:#f0f2f5}.chat[hidden]{display:none}.avatar{flex:0 0 48px;width:48px;height:48px;border-radius:50%;background:#dfe9e5;color:#286b5e;display:grid;place-items:center;font-size:18px;font-weight:bold}.chat-info{flex:1;min-width:0}.chat-top,.chat-bottom{display:flex;align-items:center;justify-content:space-between;gap:8px}.chat-top b{font-size:14px;font-weight:500;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.chat-top time,.chat-info small{font-size:10px;color:#667781;white-space:nowrap}.chat-bottom{margin-top:7px}.chat-bottom span{font-size:12px;color:#667781;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.chat-bottom i{font-style:normal;background:#25d366;color:#fff;border-radius:12px;min-width:18px;padding:2px 5px;text-align:center;font-size:10px}.chat-info small{display:block;margin-top:4px}.no-chats{padding:35px 20px;text-align:center;color:#667781;font-size:13px}footer{height:65px;background:#f0f2f5;border-top:1px solid #e3e7e9;padding:10px 15px;display:flex;align-items:center;justify-content:space-between}.user{display:flex;align-items:center;gap:10px}.user b,.user small{display:block}.user b{font-size:12px}.user small{font-size:10px;color:#667781;margin-top:3px}.avatar.mini{width:36px;height:36px;flex-basis:36px;font-size:13px}footer form button{border:0;background:transparent;font-size:20px;color:#54656d;cursor:pointer}.main{min-width:0;display:flex;flex-direction:column;background:#efeae2;position:relative}.main:before{content:"";position:absolute;inset:0;opacity:.22;pointer-events:none;background-image:radial-gradient(#9d968b .6px,transparent .6px);background-size:16px 16px}.thread-head{height:68px;flex-shrink:0;display:flex;align-items:center;gap:12px;padding:0 22px;background:#f0f2f5;border-bottom:1px solid #dfe4e7;z-index:1}.thread-head .avatar{width:42px;height:42px;flex-basis:42px}.thread-person{flex:1}.thread-person b,.thread-person small{display:block}.thread-person b{font-size:14px;font-weight:600}.thread-person small{font-size:11px;color:#667781;margin-top:4px}.head-actions{display:flex;align-items:flex-end;gap:12px;flex-shrink:0}.head-actions label{display:flex;flex-direction:column;align-items:flex-start;gap:4px;white-space:nowrap}.head-actions label>span{font-size:10px;line-height:1;color:#667781}.status-label select{min-width:82px}.online{font-size:11px;color:#16845b}.head-actions select{border:1px solid #d5dcdf;border-radius:6px;background:#fff;padding:7px;font-size:11px;color:#43535b}.messages{position:relative;z-index:1;flex:1;overflow:auto;padding:24px clamp(15px,5vw,75px);display:flex;flex-direction:column;gap:8px}.msg-row{display:flex}.msg-row.in{justify-content:flex-start}.msg-row.out{justify-content:flex-end}.bubble{max-width:min(72%,620px);padding:8px 10px 6px;border-radius:8px;box-shadow:0 1px 1px #00000012;background:#fff;overflow-wrap:anywhere}.out .bubble{background:#d9fdd3}.msg-content{font-size:13px;line-height:1.45;white-space:pre-wrap}.msg-meta{text-align:right;color:#667781;font-size:9px;margin-top:5px}.composer{position:relative;z-index:1;display:flex;align-items:center;gap:10px;padding:12px 22px 24px;background:#f0f2f5;flex-shrink:0}.composer textarea{flex:1;resize:vertical;min-height:44px;max-height:130px;border:0;outline:0;border-radius:9px;padding:13px 15px;font:13px Arial;background:#fff}.composer>button{width:44px;height:44px;border:0;border-radius:50%;background:#087e70;color:white;font-size:20px;cursor:pointer}.composer>button:disabled{opacity:.5}.send-note{position:absolute;bottom:5px;left:25px;font-size:9px;color:#667781}.loading,.error,.empty-thread{margin:auto;text-align:center;color:#667781;font-size:13px}.error{color:#a33}.welcome{position:relative;z-index:1;margin:auto;text-align:center;color:#667781;padding:30px}.welcome-icon{font-size:55px;color:#087e70}.welcome h2{color:#34434a;font-size:23px}.welcome p{font-size:13px}@media(max-width:760px){.app{grid-template-columns:310px minmax(0,1fr)}.head-actions .online{display:none}.messages{padding:18px 12px}.bubble{max-width:88%}}@media(max-width:560px){.app{height:100dvh;grid-template-columns:1fr}.left{display:none}.main{height:100dvh}.thread-head{padding:0 12px}.composer{padding:10px 12px 24px}}
/* Fase 3: asignaciones y notas internas */
.assign-label{font-size:10px;color:#667781}.assign-label select{max-width:125px;min-width:100px}.internal-notes{position:relative;z-index:1;background:#fff;border-top:1px solid #e1e6e8;padding:7px 18px}.internal-notes>button{border:0;background:#fff;color:#54656d;font-size:11px;cursor:pointer;padding:5px}.notes-list{max-height:125px;overflow:auto;display:flex;flex-direction:column;gap:6px;padding:6px 0}.note{background:#fff8d8;border:1px solid #f0e5b5;border-radius:7px;padding:7px 10px;font-size:12px;white-space:pre-wrap}.note small{display:block;color:#7b7357;font-size:10px;margin-top:5px}.notes-empty{font-size:11px;color:#667781}#noteForm{display:flex;gap:8px;align-items:flex-end}#noteForm textarea{flex:1;resize:vertical;min-height:38px;border:1px solid #d8dfe2;border-radius:7px;padding:8px;font:12px Arial}#noteForm button{border:0;border-radius:6px;background:#087e70;color:#fff;padding:9px 12px;font-size:11px;cursor:pointer}@media(max-width:900px){.head-actions{gap:7px}.assign-label select{max-width:95px;min-width:85px}.priority-label select{max-width:88px}.status-label select{min-width:75px}}@media(max-width:760px){.assign-label{display:none}}

/* Notas internas integradas en la cronología del chat */
.note-row{display:flex;justify-content:center;width:100%;margin:5px 0}
.note-card{width:min(88%,560px);background:#fff4cc;border:1px solid #eadb9e;border-radius:9px;padding:9px 12px;box-shadow:0 1px 1px #00000010}
.note-tag{font-size:9px;font-weight:700;letter-spacing:.04em;color:#79651d;margin-bottom:5px}
.note-content{font-size:12px;line-height:1.45;color:#443b20;white-space:pre-wrap;overflow-wrap:anywhere}
.note-meta{font-size:9px;color:#887943;text-align:right;margin-top:6px}
.internal-notes{padding:7px 18px}
#noteForm{display:flex;align-items:center;gap:9px}
#noteForm .note-label{font-size:10px;color:#7a6928;white-space:nowrap;font-weight:600}
#noteForm textarea{min-width:0;min-height:36px;max-height:90px;resize:vertical}
@media(max-width:600px){#noteForm .note-label{display:none}.note-card{width:96%}}

/* V1.3: el historial tiene su propio scroll y el area de escritura permanece visible */
html,body{height:100%;overflow:hidden}
.app{height:100vh;height:100dvh;min-height:0;overflow:hidden}
.main{height:100%;min-height:0;overflow:hidden}
.thread-head{flex:0 0 68px}
.messages{flex:1 1 0;min-height:0;overflow-y:auto;overflow-x:hidden;overscroll-behavior:contain;scrollbar-gutter:stable}
.internal-notes{flex:0 0 auto;min-height:0}
.notes-list{max-height:100px;overflow-y:auto}
.composer{flex:0 0 auto;min-height:78px;padding-bottom:24px}
.composer textarea{resize:none;overflow-y:auto}
@media(max-width:560px){.app,.main{height:100dvh;min-height:0}.messages{min-height:0}.internal-notes{padding:6px 10px}.composer{padding:8px 10px 24px}}

/* Fase 4: archivos y multimedia */
.attach-button{width:42px;height:42px;flex:0 0 42px;border:0;border-radius:50%;background:#e3e9e7;color:#087e70;font-size:27px;line-height:1;cursor:pointer}.attach-button:hover{background:#d4e6df}.media-content{margin-bottom:5px}.chat-image{display:block;max-width:min(100%,340px);max-height:300px;border-radius:7px;object-fit:contain}.chat-video{display:block;width:min(100%,360px);max-height:280px;border-radius:7px}.media-content audio{width:min(100%,300px)}.media-file{display:inline-flex;align-items:center;gap:8px;padding:12px;background:#f0f2f5;border-radius:7px;color:#176b60;text-decoration:none;font-size:12px}.bubble .msg-content:empty{display:none}@media(max-width:560px){.attach-button{width:38px;height:38px;flex-basis:38px}.chat-image{max-width:100%}}

/* Adjuntos preparados desde la caja de escritura, sin ventana emergente */
.composer{flex-wrap:wrap;align-content:flex-end}.attachment-preview{order:-1;flex:0 0 100%;display:flex;align-items:center;gap:10px;min-width:0;padding:8px 12px;background:#fff;border:1px solid #dfe5e7;border-radius:10px;box-shadow:0 1px 2px #0000000a}.attachment-preview[hidden]{display:none}.attachment-thumb{width:54px;height:54px;object-fit:cover;border-radius:6px;background:#f0f2f5}.attachment-generic{width:54px;height:54px;flex:0 0 54px;display:grid;place-items:center;border-radius:6px;background:#edf2f0;color:#087e70;font-size:25px}.attachment-details{display:flex;flex:1;min-width:0;flex-direction:column;gap:4px}.attachment-details b{font-size:12px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.attachment-details small{font-size:10px;color:#667781}.remove-attachment{width:30px;height:30px;flex:0 0 30px;border:0;border-radius:50%;background:#f0f2f5;color:#54656d;font-size:21px;cursor:pointer}.composer textarea{min-width:0;resize:none}
/* Citas, rectificaciones y estados de entrega */
.message-actions{display:flex;justify-content:flex-end;gap:3px;margin:-2px 0 4px;opacity:.35;transition:opacity .15s}
.bubble:hover .message-actions{opacity:1}
.message-actions button{border:0;background:#ffffffb8;color:#40545a;border-radius:5px;padding:3px 7px;cursor:pointer;font-size:13px}
.message-actions button:hover{background:#fff;color:#087e70}
.wa-ticks{font-size:13px;letter-spacing:-4px;padding-right:4px;color:#667781;font-weight:bold}
.wa-ticks.read{color:#34a9e4}
.wa-failed{color:#c0392b;font-weight:bold}
.quoted-in-bubble{border-left:3px solid #087e70;background:#00000008;border-radius:4px;padding:6px 8px;margin:2px 0 7px;display:flex;flex-direction:column;gap:3px;max-width:100%}
.quoted-in-bubble b{font-size:10px;color:#087e70}.quoted-in-bubble span{font-size:11px;color:#526168;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.quote-preview{order:-2;flex:0 0 100%;display:flex;align-items:center;justify-content:space-between;gap:10px;padding:8px 12px;border-left:4px solid #087e70;background:#fff;border-radius:7px;min-width:0}
.quote-preview>div{display:flex;flex-direction:column;gap:3px;min-width:0}.quote-preview b{font-size:10px;color:#087e70}.quote-preview small{font-size:11px;color:#526168;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.quote-preview button{border:0;background:#edf1f2;border-radius:50%;width:28px;height:28px;font-size:18px;cursor:pointer}

/* Ajuste de altura del campo de escritura */
.composer textarea{min-height:60px;padding:16px 16px;font-size:14px;line-height:1.45}
.composer{min-height:94px;gap:12px}
@media(max-width:560px){.composer textarea{min-height:56px;padding:14px}.composer{min-height:86px}}

/* Fase 6 CRM: tercera columna persistente */
.crm-panel{min-width:0;display:flex;flex-direction:column;background:#fff;border-left:1px solid #dfe4e7;min-height:0}
.crm-panel[hidden]{display:none}
.crm-head{height:68px;flex:0 0 68px;background:#f7f8f9;border-bottom:1px solid #e3e7e9;padding:10px 15px;display:flex;align-items:center;justify-content:space-between}
.crm-head b,.crm-head small{display:block}.crm-head b{font-size:14px}.crm-head small{font-size:10px;color:#667781;margin-top:4px}
.crm-avatar{width:38px;height:38px;border-radius:50%;background:#d9fdd3;color:#176b37;display:grid;place-items:center;font-weight:bold}
.crm-body{overflow:auto;min-height:0;padding:12px}
.crm-section{padding:0 0 14px;margin:0 0 13px;border-bottom:1px solid #edf0f1}
.crm-section h3{font-size:12px;margin:0 0 9px;color:#34434a}
.crm-section label{display:block;font-size:10px;color:#667781;margin:0 0 8px}
.crm-section input,.crm-section select,.crm-section textarea{display:block;width:100%;margin-top:4px;border:1px solid #d9e0e3;border-radius:6px;padding:8px;font:12px Arial;color:#263238;background:#fff}
.crm-section input[readonly]{background:#f4f6f7;color:#667781}
.crm-section textarea{resize:vertical;min-height:55px}
.crm-primary,.crm-inline button{border:0;border-radius:6px;background:#087e70;color:#fff;padding:8px 11px;font-size:11px;cursor:pointer}
#crmSaveStatus{display:block;color:#16845b;font-size:10px;margin-top:6px}
.crm-tags{display:flex;flex-wrap:wrap;gap:5px;margin-bottom:8px}
.crm-tag{display:inline-flex;align-items:center;gap:5px;background:#e8f3ef;color:#256b5a;border-radius:14px;padding:5px 8px;font-size:10px}
.crm-tag button{border:0;background:transparent;color:inherit;cursor:pointer;font-size:14px;padding:0}
.crm-inline{display:flex;gap:6px}.crm-inline input{flex:1;min-width:0;margin:0}
.crm-reminder-form{display:grid;gap:6px}.crm-reminders{display:grid;gap:7px;margin-top:9px}
.crm-reminder{display:flex;align-items:center;gap:6px;background:#f6f8f8;border:1px solid #e7ecee;border-radius:7px;padding:8px}
.crm-reminder>div{flex:1;min-width:0}.crm-reminder b,.crm-reminder small{display:block;overflow-wrap:anywhere}.crm-reminder b{font-size:11px}.crm-reminder small{font-size:9px;color:#667781;margin-top:4px}
.crm-reminder button{border:0;border-radius:50%;background:#d9fdd3;color:#176b37;width:25px;height:25px;cursor:pointer}.crm-reminder.done{opacity:.55}.crm-muted{font-size:10px;color:#849198}
@media(max-width:1100px){.app{grid-template-columns:300px minmax(0,1fr) 270px}}
@media(max-width:850px){.app{grid-template-columns:280px minmax(0,1fr)}.crm-panel{display:none!important}}
@media(max-width:560px){.app{grid-template-columns:1fr}}

/* Ficha bloqueada y avisos compartidos */
.crm-editbar{display:flex;align-items:center;justify-content:space-between;margin:0 0 10px;font-size:11px;font-weight:700;color:#34434a}
.crm-edit-button,.crm-cancel{border:1px solid #d5dfe2;background:#fff;color:#34434a;border-radius:6px;padding:7px 10px;font-size:11px;cursor:pointer}
.crm-section input:disabled,.crm-section select:disabled,.crm-section textarea:disabled{background:#f4f6f7;color:#52636a;border-color:#edf0f1;opacity:1}
.crm-edit-actions{display:flex;gap:7px}.crm-edit-actions[hidden]{display:none}
.notification-bell{position:relative;margin-left:auto;border:0;background:transparent;font-size:17px;cursor:pointer;padding:3px 8px}
.notification-bell i{position:absolute;top:-4px;right:0;background:#d93025;color:#fff;border-radius:12px;min-width:17px;height:17px;font:10px Arial;display:grid;place-items:center;font-style:normal}
.notification-panel{position:fixed;z-index:1000;top:58px;right:16px;width:min(390px,calc(100vw - 32px));max-height:70vh;overflow:auto;background:#fff;border:1px solid #dce3e6;border-radius:12px;box-shadow:0 8px 30px #0002;padding:12px}
.notification-panel[hidden]{display:none}.notification-panel-head{display:flex;justify-content:space-between;align-items:center;padding-bottom:9px;border-bottom:1px solid #edf0f1}.notification-panel-head button{border:0;background:none;font-size:22px;cursor:pointer}
.notification-item{padding:11px 2px;border-bottom:1px solid #edf0f1;display:flex;gap:9px;align-items:flex-start}.notification-item>div{flex:1;min-width:0}.notification-item b{font-size:12px;display:block}.notification-item small{font-size:10px;color:#687980;display:block;margin-top:4px}.notification-item a{font-size:10px;color:#087e70;text-decoration:none;display:inline-block;margin-top:6px}.notification-item button{border:1px solid #d5dfe2;background:#fff;border-radius:6px;padding:6px;font-size:10px;white-space:nowrap;cursor:pointer}.notification-empty{padding:18px 4px;color:#718087;font-size:12px}

/* Aviso elegante para adjuntos cuyo plazo de conservación ha terminado */
.media-expired{display:flex;flex-direction:column;align-items:flex-start;gap:5px;max-width:260px;padding:13px 15px;border:1px solid #e4e7ec;border-radius:10px;background:#f8fafb;color:#475467;font-size:13px}
.media-expired span{font-size:20px}.media-expired b{font-weight:600;color:#344054}.media-expired small{font-size:11px;line-height:1.4;color:#667085}

.chat-audio-wrap{display:flex;flex-direction:column;gap:5px;max-width:320px}.chat-audio-wrap audio{width:min(100%,300px)}.audio-download{font-size:11px;color:#087e70;text-decoration:underline;align-self:flex-start}.audio-playback-error:before{content:"Este navegador no puede reproducir este formato de audio. Puedes descargarlo.";display:block;color:#667085;font-size:11px;max-width:290px}

/* Fase 7.1: respuestas rápidas */
.composer{position:relative}.quick-replies-toggle{width:42px!important;height:42px!important;flex:0 0 42px;border-radius:10px!important;background:#e3f3ef!important;color:#087e70!important;font-size:19px!important;border:1px solid #cce6df!important}.quick-replies{position:absolute;z-index:20;left:72px;bottom:calc(100% - 8px);width:min(430px,calc(100% - 95px));max-height:340px;background:#fff;border:1px solid #dce5e7;border-radius:12px;box-shadow:0 8px 28px #20343b25;overflow:hidden}.quick-replies[hidden]{display:none}.quick-replies-head{display:flex;align-items:center;gap:8px;padding:10px 12px;border-bottom:1px solid #edf0f1}.quick-replies-head b{font-size:12px;white-space:nowrap}.quick-replies-head input{flex:1;min-width:0;border:1px solid #dce3e5;border-radius:6px;padding:7px;font-size:12px}.quick-replies-head button{border:0;background:transparent;font-size:20px;color:#667781;cursor:pointer}.quick-replies-list{max-height:285px;overflow:auto;padding:5px}.quick-reply-item{display:block;width:100%;text-align:left;background:#fff!important;color:#263238!important;border:0;border-radius:7px;padding:10px!important;height:auto!important;font-size:12px!important;cursor:pointer}.quick-reply-item:hover{background:#f0f7f5!important}.quick-reply-item b{display:block;color:#087e70;margin-bottom:4px}.quick-reply-item small{display:block;color:#667781;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.quick-replies-empty{padding:16px;color:#667781;font-size:12px}


/* Reproductor de notas de voz integrado */
.chat-audio-wrap{display:flex;align-items:center;gap:10px;width:min(100%,330px);min-width:230px;padding:9px 11px;border-radius:13px;background:#f5f7f7;border:1px solid #e3e9e7;color:#263238}
.out .chat-audio-wrap{background:#c9f3c4;border-color:#b9e9b3}
.chat-audio-wrap .chat-audio{display:none}
.audio-play{width:42px;height:42px;flex:0 0 42px;border:0;border-radius:50%;background:#087e70;color:#fff;display:grid;place-items:center;font-size:17px;cursor:pointer}
.audio-play:hover{background:#066b60}
.audio-play-icon{line-height:1;margin-left:2px}
.audio-main{min-width:0;flex:1}
.audio-progress{display:block;width:100%;height:5px;margin:4px 0 7px;accent-color:#087e70;cursor:pointer}
.audio-bottom{display:flex;align-items:center;gap:10px;font-size:10px;color:#58666c}
.audio-time{font-variant-numeric:tabular-nums;white-space:nowrap}
.audio-speed{border:1px solid #cbd7d3;background:#fff;border-radius:12px;padding:3px 7px;color:#087e70;font-size:10px;font-weight:600;cursor:pointer}
.audio-download{margin-left:auto;font-size:10px;color:#087e70;text-decoration:none;white-space:nowrap}
.audio-download:hover{text-decoration:underline}
.audio-error{font-size:11px;color:#9b332d;line-height:1.4}
.audio-error a{color:#087e70}
@media(max-width:560px){.chat-audio-wrap{min-width:210px;width:100%}}

/* Fase 7 - control de atención */
.attention-age{color:#b45309;font-weight:600}
.waiting-customer{color:#64748b}
.attention-dot{align-self:center;flex:0 0 22px;width:22px;height:22px;border-radius:50%;display:grid;place-items:center;background:#f59e0b;color:#fff;font-weight:700;font-size:12px}
.activity-row{display:flex;justify-content:center;margin:8px 0;padding:0 12px}.activity-card{display:flex;align-items:flex-start;gap:9px;max-width:88%;padding:8px 13px;border:1px solid var(--border,#e5e7eb);border-radius:12px;background:var(--surface-muted,#f7f8fa);color:var(--text-secondary,#64748b);font-size:12px;line-height:1.45}.activity-card b{display:block;color:var(--text,#334155);font-size:11px;text-transform:capitalize;margin-bottom:2px}.activity-card small{display:block;margin-top:3px;color:var(--muted,#87909d);font-size:10px}.activity-dot{font-size:20px;line-height:12px;color:#159786}
/* Fase 9: prioridad compartida e historial del contacto */
.priority-label{font-size:11px;color:var(--muted,#64748b)}.priority-label select{max-width:115px;padding:7px 8px;border:1px solid var(--border,#dce3e5);border-radius:8px;background:#fff;color:#263238;font-size:12px}.priority-badge{display:inline-flex;align-items:center;margin-left:6px;padding:2px 7px;border-radius:10px;font-size:9px;font-style:normal;font-weight:700;text-transform:uppercase;white-space:nowrap}.priority-urgente{background:#fee2e2;color:#b91c1c}.priority-alta{background:#ffedd5;color:#c2410c}.priority-baja{background:#e2e8f0;color:#475569}.crm-history{display:flex;flex-direction:column;gap:7px}.crm-history-item{display:flex;flex-direction:column;gap:3px;padding:9px;border:1px solid var(--border,#e5e7eb);border-radius:9px;text-decoration:none;color:inherit;background:#fff}.crm-history-item:hover{background:#f7faf9;border-color:#b8d8d0}.crm-history-item b{font-size:12px}.crm-history-item span,.crm-history-item small{font-size:10px;color:var(--muted,#64748b)}
@media(max-width:900px){.priority-label{font-size:10px}.priority-label select{max-width:90px}}

/* Fase 10B: panel de envío de plantillas oficiales */
#metaTemplatePanel{position:absolute;bottom:76px;left:12px;right:12px;z-index:20;max-height:55vh;overflow:auto;background:#fff;border:1px solid #dbe3e8;border-radius:12px;box-shadow:0 8px 28px rgba(15,23,42,.16);color:#17212b}#metaTemplatePanel[hidden]{display:none}#metaTemplatePanel select{width:100%;padding:9px;border:1px solid #cbd5e1;border-radius:7px}#metaTemplateSend{border:0;border-radius:7px;padding:10px 14px;background:#087f73;color:white;font-weight:600;cursor:pointer}#metaTemplateSend:disabled{opacity:.55;cursor:not-allowed}#metaTemplateFeedback{font-size:13px;color:#334155}

/* NetCom Chat · renovación visual y ficha lateral plegable */
:root{--nc-ink:#172b35;--nc-muted:#71818a;--nc-line:#e4eaed;--nc-teal:#087f73;--nc-teal-dark:#06675f;--nc-soft:#edf7f4;--nc-shadow:0 12px 34px rgba(19,45,54,.09)}
body{font-family:Inter,ui-sans-serif,system-ui,-apple-system,"Segoe UI",Arial,sans-serif;background:#eaf0f2;color:var(--nc-ink)}
.app{grid-template-columns: minmax(285px,330px) minmax(0,1fr) minmax(280px,320px);max-width:1920px;background:#f8fafb;box-shadow:0 18px 60px rgba(24,49,59,.13)}
.app.crm-collapsed{grid-template-columns:minmax(285px,330px) minmax(0,1fr) 0}
.app.crm-collapsed .crm-panel{display:none}
.left{background:#fbfcfd;border-right:1px solid var(--nc-line)}
.brand{height:76px;padding:0 20px;background:#fff;border-bottom:1px solid var(--nc-line)}
.logo{width:42px;height:42px;border-radius:13px;background:linear-gradient(145deg,#0b9385,#075e59);box-shadow:0 5px 13px rgba(8,127,115,.2)}
.brand b{font-size:15px;letter-spacing:-.02em;color:#18323c}.brand small{font-size:11px;color:#87959c}
.gear{width:36px;height:36px;display:grid;place-items:center;border-radius:11px;background:#f3f7f8;color:#52666e;transition:.18s}.gear:hover{background:#e8f3f0;color:var(--nc-teal)}
.left-title{padding:20px 18px 12px}.left-title b{font-size:19px;letter-spacing:-.03em}.left-title span{font-size:11px;color:#87959c}
.search{height:42px;margin:0 14px 12px;border:1px solid #e7edef;border-radius:12px;background:#f5f8f9;transition:.18s}.search:focus-within{background:#fff;border-color:#9acfc4;box-shadow:0 0 0 3px rgba(8,127,115,.08)}.search input{font:13px inherit;color:var(--nc-ink)}
.filters{gap:7px;padding:0 14px 13px;border-bottom:1px solid var(--nc-line)}.filters button{padding:7px 11px;border:1px solid #e8edef;background:#fff;color:#60727a;font-size:10px;font-weight:650;transition:.18s}.filters button:hover{border-color:#b9dcd4;background:#f3faf8}.filters button.active{border-color:#c5e7de;background:#e5f5f0;color:#087264}
.chats{padding:5px 7px}.chat{min-height:78px;margin:3px 0;padding:12px 11px;border:1px solid transparent;border-radius:13px;transition:background .16s,border-color .16s,box-shadow .16s}.chat:hover{background:#f4f8f8}.chat.selected{background:#eaf5f2;border-color:#d6ebe5;box-shadow:inset 3px 0 #0b897b}.avatar{background:#e7f1ee;color:#267366}.chat-top b{font-size:13px;font-weight:650;color:#203640}.chat-top time,.chat-info small{color:#87969d}.chat-bottom span{color:#657780}.chat-bottom i{background:#0b8d7e;font-weight:700}
footer{height:72px;background:#fff;border-top:1px solid var(--nc-line);padding:11px 17px}.user b{font-size:12px;color:#243b44}.user small{color:#85949b}.avatar.mini{border-radius:12px}
.main{background:#f2f6f6}.main:before{opacity:.13;background-image:radial-gradient(#9fb4ae .55px,transparent .55px);background-size:18px 18px}
.thread-head{height:76px;flex:0 0 76px;padding:0 24px;background:rgba(255,255,255,.96);border-bottom:1px solid var(--nc-line);gap:13px}.thread-head .avatar{width:44px;height:44px;flex-basis:44px;border-radius:14px;background:#e3f2ed;color:#197466}.thread-person b{font-size:14px;font-weight:700;color:#19343e}.thread-person small{font-size:11px;color:#829198}.head-actions{gap:10px}.head-actions label>span{font-size:9px;color:#8a989e;font-weight:700;text-transform:uppercase;letter-spacing:.055em}.head-actions select,.priority-label select{border:1px solid #e1e8ea;border-radius:9px;background:#fbfcfc;padding:8px 10px;color:#40545c;font:600 11px inherit;outline:none}.head-actions select:focus,.priority-label select:focus{border-color:#91c9bd;box-shadow:0 0 0 3px rgba(8,127,115,.08)}.online{font-size:10px;font-weight:700;color:#12856e}
.messages{padding:26px clamp(18px,5vw,82px);gap:10px;scrollbar-color:#cbd8d7 transparent}.msg-row{margin:1px 0}.bubble{max-width:min(76%,650px);padding:11px 13px 8px;border:1px solid #e9eeee;border-radius:14px 14px 14px 5px;background:#fff;box-shadow:0 2px 7px rgba(22,49,57,.045)}.out .bubble{border-color:#cde9df;background:#e5f5ed;border-radius:14px 14px 5px 14px}.msg-content{font-size:13px;line-height:1.55;color:#263e46}.msg-meta{font-size:9px;color:#89979c}.wa-ticks.read{color:#2396d2}
.internal-notes{background:#fff;border-top:1px solid var(--nc-line);padding:9px 18px}#noteForm .note-label{color:#92752c;font-weight:700}#noteForm textarea{border:1px solid #e5ebed;border-radius:10px;background:#fbfcfc;padding:9px 11px;font:12px inherit}#noteForm button{border-radius:9px;background:#f8f1d9;color:#806b2d;font-weight:700}#noteForm button:hover{background:#f2e7c2}
.composer{gap:9px;padding:13px 20px 25px;background:#fff;border-top:1px solid var(--nc-line)}.composer textarea{min-height:48px;border:1px solid #e5ebed;border-radius:14px;background:#f8fafb;padding:14px 16px;font:13px inherit;line-height:1.5;color:#213a43;transition:.18s}.composer textarea:focus{border-color:#9acfc4;background:#fff;box-shadow:0 0 0 3px rgba(8,127,115,.07)}.composer>button#sendButton{width:46px;height:46px;border-radius:14px;background:linear-gradient(145deg,#0b9385,#087064);box-shadow:0 5px 13px rgba(8,127,115,.2);font-size:19px}.composer>button#sendButton:hover{background:var(--nc-teal-dark);transform:translateY(-1px)}.attach-button{width:42px;height:42px;border-radius:13px;background:#f1f6f5;color:#3b8278;border:1px solid #e2eeeb;font-size:25px}.quick-replies-toggle{border-radius:13px!important;background:#f1f6f5!important;color:#3b8278!important;border:1px solid #e2eeeb!important}.send-note{left:22px;color:#9aa6aa;font-size:9px}
.crm-panel{position:relative;background:#fff;border-left:1px solid var(--nc-line);box-shadow:-8px 0 26px rgba(24,49,59,.035)}.crm-head{height:76px;flex:0 0 76px;padding:0 15px 0 19px;background:#fff;border-bottom:1px solid var(--nc-line)}.crm-heading b{font-size:13px;font-weight:750;color:#1d3740}.crm-heading small{font-size:10px;color:#8a989e}.crm-head-actions{display:flex;align-items:center;gap:9px}.crm-avatar{width:38px;height:38px;border-radius:13px;background:#e4f3ee;color:#1c7769}.crm-collapse-button{width:36px;height:36px;display:grid;place-items:center;border:1px solid #e4ebed;border-radius:11px;background:#f8fafb;color:#60747c;cursor:pointer;transition:all .18s}.crm-collapse-button:hover{border-color:#b9ddd4;background:#eaf6f2;color:#087b6e;box-shadow:0 3px 10px rgba(8,127,115,.1)}.crm-collapse-button:focus-visible{outline:3px solid rgba(8,127,115,.2);outline-offset:2px}.crm-collapse-button svg{width:19px;height:19px;fill:none;stroke:currentColor;stroke-width:1.8;stroke-linecap:round;stroke-linejoin:round}
.crm-body{padding:16px 15px;scrollbar-color:#cbd8d7 transparent}.crm-section{padding-bottom:16px;margin-bottom:15px;border-bottom:1px solid #edf1f2}.crm-section h3{font-size:11px;letter-spacing:.02em;color:#314951}.crm-section label{font-size:10px;font-weight:650;color:#7a8a91}.crm-section input,.crm-section select,.crm-section textarea{border:1px solid #e4eaec;border-radius:9px;padding:9px 10px;font:12px inherit;color:#2d444c}.crm-edit-button,.crm-cancel{border:1px solid #e0e8e9;border-radius:9px;padding:7px 10px;font-weight:650;color:#536870}.crm-primary,.crm-inline button{border-radius:9px;background:#087f73;padding:9px 12px;font-weight:700}.crm-tag{border-radius:9px;background:#eaf5f1;color:#267467;font-weight:650}.crm-reminder{border:1px solid #e8edef;border-radius:10px;background:#f9fbfb}
.quick-replies,#metaTemplatePanel{border:1px solid #e1e9e9;border-radius:16px;box-shadow:0 18px 48px rgba(17,43,51,.18)}.quick-replies-head{padding:13px 15px;border-bottom:1px solid #edf1f2}.quick-replies-head b{font-size:12px;color:#203b44}.quick-reply-item{padding:12px!important;border-radius:10px!important}.quick-reply-item:hover{background:#eff8f5!important}
#metaTemplatePanel{left:14px;right:14px;bottom:82px;max-height:min(72vh,650px);padding-bottom:4px}#metaTemplatePanel .quick-replies-head{position:sticky;top:0;background:#fff;z-index:2}#metaTemplatePanel>div:nth-child(2){padding:14px!important}#metaTemplatePanel label{font-size:11px;font-weight:700;color:#61747b}#metaTemplatePanel select,#metaTemplatePanel input{border:1px solid #dfe8e9;border-radius:9px;padding:10px 11px;font:12px inherit}#metaTemplateSend{border-radius:10px;background:linear-gradient(145deg,#0b9385,#087064);padding:11px 15px;font-weight:700}
.template-live-preview{margin-top:14px;padding:12px;border:1px solid #dcebe6;border-radius:13px;background:#f2f8f5}.template-preview-title{display:flex;flex-direction:column;gap:3px;margin-bottom:9px}.template-preview-title span{font-size:11px;font-weight:800;color:#24695e}.template-preview-title small{font-size:10px;color:#7b8d8a}.template-preview-card{max-width:390px;padding:12px;border:1px solid #e4ece8;border-radius:12px 12px 12px 4px;background:#fff;box-shadow:0 2px 7px rgba(20,50,45,.05)}.template-preview-header{font-size:12px;font-weight:800;color:#263f46;margin-bottom:7px}.template-preview-media{padding:22px 10px;margin-bottom:8px;border-radius:8px;background:#edf3f1;text-align:center;color:#71847e;font-size:11px}.template-preview-body{font-size:12px;line-height:1.55;white-space:pre-wrap;color:#344a50}.template-preview-footer{margin-top:8px;font-size:10px;color:#87958f}.template-preview-buttons{display:grid;gap:6px;margin-top:10px}.template-preview-button{padding:8px 9px;border-top:1px solid #edf1ef;text-align:center;color:#168071;font-size:11px;font-weight:700}
@media(max-width:1100px){.app{grid-template-columns:290px minmax(0,1fr) 280px}.app.crm-collapsed{grid-template-columns:290px minmax(0,1fr) 0}.head-actions{gap:7px}.head-actions select{max-width:100px}}
@media(max-width:850px){.app{grid-template-columns:280px minmax(0,1fr)}.app.crm-collapsed{grid-template-columns:280px minmax(0,1fr)}.crm-panel{display:none!important}.thread-head{padding:0 15px}.head-actions .priority-label,.head-actions .status-label{display:none}}
@media(max-width:560px){.app{grid-template-columns:1fr}.app.crm-collapsed{grid-template-columns:1fr}.messages{padding:16px 12px}.composer{padding:9px 10px 25px;gap:6px}.composer>button#sendButton{width:42px;height:42px}.thread-head{height:64px;flex-basis:64px}.bubble{max-width:92%}}

/* Ajustes V3: cabecera de chats, pestaña lateral y ficha recordada por usuario */
.left-title{display:grid;grid-template-columns:max-content minmax(0,1fr) 34px;align-items:center;column-gap:9px;justify-content:initial;padding:18px 14px 11px;min-width:0}
.left-title>b{font-size:19px;line-height:1.2;white-space:nowrap}
.left-title>span{display:block;min-width:0;white-space:nowrap;font-size:11px;line-height:1.2;color:#87959c;overflow:hidden;text-overflow:ellipsis}
.left-title .notification-bell{grid-column:3;grid-row:1;width:34px;height:34px;margin:0;padding:0;display:grid;place-items:center;border-radius:10px}
.left-title .notification-bell:hover{background:#edf4f2}
.left-title .notification-bell i{top:0;right:0}
.app.crm-collapsed{grid-template-columns:minmax(285px,330px) minmax(0,1fr) 34px}
.app.crm-collapsed .crm-panel{display:none}
.crm-reopen-tab{align-self:center;justify-self:stretch;width:34px;height:112px;padding:10px 0;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:8px;border:1px solid #dce8e5;border-right:0;border-radius:12px 0 0 12px;background:#f4faf8;color:#167568;box-shadow:-4px 2px 14px rgba(24,49,59,.07);cursor:pointer;z-index:3}
.crm-reopen-tab[hidden]{display:none!important}
.crm-reopen-tab:hover{background:#e8f5f1;color:#075f55}
.crm-reopen-tab svg{width:18px;height:18px;fill:none;stroke:currentColor;stroke-width:2;stroke-linecap:round;stroke-linejoin:round}
.crm-reopen-tab span{writing-mode:vertical-rl;transform:rotate(180deg);font-size:10px;font-weight:700;letter-spacing:.02em}
@media(max-width:1100px){.app.crm-collapsed{grid-template-columns:290px minmax(0,1fr) 34px}}
@media(max-width:850px){.crm-reopen-tab{display:none!important}.app.crm-collapsed{grid-template-columns:280px minmax(0,1fr)}}
@media(max-width:560px){.left-title{padding:16px 14px 10px}.app.crm-collapsed{grid-template-columns:1fr}}
