/* KZap — visual inspirado no WhatsApp Web */
:root {
  --green: #00a884;
  --green-dark: #008069;
  --teal-bg: #d1d7db;
  --panel: #ffffff;
  --panel-2: #f0f2f5;
  --border: #e9edef;
  --text: #111b21;
  --muted: #667781;
  --chat-bg: #efeae2;
  --bubble-in: #ffffff;
  --bubble-out: #d9fdd3;
  --system: #ffeecd;
  --blue-tick: #53bdeb;
  --danger: #ea0038;
  --hover: #f5f6f6;
  --active: #f0f2f5;
  --shadow: 0 1px .5px rgba(11,20,26,.13);
  font-synthesis: none;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: "Segoe UI", -apple-system, BlinkMacSystemFont, Roboto, "Helvetica Neue", Helvetica, Arial, sans-serif;
  font-size: 14.2px; color: var(--text); background: var(--teal-bg);
  -webkit-font-smoothing: antialiased;
}
button { font: inherit; cursor: pointer; }
input, textarea, select { font: inherit; color: inherit; }
.hidden { display: none !important; }

/* --- Login ---------------------------------------------------------------- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px;
  background: linear-gradient(var(--green) 0 220px, var(--panel-2) 220px); }
.login { background: #fff; width: 100%; max-width: 400px; border-radius: 4px; padding: 40px 36px; box-shadow: 0 17px 50px rgba(11,20,26,.19); }
.login h1 { margin: 0 0 6px; font-weight: 400; font-size: 26px; display: flex; gap: 10px; align-items: center; }
.login p { color: var(--muted); margin: 0 0 24px; }
.field { display: grid; gap: 6px; margin-bottom: 14px; }
.field label { font-size: 13px; color: var(--muted); }
.input { width: 100%; padding: 10px 12px; border: 1px solid #d1d7db; border-radius: 8px; background: #fff; outline: none; }
.input:focus { border-color: var(--green); box-shadow: 0 0 0 1px var(--green); }
.btn { border: 0; border-radius: 24px; padding: 9px 20px; background: var(--green); color: #fff; font-weight: 500; }
.btn:hover { background: var(--green-dark); }
.btn.ghost { background: transparent; color: var(--green-dark); border: 1px solid #d1d7db; }
.btn.ghost:hover { background: var(--hover); }
.btn.danger { background: var(--danger); }
.btn.small { padding: 5px 12px; font-size: 13px; }
.btn:disabled { opacity: .55; cursor: default; }
.error { color: var(--danger); font-size: 13px; min-height: 18px; }

/* --- Layout principal ----------------------------------------------------- */
.shell { height: 100vh; height: 100dvh; display: flex; max-width: 1700px; margin: 0 auto; background: var(--panel); box-shadow: 0 6px 18px rgba(11,20,26,.05); }
@media (min-width: 1441px) { .shell { height: calc(100vh - 38px); margin-top: 19px; } body::before { content: ""; position: fixed; inset: 0 0 auto 0; height: 127px; background: var(--green); z-index: -1; } }

.rail { width: 76px; flex: none; background: var(--panel-2); border-right: 1px solid var(--border); display: flex; flex-direction: column; align-items: center; padding: 10px 0; gap: 2px; overflow-y: auto; }
.rail .sp { flex: 1; min-height: 8px; }
.rail-sep { width: 40px; height: 1px; background: #d1d7db; margin: 6px 0; flex: none; }
.rail button { position: relative; border: 0; background: transparent; color: #54656f; display: grid; place-items: center; flex: none; }
.rail button.tab-btn { width: 64px; padding: 7px 0 5px; border-radius: 12px; gap: 2px; }
.rail button.round { width: 40px; height: 40px; border-radius: 50%; margin-top: 4px; }
.rail button:hover { background: #dfe3e5; }
.rail button.on { background: #d9fdd3; color: #008069; }
.rail button.on .lb { font-weight: 600; }
.rail button svg { width: 24px; height: 24px; }
.rail .lb { font-size: 10.5px; line-height: 13px; white-space: nowrap; }
.rail .badge { position: absolute; top: 2px; right: 8px; min-width: 18px; height: 18px; font-size: 11px; padding: 0 5px; }
.wa-dot { width: 10px; height: 10px; border-radius: 50%; position: absolute; bottom: 6px; right: 6px; border: 2px solid var(--panel-2); background: #8696a0; }
.wa-dot.open { background: #25d366; } .wa-dot.qr, .wa-dot.closed { background: var(--danger); }

.side { width: 30%; min-width: 320px; max-width: 460px; flex: none; display: flex; flex-direction: column; border-right: 1px solid var(--border); background: var(--panel); }
.side-head { height: 59px; padding: 10px 16px; display: flex; align-items: center; justify-content: space-between; }
.side-head h2 { margin: 0; font-size: 22px; font-weight: 600; }
.icon-btn { width: 40px; height: 40px; border: 0; background: transparent; border-radius: 50%; display: grid; place-items: center; color: #54656f; }
.icon-btn:hover { background: var(--panel-2); }
.icon-btn svg { width: 24px; height: 24px; }
.search { padding: 4px 12px 8px; }
.search-box { display: flex; align-items: center; gap: 12px; background: var(--panel-2); border-radius: 8px; padding: 0 12px; height: 36px; color: #54656f; }
.search-box input { border: 0; outline: 0; background: transparent; flex: 1; }
.search-box svg { width: 18px; height: 18px; flex: none; }
.chips { display: none; gap: 8px; padding: 2px 12px 10px; overflow-x: auto; scrollbar-width: none; }
.chip { border: 0; border-radius: 16px; padding: 6px 12px; background: var(--panel-2); color: #54656f; white-space: nowrap; font-size: 14px; display: inline-flex; gap: 6px; align-items: center; }
.chip:hover { background: #e4e7ea; }
.chip.on { background: #e7fce3; color: #008069; font-weight: 500; }
.chip .n { font-size: 12px; background: #fff; border-radius: 10px; padding: 0 6px; }
.chip.on .n { background: var(--green); color: #fff; }

.list { flex: 1; overflow-y: auto; }
.qfilter { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 12px 10px; }
.qfilter:empty { display: none; }
.qf { border: 1px solid var(--border); background: #fff; border-radius: 18px; padding: 5px 6px 5px 12px; display: inline-flex; align-items: center; gap: 8px; color: #54656f; font-size: 13.5px; }
.qf:hover { background: var(--hover); }
.qf b { min-width: 22px; height: 22px; border-radius: 11px; background: var(--panel-2); display: inline-grid; place-items: center; font-size: 12px; padding: 0 6px; color: #8696a0; }
.qf.has b { background: #fff3c4; color: #7a5b00; }
.qf.on { background: #e7fce3; border-color: #a6e3b4; color: #008069; font-weight: 600; }
.qf.on b { background: var(--green); color: #fff; }
.item { display: flex; gap: 13px; padding: 0 0 0 13px; cursor: pointer; align-items: center; }
.item:hover { background: var(--hover); }
.item.on { background: var(--active); }
.item .body { flex: 1; min-width: 0; border-bottom: 1px solid var(--border); padding: 12px 15px 12px 0; }
.item .row { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.item .name { font-size: 17px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item .time { font-size: 12px; color: var(--muted); flex: none; }
.item.unread .time { color: #1fa855; font-weight: 500; }
.item .preview { color: var(--muted); font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1; }
.item .meta { display: flex; gap: 6px; margin-top: 3px; flex-wrap: wrap; }
.tag { font-size: 11.5px; border-radius: 4px; padding: 1px 6px; background: var(--panel-2); color: #54656f; white-space: nowrap; }
.tag.q { background: #fff3c4; color: #7a5b00; }
.tag.bot { background: #e6e0fa; color: #4b3a99; }
.tag.agent { background: #dcf4ff; color: #0a5a80; }
.tag.wait-long { background: #ffe1e6; color: #a1002b; }
.badge { min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px; background: #25d366; color: #fff; font-size: 12px; font-weight: 600; display: inline-grid; place-items: center; }
.empty-list { color: var(--muted); text-align: center; padding: 40px 24px; font-size: 14px; }

.avatar { width: 49px; height: 49px; border-radius: 50%; flex: none; display: grid; place-items: center; color: #fff; font-weight: 500; font-size: 18px; }
.avatar.sm { width: 40px; height: 40px; font-size: 15px; }
.avatar.xs { width: 32px; height: 32px; font-size: 13px; }
.avatar.lg { width: 120px; height: 120px; font-size: 44px; }

/* --- Chat ----------------------------------------------------------------- */
.main { flex: 1; display: flex; min-width: 0; position: relative; }
.chat { flex: 1; display: flex; flex-direction: column; min-width: 0; background: var(--chat-bg); position: relative; }
.chat::before { content: ""; position: absolute; inset: 0; opacity: .06; pointer-events: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='80' height='80' viewBox='0 0 80 80'%3E%3Cg fill='none' stroke='%23000' stroke-width='1.4'%3E%3Ccircle cx='14' cy='14' r='5'/%3E%3Cpath d='M50 10l8 8m0-8l-8 8M30 46h12M36 40v12M62 52c4 0 6 3 6 6s-2 6-6 6-6-3-6-6M10 56l6 10h-12z'/%3E%3C/g%3E%3C/svg%3E"); }
.chat-head { height: 59px; background: var(--panel-2); display: flex; align-items: center; gap: 13px; padding: 10px 16px; border-left: 1px solid var(--border); z-index: 2; flex: none; }
.chat-head .who { flex: 1; min-width: 0; cursor: pointer; }
.chat-head .who .n { font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-head .who .s { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-head .actions { display: flex; gap: 6px; align-items: center; }
.back { display: none; }

.msgs { flex: 1; overflow-y: auto; padding: 16px 7% 8px; z-index: 1; display: flex; flex-direction: column; }
.msgs .more { align-self: center; margin: 4px 0 12px; }
.conv-sep { align-self: stretch; display: flex; align-items: center; gap: 10px; color: #54656f; font-size: 12px; margin: 14px 0 4px; }
.conv-sep::before, .conv-sep::after { content: ""; flex: 1; border-top: 1px dashed #b7c3c9; }
.conv-sep span { background: #e1f2fb; border-radius: 7px; padding: 4px 10px; box-shadow: var(--shadow); }
.msearch { background: var(--panel-2); border-bottom: 1px solid var(--border); padding: 8px 14px; position: relative; z-index: 3; flex: none; }
.msearch .row { display: flex; gap: 8px; align-items: center; }
.msearch input { flex: 1; }
.msearch .res { position: absolute; left: 14px; right: 14px; top: 100%; background: #fff; border-radius: 8px; box-shadow: 0 8px 28px rgba(11,20,26,.22); max-height: 55vh; overflow-y: auto; }
.msearch .r { padding: 9px 12px; border-bottom: 1px solid #f0f2f5; cursor: pointer; font-size: 13.5px; }
.msearch .r:hover { background: #f5f6f6; }
.msearch .r .m { color: var(--muted); font-size: 12px; margin-bottom: 2px; }
.msearch .r mark { background: #fdf3b0; color: inherit; padding: 0 1px; border-radius: 2px; }
.msearch .empty { padding: 12px; color: var(--muted); font-size: 13px; }
.flash { animation: flash 2.2s ease; }
@keyframes flash { 0%, 40% { box-shadow: 0 0 0 4px #f7d84a; } 100% { box-shadow: none; } }
.day { align-self: center; background: #fff; color: var(--muted); font-size: 12.5px; padding: 5px 12px; border-radius: 7.5px; box-shadow: var(--shadow); margin: 10px 0; text-transform: uppercase; }
.sys { align-self: center; background: var(--system); color: #54656f; font-size: 12.5px; padding: 5px 12px; border-radius: 7.5px; box-shadow: var(--shadow); margin: 6px 0; text-align: center; max-width: 80%; }
.bubble { max-width: min(65%, 560px); padding: 6px 7px 8px 9px; border-radius: 7.5px; box-shadow: var(--shadow); margin: 1px 0; position: relative; word-wrap: break-word; overflow-wrap: anywhere; }
.bubble.in { background: var(--bubble-in); align-self: flex-start; }
.bubble.out { background: var(--bubble-out); align-self: flex-end; }
.bubble.first { margin-top: 10px; }
.bubble.first.in { border-top-left-radius: 0; }
.bubble.first.out { border-top-right-radius: 0; }
.bubble.first.in::before, .bubble.first.out::before { content: ""; position: absolute; top: 0; width: 8px; height: 13px; }
.bubble.first.in::before { left: -8px; background: linear-gradient(to bottom left, var(--bubble-in) 50%, transparent 50%); }
.bubble.first.out::before { right: -8px; background: linear-gradient(to bottom right, var(--bubble-out) 50%, transparent 50%); }
.bubble .who { font-size: 12.8px; font-weight: 500; color: #027eb5; margin-bottom: 2px; }
.bubble .who.bot { color: #6b4fd8; }
.bubble .txt { white-space: pre-wrap; line-height: 19px; }
.bubble .foot { float: right; margin: 6px 0 -5px 10px; font-size: 11px; color: var(--muted); display: inline-flex; gap: 3px; align-items: center; position: relative; top: 2px; }
.bubble .foot svg { width: 16px; height: 11px; }
.bubble .foot .ok { color: var(--blue-tick); }
.bubble.failed { outline: 1px solid var(--danger); }
.bubble .fail { color: var(--danger); font-size: 12px; margin-top: 4px; display: flex; gap: 8px; align-items: center; }
.bubble .fail button { border: 0; background: none; color: var(--danger); text-decoration: underline; padding: 0; }
.bubble img.media, .bubble video.media { display: block; max-width: 100%; width: 330px; max-height: 380px; object-fit: cover; border-radius: 6px; margin: -3px -4px 4px -6px; background: #0001; cursor: pointer; }
.bubble video.media { object-fit: contain; background: #000; }
.bubble img.sticker { width: 150px; height: 150px; object-fit: contain; display: block; }
.bubble.sticker-wrap { background: transparent !important; box-shadow: none; }
.bubble.sticker-wrap::before { display: none; }
.bubble audio { width: 280px; max-width: 100%; display: block; }
.doc { display: flex; gap: 10px; align-items: center; background: #0000000d; padding: 10px; border-radius: 6px; color: inherit; text-decoration: none; min-width: 220px; margin-bottom: 2px; }
.doc .ic { width: 32px; height: 40px; background: #e2e2e2; border-radius: 3px; display: grid; place-items: center; font-size: 10px; font-weight: 700; color: #fff; }
.doc .ic.pdf { background: #e34c3c; }
.doc .nm { font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 220px; }

.composer { min-height: 62px; background: var(--panel-2); display: flex; align-items: flex-end; gap: 8px; padding: 10px 16px; z-index: 2; flex: none; position: relative; }
.composer textarea { flex: 1; resize: none; border: 0; outline: 0; border-radius: 8px; padding: 9px 12px; max-height: 120px; min-height: 42px; line-height: 22px; background: #fff; }
.composer .icon-btn { flex: none; }
.composer .send { color: #54656f; }
.composer .rec { color: var(--danger); font-variant-numeric: tabular-nums; flex: 1; align-self: center; display: flex; gap: 10px; align-items: center; }
.composer .rec .dot { width: 10px; height: 10px; background: var(--danger); border-radius: 50%; animation: blink 1s infinite; }
@keyframes blink { 50% { opacity: .2; } }
.takeover { background: var(--panel-2); padding: 14px 16px; text-align: center; z-index: 2; display: flex; gap: 12px; justify-content: center; align-items: center; flex-wrap: wrap; color: var(--muted); }

.stk-pop { position: absolute; bottom: 100%; left: 16px; width: min(420px, calc(100% - 32px)); background: #fff; border-radius: 10px; box-shadow: 0 6px 24px rgba(0,0,0,.2); margin-bottom: 6px; z-index: 5; }
.stk-pop .hd { display: flex; align-items: center; justify-content: space-between; padding: 8px 12px; border-bottom: 1px solid var(--border); font-weight: 600; font-size: 13.5px; }
.stk-pop .grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; padding: 10px; max-height: 300px; overflow-y: auto; }
.stk-pop .it { position: relative; aspect-ratio: 1; border-radius: 8px; cursor: pointer; display: flex; align-items: center; justify-content: center; }
.stk-pop .it:hover { background: var(--panel-2); }
.stk-pop .it img { max-width: 88%; max-height: 88%; }
.stk-pop .it .del { position: absolute; top: 2px; right: 2px; display: none; border: 0; background: #fff; border-radius: 50%; width: 22px; height: 22px; cursor: pointer; box-shadow: var(--shadow); font-size: 11px; }
.stk-pop .it:hover .del { display: block; }
.stk-pop .empty { grid-column: 1 / -1; color: var(--muted); font-size: 13px; padding: 14px 4px; text-align: center; }
.qr-pop { position: absolute; bottom: 100%; left: 16px; right: 16px; background: #fff; border-radius: 8px; box-shadow: 0 4px 16px rgba(0,0,0,.18); max-height: 260px; overflow-y: auto; margin-bottom: 6px; }
.qr-pop div { padding: 9px 14px; cursor: pointer; border-bottom: 1px solid var(--border); }
.qr-pop div.on, .qr-pop div:hover { background: var(--panel-2); }
.qr-pop b { color: var(--green-dark); margin-right: 8px; }
.qr-pop span { color: var(--muted); }

.upload-preview { position: absolute; inset: 0; background: var(--panel-2); z-index: 5; display: flex; flex-direction: column; }
.upload-preview .top { height: 59px; display: flex; align-items: center; gap: 12px; padding: 0 16px; background: var(--panel-2); }
.upload-preview .stage { flex: 1; display: grid; place-items: center; padding: 20px; min-height: 0; }
.upload-preview .stage img, .upload-preview .stage video { max-width: 100%; max-height: 100%; border-radius: 6px; box-shadow: 0 2px 12px #0002; }
.upload-preview .bottom { display: flex; gap: 12px; padding: 12px 16px 20px; align-items: center; justify-content: center; }
.upload-preview .bottom input { max-width: 560px; flex: 1; }
.fab { width: 56px; height: 56px; border-radius: 50%; border: 0; background: var(--green); color: #fff; display: grid; place-items: center; box-shadow: 0 2px 6px #0003; }
.fab svg { width: 26px; height: 26px; }
.progress { height: 4px; background: #0001; width: 100%; max-width: 560px; border-radius: 2px; overflow: hidden; }
.progress i { display: block; height: 100%; background: var(--green); width: 0; transition: width .2s; }

.welcome { flex: 1; display: grid; place-items: center; background: #f0f2f5; border-bottom: 6px solid #25d366; text-align: center; color: var(--muted); padding: 24px; }
.welcome h1 { color: #41525d; font-weight: 300; font-size: 32px; margin: 18px 0 10px; }
.welcome p { max-width: 460px; line-height: 20px; margin: 0 auto; }

/* --- Gaveta de contato ---------------------------------------------------- */
.drawer { width: 30%; min-width: 300px; max-width: 420px; background: var(--panel-2); border-left: 1px solid var(--border); display: flex; flex-direction: column; overflow: hidden; }
.drawer .head { height: 59px; display: flex; align-items: center; gap: 16px; padding: 0 16px; background: var(--panel); border-bottom: 1px solid var(--border); flex: none; }
.drawer .scroll { overflow-y: auto; flex: 1; }
.card { background: #fff; padding: 16px 24px; margin-bottom: 10px; box-shadow: 0 1px 3px rgba(11,20,26,.08); }
.card h4 { margin: 0 0 12px; font-weight: 400; color: var(--muted); font-size: 14px; }
.profile { text-align: center; padding: 28px 24px; }
.profile .n { font-size: 22px; margin-top: 14px; }
.profile .p { color: var(--muted); font-size: 16px; margin-top: 4px; }
.hist { display: flex; justify-content: space-between; padding: 8px 0; border-bottom: 1px solid var(--border); font-size: 13.5px; gap: 8px; }
.hist:last-child { border: 0; }

/* --- Páginas de administração -------------------------------------------- */
.page { flex: 1; overflow-y: auto; background: var(--panel-2); }
.page-inner { max-width: 1040px; margin: 0 auto; padding: 24px; }
.page h2 { font-weight: 500; margin: 0 0 18px; font-size: 22px; }
.page h3 { font-weight: 500; font-size: 16px; margin: 0 0 12px; }
.panel { background: #fff; border-radius: 10px; padding: 20px; margin-bottom: 18px; box-shadow: 0 1px 3px rgba(11,20,26,.08); }
.panel .hint { color: var(--muted); font-size: 13px; margin: -6px 0 14px; line-height: 18px; }
.tabs { display: flex; gap: 6px; margin-bottom: 18px; flex-wrap: wrap; }
table.t { width: 100%; border-collapse: collapse; }
table.t th { text-align: left; font-weight: 500; color: var(--muted); font-size: 12.5px; padding: 8px 10px; border-bottom: 1px solid var(--border); }
table.t td { padding: 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.t tr:last-child td { border: 0; }
table.t td.num, table.t th.num { text-align: right; font-variant-numeric: tabular-nums; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; }
.form-row .field { flex: 1; min-width: 160px; margin: 0; }
textarea.input { min-height: 70px; resize: vertical; }
.check { display: flex; gap: 8px; align-items: center; margin: 8px 0; cursor: pointer; }
.check input { accent-color: var(--green); width: 16px; height: 16px; }
.pill-list { display: flex; flex-wrap: wrap; gap: 6px; }
.online-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: #c3c9cc; margin-right: 6px; }
.online-dot.on { background: #25d366; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 18px; }
.kpi { background: #fff; border-radius: 10px; padding: 16px; box-shadow: 0 1px 3px rgba(11,20,26,.08); }
.kpi .l { color: var(--muted); font-size: 13px; }
.kpi .v { font-size: 28px; margin-top: 6px; font-variant-numeric: tabular-nums; }
.kpi .v small { font-size: 14px; color: var(--muted); }
.bars { display: flex; align-items: flex-end; gap: 3px; height: 150px; padding-top: 10px; }
.bars .b { flex: 1; background: var(--green); border-radius: 3px 3px 0 0; min-height: 2px; position: relative; }
.bars .b:hover { background: var(--green-dark); }
.bars .b:hover::after { content: attr(data-t); position: absolute; bottom: 100%; left: 50%; transform: translateX(-50%); background: #111b21; color: #fff; font-size: 11px; padding: 3px 6px; border-radius: 4px; white-space: nowrap; margin-bottom: 4px; }
.axis { display: flex; gap: 3px; font-size: 10.5px; color: var(--muted); margin-top: 4px; }
.axis span { flex: 1; text-align: center; overflow: hidden; white-space: nowrap; }
.qr-box { display: flex; gap: 32px; align-items: center; flex-wrap: wrap; }
.qr-box img { width: 264px; height: 264px; border: 1px solid var(--border); border-radius: 8px; }
.qr-box ol { line-height: 30px; color: #3b4a54; font-size: 15px; padding-left: 20px; }
.status-pill { display: inline-flex; align-items: center; gap: 8px; padding: 6px 12px; border-radius: 16px; background: var(--panel-2); font-weight: 500; }

/* --- Modal e toast -------------------------------------------------------- */
.modal-bg { position: fixed; inset: 0; background: rgba(11,20,26,.45); display: grid; place-items: center; z-index: 50; padding: 16px; }
.modal { background: #fff; border-radius: 10px; width: 100%; max-width: 460px; max-height: 90vh; overflow-y: auto; padding: 22px 24px; box-shadow: 0 17px 50px rgba(11,20,26,.25); }
.modal h3 { margin: 0 0 16px; font-weight: 500; font-size: 18px; }
.modal .foot { display: flex; gap: 10px; justify-content: flex-end; margin-top: 18px; }
.opt { display: flex; align-items: center; gap: 12px; padding: 10px; border-radius: 8px; cursor: pointer; }
.opt:hover { background: var(--panel-2); }
.opt .sub { color: var(--muted); font-size: 12.5px; }
.modal .sec { font-size: 12.5px; color: var(--green-dark); font-weight: 500; text-transform: uppercase; margin: 12px 0 4px; letter-spacing: .03em; }
#toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); z-index: 99; display: grid; gap: 8px; }
#toast div { background: #111b21; color: #fff; padding: 10px 18px; border-radius: 8px; box-shadow: 0 4px 12px #0003; animation: up .2s; }
#toast div.err { background: var(--danger); }
@keyframes up { from { transform: translateY(10px); opacity: 0; } }
.lightbox { position: fixed; inset: 0; background: rgba(233,237,239,.96); z-index: 60; display: grid; place-items: center; padding: 40px; cursor: zoom-out; }
.lightbox img, .lightbox video { max-width: 100%; max-height: 100%; box-shadow: 0 4px 30px #0003; }

.sim { position: fixed; right: 18px; bottom: 84px; z-index: 40; display: flex; flex-direction: column; align-items: flex-end; gap: 10px; }
.sim .box { background: #fff; border-radius: 10px; box-shadow: 0 6px 24px #0003; padding: 14px; width: 290px; }
.sim .box h4 { margin: 0 0 10px; font-weight: 500; }
.sim .box .input { margin-bottom: 8px; }

/* --- Responsivo (celular) ------------------------------------------------- */
@media (max-width: 860px) {
  .rail { display: none; }
  .side { width: 100%; max-width: none; min-width: 0; border: 0; }
  .shell.chat-open .side { display: none; }
  .shell:not(.chat-open) .main { display: none; }
  .back { display: grid; }
  .drawer { position: absolute; inset: 0; width: 100%; max-width: none; z-index: 10; }
  .msgs { padding: 12px 10px 6px; }
  .bubble { max-width: 85%; }
  .grid2 { grid-template-columns: 1fr; }
  .mobile-nav { display: flex !important; }
  .chips { display: flex; }
  .chat-head .actions .lbl { display: none; }
}
.mobile-nav { display: none; border-top: 1px solid var(--border); background: var(--panel); }
.mobile-nav button { flex: 1; border: 0; background: none; padding: 10px 0 12px; color: #54656f; font-size: 12px; display: grid; justify-items: center; gap: 2px; position: relative; }
.mobile-nav button.on { color: var(--green-dark); font-weight: 600; }
.mobile-nav svg { width: 22px; height: 22px; }
.mobile-nav .badge { position: absolute; top: 4px; left: calc(50% + 6px); }

/* --- CRM: barra de contexto, etiquetas, funil, agenda ------------------- */
.tag.stage { background: color-mix(in srgb, var(--c) 18%, #fff); color: color-mix(in srgb, var(--c) 70%, #000); }
.tag.ctag, .ctag { display: inline-flex; align-items: center; gap: 4px; font-size: 11.5px; border-radius: 10px; padding: 1px 8px; white-space: nowrap;
  background: color-mix(in srgb, var(--c) 16%, #fff); color: color-mix(in srgb, var(--c) 65%, #000); border: 1px solid color-mix(in srgb, var(--c) 35%, #fff); }
.ctag::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--c); }
.ctx { display: flex; align-items: center; gap: 8px; padding: 6px 16px; background: #fff; border-bottom: 1px solid var(--border); z-index: 2; flex-wrap: wrap; min-height: 42px; flex: none; }
.ctx .sp { flex: 1; }
.stage-pill { display: inline-flex; align-items: center; gap: 6px; border: 1px solid color-mix(in srgb, var(--c) 45%, #fff); background: color-mix(in srgb, var(--c) 14%, #fff); color: color-mix(in srgb, var(--c) 60%, #000); border-radius: 16px; padding: 3px 10px 3px 8px; font-size: 13px; font-weight: 500; }
.stage-pill svg { width: 14px; height: 14px; }
.cx-tags { display: flex; gap: 5px; align-items: center; flex-wrap: wrap; }
.cx-tags .ctag { cursor: pointer; }
.cx-add { border: 1px dashed #c3c9cc; background: none; border-radius: 12px; padding: 2px 9px; font-size: 12px; color: #667781; display: inline-flex; align-items: center; gap: 3px; }
.cx-add svg { width: 13px; height: 13px; }
.cx-add:hover { border-color: var(--green); color: var(--green-dark); }
.cx-btn { border: 0; background: var(--panel-2); color: #3b4a54; border-radius: 16px; padding: 4px 12px; font-size: 13px; display: inline-flex; gap: 5px; align-items: center; }
.cx-btn svg { width: 15px; height: 15px; }
.cx-btn:hover { background: #e4e7ea; }
.cx-link { border: 0; background: #fff3c4; color: #7a5b00; border-radius: 16px; padding: 4px 10px; font-size: 12.5px; }
.pmenu { position: fixed; z-index: 70; background: #fff; border-radius: 8px; box-shadow: 0 4px 18px rgba(0,0,0,.2); padding: 6px 0; min-width: 220px; }
.pmenu button { display: flex; align-items: center; gap: 10px; width: 100%; border: 0; background: none; padding: 9px 16px; text-align: left; }
.pmenu button:hover { background: var(--panel-2); }
.pmenu button.on { font-weight: 600; }
.pmenu i { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.pmenu hr { border: 0; border-top: 1px solid var(--border); margin: 6px 0; }
.tglist .check { margin: 6px 0; }
input.color { width: 38px; height: 34px; border: 1px solid #d1d7db; border-radius: 8px; padding: 2px; background: #fff; cursor: pointer; flex: none; }
.quick-when { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.quick-when .chip { font-size: 12.5px; padding: 4px 10px; }
.sub { color: var(--muted); font-size: 13px; }
.sched-row { display: flex; justify-content: space-between; gap: 10px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--border); }
.st { font-size: 11px; border-radius: 8px; padding: 1px 7px; margin-left: 6px; background: var(--panel-2); color: #54656f; font-weight: 500; }
.st.ok { background: #d9fdd3; color: #08703a; } .st.failed { background: #ffe1e6; color: #a1002b; } .st.off { opacity: .7; }
.qr-pop em.qmt { font-style: normal; font-size: 12px; background: var(--panel-2); border-radius: 8px; padding: 1px 7px; margin-right: 8px; color: #3b4a54; }
.qr-prev { max-width: 100%; max-height: 300px; border-radius: 8px; display: block; margin: 0 auto 10px; }
.qm-box { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; }
.qm-box .qr-prev { max-height: 160px; margin: 0; }
.qmedia:empty { display: none; }
.rail .badge.red { background: var(--danger); }

/* Funil */
.funnel-page { display: flex; flex-direction: column; overflow: hidden; }
.funnel-top { display: flex; align-items: center; gap: 10px; padding: 18px 20px 12px; flex-wrap: wrap; }
.funnel-top h2 { margin: 0 8px 0 0; font-size: 22px; font-weight: 500; }
.funnel-top .sel { width: auto; min-width: 180px; padding: 7px 10px; }
.funnel-top .sp { flex: 1; }
.hint-top { max-width: 360px; }
.board { flex: 1; display: flex; gap: 12px; overflow-x: auto; padding: 0 20px 20px; align-items: flex-start; min-height: 0; }
.col { width: 280px; flex: none; background: #e9edef; border-radius: 12px; display: flex; flex-direction: column; max-height: 100%; border-top: 4px solid var(--c); transition: background .15s; }
.col.over { background: #d9fdd3; }
.col header { display: flex; align-items: center; gap: 8px; padding: 10px 12px; font-weight: 600; color: #3b4a54; }
.col header i { width: 10px; height: 10px; border-radius: 50%; background: var(--c); }
.col header span { flex: 1; }
.col header b { background: #fff; border-radius: 10px; padding: 0 8px; font-size: 12px; color: #667781; }
.cards { overflow-y: auto; padding: 0 8px 8px; display: flex; flex-direction: column; gap: 8px; min-height: 60px; }
.col-empty { color: #8696a0; font-size: 12.5px; text-align: center; padding: 18px 6px; border: 1.5px dashed #c3c9cc; border-radius: 8px; }
.card-k { background: #fff; border-radius: 8px; padding: 10px; box-shadow: 0 1px 2px rgba(11,20,26,.12); cursor: grab; display: grid; gap: 6px; }
.card-k:hover { box-shadow: 0 3px 10px rgba(11,20,26,.15); }
.card-k.drag { opacity: .45; }
.kh { display: flex; gap: 8px; align-items: center; }
.kn { flex: 1; min-width: 0; display: grid; }
.kn b { font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kn span { font-size: 12px; color: var(--muted); }
.kt { display: flex; flex-wrap: wrap; gap: 4px; }
.kp { font-size: 12.5px; color: #54656f; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kf { display: flex; justify-content: space-between; font-size: 11.5px; color: #8696a0; gap: 6px; }
.ko { font-size: 11.5px; color: #027eb5; }

/* Agenda */
.ag-row { display: grid; grid-template-columns: 190px 1fr auto; gap: 14px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--border); }
.ag-row:last-child { border: 0; }
.ag-row.due .ag-when { color: #a1002b; font-weight: 600; }
.ag-row.off { opacity: .6; }
.ag-when { font-size: 13px; color: #3b4a54; display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
.ag-body a { color: inherit; }
.ag-act { display: flex; gap: 6px; align-items: center; }
#alerts { position: fixed; top: 16px; right: 16px; z-index: 80; display: grid; gap: 10px; width: 330px; }
.alert { background: #fff; border-radius: 10px; box-shadow: 0 8px 28px rgba(0,0,0,.25); padding: 14px; border-left: 5px solid #f59e0b; animation: up .2s; }
.alert .ah { font-weight: 600; display: flex; gap: 6px; align-items: center; }
.alert .ah svg { width: 18px; height: 18px; color: #f59e0b; }
.alert .ab { margin: 8px 0 12px; white-space: pre-wrap; }
.alert .af { display: flex; gap: 6px; flex-wrap: wrap; }
@media (max-width: 860px) {
  .ag-row { grid-template-columns: 1fr; gap: 4px; }
  .board { padding: 0 10px 10px; }
  .col { width: 250px; }
  .hint-top { display: none; }
  .ctx { padding: 6px 10px; }
  #alerts { left: 12px; right: 12px; width: auto; }
}

/* --- Central de agendamentos ------------------------------------------- */
.page-inner.wide { max-width: 1400px; }
.cal-page .page-inner { padding-bottom: 12px; }
.cal-bar { display: flex; align-items: center; gap: 6px; margin-bottom: 12px; flex-wrap: wrap; }
.cal-bar .sp { flex: 1; }
.cal-bar .sel { width: auto; min-width: 190px; padding: 6px 10px; }
.cal-label { font-size: 16px; font-weight: 500; margin-left: 8px; }
.seg { display: inline-flex; background: #fff; border: 1px solid #d1d7db; border-radius: 18px; overflow: hidden; }
.seg button { border: 0; background: none; padding: 6px 14px; font-size: 13px; color: #54656f; }
.seg button.on { background: #e7fce3; color: #008069; font-weight: 600; }
.cal { background: #fff; border-radius: 10px; box-shadow: 0 1px 3px rgba(11,20,26,.08); overflow: hidden; }
.grid-cal { display: flex; flex-direction: column; }
.gc-head { display: grid; grid-template-columns: 56px repeat(var(--cols), 1fr); border-bottom: 1px solid var(--border); }
.gc-head > div { text-align: center; padding: 8px 0; color: #667781; font-size: 12px; display: grid; }
.gc-head b { font-size: 20px; font-weight: 500; color: #3b4a54; }
.gc-head .today b { background: var(--green); color: #fff; border-radius: 50%; width: 34px; height: 34px; display: grid; place-items: center; margin: 2px auto 0; font-size: 17px; }
.gc-head .today span { color: var(--green-dark); font-weight: 600; }
.gc-body { display: grid; grid-template-columns: 56px repeat(var(--cols), 1fr); max-height: calc(100vh - 290px); overflow-y: auto; position: relative; }
.gc-hours div { font-size: 11px; color: #8696a0; text-align: right; padding-right: 8px; transform: translateY(-7px); }
.gc-hours div:first-child { transform: none; }
.gc-col { position: relative; border-left: 1px solid var(--border); }
.gc-col.today { background: #fbfffa; }
.slot { border-top: 1px solid #eef1f2; cursor: pointer; }
.slot.half { border-top: 1px dashed #f3f5f6; }
.slot:hover { background: #e7fce3; }
.ev { position: absolute; background: color-mix(in srgb, var(--c) 18%, #fff); border-left: 3px solid var(--c); border-radius: 5px; padding: 3px 6px; font-size: 11.5px; overflow: hidden; cursor: pointer; display: flex; flex-direction: column; line-height: 14px; box-shadow: 0 1px 2px #0001; z-index: 1; }
.ev:hover { box-shadow: 0 3px 10px #0002; z-index: 3; }
.ev b { font-weight: 600; color: #1f2c33; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ev span { color: #3b4a54; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ev em { font-style: normal; color: #667781; font-size: 10.5px; }
.ev.short { flex-direction: row; gap: 4px; align-items: center; padding: 1px 6px; }
.ev.short span, .ev.short em { display: none; }
.ev.canceled { opacity: .55; text-decoration: line-through; }
.ev.done, .ev.no_show { opacity: .75; }
.now-line { position: absolute; left: 0; right: 0; border-top: 2px solid #ea0038; z-index: 2; pointer-events: none; }
.now-line::before { content: ""; position: absolute; left: -5px; top: -6px; width: 10px; height: 10px; border-radius: 50%; background: #ea0038; }
.cal-legend { display: flex; gap: 14px; flex-wrap: wrap; margin-top: 10px; font-size: 12px; color: #667781; }
.cal-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }
.cl-day { padding: 12px 16px; border-bottom: 1px solid var(--border); }
.cl-day h4 { margin: 0 0 8px; font-weight: 500; color: var(--green-dark); text-transform: capitalize; }
.cl-row { display: flex; align-items: center; gap: 14px; padding: 8px 10px; border-radius: 8px; border-left: 4px solid var(--c); background: #fafbfb; margin-bottom: 6px; cursor: pointer; }
.cl-row:hover { background: #f0f2f5; }
.cl-row.canceled { opacity: .55; }
.cl-time { font-weight: 600; font-variant-numeric: tabular-nums; display: grid; min-width: 52px; }
.cl-time small { font-weight: 400; color: #8696a0; font-size: 11px; }
.cl-main { flex: 1; min-width: 0; }
.st-pill { display: inline-block; font-size: 11.5px; font-weight: 600; border-radius: 10px; padding: 2px 9px; background: color-mix(in srgb, var(--c) 20%, #fff); color: color-mix(in srgb, var(--c) 60%, #000); white-space: nowrap; }
.ad-head h3 { margin: 8px 0 12px; }
.ad-info { display: grid; gap: 7px; font-size: 14.5px; }
.ad-notes { background: #fff8e1; border-radius: 6px; padding: 8px 10px; white-space: pre-wrap; font-size: 13.5px; }
.ad-st { display: flex; gap: 6px; flex-wrap: wrap; }
.fixed-ct { display: flex; align-items: center; gap: 8px; padding: 6px 0; }
.ct-pick { position: relative; }
.ct-res { position: absolute; top: 100%; left: 0; right: 0; background: #fff; border-radius: 8px; box-shadow: 0 6px 18px #0003; z-index: 5; max-height: 220px; overflow-y: auto; margin-top: 4px; }
.ct-res div { display: flex; align-items: center; gap: 10px; padding: 8px 12px; cursor: pointer; }
.ct-res div:hover { background: var(--panel-2); }
.ct-res small { color: #8696a0; }
.cx-link.appt { background: #dcf4ff; color: #0a5a80; }
.modal { max-width: 520px; }
@media (max-width: 860px) {
  .gc-body { max-height: calc(100vh - 330px); }
  .cal-bar .sel { min-width: 0; flex: 1; }
}

/* --- Kora (IA) --------------------------------------------------------- */
.sys.ai { background: #ede7ff; color: #3b2a7a; text-align: left; white-space: pre-wrap; max-width: 70%; line-height: 19px; }
.ai-wrap { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 18px; align-items: start; }
.ai-test { position: sticky; top: 0; }
.ai-chat { background: var(--chat-bg); border-radius: 8px; height: 420px; overflow-y: auto; padding: 12px; display: flex; flex-direction: column; gap: 2px; }
.ai-chat .bubble.in { align-self: flex-end; background: var(--bubble-out); }
.ai-chat .bubble.out { align-self: flex-start; background: #fff; }
.ai-meta { font-size: 11.5px; color: #4b3a99; background: #f3efff; border-radius: 5px; padding: 4px 6px; margin-top: 6px; }
.ai-in { display: flex; gap: 8px; margin-top: 8px; }
@media (max-width: 1100px) { .ai-wrap { grid-template-columns: 1fr; } .ai-test { position: static; } }
.transcript { font-size: 13px; color: #3b4a54; background: #0000000a; border-radius: 6px; padding: 6px 8px; margin-top: 5px; max-width: 300px; white-space: pre-wrap; font-style: italic; }
.cx-ai { border: 1px solid #d6ccff; background: #f3efff; color: #4b3a99; border-radius: 16px; padding: 3px 10px; font-size: 12.5px; }
.cx-ai:hover { background: #e9e2ff; }
.cx-seller { border: 1px solid #b7e4d3; background: #eafaf3; color: #05674f; border-radius: 16px; padding: 3px 10px; font-size: 12.5px; }
.cx-seller:hover { background: #d9f5ea; }
.cx-seller.none { border-style: dashed; background: transparent; color: #667781; }
.mod-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; margin-top: 12px; }
.mod-card { border: 1px solid var(--border); border-radius: 8px; overflow: hidden; background: #fff; display: flex; flex-direction: column; }
.mod-card img { width: 100%; aspect-ratio: 1; object-fit: cover; cursor: zoom-in; background: #f0f2f5; display: block; }
.mod-card .mi { padding: 8px; display: flex; flex-direction: column; gap: 4px; flex: 1; }
.mod-card .mn { font-weight: 600; font-size: 13.5px; word-break: break-word; }
.mod-card .mt { font-size: 12px; color: var(--muted); white-space: pre-wrap; word-break: break-word; }
.mod-card .ma { display: flex; gap: 4px; margin-top: auto; padding-top: 6px; flex-wrap: wrap; }
.mod-card .ma .btn { padding: 3px 8px; font-size: 12px; }
.mod-card .input { font-size: 12.5px; padding: 5px 7px; }
.modal.wide { max-width: 860px; }
.mod-thumbs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 8px; }
.mod-thumbs img { width: 56px; height: 56px; object-fit: cover; border-radius: 6px; cursor: pointer; }
.to-model { display: block; margin: 4px 0 0; background: none; border: 0; color: #027eb5; font-size: 12px; cursor: pointer; padding: 0; }
.to-model:hover { text-decoration: underline; }
.cart-table td, .cart-table th { padding: 6px 8px; }
.cart-table select { max-width: 200px; }
.cx-ai.off { border-color: #ffd6a0; background: #fff4e5; color: #8a4b00; font-weight: 600; }
