* {
  box-sizing: border-box;
}

:root {
  --bg: #f6f7f9;
  --card: #ffffff;
  --text: #171717;
  --muted: #6f6f6f;
  --line: rgba(0, 0, 0, 0.08);
  --red: #b3261e;
  --green: #1f7a3f;
  --blue: #2458a6;
  --shadow: 0 12px 30px rgba(0, 0, 0, 0.06);
  --radius: 18px;
}

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

.hdr {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 24px;
  padding: 18px 28px;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}

.hdr h1 {
  margin: 0;
  font-size: 22px;
  letter-spacing: -0.02em;
}

.hdr p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.hdr-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.wrap {
  max-width: 1480px;
  margin: 0 auto;
  padding: 22px;
}

.tabs,
.subtabs,
.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.tabs {
  margin-bottom: 22px;
}

.tab,
.subtab,
.select,
.badge {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  border-radius: 999px;
  padding: 10px 14px;
  font-size: 14px;
}

.tab,
.subtab {
  cursor: pointer;
}

.tab.active,
.subtab.active {
  background: #171717;
  color: #fff;
  border-color: #171717;
}

.select {
  border-radius: 12px;
  min-height: 40px;
}

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

.section,
.subsection {
  display: none;
}

.section.active,
.subsection.active {
  display: block;
}

.section-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 18px;
  margin: 8px 0 16px;
}

.section-head h2 {
  margin: 0;
  font-size: 26px;
  letter-spacing: -0.03em;
}

.section-head p {
  margin: 6px 0 0;
  color: var(--muted);
}

.subtabs {
  margin: 12px 0 18px;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(180px, 1fr));
  gap: 14px;
  margin-bottom: 16px;
}

.kpi {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
}

.kpi span {
  display: block;
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 8px;
}

.kpi strong {
  display: block;
  font-size: 24px;
  line-height: 1.15;
  letter-spacing: -0.03em;
}

.kpi.red {
  border-left: 5px solid var(--red);
}

.kpi.green {
  border-left: 5px solid var(--green);
}

.kpi.blue {
  border-left: 5px solid var(--blue);
}

.layout-main-side {
  display: grid;
  grid-template-columns: minmax(0, 1.7fr) minmax(320px, 0.9fr);
  gap: 16px;
  margin-bottom: 16px;
}

.layout-stack {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
  margin-bottom: 16px;
}

.chart-card,
.table-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
}

.chart-card h3,
.table-card h3 {
  margin: 0 0 14px;
  font-size: 16px;
}

.chart-wide canvas {
  min-height: 320px;
  max-height: 420px;
}

.chart-compact canvas {
  min-height: 260px;
  max-height: 340px;
}

.table-wrap {
  overflow: auto;
  border-radius: 14px;
  border: 1px solid var(--line);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  background: #fff;
}

th,
td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  white-space: nowrap;
}

th {
  background: #fafafa;
  color: #555;
  font-weight: 700;
}

tr:last-child td {
  border-bottom: none;
}

.insight-item {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px 16px;
  margin-bottom: 10px;
  line-height: 1.45;
  font-size: 14px;
}

.insight-item strong {
  font-weight: 800;
}

#comparar-insights,
#comparar-alertas,
#insights-crescimento,
#insights-alertas,
#insights-produtos,
#insights-operacao,
#insights-gerais-resumo,
#insights-gerais-alertas,
#insights-gerais-produtos,
#insights-gerais-operacao {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.empty {
  background: var(--card);
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  padding: 22px;
  color: var(--muted);
}

@media (max-width: 1100px) {
  .layout-main-side {
    grid-template-columns: 1fr;
  }

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

@media (max-width: 700px) {
  .hdr {
    align-items: flex-start;
    flex-direction: column;
    padding: 16px;
  }

  .wrap {
    padding: 14px;
  }

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

  .tab,
  .subtab {
    width: 100%;
    text-align: left;
  }

  .chart-card,
  .table-card,
  .kpi {
    padding: 14px;
  }
}
