:root{
  --ink:#1C2024; --ink-soft:#4B5563; --ink-mute:#8A94A6;
  --ground:#F6F7F9; --surface:#FFFFFF; --line:#E4E7EC; --line-soft:#EEF0F3;
  --accent:#2D5F6B; --accent-soft:#E4EEF0; --accent-ink:#1E464F;
  --ok:#2F8F5B; --ok-soft:#E6F4EB;
  --warn:#C2410C; --warn-soft:#FDECE3;
  --danger:#C23434;
  --s1:#3461A8; --s1-soft:#E7EEF8;
  --s2:#1F8A77; --s2-soft:#E2F3F0;
  --s3:#7A4FB5; --s3-soft:#EFE7F8;
  --s4:#B2790C; --s4-soft:#FAEFD9;
  --s5:#B5436B; --s5-soft:#F8E6ED;
  --s6:#3E8F3E; --s6-soft:#E6F3E6;
  --s7:#4B5FBD; --s7-soft:#E7E9F7;
  --s8:#9A5B3C; --s8-soft:#F3E7DF;
}
*{box-sizing:border-box;}
html,body{height:100%;}
body{margin:0; font-family:'Manrope',system-ui,sans-serif; background:var(--ground); color:var(--ink); -webkit-font-smoothing:antialiased;}
.mono{font-family:'IBM Plex Mono',ui-monospace,monospace;}
a{color:var(--accent); text-decoration:none;}
button{font-family:inherit; cursor:pointer; border:none; background:none;}
input{font-family:inherit;}
::-webkit-scrollbar{width:8px; height:8px;}
::-webkit-scrollbar-thumb{background:#D7DBE1; border-radius:8px;}
#app{height:100vh; display:flex; flex-direction:column;}

/* ---------- Login ---------- */
.login-screen{height:100vh; display:flex; align-items:center; justify-content:center; background:var(--ground); padding:16px;}
.login-card{width:100%; max-width:360px; background:var(--surface); border:1px solid var(--line); border-radius:16px; padding:32px 28px; box-shadow:0 1px 3px rgba(16,24,40,0.06);}
.login-logo{width:40px; height:40px; border-radius:11px; background:var(--accent); display:flex; align-items:center; justify-content:center; margin-bottom:16px;}
.login-card h1{font-size:19px; margin:0 0 4px; letter-spacing:-0.01em;}
.login-card p{font-size:13px; color:var(--ink-mute); margin:0 0 22px;}
.field{margin-bottom:14px;}
.field label{display:block; font-size:12px; font-weight:700; color:var(--ink-soft); margin-bottom:6px;}
.field input{width:100%; height:40px; border-radius:9px; border:1px solid var(--line); padding:0 13px; font-size:14px; outline:none; background:var(--ground); color:var(--ink);}
.field input:focus{border-color:var(--accent);}
.btn-primary{width:100%; height:42px; border-radius:10px; background:var(--accent); color:#fff; font-size:14px; font-weight:700; margin-top:6px;}
.btn-primary:disabled{opacity:0.6; cursor:default;}
.login-error{background:var(--warn-soft); color:var(--warn); font-size:12.5px; font-weight:600; padding:9px 12px; border-radius:8px; margin-bottom:14px;}

/* ---------- Shell ---------- */
.topbar{flex-shrink:0; height:64px; background:var(--surface); border-bottom:1px solid var(--line); display:flex; align-items:center; gap:20px; padding:0 24px;}
.brand{display:flex; align-items:center; gap:10px; flex-shrink:0;}
.brand-mark{width:30px; height:30px; border-radius:8px; background:var(--accent); display:flex; align-items:center; justify-content:center; flex-shrink:0;}
.brand-name{font-weight:800; font-size:15px; letter-spacing:-0.01em;}
.brand-name span{color:var(--ink-mute); font-weight:600;}
.search-wrap{flex:1; max-width:440px; position:relative;}
.search-wrap svg{position:absolute; left:13px; top:50%; transform:translateY(-50%); opacity:0.45; pointer-events:none;}
.search-wrap input{width:100%; height:37px; border-radius:10px; border:1px solid var(--line); background:var(--ground); padding:0 13px 0 36px; font-size:13.5px; outline:none; color:var(--ink);}
.search-wrap input:focus{border-color:var(--accent);}
.spacer{flex:1;}
.pill{display:flex; align-items:center; gap:7px; height:32px; padding:0 12px; border-radius:999px; font-size:12px; font-weight:700; flex-shrink:0;}
.pill-ok{background:var(--ok-soft); color:#1F6B42; border:1px solid #CFE8D9;}
.pill-warn{background:var(--warn-soft); color:#9A3412; border:1px solid #F3CDB3;}
.dot{width:7px; height:7px; border-radius:999px; display:inline-block; flex-shrink:0;}
.user-avatar{width:32px; height:32px; border-radius:999px; background:var(--accent-soft); color:var(--accent-ink); display:flex; align-items:center; justify-content:center; font-weight:800; font-size:12px; flex-shrink:0;}
.logout-btn{display:flex; align-items:center; gap:6px; font-size:12px; font-weight:700; color:var(--ink-mute); padding:6px 4px;}
.logout-btn:hover{color:var(--danger);}

.body-wrap{flex:1; display:flex; min-height:0;}

/* ---------- Coluna lojas ---------- */
.stores-col{width:248px; flex-shrink:0; background:var(--surface); border-right:1px solid var(--line); padding:16px 12px; overflow-y:auto;}
.stores-col .eyebrow{font-size:11px; font-weight:800; color:var(--ink-mute); text-transform:uppercase; letter-spacing:0.06em; padding:4px 10px 10px;}
.store-btn{width:100%; display:flex; align-items:center; gap:10px; padding:9px 10px; border-radius:9px; margin-bottom:3px; text-align:left; transition:background .12s;}
.store-btn:hover{background:var(--ground);}
.store-btn.active{font-weight:800;}
.store-name-col{flex:1; min-width:0; display:flex; flex-direction:column; gap:1px;}
.store-btn .store-name{font-size:13.5px; color:var(--ink-soft); min-width:0; overflow:hidden; text-overflow:ellipsis; white-space:nowrap;}
.store-btn.active .store-name{color:var(--ink);}
.store-number{font-size:10.5px; color:var(--ink-mute); overflow:hidden; text-overflow:ellipsis; white-space:nowrap;}
.store-off-tag{font-size:9.5px; font-weight:700; color:var(--warn); background:var(--warn-soft); padding:2px 6px; border-radius:5px; flex-shrink:0;}
.watchdog-note{margin-top:16px; padding:12px; border-radius:10px; background:var(--ground); border:1px solid var(--line-soft);}
.watchdog-note .eyebrow{padding:0 0 6px;}
.watchdog-note p{font-size:11.5px; color:var(--ink-soft); line-height:1.55; margin:0;}

/* ---------- Coluna conversas ---------- */
.list-col{width:340px; flex-shrink:0; background:var(--surface); border-right:1px solid var(--line); display:flex; flex-direction:column; min-height:0;}
.list-head{padding:14px 16px 10px; border-bottom:1px solid var(--line-soft); flex-shrink:0;}
.list-head .title{font-weight:800; font-size:14px;}
.list-head .count{font-size:12px; color:var(--ink-mute); margin-top:2px;}
.date-filter{display:flex; align-items:center; gap:6px; margin-top:9px;}
.date-filter input[type="date"]{flex:1; min-width:0; height:30px; border-radius:8px; border:1px solid var(--line); background:var(--ground); padding:0 8px; font-size:11.5px; color:var(--ink-soft); outline:none;}
.date-filter input[type="date"]:focus{border-color:var(--accent);}
.date-filter span{font-size:11px; color:var(--ink-mute); flex-shrink:0;}
.date-clear{width:22px; height:22px; border-radius:999px; background:var(--ground); border:1px solid var(--line); color:var(--ink-mute); font-size:11px; flex-shrink:0;}
.date-clear:hover{color:var(--danger); border-color:var(--danger);}
.list-body{flex:1; overflow-y:auto;}
.conv-row{width:100%; display:flex; gap:10px; padding:12px 16px; border-bottom:1px solid var(--line-soft); text-align:left; border-left:3px solid transparent;}
.conv-row:hover{background:var(--ground);}
.conv-row.active{background:var(--ground);}
.avatar{width:36px; height:36px; border-radius:999px; display:flex; align-items:center; justify-content:center; font-weight:800; font-size:13px; flex-shrink:0;}
.avatar-img{object-fit:cover; background:var(--line-soft);}
.reviewed-badge{font-size:11px; font-weight:800; color:var(--ok); flex-shrink:0;}
.conv-main{flex:1; min-width:0;}
.conv-top{display:flex; align-items:center; justify-content:space-between; gap:8px;}
.conv-name{font-size:13.5px; font-weight:700; color:var(--ink); white-space:nowrap; overflow:hidden; text-overflow:ellipsis;}
.conv-time{font-size:10.5px; color:var(--ink-mute); flex-shrink:0;}
.conv-preview{font-size:12px; color:var(--ink-soft); white-space:nowrap; overflow:hidden; text-overflow:ellipsis; margin-top:2px;}
.conv-meta{display:flex; align-items:center; gap:6px; margin-top:6px;}
.store-tag{font-size:10px; font-weight:700; padding:2px 7px; border-radius:999px; flex-shrink:0;}
.unread-badge{min-width:17px; height:17px; padding:0 5px; border-radius:999px; background:var(--accent); color:#fff; font-size:10px; font-weight:800; display:flex; align-items:center; justify-content:center; flex-shrink:0;}
.empty-state{padding:48px 20px; text-align:center; color:var(--ink-mute); font-size:13px;}
.load-more{width:100%; padding:12px; font-size:12.5px; font-weight:700; color:var(--accent); text-align:center;}
.load-more:hover{background:var(--ground);}

/* ---------- Coluna conversa aberta ---------- */
.chat-col{flex:1; display:flex; flex-direction:column; min-width:0; min-height:0; background:var(--ground);}
.chat-empty{flex:1; display:flex; align-items:center; justify-content:center; color:var(--ink-mute); font-size:13.5px;}
.chat-head{flex-shrink:0; background:var(--surface); border-bottom:1px solid var(--line); padding:14px 24px; display:flex; align-items:center; gap:12px;}
.chat-head .avatar{width:40px; height:40px; font-size:14px;}
.chat-head-main{flex:1; min-width:0;}
.chat-head-name{display:flex; align-items:center; gap:8px; flex-wrap:wrap;}
.chat-head-name strong{font-size:15px; font-weight:800;}
.chat-head-phone{font-size:12px; color:var(--ink-mute); margin-top:2px;}
.mode-pill{display:flex; align-items:center; gap:6px; padding:6px 12px; border-radius:999px; background:var(--accent-soft); color:var(--accent-ink); font-size:11.5px; font-weight:700; flex-shrink:0;}
.btn-reviewed.on{background:var(--ok-soft); border-color:#CFE8D9; color:#1F6B42;}
.btn-export{flex-shrink:0;}
.icon-btn{width:34px; height:34px; border-radius:9px; display:flex; align-items:center; justify-content:center; color:var(--ink-mute); border:1px solid transparent; flex-shrink:0;}
.icon-btn:hover{background:var(--ground); color:var(--ink);}
.icon-btn.on{background:var(--accent-soft); color:var(--accent-ink); border-color:var(--accent-soft);}

.chat-search-bar{flex-shrink:0; display:flex; align-items:center; gap:10px; padding:10px 24px; background:var(--surface); border-bottom:1px solid var(--line); color:var(--ink-mute);}
.chat-search-bar input{flex:1; border:none; outline:none; background:transparent; font-size:13.5px; color:var(--ink);}
.chat-search-count{font-size:11.5px; color:var(--ink-mute); white-space:nowrap; flex-shrink:0;}

.bubble.highlighted{animation:bubble-flash 2.2s ease-out;}
@keyframes bubble-flash{
  0%{box-shadow:0 0 0 3px var(--s4);}
  70%{box-shadow:0 0 0 3px var(--s4);}
  100%{box-shadow:0 1px 2px rgba(16,24,40,.04);}
}
.messages-wrap{flex:1; overflow-y:auto; padding:22px 26px; display:flex; flex-direction:column; gap:10px;}
.msg-row{display:flex;}
.msg-row.out{justify-content:flex-end;}
.bubble{max-width:440px; padding:10px 14px; border-radius:14px; font-size:13.5px; line-height:1.5; box-shadow:0 1px 2px rgba(16,24,40,.04); white-space:pre-wrap; word-break:break-word;}
.bubble.in{background:var(--surface); color:var(--ink);}
.bubble.out{background:var(--accent); color:#fff;}
.bubble code{font-family:'IBM Plex Mono',ui-monospace,monospace; background:rgba(0,0,0,0.06); padding:1px 4px; border-radius:4px; font-size:0.93em;}
.bubble.out code{background:rgba(255,255,255,0.18);}
.bubble img{max-width:280px; border-radius:8px; display:block; margin-bottom:6px; cursor:pointer;}
.bubble img.sticker-img{max-width:120px; border-radius:0; cursor:default; background:none;}
.voice-player{display:flex; align-items:center; gap:9px; min-width:200px; max-width:260px; padding:2px 0 6px;}
.voice-play-btn{width:32px; height:32px; border-radius:999px; background:var(--accent); color:#fff; display:flex; align-items:center; justify-content:center; flex-shrink:0;}
.bubble.out .voice-play-btn{background:rgba(255,255,255,0.25);}
.voice-track{flex:1; height:20px; display:flex; align-items:center; cursor:pointer; position:relative;}
.voice-track::before{content:''; position:absolute; left:0; right:0; height:3px; border-radius:999px; background:rgba(0,0,0,0.12);}
.bubble.out .voice-track::before{background:rgba(255,255,255,0.3);}
.voice-track-fill{position:absolute; left:0; height:3px; border-radius:999px; background:var(--accent); pointer-events:none;}
.bubble.out .voice-track-fill{background:#fff;}
.voice-track-thumb{position:absolute; top:50%; width:10px; height:10px; border-radius:999px; background:var(--accent); transform:translate(-50%,-50%); box-shadow:0 1px 2px rgba(0,0,0,.18); pointer-events:none;}
.bubble.out .voice-track-thumb{background:#fff;}
.voice-time{font-size:10.5px; color:var(--ink-mute); flex-shrink:0; min-width:30px; text-align:right;}
.bubble.out .voice-time{color:rgba(255,255,255,0.8);}
.bubble video{display:block; max-width:280px; border-radius:8px; margin-bottom:6px;}
.bubble .doc-link{display:flex; align-items:center; gap:9px; padding:8px 10px; border-radius:9px; background:rgba(0,0,0,0.05); margin-bottom:6px; max-width:260px;}
.bubble.out .doc-link{background:rgba(255,255,255,0.16);}
.bubble .doc-ext{font-size:10px; font-weight:800; padding:4px 6px; border-radius:5px; background:var(--accent); color:#fff; flex-shrink:0; max-width:52px; overflow:hidden; text-overflow:ellipsis; white-space:nowrap;}
.bubble .doc-name{font-size:12.5px; overflow:hidden; text-overflow:ellipsis; white-space:nowrap;}
.bubble-time{font-size:10px; opacity:0.6; margin-top:5px; text-align:right;}
.load-older{align-self:center; font-size:12px; font-weight:700; color:var(--accent); padding:8px 14px; border-radius:999px; background:var(--surface); border:1px solid var(--line);}
.composer-wrap{flex-shrink:0; padding:14px 24px 20px;}
.reply-toggle{display:flex; align-items:center; gap:8px; height:40px; padding:0 16px; border-radius:10px; border:1px dashed var(--line); background:var(--surface); color:var(--ink-mute); font-size:13px; font-weight:600;}
.reply-toggle:hover{color:var(--accent); border-color:var(--accent);}
.reply-box{display:flex; align-items:center; gap:10px; background:var(--surface); border:1px solid var(--line); border-radius:12px; padding:8px 8px 8px 16px;}
.reply-box input{flex:1; border:none; outline:none; font-size:13.5px; background:transparent; color:var(--ink);}
.btn-ghost{height:34px; padding:0 14px; border-radius:9px; border:1px solid var(--line); background:var(--ground); font-size:12.5px; font-weight:700; color:var(--ink-soft);}
.btn-send{height:34px; padding:0 16px; border-radius:9px; background:var(--accent); color:#fff; font-size:12.5px; font-weight:700;}
.btn-send:disabled{opacity:0.5;}

@media (max-width: 860px){
  .stores-col{width:72px;}
  .store-name{display:none;}
  .list-col{width:300px;}
}
