@import url('https://fonts.googleapis.com/css2?family=Manrope:wght@500;600;700;800&display=swap');

:root {
  --background: 0 0% 100%;
  --foreground: 222 47% 11%;
  --card: 0 0% 100%;
  --card-foreground: 222 47% 11%;
  --primary: 222 89% 56%;
  --primary-foreground: 0 0% 100%;
  --secondary: 210 40% 96%;
  --secondary-foreground: 222 47% 11%;
  --muted: 210 40% 96%;
  --muted-foreground: 215 16% 47%;
  --border: 214 32% 91%;
  --input: 214 32% 91%;
  --ring: 222 89% 56%;
  --radius: 0.7rem;
  --chart-grid: rgba(15, 23, 42, 0.08);
  --chart-text: #475569;
}

:root[data-theme="dark"] {
  --background: 222 47% 7%;
  --foreground: 210 40% 98%;
  --card: 222 40% 11%;
  --card-foreground: 210 40% 98%;
  --primary: 217 91% 60%;
  --primary-foreground: 0 0% 100%;
  --secondary: 222 34% 17%;
  --secondary-foreground: 210 40% 98%;
  --muted: 223 27% 14%;
  --muted-foreground: 215 20% 65%;
  --border: 217 24% 24%;
  --input: 217 24% 24%;
  --ring: 217 91% 60%;
  --chart-grid: rgba(148, 163, 184, 0.17);
  --chart-text: #cbd5e1;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: hsl(var(--background));
  color: hsl(var(--foreground));
  font-family: 'Manrope', sans-serif;
}

.card {
  border: 1px solid hsl(var(--border));
  background: hsl(var(--card));
  color: hsl(var(--card-foreground));
  border-radius: var(--radius);
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.05);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: calc(var(--radius) - 2px);
  min-height: 38px;
  padding: 0 14px;
  border: 1px solid transparent;
  text-decoration: none;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.9rem;
  transition: all .15s ease;
}

.btn i { width: 16px; height: 16px; }

.btn-sm {
  min-height: 32px;
  padding: 0 10px;
  font-size: 0.82rem;
}

.btn-primary {
  background: hsl(var(--primary));
  color: hsl(var(--primary-foreground));
}

.btn-primary:hover { filter: brightness(1.04); }

.btn-secondary {
  background: hsl(var(--secondary));
  color: hsl(var(--secondary-foreground));
  border-color: hsl(var(--border));
}

.btn-outline {
  border-color: hsl(var(--border));
  color: hsl(var(--foreground));
  background: transparent;
}

.input,
.textarea {
  border: 1px solid hsl(var(--input));
  background: hsl(var(--background));
  color: hsl(var(--foreground));
  border-radius: calc(var(--radius) - 3px);
  min-height: 38px;
  padding: 8px 12px;
  width: 100%;
  outline: none;
  font-family: inherit;
}

.textarea {
  min-height: 120px;
  resize: vertical;
}

.input:focus,
.textarea:focus {
  border-color: hsl(var(--ring));
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field span,
.muted {
  color: hsl(var(--muted-foreground));
  font-size: .8rem;
  margin: 0;
}

.field-grow { flex: 1; }

/* App shell */
.erp-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 260px 1fr;
}

.erp-sidebar {
  border-right: 1px solid hsl(var(--border));
  background: hsl(var(--card));
  padding: 16px 14px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.erp-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 800;
  text-decoration: none;
  color: hsl(var(--foreground));
  padding: 10px 8px 14px;
  border-bottom: 1px solid hsl(var(--border));
  margin-bottom: 12px;
}

.erp-brand .brand-icon {
  width: 18px;
  height: 18px;
}

.erp-menu {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.menu-group {
  margin: 10px 8px 4px;
  color: hsl(var(--muted-foreground));
  text-transform: uppercase;
  font-size: .7rem;
  letter-spacing: .06em;
  font-weight: 700;
}

.menu-item {
  display: flex;
  align-items: center;
  gap: 9px;
  text-decoration: none;
  color: hsl(var(--foreground));
  border: 1px solid transparent;
  border-radius: calc(var(--radius) - 3px);
  padding: 9px 10px;
  font-size: .9rem;
}

.menu-item i { width: 16px; height: 16px; }

.menu-item:hover {
  background: hsl(var(--secondary));
}

.menu-item.is-active {
  background: hsl(var(--secondary));
  border-color: hsl(var(--border));
}

.menu-item.is-disabled {
  opacity: .55;
  pointer-events: none;
}

.erp-main {
  min-width: 0;
}

.erp-topbar {
  height: 68px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  border-bottom: 1px solid hsl(var(--border));
  background: hsl(var(--background));
}

.erp-topbar h1 {
  margin: 0;
  font-size: 1.25rem;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.topbar-user {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: .85rem;
  color: hsl(var(--muted-foreground));
  border: 1px solid hsl(var(--border));
  border-radius: 999px;
  padding: 7px 10px;
}

.topbar-user i { width: 14px; height: 14px; }

.erp-content {
  padding: 18px;
  display: grid;
  gap: 14px;
}

/* Dashboard */
.filters-card {
  padding: 14px;
}

.filters-row {
  display: flex;
  align-items: end;
  gap: 10px;
  flex-wrap: wrap;
}

.dashboard-export-area {
  display: grid;
  gap: 14px;
}

.pdf-avoid-break {
  break-inside: avoid;
  page-break-inside: avoid;
}

.pdf-export-mode .state-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 6px;
  align-items: start;
}

.pdf-export-mode .chart-card {
  break-inside: auto;
  page-break-inside: auto;
}

.pdf-export-mode #chartLeadsOrcamentos {
  height: 270px !important;
  max-height: 270px !important;
}

.pdf-export-mode .section-title {
  margin-top: 6px;
}

.ranking-card {
  padding: 14px;
}

.ranking-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 12px;
}

.ranking-head .section-title {
  margin: 0;
}

.ranking-periodo {
  margin: 0;
  color: hsl(var(--muted-foreground));
  font-size: .83rem;
}

.ranking-duplo-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.ranking-col {
  border: 1px solid hsl(var(--border));
  border-radius: calc(var(--radius) - 2px);
  padding: 10px;
  background: hsl(var(--background));
}

.ranking-col-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 10px;
}

.ranking-col-head h3 {
  margin: 0;
  font-size: .94rem;
}

.ranking-col-head span {
  color: hsl(var(--muted-foreground));
  font-size: .8rem;
}

.ranking-table {
  display: grid;
  gap: 8px;
}

.ranking-row {
  border: 1px solid hsl(var(--border));
  border-radius: 8px;
  padding: 8px;
  display: grid;
  gap: 6px;
  background: hsl(var(--card));
}

.ranking-meta {
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
}

.ranking-pos {
  color: hsl(var(--muted-foreground));
  font-weight: 700;
  font-size: .78rem;
}

.ranking-label {
  font-weight: 700;
  font-size: .84rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ranking-total {
  font-weight: 800;
  font-size: .84rem;
}

.ranking-bar-track {
  height: 8px;
  border-radius: 999px;
  background: hsl(var(--secondary));
  overflow: hidden;
}

.ranking-bar-fill {
  height: 100%;
  border-radius: 999px;
  background: hsl(var(--primary));
}

.ranking-row-outros .ranking-bar-fill {
  background: hsl(var(--muted-foreground));
}

.ranking-footnote {
  margin: 8px 2px 0;
  color: hsl(var(--muted-foreground));
  font-size: .76rem;
}

.pdf-export-mode .ranking-row {
  break-inside: avoid;
  page-break-inside: avoid;
}

.leads-summary-grid {
  padding: 12px;
  display: grid;
  grid-template-columns: repeat(5, minmax(190px, 1fr));
  gap: 10px;
}

.lead-priority-card {
  text-decoration: none;
  border: 1px solid hsl(var(--border));
  border-radius: calc(var(--radius) - 2px);
  background: hsl(var(--card));
  color: hsl(var(--foreground));
  padding: 12px;
  transition: .18s ease;
}

.lead-priority-card:hover {
  transform: translateY(-2px);
  border-color: hsl(var(--ring));
}

.lead-priority-card h2 {
  margin: 8px 0 6px;
  font-size: 1.65rem;
}

.lead-priority-card p {
  margin: 2px 0;
  font-size: .8rem;
  color: hsl(var(--muted-foreground));
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: .8rem;
  font-weight: 700;
}

.card-head i {
  width: 16px;
  height: 16px;
}

.priority-red { border-top: 3px solid #ef4444; }
.priority-orange { border-top: 3px solid #f97316; }
.priority-yellow { border-top: 3px solid #f59e0b; }
.priority-blue { border-top: 3px solid #3b82f6; }
.priority-green { border-top: 3px solid #22c55e; }

.leads-filter-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(160px, 1fr));
  gap: 10px;
}

.check-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.check-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid hsl(var(--border));
  background: hsl(var(--background));
  padding: 7px 10px;
  border-radius: 999px;
  font-size: .78rem;
  color: hsl(var(--foreground));
}

.check-chip input {
  margin: 0;
}

.leads-checkbox {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px dashed hsl(var(--border));
  border-radius: calc(var(--radius) - 3px);
  padding: 10px;
}

.leads-checkbox input {
  margin: 0;
}

.filters-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.chips {
  margin-top: 10px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.chip {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  border: 1px solid hsl(var(--border));
  color: hsl(var(--muted-foreground));
  text-decoration: none;
  font-size: .78rem;
  padding: 6px 10px;
}

.chip-active {
  background: hsl(var(--secondary));
  color: hsl(var(--foreground));
  border-color: hsl(var(--ring));
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(180px, 1fr));
  gap: 10px;
}

.kpi {
  padding: 14px;
}

.kpi h3 {
  margin: 7px 0 0;
  font-size: 2rem;
  line-height: 1;
}

.chart-card {
  padding: 14px;
}

.chart-card h2,
.section-title,
.card h2 {
  margin: 0 0 10px;
  font-size: 1.15rem;
  font-weight: 700;
}

canvas { width: 100% !important; max-height: 360px; }

.funnel-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(140px, 1fr));
  gap: 12px;
  padding-top: 6px;
}

.dash-funnel-grid {
  display: grid;
  width: 100%;
  padding: 0;
  grid-template-columns: repeat(4, minmax(220px, 1fr));
  gap: 14px;
}

.funnel-section {
  padding: 16px;
}

.funnel-section h2 {
  margin: 0 0 14px;
}

.dash-funnel-card h2 {
  margin: 7px 0 4px;
  font-size: 1.55rem;
}

.dash-funnel-card p {
  margin: 0;
  font-size: .86rem;
  color: hsl(var(--muted-foreground));
}

.funnel-timeline {
  position: relative;
  padding-top: 18px;
}

.funnel-timeline::before {
  content: none;
  position: absolute;
  left: 8%;
  right: 8%;
  top: 54px;
  border-top: 2px solid hsl(var(--border));
}

.funnel-item {
  border: 1px dashed hsl(var(--border));
  border-radius: calc(var(--radius) - 2px);
  padding: 14px;
  text-align: center;
  background: hsl(var(--muted));
  position: relative;
  z-index: 1;
}

.dot {
  width: 52px;
  height: 52px;
  margin: 0 auto 8px;
  border-radius: 999px;
  color: #fff;
  font-weight: 800;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.dot-0 { background: #0f172a; }
.dot-1 { background: #2563eb; }
.dot-2 { background: #f59e0b; }
.dot-3 { background: #16a34a; }

.funnel-item p { margin: 0; font-weight: 600; }
.funnel-item strong { font-size: .98rem; }

.funnel-icon {
  width: 16px;
  height: 16px;
  color: hsl(var(--muted-foreground));
  margin-bottom: 8px;
}

.funnel-meta {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin-top: 16px;
  flex-wrap: wrap;
}

.meta-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid hsl(var(--border));
  background: hsl(var(--secondary));
  border-radius: 999px;
  padding: 8px 12px;
  font-size: .86rem;
  font-weight: 600;
}

.meta-chip i {
  width: 15px;
  height: 15px;
}

.meta-loss {
  color: #b91c1c;
}

.meta-disq {
  color: hsl(var(--muted-foreground));
}

.state-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(130px, 1fr));
  gap: 10px;
}

.state-card { padding: 12px; }

.state-card h3 {
  margin: 6px 0 0;
  font-size: 1.85rem;
}

.state-percent {
  margin: 2px 0 8px;
  font-size: 0.82rem;
  font-weight: 700;
  color: hsl(var(--muted-foreground));
}

.city-list {
  margin: 0;
  padding-left: 14px;
  font-size: 0.8rem;
  line-height: 1.45;
}

/* Leads table */
.table-card {
  padding: 0;
  overflow: hidden;
}

.table-wrap {
  overflow: auto;
}

.erp-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 780px;
}

.erp-table th,
.erp-table td {
  padding: 12px;
  border-bottom: 1px solid hsl(var(--border));
  text-align: left;
  vertical-align: middle;
}

.erp-table th {
  font-size: .78rem;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: hsl(var(--muted-foreground));
}

.erp-table tbody tr:hover {
  background: hsl(var(--muted));
}

.lead-badge {
  display: inline-flex;
  align-items: center;
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 5px 9px;
  font-size: .74rem;
  font-weight: 700;
}

.status-warning { background: rgba(245, 158, 11, .16); border-color: rgba(245, 158, 11, .35); color: #b45309; }
.status-info { background: rgba(59, 130, 246, .16); border-color: rgba(59, 130, 246, .35); color: #1d4ed8; }
.status-quote { background: rgba(249, 115, 22, .14); border-color: rgba(249, 115, 22, .32); color: #c2410c; }
.status-prospect { background: rgba(14, 165, 233, .15); border-color: rgba(14, 165, 233, .32); color: #0369a1; }
.status-success { background: rgba(34, 197, 94, .15); border-color: rgba(34, 197, 94, .35); color: #15803d; }
.status-danger { background: rgba(239, 68, 68, .15); border-color: rgba(239, 68, 68, .35); color: #b91c1c; }
.status-muted { background: hsl(var(--secondary)); border-color: hsl(var(--border)); color: hsl(var(--muted-foreground)); }

.temp-hot { background: rgba(239, 68, 68, .15); border-color: rgba(239, 68, 68, .35); color: #b91c1c; }
.temp-warm { background: rgba(245, 158, 11, .15); border-color: rgba(245, 158, 11, .35); color: #b45309; }
.temp-cold { background: rgba(59, 130, 246, .15); border-color: rgba(59, 130, 246, .35); color: #1e40af; }
.temp-muted { background: hsl(var(--secondary)); border-color: hsl(var(--border)); color: hsl(var(--muted-foreground)); }

.sched-overdue { background: rgba(239, 68, 68, .18); border-color: rgba(239, 68, 68, .4); color: #b91c1c; }
.sched-today { background: rgba(245, 158, 11, .18); border-color: rgba(245, 158, 11, .4); color: #b45309; }
.sched-future { background: rgba(59, 130, 246, .18); border-color: rgba(59, 130, 246, .4); color: #1e40af; }

.table-pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px;
  border-top: 1px solid hsl(var(--border));
}

.pagination-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.pagination-info {
  font-size: .82rem;
  color: hsl(var(--muted-foreground));
}

/* Edit lead */
.edit-card {
  padding: 14px;
}

.edit-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}

.edit-header h2 {
  margin: 0;
}

.alert {
  border-radius: calc(var(--radius) - 3px);
  padding: 10px 12px;
  margin: 0 0 10px;
  font-weight: 600;
  font-size: .88rem;
}

.alert.success {
  border: 1px solid #86efac;
  background: #f0fdf4;
  color: #166534;
}

.alert.danger {
  border: 1px solid #fda4af;
  background: #fff1f2;
  color: #be123c;
}

:root[data-theme="dark"] .alert.success {
  background: rgba(22, 101, 52, .2);
  border-color: rgba(74, 222, 128, .35);
  color: #bbf7d0;
}

:root[data-theme="dark"] .alert.danger {
  background: rgba(190, 24, 93, 0.15);
  border-color: rgba(244, 114, 182, 0.35);
  color: #f9a8d4;
}

.edit-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(220px, 1fr));
  gap: 10px;
}

.field-full {
  grid-column: 1 / -1;
}

.form-actions {
  display: flex;
  justify-content: flex-end;
}

.lead-analysis-card {
  margin-top: 12px;
}

.analysis-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid hsl(var(--border));
  background: hsl(var(--muted));
  border-radius: 999px;
  padding: 6px 10px;
  font-size: .78rem;
  font-weight: 600;
  color: hsl(var(--muted-foreground));
}

.analysis-layout {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 12px;
}

.analysis-list {
  border: 1px solid hsl(var(--border));
  border-radius: calc(var(--radius) - 2px);
  background: hsl(var(--card));
  max-height: 72vh;
  overflow: auto;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}


.analysis-item {
  width: 100%;
  text-align: left;
  border: 1px solid hsl(var(--border));
  border-radius: calc(var(--radius) - 4px);
  background: hsl(var(--background));
  padding: 10px;
  cursor: pointer;
  transition: .2s ease;
}

.analysis-item:hover {
  border-color: hsl(var(--ring));
}

.analysis-item.is-active {
  border-color: hsl(var(--ring));
  background: hsl(var(--muted));
  box-shadow: 0 0 0 1px hsl(var(--ring) / .2);
}

.analysis-item-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
  font-size: .82rem;
}

.analysis-item-top span {
  color: hsl(var(--muted-foreground));
}

.analysis-item-meta {
  display: flex;
  gap: 8px;
  margin-bottom: 6px;
  font-size: .78rem;
  color: hsl(var(--muted-foreground));
}

.analysis-item p {
  margin: 0;
  font-size: .8rem;
  color: hsl(var(--foreground));
}

.analysis-detail {
  border: 1px solid hsl(var(--border));
  border-radius: calc(var(--radius) - 2px);
  background: hsl(var(--card));
  padding: 12px;
}

.analysis-detail-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}

.analysis-detail-head h3 {
  margin: 0;
}

.analysis-detail-head .muted {
  margin: 2px 0 0;
}

.analysis-kpis {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.analysis-pill {
  border: 1px solid hsl(var(--border));
  border-radius: 999px;
  padding: 5px 10px;
  font-size: .78rem;
  font-weight: 600;
}

.analysis-detail-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(180px, 1fr));
  gap: 10px;
}

.analysis-detail-card {
  border: 1px solid hsl(var(--border));
  border-radius: calc(var(--radius) - 4px);
  background: hsl(var(--background));
  padding: 10px;
  margin-bottom: 10px;
}

.analysis-detail-card h4 {
  margin: 0 0 6px;
  font-size: .84rem;
}

.analysis-detail-card p {
  margin: 0;
  font-size: .84rem;
  line-height: 1.45;
}

.analysis-collapsible {
  border: 1px solid hsl(var(--border));
  border-radius: calc(var(--radius) - 4px);
  background: hsl(var(--background));
  padding: 10px;
  margin-top: 10px;
}

.analysis-collapsible summary {
  cursor: pointer;
  font-size: .84rem;
  font-weight: 600;
}

.analysis-collapsible pre {
  margin: 10px 0 0;
  white-space: pre-wrap;
  font-size: .78rem;
  line-height: 1.45;
}

.analysis-empty {
  border: 1px dashed hsl(var(--border));
  border-radius: calc(var(--radius) - 4px);
  padding: 18px;
  color: hsl(var(--muted-foreground));
  display: flex;
  align-items: center;
  gap: 8px;
}

@media (max-width: 1024px) {
  .leads-summary-grid {
    grid-template-columns: repeat(2, minmax(180px, 1fr));
  }

  .leads-filter-grid {
    grid-template-columns: repeat(2, minmax(160px, 1fr));
  }

  .analysis-layout {
    grid-template-columns: 1fr;
  }

  .analysis-list {
    max-height: 280px;
  }
}

@media (max-width: 760px) {
  .leads-summary-grid {
    grid-template-columns: 1fr;
  }

  .leads-filter-grid {
    grid-template-columns: 1fr;
  }

  .table-pagination {
    flex-direction: column;
    align-items: flex-start;
  }

  .analysis-detail-grid {
    grid-template-columns: 1fr;
  }
}

/* Auth */
.auth-body {
  margin: 0;
  min-height: 100vh;
  background: hsl(var(--background));
  color: hsl(var(--foreground));
  font-family: 'Manrope', sans-serif;
}

.auth-shell {
  min-height: 100vh;
  padding: 12px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
}

.auth-left,
.auth-right {
  border: 1px solid hsl(var(--border));
  background: hsl(var(--card));
}

.auth-left {
  border-right: none;
  border-radius: 14px 0 0 14px;
  background: hsl(var(--muted));
  position: relative;
}

.auth-right {
  border-left: 1px solid hsl(var(--border));
  border-radius: 0 14px 14px 0;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

.auth-brand {
  position: absolute;
  top: 38px;
  left: 38px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 1.9rem;
  font-weight: 700;
}

.auth-logo {
  font-size: 2.4rem;
  line-height: 1;
}

.auth-top-link {
  position: absolute;
  top: 38px;
  right: 48px;
  font-size: 2rem;
  font-weight: 700;
}

.auth-card {
  width: min(520px, 88%);
}

.auth-card h1 {
  text-align: center;
  margin: 0;
  font-size: 2.6rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.auth-card p {
  text-align: center;
  color: hsl(var(--muted-foreground));
  margin: 10px 0 20px;
  font-size: 1.15rem;
}

.auth-error {
  border: 1px solid #fda4af;
  background: #fff1f2;
  color: #be123c;
  border-radius: 10px;
  padding: 10px 12px;
  margin-bottom: 12px;
  font-weight: 600;
}

:root[data-theme="dark"] .auth-error {
  background: rgba(190, 24, 93, 0.12);
  color: #fda4af;
  border-color: rgba(244, 114, 182, 0.4);
}

.auth-form {
  display: grid;
  gap: 10px;
}

.auth-form label {
  font-size: .95rem;
  color: hsl(var(--muted-foreground));
}

.auth-form input {
  width: 100%;
  border: 1px solid hsl(var(--input));
  background: hsl(var(--background));
  color: hsl(var(--foreground));
  border-radius: 10px;
  padding: 12px 14px;
  font-size: 1rem;
  outline: none;
}

.auth-form input:focus {
  border-color: hsl(var(--ring));
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.22);
}

.auth-form button {
  margin-top: 8px;
  width: 100%;
  border: 0;
  border-radius: 10px;
  padding: 12px 14px;
  background: #111317;
  color: #ffffff;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
}

.auth-divider {
  margin: 18px 0 10px;
  display: flex;
  align-items: center;
  gap: 10px;
  color: hsl(var(--muted-foreground));
  font-size: .92rem;
}

.auth-divider::before,
.auth-divider::after {
  content: "";
  flex: 1;
  border-top: 1px solid hsl(var(--border));
}

.auth-terms {
  margin-top: 8px;
  font-size: .92rem;
}

.table-actions-inline {
  display: flex;
  align-items: center;
  gap: 8px;
}

.ai-top-card {
  padding: 14px;
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: flex-start;
}

.ai-top-left h2 {
  margin: 0 0 8px;
  font-size: 1.15rem;
}

.ai-top-left p {
  margin: 0 0 6px;
  color: hsl(var(--muted-foreground));
  font-size: 0.9rem;
}

.ai-top-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.sep-dot {
  margin: 0 8px;
}

.ai-workspace-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 14px;
}

.ai-chat-card {
  padding: 14px;
  display: grid;
  gap: 12px;
}

.ai-chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.ai-chat-header h3 {
  margin: 0;
  font-size: 1rem;
}

.ai-chat-header p {
  margin: 0;
}

.ai-chat-messages {
  border: 1px solid hsl(var(--border));
  border-radius: calc(var(--radius) - 2px);
  background: hsl(var(--background));
  min-height: 420px;
  max-height: 520px;
  overflow-y: auto;
  padding: 12px;
  display: grid;
  gap: 10px;
}

.ai-chat-empty {
  color: hsl(var(--muted-foreground));
  text-align: center;
  padding: 28px 10px;
}

.msg-row {
  display: flex;
}

.msg-row.is-client {
  justify-content: flex-start;
}

.msg-row.is-seller {
  justify-content: flex-end;
}

.msg-bubble {
  max-width: min(74%, 640px);
  border: 1px solid hsl(var(--border));
  border-radius: 14px;
  padding: 10px 12px 8px;
  background: hsl(var(--card));
}

.msg-row.is-client .msg-bubble {
  border-top-left-radius: 8px;
}

.msg-row.is-seller .msg-bubble {
  border-top-right-radius: 8px;
  background: rgba(59, 130, 246, 0.12);
  border-color: rgba(59, 130, 246, 0.35);
}

.msg-bubble p {
  margin: 0 0 7px;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: .92rem;
}

.msg-bubble time {
  display: block;
  text-align: right;
  font-size: .75rem;
  color: hsl(var(--muted-foreground));
}

.ai-suggestions-wrap {
  border: 1px solid hsl(var(--border));
  border-radius: calc(var(--radius) - 2px);
  padding: 10px;
  display: grid;
  gap: 9px;
}

.ai-suggestions-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.ai-suggestions-head h4 {
  margin: 0;
  font-size: .95rem;
}

.ai-suggestions-list {
  display: grid;
  gap: 8px;
}

.ai-suggestion-item {
  border: 1px solid hsl(var(--border));
  border-radius: calc(var(--radius) - 4px);
  padding: 10px;
  display: grid;
  gap: 8px;
}

.ai-suggestion-item p {
  margin: 0;
  font-size: .88rem;
  white-space: pre-wrap;
  word-break: break-word;
}

.ai-composer {
  display: grid;
  gap: 10px;
}

.ai-composer .textarea {
  min-height: 105px;
}

.ai-composer-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

.ai-checklist-card {
  padding: 14px;
  display: grid;
  gap: 10px;
  align-content: start;
}

.ai-checklist-box {
  display: grid;
  gap: 12px;
}

.ai-check-block {
  border: 1px solid hsl(var(--border));
  border-radius: calc(var(--radius) - 2px);
  padding: 10px;
}

.ai-check-block h4 {
  margin: 0 0 8px;
  font-size: .9rem;
}

.ai-check-block ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 7px;
}

.ai-check-block li {
  display: flex;
  align-items: center;
  gap: 8px;
  color: hsl(var(--muted-foreground));
}

.ai-check-block li i {
  width: 16px;
  height: 16px;
}

.ai-check-block li.is-checked {
  color: hsl(var(--foreground));
  font-weight: 600;
}

.ai-toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 99;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid hsl(var(--border));
  background: hsl(var(--card));
  color: hsl(var(--foreground));
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
  transform: translateY(12px);
  opacity: 0;
  transition: .18s ease;
}

.ai-toast.is-visible {
  transform: translateY(0);
  opacity: 1;
}

.kanban-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 0;
  border: 1px solid hsl(var(--border));
  border-radius: 10px;
  overflow: hidden;
  background: hsl(var(--card));
}

.kanban-column {
  padding: 8px 10px;
  min-height: 74vh;
}

.kanban-column + .kanban-column {
  border-left: 1px solid hsl(var(--border));
}

.kanban-column-head {
  display: grid;
  gap: 8px;
  margin-bottom: 8px;
  border-bottom: 1px solid hsl(var(--border));
  padding-bottom: 8px;
}

.kanban-column-head h2 {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0;
  font-size: .8rem;
  text-transform: uppercase;
  letter-spacing: .03em;
  font-weight: 800;
}

.kanban-column-head h2 span,
.kanban-column-head h2 strong {
  color: hsl(var(--muted-foreground));
}

.kanban-column-head h2 i {
  width: 15px;
  height: 15px;
}

.kanban-column-head h2.title-blue { color: #2563eb; }
.kanban-column-head h2.title-orange { color: #ea580c; }
.kanban-column-head h2.title-green { color: #16a34a; }
.kanban-column-head h2.title-violet { color: #7c3aed; }
.kanban-column-head h2.title-gray { color: hsl(var(--foreground)); }

.kanban-search-box {
  display: flex;
  gap: 8px;
}

.kanban-cards {
  display: grid;
  gap: 8px;
  align-content: start;
}

.kanban-card {
  border: 1px solid hsl(var(--border));
  border-radius: 8px;
  padding: 8px;
  background: #f7f7f7;
  border-top-width: 3px;
  color: #0f172a;
}

:root[data-theme="dark"] .kanban-card {
  background: #0f172a;
  border-color: #334155;
  color: #e2e8f0;
}

.kanban-card-clickable {
  cursor: pointer;
}

.kanban-card-clickable:hover {
  box-shadow: 0 0 0 1px rgba(30, 41, 59, 0.2);
}

.kanban-card-top {
  display: flex;
  justify-content: space-between;
  margin-bottom: 6px;
}

.kanban-card-title-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.lead-name-wrap {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.lead-name-wrap i {
  width: 14px;
  height: 14px;
  color: #334155;
  flex: 0 0 auto;
}

:root[data-theme="dark"] .lead-name-wrap i {
  color: #cbd5e1;
}

.kanban-status {
  display: inline-flex;
  align-items: center;
  font-size: .62rem;
  font-weight: 700;
  border-radius: 999px;
  padding: 2px 8px;
  border: 1px solid transparent;
}

.kanban-badge-blue {
  color: #1d4ed8;
  background: rgba(59, 130, 246, 0.12);
  border-color: rgba(59, 130, 246, 0.35);
}

.kanban-badge-violet {
  color: #6d28d9;
  background: rgba(124, 58, 237, 0.14);
  border-color: rgba(124, 58, 237, 0.35);
}

.kanban-badge-orange {
  color: #c2410c;
  background: rgba(249, 115, 22, 0.14);
  border-color: rgba(249, 115, 22, 0.35);
}

.kanban-badge-green {
  color: #15803d;
  background: rgba(34, 197, 94, 0.14);
  border-color: rgba(34, 197, 94, 0.35);
}

.kanban-badge-gray {
  color: hsl(var(--muted-foreground));
  background: hsl(var(--muted));
  border-color: hsl(var(--border));
}

.kanban-card h3 {
  margin: 0 0 6px;
  font-size: .88rem;
  color: #0f172a;
}

:root[data-theme="dark"] .kanban-card h3 {
  color: #f8fafc;
}

.kanban-card .lead-name {
  margin: 0;
  text-transform: uppercase;
  letter-spacing: .01em;
}

.kanban-card p {
  margin: 0 0 3px;
  font-size: .76rem;
  color: #475569;
}

:root[data-theme="dark"] .kanban-card p {
  color: #cbd5e1;
}

.kanban-card strong {
  color: #0f172a;
}

:root[data-theme="dark"] .kanban-card strong {
  color: #f8fafc;
}

.kanban-card-actions {
  margin-top: 7px;
}

.kanban-card-actions .btn {
  min-height: 28px;
  padding: 0 10px;
  font-size: .75rem;
  color: #0f172a;
  border-color: #94a3b8;
  background: rgba(255, 255, 255, 0.48);
}

.kanban-empty {
  border: 1px dashed hsl(var(--border));
  border-radius: calc(var(--radius) - 2px);
  padding: 10px;
  color: hsl(var(--muted-foreground));
  font-size: .8rem;
  text-align: center;
}

.kanban-card.is-hidden {
  display: none;
}

.kanban-card.card-blue { border-top-color: #2563eb; }
.kanban-card.card-violet { border-top-color: #7c3aed; }
.kanban-card.card-orange { border-top-color: #ea580c; }
.kanban-card.card-green { border-top-color: #16a34a; }
.kanban-card.card-gray { border-top-color: #64748b; }

.kanban-card-tags {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 6px;
  flex-wrap: wrap;
}

.lead-tag {
  display: inline-flex;
  align-items: center;
  font-size: .62rem;
  font-weight: 700;
  border-radius: 999px;
  padding: 2px 7px;
  border: 1px solid transparent;
  text-transform: uppercase;
}

.lead-tag.tag-product {
  color: #0f172a;
  background: #f8fafc;
  border-color: #94a3b8;
}

:root[data-theme="dark"] .lead-tag.tag-product {
  color: #e2e8f0;
  background: #1e293b;
  border-color: #475569;
}

.lead-tag.tag-danger {
  color: #dc2626;
  background: rgba(239, 68, 68, 0.14);
  border-color: rgba(239, 68, 68, 0.35);
}

.lead-tag.tag-success {
  color: #15803d;
  background: rgba(34, 197, 94, 0.14);
  border-color: rgba(34, 197, 94, 0.35);
}

.lead-tag.tag-neutral {
  color: #475569;
  background: rgba(100, 116, 139, 0.14);
  border-color: rgba(100, 116, 139, 0.35);
}

.kanban-see-more {
  width: 100%;
}

.kanban-contact-actions {
  margin-top: 8px;
  display: grid;
  gap: 6px;
}

.kanban-contact-actions .btn {
  justify-content: center;
  width: 100%;
  min-height: 34px;
  border-radius: 9px;
  font-size: .76rem;
  font-weight: 700;
}

.btn-contact-action i {
  width: 14px;
  height: 14px;
}

.btn-contact-action.btn-clear-radar {
  border-color: #cbd5e1;
  color: #0f172a;
  background: #ffffff;
}

.btn-contact-action.btn-clear-radar:hover {
  background: #f1f5f9;
  border-color: #94a3b8;
}

:root[data-theme="dark"] .btn-contact-action.btn-clear-radar {
  border-color: #475569;
  color: #e2e8f0;
  background: #1e293b;
}

:root[data-theme="dark"] .btn-contact-action.btn-clear-radar:hover {
  background: #334155;
  border-color: #64748b;
}

.btn-contact-action.btn-promote {
  background: #2563eb;
  border-color: #2563eb;
  color: #ffffff;
}

.btn-contact-action.btn-promote:hover {
  background: #1d4ed8;
  border-color: #1d4ed8;
}

.btn-contact-action.btn-keep-contact {
  background: #fff7ed;
  border-color: #fdba74;
  color: #9a3412;
}

.btn-contact-action.btn-keep-contact:hover {
  background: #ffedd5;
  border-color: #fb923c;
}

:root[data-theme="dark"] .btn-contact-action.btn-keep-contact {
  background: rgba(154, 52, 18, 0.16);
  border-color: rgba(249, 115, 22, 0.45);
  color: #fdba74;
}

:root[data-theme="dark"] .btn-contact-action.btn-keep-contact:hover {
  background: rgba(154, 52, 18, 0.24);
  border-color: rgba(249, 115, 22, 0.65);
}

.lead-detail-card,
.lead-history-card {
  padding: 12px;
}

.lead-detail-form,
.lead-history-card {
  display: grid;
  gap: 12px;
}

.lead-detail-top {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
}

.lead-detail-top h2 {
  margin: 0;
  font-size: 1rem;
}

.lead-phone-link {
  color: hsl(var(--primary));
  text-decoration: none;
  font-weight: 700;
  font-size: .88rem;
}

.lead-detail-top-right {
  display: grid;
  grid-template-columns: repeat(2, minmax(160px, 1fr));
  gap: 10px;
}

.lead-title-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.detail-block {
  border: 1px solid hsl(var(--border));
  border-radius: calc(var(--radius) - 2px);
  padding: 10px;
}

.detail-block h3,
.lead-history-card h3 {
  margin: 0 0 10px;
  font-size: .9rem;
}

.detail-grid {
  display: grid;
  gap: 10px;
}

.detail-grid.cols-3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.field-wide {
  grid-column: span 2;
}

.detail-actions-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.detail-actions-row .btn {
  min-width: 110px;
}

.compact-table td,
.compact-table th {
  font-size: .82rem;
}

.history-form .textarea {
  min-height: 44px;
}

.history-action {
  display: flex;
  align-items: flex-end;
}

.leads-screen {
  background: hsl(var(--card));
}

/* Lead Detail (Open Lead) */
.lead-open-shell {
  padding: 14px;
  display: grid;
  gap: 12px;
}

.lead-open-topbar {
  position: sticky;
  top: 10px;
  z-index: 7;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  border: 1px solid hsl(var(--border));
  border-radius: calc(var(--radius) - 2px);
  padding: 10px;
  background: hsl(var(--card));
}

.lead-open-title-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
}

.lead-open-title-wrap h2 {
  margin: 0;
  font-size: 1.5rem;
}

.lead-open-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.lead-open-section {
  border: 1px solid hsl(var(--border));
  border-radius: calc(var(--radius) - 2px);
  padding: 12px;
}

.lead-open-section h3 {
  margin: 0;
  font-size: 1rem;
}

.lead-open-section-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}

.lead-open-edit-state {
  font-size: .8rem;
  color: hsl(var(--muted-foreground));
  font-weight: 700;
}

.lead-open-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.lead-open-field {
  display: grid;
  gap: 6px;
}

.lead-open-field .label {
  font-size: .72rem;
  font-weight: 800;
  color: hsl(var(--muted-foreground));
  text-transform: uppercase;
  letter-spacing: .04em;
}

.lead-open-read {
  margin: 0;
  min-height: 24px;
  display: flex;
  align-items: center;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  font-size: .92rem;
  font-weight: 600;
}

.lead-open-quick-form {
  margin-top: 10px;
  display: grid;
  grid-template-columns: 240px 1fr auto;
  gap: 10px;
}

.lead-open-quick-action {
  display: flex;
  align-items: flex-end;
}

.lead-open-timeline .history-timeline {
  margin-top: 10px;
}

.lead-conversation-modal {
  --chat-overlay: rgba(15, 23, 42, .45);
  --chat-dialog-bg: #f0f2f5;
  --chat-dialog-border: rgba(15, 23, 42, .14);
  --chat-header-bg: #f0f2f5;
  --chat-header-title: #111b21;
  --chat-header-subtitle: #54656f;
  --chat-list-bg: #e5ddd5;
  --chat-bubble-in-bg: #ffffff;
  --chat-bubble-in-text: #111b21;
  --chat-bubble-out-bg: #d9fdd3;
  --chat-bubble-out-text: #111b21;
  --chat-bubble-time: #667781;
  --chat-separator-bg: rgba(17, 27, 33, .75);
  --chat-separator-text: #eef4f7;
  position: fixed;
  inset: 0;
  background: var(--chat-overlay);
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
}

:root[data-theme="dark"] .lead-conversation-modal {
  --chat-overlay: rgba(7, 15, 26, .84);
  --chat-dialog-bg: #0b141a;
  --chat-dialog-border: rgba(255, 255, 255, .08);
  --chat-header-bg: #202c33;
  --chat-header-title: #e9edef;
  --chat-header-subtitle: #8696a0;
  --chat-list-bg: #0b141a;
  --chat-bubble-in-bg: #202c33;
  --chat-bubble-in-text: #e9edef;
  --chat-bubble-out-bg: #005c4b;
  --chat-bubble-out-text: #e9edef;
  --chat-bubble-time: #9fb0ba;
  --chat-separator-bg: rgba(17, 27, 33, .92);
  --chat-separator-text: #d1d7db;
}

.lead-conversation-dialog {
  width: min(88vw, 1320px);
  max-height: 86vh;
  overflow: hidden;
  border: 1px solid var(--chat-dialog-border);
  border-radius: 10px;
  background: var(--chat-dialog-bg);
  display: grid;
  grid-template-rows: auto auto 1fr;
  box-shadow: 0 22px 48px rgba(0, 0, 0, .45);
}

.lead-conversation-header,
.lead-conversation-tools {
  padding: 10px 12px;
  border-bottom: 1px solid var(--chat-dialog-border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  background: var(--chat-header-bg);
}

.lead-conversation-header h3 {
  margin: 0;
  color: var(--chat-header-title);
}

.lead-conversation-header p {
  margin: 2px 0 0;
  color: var(--chat-header-subtitle);
}

.lead-conversation-list {
  padding: 12px;
  overflow: auto;
  display: grid;
  gap: 6px;
  align-content: start;
  background-color: var(--chat-list-bg);
}

.lead-chat-item {
  display: flex;
  width: 100%;
}

.lead-chat-item.in {
  justify-content: flex-start;
}

.lead-chat-item.out {
  justify-content: flex-end;
}

.lead-chat-bubble {
  max-width: min(68%, 820px);
  border: 0;
  border-radius: 7.5px;
  padding: 6px 8px 4px;
  position: relative;
  box-shadow: 0 1px .5px rgba(11, 20, 26, .34);
  font-family: "Segoe UI", system-ui, sans-serif;
}

.lead-chat-item.in .lead-chat-bubble {
  background: var(--chat-bubble-in-bg);
  color: var(--chat-bubble-in-text);
}

.lead-chat-item.out .lead-chat-bubble {
  background: var(--chat-bubble-out-bg);
  color: var(--chat-bubble-out-text);
}

.lead-chat-item.in .lead-chat-bubble::before,
.lead-chat-item.out .lead-chat-bubble::before {
  content: "";
  position: absolute;
  top: 0;
  width: 0;
  height: 0;
  border-top: 7px solid transparent;
}

.lead-chat-item.in .lead-chat-bubble::before {
  left: -6px;
  border-right: 7px solid var(--chat-bubble-in-bg);
}

.lead-chat-item.out .lead-chat-bubble::before {
  right: -6px;
  border-left: 7px solid var(--chat-bubble-out-bg);
}

.lead-chat-bubble p {
  margin: 0;
  font-size: .93rem;
  line-height: 1.38;
  white-space: pre-line;
  word-break: break-word;
}

.lead-chat-meta {
  display: flex;
  margin-top: 6px;
}

.lead-chat-item.in .lead-chat-meta {
  justify-content: flex-start;
}

.lead-chat-item.out .lead-chat-meta {
  justify-content: flex-end;
}

.lead-chat-time {
  display: inline-block;
  font-size: .7rem;
  font-weight: 600;
  color: var(--chat-bubble-time);
  line-height: 1;
  white-space: nowrap;
  opacity: .96;
}

.lead-chat-image {
  max-width: 340px;
  border-radius: 6px;
  display: block;
  margin-bottom: 6px;
}

.lead-chat-day-separator {
  display: flex;
  justify-content: center;
  margin: 6px 0;
}

.lead-chat-day-separator span {
  background: var(--chat-separator-bg);
  color: var(--chat-separator-text);
  font-size: .74rem;
  font-weight: 700;
  border-radius: 8px;
  padding: 5px 12px;
}

.lead-open-save-btn.is-hidden,
.is-hidden {
  display: none !important;
}

.lead-cep-feedback {
  min-height: 16px;
}

.status-contact {
  color: #6d28d9;
  border-color: rgba(109, 40, 217, .35);
  background: rgba(109, 40, 217, .11);
}

/* Lead Journey UX Refactor */
.lead-journey-shell,
.lead-end-shell {
  padding: 14px;
}

.lead-journey-form {
  display: grid;
  gap: 14px;
}

.lead-save-sticky {
  position: sticky;
  top: 10px;
  z-index: 8;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: hsl(var(--card));
  border: 1px solid hsl(var(--border));
  border-radius: calc(var(--radius) - 2px);
  padding: 10px 12px;
}

.lead-save-status {
  font-size: .82rem;
  color: hsl(var(--muted-foreground));
  font-weight: 700;
}

.lead-save-status.is-dirty {
  color: #b45309;
}

.lead-start-grid {
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: 12px;
}

.lead-context-card,
.lead-next-action {
  padding: 12px;
}

.lead-context-head {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: flex-start;
}

.lead-context-head h2 {
  margin: 0;
  font-size: 1.3rem;
  font-weight: 800;
}

.lead-context-head .strong {
  font-weight: 700;
}

.lead-context-meta {
  margin-top: 12px;
  display: grid;
  gap: 8px;
}

.lead-context-meta p {
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: .9rem;
}

.lead-context-meta p strong {
  font-size: .78rem;
  color: hsl(var(--muted-foreground));
  text-transform: uppercase;
  letter-spacing: .04em;
}

.lead-next-action header {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: baseline;
  margin-bottom: 10px;
}

.lead-next-action h3 {
  margin: 0;
  font-size: 1rem;
}

.lead-next-action-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.next-action-hint {
  margin: 10px 0 0;
  font-size: .82rem;
  color: hsl(var(--muted-foreground));
}

.lead-middle-grid {
  display: grid;
  gap: 10px;
}

.lead-accordion {
  border: 1px solid hsl(var(--border));
  border-radius: calc(var(--radius) - 2px);
  background: hsl(var(--card));
}

.lead-accordion > summary {
  list-style: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px;
  font-weight: 800;
}

.lead-accordion > summary::-webkit-details-marker {
  display: none;
}

.lead-accordion > summary i {
  width: 16px;
  height: 16px;
  color: hsl(var(--muted-foreground));
}

.lead-accordion .detail-grid {
  padding: 0 12px 12px;
}

.detail-grid.cols-2 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.lead-secondary-footer {
  display: flex;
  justify-content: flex-start;
}

.lead-end-header h3 {
  margin: 0;
}

.lead-end-header p {
  margin: 4px 0 0;
}

.history-timeline {
  margin-top: 12px;
  display: grid;
  gap: 10px;
}

.timeline-empty {
  border: 1px dashed hsl(var(--border));
  border-radius: calc(var(--radius) - 2px);
  padding: 12px;
  color: hsl(var(--muted-foreground));
  font-size: .85rem;
}

.timeline-item {
  display: grid;
  grid-template-columns: 16px 1fr;
  gap: 8px;
}

.timeline-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: hsl(var(--primary));
  margin-top: 7px;
}

.timeline-content {
  border: 1px solid hsl(var(--border));
  border-radius: calc(var(--radius) - 2px);
  padding: 10px;
  background: hsl(var(--card));
}

.timeline-content header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
}

.timeline-date {
  font-size: .76rem;
  color: hsl(var(--muted-foreground));
  font-weight: 700;
}

.timeline-content p {
  margin: 0;
  font-size: .86rem;
  line-height: 1.5;
}

.lead-interaction-form {
  margin-top: 14px;
  border-top: 1px solid hsl(var(--border));
  padding-top: 12px;
}

.lead-interaction-form h4 {
  margin: 0 0 10px;
  font-size: 1rem;
}

.mobile-action-bar {
  display: none;
}

@media (max-width: 1250px) {
  .kpi-grid { grid-template-columns: repeat(2, minmax(180px, 1fr)); }
  .state-grid { grid-template-columns: repeat(3, minmax(130px, 1fr)); }
  .ranking-duplo-grid { grid-template-columns: 1fr; }
  .ai-workspace-grid { grid-template-columns: 1fr; }
  .kanban-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 980px) {
  .erp-shell {
    grid-template-columns: 1fr;
  }

  .erp-sidebar {
    position: static;
    height: auto;
    border-right: none;
    border-bottom: 1px solid hsl(var(--border));
  }

  .erp-menu {
    display: grid;
    grid-template-columns: repeat(2, minmax(160px, 1fr));
  }

  .auth-shell {
    grid-template-columns: 1fr;
    padding: 0;
  }

  .auth-left {
    min-height: 180px;
    border-radius: 0;
    border-right: 1px solid hsl(var(--border));
    border-bottom: none;
  }

  .auth-right {
    border-radius: 0;
    min-height: calc(100vh - 180px);
  }

  .auth-top-link {
    top: 20px;
    right: 20px;
    font-size: 1.4rem;
  }

  .auth-brand {
    top: 20px;
    left: 20px;
    font-size: 1.4rem;
  }

  .auth-logo { font-size: 1.7rem; }
  .auth-card h1 { font-size: 2rem; }
}

@media (max-width: 760px) {
  .erp-content { padding: 12px; }
  .erp-topbar {
    padding: 10px 12px;
    height: auto;
    align-items: flex-start;
    flex-direction: column;
    gap: 10px;
  }

  .topbar-actions {
    width: 100%;
    flex-wrap: wrap;
  }

  .funnel-grid { grid-template-columns: repeat(2, minmax(130px, 1fr)); }
  .dash-funnel-grid { grid-template-columns: 1fr; gap: 10px; }
  .state-grid { grid-template-columns: repeat(2, minmax(130px, 1fr)); }
  .ranking-head { flex-direction: column; align-items: flex-start; }
  .ranking-meta { grid-template-columns: 32px minmax(0, 1fr); }
  .ranking-total { grid-column: 2; justify-self: flex-start; }
  .edit-grid { grid-template-columns: 1fr; }
  .erp-menu { grid-template-columns: 1fr; }
  .ai-top-card { flex-direction: column; }
  .ai-top-actions { justify-content: flex-start; }
  .ai-chat-messages { min-height: 360px; }
  .msg-bubble { max-width: 88%; }
  .table-actions-inline { flex-direction: column; align-items: stretch; }
  .kanban-grid { grid-template-columns: 1fr; }
  .lead-detail-top { flex-direction: column; }
  .lead-detail-top-right { grid-template-columns: 1fr; width: 100%; }
  .detail-grid.cols-3 { grid-template-columns: 1fr; }
  .detail-grid.cols-2 { grid-template-columns: 1fr; }
  .field-wide { grid-column: span 1; }

  .lead-open-topbar {
    top: 0;
    flex-direction: column;
    align-items: flex-start;
  }

  .lead-open-actions {
    width: 100%;
    justify-content: flex-start;
  }

  .lead-open-grid {
    grid-template-columns: 1fr;
  }

  .lead-open-quick-form {
    grid-template-columns: 1fr;
  }

  .lead-conversation-dialog {
    width: 100%;
    max-height: 90vh;
  }

  .lead-start-grid {
    grid-template-columns: 1fr;
  }

  .lead-next-action-grid {
    grid-template-columns: 1fr;
  }

  .lead-save-sticky {
    top: 0;
  }

  .lead-accordion {
    overflow: hidden;
  }

  .lead-accordion > summary {
    padding: 11px;
  }

  .lead-secondary-footer {
    display: none;
  }

  .mobile-action-bar {
    position: fixed;
    left: 10px;
    right: 10px;
    bottom: 10px;
    z-index: 22;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    background: hsl(var(--card));
    border: 1px solid hsl(var(--border));
    border-radius: calc(var(--radius) - 1px);
    padding: 8px;
    box-shadow: 0 10px 24px rgba(0, 0, 0, .22);
  }

  .erp-content {
    padding-bottom: 84px;
  }
}
