/* App Stylesheet - ObrasGov + Transferegov Federal Visualizer */

:root {
    --primary: #1e3a8a;
    --primary-light: #2563eb;
    --primary-dark: #0f172a;
    --bg-page: #f8fafc;
    --bg-card: #ffffff;
    --text-main: #0f172a;
    --text-muted: #64748b;
    --border-color: #e2e8f0;
    --border-focus: #3b82f6;
    --success: #10b981;
    --warning: #d97706;
    --danger: #ef4444;
    --info: #0ea5e9;

    /* Presidents colors */
    --color-lula: #e63946;
    --color-bolsonaro: #1d3557;
    --color-dilma: #a8201a;
    --color-temer: #2a9d8f;
    --color-fhc: #457b9d;
    --color-other: #6c757d;

    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.05);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.08), 0 2px 4px -2px rgba(0,0,0,0.05);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.1), 0 4px 6px -4px rgba(0,0,0,0.05);
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background-color: var(--bg-page);
    color: var(--text-main);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

/* Header */
.app-header {
    background: linear-gradient(135deg, #0b1e36 0%, #173b6c 100%);
    color: #ffffff;
    padding: 1rem 1.5rem;
    box-shadow: 0 2px 10px rgba(0,0,0,0.15);
    position: sticky;
    top: 0;
    z-index: 1000;
}

.header-container {
    max-width: 1440px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
}

.logo-area {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.logo-badge {
    background: #ffffff;
    color: #0b1e36;
    font-family: 'Outfit', sans-serif;
    font-weight: 800;
    font-size: 1.1rem;
    padding: 0.35rem 0.75rem;
    border-radius: var(--radius-sm);
    letter-spacing: 0.5px;
    box-shadow: var(--shadow-sm);
}

.header-titles h1 {
    font-family: 'Outfit', sans-serif;
    font-size: 1.35rem;
    font-weight: 700;
    letter-spacing: -0.01em;
}

.header-titles p {
    font-size: 0.85rem;
    color: #94a3b8;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.btn-transparency {
    background: rgba(255, 255, 255, 0.15);
    color: #ffffff;
    border: 1px solid rgba(255, 255, 255, 0.25);
    padding: 0.45rem 0.85rem;
    border-radius: var(--radius-sm);
    font-size: 0.82rem;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    font-weight: 600;
    transition: all 0.2s ease;
}

.btn-transparency:hover {
    background: rgba(255, 255, 255, 0.25);
}

.header-status {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(8px);
    padding: 0.4rem 0.85rem;
    border-radius: 9999px;
    font-size: 0.8rem;
    color: #cbd5e1;
    border: 1px solid rgba(255, 255, 255, 0.15);
}

.status-pulse {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #10b981;
    display: inline-block;
    box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7);
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7); }
    70% { transform: scale(1); box-shadow: 0 0 0 6px rgba(16, 185, 129, 0); }
    100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

/* Main Container */
.app-main {
    max-width: 1440px;
    margin: 1.5rem auto;
    padding: 0 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

/* Toolbar & Filters */
.toolbar-section {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: 1rem 1.25rem;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.toolbar-main {
    display: grid;
    grid-template-columns: minmax(240px, 1.6fr) minmax(170px, 1fr) minmax(170px, 1fr) auto;
    gap: 0.75rem;
    align-items: end;
}

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

.filter-more {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 0.75rem;
    padding: 0.85rem;
    background: #f8fafc;
    border: 1px dashed var(--border-color);
    border-radius: var(--radius-md);
}

.filter-more[hidden] { display: none; }

.filter-count-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 9px;
    background: var(--primary-light);
    color: #fff;
    font-size: 0.7rem;
    font-weight: 700;
}

.filter-count-badge[hidden] { display: none; }

#toggle-more-filters.active {
    background: #eff6ff;
    border-color: #bfdbfe;
    color: var(--primary);
}

.btn-ghost {
    background: transparent;
    border: 1.5px solid transparent;
    color: #64748b;
}

.btn-ghost:hover { background: #f1f5f9; color: var(--text-main); }

.btn-ghost.is-active { color: #b91c1c; }

.active-chips {
    display: none;
    flex-wrap: wrap;
    gap: 0.4rem;
}

.active-chips.has-chips { display: flex; }

.filter-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.3rem 0.45rem 0.3rem 0.75rem;
    border-radius: 999px;
    border: 1px solid #bfdbfe;
    background: #eff6ff;
    color: #1e3a8a;
    font: 600 0.8rem/1.2 inherit;
    font-family: inherit;
    cursor: pointer;
    white-space: nowrap;
}

.filter-chip span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #dbeafe;
    font-size: 0.85rem;
    line-height: 1;
}

.filter-chip:hover span { background: #1e3a8a; color: #fff; }

.search-box {
    position: relative;
    width: 100%;
    min-width: 0;
}

.search-icon {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    width: 20px;
    height: 20px;
    color: #94a3b8;
    pointer-events: none;
}

.search-box input {
    width: 100%;
    padding: 0.75rem 2.5rem 0.75rem 2.85rem;
    font-size: 0.95rem;
    border: 1.5px solid var(--border-color);
    border-radius: var(--radius-md);
    outline: none;
    transition: all 0.2s ease;
    background: #f8fafc;
}

.search-box input:focus {
    border-color: var(--primary-light);
    background: #ffffff;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.clear-btn {
    position: absolute;
    right: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    font-size: 1.1rem;
    color: #94a3b8;
    cursor: pointer;
    padding: 0.25rem;
}

.autocomplete-dropdown {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    background: #ffffff;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    z-index: 2000;
    max-height: 280px;
    overflow-y: auto;
    display: none;
}

.autocomplete-dropdown.active {
    display: block;
}

.autocomplete-item {
    padding: 0.7rem 1rem;
    cursor: pointer;
    border-bottom: 1px solid #f1f5f9;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: background 0.15s ease;
}

.autocomplete-item:hover {
    background: #eff6ff;
}

.autocomplete-item .mun-name {
    font-weight: 600;
    color: var(--text-main);
}

.autocomplete-item .mun-count {
    font-size: 0.8rem;
    background: #e2e8f0;
    padding: 0.2rem 0.5rem;
    border-radius: 9999px;
    color: #475569;
}

.filter-item {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    min-width: 0;
}

.filter-item label {
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    color: #64748b;
}

.filter-item select {
    width: 100%;
    height: 44px;
    padding: 0 0.75rem;
    border-radius: var(--radius-md);
    border: 1.5px solid var(--border-color);
    background: #ffffff;
    font-size: 0.9rem;
    color: var(--text-main);
    outline: none;
    cursor: pointer;
    transition: border 0.2s ease;
    text-overflow: ellipsis;
}

.filter-item select:focus {
    border-color: var(--primary-light);
}

.toolbar-section .search-box input { height: 44px; padding-top: 0; padding-bottom: 0; }
.toolbar-actions .btn { height: 44px; }

@media (max-width: 1024px) {
    .toolbar-main { grid-template-columns: 1fr 1fr; }
    .toolbar-main .filter-item-search,
    .toolbar-main .search-box { grid-column: 1 / -1; }
    .toolbar-actions { grid-column: 1 / -1; }
    .toolbar-actions #toggle-more-filters { flex: 1; justify-content: center; }
    .filter-more { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 600px) {
    .toolbar-main { grid-template-columns: 1fr; }
    .filter-more { grid-template-columns: 1fr; }
}

.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.55rem 1rem;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: all 0.2s ease;
    text-decoration: none;
}

.btn-secondary {
    background: #f1f5f9;
    color: #475569;
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background: #e2e8f0;
    color: var(--text-main);
}

.btn-sm {
    padding: 0.35rem 0.7rem;
    font-size: 0.8rem;
}

.btn-xs {
    padding: 0.2rem 0.5rem;
    font-size: 0.75rem;
    background: #e0f2fe;
    color: #0369a1;
    border: 1px solid #bae6fd;
    border-radius: 4px;
}

.btn-xs:hover {
    background: #bae6fd;
}

/* Map Section */
.map-section {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
    overflow: hidden;
}

.map-header {
    padding: 0.85rem 1.25rem;
    background: #f8fafc;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.map-title-bar {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.map-tag {
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.5px;
    background: #0f172a;
    color: #ffffff;
    padding: 0.2rem 0.55rem;
    border-radius: 4px;
}

#map-indicator-text {
    font-size: 0.85rem;
    color: #64748b;
}

.map-legend {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    flex-wrap: wrap;
    font-size: 0.8rem;
    font-weight: 500;
    color: #475569;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

.legend-color {
    width: 11px;
    height: 11px;
    border-radius: 50%;
    display: inline-block;
}

#map-container {
    position: relative;
    width: 100%;
    height: 520px;
    contain: layout paint;
}

#leaflet-map {
    width: 100%;
    height: 100%;
    z-index: 10;
}

.map-loader-overlay {
    position: absolute;
    inset: 0;
    background: rgba(255, 255, 255, 0.75);
    backdrop-filter: blur(3px);
    z-index: 50;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 0.75rem;
    font-size: 0.9rem;
    color: #475569;
    font-weight: 500;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
}

.map-loader-overlay.active {
    opacity: 1;
    pointer-events: all;
}

.spinner {
    width: 32px;
    height: 32px;
    border: 3px solid #e2e8f0;
    border-top-color: var(--primary-light);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Section Card */
.section-card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
}

/* Municipio Header */
.municipio-header-card {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1.5rem;
    border-left: 5px solid var(--primary-light);
}

.mun-title-wrap h2 {
    font-family: 'Outfit', sans-serif;
    font-size: 1.75rem;
    font-weight: 800;
    color: var(--text-main);
    line-height: 1.2;
}

.mun-ibge-badge {
    display: inline-block;
    font-size: 0.75rem;
    font-weight: 700;
    background: #e0f2fe;
    color: #0369a1;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    margin-bottom: 0.35rem;
}

.mun-title-wrap p {
    font-size: 0.95rem;
    color: #64748b;
    margin-top: 0.2rem;
}

.mun-social-indicators {
    display: flex;
    gap: 0.75rem;
    margin-top: 0.4rem;
    font-size: 0.8rem;
    color: #475569;
}

.mun-quick-metrics {
    display: flex;
    gap: 1.25rem;
    flex-wrap: wrap;
}

.metric-box {
    background: #f8fafc;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 0.85rem 1.25rem;
    display: flex;
    flex-direction: column;
    min-width: 150px;
}

.metric-box.transfer-box {
    border-color: #bbf7d0;
    background: #f0fdf4;
}

.metric-label {
    font-size: 0.75rem;
    color: #64748b;
    text-transform: uppercase;
    font-weight: 600;
    letter-spacing: 0.5px;
}

.metric-value {
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--text-main);
    margin-top: 0.2rem;
}

.metric-value.highlight {
    color: var(--primary);
}

.metric-sub {
    font-size: 0.75rem;
    color: #64748b;
    margin-top: 0.2rem;
}

.text-success {
    color: #15803d !important;
}

/* Presidential Comparison Card */
.presidential-insight-card {
    background: linear-gradient(135deg, #f8fafc 0%, #edf2f7 100%);
    border-left: 5px solid #e63946;
    margin-top: 1.25rem;
}

.insight-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1rem;
}

.insight-icon {
    font-size: 2rem;
    background: #ffffff;
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-sm);
}

.insight-titles h3 {
    font-family: 'Outfit', sans-serif;
    font-size: 1.25rem;
    font-weight: 700;
}

.insight-titles p {
    font-size: 0.9rem;
    color: #475569;
}

.toggle-tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.tab-btn {
    padding: 0.4rem 0.85rem;
    border-radius: 9999px;
    border: 1px solid var(--border-color);
    background: #ffffff;
    font-size: 0.82rem;
    font-weight: 600;
    color: #475569;
    cursor: pointer;
    transition: all 0.2s ease;
}

.tab-btn.active {
    background: #0f172a;
    color: #ffffff;
    border-color: #0f172a;
}

.president-comparison-bars {
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
}

.pres-bar-item {
    background: #ffffff;
    border-radius: var(--radius-md);
    padding: 0.9rem 1.25rem;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
}

.pres-bar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.45rem;
    font-size: 0.95rem;
}

.pres-bar-name {
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.pres-color-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    display: inline-block;
}

.pres-bar-stats {
    font-weight: 600;
    color: #334155;
    font-size: 0.9rem;
}

.bar-track {
    width: 100%;
    height: 10px;
    background: #f1f5f9;
    border-radius: 9999px;
    overflow: hidden;
}

.bar-fill {
    height: 100%;
    border-radius: 9999px;
    transition: width 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Paired Comparison Bars (Obras + Recursos colados) */
.paired-bars-container {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin: 0.5rem 0 0.35rem;
}

.paired-bar-row {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.paired-bar-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.78rem;
    color: #475569;
}

.paired-bar-meta .meta-label {
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.paired-bar-meta .meta-val {
    font-weight: 700;
    color: #0f172a;
}

.bar-track-obras {
    height: 9px;
    background: #f1f5f9;
    border-radius: 9999px;
    overflow: hidden;
}

.bar-track-recursos {
    height: 7px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 9999px;
    overflow: hidden;
}

.bar-fill-recursos {
    height: 100%;
    border-radius: 9999px;
    opacity: 0.82;
    background-image: repeating-linear-gradient(45deg, transparent, transparent 5px, rgba(255,255,255,0.45) 5px, rgba(255,255,255,0.45) 10px);
    transition: width 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}

.divergence-notice-box {
    background: #fffbeb;
    border: 1px solid #fde68a;
    border-radius: var(--radius-md);
    padding: 0.65rem 0.95rem;
    font-size: 0.82rem;
    color: #92400e;
    margin-bottom: 0.85rem;
    line-height: 1.45;
}

.badge-divergence {
    background: #fef3c7;
    color: #92400e;
    border: 1px solid #fde68a;
    font-size: 0.72rem;
    padding: 2px 7px;
    border-radius: 4px;
    font-weight: 700;
}

.map-header-controls {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.map-metric-toggle {
    display: inline-flex;
    background: #e2e8f0;
    border-radius: 6px;
    padding: 2px;
}

.map-metric-toggle .tab-btn {
    padding: 0.25rem 0.6rem;
    font-size: 0.76rem;
    font-weight: 600;
    border-radius: 4px;
    border: none;
    background: transparent;
    cursor: pointer;
    color: #475569;
}

.map-metric-toggle .tab-btn.active {
    background: #ffffff;
    color: #1e3a8a;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.pres-bar-footer {
    display: flex;
    justify-content: space-between;
    margin-top: 0.35rem;
    font-size: 0.78rem;
    color: #64748b;
}

/* Charts Grid */
.charts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 1.25rem;
    margin-top: 1.25rem;
}

.chart-card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
}

.chart-header {
    margin-bottom: 1rem;
}

.chart-header h4 {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--text-main);
}

.chart-sub {
    font-size: 0.8rem;
    color: #64748b;
}

.chart-canvas-wrapper {
    position: relative;
    width: 100%;
    height: 240px;
    contain: layout paint;
}

/* Table Card */
.works-table-card {
    margin-top: 1.25rem;
}

.table-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 1rem;
}

.table-card-header h3 {
    font-size: 1.2rem;
    font-weight: 700;
}

.table-sub {
    font-size: 0.85rem;
    color: #64748b;
}

.table-filters input {
    padding: 0.5rem 0.85rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    min-width: 260px;
    outline: none;
}

.table-filters input:focus {
    border-color: var(--primary-light);
}

.table-responsive {
    overflow-x: auto;
}

.obras-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.88rem;
    text-align: left;
}

.obras-table th {
    background: #f8fafc;
    padding: 0.75rem 0.85rem;
    font-weight: 600;
    color: #475569;
    border-bottom: 2px solid var(--border-color);
    white-space: nowrap;
}

.obras-table td {
    padding: 0.75rem 0.85rem;
    border-bottom: 1px solid #f1f5f9;
    vertical-align: middle;
}

.obras-table tr:hover {
    background: #f8fafc;
}

/* Badges */
.badge {
    display: inline-block;
    padding: 0.2rem 0.55rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
    white-space: nowrap;
}

.badge-concluida { background: #dcfce7; color: #15803d; }
.badge-execucao { background: #e0f2fe; color: #0369a1; }
.badge-cadastrada { background: #fef3c7; color: #b45309; }
.badge-paralisada { background: #fee2e2; color: #b91c1c; }
.badge-cancelada { background: #f1f5f9; color: #475569; }

.badge-warning {
    background: #fffbeb;
    color: #b45309;
    border: 1px solid #fde68a;
}

.table-pagination {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 1rem;
    font-size: 0.85rem;
    color: #64748b;
}

/* National Overview Card */
.national-overview-card {
    margin-top: 1.5rem;
    border-top: 4px solid var(--primary);
}

.card-header-styled {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.card-header-styled .icon-wrap {
    font-size: 2.2rem;
}

.card-header-styled h2 {
    font-family: 'Outfit', sans-serif;
    font-size: 1.45rem;
    font-weight: 800;
}

.card-header-styled p {
    font-size: 0.9rem;
    color: #64748b;
}

.national-stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.stat-card {
    background: #f8fafc;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 1.1rem;
    display: flex;
    flex-direction: column;
}

.stat-label {
    font-size: 0.78rem;
    color: #64748b;
    font-weight: 600;
    text-transform: uppercase;
}

.stat-number {
    font-size: 1.6rem;
    font-weight: 800;
    color: var(--text-main);
    margin: 0.25rem 0;
}

.stat-number.highlight {
    color: var(--color-lula);
}

.stat-detail {
    font-size: 0.78rem;
    color: #94a3b8;
}

.national-analysis-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.25rem;
    margin-bottom: 1.25rem;
}

@media (max-width: 900px) {
    .national-analysis-grid {
        grid-template-columns: 1fr;
    }
}

.analysis-box {
    background: #ffffff;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 1.25rem;
}

.analysis-box h3 {
    font-size: 1.05rem;
    font-weight: 700;
    margin-bottom: 1rem;
}

.national-charts-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.25rem;
}

@media (max-width: 900px) {
    .national-charts-row {
        grid-template-columns: 1fr;
    }
}

/* Modals */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(4px);
    z-index: 3000;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 1.5rem;
}

.modal-card {
    background: #ffffff;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 720px;
    max-height: 90vh;
    overflow-y: auto;
    border: 1px solid var(--border-color);
}

.modal-large {
    max-width: 860px;
}

.modal-header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

.modal-badge {
    font-size: 0.75rem;
    font-weight: 700;
    background: #e2e8f0;
    color: #475569;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
}

.modal-header h3 {
    font-size: 1.2rem;
    font-weight: 700;
    margin-top: 0.3rem;
}

.modal-close-btn {
    background: none;
    border: none;
    font-size: 1.5rem;
    line-height: 1;
    color: #94a3b8;
    cursor: pointer;
    padding: 0.2rem 0.5rem;
}

.modal-close-btn:hover {
    color: var(--text-main);
}

.modal-body {
    padding: 1.5rem;
}

.transparency-content h4 {
    font-size: 1.05rem;
    color: var(--primary);
    margin-top: 1.25rem;
    margin-bottom: 0.4rem;
}

.transparency-content p, .transparency-content ul, .transparency-content ol {
    font-size: 0.9rem;
    color: #334155;
    margin-bottom: 0.75rem;
    line-height: 1.6;
}

.transparency-content ul, .transparency-content ol {
    padding-left: 1.5rem;
}

.transparency-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
    margin-top: 0.75rem;
}

.transparency-table th {
    background: #f1f5f9;
    padding: 0.5rem 0.75rem;
    text-align: left;
    border-bottom: 2px solid #cbd5e1;
}

.transparency-table td {
    padding: 0.5rem 0.75rem;
    border-bottom: 1px solid #e2e8f0;
}

.detail-row {
    display: flex;
    flex-direction: column;
    margin-bottom: 0.85rem;
}

.detail-label {
    font-size: 0.75rem;
    color: #64748b;
    text-transform: uppercase;
    font-weight: 600;
}

.detail-value {
    font-size: 0.95rem;
    color: var(--text-main);
    font-weight: 500;
    margin-top: 0.15rem;
}

/* Ranking de Cidades por Presidente Styles */
.ranking-cidades-card {
    border-top: 4px solid #2563eb;
    margin-top: 1.5rem;
}

.ranking-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    flex-wrap: wrap;
    gap: 1.25rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border-color);
}

.ranking-header h2 {
    font-family: 'Outfit', sans-serif;
    font-size: 1.45rem;
    font-weight: 800;
    margin-top: 0.35rem;
}

.section-sub {
    font-size: 0.88rem;
    color: #64748b;
    margin-top: 0.15rem;
}

.ranking-controls {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.ranking-ctrl-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.ranking-ctrl-item label {
    font-size: 0.82rem;
    font-weight: 600;
    color: #475569;
}

.ranking-ctrl-item select {
    padding: 0.5rem 0.85rem;
    border-radius: var(--radius-sm);
    border: 1.5px solid var(--border-color);
    background: #ffffff;
    font-size: 0.85rem;
    color: var(--text-main);
    outline: none;
    cursor: pointer;
}

.ranking-ctrl-item select:focus {
    border-color: var(--primary-light);
}

.ranking-table td {
    padding: 0.85rem 1rem;
}

/* Share Bar & Deep Linking Styles */
.share-bar {
    background: #f8fafc;
    border: 1px dashed var(--border-color);
    border-radius: var(--radius-md);
    padding: 0.75rem 1.25rem;
    margin-top: 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.share-title {
    font-size: 0.85rem;
    font-weight: 600;
    color: #475569;
}

.share-buttons {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.btn-share-wa {
    background: #25d366;
    color: #ffffff;
    border: none;
}

.btn-share-wa:hover {
    background: #1ebd5a;
    color: #ffffff;
}

/* Neutrality / Impartiality Box */
.neutrality-box {
    background: #f8fafc;
    border-left: 4px solid #3b82f6;
    padding: 0.85rem 1.1rem;
    border-radius: 4px;
    font-size: 0.88rem;
    color: #334155;
    margin: 1rem 0;
    line-height: 1.5;
}

/* Toast Notification */
.toast-notification {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    background: #0f172a;
    color: #ffffff;
    padding: 0.75rem 1.25rem;
    border-radius: var(--radius-md);
    font-size: 0.9rem;
    font-weight: 500;
    box-shadow: var(--shadow-lg);
    z-index: 5000;
    opacity: 0;
    transform: translateY(20px);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    pointer-events: none;
}

.toast-notification.active {
    opacity: 1;
    transform: translateY(0);
}

/* Historical Notice Banner */
.historical-notice-banner {
    background: #fffbeb;
    border: 1px solid #fde68a;
    border-left: 5px solid #f59e0b;
    border-radius: var(--radius-md);
    padding: 0.9rem 1.25rem;
    display: flex;
    align-items: flex-start;
    gap: 0.85rem;
    color: #92400e;
    font-size: 0.88rem;
    line-height: 1.5;
    position: relative;
    box-shadow: var(--shadow-sm);
    margin-bottom: 0.5rem;
}

.notice-icon {
    font-size: 1.35rem;
    line-height: 1;
    flex-shrink: 0;
}

.notice-content {
    flex: 1;
}

.notice-content strong {
    color: #78350f;
}

.notice-content a {
    color: #b45309;
    font-weight: 700;
    text-decoration: underline;
    cursor: pointer;
}

.notice-content a:hover {
    color: #78350f;
}

.notice-close-btn {
    background: none;
    border: none;
    color: #92400e;
    font-size: 1.35rem;
    line-height: 1;
    cursor: pointer;
    padding: 0.2rem 0.5rem;
    flex-shrink: 0;
    opacity: 0.7;
    transition: opacity 0.2s;
}

.notice-close-btn:hover {
    opacity: 1;
}

/* ==========================================================================
   Comprehensive Mobile & Tablet Responsive Optimizations (Mobile-Friendly)
   ========================================================================== */

@media (max-width: 900px) {
    .charts-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    /* Touch optimization */
    html, body {
        overflow-x: hidden;
        -webkit-tap-highlight-color: transparent;
    }

    .app-header {
        padding: 0.85rem 1rem;
        position: static; /* Better scrolling experience on mobile */
    }

    .header-container {
        flex-direction: column;
        align-items: stretch;
        gap: 0.75rem;
    }

    .logo-area {
        align-items: center;
        gap: 0.65rem;
    }

    .logo-badge {
        font-size: 0.8rem;
        padding: 0.25rem 0.5rem;
    }

    .header-titles h1 {
        font-size: 1.15rem;
        line-height: 1.25;
    }

    .header-titles p {
        font-size: 0.78rem;
    }

    .header-actions {
        width: 100%;
        display: flex;
        justify-content: space-between;
        align-items: center;
        gap: 0.5rem;
    }

    .btn-transparency {
        flex: 1;
        justify-content: center;
        min-height: 40px;
        font-size: 0.8rem;
    }

    .header-status {
        font-size: 0.75rem;
        padding: 0.35rem 0.65rem;
    }

    .app-main {
        padding: 0 0.75rem;
        margin: 1rem auto;
        gap: 1rem;
    }

    /* Banner */
    .historical-notice-banner {
        padding: 0.75rem;
        font-size: 0.82rem;
        gap: 0.5rem;
    }

    /* Toolbar & Search */
    .toolbar-section {
        padding: 0.75rem;
        gap: 0.6rem;
    }

    .toolbar-main { gap: 0.5rem; }

    .search-box {
        min-width: 0;
    }

    .search-box input {
        font-size: 16px; /* evita zoom automático no iOS */
    }

    .filter-item label { font-size: 0.68rem; }
    .filter-item select { font-size: 15px; padding: 0 0.55rem; }

    .filter-more {
        grid-template-columns: 1fr 1fr;
        padding: 0.65rem;
        gap: 0.5rem;
    }

    .active-chips.has-chips {
        flex-wrap: nowrap;
        overflow-x: auto;
        scrollbar-width: none;
        margin: 0 -0.75rem;
        padding: 0 0.75rem;
    }

    .active-chips::-webkit-scrollbar { display: none; }

    /* Map */
    #map-container {
        height: 380px;
    }

    .map-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
        padding: 0.75rem 1rem;
    }

    .map-title-bar {
        width: 100%;
        justify-content: space-between;
    }

    .map-legend {
        width: 100%;
        gap: 0.5rem;
        font-size: 0.75rem;
    }

    /* Municipality Header Card */
    .section-card {
        padding: 1rem;
        border-radius: var(--radius-md);
    }

    .municipio-header-card {
        border-left-width: 4px;
        gap: 1rem;
    }

    .mun-title-wrap h2 {
        font-size: 1.4rem;
    }

    .mun-quick-metrics {
        display: grid;
        grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
        width: 100%;
        gap: 0.65rem;
    }

    .metric-box {
        min-width: 0;
        padding: 0.75rem;
    }

    .metric-value {
        font-size: 1.15rem;
    }

    /* Share Bar */
    .share-bar {
        padding: 0.75rem;
        flex-direction: column;
        align-items: stretch;
        gap: 0.65rem;
    }

    .share-title {
        text-align: center;
        font-size: 0.82rem;
    }

    .share-buttons {
        display: grid;
        grid-template-columns: 1fr;
        width: 100%;
        gap: 0.5rem;
    }

    .share-buttons .btn {
        width: 100%;
        height: 42px;
        justify-content: center;
        font-size: 0.85rem;
    }

    /* Presidential Comparison Card */
    .presidential-insight-card {
        padding: 1rem;
    }

    .insight-header {
        gap: 0.65rem;
    }

    .insight-icon {
        width: 38px;
        height: 38px;
        font-size: 1.3rem;
    }

    .insight-titles h3 {
        font-size: 1.1rem;
    }

    .insight-titles p {
        font-size: 0.82rem;
    }

    .toggle-tabs {
        width: 100%;
        display: flex;
    }

    .tab-btn {
        flex: 1;
        text-align: center;
        padding: 0.55rem 0.25rem;
        font-size: 0.8rem;
    }

    .pres-bar-item {
        padding: 0.75rem;
    }

    .pres-bar-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.2rem;
    }

    .pres-bar-footer {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.15rem;
    }

    /* Charts */
    .chart-card {
        padding: 1rem;
    }

    .chart-canvas-wrapper {
        height: 210px;
    }

    /* Table */
    .works-table-card {
        padding: 1rem;
    }

    .table-card-header {
        flex-direction: column;
        align-items: stretch;
        gap: 0.65rem;
    }

    .table-filters {
        width: 100%;
    }

    .table-filters input {
        width: 100%;
        min-width: 0;
        height: 42px;
    }

    .table-responsive {
        -webkit-overflow-scrolling: touch;
    }

    .obras-table {
        font-size: 0.82rem;
    }

    .obras-table th, .obras-table td {
        padding: 0.55rem 0.5rem;
    }

    .table-pagination {
        flex-direction: column;
        gap: 0.65rem;
        align-items: center;
    }

    .table-pagination .btn {
        min-height: 40px;
        min-width: 110px;
    }

    /* Ranking Card */
    .ranking-cidades-card {
        padding: 1rem;
    }

    .ranking-header {
        flex-direction: column;
        align-items: stretch;
        gap: 0.75rem;
    }

    .ranking-header h2 {
        font-size: 1.25rem;
    }

    .ranking-controls {
        display: grid;
        grid-template-columns: 1fr;
        width: 100%;
        gap: 0.65rem;
    }

    .ranking-ctrl-item {
        display: flex;
        flex-direction: column;
        align-items: stretch;
        width: 100%;
        gap: 0.25rem;
    }

    .ranking-ctrl-item select {
        width: 100%;
        height: 44px;
        font-size: 14px;
    }

    /* National Overview */
    .national-overview-card {
        padding: 1rem;
    }

    .card-header-styled {
        gap: 0.65rem;
    }

    .card-header-styled h2 {
        font-size: 1.25rem;
    }

    .national-stats-grid {
        grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
        gap: 0.65rem;
    }

    .stat-card {
        padding: 0.85rem;
    }

    .stat-number {
        font-size: 1.35rem;
    }

    /* Modals */
    .modal-overlay {
        padding: 0.5rem;
    }

    .modal-card {
        width: 100%;
        max-height: 94vh;
        border-radius: 12px;
    }

    .modal-header {
        padding: 0.85rem 1rem;
    }

    .modal-header h3 {
        font-size: 1.05rem;
    }

    .modal-close-btn {
        width: 44px;
        height: 44px;
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 1.75rem;
    }

    .modal-body {
        padding: 1rem;
    }

    .toast-notification {
        left: 1rem;
        right: 1rem;
        bottom: 1rem;
        text-align: center;
        font-size: 0.85rem;
    }
}

@media (max-width: 480px) {
    .mun-quick-metrics {
        grid-template-columns: 1fr;
    }

    .national-stats-grid {
        grid-template-columns: 1fr;
    }

    #map-container {
        height: 340px;
    }
}

/* Footer */
.app-footer {
    background: #0f172a;
    color: #94a3b8;
    padding: 1.5rem;
    margin-top: 3rem;
    font-size: 0.85rem;
    text-align: center;
    border-top: 1px solid #1e293b;
}

.footer-container a {
    color: #38bdf8;
    text-decoration: none;
}

.footer-container a:hover {
    text-decoration: underline;
}

/* Header brand shortcut */
.header-brand-link {
    display: flex;
    align-items: center;
    gap: 1rem;
    text-decoration: none;
    color: inherit;
    cursor: pointer;
    transition: opacity 0.2s ease;
}

.header-brand-link:hover {
    opacity: 0.92;
}

/* Floating Back to Top Button */
.back-to-top-btn {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 999;
    background: #1e3a8a;
    color: #ffffff;
    border: none;
    border-radius: 30px;
    padding: 0.65rem 1.15rem;
    font-size: 0.88rem;
    font-weight: 700;
    font-family: inherit;
    box-shadow: 0 4px 14px rgba(15, 23, 42, 0.25);
    cursor: pointer;
    opacity: 0;
    pointer-events: none;
    transform: translateY(10px);
    transition: opacity 0.25s ease, transform 0.25s ease, background 0.2s ease;
}

.back-to-top-btn.visible {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0);
}

.back-to-top-btn:hover {
    background: #2563eb;
    transform: translateY(-2px);
}

/* Mobile Hamburger Menu */
.mobile-menu-btn {
    display: none;
    background: rgba(255, 255, 255, 0.12);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    color: #ffffff;
    font-size: 1.4rem;
    line-height: 1;
    padding: 0.4rem 0.65rem;
    cursor: pointer;
}

@media (max-width: 768px) {
    .mobile-menu-btn {
        display: block;
    }
}

.mobile-drawer-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(15, 23, 42, 0.65);
    backdrop-filter: blur(4px);
    z-index: 10000;
    display: flex;
    justify-content: flex-end;
}

.mobile-drawer-content {
    background: #ffffff;
    width: 84%;
    max-width: 320px;
    height: 100%;
    padding: 1.5rem;
    box-shadow: -4px 0 20px rgba(0,0,0,0.25);
    display: flex;
    flex-direction: column;
    animation: drawerSlide 0.25s ease-out;
}

@keyframes drawerSlide {
    from { transform: translateX(100%); }
    to { transform: translateX(0); }
}

.mobile-drawer-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 1rem;
    margin-bottom: 1.25rem;
}

.mobile-drawer-header h3 {
    font-family: 'Outfit', sans-serif;
    font-size: 1.15rem;
    color: var(--text-main);
}

.mobile-drawer-links {
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
    overflow-y: auto;
}

.drawer-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    border-radius: 8px;
    color: var(--text-main);
    text-decoration: none;
    font-weight: 600;
    font-size: 0.95rem;
    background: #f8fafc;
    border: 1px solid #f1f5f9;
    transition: all 0.15s ease;
}

.drawer-link:hover {
    background: #e0f2fe;
    color: var(--primary-light);
}

/* Collapsible Notice Banner */
.historical-notice-banner {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    background: #fffbeb;
    border: 1px solid #fde68a;
    border-left: 5px solid #f59e0b;
    border-radius: var(--radius-md);
    padding: 0.85rem 1.25rem;
    color: #92400e;
    font-size: 0.88rem;
    box-shadow: var(--shadow-sm);
}

.notice-top-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
}

.notice-title-wrap {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
    font-weight: 700;
    color: #92400e;
}

.notice-actions-wrap {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.notice-toggle-btn {
    background: rgba(245, 158, 11, 0.15);
    border: 1px solid rgba(245, 158, 11, 0.35);
    color: #92400e;
    font-size: 0.78rem;
    font-weight: 700;
    padding: 0.25rem 0.6rem;
    border-radius: 4px;
    cursor: pointer;
}

.notice-body-collapsible {
    font-size: 0.84rem;
    line-height: 1.5;
    color: #78350f;
    border-top: 1px dashed rgba(245, 158, 11, 0.3);
    padding-top: 0.5rem;
    margin-top: 0.25rem;
}

@media (max-width: 768px) {
    .notice-body-collapsible {
        display: none;
    }
    .notice-body-collapsible.open {
        display: block;
    }
}

@media (min-width: 769px) {
    .notice-toggle-btn {
        display: none;
    }
    .notice-body-collapsible {
        display: block !important;
    }
}

/* ==========================================================================
   Sortable Columns, Enhanced Pagination & Methodology Modal Styles
   ========================================================================== */

.obras-table th.sortable-th {
    cursor: pointer;
    user-select: none;
    transition: background-color 0.15s ease, color 0.15s ease;
}

.obras-table th.sortable-th:hover {
    background: #eef2ff;
    color: #1e3a8a;
}

.obras-table th.sortable-th.active-sort {
    background: #e0f2fe;
    color: #0f172a;
    border-bottom-color: #0284c7;
}

.sort-indicator {
    display: inline-block;
    margin-left: 4px;
    font-size: 0.78rem;
    color: #94a3b8;
    font-weight: 700;
}

.obras-table th.sortable-th.active-sort .sort-indicator {
    color: #0284c7;
}

.table-pagination {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.85rem;
    margin-top: 1.15rem;
    padding-top: 0.85rem;
    border-top: 1px solid #e2e8f0;
    font-size: 0.85rem;
    color: #475569;
}

.pagination-info {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.page-size-label {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.82rem;
    color: #64748b;
}

.page-size-select {
    padding: 0.25rem 0.5rem;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background: #ffffff;
    font-size: 0.82rem;
    font-weight: 600;
    color: #0f172a;
    cursor: pointer;
}

.pagination-controls {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    flex-wrap: wrap;
}

.page-numbers {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
}

.page-num-btn {
    min-width: 32px;
    height: 32px;
    padding: 0 0.5rem;
    border-radius: 6px;
    border: 1px solid var(--border-color);
    background: #ffffff;
    color: #334155;
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s ease;
}

.page-num-btn:hover {
    background: #f1f5f9;
    border-color: #cbd5e1;
}

.page-num-btn.active {
    background: #1e3a8a;
    color: #ffffff;
    border-color: #1e3a8a;
}

.page-ellipsis {
    padding: 0 0.25rem;
    color: #94a3b8;
    font-weight: 600;
}

.methodology-body h4 {
    font-size: 1.02rem;
    font-weight: 700;
    color: #0f172a;
    margin-top: 1.25rem;
    margin-bottom: 0.45rem;
}

.methodology-body p {
    margin-bottom: 0.75rem;
}

.methodology-callout {
    background: #f0f9ff;
    border: 1px solid #bae6fd;
    border-left: 4px solid #0284c7;
    border-radius: 8px;
    padding: 0.9rem 1.1rem;
    margin-bottom: 1.1rem;
    font-size: 0.9rem;
    color: #0c4a6e;
}

.methodology-api-links {
    margin-top: 0.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    font-size: 0.86rem;
}

.methodology-api-links a {
    color: #0369a1;
    font-weight: 700;
    text-decoration: underline;
    word-break: break-all;
}

.methodology-api-links code {
    background: #e0f2fe;
    color: #075985;
    padding: 0.12rem 0.4rem;
    border-radius: 4px;
    font-size: 0.82rem;
    word-break: break-all;
}

.methodology-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

.methodology-table th {
    background: #f1f5f9;
    color: #334155;
    font-weight: 700;
    text-align: left;
    padding: 0.55rem 0.75rem;
    border-bottom: 2px solid #cbd5e1;
}

.methodology-table td {
    padding: 0.5rem 0.75rem;
    border-bottom: 1px solid #e2e8f0;
    color: #334155;
}

/* ==========================================================================
   Filter Context Stamps (Anti-Out-of-Context Screenshots), Map Hints & Dominance
   ========================================================================== */

.filter-context-stamp {
    background: #fffbeb;
    border: 1.5px solid #f59e0b;
    border-left: 5px solid #d97706;
    color: #92400e;
    padding: 0.6rem 0.95rem;
    border-radius: 8px;
    font-size: 0.84rem;
    line-height: 1.45;
    margin: 0.75rem 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    box-shadow: 0 1px 3px rgba(245, 158, 11, 0.12);
}

.filter-context-stamp[hidden] {
    display: none !important;
}

.map-zoom-hint {
    position: absolute;
    top: 16px;
    left: 50%;
    transform: translateX(-50%) translateY(-8px);
    z-index: 1100;
    background: rgba(15, 23, 42, 0.88);
    color: #ffffff;
    padding: 0.5rem 1rem;
    border-radius: 999px;
    font-size: 0.82rem;
    font-weight: 600;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.22s ease, transform 0.22s ease;
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.28);
    white-space: nowrap;
}

.map-zoom-hint.visible {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.map-zoom-hint kbd {
    background: rgba(255, 255, 255, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.35);
    border-radius: 4px;
    padding: 0.08rem 0.38rem;
    font-family: inherit;
    font-size: 0.78rem;
}

.map-mobile-pan-btn {
    display: none;
    position: absolute;
    bottom: 14px;
    left: 14px;
    z-index: 1100;
    background: rgba(15, 23, 42, 0.86);
    color: #ffffff;
    border: 1px solid rgba(255, 255, 255, 0.28);
    border-radius: 999px;
    padding: 0.45rem 0.85rem;
    font-size: 0.78rem;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
    align-items: center;
    gap: 0.35rem;
}

.map-mobile-pan-btn.active {
    background: #1d4ed8;
    border-color: #93c5fd;
}

.badge-majority {
    background: #fef3c7;
    color: #92400e;
    border: 1px solid #f59e0b;
    font-weight: 700;
}

.pres-bar-item.is-filtered-target {
    background: #eff6ff;
    border: 1.5px solid #93c5fd;
    padding: 0.55rem 0.65rem !important;
    border-radius: 8px;
}

.chart-footnote {
    font-size: 0.76rem;
    color: #64748b;
    line-height: 1.45;
    margin-top: 0.55rem;
    padding-top: 0.45rem;
    border-top: 1px dashed #e2e8f0;
}

.dominancia-regional-box {
    background: #f8fafc;
    border: 1px solid #cbd5e1;
}

.dominancia-header h3 {
    font-size: 1.1rem;
    font-weight: 800;
    color: #0f172a;
    margin-bottom: 0.25rem;
}

.dominancia-sub {
    font-size: 0.84rem;
    color: #475569;
    margin-bottom: 0.85rem;
    line-height: 1.45;
}

.dominancia-table th {
    font-size: 0.78rem;
    background: #f1f5f9;
}

.dominancia-table td {
    padding: 0.65rem 0.75rem;
    vertical-align: middle;
}

.dom-cell-highlight {
    background: #fffbeb;
}

.dom-row-total {
    background: #f1f5f9;
    border-top: 2px solid #cbd5e1;
}

/* Footer Commit Version Badge & Popover */
.footer-version-wrap {
    margin-top: 0.65rem;
    display: flex;
     flex-direction: column;
    align-items: center;
    gap: 0.45rem;
    position: relative;
}

.footer-commit-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    background: #e2e8f0;
    color: #334155;
    border: 1px solid #cbd5e1;
    border-radius: 999px;
    padding: 0.28rem 0.75rem;
    font-size: 0.78rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s ease;
    font-family: inherit;
}

.footer-commit-badge:hover,
.footer-commit-badge[aria-expanded="true"] {
    background: #dbeafe;
    border-color: #93c5fd;
    color: #1e3a8a;
}

.footer-commit-badge code {
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-weight: 700;
    font-size: 0.78rem;
    color: #0f172a;
}

.commit-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #10b981;
    display: inline-block;
}

.footer-commit-popover {
    background: #0f172a;
    color: #f8fafc;
    padding: 0.45rem 0.85rem;
    border-radius: 8px;
    font-size: 0.78rem;
    line-height: 1.4;
    box-shadow: 0 6px 18px rgba(15, 23, 42, 0.25);
    text-align: center;
    max-width: 92vw;
}

.footer-commit-popover[hidden] {
    display: none !important;
}

.footer-commit-popover code {
    background: rgba(255, 255, 255, 0.15);
    padding: 0.1rem 0.35rem;
    border-radius: 4px;
    color: #38bdf8;
    font-weight: 700;
}

/* ==========================================================================
   Filtered Indicator Highlighting, Compact Ranking Bars & Mobile CSS Fixes
   ========================================================================== */

html, body {
    max-width: 100%;
    overflow-x: hidden;
}

.app-main > *,
.section-card,
.analysis-box,
.chart-card,
.national-analysis-grid > *,
.national-charts-row > *,
.charts-grid > *,
.municipio-grid > * {
    min-width: 0;
    max-width: 100%;
}

.stat-card.is-filtered-card,
.metric-box.is-filtered-card {
    background: #eff6ff;
    border: 2px solid #3b82f6;
    box-shadow: 0 2px 10px rgba(37, 99, 235, 0.12);
}

.stat-card.is-filtered-card .stat-label,
.metric-box.is-filtered-card .metric-label {
    color: #1e40af;
    font-weight: 800;
}

.comp-note-highlight {
    color: #1e3a8a !important;
    background: #dbeafe;
    padding: 0.25rem 0.55rem;
    border-radius: 6px;
    font-size: 0.78rem !important;
    margin-top: 0.35rem;
    display: inline-block;
    line-height: 1.35;
}

.nat-comp-banner {
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    border-left: 4px solid #2563eb;
    color: #1e3a8a;
    padding: 0.65rem 0.85rem;
    border-radius: 8px;
    font-size: 0.82rem;
    line-height: 1.45;
    margin-bottom: 0.85rem;
}

.nat-comp-banner[hidden] {
    display: none !important;
}

.rank-stacked-bar {
    height: 6px;
    width: 100%;
    max-width: 240px;
    background: #e2e8f0;
    border-radius: 4px;
    overflow: hidden;
    display: flex;
    margin: 5px 0 4px;
}

.rank-pres-mini-list {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.rank-pres-mini {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 0.72rem;
    color: #475569;
    font-weight: 600;
}

.rank-pres-mini i {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    display: inline-block;
}

@media (max-width: 768px) {
    .app-main {
        padding: 0 0.65rem;
        margin: 0.85rem auto;
        gap: 1rem;
    }

    .section-card {
        padding: 1rem 0.85rem;
        border-radius: 12px;
    }

    .card-header-styled {
        gap: 0.65rem;
        margin-bottom: 1rem;
    }

    .card-header-styled .icon-wrap {
        font-size: 1.65rem;
    }

    .card-header-styled h2,
    .ranking-header h2,
    .mun-header h2 {
        font-size: 1.15rem;
        line-height: 1.25;
    }

    .national-stats-grid,
    .mun-key-metrics {
        grid-template-columns: 1fr;
        gap: 0.65rem;
    }

    .stat-card,
    .metric-box {
        padding: 0.85rem 0.95rem;
    }

    .stat-number,
    .metric-value {
        font-size: 1.38rem;
    }

    .analysis-box,
    .chart-card {
        padding: 0.9rem 0.75rem;
    }

    .echart-box {
        height: 250px !important;
        width: 100% !important;
    }

    .filter-context-stamp {
        font-size: 0.78rem;
        padding: 0.5rem 0.7rem;
    }

    .share-bar {
        padding: 0.75rem;
        flex-direction: column;
        align-items: stretch;
    }

    .share-buttons {
        width: 100%;
    }

    .share-buttons .btn {
        flex: 1 1 calc(50% - 0.35rem);
        justify-content: center;
        text-align: center;
        font-size: 0.78rem;
        padding: 0.5rem 0.55rem;
    }

    /* Dominance Table -> Clean Mobile Cards */
    .dominancia-table thead {
        display: none;
    }

    .dominancia-table,
    .dominancia-table tbody,
    .dominancia-table tr,
    .dominancia-table td {
        display: block;
        width: 100%;
    }

    .dominancia-table tr {
        background: #ffffff;
        border: 1px solid #cbd5e1;
        border-radius: 10px;
        margin-bottom: 0.75rem;
        padding: 0.5rem 0.75rem;
        box-shadow: 0 1px 3px rgba(15, 23, 42, 0.05);
    }

    .dominancia-table tr.dom-row-total {
        background: #f1f5f9;
        border: 2px solid #94a3b8;
    }

    .dominancia-table td {
        padding: 0.4rem 0;
        border-bottom: 1px dashed #e2e8f0;
        display: flex;
        justify-content: space-between;
        align-items: center;
        gap: 0.5rem;
        text-align: right;
    }

    .dominancia-table td:last-child {
        border-bottom: none;
    }

    .dominancia-table td::before {
        content: attr(data-label);
        font-size: 0.75rem;
        font-weight: 700;
        color: #475569;
        text-transform: uppercase;
        text-align: left;
        flex-shrink: 0;
    }

    .dom-cell-inner {
        text-align: right;
        display: flex;
        flex-direction: column;
        align-items: flex-end;
    }

    /* Ranking Cidades Table -> Clean Mobile Cards */
    #ranking-cidades-table thead {
        display: none;
    }

    #ranking-cidades-table,
    #ranking-cidades-table tbody,
    #ranking-cidades-table tr,
    #ranking-cidades-table td {
        display: block;
        width: 100%;
    }

    #ranking-cidades-table tr {
        background: #ffffff;
        border: 1px solid #cbd5e1;
        border-radius: 10px;
        margin-bottom: 0.75rem;
        padding: 0.65rem 0.85rem;
        box-shadow: 0 1px 3px rgba(15, 23, 42, 0.05);
    }

    #ranking-cidades-table td {
        padding: 0.38rem 0;
        border-bottom: 1px dashed #f1f5f9;
        display: flex;
        justify-content: space-between;
        align-items: center;
        gap: 0.6rem;
        font-size: 0.85rem;
    }

    #ranking-cidades-table td[data-label="Total e Comparativo"] {
        flex-direction: column;
        align-items: flex-start;
    }

    #ranking-cidades-table td[data-label="Total e Comparativo"]::before {
        margin-bottom: 0.2rem;
    }

    #ranking-cidades-table td:last-child {
        border-bottom: none;
        padding-top: 0.55rem;
    }

    #ranking-cidades-table td:last-child .btn {
        width: 100%;
    }

    #ranking-cidades-table td::before {
        content: attr(data-label);
        font-size: 0.73rem;
        font-weight: 700;
        color: #64748b;
        text-transform: uppercase;
        flex-shrink: 0;
    }

    .rank-stacked-bar {
        max-width: 100%;
    }

    /* Card Modal on Mobile */
    .modal-overlay {
        padding: 0.65rem;
    }

    .modal-header {
        padding: 0.9rem 1rem;
    }

    .modal-body {
        padding: 0.9rem 1rem;
    }
}

.chart-filter-badge {
    display: inline-flex;
    align-items: center;
    background: #dbeafe;
    color: #1e40af;
    border: 1px solid #93c5fd;
    font-size: 0.72rem;
    font-weight: 700;
    padding: 0.15rem 0.5rem;
    border-radius: 999px;
    margin-left: 6px;
    vertical-align: middle;
}

.chart-comp-badge {
    display: inline-flex;
    align-items: center;
    background: #f1f5f9;
    color: #334155;
    border: 1px solid #cbd5e1;
    font-size: 0.72rem;
    font-weight: 700;
    padding: 0.15rem 0.5rem;
    border-radius: 999px;
    margin-left: 6px;
    vertical-align: middle;
}

/* Info "Como ler" Toggle Buttons, Table PNG Export Buttons, and Clear Filter Stamp Buttons */
.section-title-with-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.6rem;
    flex-wrap: wrap;
}

.section-title-with-actions h2,
.section-title-with-actions h3,
.section-title-with-actions h4 {
    margin: 0;
}

.table-header-actions {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    flex-wrap: wrap;
}

.btn-info-toggle {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    background: #f1f5f9;
    color: #334155;
    border: 1px solid #cbd5e1;
    border-radius: 999px;
    padding: 0.22rem 0.65rem;
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s ease;
    white-space: nowrap;
}

.btn-info-toggle:hover,
.btn-info-toggle.active {
    background: #dbeafe;
    color: #1e40af;
    border-color: #93c5fd;
}

.btn-export-table {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    background: #eff6ff;
    color: #1d4ed8;
    border: 1px solid #bfdbfe;
    border-radius: 999px;
    padding: 0.24rem 0.72rem;
    font-size: 0.75rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.15s ease;
    white-space: nowrap;
}

.btn-export-table:hover {
    background: #1d4ed8;
    color: #ffffff;
    border-color: #1d4ed8;
}

.btn-export-table:disabled {
    opacity: 0.65;
    cursor: wait;
}

.info-guide-box {
    background: #f8fafc;
    border: 1px solid #cbd5e1;
    border-left: 4px solid #2563eb;
    border-radius: 8px;
    padding: 0.7rem 0.9rem;
    margin-top: 0.55rem;
    margin-bottom: 0.75rem;
    font-size: 0.82rem;
    color: #334155;
    line-height: 1.45;
}

.info-guide-box strong {
    color: #0f172a;
}

.info-guide-box ul {
    margin: 0.35rem 0 0 1.15rem;
    padding: 0;
}

.info-guide-box li {
    margin-bottom: 0.25rem;
}

.stamp-content-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    flex-wrap: wrap;
    width: 100%;
}

.btn-stamp-clear {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    background: #ffffff;
    color: #9a3412;
    border: 1px solid #fdba74;
    border-radius: 6px;
    padding: 0.25rem 0.65rem;
    font-size: 0.76rem;
    font-weight: 700;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.15s ease;
    flex-shrink: 0;
}

.btn-stamp-clear:hover {
    background: #ffedd5;
    border-color: #fb923c;
    color: #7c2d12;
}

.table-filters {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

#rank-clear-filters-btn.is-active,
#mun-table-clear-btn.is-active {
    background: #fff7ed;
    color: #c2410c;
    border-color: #fdba74;
    font-weight: 700;
}

/* ==========================================================================
   Cadastral Anomalies, CIPI Deep Links & Fala.BR Audit Styles
   ========================================================================== */

.mun-anomaly-banner {
    background: #fffbeb;
    border: 1px solid #fde68a;
    border-left: 4px solid #f59e0b;
    border-radius: var(--radius-md);
    padding: 0.85rem 1.15rem;
    margin-bottom: 1.25rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.85rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.mun-anomaly-content {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    max-width: 820px;
}

.mun-anomaly-icon {
    font-size: 1.4rem;
    line-height: 1;
    flex-shrink: 0;
}

.mun-anomaly-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.modal-anomaly-box {
    background: #fffbeb;
    border: 1px solid #fde68a;
    border-left: 4px solid #f59e0b;
    border-radius: 8px;
    padding: 0.85rem 1rem;
    margin-bottom: 1rem;
}

.modal-anomaly-header {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.92rem;
    font-weight: 700;
    color: #92400e;
    margin-bottom: 0.35rem;
}

.modal-anomaly-desc {
    font-size: 0.86rem;
    color: #78350f;
    line-height: 1.55;
    margin-bottom: 0.5rem;
}

.modal-anomaly-footer {
    border-top: 1px dashed #fde68a;
    padding-top: 0.5rem;
    font-size: 0.8rem;
    color: #b45309;
}

/* Anomaly Cards in Registry Modal */
.anomaly-card {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 1rem;
    transition: all 0.2s ease;
}

.anomaly-card:hover {
    border-color: #cbd5e1;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.anomaly-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 0.45rem;
}

.anomaly-card-tags {
    display: flex;
    gap: 6px;
    align-items: center;
    flex-wrap: wrap;
}

.anomaly-card-title {
    font-weight: 700;
    font-size: 0.96rem;
    color: #0f172a;
    margin-bottom: 0.35rem;
}

.anomaly-card-reason {
    background: #fef3c7;
    border: 1px solid #fde68a;
    border-radius: 6px;
    padding: 0.55rem 0.75rem;
    font-size: 0.85rem;
    color: #92400e;
    line-height: 1.5;
    margin: 0.5rem 0;
}

.anomaly-card-meta {
    font-size: 0.82rem;
    color: #64748b;
    display: flex;
    gap: 0.85rem;
    flex-wrap: wrap;
    margin-bottom: 0.65rem;
}

.anomaly-card-actions {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    flex-wrap: wrap;
}

.btn-falabr {
    background: #0284c7;
    color: #ffffff !important;
    border: 1px solid #0284c7;
    font-weight: 600;
}

.btn-falabr:hover {
    background: #0369a1;
    border-color: #0369a1;
}

.btn-cipi {
    background: #e0f2fe;
    color: #0369a1 !important;
    border: 1px solid #bae6fd;
    font-weight: 600;
}

.btn-cipi:hover {
    background: #bae6fd;
}







