/* LinQ — tokens e componentes do design system (ver design_system/design-system.html) */
:root {
  --color-primary: #0B5FFF;
  --color-primary-hover: #0A4FD6;
  --color-primary-soft: #E8F0FF;
  --color-accent: #0891B2;
  --color-accent-soft: #E0F7FB;
  --color-success: #15803D;
  --color-success-soft: #DCFCE7;
  --color-warning: #B45309;
  --color-warning-soft: #FEF3C7;
  --color-danger: #B91C1C;
  --color-danger-soft: #FEE2E2;
  --color-ink: #0F172A;
  --color-text: #1E293B;
  --color-muted: #5B6B80;
  --color-border: #E2E8F0;
  --color-border-strong: #CBD5E1;
  --color-bg: #F4F6FA;
  --color-surface: #FFFFFF;
  --color-surface-2: #F8FAFC;
  --color-sidebar: #0B1730;
  --color-sidebar-text: #C7D2E5;
  --color-sidebar-active: #1B2C4F;
  --bubble-in: #FFFFFF;
  --bubble-out: #0B5FFF;
  --bubble-ai: #EEF2FF;
  --bubble-note: #FEF9C3;
  --font-sans: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, Consolas, monospace;
  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, .06);
  --shadow: 0 4px 16px rgba(15, 23, 42, .08);
  --shadow-lg: 0 18px 48px rgba(15, 23, 42, .18);
  --space-1: 4px; --space-2: 8px; --space-3: 12px; --space-4: 16px; --space-5: 24px; --space-6: 32px;
  --sidebar-w: 248px;
  --topbar-h: 60px;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; font-family: var(--font-sans); font-size: 14px; line-height: 1.5; color: var(--color-text); background: var(--color-bg); -webkit-font-smoothing: antialiased; }
a { color: var(--color-primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { color: var(--color-ink); margin: 0 0 var(--space-3); line-height: 1.25; }
h1 { font-size: 22px; font-weight: 700; }
h2 { font-size: 17px; font-weight: 650; }
h3 { font-size: 15px; font-weight: 600; }
p { margin: 0 0 var(--space-3); }
small, .muted { color: var(--color-muted); }
code, pre { font-family: var(--font-mono); font-size: 12.5px; }
:focus-visible { outline: 3px solid rgba(11, 95, 255, .45); outline-offset: 2px; border-radius: 4px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ---------- layout do console ---------- */
.app { display: grid; grid-template-columns: var(--sidebar-w) 1fr; min-height: 100vh; }
.sidebar { background: var(--color-sidebar); color: var(--color-sidebar-text); display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.brand { display: flex; align-items: center; gap: 10px; padding: 18px 20px; color: #fff; font-weight: 700; font-size: 16px; letter-spacing: .2px; }
.brand-mark { width: 32px; height: 32px; border-radius: 9px; background: linear-gradient(135deg, var(--color-primary), var(--color-accent)); display: grid; place-items: center; font-size: 15px; }
.brand small { display: block; color: var(--color-sidebar-text); font-weight: 500; font-size: 11px; }
.nav-section { padding: 14px 20px 6px; font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: #7F8EA8; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 9px 20px; color: var(--color-sidebar-text); font-weight: 500; border-left: 3px solid transparent; }
.nav a:hover { background: rgba(255, 255, 255, .05); text-decoration: none; color: #fff; }
.nav a.active { background: var(--color-sidebar-active); color: #fff; border-left-color: var(--color-accent); }
.nav .ico { width: 20px; text-align: center; opacity: .9; }
.nav .count { margin-left: auto; background: var(--color-primary); color: #fff; border-radius: 999px; font-size: 11px; padding: 0 7px; font-weight: 600; }
.sidebar-footer { margin-top: auto; padding: 16px 20px; font-size: 12px; color: #7F8EA8; }

.main { display: flex; flex-direction: column; min-width: 0; }
.topbar { height: var(--topbar-h); background: var(--color-surface); border-bottom: 1px solid var(--color-border); display: flex; align-items: center; gap: var(--space-3); padding: 0 var(--space-5); position: sticky; top: 0; z-index: 20; }
.topbar .title { font-weight: 650; color: var(--color-ink); font-size: 15px; }
.topbar .spacer { flex: 1; }
.menu-toggle { display: none; }
.content { padding: var(--space-5); max-width: 1400px; width: 100%; }
.content.full { max-width: none; padding: 0; }
.page-header { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--space-4); margin-bottom: var(--space-5); flex-wrap: wrap; }
.page-header p { margin: 4px 0 0; color: var(--color-muted); max-width: 760px; }

/* ---------- componentes ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 38px; padding: 0 16px; border-radius: var(--radius-sm); border: 1px solid var(--color-border-strong); background: var(--color-surface); color: var(--color-ink); font: inherit; font-weight: 600; cursor: pointer; white-space: nowrap; transition: background .15s, border-color .15s, box-shadow .15s; text-decoration: none !important; }
.btn:hover { background: var(--color-surface-2); border-color: #94A3B8; }
.btn:disabled, .btn[aria-busy='true'] { opacity: .65; cursor: progress; }
.btn-primary { background: var(--color-primary); border-color: var(--color-primary); color: #fff; }
.btn-primary:hover { background: var(--color-primary-hover); border-color: var(--color-primary-hover); }
.btn-success { background: var(--color-success); border-color: var(--color-success); color: #fff; }
.btn-danger { background: var(--color-danger); border-color: var(--color-danger); color: #fff; }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-ghost:hover { background: var(--color-primary-soft); }
.btn-sm { height: 30px; padding: 0 10px; font-size: 13px; }
.btn-lg { height: 48px; padding: 0 22px; font-size: 15px; }
.btn-block { width: 100%; }
.btn .spinner { width: 15px; height: 15px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.icon-btn { width: 38px; height: 38px; display: inline-grid; place-items: center; border-radius: var(--radius-sm); border: 1px solid transparent; background: transparent; cursor: pointer; color: var(--color-muted); font-size: 17px; position: relative; }
.icon-btn:hover { background: var(--color-surface-2); color: var(--color-ink); }

.card { background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.card-body { padding: var(--space-5); }
.card-header { padding: var(--space-4) var(--space-5); border-bottom: 1px solid var(--color-border); display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); }
.card-header h2, .card-header h3 { margin: 0; }
.grid { display: grid; gap: var(--space-4); }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.stack > * + * { margin-top: var(--space-4); }
.row { display: flex; align-items: center; gap: var(--space-2); flex-wrap: wrap; }
.row.between { justify-content: space-between; }

.kpi { padding: var(--space-4) var(--space-5); }
.kpi .label { color: var(--color-muted); font-size: 12.5px; font-weight: 500; }
.kpi .value { font-size: 26px; font-weight: 700; color: var(--color-ink); margin-top: 2px; }
.kpi .hint { font-size: 12px; color: var(--color-muted); }

.badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--color-surface-2); color: var(--color-text); border: 1px solid var(--color-border); white-space: nowrap; }
.badge-primary { background: var(--color-primary-soft); color: #0842B8; border-color: #C9DAFF; }
.badge-success { background: var(--color-success-soft); color: var(--color-success); border-color: #BBF7D0; }
.badge-warning { background: var(--color-warning-soft); color: var(--color-warning); border-color: #FDE68A; }
.badge-danger { background: var(--color-danger-soft); color: var(--color-danger); border-color: #FECACA; }
.badge-accent { background: var(--color-accent-soft); color: #0E7490; border-color: #A5F3FC; }
.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; background: #94A3B8; }
.dot.available { background: #22C55E; } .dot.paused { background: #F59E0B; } .dot.offline { background: #94A3B8; }

.table-wrap { overflow-x: auto; }
table.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--color-muted); font-weight: 600; padding: 10px 14px; background: var(--color-surface-2); border-bottom: 1px solid var(--color-border); white-space: nowrap; }
.table td { padding: 11px 14px; border-bottom: 1px solid var(--color-border); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: #FAFBFD; }
.table .actions { text-align: right; white-space: nowrap; }

.empty { text-align: center; padding: 48px 20px; color: var(--color-muted); }
.empty .ico { font-size: 34px; margin-bottom: 6px; }

.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-4) var(--space-5); }
.form-grid .full { grid-column: 1 / -1; }
.field label, .field > .label { display: block; font-weight: 600; color: var(--color-ink); margin-bottom: 6px; font-size: 13px; }
.field .help { color: var(--color-muted); font-size: 12px; margin-top: 4px; }
.field .error, .errorlist { color: var(--color-danger); font-size: 12.5px; margin: 4px 0 0; padding: 0; list-style: none; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=tel], input[type=url], input[type=date], input[type=search], select, textarea {
  width: 100%; height: 40px; padding: 0 12px; font: inherit; color: var(--color-ink); background: var(--color-surface); border: 1px solid var(--color-border-strong); border-radius: var(--radius-sm); transition: border-color .15s, box-shadow .15s;
}
textarea { height: auto; min-height: 90px; padding: 10px 12px; resize: vertical; line-height: 1.5; }
textarea.markdown, textarea.code { font-family: var(--font-mono); font-size: 12.5px; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--color-primary); box-shadow: 0 0 0 3px rgba(11, 95, 255, .15); }
input[type=checkbox] { width: 17px; height: 17px; accent-color: var(--color-primary); vertical-align: middle; }
.checkbox-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 6px 14px; }
.checkbox-list label, .check { display: flex; align-items: center; gap: 8px; font-weight: 500; }
.field ul { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 6px 14px; }
.field ul label { display: flex; align-items: center; gap: 8px; font-weight: 500; margin: 0; }
.toolbar { display: flex; gap: var(--space-2); flex-wrap: wrap; align-items: center; margin-bottom: var(--space-4); }
.toolbar input, .toolbar select { width: auto; min-width: 180px; }

.alert { padding: 12px 16px; border-radius: var(--radius-sm); margin-bottom: var(--space-4); border: 1px solid; font-weight: 500; }
.alert-success { background: var(--color-success-soft); border-color: #BBF7D0; color: #14532D; }
.alert-error, .alert-danger { background: var(--color-danger-soft); border-color: #FECACA; color: #7F1D1D; }
.alert-warning { background: var(--color-warning-soft); border-color: #FDE68A; color: #78350F; }
.alert-info { background: var(--color-primary-soft); border-color: #C9DAFF; color: #0B3B99; }

.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--color-border); overflow-x: auto; }
.tab { padding: 10px 14px; border: 0; background: none; font: inherit; font-weight: 600; color: var(--color-muted); cursor: pointer; border-bottom: 2px solid transparent; white-space: nowrap; display: inline-flex; gap: 6px; align-items: center; }
.tab.active { color: var(--color-primary); border-bottom-color: var(--color-primary); }
.tab .count { background: var(--color-surface-2); border: 1px solid var(--color-border); border-radius: 999px; padding: 0 7px; font-size: 11px; color: var(--color-text); }
.tab.active .count { background: var(--color-primary); color: #fff; border-color: var(--color-primary); }

.pagination { display: flex; gap: 6px; justify-content: flex-end; align-items: center; padding: var(--space-3) var(--space-4); }

.modal-backdrop { position: fixed; inset: 0; background: rgba(15, 23, 42, .5); display: none; align-items: center; justify-content: center; z-index: 100; padding: 16px; }
.modal-backdrop.open { display: flex; }
.modal { background: var(--color-surface); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); width: 100%; max-width: 520px; max-height: 90vh; overflow-y: auto; }
.modal-header { padding: 18px 22px 0; display: flex; justify-content: space-between; align-items: center; }
.modal-body { padding: 16px 22px; }
.modal-footer { padding: 0 22px 20px; display: flex; justify-content: flex-end; gap: 8px; }

.toasts { position: fixed; right: 18px; bottom: 18px; display: flex; flex-direction: column; gap: 10px; z-index: 200; max-width: min(380px, calc(100vw - 36px)); }
.toast { background: var(--color-ink); color: #fff; padding: 12px 16px; border-radius: var(--radius); box-shadow: var(--shadow-lg); display: flex; gap: 10px; align-items: flex-start; animation: toast-in .2s ease-out; }
.toast.success { background: #14532D; } .toast.error { background: #7F1D1D; } .toast.warning { background: #78350F; }
.toast strong { display: block; }
.toast a { color: #BFD3FF; }
@keyframes toast-in { from { transform: translateY(10px); opacity: 0; } }

.dropdown { position: relative; }
.dropdown-menu { position: absolute; right: 0; top: calc(100% + 6px); background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius); box-shadow: var(--shadow-lg); min-width: 300px; display: none; z-index: 50; overflow: hidden; }
.dropdown.open .dropdown-menu { display: block; }
.dropdown-menu a, .dropdown-menu button.item { display: block; width: 100%; text-align: left; padding: 10px 14px; color: var(--color-text); border: 0; background: none; font: inherit; cursor: pointer; }
.dropdown-menu a:hover, .dropdown-menu button.item:hover { background: var(--color-surface-2); text-decoration: none; }
.notif-badge { position: absolute; top: 3px; right: 3px; background: var(--color-danger); color: #fff; border-radius: 999px; font-size: 10px; padding: 0 5px; font-weight: 700; min-width: 16px; text-align: center; }
.notif-item { border-bottom: 1px solid var(--color-border); }
.notif-item.unread { background: #F5F8FF; }
.notif-item .t { font-weight: 600; color: var(--color-ink); }
.notif-item .m { font-size: 12.5px; color: var(--color-muted); }

.avatar { width: 36px; height: 36px; border-radius: 50%; background: var(--color-primary-soft); color: #0842B8; display: inline-grid; place-items: center; font-weight: 700; font-size: 13px; flex-shrink: 0; }
.avatar.tech { background: var(--color-accent-soft); color: #0E7490; }

.bar { height: 8px; border-radius: 999px; background: var(--color-surface-2); overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--color-primary); border-radius: 999px; }
.chart-bars { display: flex; align-items: flex-end; gap: 4px; height: 160px; padding-top: 10px; }
.chart-bars .b { flex: 1; background: linear-gradient(180deg, var(--color-primary), #5B8CFF); border-radius: 4px 4px 0 0; min-height: 2px; position: relative; }
.chart-bars .b:hover::after { content: attr(data-tip); position: absolute; bottom: 100%; left: 50%; transform: translateX(-50%); background: var(--color-ink); color: #fff; font-size: 11px; padding: 2px 6px; border-radius: 4px; white-space: nowrap; margin-bottom: 4px; }

/* ---------- login ---------- */
.auth-page { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; }
.auth-hero { background: radial-gradient(circle at 20% 20%, #17306A, var(--color-sidebar)); color: #fff; padding: 56px; display: flex; flex-direction: column; justify-content: space-between; }
.auth-hero h1 { color: #fff; font-size: 34px; max-width: 460px; }
.auth-hero p { color: var(--color-sidebar-text); max-width: 440px; font-size: 15px; }
.auth-form { display: flex; align-items: center; justify-content: center; padding: 32px 20px; background: var(--color-surface); }
.auth-form .box { width: 100%; max-width: 380px; }

/* ---------- inbox (console) ---------- */
.inbox { display: grid; grid-template-columns: 340px minmax(0, 1fr) 320px; height: calc(100vh - var(--topbar-h)); background: var(--color-surface); }
.inbox-list { border-right: 1px solid var(--color-border); display: flex; flex-direction: column; min-height: 0; }
.inbox-list .search { padding: 12px; border-bottom: 1px solid var(--color-border); }
.conv-items { overflow-y: auto; flex: 1; }
.conv-item { display: flex; gap: 10px; padding: 12px 14px; border-bottom: 1px solid var(--color-border); cursor: pointer; border-left: 3px solid transparent; }
.conv-item:hover { background: var(--color-surface-2); }
.conv-item.active { background: var(--color-primary-soft); border-left-color: var(--color-primary); }
.conv-item .info { min-width: 0; flex: 1; }
.conv-item .name { font-weight: 600; color: var(--color-ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv-item .preview { color: var(--color-muted); font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv-item .meta { text-align: right; font-size: 11.5px; color: var(--color-muted); display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.conv-item .unread { background: var(--color-primary); color: #fff; border-radius: 999px; padding: 0 6px; font-weight: 700; font-size: 11px; }
.conv-item.sla { border-left-color: var(--color-danger); }

.chat { display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--color-bg); }
.chat-header { padding: 12px 18px; background: var(--color-surface); border-bottom: 1px solid var(--color-border); display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.chat-header .who { flex: 1; min-width: 160px; }
.chat-header .who strong { color: var(--color-ink); }
.messages { flex: 1; overflow-y: auto; padding: 18px; display: flex; flex-direction: column; gap: 6px; }
.msg { max-width: min(72%, 560px); padding: 9px 13px; border-radius: 14px; box-shadow: var(--shadow-sm); word-wrap: break-word; white-space: pre-wrap; position: relative; }
.msg .who { font-size: 11.5px; font-weight: 600; margin-bottom: 2px; opacity: .85; }
.msg .time { font-size: 10.5px; opacity: .7; text-align: right; margin-top: 3px; }
.msg.in { align-self: flex-start; background: var(--bubble-in); border: 1px solid var(--color-border); border-bottom-left-radius: 4px; color: var(--color-text); }
.msg.out { align-self: flex-end; background: var(--bubble-out); color: #fff; border-bottom-right-radius: 4px; }
.msg.out.bot, .msg.out.ai { background: var(--bubble-ai); color: var(--color-ink); border: 1px solid #DDE3FF; }
.msg.note { align-self: center; background: var(--bubble-note); color: #713F12; border: 1px dashed #EAB308; max-width: 90%; }
.msg.system { align-self: center; background: transparent; box-shadow: none; color: var(--color-muted); font-size: 12px; padding: 2px 8px; text-align: center; }
.msg img { max-width: 100%; border-radius: 8px; display: block; margin-top: 4px; }
.msg .file { display: inline-flex; align-items: center; gap: 6px; padding: 6px 10px; border-radius: 8px; background: rgba(0, 0, 0, .06); color: inherit; margin-top: 4px; font-weight: 600; }
.msg.out:not(.bot):not(.ai) .file { background: rgba(255, 255, 255, .18); color: #fff; }
.msg .opts { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.msg .opts span { border: 1px solid #C9D3F5; border-radius: 999px; padding: 2px 10px; font-size: 12px; background: #fff; color: var(--color-primary); }
.composer { background: var(--color-surface); border-top: 1px solid var(--color-border); padding: 10px 14px; }
.composer form { display: flex; gap: 8px; align-items: flex-end; }
.composer textarea { min-height: 42px; max-height: 160px; height: 42px; resize: none; }
.composer .modes { display: flex; gap: 6px; margin-bottom: 8px; }
.composer.internal textarea { background: #FFFBEB; border-color: #FCD34D; }
.composer .notice { text-align: center; color: var(--color-muted); padding: 6px; }
.quick-replies { position: absolute; bottom: 100%; left: 14px; right: 14px; background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius); box-shadow: var(--shadow-lg); max-height: 220px; overflow-y: auto; display: none; }
.quick-replies.open { display: block; }
.quick-replies button { display: block; width: 100%; border: 0; background: none; text-align: left; padding: 8px 12px; cursor: pointer; font: inherit; }
.quick-replies button:hover { background: var(--color-surface-2); }
.typing { font-size: 12px; color: var(--color-muted); padding: 0 18px 6px; min-height: 20px; }

.side-panel { border-left: 1px solid var(--color-border); overflow-y: auto; padding: 16px; background: var(--color-surface); }
.side-panel h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .05em; color: var(--color-muted); margin-top: 18px; }
.kv { display: grid; grid-template-columns: 110px 1fr; gap: 4px 10px; font-size: 13px; }
.kv dt { color: var(--color-muted); }
.kv dd { margin: 0; color: var(--color-ink); word-break: break-word; }
.timeline { list-style: none; padding: 0; margin: 0; font-size: 12.5px; }
.timeline li { padding: 6px 0 6px 14px; border-left: 2px solid var(--color-border); position: relative; }
.timeline li::before { content: ''; position: absolute; left: -5px; top: 11px; width: 8px; height: 8px; border-radius: 50%; background: var(--color-primary); }
.tag-chip { display: inline-flex; align-items: center; gap: 4px; padding: 2px 9px; border-radius: 999px; font-size: 12px; border: 1px solid var(--color-border); cursor: pointer; background: var(--color-surface); margin: 0 4px 4px 0; }
.tag-chip.on { color: #fff; border-color: transparent; }
.placeholder { display: grid; place-items: center; height: 100%; color: var(--color-muted); text-align: center; padding: 20px; }
.mobile-tabs { display: none; }

/* ---------- editor de fluxos ---------- */
.flow-editor { display: grid; grid-template-columns: 250px minmax(0, 1fr) 340px; height: calc(100vh - var(--topbar-h) - 57px); }
.flow-bar { display: flex; gap: 8px; align-items: center; padding: 10px 16px; background: var(--color-surface); border-bottom: 1px solid var(--color-border); flex-wrap: wrap; }
.palette { border-right: 1px solid var(--color-border); overflow-y: auto; background: var(--color-surface); padding: 10px; }
.palette h4 { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--color-muted); margin: 14px 4px 6px; }
.palette-item { display: flex; align-items: center; gap: 8px; padding: 7px 9px; border: 1px solid var(--color-border); border-radius: 8px; margin-bottom: 5px; cursor: grab; background: var(--color-surface); font-size: 13px; font-weight: 500; }
.palette-item:hover { border-color: var(--color-primary); background: var(--color-primary-soft); }
.palette-item.disabled { opacity: .45; cursor: not-allowed; }
.palette-item .ico { width: 22px; text-align: center; }
#drawflow { position: relative; background: var(--color-bg); background-image: radial-gradient(#CBD5E1 1px, transparent 1px); background-size: 22px 22px; overflow: hidden; }
.inspector { border-left: 1px solid var(--color-border); overflow-y: auto; background: var(--color-surface); padding: 16px; }
.inspector .field { margin-bottom: 14px; }
.validation { font-size: 12.5px; }
.validation li { margin-bottom: 4px; cursor: pointer; }
.drawflow .drawflow-node { background: var(--color-surface) !important; border: 1px solid var(--color-border-strong) !important; border-radius: 10px !important; box-shadow: var(--shadow-sm); min-width: 210px; width: auto !important; padding: 0 !important; color: var(--color-ink); }
.drawflow .drawflow-node.selected { border-color: var(--color-primary) !important; box-shadow: 0 0 0 3px rgba(11, 95, 255, .2) !important; }
.drawflow .drawflow-node .drawflow_content_node { width: 100%; }
.drawflow .drawflow-node .inputs, .drawflow .drawflow-node .outputs { width: 0; }
.drawflow .drawflow-node .input, .drawflow .drawflow-node .output { width: 14px !important; height: 14px !important; border: 2px solid var(--color-primary) !important; background: #fff !important; }
.drawflow .drawflow-node .output:hover, .drawflow .drawflow-node .input:hover { background: var(--color-primary) !important; }
.drawflow .connection .main-path { stroke: #7B93C9 !important; stroke-width: 2.5px !important; }
.drawflow .connection .main-path.selected { stroke: var(--color-primary) !important; }
.node-card .nh { display: flex; align-items: center; gap: 8px; padding: 8px 12px; border-bottom: 1px solid var(--color-border); font-weight: 650; font-size: 13px; border-radius: 10px 10px 0 0; }
.node-card .nb { padding: 6px 12px 8px; font-size: 11.5px; color: var(--color-muted); max-width: 260px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.node-card .no { padding: 0 12px 8px; display: flex; flex-direction: column; gap: 2px; align-items: flex-end; font-size: 10.5px; color: var(--color-muted); }
.cat-messages .nh { background: #EEF4FF; } .cat-interaction .nh { background: #ECFEFF; } .cat-logic .nh { background: #F5F3FF; }
.cat-service .nh { background: #F0FDF4; } .cat-integrations .nh { background: #FFF7ED; } .cat-ai .nh { background: #FDF2F8; }

/* ---------- webchat (público, mobile-first) ---------- */
.wc-body { background: var(--color-bg); min-height: 100vh; }
.wc { max-width: 560px; margin: 0 auto; min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; background: var(--color-surface); box-shadow: var(--shadow); }
.wc-header { background: linear-gradient(135deg, var(--color-sidebar), #17306A); color: #fff; padding: 14px 16px; padding-top: max(14px, env(safe-area-inset-top)); display: flex; align-items: center; gap: 12px; position: sticky; top: 0; z-index: 10; }
.wc-header .t { flex: 1; min-width: 0; }
.wc-header .t strong { display: block; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wc-header .t small { color: var(--color-sidebar-text); font-size: 12px; }
.wc-header .btn { height: 34px; padding: 0 12px; background: rgba(255, 255, 255, .12); border-color: rgba(255, 255, 255, .25); color: #fff; }
.wc-header a { color: #fff; }
.wc-main { flex: 1; padding: 20px 16px; }
.wc-hero { text-align: center; padding: 22px 6px 10px; }
.wc-hero .brand-mark { width: 56px; height: 56px; font-size: 26px; margin: 0 auto 12px; border-radius: 16px; color: #fff; }
.wc .messages { background: var(--color-bg); padding: 14px 12px; }
.wc .msg { max-width: 86%; font-size: 15px; }
.wc-composer { position: sticky; bottom: 0; background: var(--color-surface); border-top: 1px solid var(--color-border); padding: 8px 10px; padding-bottom: max(8px, env(safe-area-inset-bottom)); }
.wc-composer form { display: flex; gap: 6px; align-items: flex-end; }
.wc-composer textarea { font-size: 16px; min-height: 44px; height: 44px; max-height: 140px; resize: none; border-radius: 22px; padding: 11px 16px; }
.wc-composer .icon-btn { width: 44px; height: 44px; flex-shrink: 0; }
.wc-composer .send { background: var(--color-primary); color: #fff; border-radius: 50%; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.chip { border: 1px solid var(--color-primary); color: var(--color-primary); background: #fff; border-radius: 999px; padding: 8px 14px; font: inherit; font-weight: 600; font-size: 14px; cursor: pointer; min-height: 40px; }
.chip:hover, .chip:active { background: var(--color-primary); color: #fff; }
.chips.used .chip { opacity: .5; pointer-events: none; }
.sheet-backdrop { position: fixed; inset: 0; background: rgba(15, 23, 42, .5); display: none; z-index: 100; align-items: flex-end; justify-content: center; }
.sheet-backdrop.open { display: flex; }
.sheet { background: var(--color-surface); width: 100%; max-width: 560px; border-radius: 20px 20px 0 0; padding: 18px 18px max(18px, env(safe-area-inset-bottom)); animation: sheet-in .2s ease-out; max-height: 88vh; overflow-y: auto; }
@keyframes sheet-in { from { transform: translateY(40px); opacity: .4; } }
.sheet .handle { width: 42px; height: 5px; border-radius: 999px; background: var(--color-border-strong); margin: 0 auto 14px; }
.reason { display: flex; align-items: center; gap: 10px; padding: 12px; border: 1px solid var(--color-border); border-radius: var(--radius); margin-bottom: 8px; cursor: pointer; font-weight: 500; }
.reason:has(input:checked) { border-color: var(--color-primary); background: var(--color-primary-soft); }
.history-item { display: block; padding: 14px; border: 1px solid var(--color-border); border-radius: var(--radius); margin-bottom: 10px; color: inherit; }
.history-item:hover { border-color: var(--color-primary); text-decoration: none; }
.closed-banner { text-align: center; padding: 16px; background: var(--color-surface-2); border-top: 1px solid var(--color-border); }
.conn { width: 8px; height: 8px; border-radius: 50%; background: #F59E0B; display: inline-block; margin-right: 4px; }
.conn.on { background: #22C55E; }

/* ---------- responsivo ---------- */
@media (max-width: 1200px) {
  .inbox { grid-template-columns: 300px minmax(0, 1fr); }
  .inbox .side-panel { display: none; }
  .inbox.show-panel .side-panel { display: block; position: fixed; right: 0; top: var(--topbar-h); bottom: 0; width: min(340px, 92vw); z-index: 30; box-shadow: var(--shadow-lg); }
  .flow-editor { grid-template-columns: 210px minmax(0, 1fr) 300px; }
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; width: var(--sidebar-w); transform: translateX(-100%); transition: transform .2s; z-index: 60; }
  .app.nav-open .sidebar { transform: none; box-shadow: var(--shadow-lg); }
  .menu-toggle { display: inline-grid; }
  .content { padding: var(--space-4); }
  .grid-2, .grid-3, .form-grid { grid-template-columns: 1fr; }
  .auth-page { grid-template-columns: 1fr; }
  .auth-hero { display: none; }
  .inbox { grid-template-columns: 1fr; height: calc(100vh - var(--topbar-h) - 48px); }
  .inbox .inbox-list, .inbox .chat { display: none; }
  .inbox[data-view='list'] .inbox-list, .inbox[data-view='chat'] .chat { display: flex; }
  .mobile-tabs { display: flex; position: sticky; top: var(--topbar-h); z-index: 15; background: var(--color-surface); border-bottom: 1px solid var(--color-border); }
  .mobile-tabs button { flex: 1; height: 48px; border: 0; background: none; font: inherit; font-weight: 600; color: var(--color-muted); }
  .mobile-tabs button.active { color: var(--color-primary); box-shadow: inset 0 -2px 0 var(--color-primary); }
  .flow-editor { grid-template-columns: 1fr; height: auto; }
  .flow-editor .palette { max-height: 180px; }
  #drawflow { height: 60vh; }
  .msg { max-width: 88%; }
  .topbar { padding: 0 var(--space-3); }
}
@media (max-width: 560px) {
  .grid-4 { grid-template-columns: 1fr 1fr; }
  .kpi .value { font-size: 21px; }
  .page-header h1 { font-size: 19px; }
  .table th, .table td { padding: 9px 10px; }
  .wc { box-shadow: none; }
}

/* ---------- menu lateral fixável + cartão do usuário ---------- */
.sidebar { overflow: visible; }
.sidebar .nav { overflow-y: auto; overflow-x: hidden; flex: 1; min-height: 0; padding-bottom: 8px; }
.sidebar-head { display: flex; align-items: center; justify-content: space-between; padding-right: 10px; }
.sidebar-head .brand { padding-right: 6px; }
.pin-btn { color: var(--color-sidebar-text); font-size: 15px; width: 32px; height: 32px; }
.pin-btn:hover { background: rgba(255, 255, 255, .08); color: #fff; }
.pin-btn[aria-pressed='false'] { opacity: .55; transform: rotate(45deg); }
.nav a .label, .nav-section .label { white-space: nowrap; }
.user-card { position: relative; border-top: 1px solid rgba(255, 255, 255, .08); padding: 10px; }
.user-card-toggle { width: 100%; display: flex; align-items: center; gap: 10px; background: transparent; border: 0; color: #fff; cursor: pointer; padding: 6px; border-radius: 10px; text-align: left; font: inherit; }
.user-card-toggle:hover { background: rgba(255, 255, 255, .06); }
.avatar-wrap { position: relative; flex-shrink: 0; }
.avatar-wrap .dot { position: absolute; right: -1px; bottom: -1px; border: 2px solid var(--color-sidebar); width: 12px; height: 12px; }
.user-info { min-width: 0; flex: 1; display: flex; flex-direction: column; line-height: 1.3; }
.user-info strong { font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-info small { color: var(--color-sidebar-text); font-size: 11.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-info .user-depts { color: #7F8EA8; }
.caret { color: var(--color-sidebar-text); font-size: 12px; }
.user-menu { position: absolute; left: 10px; right: 10px; bottom: calc(100% + 6px); background: var(--color-surface); color: var(--color-text); border-radius: var(--radius); box-shadow: var(--shadow-lg); border: 1px solid var(--color-border); z-index: 80; min-width: 228px; }
.user-menu-section { padding: 10px 14px; border-bottom: 1px solid var(--color-border); font-size: 13px; }
.status-switch { display: flex; flex-direction: column; gap: 4px; margin-top: 4px; }
.status-switch button { display: flex; align-items: center; gap: 8px; border: 1px solid var(--color-border); background: var(--color-surface); border-radius: 8px; padding: 6px 10px; font: inherit; cursor: pointer; text-align: left; }
.status-switch button.on { border-color: var(--color-primary); background: var(--color-primary-soft); font-weight: 600; }
.user-menu-links a, .user-menu-links button { display: block; width: 100%; text-align: left; padding: 9px 14px; color: var(--color-text); background: none; border: 0; font: inherit; cursor: pointer; }
.user-menu-links a:hover, .user-menu-links button:hover { background: var(--color-surface-2); text-decoration: none; }

/* Menu desafixado: barra de ícones que expande ao passar o mouse (sobrepondo o conteúdo) */
@media (min-width: 901px) {
  .sidebar-unpinned .app { grid-template-columns: 64px 1fr; }
  .sidebar-unpinned .sidebar { position: fixed; left: 0; top: 0; bottom: 0; width: 64px; z-index: 70; transition: width .18s ease, box-shadow .18s ease; }
  .sidebar-unpinned .main { grid-column: 2; }
  .sidebar-unpinned .sidebar:hover, .sidebar-unpinned .sidebar:focus-within, .sidebar-unpinned .sidebar.menu-open { width: var(--sidebar-w); box-shadow: var(--shadow-lg); }
  .sidebar-unpinned .sidebar:not(:hover):not(:focus-within):not(.menu-open) .label { display: none; }
  .sidebar-unpinned .sidebar:not(:hover):not(:focus-within):not(.menu-open) .nav a { justify-content: center; padding-left: 0; padding-right: 0; }
  .sidebar-unpinned .sidebar:not(:hover):not(:focus-within):not(.menu-open) .nav-section { padding: 10px 0 2px; border-top: 1px solid rgba(255, 255, 255, .06); margin: 0 12px; }
  .sidebar-unpinned .sidebar:not(:hover):not(:focus-within):not(.menu-open) .brand { padding: 18px 16px; }
  .sidebar-unpinned .sidebar:not(:hover):not(:focus-within):not(.menu-open) .user-card-toggle { justify-content: center; }
  .sidebar-unpinned .sidebar:not(:hover):not(:focus-within):not(.menu-open) .nav .count { position: absolute; margin-left: 18px; margin-top: -14px; }
}
@media (max-width: 900px) { .pin-btn { display: none; } }

/* ---------- console de atendimento v2 ---------- */
[hidden] { display: none !important; }
.inbox { grid-template-columns: 360px minmax(0, 1fr); }
.chat-view { display: flex; flex-direction: column; height: 100%; min-height: 0; }
.chat-header { flex-wrap: nowrap; gap: 10px; }
.chat-header .who { min-width: 0; }
.chat-header .who strong { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-meta { font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-header .dropdown-menu .item { white-space: nowrap; }
.item-actions { display: flex; gap: 6px; margin-top: 8px; }
.queue-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 12px 16px; background: var(--color-warning-soft); border-top: 1px solid #FDE68A; }
.composer .hint { font-size: 12px; align-self: center; }
.flow-trail { list-style: none; margin: 0; padding: 0; }
.flow-trail li { display: flex; gap: 10px; padding: 8px 0; border-bottom: 1px dashed var(--color-border); }
.flow-trail li:last-child { border-bottom: 0; }
.flow-trail li.error { background: var(--color-danger-soft); border-radius: 6px; padding: 8px; }
.trail-ico { width: 28px; height: 28px; border-radius: 8px; background: var(--color-primary-soft); display: grid; place-items: center; flex-shrink: 0; font-size: 14px; }
@media (max-width: 1200px) { .inbox { grid-template-columns: 300px minmax(0, 1fr); } }
@media (max-width: 900px) {
  .inbox { grid-template-columns: 1fr; }
  .chat-header { flex-wrap: wrap; }
  .composer .hint { display: none; }
}
.var-help { background: var(--color-surface-2); border: 1px solid var(--color-border); border-radius: 8px; padding: 8px; }
.var-chip { font-family: var(--font-mono); font-size: 11.5px; border: 1px solid var(--color-border-strong); background: var(--color-surface); border-radius: 6px; padding: 2px 6px; margin: 0 4px 4px 0; cursor: pointer; }
.var-chip:hover { border-color: var(--color-primary); color: var(--color-primary); }

/* ---------- mídias, gravador, transcrição e respostas rápidas ---------- */
.composer { position: relative; }
.quick-replies { z-index: 40; bottom: calc(100% - 4px); }
.quick-replies button.active { background: var(--color-primary-soft); }
.qr-empty { padding: 10px 12px; color: var(--color-muted); font-size: 13px; }
.media-buttons { display: flex; gap: 2px; flex-shrink: 0; }
.media-buttons .icon-btn { width: 36px; height: 40px; font-size: 17px; }
.queued-for { font-size: 12px; color: var(--color-warning); font-weight: 600; margin-top: 4px; }
.queue-bar.bot { background: var(--color-accent-soft); border-top-color: #A5F3FC; }
.msg audio.media-audio { display: block; width: 260px; max-width: 100%; margin-top: 4px; height: 40px; }
.msg video.media-video { display: block; width: 320px; max-width: 100%; border-radius: 8px; margin-top: 4px; background: #000; }
.transcript { margin-top: 6px; padding: 8px 10px; border-radius: 8px; background: rgba(15, 23, 42, .06); font-size: 13.5px; white-space: pre-wrap; }
.msg.out:not(.bot):not(.ai) .transcript { background: rgba(255, 255, 255, .16); }
.transcript.pending { display: flex; align-items: center; gap: 8px; color: var(--color-muted); }
.transcript .spinner { width: 13px; height: 13px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; }
.ai-badge { display: inline-flex; align-items: center; gap: 4px; font-size: 11px; font-weight: 700; letter-spacing: .02em; text-transform: uppercase; color: #6D28D9; background: #EDE9FE; border-radius: 999px; padding: 1px 8px; margin-right: 6px; white-space: nowrap; }
.msg.out:not(.bot):not(.ai) .ai-badge { color: #fff; background: rgba(255, 255, 255, .22); }
.recorder-backdrop { position: fixed; inset: 0; background: rgba(15, 23, 42, .6); display: none; align-items: center; justify-content: center; z-index: 300; padding: 16px; }
.recorder-backdrop.open { display: flex; }
.recorder { background: var(--color-surface); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); padding: 20px; width: 100%; max-width: 420px; text-align: center; color: var(--color-text); }
.recorder video { width: 100%; border-radius: 10px; background: #000; margin-bottom: 12px; transform: scaleX(-1); }
.recorder-status { display: flex; align-items: center; justify-content: center; gap: 8px; font-size: 22px; font-weight: 700; color: var(--color-ink); margin: 6px 0 16px; font-variant-numeric: tabular-nums; }
.recorder-status small { font-size: 12px; font-weight: 500; }
.rec-dot { width: 12px; height: 12px; border-radius: 50%; background: var(--color-danger); animation: pulse 1s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .3; } }
.recorder-actions { display: flex; gap: 10px; justify-content: center; }
.wc-composer .media-buttons .icon-btn { width: 38px; height: 44px; }
@media (max-width: 560px) {
  .wc-composer .media-buttons .icon-btn { width: 34px; font-size: 16px; }
  .media-buttons { gap: 0; }
}

/* ---------- credenciais temporárias ---------- */
.credentials-box { display: grid; gap: 12px; padding: 16px; border: 1px dashed var(--color-border-strong); border-radius: var(--radius); background: var(--color-surface-2); }
.mono { font-family: var(--font-mono); font-size: 15px; color: var(--color-ink); word-break: break-all; }
.mono.big { font-size: 22px; font-weight: 600; letter-spacing: .03em; }

.cat-code .nh { background: #F1F5F9; }

.code-block { background: var(--color-surface-2); border: 1px solid var(--color-border); border-radius: 8px; padding: 12px; white-space: pre-wrap; font-family: var(--font-mono); font-size: 12.5px; max-height: 360px; overflow: auto; }

.subject-line { font-size: 12px; color: var(--color-text); margin-top: 4px; }

/* ---------- contato ativo (central → técnico) ---------- */
.outbound-list { margin-bottom: 14px; }
.outbound-list h2 { font-size: 15px; margin: 0 0 8px; }
.outbound-card { display: flex; flex-direction: column; gap: 2px; padding: 12px 14px; border-radius: var(--radius); background: var(--color-accent-soft); border: 1px solid #A5F3FC; color: var(--color-ink); margin-bottom: 8px; text-decoration: none !important; animation: toast-in .2s ease-out; }
.outbound-card span { color: var(--color-text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.outbound-card small { color: var(--color-muted); }
.outbound-banner { position: fixed; left: 50%; transform: translateX(-50%); top: max(10px, env(safe-area-inset-top)); width: min(540px, calc(100vw - 20px)); z-index: 250; background: var(--color-ink); color: #fff; border-radius: 14px; box-shadow: var(--shadow-lg); padding: 12px 12px 12px 16px; display: flex; align-items: center; gap: 10px; animation: toast-in .2s ease-out; }
.outbound-banner .ob-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.outbound-banner .ob-text span { color: #CBD5E1; font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.outbound-banner .icon-btn { color: #CBD5E1; }

.geo-line { font-size: 12px; margin-top: 4px; opacity: .9; }

/* ---------- lista de atendimentos (v2) ---------- */
.inbox-head { padding: 12px 12px 10px; border-bottom: 1px solid var(--color-border); display: grid; gap: 10px; background: var(--color-surface); }
.seg-tabs { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; background: var(--color-surface-2); border: 1px solid var(--color-border); border-radius: 12px; padding: 4px; }
.seg { border: 0; background: transparent; border-radius: 9px; padding: 7px 4px 6px; font: inherit; font-size: 12px; font-weight: 600; color: var(--color-muted); cursor: pointer; display: grid; justify-items: center; gap: 1px; position: relative; transition: background .15s, color .15s; }
.seg:hover { color: var(--color-ink); background: rgba(15, 23, 42, .04); }
.seg.active { background: var(--color-surface); color: var(--color-primary); box-shadow: var(--shadow-sm), 0 0 0 1px var(--color-border); }
.seg-ico { font-size: 15px; line-height: 1.2; }
.seg-count { position: absolute; top: 3px; right: 6px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 999px; background: var(--color-border); color: var(--color-text); font-size: 10.5px; line-height: 18px; text-align: center; font-variant-numeric: tabular-nums; }
.seg.active .seg-count { background: var(--color-primary); color: #fff; }
.search-box { display: flex; align-items: center; gap: 8px; border: 1px solid var(--color-border); border-radius: 10px; padding: 0 10px; background: var(--color-surface-2); }
.search-box:focus-within { border-color: var(--color-primary); background: var(--color-surface); box-shadow: 0 0 0 3px var(--color-primary-soft); }
.search-box span { font-size: 13px; opacity: .6; }
.search-box input { border: 0; background: transparent; box-shadow: none !important; height: 36px; padding: 0; outline: none; }
.conv-items { padding: 6px; background: var(--color-surface-2); }
.conv-item { gap: 11px; padding: 11px 12px; border: 1px solid transparent; border-left: 3px solid transparent; border-radius: 12px; margin-bottom: 4px; background: var(--color-surface); box-shadow: var(--shadow-sm); transition: border-color .15s, box-shadow .15s; }
.conv-item:hover { background: var(--color-surface); border-color: var(--color-border-strong); }
.conv-item.active { background: var(--color-primary-soft); border-color: #BFD3FF; border-left-color: var(--color-primary); }
.conv-item.sla { border-left-color: var(--color-danger); }
.conv-item .avatar { width: 40px; height: 40px; box-shadow: 0 0 0 2px var(--color-surface), 0 0 0 4px var(--ring, transparent); }
.conv-item .line1, .conv-item .line2 { display: flex; align-items: center; gap: 8px; min-width: 0; }
.conv-item .line1 .name { flex: 1; min-width: 0; }
.conv-item .when { font-size: 11.5px; color: var(--color-muted); white-space: nowrap; }
.conv-item .line2 .preview { flex: 1; min-width: 0; }
.conv-item.has-unread .name, .conv-item.has-unread .preview { color: var(--color-ink); font-weight: 700; }
.conv-item.has-unread .when { color: var(--color-primary); font-weight: 600; }
.pills { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.pill { display: inline-flex; align-items: center; gap: 5px; font-size: 11px; font-weight: 600; color: var(--color-text); background: var(--color-surface-2); border: 1px solid var(--color-border); border-radius: 999px; padding: 1px 8px; white-space: nowrap; }
.pill i { width: 7px; height: 7px; border-radius: 50%; background: var(--color-muted); display: inline-block; }
.pill.st-queued { color: var(--color-warning); background: var(--color-warning-soft); border-color: #FDE68A; }
.pill.st-queued i { background: #F59E0B; animation: pulse 1.6s ease-in-out infinite; }
.pill.st-progress { color: var(--color-success); background: var(--color-success-soft); border-color: #BBF7D0; }
.pill.st-progress i { background: #22C55E; }
.pill.st-bot { color: #0E7490; background: var(--color-accent-soft); border-color: #A5F3FC; }
.pill.st-bot i { background: var(--color-accent); }
.pill.st-closed i { background: var(--color-border-strong); }
.pill.st-urgent { color: var(--color-danger); background: var(--color-danger-soft); border-color: #FECACA; }
.item-actions { display: flex; gap: 6px; margin-top: 8px; }
.item-actions .btn { height: 28px; padding: 0 10px; font-size: 12px; }
.conv-items .empty { background: var(--color-surface); border-radius: 12px; margin: 6px; border: 1px dashed var(--color-border-strong); display: grid; gap: 4px; }

/* ---------- conversa (v2) ---------- */
.messages { gap: 2px; padding: 18px 48px; background-color: var(--color-bg); background-image: radial-gradient(rgba(15, 23, 42, .045) 1px, transparent 1px); background-size: 18px 18px; }
.msg { margin-top: 8px; padding: 8px 12px 6px; line-height: 1.45; box-shadow: 0 1px 1.5px rgba(15, 23, 42, .1); white-space: normal; }
.msg .text { white-space: pre-wrap; }
.msg.grouped { margin-top: 2px; }
.msg.grouped > .who { display: none; }
.msg.in.grouped { border-top-left-radius: 6px; }
.msg.out.grouped { border-top-right-radius: 6px; }
.msg .time { font-size: 10.5px; margin-top: 2px; }
.msg.system { margin: 10px auto 4px; background: rgba(255, 255, 255, .85); border: 1px solid var(--color-border); border-radius: 999px; padding: 3px 12px; box-shadow: none; }
.msg-reply { position: absolute; top: 50%; transform: translateY(-50%); width: 28px; height: 28px; border-radius: 50%; border: 1px solid var(--color-border); background: var(--color-surface); color: var(--color-muted); cursor: pointer; opacity: 0; transition: opacity .15s; font-size: 14px; line-height: 1; box-shadow: var(--shadow-sm); padding: 0; }
.msg.in .msg-reply, .msg.note .msg-reply { right: -36px; }
.msg.out .msg-reply { left: -36px; }
.msg:hover .msg-reply, .msg-reply:focus-visible { opacity: 1; }
.msg-reply:hover { color: var(--color-primary); border-color: var(--color-primary); }
@media (hover: none) { .msg-reply { opacity: .6; } }
.quote { display: flex; flex-direction: column; gap: 1px; width: 100%; text-align: left; font: inherit; font-size: 12.5px; border: 0; border-left: 3px solid var(--color-primary); background: rgba(15, 23, 42, .05); border-radius: 6px; padding: 5px 8px; margin: 2px 0 5px; cursor: pointer; color: inherit; }
.quote strong { font-size: 11.5px; color: var(--color-primary); }
.quote span { opacity: .85; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.quote.internal { border-left-color: #EAB308; }
.quote.internal strong { color: #A16207; }
.msg.out:not(.bot):not(.ai) .quote { background: rgba(255, 255, 255, .16); border-left-color: #fff; }
.msg.out:not(.bot):not(.ai) .quote strong { color: #fff; }
.msg.flash { animation: flash 1.2s ease-out; }
@keyframes flash { 0%, 40% { box-shadow: 0 0 0 4px rgba(11, 95, 255, .35); } 100% { box-shadow: 0 1px 1.5px rgba(15, 23, 42, .1); } }
.day-divider { align-self: center; margin: 14px 0 4px; position: sticky; top: 4px; z-index: 2; }
.day-divider span { display: inline-block; font-size: 11.5px; font-weight: 600; color: var(--color-muted); background: var(--color-surface); border: 1px solid var(--color-border); border-radius: 999px; padding: 3px 12px; box-shadow: var(--shadow-sm); }
.reply-bar { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; padding: 6px 6px 6px 12px; border-left: 3px solid var(--color-primary); background: var(--color-primary-soft); border-radius: 8px; }
.reply-bar[hidden] { display: none; }
.reply-bar .rb-text { flex: 1; min-width: 0; display: flex; flex-direction: column; font-size: 12.5px; }
.reply-bar .rb-text strong { color: var(--color-primary); font-size: 12px; }
.reply-bar .rb-text span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--color-text); }
.composer.internal .reply-bar { background: #FFFBEB; border-left-color: #EAB308; }
.composer.internal .reply-bar .rb-text strong { color: #A16207; }
.composer form { background: var(--color-surface-2); border: 1px solid var(--color-border); border-radius: 14px; padding: 4px 4px 4px 6px; align-items: center; }
.composer form:focus-within { border-color: var(--color-primary); box-shadow: 0 0 0 3px var(--color-primary-soft); background: var(--color-surface); }
.composer textarea { border: 0; background: transparent; box-shadow: none !important; padding: 10px 6px; }
.composer.internal form { background: #FFFBEB; border-color: #FCD34D; }
.composer.internal textarea { background: transparent; }
.chat-header { box-shadow: 0 1px 0 var(--color-border), 0 2px 6px rgba(15, 23, 42, .04); z-index: 3; }
.wc .messages { padding: 12px 38px; }
.wc .msg.in .msg-reply { right: -32px; }
.wc .msg.out .msg-reply { left: -32px; }
.wc-composer .reply-bar { margin: 0 0 6px; }
@media (max-width: 760px) {
  .messages { padding: 14px 38px; }
}

/* ---------- fotos dos atendentes ---------- */
img.avatar { object-fit: cover; padding: 0; background: var(--color-surface-2); }
.avatar-xl { width: 64px; height: 64px; font-size: 22px; }
.msg .who { display: flex; align-items: center; gap: 6px; }
.who-avatar { width: 20px; height: 20px; border-radius: 50%; object-fit: cover; flex-shrink: 0; }
.wc-header img.avatar { width: 36px; height: 36px; border: 2px solid rgba(255, 255, 255, .5); }

/* ---------- fotos no histórico ---------- */
.media-gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: 6px; margin-top: 10px; }
.media-gallery img, .media-tile { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 8px; border: 1px solid var(--color-border); display: block; }
.media-tile { display: grid; place-items: center; align-content: center; font-size: 24px; background: var(--color-surface-2); color: var(--color-text); text-decoration: none !important; }
.media-tile small { font-size: 11px; color: var(--color-muted); }
.file-row { display: block; margin-top: 8px; font-size: 13px; }
.thumb-strip { display: flex; gap: 4px; margin-top: 6px; align-items: center; }
.thumb-strip img { width: 34px; height: 34px; object-fit: cover; border-radius: 6px; border: 1px solid var(--color-border); }
.thumb-strip span { font-size: 11.5px; color: var(--color-muted); font-weight: 600; }

/* ---------- busca nos atendimentos ---------- */
.search-hero { display: flex; align-items: center; gap: 10px; padding: 8px 8px 8px 16px; border-radius: 14px; }
.search-hero > span { font-size: 18px; opacity: .65; }
.search-hero input { flex: 1; border: 0; box-shadow: none !important; background: transparent; font-size: 15px; height: 42px; padding: 0; outline: none; }
.search-panel .search-hero { border: 1px solid var(--color-border-strong); background: var(--color-surface); }
.search-panel .search-hero:focus-within, form.search-hero:focus-within { box-shadow: 0 0 0 3px var(--color-primary-soft); border-color: var(--color-primary); }
.search-result { padding: 14px 16px; margin-bottom: 10px; }
.hits { display: grid; gap: 6px; margin-top: 10px; }
.hit { display: block; padding: 8px 12px; border-radius: 10px; background: var(--color-surface-2); border: 1px solid var(--color-border); border-left: 3px solid var(--color-primary); color: var(--color-text); text-decoration: none !important; }
.hit:hover { border-color: var(--color-primary); }
.hit.internal { border-left-color: #EAB308; background: #FFFBEB; }
.hit small { display: block; color: var(--color-muted); font-size: 11.5px; margin-bottom: 2px; }
.hit span { font-size: 13.5px; white-space: pre-wrap; }
mark { background: #FDE68A; color: inherit; border-radius: 3px; padding: 0 2px; }

/* ---------- verificação da configuração ---------- */
.health-list { display: grid; gap: 6px; padding: 0 16px 16px; }
.health-item { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--color-border); color: var(--color-text); text-decoration: none !important; }
.health-item:hover { border-color: var(--color-border-strong); background: var(--color-surface-2); }
.health-item .ico { font-size: 16px; line-height: 1.3; }
.health-item strong { display: block; font-size: 13.5px; color: var(--color-ink); }
.health-item small { color: var(--color-muted); font-size: 12.5px; }
.health-item.error { border-left: 3px solid var(--color-danger); }
.health-item.warning { border-left: 3px solid #F59E0B; }
.health-item.info { border-left: 3px solid var(--color-accent); }

/* ---------- cofre de tokens ---------- */
.vault-status { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 14px 16px; border-radius: 14px; border: 1px solid var(--color-border); background: var(--color-surface); }
.vault-status .ico { font-size: 22px; }
.vault-status > div { flex: 1; min-width: 220px; display: grid; }
.vault-status small { color: var(--color-muted); }
.vault-status.locked { border-left: 4px solid var(--color-warning); }
.vault-status.open { border-left: 4px solid var(--color-success); background: var(--color-success-soft); }
.vault-status input[name=code] { width: 130px; text-align: center; font-family: var(--font-mono); font-size: 18px; letter-spacing: .2em; }
code.masked { letter-spacing: .08em; }
.vault-help { margin: 0; padding-left: 18px; display: grid; gap: 6px; font-size: 13.5px; }
.setup-totp { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 20px; align-items: start; }
.setup-steps { margin: 0; padding-left: 20px; display: grid; gap: 12px; }
.totp-key { display: inline-block; margin-top: 6px; font-size: 15px; letter-spacing: .08em; word-break: break-all; }
.setup-totp .qr { display: grid; gap: 8px; justify-items: center; }
.setup-totp .qr img { display: block; width: 264px; height: 264px; image-rendering: pixelated; background: #fff; border-radius: 12px; border: 1px solid var(--color-border); }
.setup-totp input[name=code] { font-family: var(--font-mono); font-size: 22px; letter-spacing: .3em; text-align: center; }
@media (max-width: 640px) { .setup-totp { grid-template-columns: 1fr; } .setup-totp .qr { justify-self: center; } }

/* ---------- base de conhecimento ---------- */
.dropzone { position: relative; display: grid; justify-items: center; gap: 4px; padding: 26px 16px; border: 2px dashed var(--color-border-strong); border-radius: 14px; background: var(--color-surface-2); text-align: center; cursor: pointer; }
.dropzone:hover, .dropzone:focus-within { border-color: var(--color-primary); background: var(--color-primary-soft); }
.dropzone input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.dropzone .ico { font-size: 26px; }
.dropzone small { color: var(--color-muted); }

.maps-link { font-weight: 600; white-space: nowrap; }
.msg.out:not(.bot):not(.ai) .maps-link { color: #fff; text-decoration: underline; }

/* ---------- modelos de O.S. e catálogo de variáveis ---------- */
.os-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 12px; }
.os-card { display: grid; gap: 8px; color: var(--color-text); text-decoration: none !important; border-top: 3px solid var(--color-primary); }
.os-card:hover { border-color: var(--color-primary); }
.os-card pre { margin: 0; white-space: pre-wrap; font-size: 12px; color: var(--color-muted); max-height: 140px; overflow: hidden; }
.os-editor { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 16px; align-items: start; }
.mono-area { font-family: var(--font-mono); font-size: 13px; line-height: 1.5; }
.os-preview { margin: 0; white-space: pre-wrap; background: var(--color-surface-2); border: 1px solid var(--color-border); border-left: 3px solid var(--color-success); border-radius: 10px; padding: 12px; font-size: 13px; }
.check-list ul, .check-list > div { list-style: none; padding: 0; margin: 0; display: grid; gap: 4px; max-height: 240px; overflow-y: auto; }
.check-list label { display: flex; gap: 8px; align-items: center; font-weight: 500; }
.var-picker { position: sticky; top: calc(var(--topbar-h) + 12px); max-height: calc(100vh - var(--topbar-h) - 40px); display: flex; flex-direction: column; overflow: hidden; }
.var-picker-head { display: grid; gap: 8px; padding: 12px; border-bottom: 1px solid var(--color-border); }
.var-picker-body { overflow-y: auto; padding: 6px; }
.var-picker details { margin-bottom: 4px; }
.var-picker summary { cursor: pointer; font-weight: 600; font-size: 13px; padding: 6px 8px; border-radius: 8px; }
.var-picker summary:hover { background: var(--color-surface-2); }
.var-item { display: grid; width: 100%; text-align: left; gap: 1px; border: 0; background: transparent; padding: 6px 10px; border-radius: 8px; cursor: pointer; font: inherit; color: inherit; }
.var-item:hover { background: var(--color-primary-soft); }
.var-item code { font-size: 12px; color: var(--color-primary); }
.var-item small { font-size: 11.5px; color: var(--color-muted); }
.var-picker-foot { padding: 10px 12px; border-top: 1px solid var(--color-border); font-size: 13px; font-weight: 600; }
.var-toolbar { display: grid; gap: 10px; }
.var-toolbar input { max-width: 420px; }
.copy-var { border: 0; background: none; padding: 0; cursor: pointer; text-align: left; }
.catalog-table code.value { font-size: 12px; }
.uses { margin: 6px 0 0; padding-left: 16px; font-size: 12.5px; display: grid; gap: 2px; }
.pill.kind-system { color: var(--color-accent); } .pill.kind-global { color: var(--color-primary); }
.pill.kind-flow { color: var(--color-success); } .pill.kind-subject { color: #7C3AED; }
.pill.kind-api { color: var(--color-warning); } .pill.kind-function { color: #BE185D; }
.pill.kind-undefined { color: var(--color-danger); background: var(--color-danger-soft); border-color: #FECACA; }
@media (max-width: 1000px) { .os-editor { grid-template-columns: 1fr; } .var-picker { position: static; max-height: 420px; } }
