:root {
  --primary: #211047;
  --primary-2: #32176B;
  --accent: #18D4B4;
  --accent-2: #25B89A;
  --warning: #F59E0B;
  --danger: #B91C1C;
  --success: #15803D;
  --info: #2563EB;
  --bg: #F4F6F8;
  --card: #FFFFFF;
  --text: #111827;
  --muted: #6B7280;
  --border: #E5E7EB;
}
* { box-sizing: border-box; }
body { margin: 0; font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; color: var(--text); background: var(--bg); letter-spacing: 0; }
a { color: var(--primary-2); text-decoration: none; font-weight: 800; }
button, input, select, textarea { font: inherit; }
.crm-body { display: grid; grid-template-columns: 252px minmax(0, 1fr); min-height: 100vh; }
.crm-sidebar { position: sticky; top: 0; height: 100vh; background: var(--primary); color: #fff; padding: 18px; overflow-y: auto; }
.crm-brand, .login-brand { display: flex; align-items: center; gap: 10px; color: #fff; margin-bottom: 20px; }
.brand-mark { width: 34px; height: 34px; border-radius: 8px; display: grid; place-items: center; background: linear-gradient(135deg, var(--accent), var(--primary-2)); color: #fff; font-weight: 900; }
.crm-sidebar nav { display: grid; gap: 4px; }
.crm-sidebar nav a { color: #e8edf7; padding: 10px 12px; border-radius: 8px; font-weight: 700; }
.crm-sidebar nav a:hover { background: rgba(255,255,255,.1); }
.crm-main { min-width: 0; padding: 22px; }
.crm-topbar { display: flex; justify-content: space-between; gap: 16px; align-items: center; margin-bottom: 20px; }
.crm-topbar h1 { margin: 0; color: var(--primary); }
.crm-topbar small { color: var(--muted); }
.user-box { display: flex; align-items: center; gap: 10px; }
.button { border: 1px solid var(--border); border-radius: 8px; padding: 10px 14px; min-height: 40px; background: #fff; color: var(--primary); cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 8px; font-weight: 800; }
.button.primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.button.secondary { background: var(--accent); color: #06251f; border-color: var(--accent); }
.button.ghost { background: #fff; color: var(--primary); }
.button.small { min-height: 32px; padding: 6px 10px; font-size: 13px; }
.button.full { width: 100%; }
.kpi-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi-card, .panel, .login-card, .flash { background: var(--card); border: 1px solid var(--border); border-radius: 8px; box-shadow: 0 10px 28px rgba(17,24,39,.05); }
.kpi-card { padding: 16px; display: grid; gap: 8px; min-height: 96px; }
.kpi-card span { color: var(--muted); font-weight: 700; font-size: 13px; }
.kpi-card strong { color: var(--primary); font-size: 32px; }
.dashboard-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; margin-bottom: 16px; }
.panel { padding: 16px; min-width: 0; }
.panel.wide { grid-column: span 2; }
.panel.narrow { max-width: 780px; }
.panel h2, .panel h3 { margin-top: 0; color: var(--primary); }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.rank-list, .compact-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.rank-list li, .compact-list li { display: flex; justify-content: space-between; gap: 12px; padding: 10px; border: 1px solid var(--border); border-radius: 8px; background: #fbfdff; }
.compact-list li { display: grid; justify-content: stretch; }
.mini-map { min-height: 320px; border-radius: 8px; overflow: hidden; border: 1px solid var(--border); }
.map-placeholder { height: 100%; min-height: 220px; display: grid; place-items: center; padding: 20px; text-align: center; color: var(--muted); background: repeating-linear-gradient(45deg, #f8fafc, #f8fafc 12px, #eef2f7 12px, #eef2f7 24px); }
.filters { display: grid; grid-template-columns: repeat(6, minmax(130px, 1fr)); gap: 10px; align-items: end; background: #fff; border: 1px solid var(--border); border-radius: 8px; padding: 12px; margin-bottom: 14px; }
.filters.compact { grid-template-columns: repeat(8, minmax(110px, 1fr)); }
input, select, textarea { width: 100%; border: 1px solid var(--border); border-radius: 8px; padding: 10px; background: #fff; color: var(--text); }
label { display: grid; gap: 6px; font-weight: 800; color: #1f2937; }
.stack-form { display: grid; gap: 12px; }
.table-wrap { width: 100%; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; min-width: 900px; }
th, td { text-align: left; padding: 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { color: var(--muted); font-size: 12px; text-transform: uppercase; background: #f8fafc; }
td small { color: var(--muted); }
.badge { display: inline-flex; align-items: center; border-radius: 999px; padding: 5px 10px; font-weight: 800; font-size: 12px; background: #eef2ff; color: var(--primary); white-space: nowrap; }
.badge.success { background: #dcfce7; color: var(--success); }
.badge.info { background: #dbeafe; color: var(--info); }
.badge.warning { background: #fef3c7; color: #92400e; }
.badge.danger { background: #fee2e2; color: var(--danger); }
.badge.muted { background: #f1f5f9; color: #475569; }
.flash { padding: 12px; margin-bottom: 12px; }
.flash.success { border-color: #bbf7d0; background: #f0fdf4; color: var(--success); }
.flash.danger { border-color: #fecaca; background: #fef2f2; color: var(--danger); }
.login-body { min-height: 100vh; display: grid; place-items: center; background: radial-gradient(circle at top left, #e6fbf7, transparent 35%), var(--bg); padding: 20px; }
.login-card { width: min(420px, 100%); padding: 24px; }
.login-card .login-brand { color: var(--primary); }
.login-card h1 { color: var(--primary); margin-bottom: 6px; }
.login-card p, .login-card small { color: var(--muted); }
.login-card form { display: grid; gap: 12px; margin: 18px 0; }
.detail-layout { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 14px; align-items: start; }
.detail-title { display: flex; justify-content: space-between; gap: 12px; }
.detail-title h2 { margin: 8px 0 4px; color: var(--primary); }
.summary-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin: 14px 0; }
.summary-grid p { margin: 0; padding: 12px; border: 1px solid var(--border); border-radius: 8px; background: #fbfdff; }
.summary-grid strong { display: block; color: var(--muted); font-size: 12px; text-transform: uppercase; }
.description { line-height: 1.7; background: #fbfdff; border: 1px solid var(--border); padding: 12px; border-radius: 8px; }
.detail-map { min-height: 300px; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.photo-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.photo-grid img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: 8px; border: 1px solid var(--border); }
.detail-side { position: sticky; top: 18px; }
.whatsapp-actions { display: grid; gap: 8px; margin: 12px 0 18px; }
.check-line { display: flex; gap: 8px; align-items: flex-start; font-weight: 600; }
.check-line input { width: auto; margin-top: 3px; }
.timeline { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; }
.timeline li { border-left: 3px solid var(--accent); padding-left: 12px; display: grid; gap: 4px; }
.map-layout { display: grid; grid-template-columns: minmax(0, 1fr) 320px; grid-template-rows: auto minmax(620px, calc(100vh - 230px)); gap: 12px; }
.map-toolbar { grid-column: 1 / -1; display: flex; justify-content: space-between; align-items: center; background: #fff; border: 1px solid var(--border); border-radius: 8px; padding: 10px; }
.crm-map { min-height: 620px; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; background: #e5e7eb; }
.map-side { background: #fff; border: 1px solid var(--border); border-radius: 8px; padding: 14px; overflow-y: auto; }
.mini-kpis { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin-bottom: 12px; }
.mini-kpis span { border: 1px solid var(--border); border-radius: 8px; padding: 10px; display: grid; color: var(--muted); }
.mini-kpis strong { color: var(--primary); font-size: 22px; }
.color-dot { width: 14px; height: 14px; border-radius: 50%; display: inline-block; margin-right: 8px; vertical-align: middle; border: 1px solid rgba(0,0,0,.08); }
.category-detail { border: 1px solid var(--border); border-radius: 8px; padding: 10px; margin-bottom: 8px; }
.category-detail summary { cursor: pointer; font-weight: 900; color: var(--primary); }
.category-detail li { margin: 8px 0; }
.category-detail small { color: var(--muted); }
@media (max-width: 1120px) {
  .crm-body { grid-template-columns: 1fr; }
  .crm-sidebar { position: static; height: auto; }
  .crm-sidebar nav { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dashboard-grid, .detail-layout, .map-layout { grid-template-columns: 1fr; }
  .panel.wide { grid-column: auto; }
  .detail-side { position: static; }
  .filters, .filters.compact { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 640px) {
  .crm-main { padding: 14px; }
  .crm-topbar { flex-direction: column; align-items: flex-start; }
  .crm-sidebar nav { grid-template-columns: 1fr 1fr; }
  .kpi-grid, .summary-grid, .filters, .filters.compact, .photo-grid { grid-template-columns: 1fr; }
  .button { width: 100%; }
}


/* ===== T2026: mapa territorial premium com contagem por bairro ===== */
.leaflet-container {
  width: 100%;
  height: 100%;
  min-height: inherit;
  font: inherit;
  background: #edf2f7;
}
.leaflet-control-zoom a {
  color: var(--primary) !important;
  font-weight: 900;
}
.leaflet-popup-content-wrapper {
  border-radius: 18px;
  box-shadow: 0 22px 70px rgba(17, 24, 39, .22);
}
.leaflet-popup-content {
  margin: 14px;
  min-width: 240px;
}
.bairro-count-icon {
  background: transparent;
  border: 0;
}
.bairro-count-chip {
  min-width: 62px;
  max-width: 178px;
  height: 42px;
  display: inline-grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  padding: 5px 11px 5px 6px;
  border-radius: 999px;
  background: #ffffff;
  border: 2px solid #0ea5e9;
  color: #0f172a;
  box-shadow: 0 12px 30px rgba(15, 23, 42, .22), 0 0 0 5px rgba(255,255,255,.65);
  white-space: nowrap;
  transform: translateZ(0);
  transition: transform .18s ease, box-shadow .18s ease;
}
.bairro-count-chip:hover {
  transform: scale(1.05);
  box-shadow: 0 16px 40px rgba(15, 23, 42, .28), 0 0 0 6px rgba(24, 212, 180, .18);
}
.bairro-count-chip strong {
  min-width: 31px;
  height: 31px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: var(--primary);
  color: #fff;
  font-size: 14px;
  line-height: 1;
  font-weight: 950;
  letter-spacing: -.02em;
}
.bairro-count-chip span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 12px;
  line-height: 1.05;
  font-weight: 900;
  max-width: 112px;
}
.bairro-count-low .bairro-count-chip { border-color: #2563eb; }
.bairro-count-mid .bairro-count-chip { border-color: #18d4b4; }
.bairro-count-high .bairro-count-chip { border-color: #f59e0b; }
.bairro-count-hot .bairro-count-chip { border-color: #b91c1c; }
.bairro-count-hot .bairro-count-chip strong { background: #b91c1c; }
.bairro-count-high .bairro-count-chip strong { background: #f59e0b; color: #32176b; }
.bairro-count-mid .bairro-count-chip strong { background: #18d4b4; color: #06251f; }
.crm-point-icon {
  background: transparent;
  border: 0;
}
.crm-point-icon span {
  width: 18px;
  height: 18px;
  display: block;
  border-radius: 999px;
  border: 3px solid #fff;
  box-shadow: 0 7px 18px rgba(15, 23, 42, .30);
}
.map-popup h3 {
  margin: 2px 0 6px;
  color: var(--primary);
  font-size: 18px;
  line-height: 1.15;
}
.map-popup h4 {
  margin: 12px 0 8px;
  color: #334155;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: .06em;
}
.map-popup p {
  margin: 5px 0;
  color: #475569;
  line-height: 1.35;
}
.popup-kicker {
  color: var(--accent-2);
  font-weight: 950;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .08em;
  margin-bottom: 4px;
}
.popup-total {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  margin: 10px 0;
  padding: 10px;
  border: 1px solid rgba(24, 212, 180, .32);
  border-radius: 14px;
  background: linear-gradient(135deg, rgba(24,212,180,.14), rgba(37,99,235,.08));
}
.popup-total strong {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  border-radius: 16px;
  background: var(--primary);
  color: #fff;
  font-size: 24px;
  font-weight: 950;
}
.popup-total span {
  color: #334155;
  font-weight: 850;
}
.popup-metrics, .popup-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 8px 0;
}
.popup-metrics span, .mini-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  border-radius: 999px;
  padding: 5px 9px;
  background: #f1f5f9;
  color: #334155;
  font-weight: 850;
  font-size: 12px;
}
.popup-rank, .popup-demand-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 6px;
}
.popup-rank li, .popup-demand-list li {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  padding: 8px;
  background: #fbfdff;
}
.popup-demand-list li {
  display: grid;
  justify-content: stretch;
}
.popup-demand-list li a {
  color: var(--primary-2);
  font-weight: 950;
}
.popup-demand-list li span {
  color: #64748b;
  font-size: 12px;
}
.popup-rank li strong {
  color: var(--primary);
}
.popup-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}
.popup-photo {
  width: 100%;
  max-height: 150px;
  object-fit: cover;
  border-radius: 12px;
  margin-bottom: 10px;
  border: 1px solid #e5e7eb;
}
.map-toolbar label {
  display: flex;
  grid-template-columns: none;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
}
.map-toolbar select {
  min-width: 230px;
  border-radius: 999px;
  font-weight: 850;
  color: var(--primary);
}
@media (max-width: 640px) {
  .bairro-count-chip span { max-width: 76px; }
  .map-toolbar { align-items: stretch; flex-direction: column; }
  .map-toolbar label { align-items: stretch; flex-direction: column; }
  .map-toolbar select { min-width: 0; width: 100%; }
}
.mini-map { height: 320px; }
.crm-map { height: min(760px, calc(100vh - 230px)); }
.detail-map { height: 300px; }
@media (max-width: 1120px) {
  .crm-map { height: 560px; }
}
