/* Apuração Eleitoral — estilos do front. Código original.
   As cores vêm de variáveis definidas pelo admin (--apel-primary, etc.). */

.apel-portal {
	--apel-radius: 16px;
	--apel-bg: #ffffff;
	--apel-surface: #f6f7f9;
	--apel-text: #15181d;
	--apel-muted: #6b7280;
	--apel-border: #e5e7eb;
	--apel-primary: #1f6feb;
	--apel-accent: #16a34a;
	--apel-on-primary: #ffffff;

	max-width: 760px;
	margin: 0 auto;
	font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
	color: var(--apel-text);
}

/* Tema escuro: automático pelo SO, ou forçado via data-apel-theme="dark". */
@media (prefers-color-scheme: dark) {
	.apel-portal[data-apel-theme="auto"] {
		--apel-bg: #0f1115;
		--apel-surface: #161a20;
		--apel-text: #e8eaed;
		--apel-muted: #9aa3af;
		--apel-border: #2a2f37;
	}
}
.apel-portal[data-apel-theme="dark"] {
	--apel-bg: #0f1115;
	--apel-surface: #161a20;
	--apel-text: #e8eaed;
	--apel-muted: #9aa3af;
	--apel-border: #2a2f37;
}

.apel-head { text-align: center; margin-bottom: 18px; }
.apel-live {
	display: inline-flex; align-items: center; gap: 6px;
	font-size: 12px; font-weight: 700; letter-spacing: .08em;
	color: #fff; background: #d93025; padding: 4px 10px; border-radius: 999px;
}
.apel-dot {
	width: 8px; height: 8px; border-radius: 50%; background: #fff;
	animation: apel-pulse 1.4s infinite;
}
@keyframes apel-pulse { 0%,100%{opacity:1} 50%{opacity:.25} }
.apel-title { margin: 10px 0 2px; font-size: 1.5rem; }
.apel-office { margin: 0; color: var(--apel-muted); font-weight: 600; }

.apel-progress-wrap { margin: 16px 0 22px; }
.apel-progress {
	height: 10px; background: var(--apel-surface);
	border: 1px solid var(--apel-border); border-radius: 999px; overflow: hidden;
}
.apel-progress-bar {
	display: block; height: 100%; width: 0;
	background: var(--apel-primary); transition: width .6s ease;
}
.apel-progress-label {
	display: block; text-align: center; margin-top: 6px;
	font-size: 13px; color: var(--apel-muted);
}

.apel-cards { display: grid; gap: 12px; }

.apel-card {
	display: flex; gap: 14px; align-items: center;
	background: var(--apel-bg); border: 1px solid var(--apel-border);
	border-radius: var(--apel-radius); padding: 12px 14px;
	transition: border-color .2s, transform .2s;
}
.apel-card.is-elected { border-color: var(--apel-accent); box-shadow: 0 0 0 1px var(--apel-accent) inset; }

.apel-card-photo {
	flex: 0 0 64px; width: 64px; height: 64px; border-radius: 12px; overflow: hidden;
	background: var(--apel-surface);
}
.apel-card-photo img { width: 100%; height: 100%; object-fit: cover; display: block; }

.apel-card-body { flex: 1 1 auto; min-width: 0; }
.apel-card-top { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.apel-name { font-weight: 700; font-size: 1.02rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.apel-badge {
	flex: 0 0 auto; font-size: 12px; font-weight: 700;
	color: var(--apel-on-primary); background: var(--apel-primary);
	padding: 2px 8px; border-radius: 999px;
}

.apel-bar {
	height: 8px; background: var(--apel-surface); border-radius: 999px;
	margin: 8px 0 6px; overflow: hidden;
}
.apel-bar span {
	display: block; height: 100%; width: 0;
	background: var(--apel-primary); transition: width .6s ease;
}

.apel-card-stats { display: flex; align-items: center; gap: 10px; }
.apel-pct { font-size: 1.1rem; }
.apel-votes { color: var(--apel-muted); font-size: 13px; }
.apel-elected {
	margin-left: auto; font-size: 12px; font-weight: 700;
	color: #fff; background: var(--apel-accent); padding: 2px 8px; border-radius: 999px;
}

.apel-empty { text-align: center; color: var(--apel-muted); padding: 24px; }

.apel-foot {
	display: flex; justify-content: space-between;
	margin-top: 16px; font-size: 12px; color: var(--apel-muted);
}

@media (max-width: 480px) {
	.apel-card-photo { flex-basis: 52px; width: 52px; height: 52px; }
	.apel-title { font-size: 1.25rem; }
}

/* ===== Diretório de candidatos ===== */
.apel-search { margin: 0 0 16px; }
.apel-search input {
	width: 100%; box-sizing: border-box; padding: 11px 14px;
	border: 1px solid var(--apel-border); border-radius: 12px;
	background: var(--apel-bg); color: var(--apel-text); font-size: 15px;
}
.apel-grid {
	display: grid; gap: 12px;
	grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
}
.apel-cand {
	background: var(--apel-bg); border: 1px solid var(--apel-border);
	border-radius: var(--apel-radius); padding: 12px; text-align: center;
	transition: transform .15s, border-color .15s;
}
.apel-cand:hover { transform: translateY(-2px); border-color: var(--apel-primary); }
.apel-cand-photo { position: relative; width: 96px; height: 96px; margin: 0 auto 10px; }
.apel-cand-photo img, .apel-cand-ph {
	width: 96px; height: 96px; border-radius: 50%; object-fit: cover; display: block;
	background: var(--apel-surface);
}
.apel-cand-ph {
	display: flex; align-items: center; justify-content: center;
	font-size: 34px; font-weight: 700; color: var(--apel-muted);
}
.apel-cand-num {
	position: absolute; bottom: -4px; right: 50%; transform: translateX(50%);
	background: var(--apel-primary); color: var(--apel-on-primary);
	font-size: 12px; font-weight: 700; padding: 2px 8px; border-radius: 999px;
	border: 2px solid var(--apel-bg);
}
.apel-cand-name { display: block; font-size: 14px; line-height: 1.25; }
.apel-cand-party { font-size: 12px; color: var(--apel-muted); font-weight: 600; }
.apel-noresults { text-align: center; color: var(--apel-muted); padding: 16px; }

/* ===== Mapa ===== */
.apel-map { position: relative; }
.apel-map-wrap { max-width: 560px; margin: 0 auto; }
.apel-map-svg { width: 100%; height: auto; display: block; }
.apel-map-svg path {
	fill: #cfd6e0; stroke: #ffffff; stroke-width: 1.6;
	transition: fill .15s;
}
.apel-map-svg path.is-hover { fill: var(--apel-primary); }
.apel-map-tip {
	position: absolute; pointer-events: none; z-index: 5;
	background: var(--apel-text); color: var(--apel-bg);
	font-size: 12px; font-weight: 600; padding: 4px 8px; border-radius: 6px;
	white-space: nowrap;
}

/* ===== Estatísticas da apuração ===== */
.apel-stats {
	display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 0 0 20px;
}
.apel-stat {
	background: var(--apel-surface); border-radius: 12px; padding: 10px 8px; text-align: center;
}
.apel-stat-num { display: block; font-size: 1.05rem; font-weight: 800; }
.apel-stat-label { font-size: 11px; color: var(--apel-muted); text-transform: uppercase; letter-spacing: .03em; }
.apel-mate { display: block; font-size: 12px; color: var(--apel-muted); margin-top: 2px; }
.apel-cand-mate { display: block; font-size: 11px; color: var(--apel-muted); margin-top: 3px; }
@media (max-width: 480px) { .apel-stats { grid-template-columns: repeat(2, 1fr); } }

/* ===== Portal SPA [portal] ===== */
.apel-app .apel-tabs {
	display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin: 4px 0 18px;
}
.apel-tab {
	border: 1px solid var(--apel-border); background: var(--apel-bg); color: var(--apel-text);
	padding: 8px 14px; border-radius: 999px; font-size: 14px; font-weight: 600; cursor: pointer;
	transition: all .15s;
}
.apel-tab:hover { border-color: var(--apel-primary); }
.apel-tab.is-active { background: var(--apel-primary); color: var(--apel-on-primary); border-color: var(--apel-primary); }

.apel-ufbar { display: flex; align-items: center; gap: 12px; margin: 0 0 14px; }
.apel-ufback {
	border: 1px solid var(--apel-border); background: var(--apel-bg); color: var(--apel-text);
	padding: 6px 12px; border-radius: 10px; cursor: pointer; font-weight: 600;
}
.apel-ufback:hover { border-color: var(--apel-primary); }
.apel-ufname { font-weight: 800; font-size: 1.1rem; }

.apel-app-grid { display: grid; grid-template-columns: 1fr; gap: 20px; }
.apel-app.has-map .apel-app-grid { grid-template-columns: minmax(240px, 360px) 1fr; align-items: start; }
.apel-app-map { position: relative; }
.apel-map-hint { text-align: center; font-size: 12px; color: var(--apel-muted); margin: 6px 0 0; }
.apel-map-svg path.is-active { fill: var(--apel-primary); }

@media (max-width: 680px) {
	.apel-app.has-map .apel-app-grid { grid-template-columns: 1fr; }
	.apel-app-map { max-width: 420px; margin: 0 auto; }
}

/* Correção: garante que [hidden] realmente esconda (display acima vence o atributo) */
.apel-app [hidden] { display: none !important; }

/* ==================================================================== */
/* PORTAL COMPLETO [portal] — layout em seções (estilo referência)      */
/* ==================================================================== */
.apel-full { max-width: 920px; margin: 0 auto; }
.apel-full .apel-topbar {
	display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px;
}
.apel-full .apel-updated { font-size: 12px; color: var(--apel-muted); }

.apel-sec {
	background: var(--apel-bg); border: 1px solid var(--apel-border);
	border-radius: 18px; padding: 24px; margin: 18px 0;
}
.apel-sec-kicker {
	font-size: 11px; font-weight: 800; letter-spacing: .12em; text-transform: uppercase;
	color: var(--apel-primary); margin-bottom: 4px;
}
.apel-sec-title { margin: 0 0 4px; font-size: 1.5rem; line-height: 1.15; }
.apel-sec-desc { margin: 0 0 18px; color: var(--apel-muted); font-size: 14px; }
.apel-sec-head-row { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.apel-sec-ap { color: var(--apel-primary); font-weight: 800; font-size: 13px; white-space: nowrap; }

/* ---- 1. Brasil em uma tela ---- */
.apel-brasil { display: grid; grid-template-columns: 1.1fr 1fr; gap: 20px; align-items: start; }
.apel-brasil-map { position: relative; }
.apel-brasil-map .apel-map-wrap { max-width: 460px; margin: 0 auto; }
.apel-map-svg { width: 100%; height: auto; display: block; }
.apel-map-svg path {
	fill: #cfd6e0; stroke: #ffffff; stroke-width: 1.6; transition: fill .2s, opacity .15s;
}
.apel-map-svg path.is-hover { opacity: .8; }
.apel-map-svg path.is-active { stroke: var(--apel-text); stroke-width: 1.6; }
.apel-map-tip {
	position: absolute; pointer-events: none; z-index: 5; background: var(--apel-text); color: var(--apel-bg);
	font-size: 12px; font-weight: 600; padding: 4px 8px; border-radius: 6px; white-space: nowrap;
}
.apel-brasil-side {
	background: var(--apel-surface); border-radius: 14px; padding: 16px; min-height: 180px;
}
.apel-side-empty { color: var(--apel-muted); font-size: 14px; text-align: center; padding: 28px 10px; }
.apel-side-title { margin: 0 0 12px; font-size: 1.1rem; }
.apel-side-title small { font-weight: 600; color: var(--apel-muted); font-size: 12px; }
.apel-side-rows .apel-row { padding: 8px 0; }

.apel-legend { display: flex; flex-wrap: wrap; gap: 10px 16px; margin-top: 16px; }
.apel-legend-item { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 700; }
.apel-legend-item i { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }
.apel-legend-note { font-size: 12px; color: var(--apel-muted); }

/* ---- 2. Ranking (linhas) ---- */
.apel-rows { display: flex; flex-direction: column; }
.apel-row { display: flex; align-items: center; gap: 12px; padding: 12px 4px; border-bottom: 1px solid var(--apel-border); }
.apel-row:last-child { border-bottom: 0; }
.apel-row--lead { background: linear-gradient(90deg, color-mix(in srgb, var(--apel-primary) 8%, transparent), transparent); border-radius: 12px; }
.apel-row-photo { width: 52px; height: 52px; border-radius: 50%; object-fit: cover; background: var(--apel-surface); flex: 0 0 52px; }
.apel-row-main { flex: 1; min-width: 0; }
.apel-row-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.apel-row-name { font-weight: 700; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.apel-row-name b { color: var(--apel-muted); font-weight: 600; }
.apel-row-pct { font-size: 1.15rem; font-weight: 800; white-space: nowrap; }
.apel-row-sub { display: flex; justify-content: space-between; font-size: 12px; color: var(--apel-muted); margin: 2px 0 7px; gap: 8px; }
.apel-row-bar { height: 7px; background: var(--apel-surface); border-radius: 999px; overflow: hidden; }
.apel-row-bar span { display: block; height: 100%; border-radius: 999px; transition: width .6s; }
.apel-row-party { flex: 0 0 auto; color: #fff; font-size: 12px; font-weight: 800; padding: 4px 10px; border-radius: 8px; min-width: 42px; text-align: center; }

.apel-footrow { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-top: 16px; }
.apel-foot-cell { background: var(--apel-surface); border-radius: 12px; padding: 12px; text-align: center; }
.apel-foot-cell strong { display: block; font-size: 1rem; }
.apel-foot-cell span { font-size: 11px; color: var(--apel-muted); text-transform: uppercase; letter-spacing: .03em; }

/* ---- 3. Governos estaduais (grid) ---- */
.apel-govgrid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.apel-gov-card { background: var(--apel-surface); border-radius: 14px; padding: 12px 14px; cursor: pointer; transition: transform .15s; }
.apel-gov-card:hover { transform: translateY(-2px); }
.apel-gov-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 8px; }
.apel-gov-head strong { font-size: 14px; }
.apel-gov-head span { font-size: 11px; color: var(--apel-muted); font-weight: 700; }
.apel-gov-cand { display: flex; align-items: center; gap: 8px; padding: 4px 0; }
.apel-gov-cand img, .apel-gov-ph { width: 34px; height: 34px; border-radius: 50%; object-fit: cover; background: var(--apel-border); flex: 0 0 34px; }
.apel-gov-cinfo { flex: 1; min-width: 0; }
.apel-gov-cname { display: block; font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.apel-gov-cparty { font-size: 11px; font-weight: 800; }
.apel-gov-cpct { font-size: 14px; font-weight: 800; }
.apel-gov-empty { font-size: 12px; color: var(--apel-muted); margin: 4px 0; }

/* ---- 4. Notícias ---- */
.apel-news { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.apel-news-card { text-decoration: none; color: inherit; background: var(--apel-surface); border-radius: 14px; overflow: hidden; display: flex; flex-direction: column; transition: transform .15s; }
.apel-news-card:hover { transform: translateY(-3px); }
.apel-news-thumb { aspect-ratio: 16/9; background: var(--apel-border) center/cover no-repeat; }
.apel-news-body { padding: 12px; }
.apel-news-cat { font-size: 11px; color: var(--apel-muted); text-transform: uppercase; letter-spacing: .04em; }
.apel-news-title { margin: 6px 0 0; font-size: 14px; line-height: 1.3; }

/* ---- 5. Infocards + FAQ ---- */
.apel-infocards { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 20px; }
.apel-infocard { background: var(--apel-surface); border-radius: 14px; padding: 16px; text-align: center; }
.apel-infocard-big { display: block; font-size: 1.35rem; font-weight: 800; color: var(--apel-primary); }
.apel-infocard-label { display: block; font-weight: 700; margin: 2px 0 6px; }
.apel-infocard-desc { font-size: 12px; color: var(--apel-muted); }
.apel-faq-item { border: 1px solid var(--apel-border); border-radius: 12px; padding: 4px 16px; margin-bottom: 8px; }
.apel-faq-item summary { cursor: pointer; font-weight: 700; padding: 12px 0; list-style: none; }
.apel-faq-item summary::-webkit-details-marker { display: none; }
.apel-faq-item summary::after { content: '+'; float: right; color: var(--apel-primary); font-weight: 800; }
.apel-faq-item[open] summary::after { content: '–'; }
.apel-faq-item p { margin: 0 0 14px; color: var(--apel-muted); font-size: 14px; line-height: 1.5; }

/* ---- 6. Timeline ---- */
.apel-timeline { list-style: none; margin: 0; padding: 0; }
.apel-tl-item { display: flex; gap: 14px; padding: 12px 0; border-bottom: 1px solid var(--apel-border); }
.apel-tl-item:last-child { border-bottom: 0; }
.apel-tl-date { flex: 0 0 56px; text-align: center; background: var(--apel-surface); border-radius: 12px; padding: 8px 0; height: fit-content; }
.apel-tl-item.is-key .apel-tl-date { background: var(--apel-primary); color: var(--apel-on-primary); }
.apel-tl-date strong { display: block; font-size: 1.3rem; line-height: 1; }
.apel-tl-date span { font-size: 11px; font-weight: 700; }
.apel-tl-body h4 { margin: 0 0 3px; font-size: 15px; }
.apel-tl-body p { margin: 0; font-size: 13px; color: var(--apel-muted); }

/* ---- responsivo ---- */
@media (max-width: 720px) {
	.apel-brasil { grid-template-columns: 1fr; }
	.apel-govgrid { grid-template-columns: 1fr; }
	.apel-news { grid-template-columns: 1fr 1fr; }
	.apel-infocards { grid-template-columns: 1fr 1fr; }
	.apel-footrow { grid-template-columns: 1fr 1fr; }
	.apel-sec { padding: 18px; }
}
@media (max-width: 460px) {
	.apel-news { grid-template-columns: 1fr; }
}

/* Abas de cargo no painel do estado (Brasil em uma tela) */
.apel-statetabs { display: flex; flex-wrap: wrap; gap: 6px; margin: 2px 0 12px; }
.apel-statetab {
	border: 1px solid var(--apel-border); background: var(--apel-bg); color: #15181d;
	padding: 5px 12px; border-radius: 999px; font-size: 12px; font-weight: 700; cursor: pointer; transition: all .15s;
}
:root:not([data-theme="light"]) .apel-statetab,
[data-apel-theme="dark"] .apel-statetab { color: #e8eaed; }
.apel-statetab:hover { border-color: var(--apel-primary); }
.apel-statetab.is-active { background: var(--apel-primary); color: var(--apel-on-primary); border-color: var(--apel-primary); }
.apel-side-sub { font-size: 12px; color: var(--apel-muted); font-weight: 700; margin: 0 0 6px; }

/* ===== Ajustes v1.8: scroll, modal, abas, mobile ===== */

/* Lista de candidatos do estado com rolagem (dep. estadual tem muitos) */
.apel-side-rows { max-height: 56vh; overflow-y: auto; overflow-x: hidden; padding-right: 4px; }
.apel-side-rows::-webkit-scrollbar { width: 8px; }
.apel-side-rows::-webkit-scrollbar-thumb { background: var(--apel-border); border-radius: 8px; }

/* Abas de cargo do estado — nunca cortam, rolam na horizontal se preciso */
.apel-statetabs { flex-wrap: wrap; overflow-x: auto; -webkit-overflow-scrolling: touch; }
.apel-statetab { white-space: nowrap; flex: 0 0 auto; }

/* Candidato clicável */
.apel-clickable { cursor: pointer; border-radius: 10px; }
.apel-clickable:hover { background: color-mix(in srgb, var(--apel-primary) 7%, transparent); }

/* Garante que selo de partido não estoure a largura */
.apel-row { box-sizing: border-box; max-width: 100%; }
.apel-row-party { max-width: 110px; overflow: hidden; text-overflow: ellipsis; }

/* ===== Modal de detalhes do candidato ===== */
.apel-modal { position: fixed; inset: 0; z-index: 9999; display: flex; align-items: center; justify-content: center; }
.apel-modal[hidden] { display: none; }
.apel-modal-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,.55); }
.apel-modal-box {
	position: relative; z-index: 1; width: min(420px, 92vw); max-height: 88vh; overflow-y: auto;
	background: var(--apel-bg); color: var(--apel-text); border-radius: 18px; padding: 22px;
	box-shadow: 0 20px 60px rgba(0,0,0,.35);
}
.apel-modal-x {
	position: absolute; top: 10px; right: 10px;
	width: 34px; height: 34px; border: 0; border-radius: 50%;
	background: var(--apel-surface); color: var(--apel-text);
	font-size: 22px; line-height: 34px; text-align: center; cursor: pointer;
	box-shadow: 0 1px 4px rgba(0,0,0,.15); z-index: 2;
}
.apel-modal-x:hover { background: var(--apel-primary); color: var(--apel-on-primary); }
.apel-modal-head { display: flex; gap: 14px; align-items: center; margin-bottom: 16px; }
.apel-modal-photo { width: 76px; height: 76px; border-radius: 50%; object-fit: cover; background: var(--apel-surface); flex: 0 0 76px; }
.apel-modal-party { display: inline-block; color: #fff; font-size: 12px; font-weight: 800; padding: 3px 10px; border-radius: 8px; }
.apel-modal-name { margin: 6px 0 2px; font-size: 1.2rem; line-height: 1.15; }
.apel-modal-cargo { margin: 0; color: var(--apel-muted); font-size: 13px; font-weight: 600; }
.apel-modal-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 14px; }
.apel-modal-stats div { background: var(--apel-surface); border-radius: 12px; padding: 12px; text-align: center; }
.apel-modal-stats strong { display: block; font-size: 1.25rem; }
.apel-modal-stats span { font-size: 11px; color: var(--apel-muted); text-transform: uppercase; }
.apel-modal-vice { font-size: 14px; color: var(--apel-text); margin: 0 0 14px; }
.apel-modal-tse {
	display: block; text-align: center; background: var(--apel-primary); color: var(--apel-on-primary);
	text-decoration: none; font-weight: 700; padding: 12px; border-radius: 12px;
}
.apel-modal-note { font-size: 12px; color: var(--apel-muted); text-align: center; margin: 0; }

/* ===== Mobile: evita corte na lista de candidatos do mapa ===== */
@media (max-width: 720px) {
	.apel-sec { overflow: hidden; }
	.apel-brasil-side { padding: 14px; }
	.apel-side-rows { max-height: 65vh; overflow-y: auto; -webkit-overflow-scrolling: touch; }

	.apel-row { gap: 8px; padding: 10px 2px; }
	.apel-row-photo { width: 44px; height: 44px; flex-basis: 44px; }
	.apel-row-main { min-width: 0; }
	.apel-row-name { font-size: 14px; }
	.apel-row-pct { font-size: 1rem; }
	.apel-row-party {
		position: static; flex: 0 0 46px; width: 46px; max-width: 46px;
		font-size: 10px; padding: 3px 4px; min-width: 0; text-align: center;
		align-self: center;
	}
	.apel-row-sub { gap: 6px; }
	.apel-row-sub span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
	.apel-row-votes { flex: 0 0 auto; }
}

/* ==================================================================== */

/* ==================================================================== */
/* ISOLAMENTO DEFINITIVO contra o tema do WordPress                       */
/* Usa #apel-portal (ID) para vencer temas que forçam cor via #id/!important.*/
/* ==================================================================== */

/* 1) Base: todo texto do portal usa a cor do tema do plugin */
#apel-portal, #apel-portal * { color: var(--apel-text) !important; }

/* 2) Textos secundários -> muted */
#apel-portal .apel-sec-desc, #apel-portal .apel-stat-label, #apel-portal .apel-foot-cell span,
#apel-portal .apel-row-votes, #apel-portal .apel-row-sub, #apel-portal .apel-row-sub span,
#apel-portal .apel-side-sub, #apel-portal .apel-tl-body p, #apel-portal .apel-tl-date span,
#apel-portal .apel-news-cat, #apel-portal .apel-faq-item p, #apel-portal .apel-updated,
#apel-portal .apel-source, #apel-portal .apel-map-hint, #apel-portal .apel-empty,
#apel-portal .apel-side-empty, #apel-portal .apel-row-name b, #apel-portal .apel-modal-cargo,
#apel-portal .apel-modal-stats span {
	color: var(--apel-muted) !important;
}

/* 3) Realces na cor primaria */
#apel-portal .apel-sec-kicker, #apel-portal .apel-sec-ap { color: var(--apel-primary) !important; }

/* 4) Elementos com fundo colorido -> texto claro */
#apel-portal .apel-row-party, #apel-portal .apel-badge, #apel-portal .apel-elected,
#apel-portal .apel-live, #apel-portal .apel-modal-party, #apel-portal .apel-dot,
#apel-portal .apel-statetab.is-active, #apel-portal .apel-tab.is-active,
#apel-portal .apel-modal-tse {
	color: var(--apel-on-primary) !important;
}
#apel-portal .apel-live, #apel-portal .apel-dot { color: #fff !important; }

/* 5) Fundos dos cards preservados */
#apel-portal .apel-sec { background: var(--apel-bg) !important; }
#apel-portal .apel-brasil-side, #apel-portal .apel-stat, #apel-portal .apel-foot-cell,
#apel-portal .apel-gov-card, #apel-portal .apel-news-card, #apel-portal .apel-modal-stats div {
	background: var(--apel-surface) !important;
}

#apel-portal a { text-decoration: none; }


/* mapa dark */
@media (prefers-color-scheme: dark) {
	.apel-portal[data-apel-theme="auto"] .apel-map-svg path { fill: #2a2f37; stroke: #0f1115; }
}
.apel-portal[data-apel-theme="dark"] .apel-map-svg path { fill: #2a2f37; stroke: #0f1115; }

/* ===== Drill-down municipal ===== */
.apel-mun { margin-top: 16px; border-top: 1px solid var(--apel-border); padding-top: 14px; }
.apel-mun-title { margin: 0 0 8px; font-size: 14px; }
.apel-mun-search {
	width: 100%; box-sizing: border-box; padding: 8px 12px; margin-bottom: 8px;
	border: 1px solid var(--apel-border); border-radius: 10px;
	background: var(--apel-bg); color: var(--apel-text); font-size: 14px;
}
.apel-mun-list { max-height: 220px; overflow-y: auto; display: flex; flex-direction: column; gap: 2px; }
.apel-mun-item {
	text-align: left; border: 0; background: transparent; color: var(--apel-text);
	padding: 8px 10px; border-radius: 8px; cursor: pointer; font-size: 13px;
}
.apel-mun-item:hover { background: var(--apel-surface); }
.apel-mun-result { margin-top: 10px; }
.apel-mun-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 4px; }
.apel-mun-back {
	border: 1px solid var(--apel-border); background: var(--apel-bg); color: var(--apel-text);
	font-size: 12px; padding: 4px 10px; border-radius: 8px; cursor: pointer;
}
.apel-mun-back:hover { border-color: var(--apel-primary); }
/* isolamento contra tema */
#apel-portal .apel-mun-title, #apel-portal .apel-mun-item { color: var(--apel-text) !important; }

/* ===== Seletor Brasil / Exterior (presidência) ===== */
.apel-scope { display: flex; gap: 8px; margin: 0 0 14px; }
.apel-scope-btn {
	border: 1px solid var(--apel-border); background: var(--apel-bg); color: var(--apel-text);
	padding: 5px 14px; border-radius: 999px; font-size: 13px; font-weight: 700; cursor: pointer; transition: all .15s;
}
.apel-scope-btn:hover { border-color: var(--apel-primary); }
.apel-scope-btn.is-active { background: var(--apel-primary); color: var(--apel-on-primary); border-color: var(--apel-primary); }
#apel-portal .apel-scope-btn { color: var(--apel-text) !important; }
#apel-portal .apel-scope-btn.is-active { color: var(--apel-on-primary) !important; }

/* ===== Selo de situação (Eleito / 2º turno) ===== */
.apel-sit {
	display: inline-block; font-size: 10px; font-weight: 800; padding: 2px 7px;
	border-radius: 999px; margin-left: 6px; vertical-align: middle; white-space: nowrap;
}
.apel-badge-eleito { background: var(--apel-accent); color: #fff; }
.apel-badge-2turno { background: #f59e0b; color: #fff; }
.apel-badge-sit { background: var(--apel-surface); color: var(--apel-text); }
#apel-portal .apel-badge-eleito, #apel-portal .apel-badge-2turno { color: #fff !important; }

/* ===== Seletor de turno (topo) ===== */
.apel-turnsel { display: flex; gap: 8px; justify-content: center; margin: 0 0 16px; }
.apel-turn-btn {
	border: 1px solid var(--apel-border); background: var(--apel-bg); color: var(--apel-text);
	padding: 6px 16px; border-radius: 999px; font-size: 13px; font-weight: 700; cursor: pointer; transition: all .15s;
}
.apel-turn-btn:hover { border-color: var(--apel-primary); }
.apel-turn-btn.is-active { background: var(--apel-primary); color: var(--apel-on-primary); border-color: var(--apel-primary); }
#apel-portal .apel-turn-btn { color: var(--apel-text) !important; }
#apel-portal .apel-turn-btn.is-active { color: var(--apel-on-primary) !important; }

/* Correção: garante que [hidden] realmente esconda no portal completo
   (o display:flex de alguns elementos estava vencendo o atributo hidden). */
#apel-portal [hidden] { display: none !important; }

/* ===== Aviso de 2º turno (sem apuração ainda) ===== */
.apel-aviso {
	background: color-mix(in srgb, var(--apel-primary) 10%, var(--apel-bg));
	border: 1px solid var(--apel-primary); border-radius: 14px;
	padding: 20px; text-align: center; margin: 10px 0 18px;
}
.apel-aviso strong { display: block; font-size: 1.05rem; margin-bottom: 4px; }
.apel-aviso span { color: var(--apel-muted); font-size: 14px; }
#apel-portal .apel-aviso strong { color: var(--apel-text) !important; }

/* ===== Seletor de estado (dropdown) ===== */
.apel-uf-select {
	width: 100%; box-sizing: border-box; padding: 10px 12px; margin: 0 0 14px;
	border: 1px solid var(--apel-border); border-radius: 12px;
	background: var(--apel-bg); color: var(--apel-text); font-size: 15px; font-weight: 600;
}
#apel-portal .apel-uf-select { color: var(--apel-text) !important; }

/* ===== Mobile: mapa compacto, painel sem espaço vazio enorme ===== */
@media (max-width: 720px) {
	.apel-brasil { gap: 12px; }
	.apel-brasil-map .apel-map-wrap { max-width: 100%; text-align: center; }
	.apel-map-svg { max-height: 42vh; width: auto; margin: 0 auto; }
	.apel-brasil-side { min-height: 0; padding: 12px; }
	.apel-side-empty { padding: 14px 8px; font-size: 13px; }
	/* o dropdown vira a navegação principal no celular; dica do mapa some */
	.apel-map-hint { display: none; }
}
