/* ═══════════════════════════════════════════════════════════
   TURBOMETA CRM — Atualização de DESIGN (dashboard moderno)
   Somente apresentação: não altera dados, regras nem fluxos.
   Referência visual: sidebar roxa, topbar branca, fundo cinza claro,
   cards brancos com sombra suave, gráficos roxo/azul/verde-água/rosa.
   ═══════════════════════════════════════════════════════════ */

:root {
  --tmx-purple: #6D2FE0;
  --tmx-purple-dk: #2B0F6E;
  --tmx-purple-lt: #EFE8FD;
  --tmx-blue: #0D7EF3;
  --tmx-teal: #00BFC4;
  --tmx-pink: #F2166E;
  --tmx-shadow: 0 2px 12px rgba(40, 20, 100, 0.07);

  --bg: #F3F4F9;
  --surface2: #EDEFF6;
  --radius-lg: 12px;
}

/* ── SIDEBAR ROXA ─────────────────────────── */
#sidebar {
  background: linear-gradient(185deg, #2E1176 0%, #1C0A52 100%);
  border-right: 0;
  color: #fff;
}
#sidebar .logo { border-bottom-color: rgba(255,255,255,.10); }
#sidebar .logo-name { color: #fff; }
#sidebar .logo-tag { color: rgba(255,255,255,.55); }
#sidebar .nav-section { color: rgba(255,255,255,.42); }
#sidebar .nav-item { color: rgba(255,255,255,.72); }
#sidebar .nav-item:hover { background: rgba(255,255,255,.08); color: #fff; }
#sidebar .nav-item.active { background: rgba(255,255,255,.14); color: #fff; }
#sidebar .btn-icon { color: rgba(255,255,255,.75); border-color: rgba(255,255,255,.18); background: none; }
#sidebar .btn-icon:hover { background: rgba(255,255,255,.12); color: #fff; }
#sidebar .sidebar-footer { border-top-color: rgba(255,255,255,.10); }
#sidebar .avatar-name { color: #fff; }
#sidebar .avatar-role { color: rgba(255,255,255,.55); }

/* ── TOPBAR BRANCA + PESQUISA ─────────────── */
.topbar { box-shadow: 0 1px 0 var(--border), 0 4px 14px rgba(40,20,100,.04); }
.tmx-search {
  position: relative; flex: 0 1 340px; min-width: 120px;
}
.tmx-search i {
  position: absolute; left: 11px; top: 50%; transform: translateY(-50%);
  font-size: 15px; color: var(--text-hint); pointer-events: none;
}
.tmx-search input {
  width: 100%; height: 34px; padding: 0 12px 0 33px;
  border: 1px solid var(--border-md); border-radius: 8px;
  background: var(--surface); color: var(--text);
  font: 13px var(--font); outline: none;
}
.tmx-search input:focus { border-color: var(--tmx-purple); box-shadow: 0 0 0 3px rgba(109,47,224,.14); }
@media (max-width: 760px) { .tmx-search { display: none; } }

/* ── CARTÕES ──────────────────────────────── */
.tmx-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--tmx-shadow);
  padding: 18px 20px;
  min-width: 0;
}
.tmx-card h3 { font-size: 14px; font-weight: 600; letter-spacing: -.01em; margin: 0 0 3px; }
.tmx-card .tmx-sub { font-size: 12px; color: var(--text-muted); margin: 0 0 14px; line-height: 1.45; }

/* ── CABEÇALHO ────────────────────────────── */
.tmx-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 16px; }
.tmx-head h2 { font-size: 22px; font-weight: 600; letter-spacing: -.02em; margin: 0; }
.tmx-head p { font-size: 12.5px; color: var(--text-muted); margin: 2px 0 0; }
.tmx-range { font-size: 12px; color: var(--text-muted); font-family: var(--mono); }
.tmx-range b { color: var(--text); font-size: 15px; font-weight: 500; }

/* ── FILTROS ──────────────────────────────── */
.tmx-filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; margin-bottom: 16px; }
.tmx-filters label { display: flex; flex-direction: column; gap: 3px; font-size: 10.5px; font-weight: 600; letter-spacing: .05em; text-transform: uppercase; color: var(--text-hint); }
.tmx-filters select, .tmx-filters input[type=date] {
  height: 34px; padding: 0 10px; min-width: 130px;
  border: 1px solid var(--border-md); border-radius: 8px;
  background: var(--surface); color: var(--text); font: 13px var(--font);
}
.tmx-filters select:focus, .tmx-filters input:focus { outline: none; border-color: var(--tmx-purple); }
.tmx-btn {
  height: 34px; padding: 0 14px; border-radius: 8px; cursor: pointer;
  border: 1px solid var(--tmx-purple); background: var(--tmx-purple); color: #fff; font: 500 13px var(--font);
  display: inline-flex; align-items: center; gap: 6px;
}
.tmx-btn.ghost { background: var(--surface); color: var(--text); border-color: var(--border-md); }
.tmx-btn:hover { opacity: .9; }

/* ── KPIs ─────────────────────────────────── */
.tmx-kpis { display: grid; grid-template-columns: repeat(6, minmax(0,1fr)); gap: 14px; margin-bottom: 16px; }
.tmx-kpi { padding: 14px 16px 0; overflow: hidden; display: flex; flex-direction: column; }
.tmx-kpi-top { display: flex; align-items: center; gap: 11px; }
.tmx-kpi-ico {
  width: 40px; height: 40px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; color: #fff; font-size: 19px;
}
.tmx-kpi-val { font-size: 22px; font-weight: 600; letter-spacing: -.02em; line-height: 1.1; }
.tmx-kpi-lbl { font-size: 11.5px; color: var(--text-muted); line-height: 1.25; }
.tmx-kpi svg { display: block; width: calc(100% + 32px); margin: 10px -16px 0; height: 34px; }
.tmx-kpi .tmx-kpi-note { font-size: 10.5px; color: var(--text-hint); margin-top: 6px; padding-bottom: 10px; }
@media (max-width: 1250px) { .tmx-kpis { grid-template-columns: repeat(3, minmax(0,1fr)); } }
@media (max-width: 640px)  { .tmx-kpis { grid-template-columns: repeat(2, minmax(0,1fr)); } }

/* ── MAPA ─────────────────────────────────── */
.tmx-maprow { display: grid; grid-template-columns: minmax(0,1fr) 300px; gap: 14px; margin-bottom: 16px; }
@media (max-width: 1100px) { .tmx-maprow { grid-template-columns: 1fr; } }
.tmx-mapwrap { display: grid; grid-template-columns: 250px minmax(0,1fr); gap: 18px; }
@media (max-width: 820px) { .tmx-mapwrap { grid-template-columns: 1fr; } }
.tmx-toplist { display: flex; flex-direction: column; gap: 11px; max-height: 420px; overflow-y: auto; padding-right: 4px; }
.tmx-toplist::-webkit-scrollbar { width: 4px; }
.tmx-toplist::-webkit-scrollbar-thumb { background: var(--border-md); border-radius: 99px; }
.tmx-toprow { cursor: pointer; }
.tmx-toprow .t { display: flex; justify-content: space-between; font-size: 12.5px; margin-bottom: 4px; gap: 8px; }
.tmx-toprow .t span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tmx-toprow .t b { font-weight: 600; }
.tmx-bar { height: 5px; border-radius: 99px; background: var(--surface2); overflow: hidden; }
.tmx-bar i { display: block; height: 100%; border-radius: 99px; }
.tmx-toprow:hover .t span:first-child { color: var(--tmx-purple); }
.tmx-toprow .s { font-size: 10.5px; color: var(--text-hint); margin-top: 3px; }
#tmx-map { height: 420px; border-radius: 10px; background: var(--surface2); z-index: 0; border: 1px solid var(--border); }
.tmx-legend { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 10px; }
.tmx-legend label { display: inline-flex; align-items: center; gap: 6px; font-size: 11.5px; color: var(--text-muted); cursor: pointer; user-select: none; }
.tmx-legend i { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.tmx-mapnote { font-size: 11.5px; color: var(--text-muted); margin-top: 8px; line-height: 1.5; }
.tmx-mapnote.warn { color: var(--tm-amber); }
.leaflet-popup-content { font-family: var(--font); font-size: 12.5px; line-height: 1.5; margin: 12px 14px; }
.tmx-pop h4 { margin: 0 0 2px; font-size: 14px; }
.tmx-pop small { color: #767672; }
.tmx-pop table { margin-top: 7px; border-collapse: collapse; width: 100%; }
.tmx-pop td { padding: 2px 0; }
.tmx-pop td:last-child { text-align: right; font-weight: 600; padding-left: 14px; }
.tmx-pop i.d { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; }

/* ── DONUT ────────────────────────────────── */
.tmx-donut { position: relative; width: 180px; height: 180px; margin: 6px auto 14px; }
.tmx-donut > div { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 32px; font-weight: 700; color: var(--tmx-purple); pointer-events: none; }
.tmx-donut-legend { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.tmx-donut-legend .l { font-size: 10px; letter-spacing: .06em; text-transform: uppercase; color: var(--text-muted); display: flex; align-items: center; gap: 6px; }
.tmx-donut-legend .l i { width: 8px; height: 8px; border-radius: 50%; }
.tmx-donut-legend .v { font-size: 22px; font-weight: 600; margin-top: 2px; }

/* ── GRÁFICOS ─────────────────────────────── */
.tmx-grid2 { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 14px; margin-bottom: 16px; }
@media (max-width: 960px) { .tmx-grid2 { grid-template-columns: 1fr; } }
.tmx-chart { position: relative; height: 240px; }
.tmx-metrics { display: flex; gap: 22px; flex-wrap: wrap; margin-bottom: 8px; }
.tmx-metrics .m b { display: block; font-size: 20px; font-weight: 600; }
.tmx-metrics .m span { font-size: 11.5px; color: var(--text-muted); display: inline-flex; align-items: center; gap: 5px; }
.tmx-metrics .m span i { width: 8px; height: 8px; border-radius: 50%; }
.tmx-perf { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 12px; }
.tmx-perf .p { background: var(--surface2); border-radius: 10px; padding: 12px 14px; }
.tmx-perf .p b { display: block; font-size: 22px; font-weight: 600; }
.tmx-perf .p span { font-size: 11.5px; color: var(--text-muted); }
.tmx-empty { text-align: center; color: var(--text-hint); font-size: 12.5px; padding: 40px 10px; }

/* ── LOADING / ERRO ───────────────────────── */
.tmx-loading { opacity: .55; pointer-events: none; transition: opacity .15s; }
.tmx-err { background: var(--tm-red-lt); color: var(--tm-red); border-radius: 10px; padding: 12px 14px; font-size: 13px; margin-bottom: 14px; }

/* ── INTELIGÊNCIA COMERCIAL ───────────────── */
.tmx-intel-grid { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 18px; }
@media (max-width: 960px) { .tmx-intel-grid { grid-template-columns: 1fr; } }
.tmx-intel-grid h4 { font-size: 12.5px; font-weight: 600; margin: 0 0 8px; display: flex; align-items: center; gap: 6px; }
.tmx-irow { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--border); font-size: 12.5px; }
.tmx-irow:last-child { border-bottom: 0; }
.tmx-irow small { display: block; color: var(--text-muted); font-size: 10.5px; margin-top: 1px; }
.tmx-irow > span { font-size: 18px; font-weight: 600; color: var(--tmx-purple); }
.tmx-reco { display: flex; gap: 10px; align-items: flex-start; background: var(--tmx-purple-lt); color: #2B0F6E; border-radius: 10px; padding: 11px 14px; font-size: 12.5px; line-height: 1.5; margin-bottom: 16px; }
.tmx-reco i { font-size: 18px; color: var(--tmx-purple); margin-top: 1px; }
html[data-theme="dark"] .tmx-reco { background: rgba(109,47,224,.18); color: var(--text); }
.leaflet-tooltip.tmx-callout { background: #fff; border: 0; border-radius: 8px; box-shadow: 0 4px 14px rgba(40,20,100,.22); color: #1A1A1A; font: 11.5px/1.3 var(--font); padding: 5px 9px; text-align: center; }
.leaflet-tooltip.tmx-callout::before { border-top-color: #fff; }
