/*
         * Paleta alinhada ao design system SIIPS Admin (custom_admin.css):
         * --red: #EC322F · --gold: #eeb902 · --grad: linear-gradient(135deg, #EC322F, #eeb902)
         * Mantemos os mesmos tons de masculino/feminino/activo usados nos badges (nb-male, nb-female, nb-total).
         */
:root,
[data-theme="dark"] {
    --bg: #0f1117;
    --sidebar: #1a1d2b;
    --surface: #171922;
    --surface-2: #1d2030;
    --border: #2a2e40;
    --text: #eef0fb;
    --muted: #8b90ab;
    --muted-2: #565c78;

    --red: #EC322F;
    --gold: #eeb902;
    --grad: linear-gradient(135deg, #EC322F 0%, #eeb902 100%);
    --grad-2: linear-gradient(135deg, #6d28d9 0%, #2563eb 100%);
    --grad-success: linear-gradient(135deg, #0d9488 0%, #22c55e 100%);
    --grad-danger: linear-gradient(135deg, #b91c1c 0%, #ea580c 100%);
    --grad-info: linear-gradient(135deg, #1e3a8a 0%, #2563eb 100%);
    --grad-warning: linear-gradient(135deg, #92400e 0%, #f59e0b 100%);
    --grad-albinism: linear-gradient(135deg, #0891b2 0%, #22d3ee 100%);
    --grad-soft: rgba(236, 50, 47, 0.14);
    --gold-soft: rgba(238, 185, 2, 0.16);

    --male: #3b82f6;
    --female: #db2777;
    --active: #8b5cf6;
    --suppressed: #dc2626;

    --shadow: 0 1px 2px rgba(0, 0, 0, 0.35), 0 8px 24px -10px rgba(0, 0, 0, 0.55);
    --radius: 10px;
}

[data-theme="light"] {
    --bg: #f0f2f8;
    --sidebar: #1e2235;
    --surface: #ffffff;
    --surface-2: #f7f8fc;
    --border: #eaecf3;
    --text: #1e2235;
    --muted: #7b8299;
    --muted-2: #a3a8bf;

    --red: #EC322F;
    --gold: #eeb902;
    --grad: linear-gradient(135deg, #EC322F 0%, #eeb902 100%);
    --grad-2: linear-gradient(135deg, #5b21b6 0%, #1d4ed8 100%);
    --grad-success: linear-gradient(135deg, #0f766e 0%, #16a34a 100%);
    --grad-danger: linear-gradient(135deg, #991b1b 0%, #c2410c 100%);
    --grad-info: linear-gradient(135deg, #1e3a8a 0%, #1d4ed8 100%);
    --grad-warning: linear-gradient(135deg, #78350f 0%, #d97706 100%);
    --grad-albinism: linear-gradient(135deg, #0e7490 0%, #06b6d4 100%);
    --grad-soft: rgba(236, 50, 47, 0.07);
    --gold-soft: rgba(238, 185, 2, 0.1);

    --male: #3b82f6;
    --female: #db2777;
    --active: #7c3aed;
    --suppressed: #dc2626;

    --shadow: 0 1px 4px rgba(0, 0, 0, .06), 0 4px 20px rgba(0, 0, 0, .07);
}

* {
    box-sizing: border-box;
}

[x-cloak] {
    display: none !important;
}

html {
    overflow-x: hidden;
}

body {
    margin: 0;
    font-family: 'Inter', -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
}

.progress-bar {
    position: fixed;
    top: 0;
    left: 0;
    height: 3px;
    width: 100%;
    z-index: 200;
    overflow: hidden;
}

.progress-bar span {
    display: block;
    height: 100%;
    width: 30%;
    background: var(--grad);
    transform: translateX(-100%);
}

.progress-bar.active span {
    animation: indeterminate 1.1s ease-in-out infinite;
}

@keyframes indeterminate {
    0% {
        transform: translateX(-100%);
    }

    60% {
        transform: translateX(220%);
    }

    100% {
        transform: translateX(220%);
    }
}

/* ---------------- Shell (sem sidebar — dashboard público não precisa de nav de app) ---------------- */
.app-shell {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 50;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: env(safe-area-inset-top, 0px) 26px 0;
    gap: 12px;
    min-width: 0;
    height: calc(64px + env(safe-area-inset-top, 0px));
    flex-shrink: 0;
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
    flex-shrink: 0;
}

.topbar-left .logo-box {
    width: 34px;
    height: 34px;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    overflow: hidden;
}

.topbar-left .logo-box img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.topbar-left .brand {
    font-size: 0.9rem;
    font-weight: 700;
    letter-spacing: -0.01em;
    white-space: nowrap;
    display: none;
}

@media (min-width: 900px) {
    .topbar-left .brand {
        display: block;
    }
}

.topbar .search {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 8px 14px;
    flex: 1 1 auto;
    min-width: 0;
    max-width: 340px;
    color: var(--muted);
    font-size: 0.83rem;
}

.topbar .search i {
    font-size: 0.8rem;
    flex-shrink: 0;
}

.topbar .search input {
    border: none;
    background: transparent;
    outline: none;
    color: var(--text);
    font-family: inherit;
    font-size: 0.83rem;
    width: 100%;
    min-width: 0;
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.refresh-pill {
    font-size: 0.72rem;
    color: var(--muted);
    background: var(--surface-2);
    border: 1px solid var(--border);
    padding: 7px 12px;
    border-radius: 999px;
    display: flex;
    align-items: center;
    gap: 7px;
    white-space: nowrap;
}

.refresh-pill .dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--active);
    flex-shrink: 0;
}

.refresh-pill.stale .dot {
    background: var(--gold);
}

.refresh-pill i.fa-wifi {
    color: var(--active);
}

.refresh-pill.offline {
    background: rgba(238, 185, 2, 0.14);
    border-color: rgba(238, 185, 2, 0.35);
    color: var(--gold);
}

.refresh-pill.offline i.fa-wifi-slash {
    color: var(--gold);
}

.icon-btn {
    width: 36px;
    height: 36px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background: var(--surface-2);
    color: var(--text);
    cursor: pointer;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.icon-btn:hover {
    border-color: var(--red);
    color: var(--red);
}

.icon-btn.tv-active {
    background: var(--grad);
    border-color: transparent;
    color: #fff;
}

.icon-btn.install-btn {
    background: var(--grad-soft);
    color: var(--red);
    border-color: transparent;
}

.icon-btn.install-btn:hover {
    background: var(--grad);
    color: #fff;
}

/* ---------------- Section nav: barra horizontal fina, substitui a antiga sidebar ---------------- */
.section-nav {
    position: sticky;
    top: calc(64px + env(safe-area-inset-top, 0px));
    z-index: 45;
    background: var(--bg);
    border-bottom: 1px solid var(--border);
    padding: 0 26px;
    height: 46px;
    display: flex;
    align-items: center;
    gap: 4px;
    overflow-x: auto;
    flex-shrink: 0;
    scrollbar-width: thin;
    -webkit-mask-image: linear-gradient(to right, #000 92%, transparent 100%);
    mask-image: linear-gradient(to right, #000 92%, transparent 100%);
}

.section-nav a {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    text-decoration: none;
    font-size: 0.78rem;
    font-weight: 500;
    color: var(--muted);
    padding: 11px 13px;
    white-space: nowrap;
    border-bottom: 2px solid transparent;
    flex-shrink: 0;
}

.section-nav a i {
    font-size: 12px;
}

.section-nav a:hover {
    color: var(--text);
}

.section-nav a.active {
    color: var(--red);
    border-bottom-color: var(--red);
}

/* ---------------- Modo TV: esconde toda a "chrome", só ficam os dados ---------------- */
.app-shell.tv-mode .topbar,
.app-shell.tv-mode .section-nav,
.app-shell.tv-mode .filters {
    display: none;
}

.app-shell.tv-mode .main-content {
    padding-top: 22px;
}

/* ---------------- Main content ---------------- */
.main-content {
    flex: 1;
    padding: 32px 26px 60px;
    min-width: 0;
    overflow-x: hidden;
}

.offline-banner {
    display: flex;
    align-items: center;
    gap: 10px;
    background: rgba(238, 185, 2, 0.14);
    border: 1px solid rgba(238, 185, 2, 0.35);
    color: var(--gold);
    border-radius: var(--radius);
    padding: 12px 16px;
    font-size: 0.82rem;
    font-weight: 600;
    margin-bottom: 16px;
}

.offline-banner i {
    flex-shrink: 0;
}

.filters {
    position: relative;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 28px;
}

.filters-toggle {
    width: 100%;
    background: transparent;
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    padding: 14px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-family: inherit;
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text);
}

.filters-toggle span:first-child {
    display: flex;
    align-items: center;
    gap: 8px;
}

.filters-toggle-right {
    display: flex;
    align-items: center;
    gap: 10px;
}

.filters-badge {
    background: var(--grad);
    color: #fff;
    font-size: 0.68rem;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 999px;
    min-width: 18px;
    text-align: center;
}

.filters-chevron {
    color: var(--muted);
    font-size: 0.78rem;
    transition: transform 0.2s;
}

.filters-chevron.open {
    transform: rotate(180deg);
}

.filters-body {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    right: 0;
    z-index: 55;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: 0 12px 32px -8px rgba(0, 0, 0, 0.45), var(--shadow);
    padding: 18px 16px 16px;
    display: grid;
    grid-template-columns: 1fr;
    gap: 14px;
    align-items: end;
    max-height: calc(100vh - 140px);
    overflow-y: auto;
}

.filters-body .field {
    display: flex;
    flex-direction: column;
    gap: 5px;
    min-width: 0;
}

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

.filters-body select {
    width: 100%;
    padding: 8px 10px;
    border-radius: var(--radius);
    border: 1.5px solid var(--border);
    background: var(--surface-2);
    color: var(--text);
    min-width: 0;
    font-size: 0.84rem;
    font-family: inherit;
}

.filters-body select:focus {
    border-color: var(--red);
    outline: none;
    box-shadow: 0 0 0 3px var(--grad-soft);
}

.filters-body select:disabled {
    opacity: 0.4;
}

.filters-body .btn-ghost {
    grid-column: 1 / -1;
    justify-content: center;
}

/* ---------------- Combobox pesquisável (Província/Município/Comuna/Bairro) ---------------- */
.combo-field {
    position: relative;
}

.combo-input-wrap {
    position: relative;
    display: flex;
    align-items: center;
}

.combo-input-wrap i.combo-search-icon {
    position: absolute;
    left: 11px;
    font-size: 0.78rem;
    color: var(--muted);
    pointer-events: none;
}

.combo-input {
    width: 100%;
    padding: 8px 34px 8px 32px;
    border-radius: var(--radius);
    border: 1.5px solid var(--border);
    background: var(--surface-2);
    color: var(--text);
    font-size: 0.84rem;
    font-family: inherit;
}

.combo-input:focus {
    border-color: var(--red);
    outline: none;
    box-shadow: 0 0 0 3px var(--grad-soft);
}

.combo-input:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.combo-clear {
    position: absolute;
    right: 8px;
    width: 20px;
    height: 20px;
    border: none;
    background: var(--border);
    color: var(--muted);
    border-radius: 50%;
    font-size: 0.65rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.combo-clear:hover {
    background: var(--red);
    color: #fff;
}

.combo-dropdown {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    max-height: 230px;
    overflow-y: auto;
    z-index: 60;
    padding: 4px;
}

.combo-option {
    padding: 9px 10px;
    font-size: 0.84rem;
    color: var(--text);
    border-radius: calc(var(--radius) - 2px);
    cursor: pointer;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.combo-option:hover,
.combo-option.is-active {
    background: var(--grad-soft);
    color: var(--red);
}

.combo-option.combo-option-all {
    color: var(--muted);
    font-style: italic;
    border-bottom: 1px solid var(--border);
    border-radius: 0;
    margin-bottom: 4px;
    padding-bottom: 10px;
}

.combo-empty {
    padding: 10px;
    font-size: 0.8rem;
    color: var(--muted);
    text-align: center;
}

.btn-ghost {
    padding: 9px 14px;
    border-radius: var(--radius);
    border: 1.5px solid var(--border);
    background: transparent;
    color: var(--muted);
    cursor: pointer;
    font-size: 0.78rem;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.btn-ghost:hover {
    color: var(--red);
    border-color: var(--red);
}

/* ---------------- KPI row (legado, mantido por compatibilidade) ---------------- */
.kpi-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
    gap: 14px;
    margin-bottom: 20px;
}

.kpi-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px;
    display: flex;
    align-items: center;
    gap: 14px;
    box-shadow: var(--shadow);
}

.kpi-card .avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
}

.kpi-card .avatar.c-red {
    background: var(--grad-soft);
    color: var(--red);
}

.kpi-card .avatar.c-gold {
    background: var(--gold-soft);
    color: var(--gold);
}

.kpi-card .avatar.c-blue {
    background: rgba(59, 130, 246, 0.14);
    color: var(--male);
}

.kpi-card .avatar.c-green {
    background: rgba(139, 92, 246, 0.14);
    color: var(--active);
}

.kpi-card .avatar.c-teal {
    background: rgba(20, 184, 166, 0.14);
    color: #14b8a6;
}

.kpi-card .value {
    font-size: 1.5rem;
    font-weight: 800;
    letter-spacing: -0.02em;
    line-height: 1.1;
}

.kpi-card .value.skel {
    color: transparent;
    background: var(--border);
    border-radius: var(--radius);
    animation: pulse 1.4s ease-in-out infinite;
}

.kpi-card .label {
    font-size: 0.74rem;
    color: var(--muted);
    margin-top: 2px;
}

.kpi-subtext {
    display: flex;
    gap: 10px;
    margin-top: 5px;
    font-size: 0.7rem;
    color: var(--muted-2);
}

.kpi-subtext strong {
    color: var(--text);
    font-weight: 700;
}

.kpi-card.compact {
    padding: 16px;
}

/* ---------------- Hero row: cards grandes em gradiente (topo do dashboard) ---------------- */
.hero-row {
    display: grid;
    grid-template-columns: 1.3fr 1.3fr 0.85fr 0.85fr 0.85fr;
    gap: 14px;
    margin-bottom: 20px;
    align-items: stretch;
}

.hero-row.hero-row-2 {
    grid-template-columns: 1.3fr 1.3fr 0.85fr 0.85fr;
}

.hero-row.hero-row-albinism {
    grid-template-columns: 1.3fr 0.85fr 0.85fr;
}

@media (max-width: 1300px) {

    .hero-row,
    .hero-row.hero-row-2,
    .hero-row.hero-row-albinism {
        grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
    }
}

@media (max-width: 480px) {

    .hero-row,
    .hero-row.hero-row-2,
    .hero-row.hero-row-albinism {
        grid-template-columns: 1fr;
    }
}

.hero-card {
    background: var(--grad);
    border-radius: var(--radius);
    padding: 22px;
    color: #fff;
    box-shadow: var(--shadow);
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-height: 150px;
}

.hero-card.variant-2 {
    background: var(--grad-2);
}

.hero-card.variant-success {
    background: var(--grad-success);
}

.hero-card.variant-danger {
    background: var(--grad-danger);
}

.hero-card.variant-info {
    background: var(--grad-info);
}

.hero-card.variant-warning {
    background: var(--grad-warning);
}

.hero-card.variant-albinism {
    background: var(--grad-albinism);
}

.hero-card::before {
    content: '';
    position: absolute;
    top: -60px;
    right: -60px;
    width: 190px;
    height: 190px;
    border-radius: 50%;
    background: rgba(255, 255, 255, .08);
    pointer-events: none;
}

.hero-icon {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.18);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 15px;
    margin-bottom: 12px;
}

.hero-value {
    font-size: 2.1rem;
    font-weight: 800;
    letter-spacing: -0.02em;
    line-height: 1.1;
}

.hero-value.skel {
    color: transparent;
    background: rgba(255, 255, 255, 0.25);
    border-radius: var(--radius);
    animation: pulse 1.4s ease-in-out infinite;
    display: inline-block;
    min-width: 100px;
}

.hero-label {
    font-size: 0.82rem;
    opacity: 0.85;
    margin-top: 4px;
}

.hero-sub {
    display: flex;
    gap: 16px;
    margin-top: 16px;
    font-size: 0.74rem;
    opacity: 0.9;
    flex-wrap: wrap;
}

.hero-sub strong {
    font-weight: 700;
    margin-left: 4px;
}

@keyframes pulse {

    0%,
    100% {
        opacity: .55;
    }

    50% {
        opacity: 1;
    }
}

/* ---------------- Grid panels ---------------- */
.grid-2 {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 16px;
    margin-bottom: 16px;
    min-width: 0;
}

.grid-2>* {
    min-width: 0;
}

.grid-3 {
    display: grid;
    grid-template-columns: 1.2fr 1fr 0.9fr;
    gap: 16px;
    margin-bottom: 16px;
    min-width: 0;
}

.grid-3>* {
    min-width: 0;
}

@media (max-width: 1100px) {

    .grid-2,
    .grid-3 {
        grid-template-columns: 1fr;
    }
}

.panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px 20px;
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.panel .panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 14px;
    gap: 10px;
}

.panel .panel-head h3 {
    font-size: 0.92rem;
    font-weight: 700;
    margin: 0;
    letter-spacing: -0.01em;
}

.panel select.pill-select {
    font-size: 0.75rem;
    border: 1px solid var(--border);
    background: var(--surface-2);
    color: var(--red);
    border-radius: 999px;
    padding: 5px 10px;
    font-family: inherit;
    font-weight: 600;
}

.combo-row {
    display: flex;
    flex-wrap: wrap;
    gap: 18px;
    align-items: center;
}

.combo-row .chart-col {
    flex: 1;
    min-width: 0;
    height: 210px;
    position: relative;
}

.ring-col {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
    width: 150px;
}

.ring-wrap {
    position: relative;
    width: 140px;
    height: 140px;
}

.ring-wrap canvas {
    width: 100% !important;
    height: 100% !important;
}

.ring-center {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.35rem;
    font-weight: 800;
    color: var(--red);
}

.ring-label {
    font-size: 0.78rem;
    color: var(--muted);
    text-align: center;
}

.legend-chips {
    display: flex;
    gap: 14px;
    font-size: 0.72rem;
    color: var(--muted);
}

.legend-chips .chip {
    display: flex;
    align-items: center;
    gap: 5px;
}

.legend-chips .dot {
    width: 8px;
    height: 8px;
    border-radius: 3px;
}

.rings-panel {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-around;
    align-items: center;
    gap: 16px;
    flex: 1;
}

.rings-panel .ring-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.rings-panel .ring-wrap {
    width: 118px;
    height: 118px;
}

.rings-panel .ring-center {
    font-size: 1.15rem;
}

.area-chart-wrap {
    position: relative;
    flex: 1;
    min-height: 220px;
    min-width: 0;
}

.list-panel .list-head {
    display: flex;
    justify-content: space-between;
    font-size: 0.68rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--muted);
    padding: 0 4px 8px;
    border-bottom: 1px solid var(--border);
}

.list-panel .list-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 4px;
    border-bottom: 1px solid var(--border);
    font-size: 0.85rem;
}

.list-panel .list-row:last-child {
    border-bottom: none;
}

.list-panel .list-row .name {
    display: flex;
    align-items: center;
    gap: 10px;
}

.list-panel .list-row .bullet {
    width: 8px;
    height: 8px;
    border-radius: 2px;
    background: var(--red);
    flex-shrink: 0;
}

.list-panel .list-row .val {
    font-weight: 700;
}

.gradient-card {
    background: var(--grad);
    border-radius: var(--radius);
    padding: 22px;
    color: #fff;
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    min-height: 210px;
    position: relative;
    overflow: hidden;
}

.gradient-card.variant-info {
    background: var(--grad-info);
}

.gradient-card.variant-albinism {
    background: var(--grad-albinism);
}

.gradient-card::before {
    content: '';
    position: absolute;
    top: -50px;
    right: -50px;
    width: 180px;
    height: 180px;
    border-radius: 50%;
    background: rgba(255, 255, 255, .07);
    pointer-events: none;
}

.gradient-card .value {
    font-size: 3rem;
    font-weight: 800;
    letter-spacing: -0.02em;
    line-height: 1.05;
}

.gradient-card .label {
    font-size: 0.78rem;
    opacity: 0.85;
    margin-top: 2px;
}

.gradient-card .breakdown {
    margin-top: 16px;
}

.gradient-card .bar-track {
    height: 10px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.22);
    overflow: hidden;
    display: flex;
}

.gradient-card .bar-track div {
    height: 100%;
}

.gradient-card .breakdown-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 10px 14px;
    margin-top: 10px;
    font-size: 0.7rem;
    opacity: 0.95;
}

.gradient-card .breakdown-legend .chip {
    display: flex;
    align-items: center;
    gap: 5px;
}

.gradient-card .breakdown-legend .dot {
    width: 7px;
    height: 7px;
    border-radius: 2px;
}

.gradient-card .province-list {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 10px;
    margin: 8px 0;
}

.gradient-card .province-row {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.86rem;
}

.gradient-card .province-row .pr-dot {
    width: 9px;
    height: 9px;
    border-radius: 2px;
    flex-shrink: 0;
}

.gradient-card .province-row .pr-name {
    flex: 1;
    min-width: 0;
    opacity: 0.92;
}

.gradient-card .province-row .pr-value {
    font-weight: 700;
}

/* ---------------- Detail sections ---------------- */
section.block {
    margin-bottom: 36px;
    scroll-margin-top: 116px;
}

#visao-geral {
    scroll-margin-top: 116px;
}

.block-head {
    display: flex;
    align-items: baseline;
    gap: 10px;
    margin-bottom: 14px;
}

.block-head h2 {
    font-size: 1rem;
    font-weight: 700;
    margin: 0;
    letter-spacing: -0.01em;
}

.block-head .badge {
    font-size: 0.66rem;
    font-weight: 700;
    padding: 3px 9px;
    border-radius: 999px;
    background: var(--grad-soft);
    color: var(--red);
}

.cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
    gap: 12px;
    margin-bottom: 14px;
}

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px 16px;
    box-shadow: var(--shadow);
}

.card .label {
    font-size: 0.7rem;
    color: var(--muted);
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 6px;
}

.card .swatch {
    width: 8px;
    height: 8px;
    border-radius: 2px;
}

.card .value {
    font-size: 1.4rem;
    font-weight: 700;
    margin-top: 5px;
}

.card .sub {
    font-size: 0.7rem;
    margin-top: 4px;
    color: var(--muted-2);
}

.card.male .swatch {
    background: var(--male);
}

.card.male .value {
    color: var(--male);
}

.card.female .swatch {
    background: var(--female);
}

.card.female .value {
    color: var(--female);
}

.card.active .swatch {
    background: var(--active);
}

.card.active .value {
    color: var(--active);
}

.card.suppressed .swatch {
    background: var(--suppressed);
}

.card.suppressed .value {
    color: var(--suppressed);
}

.charts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 14px;
    min-width: 0;
}

.charts-grid>* {
    min-width: 0;
}

.chart-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    height: 270px;
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
}

.chart-card h4 {
    font-size: 0.78rem;
    font-weight: 600;
    margin: 0 0 10px 0;
    color: var(--muted);
}

.chart-card .chart-wrap {
    position: relative;
    flex: 1;
    min-height: 0;
    min-width: 0;
}

/* ---------------- Card único: Geral de Pessoas unificado ---------------- */
.unified-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    gap: 22px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.unified-card .avatar {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: var(--grad-soft);
    color: var(--red);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 26px;
    flex-shrink: 0;
}

.unified-card .value {
    font-size: 2.1rem;
    font-weight: 800;
    letter-spacing: -0.02em;
}

.unified-card .label {
    font-size: 0.8rem;
    color: var(--muted);
    margin-top: 2px;
}

.unified-card .mini-badges {
    display: flex;
    gap: 10px;
    margin-left: auto;
    flex-wrap: wrap;
}

.unified-card .mini-badge {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: var(--radius);
    font-size: 0.78rem;
    font-weight: 700;
    background: var(--surface-2);
    border: 1px solid var(--border);
}

.unified-card .mini-badge.male {
    color: var(--male);
}

.unified-card .mini-badge.female {
    color: var(--female);
}

.unified-card .note {
    flex-basis: 100%;
    font-size: 0.72rem;
    color: var(--muted-2);
    border-top: 1px dashed var(--border);
    padding-top: 10px;
    margin-top: 6px;
}

footer.page-footer {
    text-align: center;
    color: var(--muted-2);
    font-size: 0.72rem;
    padding: 10px 0 30px;
}

@media (max-width: 640px) {
    .topbar {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        padding: env(safe-area-inset-top, 0px) 14px 0;
        gap: 8px;
    }

    .topbar .search {
        display: none;
    }

    .section-nav {
        position: fixed;
        left: 0;
        right: 0;
        padding: 0 14px;
        top: calc(64px + env(safe-area-inset-top, 0px));
    }

    .section-nav a {
        font-size: 0.74rem;
        padding: 10px 10px;
    }

    .main-content {
        /* Compensa o topbar (64px + área segura) e a section-nav (46px) fixos,
           para nenhum conteúdo ficar escondido por baixo deles. */
        padding: calc(64px + 46px + env(safe-area-inset-top, 0px) + 18px) 14px 40px;
    }

    .filters-toggle {
        padding: 12px;
    }

    .filters-body {
        padding: 16px 12px 12px;
    }

    .combo-input {
        font-size: 16px;
    }

    .combo-option {
        font-size: 0.95rem;
    }
}

@media (max-width: 480px) {
    .refresh-pill .rp-label {
        display: none;
    }

    .refresh-pill {
        padding: 7px 9px;
    }

    .cards {
        grid-template-columns: 1fr;
    }

    .icon-btn.tv-toggle {
        display: none;
    }
}

/* ---------------- Painel "Cadastrados": donut + lista de legenda com valores/% ---------------- */

.donut-legend-panel .donut-legend-row {
    display: flex;
    align-items: center;
    gap: 26px;
    flex-wrap: wrap;
}

.donut-center-wrap {
    position: relative;
    width: 168px;
    height: 168px;
    flex-shrink: 0;
    margin: 0 auto;
}

.donut-center-text {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    pointer-events: none;
}

.donut-center-text .dc-value {
    font-size: 1.5rem;
    font-weight: 800;
    letter-spacing: -0.02em;
    line-height: 1.1;
}

.donut-center-text .dc-label {
    font-size: 0.68rem;
    color: var(--muted);
    margin-top: 2px;
}

.donut-legend-list {
    flex: 1;
    min-width: 240px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.donut-legend-list .dl-group-title {
    font-size: 0.66rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--muted-2);
    padding: 10px 4px 4px;
}

.donut-legend-list .dl-group-title:first-child {
    padding-top: 0;
}

.dl-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 7px 4px;
    border-radius: var(--radius);
}

.dl-row:hover {
    background: var(--surface-2);
}

.dl-row .dl-dot {
    width: 9px;
    height: 9px;
    border-radius: 2px;
    flex-shrink: 0;
}

.dl-row .dl-label {
    font-size: 0.8rem;
    color: var(--text);
    flex: 0 1 auto;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.dl-row .dl-connector {
    flex: 1 1 auto;
    min-width: 16px;
    border-bottom: 1px dotted var(--border);
    margin: 0 2px;
    align-self: center;
    height: 0;
}

.dl-row .dl-value {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--text);
    white-space: nowrap;
}

.dl-row .dl-pct {
    font-size: 0.7rem;
    color: var(--muted);
    min-width: 38px;
    text-align: right;
    white-space: nowrap;
}

@media (max-width: 640px) {
    .donut-legend-panel .donut-legend-row {
        flex-direction: column;
        align-items: stretch;
    }

    .donut-legend-list {
        min-width: 0;
    }
}