:root {
  --bg: #f4efe7;
  --panel: rgba(255, 251, 245, 0.95);
  --panel-border: rgba(30, 41, 59, 0.08);
  --text: #203136;
  --muted: #607079;
  --shadow: 0 24px 60px rgba(24, 37, 42, 0.12);
  --clientes: #2f9e44;
  --assinatura: #1c7ed6;
  --licitacao: #e03131;
  --fechamento: #7b2cbf;
}

* { box-sizing: border-box; }

html,
body {
  margin: 0;
  min-height: 100%;
  font-family: "Space Grotesk", sans-serif;
  background:
    radial-gradient(circle at top left, rgba(47, 158, 68, 0.1), transparent 35%),
    radial-gradient(circle at bottom right, rgba(28, 126, 214, 0.12), transparent 32%),
    var(--bg);
  color: var(--text);
}

body { min-height: 100vh; }

.app-shell {
  display: grid;
  grid-template-columns: 360px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: relative;
  z-index: 1200;
  padding: 28px 24px;
  background: var(--panel);
  backdrop-filter: blur(18px);
  border-right: 1px solid var(--panel-border);
  box-shadow: var(--shadow);
  overflow-y: auto;
}

.sidebar__brand h1 {
  margin: 8px 0 10px;
  font-size: clamp(2rem, 2.4vw, 2.8rem);
  line-height: 0.95;
}

.eyebrow {
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  font-size: 0.72rem;
  color: var(--muted);
}

.subtitle {
  margin: 0;
  line-height: 1.6;
  color: var(--muted);
  font-size: 0.96rem;
}

.sidebar__panel {
  margin-top: 22px;
  padding: 18px;
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid rgba(32, 49, 54, 0.08);
}

.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.sidebar__panel h2 {
  margin: 0 0 14px;
  font-size: 1rem;
}

.toggle-list {
  display: grid;
  gap: 12px;
}

.toggle-card {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 14px;
  padding: 12px 14px;
  border-radius: 18px;
  background: rgba(248, 244, 238, 0.86);
  border: 1px solid rgba(32, 49, 54, 0.08);
}

.toggle-card__swatch {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  box-shadow: 0 0 0 4px rgba(255, 255, 255, 0.75);
}

.toggle-card__title {
  display: block;
  font-size: 0.96rem;
  font-weight: 600;
}

.toggle-card__meta {
  display: block;
  font-size: 0.78rem;
  color: var(--muted);
}

.switch {
  position: relative;
  width: 52px;
  height: 30px;
  display: inline-flex;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  inset: 0;
  border-radius: 999px;
  background: rgba(96, 112, 121, 0.26);
  transition: 0.2s ease;
}

.slider::before {
  content: "";
  position: absolute;
  width: 22px;
  height: 22px;
  left: 4px;
  top: 4px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 8px 18px rgba(23, 30, 34, 0.16);
  transition: 0.2s ease;
}

.switch input:checked + .slider {
  background: linear-gradient(90deg, rgba(32, 49, 54, 0.22), rgba(32, 49, 54, 0.32));
}

.switch input:checked + .slider::before {
  transform: translateX(22px);
}

.stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin: 0;
}

.stats div {
  padding: 12px 14px;
  border-radius: 18px;
  background: rgba(248, 244, 238, 0.86);
  border: 1px solid rgba(32, 49, 54, 0.08);
}

.stats dt {
  margin: 0;
  font-size: 0.78rem;
  color: var(--muted);
}

.stats dd {
  margin: 6px 0 0;
  font-size: 1.15rem;
  font-weight: 700;
}

.decision-hint {
  margin: 0;
  font-size: 0.84rem;
  line-height: 1.5;
  color: var(--muted);
}

.decision-controls {
  margin-top: 12px;
  display: grid;
  gap: 10px;
}

.decision-controls label {
  font-size: 0.76rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

.decision-controls select,
.decision-controls input[type="number"] {
  width: 100%;
  border: 1px solid rgba(32, 49, 54, 0.16);
  border-radius: 12px;
  padding: 9px 10px;
  background: rgba(255, 255, 255, 0.94);
  color: var(--text);
  font-family: inherit;
}

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

.decision-check {
  margin-top: 2px;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text) !important;
  font-size: 0.82rem !important;
  text-transform: none !important;
  letter-spacing: 0 !important;
}

.decision-kpis {
  margin: 14px 0 0;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.decision-kpis div {
  padding: 10px 12px;
  border-radius: 14px;
  background: rgba(248, 244, 238, 0.86);
  border: 1px solid rgba(32, 49, 54, 0.08);
}

.decision-kpis dt {
  margin: 0;
  font-size: 0.72rem;
  color: var(--muted);
}

.decision-kpis dd {
  margin: 5px 0 0;
  font-size: 1rem;
  font-weight: 700;
}

.notes {
  margin: 0;
  padding-left: 18px;
  color: var(--muted);
  line-height: 1.6;
}

.map-stage {
  position: relative;
  min-height: 100vh;
}

#map {
  position: absolute;
  inset: 0;
}

.leaflet-container { background: #dde7ea; }

.leaflet-control-zoom {
  border: none !important;
  box-shadow: 0 14px 40px rgba(17, 24, 28, 0.14) !important;
}

.leaflet-control-zoom a { color: var(--text) !important; }

.map-badge {
  position: absolute;
  right: 22px;
  top: 22px;
  z-index: 900;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.88);
  border: 1px solid rgba(32, 49, 54, 0.08);
  box-shadow: var(--shadow);
}

.badge-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: linear-gradient(135deg, #2f9e44, #1c7ed6);
}

.loading {
  position: absolute;
  inset: 0;
  z-index: 1500;
  display: grid;
  place-items: center;
  background: rgba(244, 239, 231, 0.66);
  backdrop-filter: blur(8px);
}

.loading.is-hidden { display: none; }

.loading__card {
  display: grid;
  gap: 16px;
  justify-items: center;
  padding: 22px 24px;
  min-width: 220px;
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: var(--shadow);
}

.loading__card p { margin: 0; }

.loading__pulse {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: conic-gradient(var(--clientes), var(--assinatura), var(--licitacao), var(--fechamento), var(--clientes));
  animation: spin 1.2s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.school-marker {
  width: 28px;
  height: 28px;
  border-radius: 50% 50% 50% 8%;
  transform: rotate(-45deg);
  display: grid;
  place-items: center;
  color: white;
  box-shadow: 0 10px 22px rgba(19, 31, 36, 0.26);
  border: 2px solid rgba(255, 255, 255, 0.94);
}

.school-marker i {
  transform: rotate(45deg);
  font-size: 0.82rem;
}

.school-marker--clientes { background: var(--clientes); }
.school-marker--assinatura { background: var(--assinatura); }
.school-marker--licitacao { background: var(--licitacao); }
.school-marker--fechamento { background: var(--fechamento); }

.cluster-badge {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: white;
  font-weight: 700;
  box-shadow: 0 18px 32px rgba(19, 31, 36, 0.2);
  border: 3px solid rgba(255, 255, 255, 0.92);
}

.cluster-badge--clientes { background: linear-gradient(135deg, #3fb950, #2f9e44); }
.cluster-badge--assinatura { background: linear-gradient(135deg, #339af0, #1c7ed6); }
.cluster-badge--licitacao { background: linear-gradient(135deg, #ff6b6b, #e03131); }
.cluster-badge--fechamento { background: linear-gradient(135deg, #9d4edd, #7b2cbf); }

.client-popup {
  min-width: 230px;
}

.client-popup h3 {
  margin: 0 0 8px;
  font-size: 0.95rem;
}

.client-popup__pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 0.74rem;
  font-weight: 700;
  margin-bottom: 10px;
  color: white;
}

.client-popup p {
  margin: 6px 0;
  font-size: 0.84rem;
  line-height: 1.5;
}

.legend-card {
  min-width: 196px;
  padding: 14px 16px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid rgba(32, 49, 54, 0.08);
  box-shadow: 0 16px 34px rgba(17, 24, 28, 0.16);
  color: var(--text);
}

.legend-title {
  font-size: 0.92rem;
  font-weight: 700;
}

.legend-subtitle {
  margin: 4px 0 10px;
  font-size: 0.74rem;
  color: var(--muted);
}

.legend-row {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.78rem;
}

.legend-row + .legend-row {
  margin-top: 6px;
}

.legend-swatch {
  width: 18px;
  height: 12px;
  border-radius: 999px;
  border: 1px solid rgba(17, 24, 28, 0.08);
  flex: 0 0 auto;
}

.city-tooltip {
  background: rgba(255, 255, 255, 0.94);
  border: none;
  box-shadow: 0 10px 24px rgba(17, 24, 28, 0.12);
  color: var(--text);
  font-weight: 600;
}

.ghost-button,
.mobile-open {
  border: none;
  background: rgba(255, 255, 255, 0.82);
  color: var(--text);
  border-radius: 999px;
  cursor: pointer;
}

.ghost-button {
  width: 34px;
  height: 34px;
  display: none;
  place-items: center;
}

.mobile-open {
  position: absolute;
  left: 18px;
  top: 18px;
  z-index: 1200;
  display: none;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  box-shadow: var(--shadow);
}

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

  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: min(88vw, 360px);
    transform: translateX(-104%);
    transition: transform 0.28s ease;
  }

  .sidebar.is-open { transform: translateX(0); }

  .ghost-button,
  .mobile-open { display: inline-flex; }

  .map-stage { min-height: 100vh; }

  .map-badge {
    top: auto;
    bottom: 18px;
    right: 18px;
  }
}
