:root {
  color-scheme: light;
  --bg: #f6f7f8;
  --ink: #1d2521;
  --muted: #66726c;
  --line: #dce2df;
  --panel: #ffffff;
  --green: #2f6f4e;
  --blue: #275f8f;
  --gold: #b47a1e;
  --red: #a0443e;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, "Segoe UI", Arial, sans-serif;
}

.topbar {
  min-height: 132px;
  padding: 28px clamp(18px, 4vw, 52px);
  background: #23352d;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  border-bottom: 5px solid #d6a144;
}

.eyebrow,
.source,
.metric span,
.panel-title span,
label,
th,
.connector small {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

.topbar .eyebrow,
.topbar .source {
  color: rgba(255, 255, 255, 0.78);
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: clamp(30px, 4vw, 48px);
  line-height: 1.03;
  max-width: 760px;
}

h2 {
  font-size: 18px;
  line-height: 1.2;
}

.source {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.source span {
  border: 1px solid rgba(255, 255, 255, 0.32);
  border-radius: 6px;
  padding: 8px 10px;
}

main {
  width: min(1320px, calc(100% - 32px));
  margin: 20px auto 44px;
}

.summary,
.coverage,
.filters,
.grid,
.connectors {
  display: grid;
  gap: 14px;
}

.summary {
  grid-template-columns: 1fr 1.55fr 1.2fr 1.25fr 1.7fr;
}

.secondary-summary {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-top: 14px;
}

.metric,
.coverage,
.panel,
.filters,
.connectors {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.metric {
  min-height: 104px;
  padding: 18px 20px;
  min-width: 0;
}

.metric strong {
  display: block;
  margin-top: 10px;
  max-width: 100%;
  white-space: nowrap;
  font-size: clamp(22px, 2vw, 30px);
  line-height: 1;
}

.metric.highlight {
  border-color: rgba(47, 111, 78, 0.5);
  background: #f7fbf7;
}

.coverage {
  grid-template-columns: 1fr auto;
  align-items: center;
  margin-top: 14px;
  padding: 15px 18px;
}

.coverage strong {
  display: block;
  margin-bottom: 5px;
  font-size: 16px;
}

.coverage p {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.45;
}

.coverage-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.coverage-pills span {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 10px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.filters {
  grid-template-columns: 150px minmax(220px, 1fr) 150px minmax(280px, 1.25fr);
  padding: 14px;
  margin-top: 14px;
  align-items: end;
}

label {
  display: grid;
  gap: 7px;
}

select,
input {
  width: 100%;
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 10px;
  background: #fff;
  color: var(--ink);
  font: inherit;
}

.grid {
  grid-template-columns: 1.15fr 0.85fr;
  margin-top: 14px;
}

.panel {
  padding: 20px;
}

.panel-title {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: baseline;
  margin-bottom: 16px;
}

.panel-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.bars,
.ranking {
  display: grid;
  gap: 12px;
}

.bar-row,
.rank-row {
  display: grid;
  gap: 6px;
}

.bar-head,
.rank-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 14px;
}

.track {
  height: 12px;
  overflow: hidden;
  border-radius: 999px;
  background: #e7ebe5;
}

.fill {
  height: 100%;
  background: linear-gradient(90deg, var(--green), var(--blue));
}

.table-panel {
  margin-top: 14px;
  padding: 0;
}

.technical-summary {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
  background: #fbfcfa;
}

.technical-summary strong {
  display: block;
  margin-bottom: 4px;
}

.technical-summary p {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.45;
}

.quality-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.quality-pill,
.quality,
.origin {
  display: inline-block;
  border-radius: 999px;
  padding: 5px 8px;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.quality-completo,
.quality.completo {
  background: #e9f4ed;
  color: var(--green);
}

.quality-parcial,
.quality.parcial {
  background: #fff5df;
  color: var(--gold);
}

.quality-documental,
.quality.documental {
  background: #eef4fb;
  color: var(--blue);
}

.origin.federal {
  background: #eef3ef;
  color: var(--green);
}

.origin.estadual {
  background: #fff3df;
  color: var(--gold);
}

.technical-table {
  min-width: 1280px;
}

.technical-table small,
td small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.25;
}

.object-cell {
  max-width: 360px;
}

.link-button,
.icon-button {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  font: inherit;
  font-weight: 800;
}

.link-button {
  padding: 7px 10px;
}

.link-button:hover,
.icon-button:hover {
  border-color: var(--green);
  color: var(--green);
}

.detail-overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  justify-content: flex-end;
  background: rgba(18, 27, 23, 0.45);
}

.detail-overlay[hidden] {
  display: none;
}

.detail-drawer {
  width: min(720px, 100%);
  height: 100%;
  overflow: auto;
  background: #fff;
  box-shadow: -18px 0 40px rgba(0, 0, 0, 0.18);
}

.detail-head {
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: start;
  padding: 22px;
  border-bottom: 1px solid var(--line);
  background: #fff;
}

.detail-head h2 {
  margin-top: 8px;
  font-size: 24px;
}

.icon-button {
  width: 36px;
  height: 36px;
}

.detail-content {
  display: grid;
  gap: 14px;
  padding: 18px 22px 28px;
}

.detail-section {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
}

.detail-section h3 {
  margin: 0 0 12px;
  font-size: 16px;
}

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

.detail-section dt {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.detail-section dd {
  margin: 4px 0 0;
  line-height: 1.35;
}

.empty-detail {
  color: var(--muted);
  font-size: 14px;
}

.mini-table {
  display: grid;
  gap: 8px;
}

.mini-table div {
  display: grid;
  grid-template-columns: 90px 1fr 1.4fr;
  gap: 10px;
  padding: 9px 0;
  border-top: 1px solid var(--line);
  font-size: 13px;
}

.state-summary {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
  background: #fbfcfa;
}

.state-summary strong {
  font-size: 26px;
  white-space: nowrap;
}

.state-summary p {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.4;
  max-width: 620px;
}

.table-panel .panel-title {
  margin: 0;
  padding: 18px 20px;
  border-bottom: 1px solid var(--line);
}

.table-wrap {
  overflow: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 980px;
}

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

td {
  font-size: 14px;
}

.money,
.percent {
  white-space: nowrap;
  text-align: right;
}

.tag {
  display: inline-block;
  border-radius: 999px;
  padding: 5px 8px;
  background: #eef3ef;
  color: var(--green);
  font-weight: 700;
  font-size: 12px;
}

.connectors {
  grid-template-columns: 260px 1fr;
  padding: 18px;
  margin-top: 14px;
  align-items: start;
}

.connectors p {
  margin-top: 6px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.45;
}

.connector-list {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.connector {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
}

.connector strong {
  display: block;
  margin-bottom: 8px;
  font-size: 14px;
}

.status-ativo {
  color: var(--green);
}

.status-pendente_chave {
  color: var(--gold);
}

.status-em_analise {
  color: var(--blue);
}

.status-achados {
  color: var(--gold);
}

@media (max-width: 880px) {
  .topbar {
    align-items: start;
    flex-direction: column;
  }

  .source {
    justify-content: flex-start;
  }

  .summary,
  .coverage,
  .grid,
  .connectors,
  .connector-list {
    grid-template-columns: 1fr;
  }

  .coverage-pills {
    justify-content: flex-start;
  }

  .technical-summary {
    align-items: flex-start;
    flex-direction: column;
  }

  .quality-summary {
    justify-content: flex-start;
  }

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

@media (max-width: 560px) {
  .summary,
  .filters {
    grid-template-columns: 1fr;
  }

  .metric strong {
    font-size: 26px;
  }

  .state-summary {
    align-items: flex-start;
    flex-direction: column;
  }

  .detail-section dl,
  .mini-table div {
    grid-template-columns: 1fr;
  }
}
