:root {
  --azul: #0a4d8c;
  --azul-claro: #1f7fd1;
  --azul-bg: #eef5fb;
  --verde: #1f9d57;
  --amarelo: #e6a100;
  --vermelho: #d6453d;
  --tinta: #16202c;
  --cinza: #5d6b7a;
  --linha: #e4eaf0;
  --fundo: #f5f7fa;
  --card: #ffffff;
  --sombra-sm: 0 1px 3px rgba(16, 42, 67, .06);
  --sombra: 0 4px 16px rgba(16, 42, 67, .08);
  --sombra-lg: 0 12px 32px rgba(16, 42, 67, .12);
  --raio: 16px;
  --raio-sm: 10px;
}

/* ---------- TEMA ESCURO ---------- */
html[data-theme="dark"] {
  --azul: #5aa6ec;
  --azul-claro: #6db4f2;
  --azul-bg: #1a2738;
  --verde: #34c97e;
  --amarelo: #f0b429;
  --vermelho: #ef6a62;
  --tinta: #e8eef5;
  --cinza: #9fb0c2;
  --linha: #2a3a4f;
  --fundo: #0e1722;
  --card: #16212f;
  --sombra-sm: 0 1px 3px rgba(0, 0, 0, .3);
  --sombra: 0 4px 16px rgba(0, 0, 0, .35);
  --sombra-lg: 0 12px 32px rgba(0, 0, 0, .5);
}
html[data-theme="dark"] .topbar { background: rgba(16, 24, 35, .85); }
html[data-theme="dark"] .brand h1 { color: var(--tinta); }
html[data-theme="dark"] .filter input,
html[data-theme="dark"] .filter select,
html[data-theme="dark"] .input-icon input,
html[data-theme="dark"] .btn-ghost,
html[data-theme="dark"] .btn-tool,
html[data-theme="dark"] .tema-btn,
html[data-theme="dark"] .menu-btn,
html[data-theme="dark"] .map-btn { background: var(--card); border-color: var(--linha); color: var(--tinta); }
/* chips mantêm a cor da situação no escuro */
html[data-theme="dark"] .chip { background: var(--card); border-color: var(--linha); }
html[data-theme="dark"] .chip.is-on { border-color: currentColor; background: color-mix(in srgb, currentColor 22%, var(--card)); }
html[data-theme="dark"] .filter input::placeholder,
html[data-theme="dark"] .input-icon input::placeholder { color: #7d8ea0; }
html[data-theme="dark"] .af-item { background: #1b2a3d; }
html[data-theme="dark"] .btn-tool, html[data-theme="dark"] .btn-load { color: var(--azul); }
html[data-theme="dark"] .btn-load { background: #1b2a3d; border-color: var(--azul-claro); }
html[data-theme="dark"] .hero__update { background: #1b2a3d; }
html[data-theme="dark"] .obras-table thead th { background: #1b2a3d; }
html[data-theme="dark"] .chart-card h4 { color: var(--azul); }
html[data-theme="dark"] .badge--andamento { background: #15324d; color: #8fc4f5; }
html[data-theme="dark"] .badge--concluida { background: #143626; color: #6fdca0; }
html[data-theme="dark"] .badge--atrasada { background: #3a2f10; color: #f0c552; }
html[data-theme="dark"] .badge--paralisada { background: #3d1f1c; color: #f29089; }
html[data-theme="dark"] .footer { background: #0a121b; }
html[data-theme="dark"] .legend, html[data-theme="dark"] .leaflet-popup-content-wrapper { background: var(--card); color: var(--tinta); }
html[data-theme="dark"] .leaflet-popup-tip { background: var(--card); }
html[data-theme="dark"] #map { filter: brightness(.85) contrast(1.05); }

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: "Inter", system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  color: var(--tinta);
  background: var(--fundo);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--azul-claro); }
h1, h2, h3, h4 { letter-spacing: -.01em; }

/* ---------- TOPBAR ---------- */
.topbar {
  position: sticky; top: 0; z-index: 1000;
  background: rgba(255,255,255,.85);
  backdrop-filter: saturate(180%) blur(10px);
  border-bottom: 1px solid var(--linha);
}
.topbar__inner {
  position: relative;
  max-width: 1200px; margin: 0 auto; padding: .7rem 1.3rem;
  display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: .7rem; }
.brand__mark { width: 42px; height: 42px; display: grid; place-items: center; flex: none; }
.brand__mark img { display: block; width: 42px; height: 42px; object-fit: contain; }
.brand h1 { font-size: 1.15rem; margin: 0; color: var(--azul); font-weight: 800; }
.brand p { margin: 0; font-size: .78rem; color: var(--cinza); }
.topbar__right { display: flex; align-items: center; gap: 1.1rem; }
.topbar__nav { display: flex; gap: 1.3rem; flex-wrap: wrap; }
.tema-btn {
  width: 38px; height: 38px; border-radius: 10px; border: 1px solid var(--linha);
  background: var(--card); cursor: pointer; font-size: 1.05rem; line-height: 1;
  display: grid; place-items: center; box-shadow: var(--sombra-sm);
}
.tema-btn:hover { background: var(--azul-bg); }
.menu-btn {
  display: none; width: 38px; height: 38px; border-radius: 10px; border: 1px solid var(--linha);
  background: var(--card); cursor: pointer; color: var(--azul); place-items: center; box-shadow: var(--sombra-sm);
}
.menu-btn:hover { background: var(--azul-bg); }
.topbar__nav a {
  color: var(--cinza); text-decoration: none; font-size: .92rem; font-weight: 600;
  padding: .25rem 0; border-bottom: 2px solid transparent;
}
.topbar__nav a:hover { color: var(--azul); border-bottom-color: var(--azul-claro); }

/* ---------- LAYOUT ---------- */
main { max-width: 1200px; margin: 0 auto; padding: 0 1.3rem 3rem; }
.block { margin-top: 2.6rem; }
.block__head h3 { display: flex; align-items: center; gap: .6rem; font-size: 1.4rem; margin: 0 0 .2rem; font-weight: 800; }
.block__head p { margin: 0 0 1rem; color: var(--cinza); font-size: .95rem; }
.num {
  display: inline-flex; align-items: center; justify-content: center;
  width: 1.9rem; height: 1.9rem; border-radius: 10px;
  background: linear-gradient(135deg, var(--azul), var(--azul-claro)); color: #fff; font-size: 1rem; font-weight: 800;
}

/* ---------- HERO ---------- */
.hero {
  margin-top: .85rem;
  background:
    radial-gradient(120% 140% at 100% 0%, rgba(31,127,209,.12), transparent 60%),
    var(--card);
  border: 1px solid var(--linha);
  border-radius: var(--raio);
  padding: 1.7rem 1.8rem;
  box-shadow: var(--sombra-sm);
}
.hero__text h2 { margin: 0 0 .3rem; font-size: 1.85rem; color: var(--azul); font-weight: 800; }
.hero__text p { margin: 0 0 1.3rem; color: var(--cinza); font-size: 1.05rem; }
.hero__update {
  display: inline-block; font-size: .82rem !important; font-weight: 600; color: var(--azul) !important;
  background: var(--azul-bg); padding: .3rem .7rem; border-radius: 999px; margin: 0 0 1.2rem !important;
}

/* ---------- INSIGHTS (carrossel) ---------- */
.insights {
  position: relative; margin: 0 0 1.4rem;
  background:
    radial-gradient(120% 180% at 0% 0%, rgba(255,255,255,.18), transparent 45%),
    linear-gradient(115deg, #073a6b, var(--azul) 55%, var(--azul-claro));
  border-radius: var(--raio); padding: .4rem 2.6rem; overflow: hidden;
  box-shadow: var(--sombra);
}
.insights::before {
  content: ""; position: absolute; right: -40px; top: -40px; width: 160px; height: 160px;
  background: radial-gradient(circle, rgba(255,255,255,.12), transparent 70%); pointer-events: none;
}
.ins-viewport { overflow: hidden; }
.ins-track { display: flex; transition: transform .5s cubic-bezier(.4,0,.2,1); }
.ins-slide {
  flex: 0 0 100%; display: flex; align-items: center; justify-content: center; gap: .9rem;
  padding: 1rem 1.2rem 1.5rem; color: #fff; min-height: 64px; text-align: center;
}
.ins-slide .ins-ico {
  font-size: 1.5rem; width: 46px; height: 46px; flex: none; display: grid; place-items: center;
  background: rgba(255,255,255,.18); border-radius: 12px;
}
.ins-slide .ins-txt { font-size: 1.02rem; line-height: 1.4; }
.ins-slide .ins-txt b { font-weight: 800; }
.ins-slide .ins-txt .ins-big { font-size: 1.45rem; font-weight: 800; letter-spacing: -.02em; margin-right: .1rem; }
.ins-nav {
  position: absolute; top: 50%; transform: translateY(-50%); z-index: 2;
  width: 30px; height: 30px; border-radius: 50%; border: none; cursor: pointer;
  background: rgba(255,255,255,.22); color: #fff; font-size: 1.3rem; line-height: 1;
  display: grid; place-items: center; transition: background .15s;
}
.ins-nav:hover { background: rgba(255,255,255,.4); }
.ins-prev { left: .5rem; } .ins-next { right: .5rem; }
.ins-dots { position: absolute; bottom: .55rem; left: 0; right: 0; display: flex; justify-content: center; gap: .35rem; }
.ins-dots button {
  width: 7px; height: 7px; border-radius: 50%; border: none; padding: 0; cursor: pointer;
  background: rgba(255,255,255,.4); transition: background .15s, width .15s;
}
.ins-dots button.is-on { background: #fff; width: 18px; border-radius: 4px; }

/* ---------- FILTROS ---------- */
.filters { display: flex; gap: .8rem; align-items: end; flex-wrap: wrap; }
.filter { display: flex; flex-direction: column; gap: .3rem; min-width: 170px; }
.filter--grow { flex: 1 1 280px; }
.filter label { font-size: .74rem; font-weight: 700; color: var(--cinza); text-transform: uppercase; letter-spacing: .4px; }
.filter input, .filter select, .input-icon input {
  padding: .62rem .75rem; border: 1px solid #cdd8e3; border-radius: var(--raio-sm);
  font-size: .95rem; background: #fff; color: var(--tinta); font-family: inherit; width: 100%;
}
.filter select { cursor: pointer; }
.filter input:focus, .filter select:focus, .input-icon input:focus {
  outline: none; border-color: var(--azul-claro); box-shadow: 0 0 0 3px rgba(31,127,209,.15);
}
.input-icon { position: relative; display: flex; align-items: center; }
.input-icon > span { position: absolute; left: .7rem; font-size: .9rem; opacity: .6; pointer-events: none; }
.input-icon > span.search-ico { display: flex; opacity: 1; color: var(--cinza); }
.input-icon > span.search-ico svg { display: block; }
.input-icon input { padding-left: 2.1rem; }
.input-icon--lg { width: 100%; max-width: 520px; }

.btn-ghost {
  padding: .64rem 1.1rem; border: 1px solid #cdd8e3; background: #fff;
  border-radius: var(--raio-sm); cursor: pointer; font-size: .9rem; font-weight: 600; color: var(--cinza);
  white-space: nowrap; font-family: inherit;
}
.btn-ghost:hover { background: var(--azul-bg); border-color: var(--azul-claro); color: var(--azul); }

/* ---------- KPIs ---------- */
.kpis { margin-top: 1.2rem; display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem; }
.kpi {
  background: var(--card); border-radius: var(--raio); padding: 1.1rem 1.2rem;
  box-shadow: var(--sombra-sm); border: 1px solid var(--linha);
  display: flex; align-items: center; gap: .9rem; transition: box-shadow .2s, transform .2s;
}
.kpi:hover { box-shadow: var(--sombra); transform: translateY(-2px); }
.kpi__ico {
  font-size: 1.3rem; width: 46px; height: 46px; flex: none; display: grid; place-items: center;
  background: var(--azul-bg); border-radius: 12px;
}
.kpi--money .kpi__ico { background: #e6f6ec; }
.kpi--alert .kpi__ico { background: #fdeceb; }
.kpi > div { display: flex; flex-direction: column; line-height: 1.2; min-width: 0; }
.kpi__label { font-size: .76rem; color: var(--cinza); font-weight: 700; text-transform: uppercase; letter-spacing: .3px; }
.kpi__value { font-size: 1.65rem; font-weight: 800; color: var(--tinta); }
.kpi--money .kpi__value { color: var(--verde); }
.kpi--alert .kpi__value { color: var(--vermelho); }
.kpi__hint { font-size: .78rem; color: var(--cinza); }

/* ---------- CHIPS DO MAPA ---------- */
.map-chips { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; margin-bottom: .8rem; }
.map-chips__lbl { font-size: .82rem; font-weight: 700; color: var(--cinza); margin-right: .2rem; }
.chip {
  display: inline-flex; align-items: center; gap: .45rem;
  padding: .4rem .8rem; border-radius: 999px; border: 1px solid #cdd8e3;
  background: #fff; color: var(--cinza); font-size: .85rem; font-weight: 600; cursor: pointer;
  font-family: inherit; transition: all .15s; opacity: .55;
}
.chip__dot { width: 9px; height: 9px; border-radius: 50%; background: currentColor; }
.chip--andamento { color: var(--azul-claro); }
.chip--atrasada  { color: var(--amarelo); }
.chip--paralisada { color: var(--vermelho); }
.chip--concluida { color: var(--verde); }
.chip:hover { opacity: .85; }
.chip.is-on { opacity: 1; border-color: currentColor; background: color-mix(in srgb, currentColor 12%, #fff); }

/* ---------- MAPA ---------- */
.map-wrap { position: relative; }
#map {
  height: 480px; width: 100%;
  border-radius: var(--raio); box-shadow: var(--sombra); border: 1px solid var(--linha); z-index: 1;
}
.map-wrap:fullscreen { background: #fff; padding: 0; }
.map-wrap:fullscreen #map { height: 100%; border-radius: 0; border: none; }
.map-btn {
  position: absolute; top: 12px; right: 12px; z-index: 600;
  width: 38px; height: 38px; border-radius: 10px; border: 1px solid var(--linha);
  background: #fff; cursor: pointer; font-size: 1.1rem; color: var(--azul);
  box-shadow: var(--sombra-sm); display: grid; place-items: center;
}
.map-btn:hover { background: var(--azul-bg); }
#btn-fit { top: 12px; }
#btn-fullscreen { top: 56px; }
.map-btn--geo { top: 100px; }
.map-hint {
  position: absolute; inset: 0; z-index: 550; margin: auto; width: max-content; height: max-content;
  padding: .6rem 1rem; background: rgba(16,32,44,.82); color: #fff; border-radius: 10px;
  font-size: .95rem; pointer-events: none; opacity: 0; transition: opacity .25s;
}
.map-hint.show { opacity: 1; }
.map-hint kbd {
  background: #fff; color: #16202c; border-radius: 5px; padding: .05rem .4rem; font-size: .8rem;
  font-family: inherit; font-weight: 700;
}
/* cluster colorido pela situação predominante */
.cluster-wrap { background: transparent !important; }
.cluster-ico {
  display: grid; place-items: center; border-radius: 50%; color: #fff; font-weight: 800;
  background: var(--cc); border: 2px solid #fff;
  box-shadow: 0 0 0 5px color-mix(in srgb, var(--cc) 35%, transparent), 0 2px 6px rgba(0,0,0,.3);
}
.cluster-ico span { font-size: .82rem; text-shadow: 0 1px 2px rgba(0,0,0,.35); }

.legend {
  position: absolute; right: 12px; bottom: 12px; z-index: 500;
  list-style: none; margin: 0; padding: .6rem .8rem;
  background: rgba(255,255,255,.96); border-radius: 10px; box-shadow: var(--sombra-sm);
  font-size: .8rem; display: grid; gap: .25rem;
}
.legend li { display: flex; align-items: center; gap: .45rem; }
.dot { width: 11px; height: 11px; border-radius: 50%; display: inline-block; }
.dot--andamento { background: var(--azul-claro); }
.dot--concluida { background: var(--verde); }
.dot--atrasada { background: var(--amarelo); }
.dot--paralisada { background: var(--vermelho); }

/* ---------- GRÁFICOS ---------- */
/* ---------- EXECUÇÃO CONTRATUAL (gauge + cards) ---------- */
.exec-panel {
  display: grid; grid-template-columns: minmax(220px, 280px) 1fr; gap: 1rem;
  margin-bottom: 1rem;
}
.exec-gauge {
  background: var(--card); border: 1px solid var(--linha); border-radius: var(--raio);
  box-shadow: var(--sombra-sm); padding: 1.2rem 1.3rem;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
}
.exec-gauge__title { margin: 0 0 .4rem; font-size: 1rem; color: var(--azul); font-weight: 700; text-align: center; }
.exec-gauge__box { position: relative; width: 100%; height: 180px; }
.exec-gauge__center {
  position: absolute; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; pointer-events: none; padding-top: 1.2rem;
}
.exec-gauge__center strong { font-size: 2.1rem; font-weight: 800; color: var(--tinta); line-height: 1; letter-spacing: -.02em; }
.exec-gauge__center span { font-size: .78rem; color: var(--cinza); margin-top: .25rem; }
.exec-cards { display: grid; grid-template-columns: repeat(3, 1fr); grid-auto-rows: 1fr; gap: .8rem; }
.exec-card {
  background: var(--card); border: 1px solid var(--linha); border-radius: var(--raio);
  box-shadow: var(--sombra-sm); padding: 1rem 1.1rem; display: flex; flex-direction: column; justify-content: center; gap: .35rem;
}
/* Card "Contrato + aditivos" ancora a coluna da direita, ocupando as 2 linhas */
.exec-card--strong {
  grid-column: 3; grid-row: 1 / span 2;
  border-color: var(--azul-claro); background: var(--azul-bg);
  align-items: center; text-align: center; gap: .5rem;
}
.exec-card__lbl { font-size: .76rem; color: var(--cinza); text-transform: uppercase; letter-spacing: .3px; font-weight: 700; display: flex; align-items: center; gap: .35rem; }
.exec-card--strong .exec-card__lbl { justify-content: center; }
.exec-card__val { font-size: 1.5rem; font-weight: 800; color: var(--tinta); letter-spacing: -.02em; }
.exec-card--strong .exec-card__val { color: var(--azul); font-size: 1.95rem; }

/* Ícone (i) com tooltip */
.info-i {
  flex: none; width: 16px; height: 16px; cursor: help; vertical-align: middle;
  display: inline-grid; place-items: center; color: var(--cinza); position: relative; line-height: 0;
}
.info-i svg { display: block; }
.info-i:hover, .info-i:focus { color: var(--azul); outline: none; }
/* Tooltip fica fora do layout quando oculto (display:none) — senão seu
   max-content propaga overflow horizontal e gera espaço em branco no mobile. */
.info-i::after {
  content: attr(data-tip); display: none; position: absolute; bottom: calc(100% + 8px); left: 50%; transform: translateX(-50%);
  width: max-content; max-width: 240px; white-space: normal; text-transform: none; letter-spacing: normal;
  background: #0f2233; color: #fff; font-size: .76rem; font-weight: 500; line-height: 1.35;
  padding: .55rem .7rem; border-radius: 8px; box-shadow: var(--sombra); z-index: 50; pointer-events: none;
}
.info-i::before {
  content: ""; display: none; position: absolute; bottom: calc(100% + 2px); left: 50%; transform: translateX(-50%);
  border: 6px solid transparent; border-top-color: #0f2233; z-index: 50;
}
.info-i:hover::after, .info-i:focus::after, .info-i:hover::before, .info-i:focus::before { display: block; }

.charts { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1rem; }
.chart-card { background: var(--card); border-radius: var(--raio); padding: 1.2rem 1.3rem; box-shadow: var(--sombra-sm); border: 1px solid var(--linha); }
.chart-card h4 { margin: 0 0 .9rem; font-size: 1rem; color: var(--azul); font-weight: 700; }
.chart-box { position: relative; height: 330px; }

/* ---------- CARDS DE SITUAÇÃO (clicáveis) ---------- */
.status-cards { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem; }
.status-card {
  --c: var(--cinza);
  position: relative; background: var(--card); border-radius: var(--raio); padding: 1.25rem 1.1rem 1.15rem;
  box-shadow: var(--sombra-sm); border: 1px solid var(--linha); text-align: center; cursor: pointer;
  transition: box-shadow .18s, transform .18s, border-color .18s, background .18s;
}
.status-card:hover { box-shadow: var(--sombra); transform: translateY(-2px); border-color: var(--c); }
.status-card.is-active {
  border-color: var(--c);
  background: color-mix(in srgb, var(--c) 9%, var(--card));
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--c) 25%, transparent);
}
.status-card .sc-num { font-size: 2.3rem; font-weight: 800; line-height: 1; color: var(--c); }
.status-card .sc-label { display: inline-flex; align-items: center; gap: .4rem; font-size: .95rem; font-weight: 700; margin-top: .45rem; }
.status-card .sc-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--c); }
.status-card .sc-sub { font-size: .8rem; color: var(--cinza); margin-top: .3rem; }
.status-card .sc-check {
  position: absolute; top: .6rem; right: .7rem; width: 18px; height: 18px; border-radius: 50%;
  background: var(--c); color: #fff; font-size: .7rem; display: none; place-items: center; font-weight: 800;
}
.status-card.is-active .sc-check { display: grid; }
.status-hint { font-size: .82rem; color: var(--azul-claro); font-weight: 600; }

/* ---------- ATRASO: FAIXAS DE SEVERIDADE ---------- */
.atraso-faixas {
  margin-top: 1rem; background: var(--card); border: 1px solid var(--linha);
  border-radius: var(--raio); box-shadow: var(--sombra-sm); padding: 1.2rem 1.3rem;
}
.atraso-faixas h4 { margin: 0 0 .9rem; font-size: 1rem; color: var(--amarelo); font-weight: 700; }
.atraso-faixas .af-sub { color: var(--cinza); font-weight: 500; font-size: .85rem; }
.af-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem; }
.af-item {
  text-align: center; padding: .6rem; border-radius: var(--raio-sm); background: var(--azul-bg);
  border: 2px solid transparent; cursor: pointer; font-family: inherit; width: 100%;
  transition: border-color .15s, transform .12s, box-shadow .15s;
}
.af-item:hover { transform: translateY(-1px); box-shadow: var(--sombra-sm); }
.af-item.is-active { border-color: var(--amarelo); background: color-mix(in srgb, var(--amarelo) 12%, var(--azul-bg)); }

/* Badges de status acima da tabela (mesma linguagem dos chips do mapa) */
.tabela-chips { display: flex; gap: .5rem; flex-wrap: wrap; margin-bottom: .8rem; }
.tchip {
  display: inline-flex; align-items: center; gap: .45rem;
  padding: .4rem .9rem; border-radius: 999px; border: 1px solid #cdd8e3;
  background: #fff; color: var(--cinza); font-size: .85rem; font-weight: 600; cursor: pointer;
  font-family: inherit; transition: all .15s; opacity: .6;
}
.tchip__dot { width: 9px; height: 9px; border-radius: 50%; background: currentColor; }
.tchip--andamento { color: var(--azul-claro); }
.tchip--atrasada { color: var(--amarelo); }
.tchip--paralisada { color: var(--vermelho); }
.tchip--concluida { color: var(--verde); }
.tchip:hover { opacity: .9; }
.tchip.is-on { opacity: 1; border-color: currentColor; background: color-mix(in srgb, currentColor 12%, #fff); }
html[data-theme="dark"] .tchip { background: var(--card); border-color: var(--linha); }
html[data-theme="dark"] .tchip.is-on { border-color: currentColor; background: color-mix(in srgb, currentColor 22%, var(--card)); }

/* Campo de busca sem ícone (lista completa) */
.input-icon.no-ico input { padding-left: .75rem; }

/* Botão "Ver detalhes" no popup do mapa */
.popup-foot {
  display: flex; align-items: center; justify-content: space-between; gap: .9rem;
  margin-top: .7rem; padding-top: .55rem; border-top: 1px solid var(--linha);
}
.popup-btn {
  flex: none; padding: .42rem .9rem; border: none; cursor: pointer; white-space: nowrap;
  background: var(--azul); color: #fff; border-radius: 8px; font-family: inherit;
  font-size: .85rem; font-weight: 700; transition: background .15s;
}
.popup-btn:hover { background: var(--azul-claro); }

/* Botão de fechar do balão (maior, mais afastado do canto) */
.leaflet-popup-close-button {
  width: 28px !important; height: 28px !important; top: 6px !important; right: 6px !important;
  font: 700 20px/26px Tahoma, sans-serif !important; color: var(--cinza) !important;
  border-radius: 50%; display: flex !important; align-items: center; justify-content: center;
  transition: background .15s, color .15s;
}
.leaflet-popup-close-button:hover { background: var(--azul-bg) !important; color: var(--vermelho) !important; }
.leaflet-popup-content { margin: 14px 22px 14px 14px !important; }
.af-item .af-num { font-size: 1.7rem; font-weight: 800; line-height: 1; }
.af-item .af-lbl { font-size: .8rem; color: var(--cinza); margin-top: .3rem; }

/* ---------- TABELA ---------- */
.table-toolbar { margin-bottom: .8rem; display: flex; gap: .7rem; align-items: center; flex-wrap: wrap; }
.table-toolbar .input-icon--lg { flex: 1 1 320px; }
.table-toolbar__btns { display: flex; gap: .5rem; flex-wrap: wrap; }
.btn-tool {
  padding: .55rem .9rem; border: 1px solid #cdd8e3; background: var(--card); color: var(--azul);
  border-radius: var(--raio-sm); cursor: pointer; font-size: .88rem; font-weight: 600; font-family: inherit; white-space: nowrap;
}
.btn-tool:hover { background: var(--azul-bg); border-color: var(--azul-claro); }
.load-more { display: flex; justify-content: center; margin-top: 1rem; }
.btn-load {
  padding: .7rem 1.6rem; border: 1px solid var(--azul-claro); background: var(--azul-bg); color: var(--azul);
  border-radius: 999px; cursor: pointer; font-size: .92rem; font-weight: 700; font-family: inherit;
  transition: background .15s, transform .1s;
}
.btn-load:hover { background: color-mix(in srgb, var(--azul-claro) 18%, var(--card)); }
.btn-load:active { transform: scale(.98); }
.table-wrap { background: var(--card); border-radius: var(--raio); box-shadow: var(--sombra-sm); border: 1px solid var(--linha); overflow: hidden; overflow-x: auto; }
.obras-table { width: 100%; border-collapse: collapse; font-size: .92rem; min-width: 720px; }
.obras-table thead th {
  background: #f3f7fb; color: var(--azul); text-align: left; padding: .8rem 1rem;
  font-size: .76rem; text-transform: uppercase; letter-spacing: .4px; font-weight: 700;
  position: sticky; top: 0; white-space: nowrap; user-select: none;
}
.obras-table th.sortable { cursor: pointer; }
.obras-table th.sortable:hover { background: var(--azul-bg); }
.obras-table th.sortable::after { content: " ↕"; opacity: .35; font-size: .85em; }
.obras-table th.sort-asc::after { content: " ↑"; opacity: 1; }
.obras-table th.sort-desc::after { content: " ↓"; opacity: 1; }
.obras-table th.num-col, .obras-table td.num-col { text-align: right; white-space: nowrap; }
.obras-table td.nowrap { white-space: nowrap; }
.obras-table tbody tr { border-top: 1px solid var(--linha); cursor: pointer; }
.obras-table tbody tr:hover { background: var(--azul-bg); }
.obras-table td { padding: .75rem 1rem; vertical-align: middle; }
.obras-table .obra-nome { font-weight: 600; }
.obras-table .obra-id { font-size: .76rem; color: var(--cinza); }
.mini-bar { height: 7px; background: var(--linha); border-radius: 4px; overflow: hidden; min-width: 70px; margin-top: 3px; }
.mini-bar > span { display: block; height: 100%; }

.badge { display: inline-block; padding: .25rem .65rem; border-radius: 999px; font-size: .76rem; font-weight: 700; white-space: nowrap; }
.badge--andamento { background: #e3f0fb; color: #155fa0; }
.badge--concluida { background: #e3f6ea; color: #15783f; }
.badge--atrasada { background: #fdf2d6; color: #8a6500; }
.badge--paralisada { background: #fbe4e2; color: #a52f29; }

.empty-msg { padding: 2rem; text-align: center; color: var(--cinza); }
.inline-nota { font-size: .85rem; color: var(--azul-claro); font-weight: 600; }

/* ---------- FOOTER ---------- */
.footer { background: #0a3357; color: #c7dcf0; margin-top: 3.5rem; }
.footer p { max-width: 1200px; margin: 0 auto; padding: 1.6rem 1.3rem; font-size: .85rem; }
.footer a { color: #8fc6f5; }
.footer em { color: #fff; font-style: normal; font-weight: 600; }
.footer__credit {
  text-align: center; padding: 1rem 1.3rem 1.6rem !important;
  border-top: 1px solid rgba(255,255,255,.1); color: #9fbdd8;
}
.footer__credit a { font-weight: 700; color: #fff; }

/* ---------- MODAL ---------- */
.modal { position: fixed; inset: 0; z-index: 2000; display: flex; align-items: center; justify-content: center; padding: 1rem; }
.modal[hidden] { display: none; }
.modal__backdrop { position: absolute; inset: 0; background: rgba(10,30,50,.55); backdrop-filter: blur(2px); }
.modal__card {
  position: relative; background: var(--card); border-radius: var(--raio); max-width: 560px; width: 100%;
  max-height: 90vh; overflow-y: auto; box-shadow: var(--sombra-lg); padding: 1.8rem;
  border: 1px solid var(--linha);
}
html[data-theme="dark"] .modal__backdrop { background: rgba(0,0,0,.6); }
html[data-theme="dark"] .modal .m-v { color: var(--tinta); }
html[data-theme="dark"] .modal .m-action { background: #1b2a3d; color: #8fc4f5; }
.modal__close { position: absolute; top: .6rem; right: .9rem; border: none; background: none; font-size: 1.9rem; cursor: pointer; color: var(--cinza); line-height: 1; }
.modal__close:hover { color: var(--vermelho); }
.modal h3 { margin: 0 1.5rem .4rem 0; color: var(--azul); font-size: 1.3rem; font-weight: 800; }
.modal .m-id { font-size: .82rem; color: var(--cinza); margin-bottom: 1rem; }
.modal .m-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .85rem 1.3rem; margin-top: 1rem; }
.modal .m-item .m-k, .modal .m-obj .m-k { font-size: .72rem; color: var(--cinza); text-transform: uppercase; letter-spacing: .3px; }
.modal .m-item .m-v { font-weight: 600; }
.modal .m-link {
  font-weight: 600; color: var(--azul-claro); text-decoration: underline; text-underline-offset: 2px;
  display: inline-flex; align-items: center; gap: .2rem;
}
.modal .m-link:hover { color: var(--azul); }
.modal .m-link svg { flex: none; }
.modal .m-bar-wrap { margin-top: 1.3rem; }
.modal .m-bar-wrap .m-k { font-size: .82rem; color: var(--cinza); margin-bottom: .35rem; }
.modal .m-bar { height: 12px; background: var(--linha); border-radius: 6px; overflow: hidden; }
.modal .m-bar > span { display: block; height: 100%; background: var(--verde); }
.modal .m-obj { margin-top: 1.1rem; }
.modal .m-obj p { margin: .25rem 0 0; font-size: .9rem; line-height: 1.45; }
.modal .m-actions {
  display: flex; flex-wrap: wrap; gap: .55rem; margin-top: 1.4rem;
  padding-top: 1.2rem; border-top: 1px solid var(--linha);
}
.modal .m-action {
  display: inline-flex; align-items: center; gap: .4rem;
  padding: .5rem .85rem; border-radius: 999px; border: 1px solid var(--linha);
  background: var(--azul-bg); color: var(--azul); font-size: .85rem; font-weight: 600; text-decoration: none;
  transition: background .15s, border-color .15s;
}
.modal .m-action:hover { background: color-mix(in srgb, var(--azul-claro) 18%, var(--card)); border-color: var(--azul-claro); }

.kpis-nota {
  max-width: 1200px; margin: .9rem auto 0; padding: .7rem .9rem;
  font-size: .82rem; line-height: 1.45; color: var(--cinza);
  background: var(--azul-bg); border-radius: 10px;
}
.kpis-nota strong { color: var(--tinta); font-weight: 700; }
html[data-theme="dark"] .kpis-nota { background: #14222f; }

/* Banner do topo (hero): texto centralizado no desktop */
@media (min-width: 901px) {
  .hero__text { text-align: center; }
}

/* ---------- RESPONSIVO ---------- */
@media (max-width: 900px) {
  .kpis { grid-template-columns: repeat(2, 1fr); }
  .charts { grid-template-columns: 1fr; }
  .exec-panel { grid-template-columns: 1fr; }
  .exec-cards { grid-template-columns: repeat(2, 1fr); }
  .exec-card--strong { grid-column: 1 / -1; grid-row: auto; order: 99; }
  .status-cards { grid-template-columns: repeat(2, 1fr); }
  .af-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 560px) {
  /* menu hambúrguer */
  .menu-btn { display: grid; }
  .topbar__nav {
    display: none; position: absolute; top: calc(100% + 1px); left: 0; right: 0;
    flex-direction: column; gap: 0; background: var(--card); border-bottom: 1px solid var(--linha);
    box-shadow: var(--sombra); padding: .4rem 1rem .8rem;
  }
  .topbar.menu-open .topbar__nav { display: flex; }
  .topbar__nav a { padding: .8rem .2rem; border-bottom: 1px solid var(--linha); font-size: 1rem; }
  .topbar__nav a:last-child { border-bottom: none; }

  .kpis { grid-template-columns: 1fr; }
  .filter { min-width: 100%; }
  .btn-ghost { width: 100%; }
  #map { height: 380px; }
  .hero { padding: 1.3rem; }
  .hero__text h2 { font-size: 1.5rem; }
  .modal .m-grid { grid-template-columns: 1fr; }
  .legend { font-size: .72rem; }

  /* banner sem setas no mobile (mais espaço pro texto) + swipe */
  .ins-nav { display: none; }
  .insights { padding: .3rem 1rem; }
  .ins-slide { padding: .9rem .1rem 1.6rem; }
  .ins-slide .ins-txt { font-size: .95rem; }
  .table-toolbar__btns { width: 100%; }
  .table-toolbar__btns .btn-tool { flex: 1; }
  .atraso-faixas .af-sub { display: block; margin-top: .15rem; }
}
