:root {
  color-scheme: light;
  --bg: #eef2f6;
  --surface: #ffffff;
  --surface-soft: #f8fafc;
  --line: #d9e1ea;
  --line-strong: #c3ccd8;
  --text: #172033;
  --muted: #64748b;
  --teal: #0f766e;
  --blue: #2563eb;
  --amber: #b45309;
  --rose: #be123c;
  --green: #4d7c0f;
  --violet: #7c3aed;
  --shadow: 0 16px 36px rgba(15, 23, 42, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.topbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 420px);
  gap: 24px;
  align-items: center;
  padding: 24px 32px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(120deg, #ffffff 0%, #f8fafc 58%, #e8f3f0 100%);
}

.brand-block {
  min-width: 0;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  margin-top: 4px;
  font-size: clamp(28px, 3.2vw, 46px);
  font-weight: 820;
  letter-spacing: 0;
}

h2 {
  font-size: 17px;
  font-weight: 780;
  letter-spacing: 0;
}

.hero-copy {
  max-width: 740px;
  margin-top: 8px;
  color: #475569;
  font-size: 15px;
}

.eyebrow {
  color: var(--teal);
  font-size: 11px;
  font-weight: 820;
  letter-spacing: 0;
  text-transform: uppercase;
}

.status-card {
  display: grid;
  gap: 4px;
  justify-self: end;
  width: 100%;
  max-width: 420px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.78);
  box-shadow: var(--shadow);
}

.status-card span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 780;
  text-transform: uppercase;
}

.status-card strong {
  font-size: 14px;
}

.status-card small,
.muted-note {
  color: var(--muted);
  font-size: 12px;
}

.shell {
  width: min(1500px, 100%);
  margin: 0 auto;
  padding: 18px 28px 36px;
}

.filters-panel {
  display: grid;
  grid-template-columns: 0.65fr 1fr 1fr 1.35fr;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

label {
  display: grid;
  gap: 6px;
  min-width: 0;
  color: var(--muted);
  font-size: 11px;
  font-weight: 780;
  text-transform: uppercase;
}

select,
.table-search {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  padding: 0 10px;
  font: inherit;
  outline: none;
}

select:focus,
.table-search:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.14);
}

.notice {
  margin: 12px 2px 0;
  color: var(--muted);
  font-size: 12px;
}

.kpi-strip {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 12px;
  margin: 14px 0;
}

.kpi,
.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.kpi {
  min-height: 130px;
  padding: 15px;
}

.kpi span,
.kpi small {
  color: var(--muted);
}

.kpi span {
  display: block;
  font-size: 11px;
  font-weight: 820;
  text-transform: uppercase;
}

.kpi strong {
  display: block;
  max-width: 100%;
  margin-top: 8px;
  overflow-wrap: anywhere;
  font-size: clamp(20px, 1.8vw, 30px);
  line-height: 1.08;
  letter-spacing: 0;
}

.kpi small {
  display: block;
  margin-top: 8px;
  font-size: 12px;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(360px, 0.65fr);
  gap: 14px;
  align-items: start;
}

.panel {
  overflow: hidden;
}

.panel-wide {
  grid-column: span 1;
}

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

.panel-heading {
  display: flex;
  min-height: 64px;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 13px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-soft);
}

.panel-heading > div {
  min-width: 0;
}

.pill,
.tag {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  max-width: 100%;
  border-radius: 999px;
  padding: 3px 9px;
  font-size: 12px;
  font-weight: 780;
  line-height: 1.2;
  white-space: nowrap;
}

.pill {
  background: #e6f4f1;
  color: var(--teal);
}

.tag {
  background: #eef2f7;
  color: var(--muted);
}

.tag.base-consolidada {
  background: #e7f5ef;
  color: var(--green);
}

.tag.potencial-de-expansao {
  background: #e9f2ff;
  color: var(--blue);
}

.tag.area-critica {
  background: #ffe7ec;
  color: var(--rose);
}

.tag.prioridade-de-campanha {
  background: #fff3dc;
  color: var(--amber);
}

.tag.manutencao-politica {
  background: #f0eaff;
  color: var(--violet);
}

.chart-frame,
.donut-frame {
  position: relative;
  min-height: 330px;
  padding: 16px;
}

.chart-tall {
  min-height: 390px;
}

.comparison-frame {
  min-height: 360px;
}

.chart-fallback {
  display: none;
  color: var(--muted);
}

.chart-fallback.active {
  display: grid;
  gap: 8px;
}

.fallback-row {
  display: grid;
  grid-template-columns: minmax(90px, 1fr) minmax(70px, auto);
  gap: 8px;
  align-items: center;
}

.fallback-track {
  height: 8px;
  overflow: hidden;
  border-radius: 99px;
  background: #e6ebf1;
}

.fallback-fill {
  height: 100%;
  border-radius: inherit;
  background: var(--teal);
}

.rule-box {
  display: flex;
  gap: 6px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  background: #fcfdff;
  color: var(--muted);
  font-size: 12px;
}

.rule-box strong {
  color: var(--text);
  white-space: nowrap;
}

.table-search {
  max-width: 220px;
}

.table-wrap {
  width: 100%;
  overflow: auto;
}

.table-wrap.compact {
  max-height: 510px;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  padding: 10px 12px;
  border-bottom: 1px solid #edf1f5;
  text-align: left;
  vertical-align: middle;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #fbfcfe;
  color: var(--muted);
  font-size: 12px;
  font-weight: 820;
  white-space: nowrap;
}

td {
  font-size: 13px;
}

td.num,
th.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

tbody tr:hover {
  background: #f8fafc;
}

.name-cell strong {
  display: block;
  max-width: 340px;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.name-cell span {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
}

.map-placeholder {
  position: relative;
  min-height: 360px;
  padding: 16px;
  background:
    linear-gradient(90deg, rgba(15, 23, 42, 0.055) 1px, transparent 1px),
    linear-gradient(0deg, rgba(15, 23, 42, 0.055) 1px, transparent 1px),
    #f8fafc;
  background-size: 34px 34px;
}

.map-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  padding-bottom: 102px;
}

.map-cell {
  min-height: 76px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.86);
  padding: 10px;
}

.map-cell strong,
.map-cell span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.map-cell span {
  margin-top: 6px;
  color: var(--muted);
  font-size: 12px;
}

.map-caption {
  position: absolute;
  right: 16px;
  bottom: 16px;
  left: 16px;
  display: grid;
  gap: 3px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.94);
}

.map-caption span {
  color: var(--muted);
  font-size: 12px;
}

.positive {
  color: var(--green);
}

.negative {
  color: var(--rose);
}

.neutral {
  color: var(--muted);
}

.empty {
  padding: 18px;
  color: var(--muted);
}

@media (max-width: 1320px) {
  .kpi-strip {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 1120px) {
  .topbar,
  .filters-panel,
  .dashboard-grid {
    grid-template-columns: 1fr 1fr;
  }

  .panel,
  .panel-wide,
  .panel-full {
    grid-column: 1 / -1;
  }

  .status-card {
    justify-self: stretch;
  }
}

@media (max-width: 760px) {
  .topbar,
  .panel-heading,
  .rule-box {
    align-items: flex-start;
    flex-direction: column;
  }

  .topbar {
    display: flex;
    padding: 18px 16px;
  }

  .shell {
    padding: 14px 12px 26px;
  }

  .filters-panel,
  .kpi-strip,
  .dashboard-grid {
    grid-template-columns: 1fr;
  }

  .kpi {
    min-height: 108px;
  }

  .table-search {
    max-width: 100%;
  }

  .map-grid {
    grid-template-columns: 1fr 1fr;
  }

  .pill,
  .tag {
    white-space: normal;
  }
}

@media (max-width: 480px) {
  .map-grid {
    grid-template-columns: 1fr;
  }

  .chart-frame,
  .donut-frame,
  .map-placeholder {
    padding: 12px;
  }
}
