/* Omni1 — design tokens + componentes. Direção: Minimal Premium, papel quente + tinta + sinal laranja. */
:root {
  --ink: #15171b;
  --ink-2: #23262d;
  --paper: #f6f5f1;
  --surface: #ffffff;
  --surface-2: #fbfaf7;
  --line: #e6e3db;
  --line-2: #d8d4c9;
  --text: #1b1d21;
  --muted: #6a6e76;
  --faint: #9a9da3;
  --accent: #e8572a;
  --accent-ink: #b8401a;
  --accent-soft: #fdeee7;
  --ok: #1f7a5c; --ok-soft: #e4f3ec;
  --warn: #a66a00; --warn-soft: #fbf1dc;
  --bad: #c4352b; --bad-soft: #fbe7e5;
  --c-whatsapp: #1fa855; --c-instagram: #d6336c; --c-messenger: #2b6cf0; --c-email: #6b5bd2; --c-webchat: #e8572a; --c-telegram: #2aa1da;

  --font-ui: "Geist", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-display: "Instrument Serif", Georgia, serif;
  --font-mono: "Geist Mono", ui-monospace, SFMono-Regular, Menlo, monospace;

  --space-1: 4px; --space-2: 8px; --space-3: 12px; --space-4: 16px; --space-5: 24px; --space-6: 40px;
  --radius-sm: 6px; --radius-md: 10px; --radius-lg: 16px;
  --shadow-sm: 0 1px 2px rgba(20, 22, 26, .06);
  --shadow-md: 0 4px 18px -6px rgba(20, 22, 26, .14);
  --shadow-lg: 0 24px 60px -20px rgba(20, 22, 26, .28);
  --motion-fast: 120ms; --motion-base: 200ms;

  --bs-body-font-family: var(--font-ui);
  --bs-body-bg: var(--paper);
  --bs-body-color: var(--text);
  --bs-border-color: var(--line);
  --bs-primary: var(--accent);
  --bs-primary-rgb: 232, 87, 42;
  --bs-link-color: var(--accent-ink);
  --bs-link-color-rgb: 184, 64, 26;
  --bs-link-hover-color: var(--accent);
  --bs-border-radius: var(--radius-md);
  --bs-focus-ring-color: rgba(232, 87, 42, .25);
}

html { -webkit-font-smoothing: antialiased; }
body { font-family: var(--font-ui); background: var(--paper); color: var(--text); font-size: 14.5px; letter-spacing: -.005em; }
h1, h2, h3, h4, h5 { letter-spacing: -.02em; font-weight: 600; }
.mono { font-family: var(--font-mono); font-size: .9em; }
.text-muted { color: var(--muted) !important; }
.small-caps { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 600; }
a { text-underline-offset: 2px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* Botões */
.btn { font-weight: 500; border-radius: var(--radius-sm); padding: .48rem .9rem; transition: background var(--motion-fast), border-color var(--motion-fast), transform var(--motion-fast); }
.btn:active { transform: translateY(1px); }
.btn-primary { --bs-btn-bg: var(--accent); --bs-btn-border-color: var(--accent); --bs-btn-hover-bg: var(--accent-ink); --bs-btn-hover-border-color: var(--accent-ink); --bs-btn-active-bg: var(--accent-ink); --bs-btn-disabled-bg: var(--accent); --bs-btn-disabled-border-color: var(--accent); }
.btn-dark { --bs-btn-bg: var(--ink); --bs-btn-border-color: var(--ink); --bs-btn-hover-bg: var(--ink-2); }
.btn-ghost { background: transparent; border: 1px solid var(--line-2); color: var(--text); }
.btn-ghost:hover { background: var(--surface); border-color: var(--ink); }
.btn-sm { padding: .3rem .6rem; font-size: 13px; }

/* Formulários */
.form-control, .form-select { border-color: var(--line-2); border-radius: var(--radius-sm); background-color: var(--surface); font-size: 14px; padding: .5rem .7rem; }
.form-control:focus, .form-select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.form-label { font-weight: 500; font-size: 13px; margin-bottom: .3rem; }
.form-text { color: var(--muted); font-size: 12.5px; }
.form-check-input:checked { background-color: var(--accent); border-color: var(--accent); }
.cred-help { font-size: 12.5px; margin-top: 6px; padding: 8px 10px; background: var(--surface-2); border: 1px dashed var(--line-2); border-radius: var(--radius-sm); }
.cred-help ol { padding-left: 1.1rem; color: var(--muted); }

/* Cartões */
.card { border: 1px solid var(--line); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); background: var(--surface); }
.card-header { background: transparent; border-bottom: 1px solid var(--line); font-weight: 600; padding: 14px 18px; }
.card-body { padding: 18px; }
.stat { padding: 18px; }
.stat .num { font-size: 30px; font-weight: 600; letter-spacing: -.03em; line-height: 1.1; }
.stat .lbl { color: var(--muted); font-size: 13px; }

.table { --bs-table-bg: transparent; font-size: 14px; }
.table > :not(caption) > * > * { padding: .65rem .75rem; border-bottom-color: var(--line); }
.table thead th { font-size: 11.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 600; }

.badge-soft { display: inline-flex; align-items: center; gap: 4px; font-size: 11.5px; font-weight: 600; padding: 3px 8px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--line); color: var(--muted); }
.badge-soft.ok { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.badge-soft.warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.badge-soft.bad { background: var(--bad-soft); color: var(--bad); border-color: transparent; }
.badge-soft.accent { background: var(--accent-soft); color: var(--accent-ink); border-color: transparent; }

.ch-dot { width: 22px; height: 22px; border-radius: 6px; display: inline-grid; place-items: center; color: #fff; font-size: 12px; flex: none; }
.ch-whatsapp { background: var(--c-whatsapp); } .ch-instagram { background: var(--c-instagram); } .ch-messenger { background: var(--c-messenger); }
.ch-email { background: var(--c-email); } .ch-webchat { background: var(--c-webchat); } .ch-telegram { background: var(--c-telegram); } .ch-tiktok { background: #111; }

/* ── Layout do app ─────────────────────────────────────────────────── */
.app-shell { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.sidebar { background: var(--ink); color: #c9cbd0; padding: 16px 12px; position: sticky; top: 0; height: 100vh; overflow-y: auto; display: flex; flex-direction: column; }
.brand { display: flex; align-items: center; gap: 10px; color: #fff; font-weight: 600; font-size: 16px; padding: 4px 8px 18px; text-decoration: none; }
.brand-mark { width: 28px; height: 28px; border-radius: 8px; background: var(--accent); display: grid; place-items: center; color: #fff; font-family: var(--font-display); font-size: 20px; font-style: italic; }
.brand small { display: block; font-size: 11px; color: #8d9097; font-weight: 400; }
.nav-sec { font-size: 10.5px; text-transform: uppercase; letter-spacing: .1em; color: #6f737b; padding: 14px 10px 6px; }
.side-link { display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: 7px; color: #c9cbd0; text-decoration: none; font-size: 14px; }
.side-link i { font-size: 15px; opacity: .85; }
.side-link:hover { background: rgba(255, 255, 255, .06); color: #fff; }
.side-link.active { background: rgba(255, 255, 255, .1); color: #fff; }
.side-link .count { margin-left: auto; background: var(--accent); color: #fff; font-size: 11px; border-radius: 999px; padding: 1px 7px; font-weight: 600; }
.side-foot { margin-top: auto; border-top: 1px solid rgba(255, 255, 255, .08); padding-top: 12px; font-size: 13px; }
.main { min-width: 0; }
.topbar { height: 58px; display: flex; align-items: center; gap: 12px; padding: 0 28px; border-bottom: 1px solid var(--line); background: var(--surface); position: sticky; top: 0; z-index: 10; }
.topbar h1 { font-size: 17px; margin: 0; }
.page { padding: 26px 28px 60px; max-width: 1240px; }
.page-wide { padding: 0; }
.trial-bar { background: var(--accent-soft); color: var(--accent-ink); font-size: 13px; padding: 7px 28px; border-bottom: 1px solid #f6d2c3; }
.mobile-nav { display: none; }
@media (max-width: 991px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; z-index: 1050; left: -260px; width: 240px; transition: left var(--motion-base); }
  .sidebar.open { left: 0; box-shadow: var(--shadow-lg); }
  .mobile-nav { display: inline-flex; }
  .topbar, .page { padding-left: 16px; padding-right: 16px; }
}

/* ── Caixa de entrada ──────────────────────────────────────────────── */
.inbox { display: grid; grid-template-columns: 340px 1fr 300px; height: calc(100vh - 58px); }
.inbox-list { border-right: 1px solid var(--line); background: var(--surface); display: flex; flex-direction: column; min-height: 0; }
.inbox-filters { padding: 12px; border-bottom: 1px solid var(--line); display: grid; gap: 8px; }
.seg { display: flex; background: var(--paper); border-radius: 8px; padding: 3px; gap: 2px; }
.seg button { flex: 1; border: 0; background: transparent; font-size: 12.5px; padding: 5px 4px; border-radius: 6px; color: var(--muted); font-weight: 500; }
.seg button.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }
.conv-scroll { overflow-y: auto; flex: 1; }
.conv { display: flex; gap: 10px; padding: 12px 14px; border-bottom: 1px solid var(--line); cursor: pointer; position: relative; }
.conv:hover { background: var(--surface-2); }
.conv.active { background: var(--accent-soft); }
.conv.active::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--accent); }
.avatar { width: 38px; height: 38px; border-radius: 50%; background: #e9e5db; color: #5b5e65; display: grid; place-items: center; font-weight: 600; font-size: 14px; flex: none; position: relative; overflow: visible; }
.avatar img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; }
.avatar .ch-dot { position: absolute; right: -4px; bottom: -3px; width: 17px; height: 17px; font-size: 9px; border: 2px solid var(--surface); border-radius: 5px; }
.conv .who { font-weight: 600; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv .pre { color: var(--muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv .when { font-size: 11.5px; color: var(--faint); white-space: nowrap; }
.conv .unread { background: var(--accent); color: #fff; font-size: 11px; font-weight: 700; border-radius: 999px; min-width: 19px; height: 19px; display: grid; place-items: center; padding: 0 5px; }
.conv .kind { font-size: 10.5px; color: var(--muted); border: 1px solid var(--line-2); border-radius: 4px; padding: 0 4px; }

.thread { display: flex; flex-direction: column; min-height: 0; background: var(--paper); }
.thread-head { height: 62px; display: flex; align-items: center; gap: 12px; padding: 0 18px; background: var(--surface); border-bottom: 1px solid var(--line); }
.thread-body { flex: 1; overflow-y: auto; padding: 22px 6%; display: flex; flex-direction: column; gap: 6px; }
.msg { max-width: min(560px, 78%); padding: 9px 12px 6px; border-radius: 14px; font-size: 14.5px; line-height: 1.45; white-space: pre-wrap; word-wrap: break-word; box-shadow: var(--shadow-sm); position: relative; }
.msg.in { background: var(--surface); align-self: flex-start; border-bottom-left-radius: 4px; }
.msg.out { background: var(--ink); color: #f1f1f1; align-self: flex-end; border-bottom-right-radius: 4px; }
.msg.out.ai { background: #2c2541; }
.msg.note { background: #fff7d6; color: #5a4a00; align-self: center; max-width: 80%; border: 1px dashed #e5cf6d; font-size: 13.5px; }
.msg.system { background: transparent; box-shadow: none; color: var(--muted); align-self: center; font-size: 12px; padding: 2px; }
.msg .meta { font-size: 11px; opacity: .6; margin-top: 3px; display: flex; gap: 6px; justify-content: flex-end; align-items: center; }
.msg.failed { outline: 2px solid var(--bad); }
.msg img, .msg video { max-width: 100%; border-radius: 9px; display: block; margin-bottom: 4px; max-height: 340px; }
.msg audio { max-width: 260px; display: block; }
.msg .file { display: flex; gap: 8px; align-items: center; padding: 8px; background: rgba(127, 127, 127, .12); border-radius: 8px; color: inherit; text-decoration: none; margin-bottom: 4px; }
.msg .tag { font-size: 10.5px; text-transform: uppercase; letter-spacing: .06em; opacity: .7; margin-bottom: 2px; }
.day-sep { align-self: center; font-size: 11.5px; color: var(--muted); background: var(--surface); border: 1px solid var(--line); padding: 2px 10px; border-radius: 999px; margin: 10px 0; }
.composer { background: var(--surface); border-top: 1px solid var(--line); padding: 10px 14px 12px; }
.composer textarea { resize: none; border: 0; box-shadow: none !important; padding: 6px 2px; min-height: 44px; max-height: 180px; font-size: 14.5px; }
.composer.note-mode { background: #fffbe8; }
.composer-tools { display: flex; align-items: center; gap: 4px; }
.composer-tools .btn { padding: .3rem .5rem; }
.window-warn { font-size: 12.5px; background: var(--warn-soft); color: var(--warn); padding: 6px 12px; border-radius: 8px; margin-bottom: 8px; }
.qr-pop { position: absolute; bottom: 100%; left: 14px; right: 14px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow-md); max-height: 220px; overflow-y: auto; display: none; }
.qr-pop div { padding: 8px 12px; cursor: pointer; font-size: 13.5px; } .qr-pop div:hover, .qr-pop div.sel { background: var(--accent-soft); }

.side-info { background: var(--surface); border-left: 1px solid var(--line); overflow-y: auto; padding: 18px; }
.side-info dt { font-size: 11.5px; color: var(--muted); font-weight: 500; margin-top: 10px; }
.side-info dd { margin: 0; font-size: 14px; word-break: break-word; }
.empty-state { margin: auto; text-align: center; color: var(--muted); max-width: 340px; }
.empty-state i { font-size: 34px; color: var(--line-2); }
@media (max-width: 1280px) { .inbox { grid-template-columns: 310px 1fr; } .side-info { display: none; } }
@media (max-width: 860px) {
  .inbox { grid-template-columns: 1fr; }
  .inbox.has-active .inbox-list { display: none; }
  .inbox:not(.has-active) .thread { display: none; }
}

/* ── Autenticação ──────────────────────────────────────────────────── */
.auth-wrap { min-height: 100vh; display: grid; grid-template-columns: 1fr 1fr; }
.auth-art { background: var(--ink); color: #e9e9ea; padding: 48px; display: flex; flex-direction: column; justify-content: space-between; position: relative; overflow: hidden; }
.auth-art h2 { font-family: var(--font-display); font-weight: 400; font-size: 46px; line-height: 1.05; letter-spacing: -.01em; }
.auth-art h2 em { color: var(--accent); }
.auth-form { display: grid; place-items: center; padding: 32px 16px; }
.auth-form .box { width: 100%; max-width: 380px; }
@media (max-width: 860px) { .auth-wrap { grid-template-columns: 1fr; } .auth-art { display: none; } }

/* Gráfico de barras simples */
.bars { display: flex; align-items: flex-end; gap: 6px; height: 120px; }
.bars div { flex: 1; background: var(--line); border-radius: 4px 4px 0 0; min-height: 2px; position: relative; }
.bars div.hi { background: var(--accent); }
.bars-lbl { display: flex; gap: 6px; font-size: 10.5px; color: var(--faint); margin-top: 4px; } .bars-lbl span { flex: 1; text-align: center; }

.code-box { background: var(--ink); color: #e6e6e6; border-radius: var(--radius-md); padding: 14px 16px; font-family: var(--font-mono); font-size: 12.5px; white-space: pre-wrap; word-break: break-all; }
.copy-field { display: flex; gap: 6px; } .copy-field input { font-family: var(--font-mono); font-size: 12.5px; }
.tpl-preview { background: #e9e2d6; border-radius: 12px; padding: 18px; min-height: 200px; }
.tpl-bubble { background: #fff; border-radius: 10px; padding: 10px 12px; max-width: 320px; box-shadow: var(--shadow-sm); font-size: 14px; white-space: pre-wrap; }
.tpl-bubble .h { font-weight: 700; margin-bottom: 4px; } .tpl-bubble .f { color: #8a8d92; font-size: 12px; margin-top: 6px; }
.tpl-btn { background: #fff; border-radius: 10px; margin-top: 4px; max-width: 320px; text-align: center; color: #1d8ad6; font-size: 14px; padding: 8px; box-shadow: var(--shadow-sm); }
.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; }
.media-grid a { display: block; border-radius: 12px; overflow: hidden; background: var(--surface); border: 1px solid var(--line); color: inherit; text-decoration: none; }
.media-grid img { width: 100%; aspect-ratio: 1; object-fit: cover; display: block; background: var(--line); }
.media-grid .cap { padding: 8px 10px; font-size: 12.5px; color: var(--muted); }
