:root {
  --blue: #1C97E1; --blue-600: #1580C2; --blue-50: #E8F4FC; --navy: #07223C; --navy-2: #0C2F50; --black: #020002;
  --bg: #F4F6F9; --card: #FFFFFF; --line: #E3E8EF; --line-2: #EEF1F5; --muted: #66758A; --text: #0F1B2A;
  --green: #12A36B; --green-50: #E6F6EF; --orange: #E8820E; --orange-50: #FDF1E3; --red: #D64545; --red-50: #FBEAEA;
  --gray-50: #F1F3F6; --purple: #7357D9; --purple-50: #EFEBFB;
  --radius: 12px; --shadow: 0 1px 2px rgba(7, 34, 60, .06), 0 4px 16px rgba(7, 34, 60, .05);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font-family: 'Inter', system-ui, -apple-system, sans-serif; font-size: 14px; color: var(--text); background: var(--bg); -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--blue); text-decoration: none; }
h1, h2, h3, h4 { margin: 0; letter-spacing: -0.01em; }
.hidden { display: none !important; }

/* Layout */
.app { display: grid; grid-template-columns: 236px 1fr; height: 100vh; }
.sidebar { background: var(--navy); color: #C9D6E3; display: flex; flex-direction: column; padding: 18px 12px; gap: 6px; overflow-y: auto; }
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 16px; color: #fff; }
.brand .logo { width: 34px; height: 34px; border-radius: 9px; background: var(--blue); display: grid; place-items: center; font-weight: 800; font-size: 15px; color: #fff; letter-spacing: -0.04em; }
.brand b { display: block; font-size: 15px; line-height: 1.1; }
.brand small { color: #8FA6BD; font-size: 11.5px; }
.ws-select { margin: 0 4px 12px; background: var(--navy-2); border: 1px solid #1A4269; color: #fff; border-radius: 9px; padding: 9px 10px; width: calc(100% - 8px); }
.nav a { display: flex; align-items: center; gap: 11px; padding: 9px 11px; border-radius: 9px; color: #C9D6E3; font-weight: 500; position: relative; }
.nav a:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav a.active { background: var(--blue); color: #fff; }
.nav a svg { width: 18px; height: 18px; flex: none; opacity: .9; }
.nav .badge-n { margin-left: auto; background: var(--red); color: #fff; font-size: 11px; font-weight: 700; border-radius: 10px; padding: 1px 7px; }
.nav-sep { height: 1px; background: rgba(255,255,255,.08); margin: 10px 6px; }
.nav-label { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: #6F89A3; padding: 6px 12px 2px; }
.sidebar-foot { margin-top: auto; padding: 12px 8px 0; font-size: 12.5px; color: #8FA6BD; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.sidebar-foot button { background: none; border: 0; color: #8FA6BD; cursor: pointer; padding: 4px; display: grid; }
.sidebar-foot button:hover { color: #fff; }
.sidebar-foot svg { width: 18px; height: 18px; }
.main { overflow: auto; display: flex; flex-direction: column; min-width: 0; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 22px 28px 6px; }
.topbar h1 { font-size: 22px; font-weight: 700; }
.topbar p { margin: 3px 0 0; color: var(--muted); }
.content { padding: 14px 28px 32px; flex: 1; min-height: 0; }
.live-dot { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--green); font-weight: 600; background: var(--green-50); padding: 4px 10px; border-radius: 20px; }
.live-dot::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: var(--green); animation: pulse 1.6s infinite; }
@keyframes pulse { 0%, 100% { opacity: 1 } 50% { opacity: .3 } }

/* Elements */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-h { display: flex; align-items: center; justify-content: space-between; padding: 16px 18px 0; gap: 10px; }
.card-h h3 { font-size: 15px; font-weight: 650; }
.card-b { padding: 16px 18px 18px; }
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: 1fr 1fr; } .g3 { grid-template-columns: repeat(3, 1fr); } .g4 { grid-template-columns: repeat(4, 1fr); } .g5 { grid-template-columns: repeat(5, 1fr); }
.row { display: flex; align-items: center; gap: 10px; } .wrap { flex-wrap: wrap; } .between { justify-content: space-between; } .grow { flex: 1; min-width: 0; }
.muted { color: var(--muted); } .small { font-size: 12.5px; } .tiny { font-size: 11.5px; } .bold { font-weight: 650; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; border: 1px solid var(--line); background: #fff; color: var(--text); padding: 8px 14px; border-radius: 9px; cursor: pointer; font-weight: 550; white-space: nowrap; transition: background .12s, border-color .12s; }
.btn:hover { background: var(--gray-50); }
.btn.primary { background: var(--blue); border-color: var(--blue); color: #fff; }
.btn.primary:hover { background: var(--blue-600); }
.btn.dark { background: var(--navy); border-color: var(--navy); color: #fff; }
.btn.danger { color: var(--red); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.sm { padding: 5px 10px; font-size: 12.5px; border-radius: 8px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn svg { width: 16px; height: 16px; }
.input, select.input, textarea.input { width: 100%; border: 1px solid var(--line); border-radius: 9px; padding: 9px 11px; background: #fff; outline: none; transition: border-color .12s, box-shadow .12s; }
.input:focus { border-color: var(--blue); box-shadow: 0 0 0 3px var(--blue-50); }
textarea.input { resize: vertical; min-height: 90px; line-height: 1.45; }
label.f { display: block; font-size: 12.5px; font-weight: 600; color: #3A4A5E; margin-bottom: 6px; }
.field { margin-bottom: 14px; }
.help { font-size: 12px; color: var(--muted); margin-top: 5px; line-height: 1.4; }
.badge { display: inline-flex; align-items: center; gap: 5px; font-size: 11.5px; font-weight: 600; padding: 3px 9px; border-radius: 20px; background: var(--gray-50); color: #435468; white-space: nowrap; }
.badge.blue { background: var(--blue-50); color: #0D6FAB; } .badge.green { background: var(--green-50); color: #0B7A4F; }
.badge.orange { background: var(--orange-50); color: #B05F00; } .badge.red { background: var(--red-50); color: #B23333; }
.badge.purple { background: var(--purple-50); color: #5A40BF; } .badge.navy { background: var(--navy); color: #fff; }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.chips { display: flex; flex-wrap: wrap; gap: 7px; }
.chip { border: 1px solid var(--line); background: #fff; padding: 6px 12px; border-radius: 20px; cursor: pointer; font-size: 13px; font-weight: 500; user-select: none; }
.chip.on { background: var(--blue); color: #fff; border-color: var(--blue); }
.empty { text-align: center; padding: 40px 20px; color: var(--muted); }
.empty b { display: block; color: var(--text); font-size: 15px; margin-bottom: 4px; }
table.t { width: 100%; border-collapse: collapse; }
table.t th { text-align: left; font-size: 12px; font-weight: 600; color: var(--muted); padding: 10px 14px; border-bottom: 1px solid var(--line); background: #FAFBFC; position: sticky; top: 0; }
table.t td { padding: 11px 14px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
table.t tr.click:hover td { background: #F8FAFC; cursor: pointer; }
.toggle { position: relative; width: 38px; height: 22px; flex: none; }
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle span { position: absolute; inset: 0; background: #C9D2DC; border-radius: 20px; cursor: pointer; transition: .15s; }
.toggle span::before { content: ''; position: absolute; width: 16px; height: 16px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: .15s; }
.toggle input:checked + span { background: var(--green); }
.toggle input:checked + span::before { transform: translateX(16px); }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 18px; }
.tabs button { background: none; border: 0; padding: 10px 14px; cursor: pointer; font-weight: 550; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs button.on { color: var(--blue); border-color: var(--blue); }
.progress { height: 8px; border-radius: 8px; background: var(--gray-50); overflow: hidden; display: flex; }
.progress i { display: block; height: 100%; }
.avatar { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: 13px; color: #fff; flex: none; }
.score { display: inline-flex; align-items: center; gap: 2px; }
.score i { width: 5px; height: 12px; border-radius: 2px; background: var(--line); }
.score i.on { background: var(--blue); }
.score.hot i.on { background: var(--orange); } .score.top i.on { background: var(--green); }

/* KPI */
.kpi { padding: 16px 18px; }
.kpi .lbl { color: var(--muted); font-size: 12.5px; font-weight: 550; display: flex; align-items: center; gap: 7px; }
.kpi .val { font-size: 27px; font-weight: 750; margin-top: 6px; letter-spacing: -0.02em; }
.kpi .sub { font-size: 12px; color: var(--muted); margin-top: 3px; }
.bars { display: flex; align-items: flex-end; gap: 6px; height: 120px; padding-top: 10px; }
.bars .b { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 5px; height: 100%; justify-content: flex-end; }
.bars .b i { width: 100%; max-width: 28px; background: var(--blue); border-radius: 5px 5px 2px 2px; min-height: 2px; }
.bars .b span { font-size: 10.5px; color: var(--muted); }
.hbar { display: grid; grid-template-columns: 120px 1fr 70px; align-items: center; gap: 10px; padding: 7px 0; }
.hbar .track { height: 10px; background: var(--gray-50); border-radius: 6px; overflow: hidden; display: flex; }
.hbar .track i { height: 100%; display: block; }
.feed-item { display: flex; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--line-2); align-items: flex-start; }
.feed-item:last-child { border-bottom: 0; }
.flash { animation: flash 1.6s ease-out; }
@keyframes flash { 0% { background: #FFF4D6; } 100% { background: transparent; } }

/* Kanban */
.kanban { display: grid; grid-template-columns: repeat(5, minmax(220px, 1fr)); gap: 14px; align-items: start; overflow-x: auto; padding-bottom: 8px; }
.col { background: #EBEFF4; border-radius: var(--radius); padding: 10px; min-height: 300px; }
.col.over { outline: 2px dashed var(--blue); background: var(--blue-50); }
.col-h { display: flex; align-items: center; justify-content: space-between; padding: 4px 6px 10px; font-weight: 650; }
.col-h .n { font-size: 12px; color: var(--muted); font-weight: 600; background: #fff; padding: 2px 8px; border-radius: 10px; }
.col-h .v { font-size: 11.5px; color: var(--muted); font-weight: 500; }
.kcard { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 11px 12px; margin-bottom: 8px; cursor: grab; box-shadow: 0 1px 2px rgba(7,34,60,.04); }
.kcard:hover { border-color: #C5D3E2; }
.kcard .nm { font-weight: 600; display: flex; align-items: center; justify-content: space-between; gap: 6px; }
.kcard .it { color: var(--muted); font-size: 12.5px; margin: 4px 0 8px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kcard .ft { display: flex; align-items: center; justify-content: space-between; gap: 6px; }
.unread { background: var(--red); color: #fff; font-size: 10.5px; font-weight: 700; border-radius: 10px; padding: 1px 6px; }

/* Conversas */
.inbox { display: grid; grid-template-columns: 310px 1fr 320px; height: calc(100vh - 110px); gap: 0; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.inbox .list { border-right: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; }
.inbox .list .search { padding: 12px; border-bottom: 1px solid var(--line); display: grid; gap: 8px; }
.inbox .items { overflow-y: auto; flex: 1; }
.conv { display: flex; gap: 10px; padding: 12px; border-bottom: 1px solid var(--line-2); cursor: pointer; }
.conv:hover { background: #F8FAFC; } .conv.on { background: var(--blue-50); }
.conv .top { display: flex; justify-content: space-between; gap: 6px; }
.conv .nm { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conv .pv { color: var(--muted); font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-top: 2px; }
.chat { display: flex; flex-direction: column; min-height: 0; background: #EFEAE2; }
.chat-h { background: #fff; padding: 12px 16px; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 10px; }
.msgs { flex: 1; overflow-y: auto; padding: 18px 22px; display: flex; flex-direction: column; gap: 6px; }
.msg { max-width: 68%; padding: 8px 11px 6px; border-radius: 9px; background: #fff; box-shadow: 0 1px 1px rgba(0,0,0,.06); white-space: pre-wrap; word-wrap: break-word; line-height: 1.4; }
.msg.out { align-self: flex-end; background: #D9FDD3; }
.msg.out.agente { background: #E3F1FC; }
.msg.out.disparo { background: #FFF6DB; }
.msg.sys { align-self: center; background: #FFF0F0; color: var(--red); font-size: 12px; }
.msg .meta { font-size: 10.5px; color: #6B7A8C; margin-top: 3px; text-align: right; display: flex; gap: 6px; justify-content: flex-end; }
.msg .who { font-size: 11px; font-weight: 650; color: #3B6E9A; margin-bottom: 2px; }
.day-sep { align-self: center; background: #fff; font-size: 11.5px; color: var(--muted); padding: 3px 10px; border-radius: 8px; margin: 8px 0; }
.composer { background: #F0F2F5; padding: 10px 14px; display: flex; gap: 10px; align-items: flex-end; }
.composer textarea { flex: 1; border: 0; border-radius: 9px; padding: 10px 12px; resize: none; min-height: 42px; max-height: 140px; outline: none; }
.side { border-left: 1px solid var(--line); overflow-y: auto; padding: 16px; }
.side h4 { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 18px 0 8px; }
.ai-box { background: linear-gradient(135deg, #F1F8FE, #F5F2FE); border: 1px solid #DCE9F7; border-radius: 10px; padding: 12px; font-size: 13px; line-height: 1.45; }

/* Modelos */
.tpl-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; }
.tpl-card { display: flex; flex-direction: column; }
.tpl-card .body { padding: 14px 16px; flex: 1; }
.tpl-card .bubble { background: #F3F6F9; border-radius: 9px; padding: 10px 12px; font-size: 13px; white-space: pre-wrap; line-height: 1.45; max-height: 150px; overflow: hidden; }
.tpl-card .foot { border-top: 1px solid var(--line-2); padding: 10px 16px; display: flex; gap: 6px; justify-content: flex-end; flex-wrap: wrap; }
.phone { width: 300px; background: #0B141A; border-radius: 34px; padding: 12px; box-shadow: 0 10px 40px rgba(7,34,60,.25); flex: none; }
.phone .scr { background: #EFEAE2; border-radius: 24px; overflow: hidden; height: 560px; display: flex; flex-direction: column; }
.phone .bar { background: #075E54; color: #fff; padding: 14px 14px 10px; display: flex; align-items: center; gap: 9px; }
.phone .bar .av { width: 32px; height: 32px; border-radius: 50%; background: #25D366; display: grid; place-items: center; font-weight: 700; font-size: 13px; }
.phone .feed { flex: 1; padding: 12px 10px; overflow-y: auto; display: flex; flex-direction: column; gap: 6px; }
.wa-b { background: #fff; border-radius: 8px; padding: 7px 9px 5px; font-size: 13px; line-height: 1.4; max-width: 88%; box-shadow: 0 1px 1px rgba(0,0,0,.08); white-space: pre-wrap; word-wrap: break-word; }
.wa-b.me { align-self: flex-end; background: #D9FDD3; }
.wa-b .h { font-weight: 700; margin-bottom: 4px; }
.wa-b .f { color: #8696A0; font-size: 12px; margin-top: 4px; }
.wa-b img { width: 100%; border-radius: 6px; margin-bottom: 6px; display: block; }
.wa-btn { background: #fff; border-radius: 8px; text-align: center; color: #00A5F4; font-size: 13px; padding: 8px; margin-top: 2px; max-width: 88%; box-shadow: 0 1px 1px rgba(0,0,0,.08); }
.phone .inp { background: #F0F2F5; padding: 8px; display: flex; gap: 6px; }
.phone .inp input { flex: 1; min-width: 0; border: 0; border-radius: 18px; padding: 9px 13px; outline: none; }
.phone .inp button { flex: none; border: 0; background: #00A884; color: #fff; border-radius: 50%; width: 38px; height: 38px; cursor: pointer; display: grid; place-items: center; }
.typing { font-size: 12px; color: #667781; padding: 2px 6px; font-style: italic; }

/* Modal / Drawer / Toast */
.overlay { position: fixed; inset: 0; background: rgba(7, 20, 34, .45); display: flex; align-items: flex-start; justify-content: center; padding: 40px 20px; z-index: 50; overflow-y: auto; }
.modal { background: #fff; border-radius: 14px; width: 100%; max-width: 640px; box-shadow: 0 20px 60px rgba(0,0,0,.25); }
.modal.lg { max-width: 980px; } .modal.xl { max-width: 1120px; }
.modal-h { padding: 18px 22px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; }
.modal-h h3 { font-size: 17px; }
.modal-b { padding: 20px 22px; }
.modal-f { padding: 14px 22px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 8px; background: #FAFBFC; border-radius: 0 0 14px 14px; }
.x { background: none; border: 0; cursor: pointer; font-size: 22px; color: var(--muted); line-height: 1; }
.toasts { position: fixed; right: 20px; bottom: 20px; display: grid; gap: 8px; z-index: 99; }
.toast { background: var(--navy); color: #fff; padding: 11px 16px; border-radius: 10px; box-shadow: var(--shadow); font-weight: 500; max-width: 380px; animation: up .2s ease-out; }
.toast.err { background: var(--red); } .toast.ok { background: var(--green); }
@keyframes up { from { transform: translateY(10px); opacity: 0; } }
.steps { display: flex; gap: 8px; margin-bottom: 18px; }
.steps div { flex: 1; padding: 9px 10px; border-radius: 9px; background: var(--gray-50); font-size: 12.5px; font-weight: 600; color: var(--muted); }
.steps div.on { background: var(--blue-50); color: #0D6FAB; } .steps div.done { background: var(--green-50); color: #0B7A4F; }
.pick { border: 1.5px solid var(--line); border-radius: 10px; padding: 12px 14px; cursor: pointer; margin-bottom: 8px; transition: border-color .1s; }
.pick:hover { border-color: #B9CBDD; } .pick.on { border-color: var(--blue); background: var(--blue-50); }
.code { font-family: ui-monospace, Menlo, monospace; font-size: 12px; background: var(--gray-50); padding: 8px 10px; border-radius: 8px; word-break: break-all; }
.notice { border-radius: 10px; padding: 11px 14px; font-size: 13px; line-height: 1.45; background: var(--blue-50); color: #0D4F7A; }
.notice.warn { background: var(--orange-50); color: #8A4A00; } .notice.err { background: var(--red-50); color: #8E2424; } .notice.ok { background: var(--green-50); color: #0A6A44; }

/* Login */
.login { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; }
.login .art { background: var(--navy); color: #fff; padding: 56px; display: flex; flex-direction: column; justify-content: space-between; position: relative; overflow: hidden; }
.login .art::after { content: ''; position: absolute; inset: 0; background-image: linear-gradient(rgba(28,151,225,.12) 1px, transparent 1px), linear-gradient(90deg, rgba(28,151,225,.12) 1px, transparent 1px); background-size: 34px 34px; mask-image: linear-gradient(160deg, transparent 20%, #000 90%); }
.login .art h2 { font-size: 34px; line-height: 1.15; max-width: 440px; position: relative; z-index: 1; }
.login .art h2 em { font-style: normal; color: var(--blue); }
.login form { align-self: center; justify-self: center; width: 100%; max-width: 360px; padding: 24px; }

@media (max-width: 1100px) { .g5, .g4 { grid-template-columns: repeat(2, 1fr); } .inbox { grid-template-columns: 280px 1fr; } .inbox .side { display: none; } }
.chat-h .grow { min-width: 0; } .chat-h .grow .tiny { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
