/* Fontes hospedadas localmente (IBM Plex, licença SIL OFL — ver fonts/OFL-LICENSE.txt) */
@font-face { font-family: "IBM Plex Sans"; font-weight: 400; font-display: swap; src: url(fonts/ibm-plex-sans-latin-400-normal.woff2) format("woff2"); }
@font-face { font-family: "IBM Plex Sans"; font-weight: 500; font-display: swap; src: url(fonts/ibm-plex-sans-latin-500-normal.woff2) format("woff2"); }
@font-face { font-family: "IBM Plex Sans"; font-weight: 600; font-display: swap; src: url(fonts/ibm-plex-sans-latin-600-normal.woff2) format("woff2"); }
@font-face { font-family: "IBM Plex Sans"; font-weight: 700; font-display: swap; src: url(fonts/ibm-plex-sans-latin-700-normal.woff2) format("woff2"); }
@font-face { font-family: "IBM Plex Mono"; font-weight: 400; font-display: swap; src: url(fonts/ibm-plex-mono-latin-400-normal.woff2) format("woff2"); }
@font-face { font-family: "IBM Plex Mono"; font-weight: 500; font-display: swap; src: url(fonts/ibm-plex-mono-latin-500-normal.woff2) format("woff2"); }

:root {
  --bg: #F3F4F1;
  --panel: #FFFFFF;
  --ink: #17201B;
  --muted: #5B6660;
  --line: #DDE1DC;
  --line-soft: #EEF0EC;
  --field: #C9CFC8;
  --blue: #1F5FA8;
  --blue-dark: #0B3E78;
  --blue-soft: #E3EDF8;
  --orange: #C2541A;
  --orange-text: #B24A12;
  --orange-soft: #FDF3EC;
  --sea: #E4ECEF;
  --land: #FBFBF8;
  --border-state: #C2CAC3;
  --dot-other: #A9B3AB;
  --red: #B42318;
  --red-soft: #FCEBE9;
  --green-text: #1F6B43;
  --sans: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--ink); font-family: var(--sans); font-size: 14px; line-height: 1.4; }
input, select, button { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; opacity: .5; }
:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
h1, h2, h3 { margin: 0; }
h2 { font-size: 16px; font-weight: 600; }
.num { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.normal { font-weight: 400; }
.sm { font-size: 13px; }
.fine { font-size: 12px; margin: 0; }
.r { text-align: right; }
.pad { padding: 16px; margin: 0; }
.row { display: flex; gap: 8px; align-items: center; }
.row.wrap, .wrap { flex-wrap: wrap; }
.row-between { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.col { display: flex; flex-direction: column; gap: 10px; }
.col.tight { gap: 2px; min-width: 0; }
.grow { flex: 1 1 auto; min-width: 0; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.grid2.ano-uf { grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); }

.app { min-height: 100vh; display: flex; flex-wrap: wrap; }

/* Lateral */
.ink { color: var(--ink); }
.strong { font-weight: 600; }
.row-between.center { align-items: center; }
.box { margin: 0; padding: 14px; border: 1px solid var(--line); border-radius: 10px; display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.box legend { padding: 0 6px; font-weight: 700; }
.box p { margin: 0; }
.kpi.red { background: var(--red-soft); }
.kpi.red .kpi-l { color: #7A271A; }
.kpi.red .kpi-v { color: var(--red); }
.side { flex: 1 1 310px; max-width: 100%; padding: 24px 20px; background: var(--panel); border-right: 1px solid var(--line); display: flex; flex-direction: column; gap: 22px; }
.brand { display: flex; flex-direction: column; gap: 6px; }
.brand p { margin: 0; }
.eyebrow { font-size: 12px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
h1 { font-size: 24px; font-weight: 700; line-height: 1.15; }
.field { display: flex; flex-direction: column; gap: 8px; }
.field > label, .field .row-between > label { font-weight: 600; }
.input { height: 44px; padding: 0 12px; border: 1px solid var(--field); border-radius: 8px; background: var(--panel); width: 100%; }
select.input { padding: 0 8px; width: auto; }
.field select.input { width: 100%; }
.input.small { width: 84px; height: 36px; padding: 0 8px; text-align: right; }
input[type=range] { width: 100%; accent-color: var(--blue); height: 28px; }
.check { display: flex; align-items: center; gap: 10px; min-height: 44px; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--blue); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { min-height: 32px; padding: 0 10px; border-radius: 16px; border: 1px solid var(--field); background: var(--panel); font-size: 13px; font-weight: 500; }
.chip[aria-pressed="true"] { background: var(--blue); border-color: var(--blue); color: #fff; }
.kpi { padding: 12px; border-radius: 10px; background: var(--bg); display: flex; flex-direction: column; gap: 2px; }
.kpi-l { font-size: 12px; color: var(--muted); }
.kpi-v { font-size: 22px; font-weight: 500; }
.kpi-v.sm { font-size: 18px; }
.orange { color: var(--orange-text); }
.blue { color: var(--blue); }

.btn { min-height: 40px; padding: 0 14px; border-radius: 8px; border: 1px solid var(--field); background: var(--panel); font-weight: 500; }
.btn.ghost:hover:not(:disabled) { background: var(--bg); }
.btn.primary { border: 0; background: var(--blue); color: #fff; font-weight: 600; padding: 0 16px; }
.btn.primary:hover { background: var(--blue-dark); }

/* Conteúdo */
.main { flex: 999 1 640px; min-width: 0; padding: 20px; display: flex; flex-wrap: wrap; gap: 16px; align-content: flex-start; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; display: flex; flex-direction: column; overflow: hidden; }
.card-head { padding: 12px 16px; border-bottom: 1px solid var(--line); align-items: center; }
.card-head.col { padding: 16px 16px 12px; align-items: stretch; }
.list-card { flex: 1 1 320px; min-width: 0; }
.map-col { flex: 2 1 520px; min-width: 0; display: flex; flex-direction: column; gap: 16px; }

.list-cols, .item { display: grid; grid-template-columns: minmax(0, 1fr) 84px 50px 58px; gap: 8px; }
.list-cols { padding: 8px 16px; font-size: 12px; color: var(--muted); border-bottom: 1px solid var(--line-soft); }
.list { overflow-y: auto; max-height: 820px; padding: 4px 8px 8px; }
.item { width: 100%; align-items: center; min-height: 44px; padding: 6px 8px; border: 0; border-radius: 8px; text-align: left; background: transparent; }
.item:hover { background: var(--bg); }
.item[aria-pressed="true"] { background: var(--blue-soft); }
.item[aria-pressed="true"] .nm { font-weight: 700; }
.item .nmw { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item .nm { font-weight: 500; }
.item .uf { color: var(--muted); font-size: 12px; }
.item .num { text-align: right; font-size: 13px; }
.item .n { color: var(--blue); }
.simc { display: inline-block; min-width: 28px; padding: 2px 6px; border-radius: 6px; text-align: center; }
.simc.weak { background: var(--red-soft); color: var(--red); font-weight: 700; }

/* Mapa */
#map { display: block; width: 100%; height: 600px; background: var(--sea); cursor: crosshair; touch-action: manipulation; }
.m-states { fill: var(--land); stroke: var(--border-state); stroke-width: .8px; vector-effect: non-scaling-stroke; stroke-linejoin: round; }
.m-zones { fill: rgba(31, 95, 168, .14); stroke: rgba(31, 95, 168, .45); stroke-width: .7px; vector-effect: non-scaling-stroke; }
.m-weak { fill: rgba(200, 40, 30, .16); stroke: rgba(180, 35, 24, .6); stroke-width: .9px; vector-effect: non-scaling-stroke; }
.m-selzone { fill: rgba(31, 95, 168, .12); stroke: var(--blue-dark); stroke-width: 2px; vector-effect: non-scaling-stroke; }
.m-selzone.weak { fill: rgba(200, 40, 30, .12); stroke: var(--red); }
.dots { fill: none; stroke-linecap: round; vector-effect: non-scaling-stroke; }
.m-other { stroke: var(--dot-other); stroke-width: 2.2px; }
.m-cov { stroke: var(--blue); stroke-width: 3px; }
.m-seldots { stroke: var(--blue-dark); stroke-width: 5px; }
.m-icp { stroke: var(--orange); stroke-width: 7px; }
.m-selcenter { stroke: #7A2E07; stroke-width: 13px; }
.m-label { font-family: var(--sans); font-weight: 600; fill: var(--ink); stroke: #fff; paint-order: stroke; stroke-linejoin: round; pointer-events: none; }
.legend { display: flex; flex-wrap: wrap; gap: 16px; padding: 10px 16px; font-size: 12px; color: var(--muted); border-top: 1px solid var(--line); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }

/* Detalhe */
.det-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-start; gap: 12px; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.det-head .eyebrow { color: var(--orange-text); letter-spacing: .06em; }
.det-head h3 { font-size: 20px; font-weight: 700; }
.det-cols, .det-row { display: grid; grid-template-columns: minmax(0, 1fr) 80px 100px 92px; gap: 8px; }
.det-cols { padding: 8px 16px; font-size: 12px; color: var(--muted); border-bottom: 1px solid var(--line-soft); }
.det-list { max-height: 320px; overflow-y: auto; padding: 4px 16px 10px; }
.det-row { align-items: center; min-height: 34px; border-bottom: 1px solid #F0F2EE; }
.det-row .nmw { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.det-row .num { text-align: right; font-size: 13px; }
.status-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 4px; font-size: 13px; }
.status { display: inline-block; padding: 3px 8px; border-radius: 6px; font-size: 12px; font-weight: 700; }
.status.ok { background: var(--blue-soft); color: var(--blue-dark); }
.status.weak { background: var(--red-soft); color: var(--red); }
.tag.sim { background: var(--blue-soft); color: var(--blue-dark); }
.tag { display: inline-block; padding: 1px 6px; border-radius: 4px; background: #FBE7DB; color: #8A3410; font-size: 11px; font-weight: 600; }

/* Planilha */
.modal { position: fixed; inset: 0; z-index: 50; background: rgba(23, 32, 27, .45); display: flex; justify-content: center; padding: 24px; }
.modal[hidden] { display: none; }
.sheet { flex: 1 1 auto; max-width: 1280px; min-width: 0; background: var(--panel); border-radius: 14px; display: flex; flex-direction: column; overflow: hidden; }
.sheet-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.sheet-head h2 { font-size: 18px; font-weight: 700; }
.sheet-msg { padding: 8px 20px; background: #EEF4FB; color: var(--blue-dark); font-size: 13px; }
.sheet-body { flex: 1 1 auto; overflow: auto; min-height: 0; }
.tbl { border-collapse: collapse; width: 100%; min-width: 1030px; font-size: 13px; }
.tbl th { position: sticky; top: 0; background: var(--bg); text-align: left; font-size: 12px; font-weight: 600; color: #3E4842; padding: 8px; border-bottom: 1px solid var(--field); border-right: 1px solid var(--line); white-space: nowrap; }
.tbl td { padding: 6px 8px; border-bottom: 1px solid var(--line-soft); border-right: 1px solid var(--line-soft); white-space: nowrap; max-width: 280px; overflow: hidden; text-overflow: ellipsis; }
.tbl td.num { font-size: 12.5px; }
.tbl tr.center td { background: var(--orange-soft); }
.tbl tr.center td.nm { font-weight: 700; }
.tbl td.t-center { color: #8A3410; }
.tbl td.t-icp { color: var(--orange-text); }
.tbl td.t-zone { color: var(--muted); }
.tbl td.t-sim { color: var(--blue-dark); }
.tbl td.s-ok { color: var(--blue-dark); }
.tbl td.s-weak { color: var(--red); font-weight: 600; }
.sheet-foot { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 8px; padding: 10px 20px; border-top: 1px solid var(--line); font-size: 13px; color: var(--muted); }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 8px; font-size: 13px; z-index: 60; }

@media (max-width: 720px) {
  .main { padding: 12px; }
  #map { height: 420px; }
  .modal { padding: 0; }
  .sheet { border-radius: 0; }
}
@media print {
  .side, .list-card, .legend, .btn { display: none !important; }
}
