/* Conecta CRM — shell enterprise (HubSpot / Pipedrive / Attio tier) */

:root {
  --crm-pipeline-draft: #94a3b8;
  --crm-pipeline-ready: #3b82f6;
  --crm-pipeline-submitted: #8b5cf6;
  --crm-pipeline-done: #22c55e;
  --crm-pipeline-blocked: #ef4444;
  --blue: var(--crm-accent);
  --blue-dark: var(--crm-accent-hover);
  --blue-soft: var(--crm-accent-soft);
  --gray-bg: var(--crm-page-bg);
  --gray-border: var(--crm-border);
}

/* ========== ADM SHELL ========== */
.crm-app.crm-adm {
  min-height: 100vh;
  background: var(--crm-page-bg);
}

html[data-theme="dark"] .crm-topbar {
  background: var(--surface);
  border-bottom-color: var(--crm-border);
}

html[data-theme="dark"] .crm-main {
  background: var(--crm-page-bg);
}

html[data-theme="dark"] .crm-topbar .user-badge {
  background: var(--surface-2);
  color: var(--text);
  border-color: var(--crm-border);
}

.crm-shell {
  display: flex;
  min-height: 100vh;
}

.crm-sidebar {
  width: var(--crm-sidebar-w);
  flex-shrink: 0;
  background: var(--crm-sidebar-bg);
  color: var(--crm-sidebar-text);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 200;
  border-right: 1px solid var(--crm-sidebar-border);
  transition: transform var(--duration-normal) var(--ease-out);
  box-shadow: 4px 0 24px rgba(0, 0, 0, .12);
}

.crm-sidebar-brand {
  padding: 1.25rem 1.15rem 1rem;
  border-bottom: 1px solid var(--crm-sidebar-border);
  display: flex;
  align-items: center;
  gap: .65rem;
}

.crm-logo {
  height: 36px;
  width: auto;
  max-width: 140px;
  object-fit: contain;
  filter: brightness(0) invert(1);
  opacity: .95;
}

.crm-product-badge {
  font-size: .62rem;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  background: linear-gradient(135deg, rgba(59, 130, 246, .45), rgba(37, 99, 235, .25));
  color: #dbeafe;
  padding: 4px 9px;
  border-radius: var(--radius-full);
  border: 1px solid rgba(147, 197, 253, .22);
}

.crm-nav {
  flex: 1;
  min-height: 0;
  overflow: hidden;
  padding: .85rem .75rem 0;
  display: flex;
  flex-direction: column;
  gap: .15rem;
}

.crm-nav-main {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, .12) transparent;
}

.crm-nav-bottom {
  flex-shrink: 0;
  padding: .5rem 0 .85rem;
  margin-top: auto;
}

.crm-nav-group { margin-bottom: .65rem; }
.crm-nav-group-label {
  display: block;
  padding: .35rem .85rem .45rem;
  font-size: .65rem;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: rgba(148, 163, 184, .72);
}

.crm-nav.tabs-nav-left {
  flex-direction: column;
  gap: 2px;
}

.crm-nav button,
.crm-nav.tabs-nav-left button {
  display: flex;
  align-items: center;
  gap: .75rem;
  width: 100%;
  text-align: left;
  background: transparent;
  border: none;
  border-radius: var(--radius-md);
  padding: .62rem .85rem;
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--crm-sidebar-text);
  cursor: pointer;
  white-space: nowrap;
  transition: background var(--duration-fast) var(--ease-out), color var(--duration-fast) var(--ease-out), box-shadow var(--duration-fast) var(--ease-out);
  position: relative;
}

.crm-nav button:hover,
.crm-nav.tabs-nav-left button:hover {
  background: var(--crm-sidebar-hover);
  color: var(--crm-sidebar-text-active);
}

.crm-nav button.active,
.crm-nav.tabs-nav-left button.active {
  background: linear-gradient(90deg, rgba(37, 99, 235, .28) 0%, rgba(37, 99, 235, .08) 100%);
  color: var(--crm-sidebar-text-active);
  font-weight: 600;
  box-shadow: inset 0 0 0 1px rgba(96, 165, 250, .18);
}

.crm-nav button.active::before,
.crm-nav.tabs-nav-left button.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 58%;
  border-radius: 0 4px 4px 0;
  background: linear-gradient(180deg, #60a5fa, #2563eb);
}

.crm-nav-icon {
  width: 20px;
  height: 20px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  opacity: .78;
}
.crm-nav-icon svg { width: 18px; height: 18px; display: block; }

.crm-nav button.active .crm-nav-icon { opacity: 1; color: #93c5fd; }

.crm-nav button.hidden,
.crm-nav.tabs-nav-left button.hidden {
  display: none !important;
}

body.crm-readonly .crm-write-only {
  display: none !important;
}

.crm-nav-operador {
  border-top: 1px solid rgba(255, 255, 255, .06);
  background: rgba(99, 102, 241, .12);
}
.crm-nav-operador:hover {
  background: rgba(99, 102, 241, .22);
}

.crm-sidebar-foot {
  flex-shrink: 0;
  padding: .65rem .75rem 1.1rem;
  border-top: 1px solid rgba(255, 255, 255, .06);
  display: flex;
  flex-direction: column;
  gap: .45rem;
}

.crm-sidebar-foot-btn {
  display: flex;
  align-items: center;
  gap: .75rem;
  width: 100%;
  text-align: left;
  background: transparent;
  border: none;
  border-radius: var(--radius-md);
  padding: .62rem .85rem;
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--crm-sidebar-text);
  cursor: pointer;
  white-space: nowrap;
  transition: background var(--duration-fast) var(--ease-out), color var(--duration-fast) var(--ease-out);
  position: relative;
}

.crm-sidebar-foot-btn:hover {
  background: var(--crm-sidebar-hover);
  color: var(--crm-sidebar-text-active);
}

.crm-sidebar-foot-btn.active {
  background: linear-gradient(90deg, rgba(37, 99, 235, .28) 0%, rgba(37, 99, 235, .08) 100%);
  color: var(--crm-sidebar-text-active);
  font-weight: 600;
  box-shadow: inset 0 0 0 1px rgba(96, 165, 250, .18);
}

.crm-sidebar-foot-btn.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 58%;
  border-radius: 0 4px 4px 0;
  background: linear-gradient(180deg, #60a5fa, #2563eb);
}

.crm-sidebar-foot-btn.active .crm-nav-icon { opacity: 1; color: #93c5fd; }

.crm-portal-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .5rem;
  padding: .65rem .85rem;
  border-radius: 10px;
  background: rgba(255, 255, 255, .05);
  color: #cbd5e1;
  font-size: .8rem;
  font-weight: 600;
  text-decoration: none;
  transition: background .15s;
}

.crm-portal-link:hover {
  background: rgba(255, 255, 255, .1);
  color: #fff;
  text-decoration: none;
}

.crm-main {
  flex: 1;
  margin-left: var(--crm-sidebar-w);
  min-width: 0;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.crm-topbar {
  height: var(--crm-topbar-h);
  min-height: var(--crm-topbar-h);
  background: rgba(255, 255, 255, .88);
  backdrop-filter: blur(12px) saturate(1.2);
  border-bottom: 1px solid var(--crm-border);
  display: flex;
  align-items: center;
  gap: var(--space-4);
  padding: 0 var(--space-5);
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--elevation-1);
}

html[data-theme="dark"] .crm-topbar {
  background: rgba(26, 35, 50, .92);
}

.crm-topbar-context {
  display: none;
  flex-direction: column;
  gap: .1rem;
  min-width: 0;
  margin-right: .5rem;
}
@media (min-width: 768px) {
  .crm-topbar-context { display: flex; }
}
.crm-topbar-title {
  font-size: var(--text-lg);
  font-weight: 700;
  letter-spacing: -.03em;
  line-height: 1.2;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.crm-topbar-subtitle {
  font-size: var(--text-xs);
  color: var(--gray-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.crm-menu-toggle {
  display: none;
  background: none;
  border: 1px solid var(--crm-border);
  border-radius: 8px;
  width: 38px;
  height: 38px;
  cursor: pointer;
  font-size: 1.1rem;
  color: var(--text);
}

.crm-topbar-search {
  flex: 1;
  max-width: 420px;
}

.crm-topbar-search input {
  width: 100%;
  padding: .58rem .95rem .58rem 2.45rem;
  border-radius: var(--radius-full);
  border: 1px solid var(--crm-border);
  background: var(--neutral-50);
  font-size: var(--text-sm);
  transition: border-color var(--duration-fast), box-shadow var(--duration-fast), background var(--duration-fast);
}
.crm-topbar-search input:focus {
  background: var(--surface);
  border-color: var(--brand-500);
  box-shadow: var(--elevation-focus);
}

.crm-topbar-search {
  position: relative;
}

.crm-topbar-search::before {
  content: '';
  position: absolute;
  left: .85rem;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  opacity: .45;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%2364748b'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M21 21l-4.35-4.35M11 18a7 7 0 100-14 7 7 0 000 14z'/%3E%3C/svg%3E") center/contain no-repeat;
}

.crm-topbar-actions {
  display: flex;
  align-items: center;
  gap: .65rem;
  margin-left: auto;
}

.crm-content {
  flex: 1;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  position: relative;
  isolation: isolate;
}

.crm-content::before {
  content: '';
  position: fixed;
  top: var(--crm-topbar-h);
  left: var(--crm-sidebar-w);
  right: 0;
  bottom: 0;
  background:
    radial-gradient(ellipse 70% 45% at 50% -10%, rgba(37, 99, 235, .07), transparent 55%),
    var(--crm-page-bg);
  pointer-events: none;
  z-index: -1;
}

@media (max-width: 1023px) {
  .crm-content::before { left: 0; }
}

.crm-adm .tab-pane.crm-tab-fullbleed {
  flex: 1;
  min-height: 0;
  padding: 0;
  margin: 0;
}

.crm-adm .tab-pane.crm-tab-fullbleed.active {
  display: flex;
  flex-direction: column;
}

.crm-adm header:not(.crm-topbar) { display: none !important; }
.crm-adm nav.tabs { display: none !important; }

.crm-adm .container {
  max-width: 1480px;
  padding: var(--space-6) var(--space-6) 3rem;
}

.crm-adm .dash-section-title {
  font-size: var(--text-lg);
  font-weight: 700;
  text-transform: none;
  letter-spacing: -.03em;
  color: var(--text);
}

.crm-page-header {
  display: none;
}

.crm-page-header h1 {
  font-size: var(--text-2xl);
  font-weight: 700;
  letter-spacing: -.03em;
  margin-bottom: .25rem;
}

.crm-page-header p {
  color: var(--gray-text);
  font-size: var(--text-sm);
}

.crm-adm .panel {
  border-radius: var(--radius-lg);
  border-color: var(--crm-border);
  box-shadow: var(--elevation-1);
}

/* Conversas — WhatsApp Web feel */
.crm-adm .conversas-wrap {
  padding: 0;
  max-width: none;
}

.crm-adm .conversas-layout {
  grid-template-columns: 340px 1fr;
  gap: 0;
  min-height: calc(100vh - var(--crm-topbar-h) - 3rem);
  border: 1px solid var(--crm-border);
  border-radius: 14px;
  overflow: hidden;
  background: var(--surface);
}

.crm-adm .conversas-list {
  border: none;
  border-right: 1px solid var(--crm-border);
  border-radius: 0;
  max-height: none;
  background: #fafbfc;
}

.crm-adm .conversas-detail {
  border: none;
  border-radius: 0;
  min-height: 0;
}

.crm-adm .conversas-messages {
  background: #e5ddd5 url("data:image/svg+xml,%3Csvg width='60' height='60' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M0 0h30v30H0zm30 30h30v30H30z' fill='%23d4cdc4' fill-opacity='.15'/%3E%3C/svg%3E");
}

.crm-adm .conversas-msg--outbound {
  background: #d9fdd3;
  border: none;
  box-shadow: 0 1px 1px rgba(0, 0, 0, .06);
}

.crm-adm .conversas-msg--inbound {
  background: #fff;
  border: none;
  box-shadow: 0 1px 1px rgba(0, 0, 0, .06);
}

.crm-adm .conversas-page .container {
  padding-top: 0;
}

.crm-adm .relatorios-page .container.relatorios-page-inner {
  padding: var(--space-6);
  padding-bottom: 3rem;
  box-sizing: border-box;
}

.crm-adm .relatorios-wrap {
  padding: 0;
  max-width: none;
}

.crm-adm .relatorios-header {
  align-items: flex-end;
}

.crm-adm .relatorios-header h1 {
  font-size: 1.5rem;
  font-weight: 700;
  margin: 0;
}

/* Pipeline Kanban */
.pipeline-shell { padding-bottom: 2rem; }
.pipeline-head {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  align-items: center;
  gap: 1rem;
  margin-bottom: .75rem;
}

.pipeline-head-actions {
  display: flex;
  gap: .5rem;
  align-items: center;
  flex-wrap: wrap;
}
.pipeline-subnav {
  display: flex;
  gap: .35rem;
  background: var(--surface-2);
  padding: 4px;
  border-radius: 12px;
  border: 1px solid var(--crm-border);
}
.pipeline-subnav-btn {
  border: none;
  background: transparent;
  padding: .5rem 1rem;
  border-radius: 9px;
  font-size: .84rem;
  font-weight: 600;
  color: var(--gray-text);
  cursor: pointer;
}
.pipeline-subnav-btn.active {
  background: var(--surface);
  color: var(--crm-accent);
  box-shadow: var(--shadow-sm);
}
.pipeline-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
  align-items: center;
  margin-bottom: 1rem;
}
.pipeline-toolbar select { min-width: 150px; }
.pipeline-board {
  display: grid;
  grid-template-columns: repeat(5, minmax(200px, 1fr));
  gap: .75rem;
  align-items: start;
  overflow-x: auto;
  padding-bottom: .5rem;
}
.pipeline-column {
  background: var(--surface-2);
  border: 1px solid var(--crm-border);
  border-radius: 14px;
  min-height: 320px;
  display: flex;
  flex-direction: column;
  min-width: 200px;
}
.pipeline-column-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: .75rem .85rem;
  border-bottom: 1px solid var(--crm-border);
  background: var(--surface);
  border-radius: 14px 14px 0 0;
}
.pipeline-column-title {
  font-size: .78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.pipeline-column-count {
  font-size: .75rem;
  font-weight: 700;
  background: var(--crm-accent-soft);
  color: var(--crm-accent);
  padding: 2px 8px;
  border-radius: 999px;
}
.pipeline-column--draft .pipeline-column-count { background: #f1f5f9; color: #64748b; }
.pipeline-column--blocked .pipeline-column-count { background: #fee2e2; color: #dc2626; }
.pipeline-column--documents .pipeline-column-count { background: #fef3c7; color: #d97706; }
.pipeline-column--ready .pipeline-column-count { background: #dbeafe; color: #2563eb; }
.pipeline-column--sent .pipeline-column-count { background: #dcfce7; color: #16a34a; }
.pipeline-column-body {
  padding: .5rem;
  display: flex;
  flex-direction: column;
  gap: .5rem;
  flex: 1;
  overflow-y: auto;
  max-height: calc(100vh - 280px);
}
.pipeline-card {
  display: block;
  width: 100%;
  text-align: left;
  border: 1px solid var(--crm-border);
  border-radius: 12px;
  background: var(--surface);
  padding: .65rem .75rem;
  cursor: pointer;
  transition: border-color .15s, box-shadow .15s;
}
.pipeline-card:hover {
  border-color: #93c5fd;
  box-shadow: 0 4px 14px rgba(37, 99, 235, .12);
}
.pipeline-card-top {
  display: flex;
  justify-content: space-between;
  gap: .35rem;
  align-items: center;
  margin-bottom: .25rem;
}
.pipeline-card-name {
  font-size: .84rem;
  font-weight: 600;
  margin-bottom: .35rem;
}
.pipeline-card-meta {
  display: flex;
  justify-content: space-between;
  font-size: .7rem;
  color: var(--gray-text);
}
.pipeline-card-cep { font-size: .68rem; margin-top: .2rem; }
.pipeline-empty, .pipeline-loading, .pipeline-truncated {
  padding: 1rem;
  text-align: center;
  font-size: .82rem;
}
.wa-flows-actions { display: flex; gap: .5rem; flex-wrap: wrap; }

/* Fase 3 — forecast & score */
.forecast-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: .75rem;
  margin-bottom: .75rem;
}
.forecast-card {
  background: var(--surface-2, #f8fafc);
  border: 1px solid var(--crm-border, #e5e7eb);
  border-radius: 10px;
  padding: .75rem;
}
.forecast-card--primary {
  border-color: #2563eb;
  background: #eff6ff;
}
.forecast-label { display: block; font-size: .72rem; color: var(--gray-text); margin-bottom: .25rem; }
.forecast-card strong { font-size: 1.35rem; color: #111827; }
.score-dist { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.score-pill {
  font-size: .75rem;
  padding: .2rem .55rem;
  border-radius: 999px;
  background: #f3f4f6;
}
.score-pill--hot { background: #fef2f2; color: #b91c1c; }
.score-pill--warm { background: #fffbeb; color: #b45309; }
.score-pill--cold { background: #eff6ff; color: #1d4ed8; }
.pipeline-score {
  font-size: .65rem;
  font-weight: 700;
  padding: .1rem .35rem;
  border-radius: 6px;
  line-height: 1.2;
}
.pipeline-score--hot { background: #fee2e2; color: #991b1b; }
.pipeline-score--warm { background: #fef3c7; color: #92400e; }
.pipeline-score--cold { background: #dbeafe; color: #1e40af; }
.webhooks-list { display: flex; flex-direction: column; gap: .65rem; }
.webhook-row {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
  align-items: flex-start;
  justify-content: space-between;
  padding: .65rem .75rem;
  border: 1px solid var(--gray-border);
  border-radius: 8px;
  background: #fff;
}

.pipeline-portal-shell {
  height: calc(100vh - var(--crm-topbar-h) - 8rem);
  min-height: 480px;
  border: 1px solid var(--crm-border);
  border-radius: 14px;
  overflow: hidden;
  background: var(--surface-2);
}
.pipeline-portal-status {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .5rem;
  height: 100%;
  color: var(--gray-text);
  font-size: .9rem;
}
.pipeline-portal-status.hidden { display: none; }
.pipeline-portal-frame {
  width: 100%;
  height: 100%;
  border: none;
  display: block;
  background: #fff;
}
.pipeline-portal-frame.hidden { display: none; }

.pipeline-column-body.pipeline-drop-target {
  background: var(--crm-accent-soft);
  outline: 2px dashed var(--crm-accent);
  outline-offset: -4px;
}
.pipeline-card--dragging {
  opacity: .55;
  transform: rotate(2deg);
}
.pipeline-card[draggable="true"] { cursor: grab; }
.pipeline-card[draggable="true"]:active { cursor: grabbing; }

#lookup-modal .modal.modal--sale-edit {
  max-width: min(1040px, calc(100vw - 2rem));
  width: 100%;
  max-height: 92vh;
  display: flex;
  flex-direction: column;
}

#lookup-modal .modal.modal--sale-edit #lookup-modal-body {
  flex: 1;
  min-height: 0;
  padding: 0 1.35rem 1.35rem;
}

.pipeline-sale-edit-frame {
  width: 100%;
  height: min(78vh, 760px);
  min-height: 420px;
  border: 1px solid var(--crm-border);
  border-radius: 12px;
  background: #fff;
  display: block;
}

.pipeline-sale-edit-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .5rem;
  min-height: 200px;
  padding: 2rem;
}

@media (max-width: 1100px) {
  .pipeline-board { grid-template-columns: repeat(5, minmax(240px, 1fr)); }
}

/* ========== VENDAS PORTAL SHELL ========== */
.crm-app.crm-vendas {
  min-height: 100vh;
  background: var(--crm-page-bg);
}

.crm-vendas .crm-vendas-shell {
  display: flex;
  min-height: 100vh;
}

.crm-vendas .crm-v-sidebar {
  width: 220px;
  background: var(--crm-sidebar-bg);
  color: var(--crm-sidebar-text);
  padding: 1rem .75rem;
  display: none;
  flex-direction: column;
  gap: .5rem;
  position: fixed;
  left: 0;
  top: 0;
  bottom: 0;
  z-index: 40;
}

.crm-vendas .crm-v-main {
  flex: 1;
  min-width: 0;
  padding-bottom: 72px;
}

.crm-vendas .crm-v-nav-btn {
  display: flex;
  align-items: center;
  gap: .65rem;
  width: 100%;
  padding: .6rem .75rem;
  border: none;
  border-radius: 10px;
  background: transparent;
  color: var(--crm-sidebar-text);
  font-size: .85rem;
  font-weight: 500;
  cursor: pointer;
  text-align: left;
}

.crm-vendas .crm-v-nav-btn.active,
.crm-vendas .crm-v-nav-btn:hover {
  background: var(--crm-sidebar-hover);
  color: #fff;
}

.crm-vendas .crm-v-nav-btn.active {
  background: var(--crm-sidebar-active);
  box-shadow: inset 3px 0 0 var(--crm-accent);
}

.crm-vendas-bottomnav {
  display: flex;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--surface);
  border-top: 1px solid var(--crm-border);
  padding: .35rem .5rem calc(.35rem + env(safe-area-inset-bottom));
  z-index: 50;
  justify-content: space-around;
  box-shadow: 0 -4px 20px rgba(15, 23, 42, .06);
}

.crm-vendas-bottomnav button {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: .4rem;
  border: none;
  background: none;
  color: var(--gray-text);
  font-size: .65rem;
  font-weight: 600;
  cursor: pointer;
  border-radius: 8px;
}

.crm-vendas-bottomnav button.active {
  color: var(--crm-accent);
}

.crm-vendas-bottomnav .bn-icon {
  font-size: 1.25rem;
  line-height: 1;
}

/* Pipeline strip — Pipedrive-style */
.crm-pipeline-strip {
  display: flex;
  gap: 4px;
  margin-bottom: 1.25rem;
  overflow-x: auto;
  padding-bottom: 4px;
  scrollbar-width: none;
}

.crm-pipeline-strip::-webkit-scrollbar { display: none; }

.crm-pipeline-stage {
  flex: 1;
  min-width: 100px;
  text-align: center;
  padding: .5rem .35rem;
  border-radius: 8px;
  font-size: .68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--gray-text);
  background: var(--surface-2);
  border: 1px solid var(--crm-border);
  position: relative;
}

.crm-pipeline-stage::after {
  content: '';
  position: absolute;
  right: -6px;
  top: 50%;
  transform: translateY(-50%);
  border: 5px solid transparent;
  border-left-color: var(--crm-border);
}

.crm-pipeline-stage:last-child::after { display: none; }

.crm-pipeline-stage.is-active {
  background: var(--crm-accent-soft);
  border-color: #93c5fd;
  color: var(--crm-accent);
}

/* Sale cards — kanban feel */
.crm-vendas .sale-card {
  border-radius: 14px;
  border: 1px solid var(--crm-border);
  box-shadow: 0 1px 2px rgba(15, 23, 42, .04);
}

.crm-vendas .sale-card:hover {
  border-color: #93c5fd;
  box-shadow: 0 8px 24px rgba(37, 99, 235, .1);
  transform: translateY(-2px);
}

.crm-vendas .topbar {
  background: var(--surface) !important;
  color: var(--text) !important;
  border-bottom: 1px solid var(--crm-border);
  box-shadow: none !important;
  margin: 0 !important;
  padding: .85rem 1.25rem !important;
}

.crm-vendas .topbar-logo {
  filter: none !important;
  height: 38px !important;
}

.crm-vendas .topbar-title {
  color: var(--text) !important;
  font-size: 1rem !important;
  font-weight: 700 !important;
}

.crm-vendas .topbar .muted {
  color: var(--gray-text) !important;
}

.crm-vendas .topbar button.secondary {
  background: var(--surface-2) !important;
  color: var(--text) !important;
  border-color: var(--crm-border) !important;
}

.crm-vendas #login-view .card {
  box-shadow: 0 20px 50px rgba(15, 23, 42, .08);
  border: 1px solid var(--crm-border);
}

/* Command toolbar */
.crm-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .5rem;
  margin-bottom: 1rem;
  padding: .65rem .85rem;
  background: var(--surface);
  border: 1px solid var(--crm-border);
  border-radius: 12px;
}

@media (min-width: 1024px) {
  .crm-vendas .crm-v-sidebar { display: flex; }
  .crm-vendas .crm-v-main { margin-left: 220px; padding-bottom: 0; }
  .crm-vendas-bottomnav { display: none; }
}

/* ========== Menu superior sticky (preferência em Configurações) ========== */
html[data-nav-layout="top"] .crm-shell {
  flex-direction: column;
}

html[data-nav-layout="top"] .crm-sidebar {
  position: sticky;
  top: 0;
  left: 0;
  right: 0;
  bottom: auto;
  width: 100%;
  height: auto;
  max-height: none;
  flex-direction: row;
  align-items: stretch;
  flex-wrap: nowrap;
  border-right: none;
  border-bottom: 1px solid var(--crm-sidebar-border);
  transform: none !important;
  box-shadow: 0 4px 18px rgba(0, 0, 0, .14);
  z-index: 210;
}

html[data-nav-layout="top"] .crm-sidebar-brand {
  border-bottom: none;
  border-right: 1px solid var(--crm-sidebar-border);
  padding: .55rem 1rem;
  flex-shrink: 0;
}

html[data-nav-layout="top"] .crm-logo {
  height: 30px;
}

html[data-nav-layout="top"] .crm-nav {
  flex: 1;
  flex-direction: row;
  align-items: center;
  padding: .3rem .45rem;
  overflow: hidden;
  min-width: 0;
}

html[data-nav-layout="top"] .crm-nav-main {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: .1rem;
  overflow-x: auto;
  overflow-y: hidden;
  flex: 1;
  min-width: 0;
  scrollbar-width: thin;
}

html[data-nav-layout="top"] .crm-nav-group {
  display: flex;
  flex-direction: row;
  align-items: center;
  margin-bottom: 0;
  margin-right: .15rem;
  padding-right: .15rem;
  border-right: 1px solid rgba(255, 255, 255, .08);
  flex-shrink: 0;
}

html[data-nav-layout="top"] .crm-nav-group:last-of-type {
  border-right: none;
}

html[data-nav-layout="top"] .crm-nav-group-label {
  display: none;
}

html[data-nav-layout="top"] .crm-nav button,
html[data-nav-layout="top"] .crm-nav.tabs-nav-left button,
html[data-nav-layout="top"] .crm-sidebar-foot-btn {
  width: auto;
  padding: .42rem .62rem;
  font-size: .78rem;
}

html[data-nav-layout="top"] .crm-nav button.active::before,
html[data-nav-layout="top"] .crm-nav.tabs-nav-left button.active::before,
html[data-nav-layout="top"] .crm-sidebar-foot-btn.active::before {
  left: 50%;
  top: auto;
  bottom: 0;
  transform: translateX(-50%);
  width: 55%;
  height: 3px;
  border-radius: 4px 4px 0 0;
}

html[data-nav-layout="top"] .crm-nav-bottom {
  display: flex;
  flex-direction: row;
  align-items: center;
  padding: 0 .15rem;
  margin: 0;
  flex-shrink: 0;
}

html[data-nav-layout="top"] .crm-nav-operador {
  border-top: none;
  margin: 0;
}

html[data-nav-layout="top"] .crm-sidebar-foot {
  flex-direction: row;
  border-top: none;
  border-left: 1px solid rgba(255, 255, 255, .08);
  padding: .3rem .45rem;
  align-items: center;
  flex-shrink: 0;
}

html[data-nav-layout="top"] .crm-main {
  margin-left: 0;
}

html[data-nav-layout="top"] .crm-content::before {
  left: 0;
}

html[data-nav-layout="top"] .crm-menu-toggle {
  display: none !important;
}

html[data-nav-layout="top"] .crm-sidebar-backdrop {
  display: none !important;
}

@media (max-width: 1023px) {
  html[data-nav-layout="top"] .crm-nav-label {
    display: none;
  }

  html[data-nav-layout="top"] .crm-nav button,
  html[data-nav-layout="top"] .crm-nav.tabs-nav-left button,
  html[data-nav-layout="top"] .crm-sidebar-foot-btn {
    padding: .5rem .55rem;
  }
}

@media (max-width: 1023px) {
  .crm-sidebar {
    transform: translateX(-100%);
  }
  .crm-sidebar.is-open {
    transform: translateX(0);
    box-shadow: 8px 0 32px rgba(0, 0, 0, .25);
  }
  .crm-main {
    margin-left: 0;
  }
  .crm-menu-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }
  .crm-sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, .45);
    z-index: 199;
  }
  .crm-sidebar-backdrop.is-open { display: block; }
}
