/* Prospecta */
:root {
  --navy: #101D35; --navy-raised: #1D304F; --silver: #CBD5E1; --white: #FFFFFF;
  /* Tipografia: Geist (texto e interface), Instrument Serif (títulos de página), Geist Mono (dados).
     Arquivos em /assets/fonts; sem eles, cai para a fonte do sistema sem quebrar o layout. */
  --font-sans: "Geist", "Segoe UI Variable Text", -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", system-ui, sans-serif;
  --font-display: "Instrument Serif", "Geist", "Segoe UI Variable Display", -apple-system, "SF Pro Display", "Segoe UI", system-ui, serif;
  --font-mono: "Geist Mono", ui-monospace, "Cascadia Mono", "SF Mono", Consolas, monospace;
  --font-signature: "Instrument Serif", Georgia, "Times New Roman", serif;
  --type-small: .75rem; --type-label: .8125rem; --type-body: .90625rem;
  --type-heading: 1.0625rem; --type-title: 1.75rem;
  --weight-regular: 400; --weight-medium: 500; --weight-strong: 600;
  --space-1: 4px; --space-2: 8px; --space-3: 12px; --space-4: 16px;
  --space-5: 20px; --space-6: 24px; --space-7: 32px;
  --radius-sm: 8px; --radius-md: 12px; --radius-lg: 16px; --radius-xl: 20px; --radius-pill: 999px;
  --control-size: 40px; --touch-size: 44px; --topbar-size: 68px;
  --page-gutter: clamp(var(--space-4), 3vw, 40px);
  --motion-fast: 160ms;
}
:root, [data-theme="light"] {
  --bg: #F4F6F9; --surface: var(--white); --soft: #EDF1F6; --hover: #E7EDF5; --selected: #E1E9F5;
  --border: #DCE3EC; --border-strong: #B8C5D5; --control-border: #7A889A;
  --text: #142138; --text-2: #334155; --muted: #526177;
  --accent: var(--navy); --on-accent: var(--white); --accent-hover: var(--navy-raised);
  --focus: #365A88;
  --ok: #2F6B3A; --ok-soft: #E3EBE0; --warn: #7A4522; --warn-soft: #F3E3D6; --danger: #9A2B22; --danger-soft: #F6DEDA;
  --bubble-lead: var(--surface); --bubble-bot: var(--soft); --bubble-agent: var(--selected); --chat: #F6F8FB;
  --highlight: var(--navy); --highlight-hover: var(--navy-raised);
  --highlight-text: var(--white); --highlight-muted: var(--silver);
  --nav-surface: var(--navy); --nav-active: var(--navy-raised); --nav-border: var(--navy-raised);
  --nav-text: var(--white); --nav-muted: var(--silver); --nav-focus: var(--silver);
  --scrim: #101D3588; --shadow: 0 1px 2px #101D350A, 0 8px 24px #101D3514;
  color-scheme: light;
}
[data-theme="dark"] {
  --bg: #0C1423; --surface: #152137; --soft: #1C2A41; --hover: #23324A; --selected: #2B3D59;
  --border: #2A3950; --border-strong: #455772; --control-border: #6F829F;
  --text: #F4F7FC; --text-2: var(--silver); --muted: #A9B8CD;
  --accent: #DCE6F5; --on-accent: var(--navy); --accent-hover: #F0F5FC;
  --focus: #A5BFE5;
  --ok: #9CD3A4; --ok-soft: #26362A; --warn: #F0C39C; --warn-soft: #3D2E22; --danger: #F2A49B; --danger-soft: #45282A;
  --bubble-lead: var(--soft); --bubble-bot: var(--hover); --bubble-agent: var(--selected); --chat: #101A2D;
  --highlight: var(--accent); --highlight-hover: var(--accent-hover);
  --highlight-text: var(--navy); --highlight-muted: var(--navy-raised);
  --nav-surface: var(--chat); --nav-active: var(--selected); --nav-border: var(--border);
  --nav-text: var(--text); --nav-muted: var(--silver); --nav-focus: var(--focus);
  --scrim: #0C1423B8; --shadow: 0 1px 2px #0006, 0 8px 24px #0005;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--text); font: var(--type-body)/1.5 var(--font-sans); -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; }
h1, h2, h3, p { margin: 0; }
h1 { font-size: var(--type-title); line-height: 1.15; letter-spacing: -.035em; font-weight: 700; }
h2 { font-size: var(--type-heading); line-height: 1.25; letter-spacing: -.025em; }
h3 { font-size: var(--type-body); line-height: 1.35; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.content :focus-visible { scroll-margin-block-start: calc(var(--topbar-size) + var(--space-2)); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--muted); }
.small { font-size: var(--type-small); }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mono { font-family: var(--font-mono); }
.label { font-size: var(--type-small); font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.meta-list { display: flex; flex-wrap: wrap; align-items: center; gap: 2px 12px; overflow-wrap: anywhere; }
.meta-list:empty { display: none; }
.item-copy { display: grid; gap: 3px; min-width: 0; overflow-wrap: anywhere; }

/* ---------- Estrutura ---------- */
.shell { display: flex; min-height: 100dvh; }
.sidebar { flex: 0 0 224px; background: var(--nav-surface); color: var(--nav-text); border-right: 1px solid var(--nav-border); position: sticky; top: 0; height: 100dvh; display: flex; flex-direction: column; padding: var(--space-6) var(--space-3); gap: var(--space-1); overflow: auto; }
.sidebar :focus-visible { outline-color: var(--nav-focus); }
.brand { display: flex; align-items: center; gap: var(--space-3); padding: var(--space-1) var(--space-2) var(--space-5); text-decoration: none; }
.nav-links { display: grid; gap: 3px; min-width: 0; }
.brand-mark { width: 34px; height: 34px; border-radius: var(--radius-sm); background: var(--accent); color: var(--on-accent); display: grid; place-items: center; flex: none; }
.brand-word { font-weight: 700; letter-spacing: .22em; font-size: var(--type-label); }
.company-brand { display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: center; gap: var(--space-3); min-width: 0; padding: var(--space-1) var(--space-2) var(--space-5); text-decoration: none; }
.sidebar .brand, .sidebar .company-brand { border-bottom: 1px solid var(--nav-border); }
.sidebar .brand-mark, .company-brand .company-avatar { background: var(--white); color: var(--navy); }
.company-brand .company-avatar { width: var(--touch-size); height: var(--touch-size); border-radius: var(--radius-sm); }
.company-avatar img { padding: 3px; }
.company-brand-copy { display: grid; gap: 2px; min-width: 0; }
.company-name { font-size: 1rem; font-weight: 700; line-height: 1.25; letter-spacing: -.02em; overflow-wrap: anywhere; }
.company-signature { color: var(--nav-muted); font: italic var(--type-label)/1.2 var(--font-signature); letter-spacing: .025em; }
.nav-group { color: var(--nav-muted); margin: var(--space-4) var(--space-2) var(--space-1); }
.nav { display: flex; align-items: center; gap: var(--space-3); min-height: var(--control-size); padding: var(--space-2) var(--space-3); border-radius: var(--radius-sm); color: var(--nav-muted); text-decoration: none; font-weight: 500; border: 1px solid transparent; }
.nav svg { width: 18px; height: 18px; flex: none; }
.nav:hover { background: var(--nav-active); color: var(--nav-text); }
.nav[aria-current="page"] { background: var(--nav-active); color: var(--nav-text); font-weight: 700; box-shadow: inset 2px 0 var(--nav-focus); }
.nav .count { margin-left: auto; }
.sidebar .count { background: var(--silver); color: var(--navy); }
.sidebar-foot { margin-top: auto; display: grid; gap: var(--space-2); padding-top: var(--space-4); }
.status-chip { display: flex; align-items: center; gap: var(--space-2); border: 1px solid var(--nav-border); border-radius: var(--radius-sm); padding: var(--space-2) var(--space-3); font-size: var(--type-small); color: var(--nav-muted); text-decoration: none; }
.status-chip:hover { background: var(--nav-active); }
.status-chip svg { width: 16px; height: 16px; flex: none; }
.status-chip { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.inline > select { width: auto; }
.inline > input:not([type="checkbox"]) { flex: 1 1 180px; width: auto; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); flex: none; }
.dot.on { background: var(--ok); }
.dot.off { background: var(--warn); }
.sidebar .dot.on { background: var(--ok-soft); }
.sidebar .dot.off { background: var(--warn-soft); }
[data-theme="dark"] .sidebar .dot.on { background: var(--ok); }
[data-theme="dark"] .sidebar .dot.off { background: var(--warn); }

.workspace { flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 30; min-height: var(--topbar-size); flex: none; display: flex; align-items: center; gap: var(--space-3); padding: 0 var(--page-gutter); background: var(--surface); border-bottom: 1px solid var(--border); }
.topbar h1 { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; font-size: clamp(var(--type-title), 2.3vw, 2rem); }
.top-actions { margin-left: auto; display: flex; align-items: center; gap: var(--space-2); flex: none; position: relative; }
.content { width: min(100%, 1600px); margin-inline: auto; padding: var(--space-7) var(--page-gutter) 48px; min-width: 0; flex: 1; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); flex-wrap: wrap; margin-bottom: var(--space-5); }
.page-head p { color: var(--muted); }

/* ---------- Componentes ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2); min-height: var(--control-size); padding: var(--space-2) var(--space-3); border-radius: var(--radius-sm); border: 1px solid var(--control-border); background: var(--surface); color: var(--text); font-weight: 600; text-decoration: none; white-space: nowrap; }
.btn:hover { background: var(--hover); }
.btn svg { width: 16px; height: 16px; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn.primary:hover { background: var(--accent-hover); }
.btn.danger { color: var(--danger); }
.btn.small { min-height: var(--space-7); padding: var(--space-1) var(--space-2); font-size: var(--type-label); }
.btn.quiet { background: transparent; border-color: transparent; }
.btn.quiet:hover { background: var(--hover); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.icon-btn { position: relative; display: inline-grid; place-items: center; width: var(--control-size); height: var(--control-size); border-radius: var(--radius-sm); border: 1px solid var(--border); background: var(--surface); color: var(--text); }
.icon-btn:hover { background: var(--hover); }
.icon-btn[aria-expanded="true"] { background: var(--selected); }
.icon-btn svg { width: 18px; height: 18px; }
.icon-btn .count { position: absolute; top: -6px; right: -6px; }
.link-btn { border: 0; background: none; padding: var(--space-1) 0; color: var(--text); text-decoration: underline; text-underline-offset: 3px; font-weight: 600; }
.avatar { width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; background: var(--soft); font-weight: 700; font-size: 13px; flex: none; overflow: hidden; }
.avatar img { width: 100%; height: 100%; object-fit: contain; background: var(--white); }
.avatar.sq { border-radius: var(--radius-sm); }

/* Contador circular */
.count { min-width: 22px; height: 22px; padding: 0 6px; border-radius: var(--radius-pill); display: inline-grid; place-items: center; background: var(--accent); color: var(--on-accent); font-size: .6875rem; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1; }
.count.soft { background: var(--soft); color: var(--text); }
.count.lg { width: 34px; height: 34px; min-width: 34px; font-size: 13px; padding: 0; }

.pill { display: inline-flex; align-items: center; gap: var(--space-1); border-radius: var(--radius-pill); padding: 3px var(--space-2); font-size: var(--type-small); font-weight: 600; background: var(--soft); color: var(--text-2); white-space: nowrap; }
.pill.ok { background: var(--ok-soft); color: var(--ok); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.danger { background: var(--danger-soft); color: var(--danger); }
.pill.dark { background: var(--accent); color: var(--on-accent); }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md); padding: clamp(var(--space-4), 2vw, var(--space-6)); min-width: 0; }
.card + .card { margin-top: var(--space-4); }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: var(--space-2); flex-wrap: wrap; margin-bottom: var(--space-4); padding-bottom: var(--space-3); border-bottom: 1px solid var(--border); }
.grid { display: grid; gap: var(--space-4); }
.grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.metrics { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 155px), 1fr)); gap: var(--space-3); margin-bottom: var(--space-5); }
.dashboard-metrics { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.content[data-page="dashboard"] > .grid + .card { margin-top: 16px; }
.metric { display: flex; position: relative; flex-direction: column; justify-content: space-between; gap: var(--space-2); min-height: 120px; text-decoration: none; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: var(--space-4); }
.metric > span:first-child { color: var(--muted); font-size: var(--type-label); font-weight: 600; }
a.metric > span:first-child { padding-inline-end: var(--space-5); }
.metric > svg { position: absolute; top: var(--space-4); right: var(--space-4); width: var(--space-4); height: var(--space-4); color: var(--muted); }
a.metric:hover { background: var(--hover); }
.metric strong { font-size: clamp(1.625rem, 3vw, 2.5rem); font-variant-numeric: tabular-nums; letter-spacing: -.055em; line-height: 1.1; overflow-wrap: anywhere; }
.metric.highlight { background: var(--highlight); color: var(--highlight-text); border-color: var(--highlight); }
.metric.highlight > span:first-child, .metric.highlight > svg { color: var(--highlight-muted); }
a.metric.highlight:hover { background: var(--highlight-hover); }
.metric.highlight strong { color: inherit; }
.row { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); padding: var(--space-3) 0; border-bottom: 1px solid var(--border); }
.row:last-child { border-bottom: 0; }
a.row { text-decoration: none; border-radius: var(--radius-sm); padding-inline: var(--space-2); }
a.row:hover { background: var(--hover); }
.empty { padding: 20px 10px; text-align: center; color: var(--muted); }
.notice { background: var(--soft); border-radius: var(--radius-sm); padding: var(--space-3) var(--space-4); color: var(--text-2); }
.notice.warn { background: var(--warn-soft); color: var(--warn); }
.notice.ok { background: var(--ok-soft); color: var(--ok); }
.status-line { min-height: 20px; font-size: 13px; color: var(--muted); }
.status-line.error { color: var(--danger); }

/* Formulários */
.field { display: grid; gap: 5px; font-weight: 600; font-size: 13px; }
.field small { font-weight: 400; color: var(--muted); }
input, select, textarea { min-height: var(--control-size); border: 1px solid var(--control-border); border-radius: var(--radius-sm); background: var(--surface); padding: var(--space-2) var(--space-3); width: 100%; }
textarea { min-height: 96px; resize: vertical; line-height: 1.45; }
input[type="checkbox"], input[type="radio"] { width: 18px; height: 18px; min-height: 0; accent-color: var(--accent); }
input::placeholder, textarea::placeholder { color: var(--muted); opacity: 1; }
input:hover, select:hover, textarea:hover { border-color: var(--muted); }
.form { display: grid; gap: var(--space-4); }
.form-actions { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; align-items: center; }
.inline { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.search { position: relative; flex: 1 1 220px; max-width: 360px; }
.search svg { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; color: var(--muted); }
.search input { padding-left: 34px; }

/* Abas */
.tabs { display: flex; gap: var(--space-1); border-bottom: 1px solid var(--border); margin-bottom: var(--space-5); overflow-x: auto; }
.tab { border: 0; background: none; padding: var(--space-2) var(--space-3); border-bottom: 2px solid transparent; color: var(--muted); font-weight: 600; display: inline-flex; gap: var(--space-2); align-items: center; white-space: nowrap; border-radius: var(--radius-sm) var(--radius-sm) 0 0; }
.tab:hover { color: var(--text); background: var(--hover); }
.tab, .avatar, .metric, .conv { text-decoration: none; }
.grid > .card + .card, .grid > .card, .board .card { margin-top: 0; }
.tab[aria-selected="true"], .tab[aria-current="page"] { color: var(--text); border-bottom-color: var(--accent); }
.tab .count { background: var(--soft); color: var(--text); }
.tab[aria-selected="true"] .count { background: var(--accent); color: var(--on-accent); }
.period { display: inline-flex; gap: 2px; padding: var(--space-1); background: var(--soft); border: 1px solid var(--border); border-radius: var(--radius-md); }
.period a { display: inline-flex; align-items: center; padding: var(--space-1) var(--space-2); border-radius: var(--radius-sm); color: var(--muted); text-decoration: none; font-size: var(--type-small); font-weight: 600; white-space: nowrap; }
.period a:hover { color: var(--text); }
.period a[aria-current="true"] { background: var(--surface); color: var(--text); }

/* Interruptor */
.switch { display: inline-flex; align-items: center; gap: var(--space-2); border: 1px solid var(--border); background: var(--surface); border-radius: var(--radius-pill); padding: var(--space-1) var(--space-3) var(--space-1) var(--space-2); font-weight: 600; font-size: var(--type-label); min-height: var(--control-size); }
.switch:hover { background: var(--hover); }
.switch .track { width: 36px; height: 22px; border-radius: var(--radius-pill); background: var(--control-border); position: relative; flex: none; }
.switch .track::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: var(--white); }
.switch[aria-checked="true"] .track { background: var(--accent); }
.switch[aria-checked="true"] .track::after { transform: translateX(14px); background: var(--on-accent); }
@media (prefers-reduced-motion: no-preference) {
  .btn, .icon-btn, .nav, .tab, .switch .track { transition: background-color var(--motion-fast) ease-out; }
  .switch .track::after { transition: transform var(--motion-fast) ease-out; }
}

/* Tabela */
.table-wrap { position: relative; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; text-align: left; }
th, td { padding: 11px 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { font-size: 12px; color: var(--muted); font-weight: 600; white-space: nowrap; }
td small { display: block; color: var(--muted); }
tbody tr:hover { background: var(--hover); }
tbody tr:last-child td { border-bottom: 0; }

/* Popover de notificações: abre abaixo do sino, sem trocar de tela */
.popover { position: absolute; top: calc(100% + var(--space-2)); right: 0; width: min(380px, calc(100vw - 2 * var(--space-3))); max-height: min(65dvh, 480px); overflow: auto; overscroll-behavior: contain; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md); box-shadow: var(--shadow); z-index: 60; }
.popover-head { position: sticky; top: 0; background: var(--surface); display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: var(--space-1) var(--space-2); padding: var(--space-3); border-bottom: 1px solid var(--border); }
.popover-head .inline { gap: var(--space-1); }
.note { display: block; padding: var(--space-3); border-bottom: 1px solid var(--border); text-decoration: none; }
.note:hover { background: var(--hover); }
.note.unread { background: var(--soft); }
.note strong { display: block; font-size: 13px; }
.note span { display: block; color: var(--muted); font-size: 12px; }

/* Diálogo */
dialog { width: min(560px, calc(100% - 2 * var(--space-3))); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: var(--space-6); background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
dialog::backdrop { background: var(--scrim); }
.dialog-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 14px; }

/* Toast */
.toast { position: fixed; bottom: calc(var(--space-5) + env(safe-area-inset-bottom, 0px)); left: 50%; transform: translateX(-50%); background: var(--accent); color: var(--on-accent); padding: var(--space-2) var(--space-4); border-radius: var(--radius-sm); box-shadow: var(--shadow); z-index: 100; font-weight: 600; max-width: calc(100vw - 2 * var(--space-4)); }

/* ---------- Atendimentos ---------- */
.inbox { display: grid; grid-template-columns: minmax(240px, 320px) minmax(0, 1fr) minmax(250px, 310px); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md); min-height: calc(100dvh - var(--topbar-size) - 120px); overflow: hidden; }
.inbox-list { border-right: 1px solid var(--border); display: flex; flex-direction: column; min-width: 0; }
.inbox-list .tabs { margin: 0; padding: var(--space-1) var(--space-2) 0; background: var(--soft); }
.inbox-items { overflow: auto; flex: 1; }
.inbox-list .tabs { flex-wrap: wrap; overflow: visible; gap: 0; }
.inbox-list .tab { padding: 10px 7px; font-size: 13px; gap: 5px; }
.stack > * + * { margin-top: 14px; }
.conv { display: flex; gap: var(--space-3); padding: var(--space-3) var(--space-4); border-bottom: 1px solid var(--border); text-decoration: none; border-left: 3px solid transparent; }
.conv:hover { background: var(--hover); }
.conv[aria-current="true"] { background: var(--selected); border-left-color: var(--accent); }
.tab:focus-visible, .conv:focus-visible, .note:focus-visible { outline-offset: -3px; }
.conv-main { min-width: 0; flex: 1; display: grid; gap: 3px; }
.conv-top { display: flex; justify-content: space-between; gap: 8px; }
.conv-top strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conv-preview { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.chat { display: flex; flex-direction: column; min-width: 0; background: var(--chat); }
.chat-head { display: flex; justify-content: space-between; align-items: center; gap: var(--space-2); padding: var(--space-3) var(--space-4); border-bottom: 1px solid var(--border); background: var(--surface); flex-wrap: wrap; }
.messages { flex: 1; overflow: auto; padding: var(--space-4); display: flex; flex-direction: column; gap: var(--space-2); max-height: calc(100dvh - 330px); min-height: 260px; }
.bubble { max-width: min(78%, 560px); padding: var(--space-2) var(--space-3); border-radius: var(--radius-md); background: var(--bubble-lead); border: 1px solid var(--border); white-space: pre-wrap; overflow-wrap: anywhere; }
.bubble.out { align-self: flex-end; background: var(--bubble-bot); }
.bubble.agent { background: var(--bubble-agent); }
.bubble .who { display: block; font-size: 12px; font-weight: 700; margin-bottom: 2px; }
.bubble time { display: block; text-align: right; font-size: 11px; color: var(--muted); margin-top: 3px; }
.message-meta { display: flex; flex-wrap: wrap; justify-content: flex-end; align-items: center; gap: 2px 9px; margin-top: 4px; color: var(--muted); font-size: 11px; }
.message-meta time { margin: 0; }
.delivery-failed { color: var(--danger); font-weight: 600; }
.bubble.failed { border-color: var(--danger); }
.sysnote { align-self: center; font-size: var(--type-small); background: var(--warn-soft); color: var(--warn); border-radius: var(--radius-pill); padding: var(--space-1) var(--space-3); text-align: center; }
.composer { display: flex; gap: var(--space-2); padding: var(--space-3) var(--space-4); border-top: 1px solid var(--border); background: var(--surface); }
.composer textarea { min-height: var(--control-size); height: var(--control-size); }
.lead-panel { border-left: 1px solid var(--border); padding: var(--space-4); display: flex; flex-direction: column; gap: var(--space-3); overflow: auto; min-width: 0; }
.stage-bar { display: flex; gap: 4px; }
.stage-bar span { flex: 1; height: 5px; border-radius: 3px; background: var(--border); }
.stage-bar span.on { background: var(--accent); }
.kv .row { font-size: 13px; }
.kv .row span:first-child { color: var(--muted); }
.kv .row span:last-child { text-align: right; overflow-wrap: anywhere; }

/* ---------- Funil ---------- */
.board { display: grid; grid-template-columns: repeat(5, minmax(220px, 1fr)); gap: 12px; overflow-x: auto; padding-bottom: 8px; }
.column { background: var(--soft); border-radius: var(--radius-md); padding: var(--space-3); min-height: 300px; display: flex; flex-direction: column; gap: var(--space-2); }
.column.drop { outline: 2px dashed var(--focus); }
.column-head { display: flex; align-items: center; justify-content: space-between; padding: 2px 4px 6px; }
.lead-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: var(--space-3); display: grid; gap: var(--space-2); cursor: grab; }
.lead-card:hover { border-color: var(--control-border); }
.lead-card a { font-weight: 700; text-decoration: none; }
.lead-card a:hover { text-decoration: underline; }
.lead-card select { min-height: 32px; padding: 4px 8px; font-size: 12px; }

/* ---------- Bot e base ---------- */
.choice { display: grid; gap: var(--space-1); text-align: left; padding: var(--space-4); border-radius: var(--radius-md); border: 1px solid var(--border); background: var(--surface); }
.choice[aria-pressed="true"] { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.question-row { display: grid; grid-template-columns: 130px minmax(0, 1fr) 80px var(--control-size); gap: var(--space-2); align-items: center; }
.kb-item { display: flex; justify-content: space-between; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--border); }
.kb-item:last-child { border-bottom: 0; }
.kb-item p { color: var(--muted); font-size: 13px; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.test-chat { display: flex; flex-direction: column; gap: var(--space-2); min-height: 220px; max-height: 380px; overflow: auto; background: var(--chat); border-radius: var(--radius-md); padding: var(--space-3); border: 1px solid var(--border); }
.schedule-row { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--space-2); align-items: center; max-width: 370px; }
.schedule-row input[type="time"] { min-width: 0; }
.log { font-size: 13px; display: grid; grid-template-columns: 150px 1fr; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--border); }
.log:last-child { border-bottom: 0; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { display: inline-flex; align-items: center; gap: var(--space-1); border-radius: var(--radius-pill); padding: var(--space-1) var(--space-1) var(--space-1) var(--space-2); background: var(--soft); font-size: var(--type-label); }
.chip button { border: 0; background: none; width: var(--space-6); height: var(--space-6); border-radius: 50%; display: grid; place-items: center; }
.chip button:hover { background: var(--hover); }
.logo-editor { display: flex; gap: 14px; align-items: center; }
.logo-editor .avatar { width: 64px; height: 64px; font-size: 20px; }

/* ---------- Login ---------- */
.auth { min-height: 100dvh; display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); }
.auth main { display: flex; flex-direction: column; justify-content: center; padding: 40px clamp(20px, 6vw, 80px); gap: 22px; position: relative; }
.auth-box { width: min(100%, 400px); display: grid; gap: 18px; }
.auth-box h1 { font-size: clamp(2.125rem, 5vw, 3.25rem); }
.auth-brand { display: grid; justify-items: start; gap: clamp(72px, 23vw, 112px); width: min(100%, 400px); }
.auth-brand .brand { padding: 0; }
.auth-brand .brand-mark { width: var(--control-size); height: var(--control-size); }
.auth-brand .brand-word { font-size: 1rem; }
.auth-brand .label { width: 100%; display: flex; align-items: center; gap: var(--space-3); }
.auth-brand .label::after { content: ""; flex: 1; background: var(--border-strong); height: 1px; }
.password-entry { position: relative; }
.password-entry input { min-height: 46px; padding-inline-end: 52px; }
.password-visibility { position: absolute; inset-block: 1px; inset-inline-end: 1px; width: var(--touch-size); display: grid; place-items: center; border: 0; border-radius: var(--radius-sm); background: transparent; color: var(--muted); }
.password-visibility:hover { color: var(--text); background: var(--hover); }
.password-visibility svg { width: 19px; height: 19px; }
.auth aside { margin: var(--space-4); border-radius: var(--radius-xl); background: var(--navy); color: var(--white); padding: clamp(var(--space-6), 4vw, 64px); display: flex; flex-direction: column; justify-content: flex-end; gap: var(--space-3); }
.auth aside h2 { max-width: 13ch; border-top: 1px solid var(--silver); padding-top: var(--space-6); font-size: clamp(2.25rem, 4vw, 4.25rem); line-height: 1.04; letter-spacing: -.045em; overflow-wrap: anywhere; }
.auth aside p { color: var(--silver); }
.auth .corner { position: absolute; top: 20px; right: 20px; }
.code-input { font-size: 22px; letter-spacing: .4em; text-align: center; min-height: 52px; font-variant-numeric: tabular-nums; }

/* ---------- Admin ---------- */
.admin-layout { display: grid; grid-template-columns: minmax(0, 2.2fr) minmax(260px, 1fr); gap: 14px; align-items: start; }
.list-toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
.list-toolbar select { width: auto; max-width: 100%; }
.list-toolbar .btn.primary { margin-inline-start: auto; }
.pairing-qr:empty { display: none; }
.pairing-qr img { display: block; max-width: 100%; height: auto; }
.meeting-copy { display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: start; gap: 12px; min-width: 0; }
.meeting-time { font-variant-numeric: tabular-nums; }
.agenda-row { flex-wrap: wrap; }
.bar { height: 6px; background: var(--soft); border-radius: 3px; overflow: hidden; margin-top: 6px; }
.bar span { display: block; height: 100%; background: var(--accent); }
.bar.warn span { background: var(--warn); }
.bar.over span { background: var(--danger); }

/* ---------- Responsivo ---------- */
@media (max-width: 1180px) {
  .inbox { grid-template-columns: minmax(220px, 300px) minmax(0, 1fr); }
  .lead-panel { grid-column: 1 / -1; border-left: 0; border-top: 1px solid var(--border); }
}
@media (max-width: 900px) {
  .admin-layout, .grid.two, .grid.three { grid-template-columns: 1fr; }
  .auth { grid-template-columns: 1fr; }
  .auth main { justify-content: flex-start; padding-top: 28px; gap: 16px; }
  .auth-box { gap: 12px; }
  .auth aside { display: none; }
}
@media (max-width: 780px) {
  :root { --page-gutter: var(--space-3); }
  .shell { flex-direction: column; }
  .sidebar { position: static; height: auto; flex: none; flex-direction: row; flex-wrap: wrap; padding: var(--space-3); border-right: 0; border-bottom: 1px solid var(--nav-border); }
  .sidebar .brand, .sidebar .company-brand { flex: 0 0 100%; padding: 0 var(--space-1) var(--space-3); }
  .company-brand .company-avatar { width: 40px; height: 40px; }
  .nav-group, .sidebar-foot { display: none; }
  .nav-links { display: flex; width: 100%; overflow-x: auto; gap: 4px; padding: 2px 4px 6px; scrollbar-width: thin; }
  .nav { flex: none; min-height: var(--touch-size); padding-inline: var(--space-2); font-size: var(--type-label); white-space: nowrap; }
  .nav[aria-current="page"] { box-shadow: inset 0 -2px var(--nav-focus); }
  .nav svg { width: 15px; height: 15px; }
  .topbar { gap: var(--space-2); }
  .top-actions { position: static; }
  .topbar .popover { right: var(--page-gutter); }
  .topbar h1 { font-size: clamp(var(--type-heading), 5vw, 1.375rem); }
  .content { padding-block: var(--space-4) 40px; }
  .icon-btn { width: var(--touch-size); height: var(--touch-size); }
  .btn, .btn.small, .link-btn, .switch, .tab, .period a, input, select, textarea,
  .composer textarea, .lead-card select { min-height: var(--touch-size); }
  input:not([type="checkbox"], [type="radio"]), select, textarea { font-size: 1rem; }
  input.code-input { font-size: 1.375rem; }
  input[type="checkbox"], input[type="radio"] { width: var(--space-6); height: var(--space-6); }
  .inbox { grid-template-columns: 1fr; }
  .inbox-list { border-right: 0; border-bottom: 1px solid var(--border); max-height: 340px; }
  .inbox.no-conversation { min-height: 0; }
  .inbox.no-conversation .inbox-list { border-bottom: 0; }
  .inbox.no-conversation .chat, .inbox.no-conversation .lead-panel { display: none; }
  .question-row { grid-template-columns: minmax(0, 1fr) 70px var(--touch-size); }
  .question-row input:first-child { grid-column: 1 / -1; }
  .log { grid-template-columns: 1fr; gap: 2px; }
  .hide-sm { display: none !important; }
}
@media (max-width: 520px) {
  .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .metric { min-height: 96px; padding: var(--space-3); }
  .metric > svg { top: var(--space-3); right: var(--space-3); }
  .list-toolbar .search { flex-basis: 100%; max-width: none; }
  .schedule-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .schedule-row label { grid-column: 1 / -1; }
}

/* =====================================================================
   Refinamentos de layout e tipografia
   ===================================================================== */

/* ---- Fontes locais (a CSP só permite arquivos do próprio servidor) ---- */
@font-face { font-family: "Geist"; src: url("/assets/fonts/geist-latin-wght-normal.woff2") format("woff2"); font-weight: 100 900; font-style: normal; font-display: swap; }
@font-face { font-family: "Geist Mono"; src: url("/assets/fonts/geist-mono-latin-wght-normal.woff2") format("woff2"); font-weight: 100 900; font-style: normal; font-display: swap; }
@font-face { font-family: "Instrument Serif"; src: url("/assets/fonts/instrument-serif-latin-400-normal.woff2") format("woff2"); font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: "Instrument Serif"; src: url("/assets/fonts/instrument-serif-latin-400-italic.woff2") format("woff2"); font-weight: 400; font-style: italic; font-display: swap; }

/* ---- Base tipográfica ---- */
body { font-weight: var(--weight-regular); font-feature-settings: "ss01", "cv11"; letter-spacing: -.003em; text-rendering: optimizeLegibility; }
h1, h2, h3 { text-wrap: balance; }
h1 { font-family: var(--font-display); font-weight: 400; letter-spacing: -.01em; line-height: 1.05; }
h2 { font-weight: var(--weight-strong); letter-spacing: -.012em; }
h3 { font-weight: var(--weight-strong); }
.topbar h1 { font-size: clamp(1.625rem, 2.4vw, 2.125rem); padding-block: 2px; }
.label, .nav-group { font-size: .6875rem; font-weight: var(--weight-strong); letter-spacing: .09em; }
.brand-word { font-weight: var(--weight-strong); letter-spacing: .28em; }
.company-name { font-weight: var(--weight-strong); letter-spacing: -.01em; }
.company-signature { font-style: italic; font-size: .875rem; letter-spacing: 0; }
.nav { font-weight: var(--weight-medium); }
.nav[aria-current="page"] { font-weight: var(--weight-strong); }
.btn, .tab, .switch, .period a, .pill, .link-btn { font-weight: var(--weight-medium); letter-spacing: -.003em; }
.btn.primary { font-weight: var(--weight-strong); }
.field { font-weight: var(--weight-medium); color: var(--text-2); }
th { font-weight: var(--weight-medium); text-transform: uppercase; letter-spacing: .07em; font-size: .6875rem; }
.metric > span:first-child { font-weight: var(--weight-medium); }
.metric strong { font-weight: var(--weight-medium); letter-spacing: -.04em; }
.count, .metric strong, .meeting-time, .bubble time, .message-meta, td.num { font-variant-numeric: tabular-nums; }
.mono, .count { font-family: var(--font-mono); }
.count { font-weight: var(--weight-medium); letter-spacing: 0; }
.auth-box h1 { font-size: clamp(2.5rem, 5.5vw, 3.75rem); }
.auth aside h2 { font-family: var(--font-display); font-weight: 400; letter-spacing: -.015em; line-height: 1.02; }
.lead-card a, .bubble .who, .note strong { font-weight: var(--weight-strong); }

/* ---- Cartões: espaçamento interno consistente entre blocos ---- */
.card { display: grid; gap: var(--space-4); align-content: start; }
.card > * { min-width: 0; }
.card > .card-head { margin-bottom: 0; }
.card > .btn, .card > a.btn, .card > button, .card > label.btn { justify-self: start; }
.card > h2 + p, .card > h2 + .muted { margin-top: calc(-1 * var(--space-2)); }
.form > h2:not(:first-child) { margin-top: var(--space-3); padding-top: var(--space-4); border-top: 1px solid var(--border); }
.stack > * + * { margin-top: var(--space-4); }

/* Cabeçalho de cartão com ferramentas à direita */
.card-tools { display: flex; align-items: center; gap: var(--space-2); flex-wrap: wrap; margin-left: auto; }
.tool-label { display: inline-flex; align-items: center; gap: var(--space-2); font-size: var(--type-small); color: var(--muted); font-weight: var(--weight-medium); }
select.compact { width: auto; min-height: 32px; padding: 4px 28px 4px 10px; font-size: var(--type-label); }

/* Campo + botão na mesma linha, sem disputa de espaço */
.composer-inline { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: var(--space-2); align-items: center; }
.composer-inline .btn { min-width: var(--control-size); }

/* ---- Campos lado a lado: rótulo, controle e ajuda alinhados por linha ---- */
.grid.two:has(> .field), .grid.three:has(> .field) { row-gap: var(--space-4); align-items: start; }
.grid.two > .field, .grid.three > .field { grid-row: span 3; grid-template-rows: subgrid; row-gap: 6px; align-items: end; }
.grid.two > .field > small, .grid.three > .field > small { align-self: start; }

/* ---- Barras com vários controles: quebram de linha de forma previsível ---- */
.inline { gap: var(--space-2) var(--space-3); }
.inline > input:not([type="checkbox"], [type="radio"]) { flex: 1 1 220px; min-width: 0; }
.inline > .btn, .form-actions > .btn { flex: none; }
.form-actions .status-line { margin-right: auto; }

/* ---- Pontos específicos ---- */
.logo-actions { display: grid; gap: var(--space-1); }
.logo-actions .inline { gap: var(--space-1) var(--space-4); }
.sidebar { flex-basis: 248px; }
.nav span { min-width: 0; }
.inbox-list .tabs { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0; padding: var(--space-1); overflow: visible; }
.inbox-list .tab { flex-direction: column; justify-content: center; gap: 3px; padding: var(--space-2) var(--space-1); font-size: var(--type-small); border-bottom-width: 2px; border-radius: var(--radius-sm); min-width: 0; }
.inbox-list .tab .count { min-width: 20px; height: 18px; font-size: .625rem; }
.test-chat { min-height: 260px; }
.kv .row { gap: var(--space-4); }
.protections { display: grid; gap: var(--space-3); }
.protection { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: var(--space-3); align-items: start; padding: var(--space-3) var(--space-4); border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--soft); font-weight: var(--weight-regular); }
.protection input { margin-top: 2px; }
.protection strong { display: block; font-weight: var(--weight-strong); }
.protection small { display: block; color: var(--muted); margin-top: 2px; }
.protection-list { margin: 0; padding-left: var(--space-5); color: var(--muted); font-size: var(--type-label); display: grid; gap: var(--space-1); }

@media (max-width: 780px) {
  .sidebar { flex-basis: auto; }
  .topbar h1 { white-space: normal; overflow-wrap: anywhere; }
  .grid.two > .field, .grid.three > .field { grid-row: auto; grid-template-rows: none; }
  .card-tools { margin-left: 0; width: 100%; justify-content: space-between; }
}

@media (max-width: 380px) {
  .workspace:has(.top-actions > :nth-child(4)) { --topbar-size: 100px; }
  .topbar:has(.top-actions > :nth-child(4)) { flex-wrap: wrap; align-content: center; padding-block: var(--space-2); }
  .topbar:has(.top-actions > :nth-child(4)) h1 { flex-basis: 100%; }
  .topbar:has(.top-actions > :nth-child(4)) .top-actions { margin-inline-start: 0; }
}

/* ---- Acessos da equipe ---- */
.seat-usage { display: grid; gap: var(--space-1); min-width: 160px; margin-left: auto; }
.seat-copy { display: flex; align-items: baseline; justify-content: flex-end; gap: var(--space-2); }
.seat-count { font-family: var(--font-mono); font-weight: var(--weight-medium); font-variant-numeric: tabular-nums; }
.seat-usage .bar { margin-top: 0; }
@media (max-width: 780px) { .seat-usage { margin-left: 0; width: 100%; } .seat-copy { justify-content: flex-start; } }
