/* CRM Clínicas — tema claro (fase 1) */
:root {
  --accent: #2F6BFF;
  --accent-soft: color-mix(in srgb, var(--accent) 9%, #ffffff);
  --accent-softer: color-mix(in srgb, var(--accent) 5%, #ffffff);
  --accent-ring: color-mix(in srgb, var(--accent) 30%, transparent);
  --bg: #EEF1F6;
  --surface: #FFFFFF;
  --surface-2: #F6F7FA;
  --surface-3: #F0F2F6;
  --border: #E6E9EF;
  --border-strong: #D9DEE7;
  --text: #12131A;
  --text-2: #3B4354;
  --text-3: #4A5162;
  --muted: #6B7385;
  --faint: #6F7789;
  --ink: #12131A;
  --green: #15803D; --green-bg: #E7F6EC;
  --amber: #B45309; --amber-bg: #FEF3E2;
  --red: #DC2626; --red-bg: #FDECEC;
  --violet: #5B3FD1; --violet-bg: #F0EBFF;
  --blue: #2455D6; --blue-bg: #E8EFFF;
  --radius: 22px;
  --radius-sm: 12px;
  --shadow-hover: 0 12px 28px rgba(30, 41, 80, .10);
  --shadow-pop: 0 24px 60px rgba(15, 23, 42, .18);
  --sidebar-w: 248px;
  --font: 'Plus Jakarta Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font-family: var(--font); font-size: 14px; line-height: 1.45; }
a { color: inherit; text-decoration: none; }
code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .92em; background: var(--surface-3); padding: 1px 6px; border-radius: 6px; }
h1, h2, h3 { margin: 0; letter-spacing: -.02em; }
[x-cloak] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 3px solid var(--accent-ring); outline-offset: 2px; }
.muted { color: var(--muted); }

/* ---------- Estrutura ---------- */
.app { display: flex; min-height: 100vh; }
.sidebar {
  width: var(--sidebar-w); flex-shrink: 0; background: var(--surface); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; gap: 22px; padding: 22px 16px; position: sticky; top: 0; height: 100vh;
  transition: width .25s ease;
}
.brand { display: flex; align-items: center; gap: 12px; padding: 0 6px; min-height: 42px; }
.brand-mark {
  width: 40px; height: 40px; border-radius: 12px; background: var(--accent); color: #fff; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; font-size: 18px; font-weight: 800; overflow: hidden;
}
.brand-mark img { width: 100%; height: 100%; object-fit: cover; background: #fff; }
.brand-text { display: flex; flex-direction: column; min-width: 0; }
.brand-text strong { font-size: 15px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand-text span { font-size: 12px; color: var(--muted); }
.nav { display: flex; flex-direction: column; gap: 18px; overflow-y: auto; flex-grow: 1; margin: 0 -4px; padding: 0 4px; }
.nav-section { display: flex; flex-direction: column; gap: 2px; }
.nav-title { font-size: 11px; font-weight: 600; letter-spacing: .1em; text-transform: uppercase; color: var(--faint); padding: 0 12px 6px; }
.nav-link {
  display: flex; align-items: center; gap: 12px; height: 44px; padding: 0 12px; border-radius: 12px;
  font-size: 14px; font-weight: 500; color: var(--text-3); transition: background .15s ease, color .15s ease;
}
.nav-link:hover { background: #F3F5F9; color: var(--text); }
.nav-link.active { background: var(--accent-soft); color: var(--accent); font-weight: 700; }
.nav-link svg { flex-shrink: 0; }
.nav-link .label { flex-grow: 1; white-space: nowrap; }
.nav-soon { white-space: nowrap; font-size: 10px; font-weight: 700; color: var(--faint); background: var(--surface-3); border-radius: 999px; padding: 2px 7px; }

.user-menu { position: relative; }
.user-card {
  width: 100%; display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 16px;
  background: var(--surface-2); border: 1px solid var(--border); font: inherit; color: inherit; cursor: pointer; text-align: left;
}
.user-card:hover { border-color: var(--border-strong); }
.user-card .who { display: flex; flex-direction: column; flex-grow: 1; min-width: 0; }
.user-card .who strong { font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-card .who span { font-size: 12px; color: var(--muted); }
.dropdown {
  position: absolute; left: 0; right: 0; bottom: calc(100% + 8px); background: var(--surface); border: 1px solid var(--border);
  border-radius: 16px; box-shadow: var(--shadow-pop); padding: 6px; display: flex; flex-direction: column; z-index: 30;
}
.dropdown a, .dropdown button {
  display: flex; align-items: center; gap: 10px; height: 42px; padding: 0 12px; border-radius: 10px; font: inherit;
  font-size: 13px; font-weight: 600; color: var(--text-2); background: none; border: 0; cursor: pointer; text-align: left; width: 100%;
}
.dropdown a:hover, .dropdown button:hover { background: var(--surface-2); }
.dropdown .danger { color: var(--red); }

.collapse-btn {
  position: absolute; top: 30px; right: -14px; width: 28px; height: 28px; border-radius: 14px; background: var(--surface);
  border: 1px solid var(--border); display: flex; align-items: center; justify-content: center; cursor: pointer; color: var(--text-3);
  transition: transform .25s ease;
}
.sidebar.collapsed { width: 84px; }
.sidebar.collapsed .brand-text, .sidebar.collapsed .nav-title, .sidebar.collapsed .label,
.sidebar.collapsed .nav-soon, .sidebar.collapsed .user-card .who { display: none; }
.sidebar.collapsed .nav-link, .sidebar.collapsed .user-card { justify-content: center; padding: 0; }
.sidebar.collapsed .user-card { padding: 10px 0; }
.sidebar.collapsed .collapse-btn { transform: rotate(180deg); }

.main { flex-grow: 1; min-width: 0; padding: 26px 32px 40px; display: flex; flex-direction: column; gap: 20px; }
.topbar { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.topbar-title { flex-grow: 1; display: flex; flex-direction: column; gap: 4px; min-width: 220px; }
.topbar-title h1 { font-size: 30px; font-weight: 700; }
.topbar-title p { margin: 0; color: var(--muted); font-size: 14px; }
.btn.mobile-menu { display: none; }

/* ---------- Componentes ---------- */
.card { background: var(--surface); border-radius: var(--radius); padding: 22px 24px; }
.card-head { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.card-head h2 { font-size: 17px; font-weight: 700; flex-grow: 1; }
.card-head p { margin: 2px 0 0; font-size: 13px; color: var(--muted); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 44px; padding: 0 20px; border-radius: 999px;
  border: 1px solid transparent; font: inherit; font-size: 14px; font-weight: 700; cursor: pointer; white-space: nowrap;
  transition: filter .15s ease, background .15s ease, border-color .15s ease, transform .1s ease;
  background: var(--surface); color: var(--text);
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { filter: brightness(1.08); }
.btn-dark { background: var(--ink); color: #fff; }
.btn-dark:hover { filter: brightness(1.25); }
.btn-ghost { background: var(--surface); border-color: var(--border-strong); color: var(--text); }
.btn-ghost:hover { background: var(--surface-2); }
.btn-danger { background: var(--surface); border-color: #F3C9C9; color: var(--red); }
.btn-danger:hover { background: var(--red-bg); }
.btn-sm { height: 36px; padding: 0 14px; font-size: 13px; }
.btn-lg { height: 50px; padding: 0 26px; font-size: 15px; }
.btn-icon { width: 40px; height: 40px; padding: 0; border-radius: 20px; border-color: var(--border); }
.btn-icon:hover { background: var(--surface-2); }
.btn[disabled] { opacity: .5; cursor: not-allowed; }

.pill-group { display: inline-flex; gap: 4px; padding: 5px; background: var(--surface); border: 1px solid var(--border); border-radius: 999px; }
.pill { height: 36px; padding: 0 18px; border-radius: 999px; font-size: 13px; font-weight: 600; color: var(--text-3); display: inline-flex; align-items: center; transition: background .15s ease; }
.pill:hover { background: var(--surface-2); }
.pill.active { background: var(--ink); color: #fff; }

.tag { display: inline-flex; align-items: center; gap: 6px; font-size: 11px; font-weight: 700; padding: 3px 10px; border-radius: 999px; background: var(--surface-3); color: var(--text-2); white-space: nowrap; }
.tag-blue { background: var(--blue-bg); color: var(--blue); }
.tag-violet { background: var(--violet-bg); color: var(--violet); }
.tag-green { background: var(--green-bg); color: var(--green); }
.tag-amber { background: var(--amber-bg); color: var(--amber); }
.tag-red { background: var(--red-bg); color: var(--red); }
.tag-dark { background: var(--ink); color: #fff; }
.dot { width: 10px; height: 10px; border-radius: 5px; display: inline-block; flex-shrink: 0; }

.avatar {
  width: 36px; height: 36px; border-radius: 18px; background: var(--accent-soft); color: var(--accent);
  display: inline-flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 800; flex-shrink: 0;
}
.avatar-dark { background: var(--ink); color: #fff; }

/* KPIs */
.kpi-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 16px; }
.kpi { background: var(--surface); border-radius: var(--radius); padding: 18px 20px; display: flex; flex-direction: column; gap: 12px; transition: transform .25s ease, box-shadow .25s ease; }
.kpi:hover { transform: translateY(-3px); box-shadow: var(--shadow-hover); }
.kpi-top { display: flex; align-items: center; gap: 8px; }
.kpi-label { font-size: 13px; font-weight: 500; color: var(--muted); flex-grow: 1; }
.kpi-icon { width: 34px; height: 34px; border-radius: 17px; background: var(--accent-soft); color: var(--accent); display: flex; align-items: center; justify-content: center; }
.kpi-value { font-size: 32px; font-weight: 700; letter-spacing: -.02em; line-height: 1; }
.kpi-hint { font-size: 12px; color: var(--muted); }
.kpi.hero { background: linear-gradient(135deg, var(--accent) 0%, color-mix(in srgb, var(--accent) 60%, #ffffff) 100%); color: #fff; }
.kpi.hero .kpi-label, .kpi.hero .kpi-hint { color: rgba(255, 255, 255, .88); }
.kpi.hero .kpi-icon { background: #fff; }
.kpi.dark .kpi-icon { background: var(--ink); color: #fff; }

/* Formulários */
.form { display: flex; flex-direction: column; gap: 18px; }
.form h2 { font-size: 16px; font-weight: 700; margin-top: 4px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.field { display: flex; flex-direction: column; gap: 7px; }
.field > span, .field-label { font-size: 13px; font-weight: 600; color: var(--text-2); }
.field small { font-size: 12px; color: var(--muted); }
.input, .field input:not([type=checkbox]):not([type=radio]):not([type=file]):not([type=color]), .field select, .field textarea {
  width: 100%; height: 46px; padding: 0 16px; border-radius: 14px; border: 1px solid var(--border-strong); background: var(--surface);
  font: inherit; font-size: 14px; color: var(--text); transition: border-color .15s ease, box-shadow .15s ease;
}
.field textarea { height: auto; min-height: 110px; padding: 12px 16px; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus, .input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-ring); }
.form-actions { display: flex; gap: 10px; justify-content: flex-end; align-items: center; padding-top: 4px; }
.check { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-radius: 14px; border: 1px solid var(--border); cursor: pointer; }
.check:hover { background: var(--surface-2); }
.check input { width: 18px; height: 18px; accent-color: var(--accent); }

.color-options { display: flex; flex-wrap: wrap; gap: 10px; }
.swatch { position: relative; cursor: pointer; }
.swatch input { position: absolute; opacity: 0; pointer-events: none; }
.swatch span { display: block; width: 40px; height: 40px; border-radius: 20px; border: 3px solid #fff; box-shadow: 0 0 0 1px var(--border-strong); transition: box-shadow .15s ease, transform .15s ease; }
.swatch input:checked + span { box-shadow: 0 0 0 3px var(--text); transform: scale(1.05); }
.swatch input:focus-visible + span { outline: 3px solid var(--accent-ring); outline-offset: 3px; }
.swatch-custom { display: flex; align-items: center; gap: 8px; }
.swatch-custom input[type=color] { width: 44px; height: 44px; padding: 0; border: 0; background: none; cursor: pointer; }

/* Tabelas */
.table-wrap { overflow-x: auto; margin: 0 -8px; }
.table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 14px; }
.table th { text-align: left; font-size: 12px; font-weight: 600; color: var(--muted); background: var(--surface-2); padding: 11px 12px; white-space: nowrap; }
.table th:first-child { border-radius: 12px 0 0 12px; }
.table th:last-child { border-radius: 0 12px 12px 0; }
.table td { padding: 12px; border-bottom: 1px solid #F0F2F6; vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr { transition: background .15s ease; }
.table tbody tr:hover { background: #F8F9FC; }
.table .person { display: flex; align-items: center; gap: 12px; }
.table .person strong { display: block; font-weight: 700; }
.table .person span { font-size: 12px; color: var(--muted); }
.row-actions { display: flex; gap: 6px; justify-content: flex-end; }
tr.inativo td { opacity: .55; }

/* Avisos */
.notice { padding: 14px 16px; border-radius: 16px; font-size: 13px; line-height: 1.5; display: flex; flex-direction: column; gap: 4px; }
.notice-error { background: var(--red-bg); color: #991B1B; }
.notice-warn { background: var(--amber-bg); color: #92400E; }
.notice-info { background: var(--accent-soft); color: var(--text-2); }
.notice-success { background: var(--green-bg); color: #166534; }

.toasts { position: fixed; bottom: 20px; right: 20px; display: flex; flex-direction: column; gap: 10px; z-index: 60; max-width: min(420px, calc(100vw - 40px)); }
.toast {
  display: flex; align-items: flex-start; gap: 12px; padding: 14px 16px; border-radius: 16px; background: var(--surface);
  box-shadow: var(--shadow-pop); font-size: 14px; font-weight: 600; border-left: 0;
  animation: toast-in .35s cubic-bezier(.2, .8, .2, 1);
}
.toast .ico { width: 26px; height: 26px; border-radius: 13px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.toast.success .ico { background: var(--green-bg); color: var(--green); }
.toast.error .ico { background: var(--red-bg); color: var(--red); }
.toast button { margin-left: auto; background: none; border: 0; cursor: pointer; color: var(--muted); padding: 2px; }
@keyframes toast-in { from { opacity: 0; transform: translateY(-10px) scale(.98); } to { opacity: 1; transform: none; } }

/* Modal */
.modal-backdrop { position: fixed; inset: 0; background: rgba(15, 23, 42, .35); z-index: 50; display: flex; align-items: center; justify-content: center; padding: 20px; }
.modal { width: min(560px, 100%); background: var(--surface); border-radius: 26px; box-shadow: var(--shadow-pop); max-height: calc(100vh - 40px); overflow: auto; }
.modal-head { display: flex; align-items: center; gap: 12px; padding: 20px 24px; border-bottom: 1px solid #EEF0F4; }
.modal-head h2 { font-size: 18px; font-weight: 700; flex-grow: 1; }
.modal-body { padding: 22px 24px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 16px 24px; border-top: 1px solid #EEF0F4; }

/* Abas de configurações */
.tabs { display: flex; gap: 4px; padding: 5px; background: var(--surface); border: 1px solid var(--border); border-radius: 999px; width: fit-content; }
.tabs a { height: 38px; padding: 0 18px; border-radius: 999px; display: inline-flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 600; color: var(--text-3); }
.tabs a:hover { background: var(--surface-2); }
.tabs a.active { background: var(--ink); color: #fff; }

/* Vazio / em breve */
.empty { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 12px; padding: 56px 24px; }
.empty-icon { width: 72px; height: 72px; border-radius: 24px; background: var(--accent-soft); color: var(--accent); display: flex; align-items: center; justify-content: center; }
.empty h2 { font-size: 22px; font-weight: 700; }
.empty p { margin: 0; color: var(--muted); max-width: 480px; font-size: 14px; line-height: 1.6; }

/* Painel */
.dash-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 16px; }
.span-2 { grid-column: span 2; }
.span-3 { grid-column: span 3; }
.funnel-row { display: flex; flex-direction: column; gap: 6px; }
.funnel-top { display: flex; font-size: 13px; gap: 8px; }
.funnel-top span:first-child { flex-grow: 1; color: var(--text-3); font-weight: 500; }
.funnel-top b { font-weight: 700; }
.bar-track { height: 10px; border-radius: 5px; background: var(--surface-3); overflow: hidden; }
.bar-fill { height: 10px; border-radius: 5px; transition: width .7s cubic-bezier(.2, .8, .2, 1); }
.steps { display: flex; flex-direction: column; gap: 8px; }
.step { display: flex; align-items: center; gap: 14px; padding: 12px 14px; border-radius: 16px; border: 1px solid var(--border); transition: background .15s ease; }
a.step:hover { background: var(--surface-2); }
.step-check { width: 28px; height: 28px; border-radius: 14px; border: 2px solid var(--border-strong); display: flex; align-items: center; justify-content: center; flex-shrink: 0; color: #fff; }
.step.done .step-check { background: var(--green); border-color: var(--green); }
.step-text { display: flex; flex-direction: column; flex-grow: 1; }
.step-text strong { font-size: 14px; }
.step-text span { font-size: 12px; color: var(--muted); }
.step.done .step-text strong { color: var(--muted); text-decoration: line-through; }
.progress { height: 8px; border-radius: 4px; background: var(--surface-3); overflow: hidden; }
.progress > div { height: 8px; border-radius: 4px; background: var(--accent); }

/* Etapas */
.stage-list { display: flex; flex-direction: column; gap: 8px; }
.stage {
  display: flex; align-items: center; gap: 14px; padding: 12px 14px; border-radius: 16px; background: var(--surface);
  border: 1px solid var(--border); transition: box-shadow .2s ease, border-color .2s ease;
}
.stage:hover { border-color: var(--border-strong); }
.stage.sortable-ghost { opacity: .4; }
.stage.sortable-chosen { box-shadow: var(--shadow-hover); }
.drag { cursor: grab; color: var(--faint); display: flex; padding: 4px; border-radius: 8px; }
.drag:hover { background: var(--surface-2); }
.stage-name { flex-grow: 1; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.stage-name strong { font-size: 14px; }
.stage-name span { font-size: 12px; color: var(--muted); }
.stage-color { width: 14px; height: 14px; border-radius: 7px; flex-shrink: 0; }

/* Login */
.auth-body { min-height: 100vh; }
.auth { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); }
.auth-side {
  margin: 16px; border-radius: 30px; padding: 44px; color: #fff; display: flex; flex-direction: column; justify-content: space-between;
  background: radial-gradient(circle at 80% 10%, rgba(255, 255, 255, .22), transparent 40%),
              linear-gradient(145deg, var(--accent) 0%, color-mix(in srgb, var(--accent) 55%, #0B1330) 100%);
  position: relative; overflow: hidden;
}
.auth-side h1 { font-size: 40px; line-height: 1.1; font-weight: 800; max-width: 460px; }
.auth-side p { color: rgba(255, 255, 255, .85); font-size: 15px; max-width: 440px; line-height: 1.6; }
.auth-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.auth-stat { background: rgba(255, 255, 255, .14); border: 1px solid rgba(255, 255, 255, .2); border-radius: 18px; padding: 14px 16px; }
.auth-stat b { display: block; font-size: 15px; }
.auth-stat span { font-size: 12px; color: rgba(255, 255, 255, .85); }
.auth-form-wrap { display: flex; align-items: center; justify-content: center; padding: 40px 24px; }
.auth-form { width: min(400px, 100%); display: flex; flex-direction: column; gap: 18px; }
.auth-form h2 { font-size: 28px; font-weight: 700; }
.pw-wrap { position: relative; }
.pw-wrap input { padding-right: 52px; }
.pw-toggle { position: absolute; right: 6px; top: 5px; height: 36px; padding: 0 10px; border: 0; background: none; font: inherit; font-size: 12px; font-weight: 700; color: var(--accent); cursor: pointer; border-radius: 10px; }

/* Instalador */
.install { width: min(760px, 100%); margin: 0 auto; padding: 40px 20px; display: flex; flex-direction: column; gap: 18px; }
.install-head { display: flex; align-items: center; gap: 14px; }
.install-head h1 { font-size: 28px; font-weight: 700; }
.install-head p { margin: 2px 0 0; }
.install .card { display: flex; flex-direction: column; gap: 16px; }
.success-mark { width: 56px; height: 56px; border-radius: 28px; background: var(--green-bg); color: var(--green); display: flex; align-items: center; justify-content: center; }

/* Responsivo */
@media (max-width: 1200px) {
  .kpi-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .dash-grid { grid-template-columns: 1fr; }
  .span-2, .span-3 { grid-column: auto; }
}
@media (max-width: 900px) {
  .auth { grid-template-columns: 1fr; }
  .auth-side { display: none; }
  .sidebar { position: fixed; left: 0; top: 0; z-index: 40; transform: translateX(-100%); transition: transform .25s ease; box-shadow: none; }
  .sidebar.open { transform: none; box-shadow: var(--shadow-pop); }
  .sidebar.collapsed { width: var(--sidebar-w); }
  .collapse-btn { display: none; }
  .btn.mobile-menu { display: inline-flex; }
  .main { padding: 18px 16px 32px; }
  .topbar-title h1 { font-size: 24px; }
  .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .scrim { position: fixed; inset: 0; background: rgba(15, 23, 42, .35); z-index: 35; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}

/* ================= Fase 2 ================= */
.text-green { color: var(--green); }
.text-red { color: var(--red); }
.small { font-size: 12px; }
.ellipsis { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 220px; }
.link-accent { color: var(--accent); font-weight: 700; background: none; border: 0; cursor: pointer; font: inherit; font-size: 12px; padding: 0; }
.link-accent:hover { text-decoration: underline; }
.no-scroll { overflow: hidden; }
.input-sm, .field .input-sm { height: 40px; padding: 0 14px; border-radius: 12px; font-size: 13px; }
select.input, .input { border: 1px solid var(--border-strong); background: var(--surface); font: inherit; color: var(--text); }
.avatar-sm { width: 30px; height: 30px; border-radius: 15px; font-size: 11px; }
.avatar-xs { width: 24px; height: 24px; border-radius: 12px; font-size: 10px; }
.avatar-lg { width: 52px; height: 52px; border-radius: 26px; font-size: 16px; }
.btn-xs { width: 28px; height: 28px; border-radius: 14px; }
.is-disabled { pointer-events: none; opacity: .45; }
.nav { scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }

/* Filtros */
.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.filters-card { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; padding: 14px 16px; }
.search-box { display: flex; align-items: center; gap: 10px; height: 46px; min-width: 240px; padding: 0 16px; background: var(--surface); border: 1px solid var(--border); border-radius: 999px; color: var(--muted); }
.search-box.grow { flex-grow: 1; background: var(--surface-2); border-color: transparent; }
.search-box input { flex-grow: 1; min-width: 0; border: 0; outline: none; background: transparent; font: inherit; font-size: 13px; color: var(--text); }
.search-box:focus-within { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-ring); }
.select-pill { height: 46px; border-radius: 999px; border-color: var(--border); padding: 0 16px; }

/* Kanban */
.board { display: flex; gap: 14px; overflow-x: auto; padding-bottom: 10px; align-items: flex-start; min-height: calc(100vh - 230px); scroll-snap-type: x proximity; }
.board::-webkit-scrollbar { height: 10px; }
.board::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 5px; }
.kcol { flex: 0 0 290px; display: flex; flex-direction: column; gap: 10px; background: #F7F8FB; border: 1px solid var(--border); border-radius: 22px; padding: 14px; max-height: calc(100vh - 230px); scroll-snap-align: start; }
.kcol-head { display: flex; align-items: center; gap: 8px; padding: 2px 4px; }
.kcol-head h2 { font-size: 14px; font-weight: 700; flex-grow: 1; letter-spacing: 0; }
.kcount { font-size: 12px; font-weight: 700; color: var(--text-3); background: var(--surface); border: 1px solid var(--border); border-radius: 999px; padding: 2px 9px; }
.kcol-note { margin: -4px 4px 0; font-size: 12px; color: var(--muted); }
.klist { display: flex; flex-direction: column; gap: 10px; overflow-y: auto; min-height: 80px; padding: 2px; margin: -2px; flex-grow: 1; }
.kempty { margin: 0; text-align: center; font-size: 12px; color: var(--faint); padding: 18px 8px; border: 1.5px dashed var(--border-strong); border-radius: 14px; }
.kempty[hidden] { display: none; }
.kcard {
  background: var(--surface); border: 1.5px solid var(--surface); border-radius: 16px; padding: 13px; display: flex; flex-direction: column; gap: 9px;
  box-shadow: 0 1px 2px rgba(30, 41, 80, .05); cursor: grab; transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease; user-select: none;
}
.kcard:hover { transform: translateY(-2px); box-shadow: var(--shadow-hover); }
.kcard:focus-visible { border-color: var(--accent); }
.kcard.is-alert { border-color: #F6CFCF; }
.kcard-top { display: flex; align-items: center; gap: 10px; }
.kcard-top strong { font-size: 14px; line-height: 1.25; }
.kcard-tags { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.kcamp { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.kcard-foot { display: flex; align-items: center; gap: 8px; padding-top: 8px; border-top: 1px solid #F0F2F6; font-size: 12px; }
.ktime { display: inline-flex; align-items: center; gap: 5px; color: var(--muted); font-weight: 600; flex-grow: 1; min-width: 0; }
.kval { font-weight: 800; }
.k-ghost { opacity: .35; }
.k-chosen { box-shadow: var(--shadow-pop); }
.k-drag { transform: rotate(2deg); }
.k-flash { animation: kflash 1.2s ease; }
@keyframes kflash { 0% { border-color: var(--accent); box-shadow: 0 0 0 5px var(--accent-ring); } 100% { border-color: var(--surface); box-shadow: 0 1px 2px rgba(30, 41, 80, .05); } }

/* Ficha lateral */
.drawer-scrim { position: fixed; inset: 0; background: rgba(15, 23, 42, .30); z-index: 44; }
.drawer { position: fixed; top: 12px; right: 12px; bottom: 12px; width: min(460px, calc(100vw - 24px)); background: var(--surface); border-radius: 26px; box-shadow: var(--shadow-pop); z-index: 45; display: flex; flex-direction: column; overflow: hidden; }
.drawer-enter { transition: transform .28s cubic-bezier(.2, .8, .2, 1), opacity .2s ease; }
.drawer-from { transform: translateX(40px); opacity: 0; }
.drawer-to { transform: none; opacity: 1; }
.drawer-inner { display: flex; flex-direction: column; height: 100%; min-height: 0; }
.drawer-loading { display: flex; align-items: center; gap: 10px; padding: 28px; color: var(--muted); }
.spinner { width: 18px; height: 18px; border-radius: 9px; border: 2.5px solid var(--border-strong); border-top-color: var(--accent); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.drawer-head { display: flex; align-items: flex-start; gap: 14px; padding: 22px 22px 16px; border-bottom: 1px solid #EEF0F4; }
.drawer-title { flex-grow: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.drawer-title h2 { font-size: 21px; font-weight: 700; }
.drawer-title .muted { font-size: 13px; }
.drawer-body { flex-grow: 1; overflow-y: auto; padding: 18px 22px; display: flex; flex-direction: column; gap: 18px; }
.drawer-foot { display: flex; gap: 10px; justify-content: space-between; padding: 14px 22px; border-top: 1px solid #EEF0F4; }
.stage-box { background: var(--surface-2); border-radius: 18px; padding: 14px; display: flex; flex-direction: column; gap: 12px; }
.stage-box-top { display: flex; align-items: center; gap: 8px; font-size: 14px; }
.stage-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.stage-actions .btn { flex-grow: 1; }
.stage-actions select { flex-basis: 150px; flex-grow: 1; }
.info-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.info-grid > div { display: flex; flex-direction: column; gap: 3px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 14px; min-width: 0; }
.info-grid span { font-size: 11px; color: var(--muted); }
.info-grid strong { font-size: 13px; overflow-wrap: anywhere; }
.drawer-section { display: flex; flex-direction: column; gap: 10px; }
.drawer-section h3 { font-size: 12px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--faint); }
.section-head { display: flex; align-items: center; justify-content: space-between; }
.origin-card { display: flex; flex-direction: column; gap: 10px; padding: 12px 14px; border: 1px solid var(--border); border-radius: 16px; align-items: flex-start; }
.origin-grid { display: grid; grid-template-columns: 84px 1fr; row-gap: 6px; font-size: 13px; width: 100%; }
.origin-grid span { color: var(--muted); }
.qa { display: flex; flex-direction: column; gap: 2px; padding: 8px 0; border-bottom: 1px solid #F0F2F6; font-size: 13px; }
.qa span { color: var(--muted); font-size: 12px; }
.mini-row { display: flex; align-items: center; gap: 10px; font-size: 13px; padding: 8px 10px; border-radius: 12px; background: var(--surface-2); }
.mini-row span:nth-child(2) { flex-grow: 1; color: var(--muted); }
.note-form { display: flex; gap: 8px; }
.note-form input { flex-grow: 1; }
.timeline { list-style: none; margin: 0; padding: 0 0 0 4px; display: flex; flex-direction: column; }
.timeline li { display: flex; gap: 12px; position: relative; padding-bottom: 14px; }
.timeline li::before { content: ''; position: absolute; left: 4px; top: 12px; bottom: 0; width: 2px; background: #EEF0F4; }
.timeline li:last-child::before { display: none; }
.t-dot { width: 10px; height: 10px; border-radius: 5px; background: #C9D6FF; margin-top: 5px; flex-shrink: 0; position: relative; z-index: 1; }
.timeline li.is-note .t-dot { background: var(--accent); }
.timeline p { margin: 0; font-size: 13px; color: var(--text-2); }
.timeline li.is-note p { background: var(--accent-softer); padding: 8px 10px; border-radius: 10px; color: var(--text); }
.timeline span { font-size: 11px; color: var(--faint); }

/* Modais pequenos */
.modal-sm { width: min(460px, 100%); }
.modal-icon { width: 34px; height: 34px; border-radius: 17px; display: flex; align-items: center; justify-content: center; }
.modal-icon.ok { background: var(--green-bg); color: var(--green); }
.modal-icon.bad { background: var(--red-bg); color: var(--red); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 4px; }
.chip { height: 34px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--border-strong); background: var(--surface); font: inherit; font-size: 13px; font-weight: 600; color: var(--text-2); cursor: pointer; }
.chip:hover { background: var(--surface-2); }
.chip.on { background: var(--ink); color: #fff; border-color: var(--ink); }
.picked { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 14px; background: var(--surface-2); }
.picked strong { flex-grow: 1; }
.autocomplete { position: relative; }
.autocomplete .input { width: 100%; height: 46px; padding: 0 16px; border-radius: 14px; }
.ac-list { position: absolute; left: 0; right: 0; top: calc(100% + 6px); background: var(--surface); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow-pop); z-index: 5; padding: 6px; display: flex; flex-direction: column; }
.ac-list button { display: flex; justify-content: space-between; gap: 10px; padding: 10px 12px; border: 0; background: none; border-radius: 10px; font: inherit; font-size: 13px; cursor: pointer; text-align: left; }
.ac-list button:hover { background: var(--surface-2); }
.ac-list span { color: var(--muted); }

/* Leads */
.table-click tbody tr { cursor: pointer; }
.stage-pill { display: inline-flex; align-items: center; gap: 8px; font-weight: 600; font-size: 13px; white-space: nowrap; }
.pager { display: flex; align-items: center; justify-content: center; gap: 14px; padding-top: 14px; }

/* Agenda */
.kpi-grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.week { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 12px; }
.day { background: var(--surface); border-radius: 20px; padding: 12px; display: flex; flex-direction: column; gap: 10px; min-height: 360px; border: 1.5px solid var(--surface); }
.day.is-today { border-color: var(--accent); }
.day-head { display: flex; align-items: center; gap: 6px; padding: 0 2px; }
.day-head span { font-size: 12px; font-weight: 600; color: var(--muted); }
.day-head b { font-size: 18px; flex-grow: 1; }
.day.is-today .day-head b { color: var(--accent); }
.day-list { display: flex; flex-direction: column; gap: 8px; }
.day-empty { margin: 0; font-size: 12px; color: var(--faint); text-align: center; padding: 14px 0; border: 1.5px dashed var(--border); border-radius: 12px; }
.appt { border-radius: 14px; background: var(--surface-2); border-left: 0; display: flex; flex-direction: column; overflow: visible; position: relative; }
.appt-main { display: flex; flex-direction: column; gap: 2px; padding: 10px 10px 6px; border: 0; background: none; font: inherit; text-align: left; cursor: pointer; color: var(--text); border-radius: 14px 14px 0 0; }
.appt-main:hover { background: #EEF1F6; }
.appt-main strong { font-size: 13px; line-height: 1.25; }
.appt-time { font-size: 12px; font-weight: 800; color: var(--accent); }
.appt-foot { padding: 0 10px 10px; position: relative; }
.appt-status { border: 0; cursor: pointer; font-family: inherit; }
.appt.status-cancelado .appt-main strong { text-decoration: line-through; color: var(--muted); }
.appt.status-faltou .appt-time { color: var(--red); }
.appt.status-compareceu .appt-time { color: var(--green); }
.mini-menu { position: absolute; left: 8px; top: calc(100% - 6px); z-index: 10; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow-pop); padding: 4px; display: flex; flex-direction: column; min-width: 140px; }
.mini-menu button { height: 34px; padding: 0 10px; border: 0; background: none; text-align: left; font: inherit; font-size: 13px; font-weight: 600; border-radius: 8px; cursor: pointer; }
.mini-menu button:hover { background: var(--surface-2); }

/* Confete */
.confetti { position: fixed; inset: 0; pointer-events: none; z-index: 70; overflow: hidden; }
.confetti i { position: absolute; top: 55%; width: 9px; height: 14px; border-radius: 2px; animation: confete 1.3s cubic-bezier(.2, .7, .3, 1) forwards; }
@keyframes confete { 0% { transform: translate(0, 0) rotate(0); opacity: 1; } 100% { transform: translate(var(--dx), calc(var(--dy) + 520px)) rotate(var(--r)); opacity: 0; } }

@media (max-width: 1200px) {
  .week { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .kpi-grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 900px) {
  .week { grid-template-columns: 1fr; }
  .day { min-height: 0; }
  .kcol { flex-basis: 84vw; }
  .board { min-height: 0; }
  .search-box { min-width: 0; width: 100%; }
  .info-grid { grid-template-columns: 1fr; }
}
.filters .input, .filters-card .input { width: auto; min-width: 180px; }

/* ================= Fase 5 ================= */
.span-5 { grid-column: 1 / -1; }
.num { text-align: right; white-space: nowrap; }
.table th.num { text-align: right; }
.notice-row { flex-direction: row; align-items: center; gap: 12px; }
.notice-row svg { flex-shrink: 0; color: var(--accent); }

/* Gráfico de colunas */
.chart { display: flex; flex-direction: column; gap: 8px; }
.chart-plot { position: relative; display: flex; align-items: flex-end; gap: 8px; border-bottom: 1px solid var(--border-strong); }
.chart-grid { position: absolute; inset: 0; display: flex; flex-direction: column; justify-content: space-between; pointer-events: none; }
.chart-grid span { border-top: 1px dashed #E8EBF1; }
.chart-grid span:last-child { border-top: 0; }
.chart-col { position: relative; flex: 1 1 0; height: 100%; display: flex; align-items: flex-end; justify-content: center; outline: none; cursor: default; }
.chart-bar { width: 100%; max-width: 44px; border-radius: 4px 4px 0 0; background: color-mix(in srgb, var(--accent) 45%, #ffffff); transition: background .15s ease, height .6s cubic-bezier(.2, .8, .2, 1); }
.chart-col.is-hi .chart-bar { background: var(--accent); }
.chart-col:hover .chart-bar, .chart-col:focus-visible .chart-bar { background: var(--accent); }
.chart-tip {
  position: absolute; bottom: calc(100% + 6px); left: 50%; transform: translate(-50%, 4px); opacity: 0; pointer-events: none;
  background: var(--ink); color: #fff; border-radius: 10px; padding: 6px 10px; font-size: 12px; white-space: nowrap;
  display: flex; flex-direction: column; align-items: center; transition: opacity .15s ease, transform .15s ease; z-index: 3;
}
.chart-tip span { color: rgba(255, 255, 255, .75); font-size: 11px; }
.chart-col:hover .chart-tip, .chart-col:focus-visible .chart-tip { opacity: 1; transform: translate(-50%, 0); }
.chart-x { display: flex; gap: 8px; }
.chart-x span { flex: 1 1 0; text-align: center; font-size: 11px; font-weight: 500; color: var(--faint); }

/* Ranking */
.rank { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 14px; }
.rank li { display: flex; flex-direction: column; gap: 6px; }
.rank-top { display: flex; gap: 10px; font-size: 13px; }
.rank-top span { flex-grow: 1; color: var(--text-2); font-weight: 500; }
.rank-top b { color: var(--text); }

/* Metas */
.goal { display: flex; flex-direction: column; gap: 8px; }
.goal-top { display: flex; align-items: baseline; gap: 10px; font-size: 13px; }
.goal-top strong { flex-grow: 1; font-size: 14px; }
.goal-top span { color: var(--muted); }
.goal-top b { color: var(--text); font-size: 16px; }
.progress-lg { height: 12px; border-radius: 6px; }
.progress-lg > div { height: 12px; border-radius: 6px; transition: width .7s cubic-bezier(.2, .8, .2, 1); }

/* Campanhas */
.camp-row { cursor: pointer; }
.camp-name { display: flex; align-items: center; gap: 10px; min-width: 0; }
.camp-name strong { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chev { display: inline-flex; width: 22px; height: 22px; border-radius: 11px; background: var(--surface-3); align-items: center; justify-content: center; transform: rotate(180deg); transition: transform .2s ease; flex-shrink: 0; }
.chev.on { transform: rotate(270deg); }
.ad-row td { background: #FBFCFE; font-size: 13px; }
.ad-name { padding-left: 32px; color: var(--text-2); }
.ad-dot { width: 6px; height: 6px; border-radius: 3px; background: var(--border-strong); flex-shrink: 0; }

/* Relatórios */
.report-kpis { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.tag-on-hero { background: rgba(255, 255, 255, .22); color: #fff; }
.timeline.log p + p { margin-top: 2px; }
.print-only { display: none; }

@media print {
  @page { margin: 14mm; }
  body { background: #fff; }
  .sidebar, .no-print, .toasts, .collapse-btn, .mobile-menu { display: none !important; }
  .main { padding: 0; }
  .print-only { display: block; }
  .print-head { font-size: 12px; color: var(--muted); margin-bottom: 4px; }
  .card, .kpi { box-shadow: none !important; border: 1px solid var(--border); break-inside: avoid; }
  .kpi:hover { transform: none; }
  .kpi.hero { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .chart-bar, .bar-fill, .progress > div { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .dash-grid { grid-template-columns: 1fr; }
  .span-2, .span-3, .span-5 { grid-column: auto; }
  .main { gap: 14px; }
  .report-kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 900px) {
  .report-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
.kpi-value { white-space: nowrap; font-size: clamp(22px, 2.1vw, 32px); }
.equal-cards { gap: 16px; }

/* ---------- Fase 3 · Integrações ---------- */
.int-kpi { font-size: 24px; }
.int-top .card { display: flex; flex-direction: column; gap: 16px; }
.step-num { display: inline-flex; align-items: center; justify-content: center; width: 24px; height: 24px; border-radius: 12px; background: var(--ink); color: #fff; font-size: 12px; font-weight: 700; margin-bottom: 8px; }
.more { border-top: 1px solid var(--border); padding-top: 12px; }
.more summary { cursor: pointer; font-weight: 600; font-size: 13px; color: var(--text-2); list-style: none; display: flex; align-items: center; gap: 8px; }
.more summary::-webkit-details-marker { display: none; }
.more summary::before { content: '›'; font-size: 16px; transition: transform .15s ease; color: var(--muted); }
.more[open] summary::before { transform: rotate(90deg); }
.more[open] summary { margin-bottom: 14px; }
.btn-fb { background: #1877F2; color: #fff; align-self: flex-start; }
.btn-fb:hover { background: #0f65d6; }
.btn.is-disabled { opacity: .45; pointer-events: none; }
.fb-account { display: flex; align-items: center; gap: 14px; padding: 14px; border-radius: 16px; background: var(--surface-2); border: 1px solid var(--border); }
.fb-account > div { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.fb-avatar { background: #1877F2; color: #fff; font-size: 22px; font-weight: 800; }
.copy-grid { margin-top: 4px; }
.copy-field { display: flex; flex-direction: column; gap: 7px; min-width: 0; }
.copy-row { display: flex; align-items: center; gap: 8px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 14px; padding: 6px 6px 6px 12px; min-width: 0; }
.copy-row code { background: none; padding: 0; flex-grow: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12.5px; }
.copy-row .btn { flex-shrink: 0; min-width: 76px; }
.small { font-size: 12px; }
.small-empty { padding: 32px 24px; }
.page-list { display: flex; flex-direction: column; gap: 12px; }
.page-item { border: 1px solid var(--border); border-radius: 18px; padding: 14px 16px; display: flex; flex-direction: column; gap: 12px; }
.page-item.on { border-color: color-mix(in srgb, var(--green) 35%, var(--border)); background: linear-gradient(180deg, color-mix(in srgb, var(--green-bg) 55%, #fff) 0, #fff 64px); }
.page-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.page-foto { width: 40px; height: 40px; border-radius: 12px; object-fit: cover; flex-shrink: 0; }
.page-name { display: flex; flex-direction: column; gap: 2px; flex-grow: 1; min-width: 160px; }
.page-name .muted { font-size: 12px; }
.page-empty { margin: 0; font-size: 13px; }
.form-table td { vertical-align: middle; }
.form-table select { min-width: 170px; }
.form-table .tag { margin-left: 6px; }
.switch { position: relative; display: inline-flex; width: 42px; height: 24px; cursor: pointer; }
.switch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.switch span { width: 100%; height: 100%; border-radius: 12px; background: var(--border-strong); transition: background .2s ease; }
.switch span::after { content: ''; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.2); transition: transform .2s ease; }
.switch input:checked + span { background: var(--green); }
.switch input:checked + span::after { transform: translateX(18px); }
.switch input:focus-visible + span { outline: 3px solid var(--accent-ring); outline-offset: 2px; }
tr.inativo .switch { opacity: 1; }
.event-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.event-list li { display: flex; align-items: flex-start; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.event-list li:last-child { border-bottom: 0; }
.event-list .tag { min-width: 82px; justify-content: center; }
.ev-main { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.ev-main > a, .ev-main > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.soon-list { display: flex; flex-direction: column; gap: 8px; margin-top: 16px; }
.soon { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 14px; background: var(--surface-2); color: var(--muted); }
.soon > div { display: flex; flex-direction: column; gap: 2px; }
.soon strong { color: var(--text-2); font-size: 13px; }
.soon span { font-size: 12px; }
@media (max-width: 1100px) { .copy-grid { grid-template-columns: 1fr; } }
.grid-2 > *, .grid-3 > * { min-width: 0; }
.page-row .row-actions { flex-wrap: wrap; }
@media (max-width: 640px) { .page-row .row-actions { width: 100%; } }
.table-wrap { position: relative; }

/* ---------- Fase 4 · Conversas ---------- */
.chat-shell { display: grid; grid-template-columns: 340px minmax(0, 1fr); height: calc(100vh - 140px); min-height: 520px; background: var(--surface); border-radius: var(--radius); overflow: hidden; }
.chat-list { display: flex; flex-direction: column; border-right: 1px solid var(--border); min-height: 0; }
.chat-list-head { display: flex; flex-direction: column; gap: 10px; padding: 16px; border-bottom: 1px solid var(--border); }
.chat-list-head .search-box .input { width: 100%; }
.chat-filters { display: flex; gap: 6px; flex-wrap: wrap; }
.chat-filters .pill { border: 0; cursor: pointer; font: inherit; font-size: 12px; font-weight: 600; height: 30px; padding: 0 12px; background: var(--surface-3); }
.chat-items { flex-grow: 1; overflow-y: auto; padding: 6px; }
.chat-empty { display: flex; justify-content: center; padding: 32px 16px; text-align: center; }
.chat-item { width: 100%; display: flex; gap: 12px; align-items: flex-start; padding: 12px; border: 0; background: none; border-radius: 16px; cursor: pointer; text-align: left; font: inherit; color: inherit; }
.chat-item:hover { background: var(--surface-2); }
.chat-item.active { background: var(--accent-soft); }
.chat-item-main { display: flex; flex-direction: column; gap: 3px; min-width: 0; flex-grow: 1; }
.chat-item-top { display: flex; align-items: baseline; gap: 8px; }
.chat-item-top strong { flex-grow: 1; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-item-top small { font-size: 11px; color: var(--muted); flex-shrink: 0; }
.chat-item.esperando .chat-item-top strong { font-weight: 800; }
.chat-item-prev { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.eco-mark { color: var(--text-3); font-weight: 600; }
.chat-item-tags { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-top: 2px; }
.chat-item-tags .stage-pill { font-size: 11px; }
.unread-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--accent); margin-left: auto; }
.unread-dot.late { background: var(--red); box-shadow: 0 0 0 4px var(--red-bg); }
.chat-main { display: flex; flex-direction: column; min-width: 0; min-height: 0; background: #F4F6FA; }
.chat-placeholder { margin: auto; display: flex; flex-direction: column; align-items: center; gap: 10px; text-align: center; padding: 24px; }
.chat-pane { display: flex; flex-direction: column; height: 100%; min-height: 0; position: relative; }
.chat-head { display: flex; align-items: center; gap: 12px; padding: 12px 18px; background: var(--surface); border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.chat-head-info { display: flex; flex-direction: column; min-width: 0; flex-grow: 1; }
.chat-head-info strong { font-size: 15px; }
.chat-head-info .muted { font-size: 12px; }
.chat-back { display: none; }
.chat-body { flex-grow: 1; overflow-y: auto; padding: 18px 22px; display: flex; flex-direction: column; gap: 4px;
  background-image: radial-gradient(circle at 1px 1px, rgba(18, 19, 26, .045) 1px, transparent 0); background-size: 18px 18px; }
.chat-older { align-self: center; margin-bottom: 8px; }
.msg-wrap { display: flex; flex-direction: column; }
.day-sep { align-self: center; margin: 12px 0 8px; }
.day-sep span { font-size: 11px; font-weight: 700; color: var(--text-3); background: var(--surface); border: 1px solid var(--border); padding: 4px 12px; border-radius: 999px; }
.msg { align-self: flex-start; max-width: min(72%, 560px); background: var(--surface); border-radius: 4px 16px 16px 16px; padding: 8px 12px 6px; box-shadow: 0 1px 1px rgba(15, 23, 42, .06); display: flex; flex-direction: column; gap: 4px; }
.msg.eco { align-self: flex-end; background: color-mix(in srgb, var(--accent) 12%, #ffffff); border-radius: 16px 4px 16px 16px; }
.msg.reacao { background: transparent; box-shadow: none; padding: 2px 6px; font-size: 12px; color: var(--muted); }
.msg p { margin: 0; white-space: pre-wrap; word-wrap: break-word; overflow-wrap: anywhere; font-size: 14px; line-height: 1.45; }
.msg-time { align-self: flex-end; font-size: 10.5px; color: var(--muted); }
.msg-img { display: block; max-width: 280px; max-height: 320px; border-radius: 10px; object-fit: cover; }
.msg-audio { width: 260px; max-width: 100%; }
.msg-video { max-width: 300px; border-radius: 10px; }
.msg-doc { display: inline-flex; align-items: center; gap: 8px; padding: 10px 12px; border-radius: 10px; background: var(--surface-3); font-weight: 600; font-size: 13px; }
.msg-pend { font-size: 12px; color: var(--muted); font-style: italic; }
.chat-novas { position: absolute; bottom: 64px; left: 50%; transform: translateX(-50%); border: 0; background: var(--ink); color: #fff; font: inherit; font-size: 12px; font-weight: 700; padding: 8px 14px; border-radius: 999px; cursor: pointer; box-shadow: var(--shadow-pop); }
.chat-foot { display: flex; align-items: center; justify-content: center; gap: 8px; padding: 12px 16px; font-size: 12px; color: var(--muted); background: var(--surface); border-top: 1px solid var(--border); }
@media (max-width: 900px) {
  .chat-shell { grid-template-columns: 1fr; height: calc(100dvh - 200px); min-height: 460px; }
  .chat-shell .chat-main { display: none; }
  .chat-shell.tem-aberta .chat-list { display: none; }
  .chat-shell.tem-aberta .chat-main { display: flex; }
  .chat-back { display: inline-flex; }
  .msg { max-width: 88%; }
  .chat-body { padding: 14px; }
}
.kpi-link { color: inherit; }
.btn-wa { background: #1FAF5A; color: #fff; align-self: flex-start; }
.btn-wa:hover { background: #179a4d; }
.btn-wa:disabled { opacity: .5; }
.wa-avatar { background: #E7F8EE; color: #1FAF5A; }
.wa-config { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto; gap: 12px; align-items: end; }
@media (max-width: 720px) { .wa-config { grid-template-columns: 1fr; } }
.chat-filters .pill.active { background: var(--ink); color: #fff; }
.tabs { max-width: 100%; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs a { flex-shrink: 0; }
@media (max-width: 640px) { .pill-group { max-width: 100%; overflow-x: auto; scrollbar-width: none; } .pill-group .pill { flex-shrink: 0; } }

/* ---------- Integrações · tela simples ---------- */
.setup-check { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr); gap: 20px; align-items: center; }
.setup-progress { display: flex; align-items: center; gap: 18px; }
.setup-progress h2 { font-size: 18px; }
.setup-progress p { margin: 4px 0 0; font-size: 13px; }
.ring { --p: 0; width: 72px; height: 72px; border-radius: 50%; flex-shrink: 0; display: grid; place-items: center;
  background: conic-gradient(var(--green) calc(var(--p) * 1%), var(--surface-3) 0); }
.ring span { width: 56px; height: 56px; border-radius: 50%; background: var(--surface); display: grid; place-items: center; font-weight: 800; font-size: 16px; }
.check-list { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px 16px; }
.check-list li { display: flex; align-items: center; gap: 10px; font-size: 13px; font-weight: 600; color: var(--muted); }
.check-list li.ok { color: var(--text); }
.check-dot { width: 20px; height: 20px; border-radius: 50%; border: 2px solid var(--border-strong); display: grid; place-items: center; flex-shrink: 0; color: #fff; }
.check-list li.ok .check-dot { background: var(--green); border-color: var(--green); }
.setup-step { display: flex; flex-direction: column; gap: 16px; }
.setup-step.done { border: 1px solid color-mix(in srgb, var(--green) 30%, var(--border)); }
.setup-head { display: flex; align-items: flex-start; gap: 14px; }
.setup-num { width: 34px; height: 34px; border-radius: 50%; background: var(--ink); color: #fff; font-weight: 800; display: grid; place-items: center; flex-shrink: 0; }
.setup-step.done .setup-num { background: var(--green); }
.setup-title { flex-grow: 1; min-width: 0; }
.setup-title h2 { font-size: 18px; }
.setup-title p { margin: 4px 0 0; color: var(--muted); font-size: 13px; max-width: 680px; }
.setup-action { display: flex; flex-direction: column; gap: 12px; align-items: flex-start; }
.how-to { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--text-2); max-width: 720px; }
.mini-list { display: flex; flex-direction: column; gap: 8px; }
.mini-item { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 14px; background: var(--surface-2); }
.mini-item > div { display: flex; flex-direction: column; flex-grow: 1; min-width: 0; }
.mini-item .muted { font-size: 12px; }
.setup-cols { gap: 24px; }
.setup-sub { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin-bottom: 8px; }
.toggle-row { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.toggle-row:last-child { border-bottom: 0; }
.toggle-row > div { display: flex; flex-direction: column; gap: 2px; flex-grow: 1; min-width: 0; }
.toggle-row.big { padding: 14px 16px; border: 1px solid var(--border); border-radius: 16px; background: var(--surface-2); }
.switch-btn { position: relative; width: 42px; height: 24px; border-radius: 12px; border: 0; background: var(--border-strong); cursor: pointer; flex-shrink: 0; padding: 0; transition: background .2s ease; }
.switch-btn span { position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.2); transition: transform .2s ease; }
.switch-btn.on { background: var(--green); }
.switch-btn.on span { transform: translateX(18px); }
.switch-btn:disabled { opacity: .5; }
.setup-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; border-top: 1px solid var(--border); padding-top: 14px; }
@media (max-width: 900px) { .setup-check { grid-template-columns: 1fr; } .check-list { grid-template-columns: 1fr; } }
