/* Painel de dados da região: usa os tokens de material-didatico/assets/md.css */
:root {
  --g1: #e3f1e8; --g2: #a9d8b8; --g3: #5fb27c; --g4: #157f3b; --g5: #0d5a29;
  --r1: #fbe6ea; --r3: #d9607a; --r5: #b3123a;
  --neutro: #e6e6e1; --fora: #f1f1ee; --mark: #fff36b; --mark-ink: #111;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --g1: #1c3a27; --g2: #2c6b43; --g3: #3f9a5f; --g4: #6fd39b; --g5: #b6f0cc;
    --r1: #3b1a21; --r3: #c4506a; --r5: #ff7d93;
    --neutro: #3a3a38; --fora: #1f1f1f; --mark: #5b5512; --mark-ink: #fff7a8;
  }
}
:root[data-theme="dark"] {
  --g1: #1c3a27; --g2: #2c6b43; --g3: #3f9a5f; --g4: #6fd39b; --g5: #b6f0cc;
  --r1: #3b1a21; --r3: #c4506a; --r5: #ff7d93;
  --neutro: #3a3a38; --fora: #1f1f1f; --mark: #5b5512; --mark-ink: #fff7a8;
}

.hero { padding: 48px 0 36px; border-bottom: 1.5px solid var(--ink); background:
  linear-gradient(var(--line) 1px, transparent 1px) 0 0 / 22px 22px,
  linear-gradient(90deg, var(--line) 1px, transparent 1px) 0 0 / 22px 22px; }
.hero-inner { max-width: 800px; }
.hero .lead { font-size: 19px; color: var(--ink-2); }
.hero mark { background: var(--mark); color: var(--mark-ink); padding: 0 6px; border-radius: 6px; }
.terminal { display: inline-block; font-family: ui-monospace, Consolas, monospace; font-size: 14px; background: var(--ink); color: var(--paper); border-radius: 10px; padding: 6px 12px; margin-bottom: 14px; }

/* Barra de filtros */
.filtros { position: sticky; top: 61px; z-index: 30; background: var(--paper); border-bottom: 1.5px solid var(--ink); padding: 12px 0; }
.filtros .wrap { display: flex; flex-wrap: wrap; gap: 10px 18px; align-items: center; }
.campo { display: flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 500; }
.campo > span { color: var(--ink-2); }
select.sel { border: 1.5px solid var(--ink); border-radius: 99px; padding: 7px 34px 7px 14px; min-height: 40px; background: var(--paper);
  appearance: none; -webkit-appearance: none; cursor: pointer; max-width: 100%;
  background-image: linear-gradient(45deg, transparent 50%, var(--ink) 50%), linear-gradient(135deg, var(--ink) 50%, transparent 50%);
  background-position: calc(100% - 18px) 55%, calc(100% - 13px) 55%; background-size: 5px 5px; background-repeat: no-repeat; }
.seg { display: flex; gap: 4px; padding: 4px; border: 1.5px solid var(--ink); border-radius: 99px; width: fit-content; max-width: 100%; overflow-x: auto; background: var(--paper-2); }
.seg button { border: 0; background: none; border-radius: 99px; padding: 7px 14px; font-size: 14.5px; font-weight: 500; cursor: pointer; white-space: nowrap; }
.seg button:hover { background: var(--pill-2); }
.seg button[aria-pressed="true"] { background: var(--ink); color: var(--paper); }
@media (max-width: 760px) {
  .filtros { position: static; }
  .filtros .seg, .controles .seg { flex-wrap: wrap; border-radius: 22px; }
  .campo { width: 100%; flex-wrap: wrap; }
  .campo select.sel { flex: 1; }
}

/* Cartões e painéis */
.painel { border: 1.5px solid var(--ink); border-radius: 22px; padding: 20px; background: var(--paper); min-width: 0; }
.painel h3 { font-size: 19px; margin-bottom: 4px; }
.painel .sub { font-size: 14px; color: var(--ink-2); margin-bottom: 14px; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 14px; margin-top: 18px; }
.kpi { border: 1.5px solid var(--ink); border-radius: 20px; padding: 16px 18px; background: var(--paper); }
.kpi .rot { font-size: 13px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--ink-2); }
.kpi .num { font-family: var(--display); font-weight: 800; font-size: 40px; line-height: 1.1; margin: 6px 0 2px; }
.kpi .var { display: inline-flex; font-size: 13px; font-weight: 600; padding: 2px 10px; border-radius: 99px; background: var(--pill); }
.kpi .var.sobe { background: var(--ok-soft); color: var(--ok); }
.kpi .var.desce { background: var(--bad-soft); color: var(--bad); }
.kpi .ref { font-size: 13.5px; color: var(--ink-2); margin-top: 8px; }

.duas { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 18px; margin-top: 18px; }
@media (max-width: 900px) { .duas { grid-template-columns: 1fr; } }
.controles { display: flex; flex-wrap: wrap; gap: 10px 18px; align-items: center; margin-top: 14px; }

/* Mapa */
.mapa svg { width: 100%; height: auto; display: block; }
.mapa path { stroke: var(--paper); stroke-width: 1.2; cursor: pointer; transition: opacity .15s; }
.mapa path.fora { fill: var(--fora); cursor: default; }
.mapa path.fora.hatch { fill: url(#hachura); }
.mapa path:focus { outline: none; }
.mapa path.sel, .mapa path:focus-visible { stroke: var(--ink); stroke-width: 3; }
.mapa path:not(.fora):hover { opacity: .8; }
.mapa text { font-family: var(--body); font-size: 12px; font-weight: 600; fill: var(--ink); paint-order: stroke; stroke: var(--paper); stroke-width: 3.5px; pointer-events: none; }
.legenda { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 13px; color: var(--ink-2); margin-top: 10px; align-items: center; }
.legenda i { display: inline-block; width: 18px; height: 12px; border-radius: 4px; vertical-align: -1px; margin-right: 5px; border: 1px solid var(--line); }
.escala { display: flex; align-items: center; gap: 8px; }
.escala .faixa { display: flex; }
.escala .faixa i { width: 30px; height: 12px; margin: 0; border-radius: 0; border: 0; }
.escala .faixa i:first-child { border-radius: 4px 0 0 4px; } .escala .faixa i:last-child { border-radius: 0 4px 4px 0; }

/* Barras */
.barras { display: flex; flex-direction: column; gap: 2px; }
.barra { display: grid; grid-template-columns: var(--lab) minmax(0, 1fr); align-items: center; gap: 10px; min-height: 30px; padding: 2px 6px; border-radius: 10px; cursor: pointer; border: 0; background: none; text-align: left; width: 100%; }
.barra:hover { background: var(--paper-2); }
.barra.sel { background: var(--mark); color: var(--mark-ink); }
.barra .nm { font-size: 14px; line-height: 1.2; }
.barra .tr { position: relative; height: 22px; }
.barra .b { position: absolute; top: 4px; height: 14px; border-radius: 0 4px 4px 0; background: var(--g4); }
.barra .b.neg { border-radius: 4px 0 0 4px; background: var(--r5); }
.barra .b.ref { background: var(--ink-3); }
.barra .t { position: absolute; top: 50%; transform: translateY(-50%); font-size: 13px; font-weight: 600; white-space: nowrap; }
.barra .zero { position: absolute; top: 0; bottom: 0; border-left: 1.5px solid var(--ink-3); }
.barra .nd { font-size: 13px; color: var(--ink-3); }
.linha-ref { position: absolute; top: 0; bottom: 0; border-left: 1.5px dashed var(--ink-2); pointer-events: none; }
.linha-ref span { position: absolute; top: -20px; transform: translateX(-50%); font-size: 12px; color: var(--ink-2); white-space: nowrap; background: var(--paper); padding: 0 4px; }
.area-barras { position: relative; padding-top: 22px; --lab: 150px; }
@media (max-width: 520px) { .area-barras { --lab: 108px; } .barra .nm { font-size: 12.5px; } }

/* Halteres (2010 → atual) */
.halt { display: grid; grid-template-columns: 170px minmax(0, 1fr) 118px; gap: 10px; align-items: center; min-height: 40px; font-size: 14px; }
.halt .tr { position: relative; height: 12px; background: var(--paper-2); border: 1.5px solid var(--line); border-radius: 99px; }
.halt .fl { position: absolute; left: -1.5px; top: -1.5px; bottom: -1.5px; background: var(--g4); border-radius: 99px; }
.halt .fl.desce { background: var(--r5); }
.halt .mk { position: absolute; top: -6px; bottom: -6px; width: 8px; margin-left: -4px; background: var(--mark); border: 1.5px solid var(--ink); border-radius: 3px; }
.halt .vv { text-align: right; color: var(--ink-2); font-size: 13.5px; }
.halt .vv b { color: var(--ink); }
@media (max-width: 520px) { .halt { grid-template-columns: 1fr 96px; } .halt .tr { grid-column: 1 / -1; grid-row: 2; } .halt { padding-bottom: 8px; } }

/* Tabelas */
.tabela-wrap { overflow-x: auto; margin-top: 12px; }
table.tab { border-collapse: collapse; width: 100%; font-size: 14px; }
table.tab th, table.tab td { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: right; white-space: nowrap; }
table.tab th:first-child, table.tab td:first-child { text-align: left; white-space: normal; }
table.tab thead th { font-size: 12.5px; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-2); border-bottom: 1.5px solid var(--ink); }
table.tab tr.grupo td { font-weight: 700; background: var(--paper-2); }
table.tab .melhor { font-weight: 700; color: var(--ok); }
table.tab .est { color: var(--ink-3); }
.btn-link { border: 0; background: none; color: var(--accent); text-decoration: underline; text-underline-offset: 3px; cursor: pointer; padding: 0; font-size: 14px; font-weight: 500; }

/* Destaques */
.destaques { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 14px; margin-top: 18px; }
.destaque { border: 1.5px solid var(--ink); border-radius: 22px; padding: 18px 20px; }
.destaque.atual { box-shadow: 6px 6px 0 var(--ink); }
.destaque ul { margin: 8px 0 0; padding-left: 20px; font-size: 15px; }
.destaque li { margin-bottom: 6px; }

.nota { font-size: 13.5px; color: var(--ink-2); margin-top: 12px; }
.nota-est { font-size: 13px; color: var(--ink-2); }
.fonte-box { border: 1.5px dashed var(--ink-3); border-radius: 18px; padding: 16px 20px; font-size: 14.5px; color: var(--ink-2); }
.fonte-box li { margin-bottom: 6px; }

#tip { position: fixed; z-index: 100; pointer-events: none; background: var(--ink); color: var(--paper); font-size: 13.5px; line-height: 1.4;
  padding: 8px 12px; border-radius: 12px; max-width: 260px; opacity: 0; transition: opacity .1s; }
#tip.on { opacity: 1; }
#tip b { display: block; }
