* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: #1a1a1a;
}

#app { display: flex; height: 100vh; width: 100vw; }

#panel {
  width: 320px;
  min-width: 320px;
  height: 100%;
  overflow-y: auto;
  padding: 18px 18px 24px;
  background: #ffffff;
  border-right: 1px solid #e3e3e3;
  z-index: 2;
}

#panel h1 { font-size: 18px; margin: 0 0 4px; }
#panel h2 { font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: #666; margin: 20px 0 8px; }
.hint { font-size: 12px; color: #777; margin: 0 0 6px; }
.desc { font-size: 12px; color: #555; margin-top: 16px; line-height: 1.4; }
.credit { font-size: 10px; color: #aaa; margin-top: 24px; }

#map-wrap { flex: 1; position: relative; min-width: 0; }
#map { position: absolute; inset: 0; }

/* colapsar/expandir as barras laterais */
#app.colapsado-panel #panel, #app.colapsado-resumo #resumo { display: none; }
.colapsar-lateral {
  position: absolute; top: 50%; transform: translateY(-50%); z-index: 3;
  width: 18px; height: 56px; padding: 0; cursor: pointer;
  background: #fff; color: #555; font-size: 16px; line-height: 1;
  border: 1px solid #d5d9de; box-shadow: 0 1px 3px rgba(0,0,0,.12);
}
.colapsar-lateral:hover { background: #eef4ff; color: #1a3ea8; }
#colapsar-panel { left: 0; border-left: 0; border-radius: 0 6px 6px 0; }
#colapsar-resumo { right: 0; border-right: 0; border-radius: 6px 0 0 6px; }

/* layer selector */
.layer-row { display: flex; align-items: center; gap: 6px; }
.layer-row .layer-item { flex: 1; min-width: 0; }
.layer-row .layer-item span {
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.layer-opacity {
  flex: 0 0 62px; width: 62px; height: 14px; cursor: pointer;
  accent-color: #2f6fed;
}
.layer-item {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 9px; border-radius: 6px; cursor: pointer;
  font-size: 13px; border: 1px solid transparent;
}
.layer-item:hover { background: #f4f6f8; }
.layer-item.active { background: #eef4ff; border-color: #b9d2ff; font-weight: 600; }
.layer-item input { accent-color: #2f6fed; }

/* legend */
#legend { font-size: 12px; }
/* um bloco por camada marcada */
.legend-bloco { margin-bottom: 12px; }
.legend-bloco:last-child { margin-bottom: 0; }
.legend-titulo {
  font-size: 11px; font-weight: 600; color: #444;
  margin-bottom: 3px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.legend-bar {
  height: 12px; border-radius: 3px; margin: 6px 0 4px;
  border: 1px solid #ddd;
}
.legend-scale { display: flex; justify-content: space-between; color: #666; font-size: 11px; }
.legend-unit { color: #888; font-size: 11px; margin-top: 2px; }
.legend-cat { display: flex; align-items: center; gap: 8px; margin: 4px 0; }
.legend-swatch { width: 16px; height: 16px; border-radius: 3px; border: 1px solid #ccc; flex: 0 0 auto; }

/* risco por decêndio */
#risco-hint { margin: 0 0 6px; }
#risco-legend { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 6px; }
#risco-legend .legend-cat { margin: 0; font-size: 10px; }
#risco-legend .legend-swatch { width: 11px; height: 11px; }

#risco-table-wrap {
  overflow-x: auto;
  max-width: 100%;
  border: 1px solid #e3e3e3;
  border-radius: 4px;
}
#risco-table {
  border-collapse: collapse;
  font-size: 9px;
  white-space: nowrap;
}
#risco-table th, #risco-table td {
  padding: 0;
  text-align: center;
}
#risco-table .rt-group-row th {
  background: #f4f6f8;
  color: #444;
  font-size: 9.5px;
  font-weight: 600;
  text-align: left;
  padding: 3px 6px;
  border-top: 1px solid #e3e3e3;
}
#risco-table .rt-month-row th {
  font-size: 8px;
  font-weight: 600;
  color: #666;
  padding: 2px 0;
  border-bottom: 1px solid #e3e3e3;
}
#risco-table .rt-rowlabel {
  position: sticky;
  left: 0;
  background: #fff;
  text-align: left;
  padding: 0 6px 0 6px;
  font-size: 9px;
  color: #333;
  border-right: 1px solid #e3e3e3;
  z-index: 1;
}
#risco-table .rt-rowlabel.rt-absent { color: #bbb; }
#risco-table .rt-cell {
  width: 9px;
  height: 14px;
  border-right: 1px solid rgba(255,255,255,0.6);
}
#risco-table .rt-cell.rt-month-start { border-left: 1px solid #ccc; }
#risco-table .rt-cell.rt-absent { background: #ffffff; }

/* linha do AD sob o cursor (lido de solo_ad.tif), só linhas de Soja */
#risco-table .rt-row-current .rt-rowlabel { font-weight: 700; }
#risco-table .rt-row-current td { border-top: 2px solid #333; border-bottom: 2px solid #333; }

/* hover popup */
.maplibregl-popup { max-width: 260px !important; }
.raster-popup { font-size: 12px; line-height: 1.4; }
.raster-popup .val { font-weight: 700; }
.raster-popup .mun { color: #555; }

/* caixa lateral direita: area/quantidade por UF */
#resumo {
  width: 330px; min-width: 330px; height: 100%;
  overflow-y: auto; padding: 18px 16px 24px;
  background: #ffffff; border-left: 1px solid #e3e3e3; z-index: 2;
}
#resumo h2 {
  font-size: 12px; text-transform: uppercase; letter-spacing: .05em;
  color: #666; margin: 0 0 8px;
}
#resumo-cenario { display: flex; flex-direction: column; gap: 4px; margin-bottom: 10px; }
.resumo-op {
  display: flex; align-items: center; gap: 7px; cursor: pointer;
  font-size: 12px; padding: 5px 7px; border-radius: 5px;
  border: 1px solid transparent;
}
.resumo-op:hover { background: #f4f6f8; }
.resumo-op.active { background: #eef4ff; border-color: #b9d2ff; font-weight: 600; }
.resumo-op input { accent-color: #2f6fed; }

#resumo-total {
  background: #f4f6f8; border-radius: 6px; padding: 8px 10px; margin-bottom: 10px;
}
.resumo-total-linha { display: flex; justify-content: space-between; font-size: 12px; }
.resumo-total-linha strong { color: #1b5e3f; }

#resumo-wrap { overflow-x: auto; }
#resumo-tabela { border-collapse: collapse; font-size: 11px; width: 100%; }
#resumo-tabela th, #resumo-tabela td { padding: 3px 4px; text-align: right; white-space: nowrap; }
#resumo-tabela th {
  font-size: 10px; color: #666; font-weight: 600;
  border-bottom: 1px solid #e3e3e3; position: sticky; top: 0; background: #fff;
}
#resumo-tabela td:first-child, #resumo-tabela th:first-child { text-align: left; }
#resumo-tabela tbody tr:nth-child(even) { background: #fafbfc; }
/* coluna/linha "Captado" (uniao dos circulos de raio minimo) */
#resumo-tabela .resumo-captado { background: #eef4ff; color: #1a3ea8; font-weight: 600; }
.resumo-total-linha.resumo-captado { color: #1a3ea8; margin-top: 3px; padding-top: 3px; border-top: 1px solid #dde3ea; }
.resumo-total-linha.resumo-captado span { font-size: 10.5px; }
.resumo-nota { font-size: 10px; color: #999; line-height: 1.4; margin-top: 10px; }

/* corte por raio na camada de pontos */
#raios-corte-wrap { margin: 8px 0 6px; }
#raios-corte-rotulo { display: block; font-size: 11px; color: #555; margin-bottom: 3px; }
#raios-corte { width: 100%; accent-color: #2f6fed; cursor: pointer; }

/* porte de usina na camada de raios */
#raios-meta { display: flex; flex-direction: column; gap: 3px; margin-bottom: 6px; }
#raios-cenario { display: flex; flex-direction: column; gap: 3px; margin-bottom: 4px; }
#raios-meta .resumo-op, #raios-cenario .resumo-op { font-size: 11px; padding: 4px 7px; }
/* modo: raio minimo x quantidade em raio fixo */
#raios-modo { display: flex; gap: 4px; margin: 6px 0; }
#raios-modo .resumo-op { flex: 1; font-size: 11px; padding: 4px 6px; }

/* info do ponto clicado na camada de raios */
.raios-clique { font-size: 11px; color: #2f6fed; margin: 6px 0 0; line-height: 1.4; }
