@import url("https://fonts.googleapis.com/css2?family=Saira:wght@400;600;700&family=Sora:wght@400;600;700&display=swap");

:root {
  --bg: #f4f7fb;
  --surface: #ffffff;
  --ink: #0b1f33;
  --muted: #5a6b7d;
  --brand: #073865;
  --brand-2: #1aa6ff;
  --line: #d7e2ee;
  --ok: #1f8a4c;
  --warn: #b7791f;
  --danger: #c53030;
  --shadow: 0 10px 30px rgba(7, 56, 101, 0.08);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body.cenario-body {
  font-family: "Sora", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(1200px 500px at 10% -10%, rgba(26, 166, 255, 0.18), transparent 60%),
    radial-gradient(900px 400px at 100% 0%, rgba(7, 56, 101, 0.12), transparent 55%),
    var(--bg);
  min-height: 100vh;
  overflow-x: hidden;
}

/* Links do dashboard; a nav usa as cores do index.css (.list-item) */
body.cenario-body .dash-wrap a,
body.cenario-body .cenario-modal-root a {
  color: inherit;
  text-decoration: none;
}

/* Espaço para a nav-bar fixa (mesmo padrão da home) */
body.cenario-body .dash-wrap {
  padding-top: calc(117px + 1rem);
  min-height: calc(100vh - 117px);
}

/* Nav mais compacta no cenário (mobile/tablet) */
@media (max-width: 1130px) {
  body.cenario-body .nav-bar {
    height: auto;
    min-height: 72px;
    padding: 18px 20px;
  }

  body.cenario-body .dash-wrap {
    padding-top: calc(72px + 0.85rem);
    min-height: 0;
  }
}

.cenario-wrap {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1.5rem 1.25rem 3rem;
}

.cenario-hero h1 {
  font-family: "Saira", sans-serif;
  font-size: clamp(1.6rem, 3vw, 2.2rem);
  color: var(--brand);
  margin-bottom: 0.35rem;
}

.cenario-hero p {
  color: var(--muted);
  max-width: 48rem;
  line-height: 1.5;
  margin-bottom: 1.25rem;
}

.cenario-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 1rem 1.1rem;
  margin-bottom: 1rem;
}

.cenario-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: end;
}

.cenario-cascata .cenario-field {
  flex: 1 1 180px;
}

.cenario-field {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  min-width: 140px;
}

.cenario-field label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.cenario-field select,
.cenario-field input,
.cenario-modal input,
.cenario-modal select {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.55rem 0.7rem;
  font: inherit;
  background: #fff;
  color: var(--ink);
  min-height: 42px;
}

.cenario-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.btn {
  border: none;
  border-radius: 10px;
  padding: 0.6rem 0.95rem;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.15s ease, opacity 0.15s ease;
}

.btn:hover {
  transform: translateY(-1px);
}

.btn-primary {
  background: var(--brand);
  color: #fff;
}

.btn-secondary {
  background: #e8f1fa;
  color: var(--brand);
}

.btn-danger {
  background: #fde8e8;
  color: var(--danger);
}

.btn-icon {
  width: 36px;
  height: 36px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
}

.btn-icon i {
  font-size: 1rem;
  line-height: 1;
}

.btn-ghost {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--muted);
}

.kpi-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
  gap: 0.45rem;
  margin-bottom: 0.55rem;
}

.kpi {
  background: #f7fbff;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.45rem 0.55rem;
}

.kpi span {
  display: block;
  font-size: 0.65rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 0.15rem;
}

.kpi strong {
  font-size: 0.95rem;
  color: var(--brand);
  font-variant-numeric: tabular-nums;
}

.cenario-diff {
  background: #fff8e8;
  border: 1px solid #f0d9a0;
  color: #7a5a12;
  border-radius: 12px;
  padding: 0.75rem 0.9rem;
  margin-bottom: 0.85rem;
  font-size: 0.92rem;
  line-height: 1.45;
}

.cenario-diff.hidden,
.hidden {
  display: none !important;
}

.cenario-note {
  color: var(--muted);
  font-size: 0.85rem;
  line-height: 1.45;
  margin-bottom: 0.85rem;
}

.subtabs {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
  margin-bottom: 0;
}

.subtab {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--muted);
  border-radius: 999px;
  padding: 0.3rem 0.7rem;
  font: inherit;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
}

.subtabs-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-bottom: 0.85rem;
}

.nota-slot {
  display: inline-flex;
  align-items: center;
}

.painel-toolbar {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-wrap: wrap;
  margin-bottom: 0.4rem;
}

.filtro-status {
  color: var(--muted);
  font-size: 0.82rem;
  margin: 0;
}

.info-hint {
  position: relative;
  display: inline-flex;
  align-items: center;
  vertical-align: middle;
}

.info-hint-btn {
  width: 28px;
  height: 28px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #f7fbff;
  color: var(--brand);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
  font-size: 0.95rem;
  line-height: 1;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.info-hint-btn:hover,
.info-hint.aberto .info-hint-btn,
.info-hint:focus-within .info-hint-btn {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
}

.info-hint-pop {
  display: none;
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  z-index: 40;
  min-width: 220px;
  max-width: min(340px, 80vw);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow);
  padding: 0.75rem 0.85rem;
  color: var(--ink);
  font-size: 0.82rem;
  line-height: 1.45;
}

.info-hint-pop p {
  margin: 0 0 0.45rem;
  color: var(--muted);
}

.info-hint-pop p:last-child {
  margin-bottom: 0;
}

.info-hint-pop strong {
  color: var(--ink);
}

.info-hint:hover .info-hint-pop,
.info-hint:focus-within .info-hint-pop,
.info-hint.aberto .info-hint-pop {
  display: block;
}

.nota-slot .info-hint-pop {
  left: auto;
  right: 0;
}

.subtab.ativo {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
}

.table-wrap {
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  border: 1px solid var(--line);
  border-radius: 10px;
  max-width: 100%;
}

table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8rem;
  min-width: 520px;
}

table.data th,
table.data td {
  padding: 0.28rem 0.45rem;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
  line-height: 1.25;
}

table.data th {
  background: #f3f8fc;
  color: var(--brand);
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  position: sticky;
  top: 0;
  padding: 0.35rem 0.45rem;
}

table.data tr:hover td {
  background: #f8fbfe;
}

table.data .cenario-actions {
  gap: 0.25rem;
  flex-wrap: nowrap;
}

table.data .btn-icon {
  width: 28px;
  height: 28px;
  min-height: 28px;
}

.badge {
  display: inline-block;
  border-radius: 999px;
  padding: 0.1rem 0.4rem;
  font-size: 0.65rem;
  font-weight: 700;
}

.badge-qp {
  background: #d9f5e5;
  color: var(--ok);
}

.badge-media {
  background: #e7f2ff;
  color: #1a5fad;
}

.badge-final {
  background: #fde8e8;
  color: var(--danger);
}

.badge-origem {
  background: #eee8ff;
  color: #5b3cc4;
}

.edit-input {
  width: 96px;
  max-width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0.2rem 0.35rem;
  font: inherit;
  font-size: 0.8rem;
  text-align: right;
  font-variant-numeric: tabular-nums;
  min-height: 28px;
}

.edit-input.edit-nome {
  width: 100%;
  min-width: 0;
  text-align: left;
  font-variant-numeric: normal;
  font-weight: 600;
}

.edit-input.edit-partido,
select.edit-partido {
  width: auto;
  min-width: 4.5rem;
  max-width: 7rem;
  text-align: left;
  font-variant-numeric: normal;
  font-weight: 600;
  cursor: pointer;
  background: #fff;
}

.cand-nome-cell {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  min-width: 0;
}

.cand-nome-cell .edit-nome {
  flex: 1;
}

.btn-mun-cand {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  min-height: 28px;
  color: var(--brand);
}

.cand-edit-meta-fields {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem 0.85rem;
  margin: 0.35rem 0 0.25rem;
}

.cand-edit-meta-fields .cenario-field {
  margin: 0;
  min-width: min(100%, 12rem);
  flex: 1;
}

.cand-edit-meta-fields .edit-nome,
.cand-edit-meta-fields .edit-partido {
  width: 100%;
  max-width: none;
}

.cenario-modal-root[aria-hidden="true"] {
  display: none;
}

.cenario-modal-root {
  position: fixed;
  inset: 0;
  background: rgba(7, 56, 101, 0.45);
  display: grid;
  place-items: center;
  z-index: 50;
  padding: 1rem;
}

.cenario-modal {
  width: min(480px, 100%);
  background: #fff;
  border-radius: 16px;
  padding: 1.1rem;
  box-shadow: var(--shadow);
}

.cenario-modal.wide {
  width: min(640px, 100%);
}

.cenario-modal select[size] {
  width: 100%;
  min-height: 12rem;
  font-size: 0.9rem;
}

.cenario-modal .dica {
  color: var(--muted);
  font-size: 0.85rem;
  line-height: 1.4;
  margin: 0.35rem 0 0.75rem;
}

.cenario-modal h3 {
  font-family: "Saira", sans-serif;
  color: var(--brand);
  margin-bottom: 0.85rem;
}

.cenario-modal .cenario-field {
  margin-bottom: 0.7rem;
}

.cenario-modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  border-radius: 999px;
  padding: 0.25rem 0.7rem;
  font-size: 0.78rem;
  font-weight: 700;
  background: #e8f1fa;
  color: var(--brand);
}

.status-pill.dirty {
  background: #fff1d6;
  color: #8a5a00;
}

.empty {
  color: var(--muted);
  padding: 1rem;
  text-align: center;
}

.cenario-bloco-titulo {
  font-family: "Saira", sans-serif;
  color: var(--brand);
  font-size: 0.95rem;
  margin: 0.35rem 0 0.4rem;
}

.legenda-filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  margin: 0.2rem 0 0.5rem;
}

.legenda-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--brand);
  border-radius: 999px;
  padding: 0.25rem 0.55rem;
  font: inherit;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.legenda-chip:hover {
  border-color: var(--brand-2);
}

.legenda-chip.ativo {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
}

.legenda-chip-votos {
  font-size: 0.7rem;
  opacity: 0.85;
  font-weight: 700;
}

.legenda-chip.ativo .legenda-chip-votos {
  opacity: 1;
}

.link-legenda {
  border: none;
  background: none;
  color: var(--brand-2);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  padding: 0;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.link-legenda:hover {
  color: var(--brand);
}

table.data tr.legenda-row.destaque td {
  background: #eef7ff;
}

table.data tr.cand-foco td {
  background: #fff8e8;
}

table.data tr.resumo-row td,
table.data tr.resumo-total td {
  background: #f7fbff;
}

table.data tr.resumo-row.foco td {
  background: #fff8e8;
}

.muted-inline {
  color: var(--muted);
  font-weight: 500;
  font-size: 0.85rem;
}

table.data tr.row-outros td {
  background: #f7f8fb;
  color: var(--muted);
}

.link-cand {
  border: none;
  background: none;
  color: var(--brand);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  padding: 0;
  text-align: left;
}

.link-cand:hover {
  color: var(--brand-2);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.btn-voltar-cands {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  border: none;
  background: none;
  color: var(--brand-2);
  font: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  padding: 0;
  margin-bottom: 0.55rem;
}

.btn-voltar-cands:hover {
  color: var(--brand);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.cand-edit-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.65rem;
}

.cand-edit-kpis {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.45rem;
  margin-bottom: 0.75rem;
}

.cand-reg-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 0.4rem;
  margin: 0.35rem 0 0.75rem;
}

.cand-reg-card {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  text-align: left;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 10px;
  padding: 0.55rem 0.65rem;
  cursor: pointer;
  font: inherit;
  color: var(--ink);
  transition: border-color 0.15s ease, background 0.15s ease;
}

.cand-reg-card strong {
  font-size: 0.8rem;
  color: var(--brand);
}

.cand-reg-card span {
  font-size: 0.7rem;
  color: var(--muted);
  line-height: 1.3;
}

.cand-reg-card:hover {
  border-color: var(--brand-2);
  background: #f3f9ff;
}

.cand-reg-card.ativo {
  border-color: var(--brand-2);
  background: #e8f4ff;
  box-shadow: inset 0 0 0 1px var(--brand-2);
}

.cand-mun-tools {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  flex-wrap: wrap;
}

.chk-inline {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.78rem;
  color: var(--muted);
  cursor: pointer;
  user-select: none;
}

.dica-inline {
  font-size: 0.75rem;
  color: var(--muted);
  margin: 0 0 0.15rem;
}

.edit-input.alterado {
  border-color: #e6b84d;
  background: rgba(230, 184, 77, 0.1);
}

table.data td.pos,
table.data td.num {
  font-variant-numeric: tabular-nums;
  text-align: right;
  white-space: nowrap;
}

table.data td.pos {
  color: var(--muted);
  width: 2.2rem;
}

.banner-sim {
  background: #eef7ff;
  border: 1px solid #c5ddf5;
  border-radius: 8px;
  padding: 0.4rem 0.6rem;
  font-size: 0.78rem;
  margin-bottom: 0.5rem;
}

@media (max-width: 720px) {
  .cenario-field {
    min-width: calc(50% - 0.4rem);
    flex: 1;
  }

  .cenario-actions {
    width: 100%;
  }

  .cenario-actions .btn:not(.btn-icon) {
    flex: 1;
  }

  .btn:not(.btn-icon) {
    flex: 1;
  }
}

/* ——— Dashboard ——— */
.dash-wrap {
  max-width: 1400px;
  margin: 0 auto;
  padding: 1rem 1.25rem 2.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  min-height: calc(100vh - 64px);
}

.dash-topbar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
}

.dash-title h1 {
  font-family: "Saira", sans-serif;
  font-size: clamp(1.35rem, 2.5vw, 1.85rem);
  color: var(--brand);
  margin-bottom: 0.2rem;
}

.dash-title p {
  color: var(--muted);
  font-size: 0.88rem;
  max-width: 36rem;
  line-height: 1.4;
}

.dash-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

.cargo-switch {
  display: inline-flex;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: #fff;
}

.cargo-opt {
  border: none;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 0.78rem;
  font-weight: 600;
  padding: 0.35rem 0.7rem;
  cursor: pointer;
  line-height: 1.2;
  transition: background 0.15s ease, color 0.15s ease;
}

.cargo-opt + .cargo-opt {
  border-left: 1px solid var(--line);
}

.cargo-opt:hover {
  background: #f3f8fc;
  color: var(--brand);
}

.cargo-opt.ativo {
  background: var(--brand);
  color: #fff;
}

.ano-badge {
  display: inline-flex;
  align-items: center;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--muted);
  background: #eef3f8;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0.3rem 0.5rem;
  letter-spacing: 0.03em;
}

.dash-actions {
  gap: 0.35rem;
}

.dash-actions .btn {
  padding: 0.35rem 0.65rem;
  font-size: 0.8rem;
  min-height: 32px;
}

.dash-actions .btn-icon {
  width: 32px;
  height: 32px;
  padding: 0;
}

.dash-field-wide {
  min-width: 200px;
}

.btn-sm {
  padding: 0.3rem 0.65rem;
  font-size: 0.8rem;
  min-height: auto;
}

.dash-grid {
  display: grid;
  grid-template-columns: minmax(280px, 340px) 1fr;
  gap: 0.85rem;
  align-items: stretch;
  flex: 1;
  min-height: 0;
}

.dash-sidebar,
.dash-main {
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.dash-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 0.9rem 1rem;
}

.dash-panel-fill {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 520px;
  max-height: calc(100vh - 220px);
  overflow: hidden;
}

.dash-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.65rem;
}

.dash-panel-head h2 {
  font-family: "Saira", sans-serif;
  font-size: 1.05rem;
  color: var(--brand);
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.lugar-breadcrumb {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  align-items: center;
  margin-bottom: 0.55rem;
  font-size: 0.8rem;
  color: var(--muted);
  min-height: 1.4rem;
}

.lugar-breadcrumb button {
  border: none;
  background: none;
  color: var(--brand);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  padding: 0;
}

.lugar-breadcrumb button:hover {
  color: var(--brand-2);
  text-decoration: underline;
}

.lugar-breadcrumb .sep {
  opacity: 0.45;
}

.lugar-breadcrumb .atual {
  color: var(--ink);
  font-weight: 600;
}

.lugar-busca {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.55rem 0.7rem;
  font: inherit;
  margin-bottom: 0.55rem;
  background: #f8fbfe;
}

.lugar-list {
  flex: 1;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  padding-right: 0.15rem;
}

.lugar-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.35rem 0.75rem;
  align-items: center;
  width: 100%;
  text-align: left;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.65rem 0.75rem;
  background: #fff;
  cursor: pointer;
  font: inherit;
  color: inherit;
  transition: border-color 0.15s ease, background 0.15s ease, transform 0.15s ease;
}

.lugar-item:hover {
  border-color: #9ec5e8;
  background: #f5faff;
  transform: translateY(-1px);
}

.lugar-item.ativo {
  border-color: var(--brand-2);
  background: linear-gradient(135deg, #eef7ff, #f7fbff);
  box-shadow: inset 3px 0 0 var(--brand-2);
}

.lugar-item .nome {
  font-weight: 600;
  color: var(--brand);
  font-size: 0.92rem;
}

.lugar-item .sub {
  grid-column: 1 / -1;
  font-size: 0.75rem;
  color: var(--muted);
}

.lugar-item .votos {
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  font-size: 0.88rem;
  color: var(--ink);
}

.lugar-item .chev {
  color: var(--brand-2);
  font-size: 0.85rem;
}

.cascata-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

.detalhe-header {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.55rem;
  padding-bottom: 0.55rem;
  margin-bottom: 0.45rem;
  border-bottom: 1px solid var(--line);
}

.detalhe-eyebrow {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  font-weight: 600;
  margin-bottom: 0.1rem;
}

.detalhe-header h2 {
  font-family: "Saira", sans-serif;
  font-size: 1.15rem;
  color: var(--brand);
}

.detalhe-meta {
  color: var(--muted);
  font-size: 0.78rem;
  margin-top: 0.15rem;
}

.detalhe-kpis {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  align-items: stretch;
}

.detalhe-kpi {
  background: #f7fbff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.35rem 0.5rem;
  min-width: 88px;
}

.detalhe-kpi span {
  display: block;
  font-size: 0.62rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.detalhe-kpi strong {
  font-size: 0.88rem;
  color: var(--brand);
  font-variant-numeric: tabular-nums;
}

.dash-main #cenario-saida {
  flex: 1;
  overflow: auto;
  min-height: 0;
  padding-right: 0.15rem;
}

.dash-wrap > .kpi-row {
  margin-bottom: 0;
}

@media (max-width: 980px) {
  /* Página rola naturalmente — evita painéis com overflow:hidden cortando conteúdo */
  body.cenario-body {
    overflow-x: clip;
  }

  body.cenario-body .dash-wrap {
    padding: calc(72px + 0.75rem) 0.75rem 2rem;
    min-height: 0;
    height: auto;
    overflow: visible;
  }

  .dash-topbar {
    flex-direction: column;
    align-items: stretch;
    gap: 0.65rem;
  }

  .dash-title p {
    font-size: 0.8rem;
  }

  .dash-controls {
    width: 100%;
    gap: 0.4rem;
  }

  .dash-grid {
    display: flex;
    flex-direction: column;
    flex: none;
    min-height: 0;
    gap: 0.75rem;
  }

  /* Conteúdo principal primeiro; locais depois */
  .dash-main {
    order: 1;
  }

  .dash-sidebar {
    order: 2;
  }

  .dash-panel {
    padding: 0.75rem;
  }

  .dash-panel-fill {
    flex: none;
    min-height: 0;
    max-height: none;
    overflow: visible;
  }

  .dash-main #cenario-saida {
    flex: none;
    overflow: visible;
    min-height: 0;
    padding-right: 0;
  }

  .painel-toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .cand-mun-tools {
    width: 100%;
  }

  .lugar-list {
    max-height: min(240px, 40vh);
    overflow: auto;
    -webkit-overflow-scrolling: touch;
  }

  .cand-edit-kpis {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .cand-edit-head {
    flex-direction: column;
  }

  .kpi-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .subtabs-row {
    flex-direction: column;
    align-items: stretch;
  }

  .subtabs {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.35rem;
  }

  .subtab {
    text-align: center;
    padding: 0.45rem 0.35rem;
    font-size: 0.72rem;
    border-radius: 10px;
  }

  .legenda-filter-bar {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 0.25rem;
    margin-right: -0.25rem;
    scrollbar-width: thin;
  }

  .legenda-chip {
    flex: 0 0 auto;
    white-space: nowrap;
  }

  .table-wrap {
    margin-left: 0;
    margin-right: 0;
  }

  table.data {
    min-width: 0;
    font-size: 0.75rem;
  }

  /* Scroll horizontal só quando a tabela realmente extrapola */
  .table-wrap:not(.table-wrap-cands) {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .edit-input {
    width: 100%;
    max-width: none;
    min-height: 32px;
    font-size: 0.8rem;
    padding: 0.2rem 0.4rem;
  }

  /* Candidatos em cards compactos */
  .table-wrap-cands {
    overflow: visible;
    border: none;
    background: transparent;
  }

  .table-wrap-cands table.data-cands {
    min-width: 0;
    border-collapse: separate;
    border-spacing: 0 0.35rem;
  }

  .table-wrap-cands thead {
    display: none;
  }

  .table-wrap-cands tbody tr {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto;
    gap: 0.25rem 0.4rem;
    align-items: end;
    padding: 0.5rem 0.55rem;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: none;
  }

  .table-wrap-cands tbody tr:hover td {
    background: transparent;
  }

  .table-wrap-cands tbody td {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 0.1rem;
    border: none;
    padding: 0;
    white-space: normal;
    min-width: 0;
  }

  .table-wrap-cands tbody td::before {
    content: attr(data-label);
    font-size: 0.58rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--muted);
    line-height: 1.1;
  }

  .table-wrap-cands tbody td[data-label="Candidato"] {
    grid-column: 1 / 3;
    grid-row: 1;
  }

  .table-wrap-cands tbody td[data-label="Candidato"]::before {
    display: none;
  }

  .table-wrap-cands tbody td[data-label="Candidato"] .edit-nome {
    font-size: 0.82rem;
    font-weight: 700;
  }

  .table-wrap-cands tbody td[data-label="Votos"] {
    grid-column: 1;
    grid-row: 2;
  }

  .table-wrap-cands tbody td[data-label="Partido"] {
    grid-column: 2;
    grid-row: 2;
    font-size: 0.78rem;
    font-weight: 600;
  }

  .table-wrap-cands tbody td[data-label="Partido"] .edit-partido {
    width: 100%;
    max-width: none;
  }

  .table-wrap-cands tbody td.cenario-actions {
    grid-column: 3;
    grid-row: 1 / 3;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 0.25rem;
    padding: 0;
    border: none;
    margin: 0;
    align-self: center;
  }

  .table-wrap-cands tbody td.cenario-actions::before {
    display: none;
  }

  .table-wrap-cands tbody td.cenario-actions .btn-icon {
    width: 28px;
    height: 28px;
    min-height: 28px;
  }

  .table-wrap-cands tbody td.empty {
    grid-column: 1 / -1;
  }

  .table-wrap-cands tbody td.empty::before {
    display: none;
  }

  .cenario-bloco-titulo {
    margin: 0.45rem 0 0.3rem;
    font-size: 0.88rem;
  }

  .cenario-modal-root {
    place-items: end stretch;
    padding: 0;
  }

  .cenario-modal,
  .cenario-modal.wide {
    width: 100%;
    max-height: min(92vh, 100%);
    overflow: auto;
    border-radius: 16px 16px 0 0;
    padding: 1rem 1rem calc(1rem + env(safe-area-inset-bottom, 0px));
  }

  .cenario-modal-actions {
    flex-wrap: wrap;
  }

  .cenario-modal-actions .btn {
    flex: 1;
  }
}

@media (max-width: 560px) {
  .cargo-switch {
    flex: 1 1 auto;
    width: 100%;
  }

  .cargo-opt {
    flex: 1;
    text-align: center;
    padding: 0.5rem 0.5rem;
  }

  .dash-actions {
    width: 100%;
  }

  .dash-actions .btn-sm:not(.btn-icon) {
    flex: 1;
  }

  .status-pill {
    width: 100%;
    justify-content: center;
  }

  .kpi-row {
    grid-template-columns: 1fr 1fr;
    gap: 0.35rem;
  }

  .cand-edit-kpis {
    grid-template-columns: 1fr;
  }

  .cand-reg-grid {
    grid-template-columns: 1fr;
  }

  .detalhe-header {
    flex-direction: column;
    align-items: stretch;
  }

  .detalhe-kpi {
    min-width: calc(50% - 0.2rem);
    flex: 1;
  }

  .detalhe-header h2 {
    font-size: 1.05rem;
    word-break: break-word;
  }

  .lugar-item {
    padding: 0.55rem 0.65rem;
  }

  table.data th,
  table.data td {
    padding: 0.25rem 0.35rem;
  }

  .info-hint-pop {
    left: auto;
    right: 0;
    max-width: min(300px, calc(100vw - 2rem));
  }

  .link-cand {
    text-align: left;
    white-space: normal;
    line-height: 1.3;
  }
}
