/* =====================================================================
   Central Comercial — demo Patricia
   Direção: dark editorial navy + champagne gold (padrão Self/Climb).
   Cada empresa carrega uma COR-ASSINATURA via --emp-accent.
   Mobile first (390 → 1440). Sem travessão no texto, PT-BR.
   ===================================================================== */

:root {
  --bg:        #0a1628;
  --bg-2:      #0d1a30;
  --surface:   #13213a;
  --surface-2: #182a48;
  --surface-3: #1e3155;
  --border:    #1f2d4a;
  --border-2:  #2a3b5e;

  --gold:      #c9a961;
  --gold-soft: #e8d9a8;
  --gold-dim:  #8d7640;

  --text:      #f0ead6;
  --dim:       #a8b2c7;
  --mute:      #6b7693;

  --ok:   #4ade80;
  --warn: #fbbf24;
  --bad:  #f87171;
  --wa:   #25d366;
  --ig:   #e1306c;

  /* preenchidos por JS quando entra numa empresa */
  --emp-accent:    var(--gold);
  --emp-accent-ink:#0a1628;
  --emp-accent-soft: rgba(201,169,97,.12);

  --radius:    14px;
  --radius-sm: 10px;
  --radius-lg: 20px;
  --font-serif:"Fraunces", Georgia, serif;
  --font-sans: "Inter", -apple-system, "Segoe UI", Roboto, sans-serif;
  --sidebar-w: 268px;
  --topbar-h:  56px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  background-image:
    radial-gradient(1200px 600px at 85% -10%, rgba(201,169,97,.06), transparent 60%),
    radial-gradient(900px 500px at -10% 110%, rgba(96,165,250,.04), transparent 55%),
    url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='140' height='140' viewBox='0 0 140 140'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 1  0 0 0 0 1  0 0 0 0 1  0 0 0 0.025 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
}

h1, h2, h3, h4 { font-family: var(--font-serif); font-weight: 500; margin: 0; letter-spacing: -0.01em; color: var(--text); }
h1 { font-size: 26px; line-height: 1.15; font-weight: 400; }
h2 { font-size: 20px; line-height: 1.2; }
h3 { font-size: 16px; line-height: 1.3; font-weight: 500; }
.num { font-variant-numeric: tabular-nums; }
.eyebrow { font-family: var(--font-sans); font-size: 10px; letter-spacing: .18em; text-transform: uppercase; color: var(--gold); font-weight: 600; }
.muted { color: var(--dim); }
.mute-strong { color: var(--mute); }
small { font-size: 12px; color: var(--dim); }
a { color: var(--gold); text-decoration: none; }
a:hover { color: var(--gold-soft); }

/* -- Layout -- */
.shell { display: grid; grid-template-columns: var(--sidebar-w) 1fr; min-height: 100vh; }
.main  { min-width: 0; display: flex; flex-direction: column; }

/* Mask fica fora do fluxo em qualquer tamanho; só vira block em mobile quando aberto */
.sb-mask { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.6); z-index: 45; }

/* -- Sidebar -- */
.sb {
  position: sticky; top: 0; align-self: start;
  height: 100vh; overflow-y: auto;
  border-right: 1px solid var(--border);
  background: linear-gradient(180deg, var(--bg-2) 0%, var(--bg) 100%);
  padding: 20px 14px;
  display: flex; flex-direction: column; gap: 8px;
}
.sb-head {
  display: flex; align-items: center; gap: 12px;
  padding: 2px 6px 18px; margin-bottom: 4px;
  border-bottom: 1px solid var(--border);
}
.sb-logo {
  width: 40px; height: 40px; border-radius: 10px;
  background: linear-gradient(135deg, var(--gold) 0%, var(--gold-dim) 100%);
  color: #0a1628; font-weight: 800; letter-spacing: 1px;
  display: grid; place-items: center; font-size: 13px;
}
.sb-brand { min-width: 0; }
.sb-word {
  font-family: var(--font-serif); font-size: 14px; font-weight: 500;
  color: var(--text); letter-spacing: .3px;
}
.sb-slogan { font-size: 10px; color: var(--mute); letter-spacing: .12em; text-transform: uppercase; margin-top: 2px; }

.sb-nav { display: flex; flex-direction: column; gap: 2px; margin-top: 4px; }
.sb-section {
  font-size: 10px; text-transform: uppercase; letter-spacing: .15em;
  color: var(--mute); padding: 14px 10px 6px;
}
.nav-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; border-radius: var(--radius-sm);
  color: var(--dim); font-weight: 500; font-size: 13.5px;
  position: relative; cursor: pointer;
  transition: background .15s, color .15s;
}
.nav-item:hover { background: var(--surface); color: var(--text); }
.nav-item.is-active { background: var(--surface); color: var(--text); }
.nav-item.is-active .nav-bar {
  position: absolute; left: -14px; top: 10px; bottom: 10px; width: 3px;
  background: var(--emp-accent); border-radius: 0 3px 3px 0;
}
.nav-ic {
  width: 20px; height: 20px; display: inline-flex; align-items: center; justify-content: center;
  color: var(--mute);
}
.nav-item.is-active .nav-ic,
.nav-item:hover .nav-ic { color: var(--emp-accent); }
.nav-badge {
  margin-left: auto; font-size: 10px; font-weight: 700;
  padding: 2px 8px; border-radius: 999px;
  background: var(--emp-accent-soft); color: var(--emp-accent);
  border: 1px solid var(--emp-accent-soft);
}
.nav-badge.danger { background: rgba(248,113,113,.14); color: var(--bad); border-color: rgba(248,113,113,.3); }
.nav-badge.wa     { background: rgba(37,211,102,.14); color: var(--wa); border-color: rgba(37,211,102,.3); }

/* Empresa accordion */
.emp-group { margin: 2px 0; }
.emp-head {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: var(--radius-sm);
  cursor: pointer; color: var(--text); font-weight: 600; font-size: 13.5px;
  position: relative;
}
.emp-head:hover { background: var(--surface); }
.emp-head.is-open { background: var(--surface); }
.emp-head.is-active-ctx .emp-bar {
  position: absolute; left: -14px; top: 8px; bottom: 8px; width: 3px;
  border-radius: 0 3px 3px 0;
}
.emp-chip {
  width: 28px; height: 28px; border-radius: 8px;
  display: grid; place-items: center;
  font-weight: 700; font-size: 10.5px; letter-spacing: .5px;
}
.emp-chevron {
  margin-left: auto; width: 14px; height: 14px; color: var(--mute);
  transition: transform .18s;
}
.emp-head.is-open .emp-chevron { transform: rotate(90deg); color: var(--emp-accent); }
.emp-sub {
  display: none; flex-direction: column; gap: 2px; padding: 4px 0 6px 38px;
}
.emp-group.is-open .emp-sub { display: flex; }
.sub-item {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 12px; border-radius: 8px;
  color: var(--dim); font-size: 13px; font-weight: 500;
  cursor: pointer;
}
.sub-item:hover { color: var(--text); background: rgba(255,255,255,.03); }
.sub-item.is-active { color: var(--text); font-weight: 600; }
.sub-item.is-active::before {
  content: ""; width: 5px; height: 5px; border-radius: 50%;
  background: var(--emp-cur, var(--gold));
}
.sub-item.is-active { padding-left: 8px; }
.sub-item .sub-ic { width: 14px; height: 14px; color: var(--mute); }
.sub-item.is-active .sub-ic { color: var(--emp-cur, var(--gold)); }
.sub-badge {
  margin-left: auto; font-size: 10px; font-weight: 700;
  padding: 1px 7px; border-radius: 999px;
  background: var(--surface-2); color: var(--dim);
}

.sb-foot {
  margin-top: auto; padding-top: 14px; border-top: 1px solid var(--border);
}
.sb-user { display: flex; align-items: center; gap: 10px; padding: 4px 6px; }
.sb-avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--surface-2); color: var(--gold);
  display: grid; place-items: center; font-weight: 700;
  border: 1px solid var(--border-2);
}
.sb-user-info { min-width: 0; flex: 1; }
.sb-user-name { font-size: 13px; font-weight: 600; color: var(--text); }
.sb-user-role { font-size: 11px; color: var(--mute); }
.sb-logout {
  background: var(--surface-2); color: var(--mute); border: 1px solid var(--border-2);
  width: 32px; height: 32px; border-radius: 8px; display: grid; place-items: center;
  cursor: pointer;
}
.sb-logout:hover { color: var(--gold); border-color: var(--gold); }

/* -- Topbar (mobile shows hamburger) -- */
.topbar {
  display: none;
  position: sticky; top: 0; z-index: 30;
  background: rgba(10,22,40,.9);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
  height: var(--topbar-h);
  padding: 0 14px;
  align-items: center; gap: 10px;
}
.hamb {
  background: var(--surface-2); border: 1px solid var(--border-2);
  width: 38px; height: 38px; border-radius: 10px;
  display: grid; place-items: center; color: var(--text); cursor: pointer;
}
.topbar-title { font-family: var(--font-serif); font-size: 16px; }

/* -- Content -- */
.page { padding: 28px 32px 48px; max-width: 1400px; width: 100%; }
.page-head {
  display: flex; align-items: flex-end; justify-content: space-between; gap: 20px;
  margin-bottom: 22px;
}
.page-head .lhs { min-width: 0; }
.page-head h1 { font-size: 28px; }
.page-head .crumb {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 11px; letter-spacing: .14em; text-transform: uppercase;
  color: var(--mute); margin-bottom: 6px;
}
.page-head .crumb .ctx-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--emp-accent); }
.page-head .cta { display: flex; gap: 8px; flex-wrap: wrap; }

/* -- Buttons -- */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 9px 14px; border-radius: 10px;
  font-weight: 600; font-size: 13px; cursor: pointer;
  background: var(--surface-2); color: var(--text); border: 1px solid var(--border-2);
  transition: all .15s; font-family: inherit;
}
.btn:hover { background: var(--surface-3); border-color: var(--emp-accent); }
.btn.primary { background: var(--emp-accent); color: var(--emp-accent-ink); border-color: var(--emp-accent); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.sm { padding: 6px 10px; font-size: 12px; border-radius: 8px; }
.btn.ghost { background: transparent; border-color: var(--border); color: var(--dim); }
.btn.ghost:hover { color: var(--text); border-color: var(--border-2); background: transparent; }
.btn .ic { width: 14px; height: 14px; }

/* -- KPI cards -- */
.kpi-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 20px; }
.kpi {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px 16px 18px; position: relative;
  transition: border-color .15s, transform .15s;
}
.kpi:hover { border-color: var(--border-2); }
.kpi .accent-line {
  position: absolute; left: 0; top: 14px; bottom: 14px; width: 3px;
  background: var(--emp-accent); border-radius: 0 3px 3px 0;
}
.kpi .lbl { font-size: 10px; letter-spacing: .14em; text-transform: uppercase; color: var(--mute); font-weight: 600; margin-bottom: 8px; padding-left: 10px; }
.kpi .val { font-family: var(--font-serif); font-size: 28px; line-height: 1; color: var(--text); padding-left: 10px; }
.kpi .delta { font-size: 11.5px; color: var(--dim); margin-top: 8px; padding-left: 10px; }
.kpi .delta.up { color: var(--ok); }
.kpi .delta.down { color: var(--bad); }

/* -- Panel card -- */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 18px;
}
.card.pad-lg { padding: 22px; }
.card-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 14px; margin-bottom: 14px;
}
.panel-title {
  font-family: var(--font-serif); font-size: 17px; color: var(--text);
  display: flex; align-items: center; gap: 10px;
}
.panel-title::before {
  content: ""; width: 3px; height: 16px; background: var(--emp-accent); border-radius: 2px;
}

/* -- Grid helpers -- */
.grid-2 { display: grid; grid-template-columns: 2fr 1fr; gap: 16px; }
.grid-equal-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

/* -- Pill / tag -- */
.pill {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px; border-radius: 999px;
  font-size: 10.5px; font-weight: 700; letter-spacing: .5px; text-transform: uppercase;
  background: var(--emp-accent-soft); color: var(--emp-accent);
  border: 1px solid var(--emp-accent-soft);
}
.pill.gold { background: rgba(201,169,97,.12); color: var(--gold); border-color: rgba(201,169,97,.25); }
.pill.wa  { background: rgba(37,211,102,.14); color: var(--wa); border-color: rgba(37,211,102,.3); }
.pill.ig  { background: rgba(225,48,108,.14); color: var(--ig); border-color: rgba(225,48,108,.3); }
.pill.soft { text-transform: none; font-weight: 500; font-size: 11px; letter-spacing: 0; }

.tag {
  display: inline-block; padding: 2px 8px; border-radius: 6px;
  font-size: 11px; font-weight: 500;
  background: var(--surface-2); color: var(--dim); border: 1px solid var(--border-2);
  margin-right: 4px;
}

.linkia-badge {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 10px; letter-spacing: .08em; text-transform: uppercase;
  color: var(--mute); background: rgba(255,255,255,.03);
  border: 1px solid var(--border);
  padding: 2px 8px; border-radius: 999px;
}
.linkia-badge::before {
  content: ""; width: 5px; height: 5px; border-radius: 50%; background: var(--gold); opacity: .6;
}

/* -- Table -- */
.tbl { width: 100%; border-collapse: collapse; }
.tbl thead th {
  text-align: left; padding: 10px 12px;
  font-size: 10px; text-transform: uppercase; letter-spacing: .12em;
  color: var(--mute); font-weight: 600;
  border-bottom: 1px solid var(--border); background: var(--surface-2);
}
.tbl tbody td {
  padding: 13px 12px; border-bottom: 1px solid var(--border);
  font-size: 13px; vertical-align: middle;
}
.tbl tbody tr:hover { background: rgba(255,255,255,.015); }
.tbl .name { font-weight: 600; color: var(--text); }

/* -- Inputs -- */
.input, .select {
  background: var(--bg); color: var(--text);
  border: 1px solid var(--border-2); border-radius: 10px;
  padding: 9px 12px; font-size: 13px; font-family: inherit;
  width: 100%;
}
.input:focus, .select:focus { outline: none; border-color: var(--emp-accent); }
.search { position: relative; }
.search .ic { position: absolute; left: 12px; top: 10px; width: 16px; height: 16px; color: var(--mute); pointer-events: none; }
.search .input { padding-left: 36px; }

/* =====================================================================
   CONVERSAS (inbox unificada)
   ===================================================================== */
.inbox {
  display: grid; grid-template-columns: 360px 1fr;
  gap: 0; min-height: calc(100vh - 110px);
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface); overflow: hidden;
}
.inbox-list { border-right: 1px solid var(--border); display: flex; flex-direction: column; min-width: 0; }
.inbox-toolbar { padding: 14px; border-bottom: 1px solid var(--border); display: flex; flex-direction: column; gap: 10px; background: var(--bg-2); }
.inbox-filters { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  padding: 5px 10px; border-radius: 999px; font-size: 11.5px; font-weight: 500;
  background: var(--surface-2); color: var(--dim); border: 1px solid var(--border-2);
  cursor: pointer; display: inline-flex; align-items: center; gap: 6px;
}
.chip.on { background: var(--emp-accent-soft); color: var(--emp-accent); border-color: var(--emp-accent); }
.chip .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

.inbox-items { overflow-y: auto; flex: 1; }
.inbox-item {
  display: grid; grid-template-columns: 42px 1fr auto;
  gap: 10px; padding: 12px 14px; border-bottom: 1px solid var(--border);
  cursor: pointer; position: relative; align-items: center;
}
.inbox-item:hover { background: rgba(255,255,255,.02); }
.inbox-item.active { background: var(--surface-2); }
.inbox-item.active::before {
  content: ""; position: absolute; left: 0; top: 10px; bottom: 10px; width: 3px;
  background: var(--emp-accent); border-radius: 0 3px 3px 0;
}
.av {
  width: 42px; height: 42px; border-radius: 50%; display: grid; place-items: center;
  font-weight: 700; color: var(--text); font-size: 15px;
  background: linear-gradient(135deg, var(--surface-3), var(--surface-2));
  border: 1px solid var(--border-2); position: relative;
}
.av .ch-badge {
  position: absolute; bottom: -2px; right: -2px;
  width: 16px; height: 16px; border-radius: 50%;
  display: grid; place-items: center;
  border: 2px solid var(--surface);
}
.av .ch-badge svg { width: 9px; height: 9px; color: #fff; }
.av .ch-badge.wa { background: var(--wa); }
.av .ch-badge.ig { background: linear-gradient(135deg,#fdbb2d,#e1306c 50%,#833ab4); }

.inbox-body { min-width: 0; }
.inbox-head-row {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
}
.inbox-name { font-weight: 600; color: var(--text); font-size: 13.5px; }
.inbox-when { font-size: 11px; color: var(--mute); white-space: nowrap; }
.inbox-preview { font-size: 12.5px; color: var(--dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-top: 2px; }
.inbox-item-right { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }
.emp-strip {
  width: 4px; border-radius: 2px; height: 32px;
}
.unread {
  min-width: 20px; height: 20px; border-radius: 10px;
  background: var(--emp-accent); color: var(--emp-accent-ink);
  font-size: 11px; font-weight: 700; display: grid; place-items: center; padding: 0 6px;
}
.emp-label {
  font-size: 9.5px; letter-spacing: .1em; text-transform: uppercase;
  padding: 2px 6px; border-radius: 4px; font-weight: 700;
}

/* -- Chat pane -- */
.chat { display: flex; flex-direction: column; min-width: 0; }
.chat-head {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 18px; border-bottom: 1px solid var(--border); background: var(--bg-2);
}
.chat-head .av { width: 38px; height: 38px; font-size: 14px; }
.chat-head .meta { flex: 1; min-width: 0; }
.chat-head .meta .name { font-weight: 600; color: var(--text); font-size: 14px; }
.chat-head .meta .sub { font-size: 11.5px; color: var(--mute); display: flex; gap: 8px; align-items: center; margin-top: 2px; }
.chat-head-actions { display: flex; gap: 8px; }

.chat-stream {
  flex: 1; overflow-y: auto;
  padding: 22px 24px; display: flex; flex-direction: column; gap: 8px;
  background:
    radial-gradient(800px 500px at 20% 20%, rgba(201,169,97,.025), transparent 70%),
    var(--bg);
  min-height: 300px;
}
.msg { max-width: 68%; padding: 9px 13px; border-radius: 12px; font-size: 13.5px; line-height: 1.45; position: relative; }
.msg .hora { font-size: 10px; color: var(--mute); margin-top: 3px; text-align: right; }
.msg.in { align-self: flex-start; background: var(--surface-2); border: 1px solid var(--border); color: var(--text); border-bottom-left-radius: 4px; }
.msg.out { align-self: flex-end; background: var(--emp-accent); color: var(--emp-accent-ink); border-bottom-right-radius: 4px; }
.msg.out .hora { color: rgba(0,0,0,.55); }
.msg.nota {
  align-self: center; background: rgba(251,191,36,.08); border: 1px dashed rgba(251,191,36,.3);
  color: var(--warn); font-size: 12px; max-width: 80%;
}
.msg.nota::before { content: "nota interna · "; font-weight: 700; letter-spacing: .05em; font-size: 10px; color: var(--warn); }

.chat-compose {
  border-top: 1px solid var(--border); padding: 12px 14px;
  display: flex; flex-direction: column; gap: 8px; background: var(--bg-2);
}
.compose-tabs { display: flex; gap: 4px; }
.compose-tab {
  padding: 5px 11px; border-radius: 8px 8px 0 0; font-size: 11.5px; font-weight: 600;
  background: transparent; color: var(--mute); border: 1px solid transparent; border-bottom: none; cursor: pointer;
}
.compose-tab.on { background: var(--bg); color: var(--text); border-color: var(--border); }
.compose-tab.on.nota { color: var(--warn); }
.compose-box { display: flex; gap: 8px; align-items: flex-end; }
.compose-box .input { border-radius: 12px; padding: 10px 14px; min-height: 42px; }
.compose-box .btn { padding: 10px 14px; }

.empty {
  display: grid; place-items: center; text-align: center; color: var(--mute);
  padding: 60px 20px; font-size: 13px;
}

/* =====================================================================
   PIPELINE (kanban) — padrão self-imobi
   .main precisa de min-width:0 (já está no shell grid). O wrap confina o
   scroll horizontal do board, a página nunca rola na lateral. Em >=1360px
   as 5 colunas distribuem em 1fr e cabem sem scroll interno em 1366/1440.
   ===================================================================== */
.kanban-stage { position: relative; }

.kanban-wrap {
  position: relative;
  overflow-x: auto;
  overflow-y: hidden;
  padding-bottom: 6px;
  max-width: 100%;
  scrollbar-color: var(--gold-dim) transparent;
  scrollbar-width: thin;
  user-select: text;
  cursor: grab;
}
.kanban-wrap.panning { cursor: grabbing; user-select: none; }
.kanban-wrap::-webkit-scrollbar { height: 10px; }
.kanban-wrap::-webkit-scrollbar-thumb {
  background: var(--gold-dim); border-radius: 999px;
  border: 2px solid transparent; background-clip: padding-box;
}
.kanban-wrap::-webkit-scrollbar-thumb:hover { background: var(--gold); background-clip: padding-box; border: 2px solid transparent; }
.kanban-wrap::-webkit-scrollbar-track { background: rgba(255,255,255,.015); border-radius: 999px; }

/* Botões de nav ‹ › aparecem só quando há scroll horizontal */
.kanban-nav {
  position: absolute; top: 50%; transform: translateY(-50%);
  width: 38px; height: 38px;
  display: none; align-items: center; justify-content: center;
  background: var(--surface); border: 1px solid var(--gold-dim);
  color: var(--gold); border-radius: 50%;
  cursor: pointer; z-index: 6;
  box-shadow: 0 6px 18px rgba(0,0,0,.5), 0 0 0 4px rgba(10,22,40,.35);
  transition: background .14s, color .14s, border-color .14s, opacity .14s;
}
.kanban-nav:hover { background: rgba(201,169,97,.2); border-color: var(--gold); }
.kanban-nav:active { transform: translateY(-50%) scale(0.94); }
.kanban-nav:disabled { opacity: .25; cursor: not-allowed; }
.kanban-nav.prev { left: -18px; }
.kanban-nav.next { right: -18px; }
.kanban-stage.has-scroll .kanban-nav { display: flex; }
@media (max-width: 599px) {
  .kanban-nav { display: none !important; }
}

/* Gradientes nas bordas pra sinalizar scroll */
.kanban-wrap::before,
.kanban-wrap::after {
  content: ''; position: sticky; top: 0;
  width: 28px; height: 100%;
  pointer-events: none; opacity: 0;
  transition: opacity .18s; z-index: 3;
}
.kanban-wrap::before { left: 0; margin-right: -28px; background: linear-gradient(90deg, var(--bg) 0%, rgba(10,22,40,0) 100%); }
.kanban-wrap::after  { right: 0; margin-left: -28px; background: linear-gradient(270deg, var(--bg) 0%, rgba(10,22,40,0) 100%); }
.kanban-wrap.has-scroll:not(.at-start)::before { opacity: 1; }
.kanban-wrap.has-scroll:not(.at-end)::after   { opacity: 1; }

/* Até 1359px: colunas fixas 232px, board rola internamente. A partir de 1360px
   distribui em 1fr com piso de 196px por coluna: cabe em 1366+ sem scroll. */
.kanban {
  display: grid;
  grid-template-columns: repeat(5, 232px);
  gap: 10px;
  min-width: max-content;
}
@media (min-width: 900px) {
  .kanban { height: 100%; align-items: stretch; }
}
@media (min-width: 1360px) {
  .kanban {
    grid-template-columns: repeat(5, minmax(196px, 1fr));
    min-width: 0;
  }
}

.col {
  background: linear-gradient(180deg, var(--bg-2), transparent);
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 0;
  display: flex; flex-direction: column; min-width: 0;
  overflow: hidden;
  min-height: 460px;
}
@media (min-width: 900px) {
  .col { height: 100%; min-height: 0; }
  .col-body {
    overflow-y: auto; scrollbar-width: thin;
    scrollbar-color: var(--border-2) transparent;
  }
  .col-body::-webkit-scrollbar { width: 6px; }
  .col-body::-webkit-scrollbar-thumb { background: var(--border-2); border-radius: 999px; }
  .col-body::-webkit-scrollbar-track { background: transparent; }
}
.col-head {
  position: sticky; top: 0; z-index: 2;
  background: var(--bg-2);
  padding: 12px 14px 10px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.col-head .nm { font-weight: 600; color: var(--text); font-size: 13px; display: flex; align-items: center; gap: 8px; }
.col-head .nm::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--emp-accent); }
.col-head .ct { font-size: 11px; color: var(--mute); font-weight: 600; }
.col-body {
  padding: 10px; display: flex; flex-direction: column; gap: 8px;
  flex: 1; min-height: 0;
}
.card-op {
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 10px; padding: 11px 12px; cursor: grab;
  transition: transform .12s, border-color .12s, box-shadow .12s;
}
.card-op:hover { border-color: var(--border-2); transform: translateY(-1px); box-shadow: 0 6px 16px rgba(0,0,0,.25); }
.card-op.drag { opacity: .5; }
.col.drop-over { background: var(--emp-accent-soft); border-color: var(--emp-accent); }
.card-op .top { display: flex; justify-content: space-between; align-items: flex-start; gap: 6px; margin-bottom: 6px; }
.card-op .nm { font-weight: 600; color: var(--text); font-size: 13px; line-height: 1.3; }
.card-op .val { font-family: var(--font-serif); font-size: 15px; color: var(--emp-accent); font-weight: 500; margin-top: 4px; }
.card-op .bot { display: flex; align-items: center; justify-content: space-between; margin-top: 8px; }
.card-op .person { font-size: 11px; color: var(--mute); display: flex; align-items: center; gap: 6px; }
.card-op .mini-av { width: 18px; height: 18px; border-radius: 50%; background: var(--surface-3); display: grid; place-items: center; font-size: 9px; font-weight: 700; color: var(--text); border: 1px solid var(--border-2); }

/* Fancy icons */
.svg-ic { display: inline-block; vertical-align: middle; }

/* =====================================================================
   CONEXÕES
   ===================================================================== */
.conn-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.conn-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px;
  display: flex; flex-direction: column; gap: 14px;
}
.conn-head { display: flex; align-items: center; gap: 12px; }
.conn-logo {
  width: 48px; height: 48px; border-radius: 12px; display: grid; place-items: center;
}
.conn-logo.wa { background: linear-gradient(135deg, #25d366, #128c7e); }
.conn-logo.ig { background: linear-gradient(135deg, #fdbb2d, #e1306c 50%, #833ab4); }
.conn-logo svg { width: 24px; height: 24px; color: white; }
.conn-title { flex: 1; }
.conn-title .nm { font-weight: 600; font-size: 15px; color: var(--text); }
.conn-title .sub { font-size: 12px; color: var(--mute); }
.conn-status { display: flex; align-items: center; gap: 8px; font-size: 12px; }
.conn-status .dot { width: 8px; height: 8px; border-radius: 50%; }
.conn-status.on .dot { background: var(--ok); box-shadow: 0 0 10px var(--ok); }
.conn-status.off .dot { background: var(--mute); }
.conn-status.on { color: var(--ok); }
.conn-status.off { color: var(--mute); }
.conn-meta { display: flex; flex-direction: column; gap: 6px; padding-top: 12px; border-top: 1px solid var(--border); }
.conn-meta .row { display: flex; justify-content: space-between; font-size: 12.5px; }
.conn-meta .row .k { color: var(--mute); text-transform: uppercase; letter-spacing: .1em; font-size: 10.5px; font-weight: 600; }
.conn-meta .row .v { color: var(--text); font-weight: 500; }
.conn-actions { display: flex; gap: 8px; margin-top: auto; }

/* =====================================================================
   MODAL
   ===================================================================== */
.modal-bg {
  position: fixed; inset: 0; background: rgba(5,10,20,.75); z-index: 60;
  display: none; align-items: center; justify-content: center;
  backdrop-filter: blur(4px);
  padding: 20px;
}
.modal-bg.on { display: flex; }
.modal {
  background: var(--surface); border: 1px solid var(--border-2);
  border-radius: var(--radius); max-width: 540px; width: 100%;
  padding: 26px; box-shadow: 0 30px 80px rgba(0,0,0,.6);
  max-height: 90vh; overflow-y: auto;
}
.modal h2 { font-size: 22px; margin-bottom: 6px; }
.modal .sub { color: var(--dim); font-size: 13px; margin-bottom: 20px; }
.modal-step { display: flex; gap: 10px; padding: 14px; border-radius: 10px; background: var(--bg-2); border: 1px solid var(--border); margin-bottom: 10px; }
.modal-step .n { width: 24px; height: 24px; border-radius: 50%; background: var(--emp-accent); color: var(--emp-accent-ink); display: grid; place-items: center; font-weight: 700; font-size: 12px; flex-shrink: 0; }
.modal-step .t { flex: 1; }
.modal-step .t strong { font-size: 13px; color: var(--text); display: block; margin-bottom: 2px; }
.modal-step .t span { font-size: 12px; color: var(--mute); }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; padding-top: 20px; border-top: 1px solid var(--border); }

/* -- Toast -- */
.toast-stack { position: fixed; top: 20px; right: 20px; z-index: 70; display: flex; flex-direction: column; gap: 8px; }
.toast {
  background: var(--surface); border: 1px solid var(--emp-accent);
  border-radius: 10px; padding: 12px 16px; font-size: 13px;
  color: var(--text); box-shadow: 0 10px 30px rgba(0,0,0,.4);
  animation: slideIn .25s ease-out;
}
@keyframes slideIn {
  from { transform: translateX(20px); opacity: 0; }
  to   { transform: translateX(0);    opacity: 1; }
}

/* =====================================================================
   RESPONSIVO
   ===================================================================== */
@media (max-width: 1100px) {
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .grid-2 { grid-template-columns: 1fr; }
  .conn-grid { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .sb {
    position: fixed; z-index: 50; top: 0; left: 0; width: 86%; max-width: 320px;
    height: 100vh;
    transform: translateX(-100%); transition: transform .22s ease-out;
    box-shadow: 10px 0 40px rgba(0,0,0,.6);
  }
  .sb.open { transform: translateX(0); }
  .sb-mask.on { display: block; }
  .topbar { display: flex; }
  .page { padding: 18px 16px 42px; }
  .page-head { flex-direction: column; align-items: flex-start; }
  .inbox { grid-template-columns: 1fr; min-height: unset; }
  .inbox-list { max-height: 55vh; }
  .inbox.showing-chat .inbox-list { display: none; }
  .inbox:not(.showing-chat) .chat { display: none; }
  .kanban { grid-auto-columns: 82vw; }
}
@media (max-width: 560px) {
  .kpi-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .kpi .val { font-size: 22px; }
  .page-head h1 { font-size: 22px; }
}

@media (max-width: 860px) {
  .chat-head { flex-wrap: wrap; padding: 10px 12px; gap: 10px; }
  .chat-head .meta { flex: 1 1 100%; order: 2; }
  .chat-head .av { order: 1; }
  .chat-head-actions { flex: 1 1 100%; order: 3; justify-content: flex-start; gap: 6px; }
  .chat-head-actions .btn { font-size: 11.5px; padding: 6px 10px; }
  .chat-head .meta .sub { flex-wrap: wrap; gap: 6px; }
  .msg { max-width: 82%; }
}
