/* Painel da Operação — estilo base (tokens, app shell, componentes, kanban, métricas, config, drawer).
   A aba Conversas fica em inbox.css. Sem bibliotecas: CSS moderno e JS puro. */

/* ---------- Tokens ---------- */
:root {
  --font: "Inter", "Segoe UI Variable", system-ui, -apple-system, sans-serif;
  --bg: #0b0d12;           --bg-elev: #11141b;      --surface: #161a23;    --surface-2: #1c2130;    --surface-3: #232939;
  --line: color-mix(in oklab, #ffffff 9%, transparent);   --line-strong: color-mix(in oklab, #ffffff 16%, transparent);
  --text: #e8eaf0;         --text-2: #a6acbd;       --text-3: #6f7689;
  --brand: #e0457b;        --brand-2: #ff7aa8;      --brand-soft: color-mix(in oklab, var(--brand) 18%, transparent);
  --brand-ink: #ffffff;
  --ok: #34c383;  --warn: #f2b13d;  --bad: #ef5a5a;  --info: #5b9dff;
  --ok-soft: color-mix(in oklab, var(--ok) 16%, transparent);
  --warn-soft: color-mix(in oklab, var(--warn) 16%, transparent);
  --bad-soft: color-mix(in oklab, var(--bad) 14%, transparent);
  --info-soft: color-mix(in oklab, var(--info) 16%, transparent);
  --radius-s: 8px; --radius: 12px; --radius-l: 16px;
  --shadow-1: 0 1px 2px rgba(0,0,0,.4);  --shadow-2: 0 8px 24px rgba(0,0,0,.45);
  --ring: 0 0 0 3px color-mix(in oklab, var(--brand) 35%, transparent);
  --sidebar-w: 240px; --sidebar-w-min: 64px; --topbar-h: 60px;
  --t: 140ms cubic-bezier(.2, .7, .3, 1);
  --avatar-h: 335;
  color-scheme: dark;
}
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg: #f6f7fb; --bg-elev: #ffffff; --surface: #ffffff; --surface-2: #f1f3f8; --surface-3: #e7eaf2;
    --text: #141826; --text-2: #4b5265; --text-3: #7c8399;
    --line: color-mix(in oklab, #000 10%, transparent); --line-strong: color-mix(in oklab, #000 18%, transparent);
    --brand: #d63a70; --brand-2: #b32a5c;
    --ok: #1f9d64; --warn: #b7791f; --bad: #d64545; --info: #2f6fdb;
    --shadow-1: 0 1px 2px rgba(20, 24, 38, .08); --shadow-2: 0 8px 24px rgba(20, 24, 38, .14);
    color-scheme: light;
  }
}
:root[data-theme="light"] {
  --bg: #f6f7fb; --bg-elev: #ffffff; --surface: #ffffff; --surface-2: #f1f3f8; --surface-3: #e7eaf2;
  --text: #141826; --text-2: #4b5265; --text-3: #7c8399;
  --line: color-mix(in oklab, #000 10%, transparent); --line-strong: color-mix(in oklab, #000 18%, transparent);
  --brand: #d63a70; --brand-2: #b32a5c;
  --ok: #1f9d64; --warn: #b7791f; --bad: #d64545; --info: #2f6fdb;
  --shadow-1: 0 1px 2px rgba(20, 24, 38, .08); --shadow-2: 0 8px 24px rgba(20, 24, 38, .14);
  color-scheme: light;
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body { font: 14px/1.45 var(--font); font-feature-settings: "cv11", "ss01"; overflow-x: hidden; min-height: 100vh; }
h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -.01em; }
h1 { font-size: 18px; }
h2 { font-size: 15px; }
h3 { font-size: 14px; }
p { margin: 0; }
b, strong { font-weight: 600; }
a { color: var(--brand-2); }
code { background: var(--surface-2); padding: 1px 5px; border-radius: 4px; font-size: 12.5px; }
.hidden { display: none !important; }
.muted { color: var(--text-2); }
.small { font-size: 12px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.ic { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }
.hint { color: var(--text-2); margin: 0 0 14px; font-size: 13px; max-width: 900px; }
.error { color: var(--bad); font-size: 13px; min-height: 1em; }
.ok { color: var(--ok); display: inline-flex; align-items: center; gap: 4px; font-size: 13px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.end { justify-content: flex-end; }
.only-mobile, .icon-btn.only-mobile { display: none; }
:focus-visible { outline: none; box-shadow: var(--ring); }
::selection { background: var(--brand-soft); }

/* ---------- Botões ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px; height: 36px; padding: 0 14px;
  border: 1px solid var(--line); background: var(--surface-2); color: var(--text); border-radius: var(--radius-s);
  font: inherit; font-weight: 500; cursor: pointer; white-space: nowrap; text-decoration: none;
  transition: background var(--t), border-color var(--t), color var(--t), transform var(--t);
}
.btn:hover { background: var(--surface-3); border-color: var(--line-strong); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.btn.primary:hover { background: color-mix(in oklab, var(--brand) 88%, #fff); border-color: color-mix(in oklab, var(--brand) 88%, #fff); }
.btn.secondary { background: var(--surface-2); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn.ghost:hover { background: var(--surface-2); color: var(--text); }
.btn.danger { color: var(--bad); }
.btn.danger.ghost:hover { background: var(--bad-soft); }
.btn.danger.solid { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn.small { height: 32px; padding: 0 10px; font-size: 13px; }
.btn.lg { height: 42px; font-size: 15px; }
.btn:disabled { opacity: .5; cursor: default; transform: none; }
.btn .ic { width: 16px; height: 16px; }
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center; width: 36px; height: 36px; padding: 0;
  border: 1px solid transparent; background: transparent; color: var(--text-2); border-radius: var(--radius-s); cursor: pointer;
  transition: background var(--t), color var(--t), border-color var(--t);
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn.small { width: 28px; height: 28px; }
.icon-btn.small .ic { width: 15px; height: 15px; }
.icon-btn:disabled { opacity: .5; cursor: default; }

/* ---------- Inputs ---------- */
input, select, textarea {
  background: var(--surface-2); color: var(--text); border: 1px solid var(--line);
  border-radius: var(--radius-s); padding: 0 10px; height: 36px; font: inherit; width: 100%;
  transition: border-color var(--t), box-shadow var(--t);
}
textarea { height: auto; padding: 8px 10px; resize: vertical; min-height: 36px; }
select { appearance: none; -webkit-appearance: none; padding-right: 28px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238b92a3' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 8px center; background-size: 16px; }
select.small { height: 32px; font-size: 13px; }
input:hover, select:hover, textarea:hover { border-color: var(--line-strong); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--brand); box-shadow: var(--ring); }
input:disabled, select:disabled, textarea:disabled { opacity: .6; cursor: not-allowed; }
input::placeholder, textarea::placeholder { color: var(--text-3); }
input[type=date] { min-width: 0; }
input[type=date]::-webkit-calendar-picker-indicator { opacity: .6; cursor: pointer; }
label { display: flex; flex-direction: column; gap: 5px; color: var(--text-2); font-size: 12px; font-weight: 500; }
label small { color: var(--text-3); font-size: 12px; font-weight: 400; line-height: 1.4; }
.check { flex-direction: row; align-items: center; gap: 7px; color: var(--text); font-size: 13px; font-weight: 500; cursor: pointer; }
.check input { width: 16px; height: 16px; accent-color: var(--brand); margin: 0; }

/* Interruptor */
.switch { flex-direction: row; align-items: center; gap: 10px; cursor: pointer; color: var(--text); font-size: 13.5px; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch .track { position: relative; width: 38px; height: 22px; border-radius: 99px; background: var(--surface-3); border: 1px solid var(--line-strong); transition: background var(--t), border-color var(--t); flex-shrink: 0; }
.switch .track::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: var(--text-2); transition: transform var(--t), background var(--t); }
.switch input:checked + .track { background: var(--brand); border-color: var(--brand); }
.switch input:checked + .track::after { transform: translateX(16px); background: #fff; }
.switch input:focus-visible + .track { box-shadow: var(--ring); }

/* Segmented control e chips */
.seg { display: inline-flex; padding: 3px; gap: 2px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 99px; }
.seg button { height: 28px; padding: 0 12px; border: 0; border-radius: 99px; background: transparent; color: var(--text-2); font: inherit; font-size: 13px; font-weight: 500; cursor: pointer; transition: background var(--t), color var(--t); }
.seg button:hover { color: var(--text); }
.seg button.active { background: var(--brand-soft); color: var(--brand-2); }
.chips { display: flex; gap: 6px; flex-wrap: nowrap; overflow-x: auto; align-items: center; scrollbar-width: none; padding-bottom: 2px; }
.chips::-webkit-scrollbar { display: none; }
.chips button { height: 28px; padding: 0 12px; border: 1px solid var(--line); background: transparent; color: var(--text-2); border-radius: 99px; font: inherit; font-size: 12.5px; font-weight: 500; cursor: pointer; white-space: nowrap; transition: background var(--t), color var(--t), border-color var(--t); }
.chips button:hover { color: var(--text); border-color: var(--line-strong); }
.chips button.active { background: var(--brand-soft); border-color: transparent; color: var(--brand-2); }
.chips select { width: auto; height: 28px; padding: 0 26px 0 10px; font-size: 12.5px; border-radius: 99px; background-position: right 6px center; flex-shrink: 0; }

/* Badges e pílulas */
.b { display: inline-flex; align-items: center; gap: 4px; font-size: 11px; font-weight: 500; line-height: 18px; padding: 0 7px; border-radius: 99px; background: var(--surface-3); color: var(--text-2); white-space: nowrap; max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
.b.wait { background: var(--warn-soft); color: var(--warn); }
.b.late { background: var(--bad-soft); color: var(--bad); }
.b.receipt { background: var(--ok-soft); color: var(--ok); }
.b.money { background: var(--ok-soft); color: var(--ok); font-variant-numeric: tabular-nums; }
.b.st { background: var(--brand-soft); color: var(--brand-2); }
.b.lost { background: var(--bad-soft); color: var(--bad); }
.b.info { background: var(--info-soft); color: var(--info); }
.badges { display: flex; flex-wrap: wrap; gap: 4px; }
.status-pill { display: inline-flex; align-items: center; gap: 7px; height: 28px; padding: 0 10px 0 8px; border-radius: 99px; background: var(--surface-2); border: 1px solid var(--line); font-size: 12.5px; font-weight: 500; color: var(--text-2); }
.status-pill b { color: var(--text); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--text-3); display: inline-block; flex-shrink: 0; box-shadow: 0 0 0 0 transparent; transition: background var(--t); }
.dot.on { background: var(--ok); box-shadow: 0 0 0 3px var(--ok-soft); }
.dot.off { background: var(--bad); box-shadow: 0 0 0 3px var(--bad-soft); }
.dot.wait { background: var(--warn); box-shadow: 0 0 0 3px var(--warn-soft); }
.avatar { --h: var(--avatar-h); width: 40px; height: 40px; border-radius: 50%; flex-shrink: 0; display: grid; place-items: center; font-weight: 600; font-size: 14px; letter-spacing: .02em;
  background: color-mix(in oklab, hsl(var(--h) 60% 55%) 22%, var(--surface-2)); color: hsl(var(--h) 70% 74%); }
:root[data-theme="light"] .avatar { color: hsl(var(--h) 55% 36%); }
@media (prefers-color-scheme: light) { :root:not([data-theme="dark"]) .avatar { color: hsl(var(--h) 55% 36%); } }
.avatar.sm { width: 32px; height: 32px; font-size: 12px; }
.role-chip { text-transform: capitalize; }

/* ---------- Superfícies ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow-1); min-width: 0; }
.card h2 { margin-bottom: 4px; }
.table-card { padding: 0; overflow: hidden; }
.table-card .table { width: 100%; }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius-s); }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 22px 0 10px; flex-wrap: wrap; }
.section-head h2 { margin: 0; }
.card .section-head { margin-top: 0; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 16px; }
.form { display: grid; gap: 14px; }
.form h2 { margin-bottom: 2px; }
.grid-form { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid-form .full { grid-column: 1 / -1; }
.subform { margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--line); }
.alert { display: flex; gap: 8px; align-items: flex-start; padding: 10px 12px; border-radius: var(--radius-s); font-size: 13px; border: 1px solid; }
.alert.bad { background: var(--bad-soft); border-color: color-mix(in oklab, var(--bad) 30%, transparent); color: var(--bad); }
.alert.warn { background: var(--warn-soft); border-color: color-mix(in oklab, var(--warn) 30%, transparent); color: var(--warn); }

/* Tabelas */
.table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; font-size: 13.5px; }
.table th, .table td { text-align: right; padding: 0 12px; height: 40px; border-bottom: 1px solid var(--line); white-space: nowrap; vertical-align: middle; }
.table th:first-child, .table td:first-child { text-align: left; }
.table th { color: var(--text-3); font-weight: 600; font-size: 11px; text-transform: uppercase; letter-spacing: .06em; background: var(--surface); position: sticky; top: 0; }
.table tbody tr:hover td, .table tr:not(:first-child):hover td { background: color-mix(in oklab, var(--text) 3%, transparent); }
.table tr:last-child td { border-bottom: 0; }
.table tr.worst td { background: color-mix(in oklab, var(--bad) 8%, transparent); }
.table tr.worst:hover td { background: color-mix(in oklab, var(--bad) 12%, transparent); }
.table td.muted { text-align: center; color: var(--text-3); }
.table td.wrap { white-space: pre-wrap; max-width: 360px; min-width: 220px; line-height: 1.4; padding-top: 8px; padding-bottom: 8px; height: auto; }
.table td.nowrap { white-space: nowrap; }
.table tr.off td { color: var(--text-3); }
.table .actions { display: inline-flex; gap: 4px; }
.bar-track { height: 6px; width: 100%; background: var(--surface-3); border-radius: 99px; overflow: hidden; }
.bar { height: 100%; background: var(--brand); border-radius: 99px; min-width: 2px; transition: width 300ms ease; }
.barcell { width: 32%; min-width: 120px; }

/* Empty states, skeletons, toasts, menu, dialog */
.empty { display: grid; place-items: center; align-content: center; text-align: center; padding: 40px 20px; color: var(--text-2); gap: 4px; }
.empty-ic { width: 40px; height: 40px; stroke: var(--text-3); fill: none; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; margin-bottom: 8px; padding: 8px; box-sizing: content-box; border-radius: 50%; background: var(--surface-2); }
.empty-title { color: var(--text); font-weight: 600; font-size: 15px; }
.empty p { max-width: 320px; font-size: 13px; }
.sk { display: block; background: linear-gradient(90deg, var(--surface-2) 25%, var(--surface-3) 50%, var(--surface-2) 75%); background-size: 200% 100%; animation: shimmer 1.4s infinite linear; border-radius: 6px; }
.sk-avatar { width: 40px; height: 40px; border-radius: 50%; flex-shrink: 0; }
.sk-line { height: 10px; }
.sk-line.w40 { width: 40%; } .sk-line.w50 { width: 50%; } .sk-line.w60 { width: 60%; } .sk-line.w70 { width: 70%; } .sk-line.w80 { width: 80%; } .sk-line.w90 { width: 90%; }
.sk-row { display: flex; gap: 12px; padding: 12px 14px; align-items: center; border-bottom: 1px solid var(--line); }
.sk-lines { flex: 1; display: grid; gap: 8px; }
.sk-card { height: 72px; border-radius: var(--radius-s); }
.sk-kpi { height: 92px; border-radius: var(--radius); }
.sk-table { height: 200px; border-radius: 0; }
@keyframes shimmer { to { background-position: -200% 0; } }
.toasts { position: fixed; right: 16px; bottom: 16px; display: grid; gap: 8px; z-index: 50; max-width: min(380px, calc(100vw - 32px)); }
.toast { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; background: var(--bg-elev); border: 1px solid var(--line-strong); border-left: 3px solid var(--info); border-radius: var(--radius-s); box-shadow: var(--shadow-2); font-size: 13px; animation: toast-in 160ms ease; }
.toast .ic { width: 16px; height: 16px; margin-top: 1px; color: var(--info); }
.toast.ok { border-left-color: var(--ok); } .toast.ok .ic { color: var(--ok); }
.toast.bad { border-left-color: var(--bad); } .toast.bad .ic { color: var(--bad); }
.toast.warn { border-left-color: var(--warn); } .toast.warn .ic { color: var(--warn); }
.toast.out { animation: toast-out 160ms ease forwards; }
@keyframes toast-in { from { opacity: 0; transform: translateY(6px); } }
@keyframes toast-out { to { opacity: 0; transform: translateY(6px); } }
.menu { position: absolute; left: 12px; right: 12px; bottom: calc(100% + 6px); background: var(--bg-elev); border: 1px solid var(--line-strong); border-radius: var(--radius); box-shadow: var(--shadow-2); padding: 6px; display: grid; gap: 2px; z-index: 20; }
.menu button { display: flex; align-items: center; gap: 10px; width: 100%; height: 36px; padding: 0 10px; border: 0; background: transparent; color: var(--text); border-radius: var(--radius-s); font: inherit; cursor: pointer; text-align: left; }
.menu button:hover { background: var(--surface-2); }
.menu .ic { color: var(--text-2); }
.dialog { border: 1px solid var(--line-strong); background: var(--bg-elev); color: var(--text); border-radius: var(--radius-l); padding: 22px; width: min(420px, calc(100vw - 32px)); box-shadow: var(--shadow-2); }
.dialog::backdrop { background: rgba(0, 0, 0, .55); backdrop-filter: blur(2px); }
.dialog h2 { margin-bottom: 8px; }
.dialog p { color: var(--text-2); margin-bottom: 18px; }
.scrim { position: fixed; inset: 0; background: rgba(0, 0, 0, .5); z-index: 30; backdrop-filter: blur(1px); }

/* ---------- Login ---------- */
.login { min-height: 100vh; min-height: 100dvh; display: grid; grid-template-columns: 1.1fr 1fr; }
.login-side { position: relative; padding: 48px; display: flex; flex-direction: column; justify-content: center; gap: 16px; background: var(--bg-elev); border-right: 1px solid var(--line); overflow: hidden; }
.login-side::before { content: ""; position: absolute; inset: auto -120px -160px auto; width: 460px; height: 460px; border-radius: 50%; background: radial-gradient(closest-side, var(--brand-soft), transparent); pointer-events: none; }
.login-side h2 { font-size: 30px; line-height: 1.15; max-width: 480px; letter-spacing: -.02em; }
.login-side p { color: var(--text-2); max-width: 440px; font-size: 15px; }
.login-brand { display: flex; align-items: center; gap: 10px; font-weight: 600; font-size: 15px; margin-bottom: 20px; }
.logo-mark { width: 26px; height: 26px; border-radius: 8px; background: linear-gradient(135deg, var(--brand), var(--brand-2)); display: inline-block; box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .15); flex-shrink: 0; }
.login-points { list-style: none; margin: 12px 0 0; padding: 0; display: grid; gap: 10px; color: var(--text-2); }
.login-points li { display: flex; align-items: center; gap: 10px; }
.login-points .ic { color: var(--brand-2); }
.login-main { display: grid; place-items: center; padding: 24px 16px; }
.login-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-l); padding: 28px; width: min(380px, 100%); display: grid; gap: 14px; box-shadow: var(--shadow-1); }
.login-card h1 { font-size: 22px; }
.login-card .muted { margin-top: -8px; font-size: 13px; }
.login-card .login-brand { margin-bottom: 0; }

/* ---------- App shell ---------- */
.shell { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); min-height: 100vh; min-height: 100dvh; }
.sidebar { position: sticky; top: 0; height: 100vh; height: 100dvh; display: flex; flex-direction: column; background: var(--bg-elev); border-right: 1px solid var(--line); z-index: 31; transition: width var(--t), transform 180ms ease; }
.sb-brand { display: flex; align-items: center; gap: 10px; height: var(--topbar-h); padding: 0 16px; border-bottom: 1px solid var(--line); }
.sb-brand-text { display: grid; line-height: 1.2; min-width: 0; flex: 1; }
.sb-brand-text b { font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sb-brand-text .muted { font-size: 11.5px; }
.sb-nav { display: flex; flex-direction: column; gap: 2px; padding: 10px; flex: 1; overflow-y: auto; }
.sb-nav button { display: flex; align-items: center; gap: 10px; height: 38px; padding: 0 10px; border: 0; background: transparent; color: var(--text-2); border-radius: var(--radius-s); font: inherit; font-weight: 500; cursor: pointer; text-align: left; white-space: nowrap; transition: background var(--t), color var(--t); }
.sb-nav button:hover { background: var(--surface-2); color: var(--text); }
.sb-nav button.active { background: var(--brand-soft); color: var(--brand-2); }
.sb-nav button.active .ic { color: var(--brand-2); }
.sb-nav button .ic { color: var(--text-3); transition: color var(--t); }
.sb-nav button:hover .ic { color: var(--text); }
.sb-nav button > span:first-of-type { flex: 1; }
.sb-sep { height: 1px; background: var(--line); margin: 8px 6px; }
.tab-badge { min-width: 20px; padding: 0 6px; border-radius: 99px; background: var(--brand); color: #fff; font-size: 11px; font-weight: 600; line-height: 20px; text-align: center; }
.sb-foot { position: relative; padding: 10px; border-top: 1px solid var(--line); }
.sb-user { display: flex; align-items: center; gap: 10px; width: 100%; padding: 6px; border: 0; background: transparent; color: var(--text); border-radius: var(--radius-s); font: inherit; cursor: pointer; text-align: left; transition: background var(--t); }
.sb-user:hover, .sb-user[aria-expanded="true"] { background: var(--surface-2); }
.sb-user-text { display: grid; line-height: 1.25; min-width: 0; flex: 1; }
.sb-user-name { font-weight: 600; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sb-user-role { font-size: 11.5px; text-transform: capitalize; }
.sb-user .dots { color: var(--text-3); }

.shell-main { display: flex; flex-direction: column; min-width: 0; min-height: 100vh; min-height: 100dvh; }
.topbar { display: flex; align-items: center; gap: 16px; min-height: var(--topbar-h); padding: 10px 24px; border-bottom: 1px solid var(--line); background: color-mix(in oklab, var(--bg) 85%, transparent); backdrop-filter: blur(10px); position: sticky; top: 0; z-index: 10; flex-wrap: wrap; }
.tb-title { display: grid; line-height: 1.25; min-width: 0; }
.tb-title p { font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tb-actions { margin-left: auto; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; justify-content: flex-end; min-width: 0; }
.wa-pill { display: inline-flex; align-items: center; gap: 8px; height: 32px; padding: 0 12px 0 10px; border-radius: 99px; background: var(--surface); border: 1px solid var(--line); font-size: 12.5px; font-weight: 500; color: var(--text-2); white-space: nowrap; }
.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.filters label { flex-direction: row; align-items: center; gap: 6px; font-size: 12px; color: var(--text-3); }
.filters label > span { white-space: nowrap; }
.filters input, .filters select { height: 32px; font-size: 13px; }
.filters select { width: auto; min-width: 110px; }
.filters .f-date input { width: 132px; }
.filters .f-search { position: relative; }
.filters .f-search .ic { position: absolute; left: 9px; width: 15px; height: 15px; color: var(--text-3); pointer-events: none; }
.filters .f-search input { width: 230px; padding-left: 30px; border-radius: 99px; }
body[data-tab=kanban] .only-metrics, body:not([data-tab=kanban]) .only-kanban { display: none; }
body[data-tab=whatsapp] .filters, body[data-tab=settings] .filters, body[data-tab=inbox] .filters { display: none; }

main { padding: 20px 24px 32px; flex: 1; min-width: 0; }
.tab { max-width: 1440px; }
#tab-inbox { max-width: none; }

/* ---------- Kanban ---------- */
.board { display: grid; grid-auto-flow: column; grid-auto-columns: 280px; gap: 12px; overflow-x: auto; padding-bottom: 12px; min-height: 60vh; scroll-snap-type: x proximity; }
.col { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); display: flex; flex-direction: column; min-height: 240px; max-height: calc(100vh - 190px); scroll-snap-align: start; transition: background var(--t), border-color var(--t); box-shadow: var(--shadow-1); }
.col.drop { background: color-mix(in oklab, var(--brand) 8%, var(--surface)); border-color: color-mix(in oklab, var(--brand) 45%, transparent); }
.col-head { padding: 10px 12px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; font-weight: 600; font-size: 13px; gap: 8px; }
.col-head span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.col-head .n { min-width: 22px; height: 20px; padding: 0 7px; border-radius: 99px; background: var(--surface-3); color: var(--text-2); font-size: 11.5px; font-weight: 600; display: grid; place-items: center; }
.col.lost .col-head { color: var(--bad); }
.col.lost .col-head .n { background: var(--bad-soft); color: var(--bad); }
.col-body { padding: 8px; display: flex; flex-direction: column; gap: 8px; overflow-y: auto; flex: 1; }
.col-empty { color: var(--text-3); font-size: 12px; text-align: center; padding: 18px 8px; border: 1px dashed var(--line); border-radius: var(--radius-s); }
.kcard { background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius-s); padding: 10px; cursor: pointer; display: grid; grid-template-columns: 32px 1fr; gap: 6px 10px; transition: border-color var(--t), transform var(--t), box-shadow var(--t), opacity var(--t); }
.kcard:hover { border-color: var(--line-strong); box-shadow: var(--shadow-1); }
.kcard[draggable=true]:active { cursor: grabbing; }
.kcard.lift { transform: rotate(1deg); box-shadow: var(--shadow-2); border-color: var(--brand); }
.kcard.dragging { opacity: .4; }
.kcard .avatar { width: 32px; height: 32px; font-size: 12px; grid-row: 1 / span 3; }
.kcard .t { display: flex; justify-content: space-between; gap: 8px; font-weight: 600; min-width: 0; }
.kcard .t > span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kcard .t .time { color: var(--text-3); font-weight: 400; font-size: 12px; white-space: nowrap; }
.kcard .snip { color: var(--text-2); font-size: 12.5px; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; line-height: 1.35; }
.kcard .badges:empty { display: none; }

/* ---------- Métricas ---------- */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow-1); display: grid; gap: 4px; min-width: 0; }
.kpi .l { color: var(--text-2); font-size: 12px; font-weight: 500; }
.kpi .v { font-size: 26px; font-weight: 600; letter-spacing: -.02em; font-variant-numeric: tabular-nums; line-height: 1.15; }
.kpi .s { color: var(--text-3); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi .bar-track { margin-top: 6px; height: 4px; }
.callouts { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 12px; margin-top: 12px; }
.callout { display: flex; gap: 10px; align-items: flex-start; border: 1px solid var(--line); border-left: 3px solid var(--bad); background: var(--surface); padding: 10px 12px; border-radius: var(--radius-s); font-size: 13px; color: var(--text-2); }
.callout .ic { color: var(--bad); margin-top: 1px; }
.callout b { color: var(--text); }
.report-grid { align-items: start; }
.report-card { display: grid; gap: 10px; }
.report { white-space: pre-wrap; font: 13px/1.55 ui-monospace, "Cascadia Mono", Consolas, monospace; margin: 0; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius-s); padding: 14px; overflow-x: auto; color: var(--text); }

/* ---------- WhatsApp ---------- */
.wa { max-width: 620px; display: grid; gap: 14px; }
.wa .row { margin-top: 2px; }
.wa .hint { margin: 0; }
.qr { background: #fff; border-radius: var(--radius); padding: 18px; text-align: center; color: #222; display: grid; gap: 8px; justify-items: center; border: 1px solid var(--line); }
.qr img { width: 240px; height: 240px; display: block; image-rendering: pixelated; }
.qr .muted { color: #4b5265; font-size: 13px; }
.qr .small { font-size: 12px; color: #7c8399; }

/* ---------- Config ---------- */
.cfg-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.cfg-grid > * { min-width: 0; }
.cfg-grid .wide { grid-column: 1 / -1; }
.switch-box { display: grid; gap: 8px; padding: 12px; border: 1px solid color-mix(in oklab, var(--warn) 40%, transparent); background: color-mix(in oklab, var(--warn) 6%, transparent); border-radius: var(--radius-s); }
.warn-text { color: var(--warn); font-size: 12px; line-height: 1.45; }
.cfg .table th, .cfg .table td { text-align: left; }

/* ---------- Drawer de detalhe ---------- */
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(520px, 100%); background: var(--bg-elev); border-left: 1px solid var(--line); z-index: 40; display: flex; flex-direction: column; box-shadow: var(--shadow-2); animation: slide-in 180ms ease; }
@keyframes slide-in { from { transform: translateX(24px); opacity: 0; } }
.drawer-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.drawer-who { display: flex; align-items: center; gap: 12px; min-width: 0; }
.drawer-who h2 { font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.drawer-body { overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 16px; }
.dform { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.dform .full { grid-column: 1 / -1; }
.drawer-section .label { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--text-3); font-weight: 600; margin-bottom: 8px; }
.log { font-size: 12px; color: var(--text-2); display: flex; flex-wrap: wrap; gap: 6px; }
.log:empty::before { content: "Sem mudanças de etapa registradas."; color: var(--text-3); }
.chat { display: flex; flex-direction: column; gap: 6px; background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; }
.msg { max-width: 82%; padding: 8px 12px; border-radius: 14px; border-bottom-left-radius: 4px; background: var(--surface-2); white-space: pre-wrap; overflow-wrap: anywhere; font-size: 14px; line-height: 1.45; }
.msg.me { align-self: flex-end; background: var(--brand-soft); border: 1px solid color-mix(in oklab, var(--brand) 25%, transparent); border-radius: 14px; border-bottom-right-radius: 4px; }
.msg .ts { display: block; font-size: 11px; color: var(--text-3); margin-top: 3px; text-align: right; }
.msg .media { font-style: italic; color: var(--text-2); }
.day { align-self: center; font-size: 11px; font-weight: 500; color: var(--text-2); margin: 8px 0 4px; padding: 2px 10px; border-radius: 99px; background: var(--surface-2); border: 1px solid var(--line); }

/* ---------- Responsivo ---------- */
@media (max-width: 1279px) {
  .shell { grid-template-columns: var(--sidebar-w-min) minmax(0, 1fr); }
  .sidebar { width: var(--sidebar-w-min); }
  .sb-brand { padding: 0; justify-content: center; }
  .sb-brand-text, .sb-nav button > span:first-of-type, .sb-user-text, .sb-user .dots { display: none; }
  .sb-nav { padding: 10px 8px; }
  .sb-nav button { justify-content: center; padding: 0; width: 48px; position: relative; }
  .sb-nav .tab-badge { position: absolute; top: 3px; right: 3px; min-width: 16px; line-height: 16px; font-size: 10px; padding: 0 4px; }
  .sb-foot { padding: 8px; }
  .sb-user { justify-content: center; padding: 6px 0; }
  .menu { left: 8px; right: auto; width: 200px; }
  .topbar { padding: 10px 20px; }
  main { padding: 16px 20px 28px; }
}
@media (max-width: 900px) {
  .filters .f-search input { width: 180px; }
  .cfg-grid { grid-template-columns: 1fr; }
  .login { grid-template-columns: 1fr; }
  .login-side { display: none; }
  .login-brand.only-mobile { display: flex; }
}
@media (max-width: 640px) {
  .only-mobile, .icon-btn.only-mobile { display: inline-flex; }
  .shell { grid-template-columns: minmax(0, 1fr); }
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; width: min(280px, 85vw); transform: translateX(-100%); box-shadow: none; }
  body.nav-open .sidebar { transform: none; box-shadow: var(--shadow-2); }
  body.nav-open .side-scrim { display: block !important; }
  .sb-brand { padding: 0 16px; justify-content: flex-start; }
  .sb-brand-text, .sb-nav button > span:first-of-type, .sb-user-text, .sb-user .dots { display: revert; }
  .sb-brand-text { display: grid; }
  .sb-user-text { display: grid; }
  .sb-nav { padding: 10px; }
  .sb-nav button { justify-content: flex-start; padding: 0 10px; width: auto; }
  .sb-nav .tab-badge { position: static; min-width: 20px; line-height: 20px; font-size: 11px; padding: 0 6px; }
  .sb-user { justify-content: flex-start; padding: 6px; }
  .menu { left: 12px; right: 12px; width: auto; }
  .topbar { padding: 8px 16px; gap: 10px; }
  .tb-title h1 { font-size: 16px; }
  .tb-title p { display: none; }
  .tb-actions { flex-basis: 100%; margin-left: 0; justify-content: flex-start; }
  body[data-tab=inbox] .tb-actions, body[data-tab=whatsapp] .tb-actions, body[data-tab=settings] .tb-actions { flex-basis: auto; margin-left: auto; }
  .wa-pill span:last-child { display: none; }
  .wa-pill { padding: 0 8px; }
  .filters { width: 100%; }
  .filters .seg { width: 100%; }
  .filters .seg button { flex: 1; padding: 0; }
  .filters label { flex: 1 1 calc(50% - 4px); min-width: 0; }
  .filters label > span { display: none; }
  .filters .f-date input, .filters select { width: 100%; min-width: 0; }
  .filters .f-search { flex-basis: 100%; }
  .filters .f-search input { width: 100%; }
  main { padding: 16px 16px 28px; }
  .grid2 { grid-template-columns: 1fr; }
  .dform, .grid-form { grid-template-columns: 1fr; }
  .board { grid-auto-columns: min(300px, 85vw); }
  .col { max-height: calc(100vh - 230px); }
  .card { padding: 14px; }
  .kpi .v { font-size: 22px; }
  .qr img { width: 200px; height: 200px; }
  .toasts { right: 12px; left: 12px; bottom: 12px; max-width: none; }
  .drawer { width: 100%; }
}

/* ---------- Movimento reduzido ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
  .sk { background: var(--surface-2); }
}
