/* ===== VARIÁVEIS DE TEMA ===== */
:root,
[data-theme="light"] {
    --bg: #f5f5f5;
    --surface: #ffffff;
    --surface-2: #fafafa;
    --text: #171717;
    --text-sec: #525252;
    --muted: #737373;
    --accent: #2563eb;
    --accent-hover: #1d4ed8;
    --ok: #16a34a;
    --warn: #ca8a04;
    --err: #dc2626;
    --border: #e5e5e5;
    --input-bg: #ffffff;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

[data-theme="dark"] {
    --bg: #0a0a0a;
    --surface: #141414;
    --surface-2: #1f1f1f;
    --text: #fafafa;
    --text-sec: #a3a3a3;
    --muted: #737373;
    --accent: #3b82f6;
    --accent-hover: #60a5fa;
    --ok: #22c55e;
    --warn: #eab308;
    --err: #ef4444;
    --border: #262626;
    --input-bg: #0a0a0a;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
    --radius: 8px;
    --radius-lg: 12px;
}

/* ===== RESET / BASE ===== */
*,
*::before,
*::after {
    box-sizing: border-box;
}

html,
body {
    height: 100%;
    margin: 0;
}

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    background: var(--bg);
    color: var(--text);
    transition: background 0.2s, color 0.2s;
}

.president-history.hidden {
    display: none;
}

.president-history {
    margin: 0 0 16px 0;
}

.president-history-card {
    --history-bg: #ffffff;
    --history-bg-2: #ffffff;
    --history-row: #fafafa;
    --history-row-border: #e5e5e5;
    --history-text: #171717;
    --history-muted: #737373;
    --history-soft: #525252;
    --history-header-hover: #f5f5f5;
    --history-header-border: #e5e5e5;
    --history-card-border: #e5e5e5;
    border: 1px solid var(--history-card-border);
    background: var(--history-bg);
    border-radius: 8px;
    overflow: hidden;
    color: var(--history-text);
}

[data-theme="dark"] .president-history-card {
    --history-bg: #242421;
    --history-bg-2: #2d2d29;
    --history-row: #20201d;
    --history-row-border: #33332f;
    --history-text: #f4f4ee;
    --history-muted: #b8b8ad;
    --history-soft: #d9d9cf;
    --history-header-hover: #2a2a26;
    --history-header-border: #42423c;
    --history-card-border: #42423c;
}

.president-history-header {
    width: 100%;
    min-height: 40px;
    border-bottom: 1px solid var(--history-header-border);
    background: var(--history-bg);
    color: var(--history-text);
    display: grid;
    grid-template-columns: minmax(118px, 1fr) minmax(0, auto);
    align-items: stretch;
    gap: 10px;
    padding: 0;
    text-align: left;
}

.president-history-toggle {
    min-width: 0;
    border: 0;
    background: transparent;
    color: var(--history-text);
    display: grid;
    grid-template-columns: 12px minmax(0, 1fr);
    align-items: center;
    gap: 7px;
    padding: 8px 10px;
    cursor: pointer;
    text-align: left;
}

.president-history-toggle:hover {
    background: var(--history-header-hover);
}

.history-caret {
    font-size: 7px;
    color: var(--history-muted);
    transform: rotate(0deg);
    transition: transform 0.15s ease;
}

.president-history-card.collapsed .history-caret {
    transform: rotate(-90deg);
}

.history-header-text {
    min-width: 0;
    display: flex;
    flex-direction: column;
    line-height: 1.08;
}

.history-header-text strong {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.35px;
    color: var(--history-soft);
}

.history-header-text small {
    color: var(--history-text);
    font-size: 11px;
    font-weight: 800;
}

.history-match-badge {
    border: 1px solid #4d83d8;
    border-radius: 999px;
    padding: 4px 7px;
    font-size: 9px;
    font-weight: 700;
    text-transform: lowercase;
    white-space: nowrap;
    color: #93c5fd;
    background: rgba(37, 99, 235, 0.18);
}

.major-history-actions {
    display: inline-flex;
    align-items: center;
    justify-content: flex-end;
    gap: 6px;
    padding: 7px 10px 7px 0;
    min-width: 0;
    overflow: hidden;
}

.major-history-switch {
    display: inline-flex;
    align-items: center;
    padding: 2px;
    border: 1px solid var(--history-row-border);
    border-radius: 7px;
    background: var(--history-row);
    gap: 1px;
    max-width: 100%;
    overflow-x: auto;
    scrollbar-width: none;
}

.major-history-switch::-webkit-scrollbar {
    display: none;
}

.major-history-switch-btn {
    border: 0;
    border-radius: 4px;
    background: transparent;
    color: var(--history-muted);
    cursor: pointer;
    font-size: 9px;
    font-weight: 800;
    line-height: 1;
    min-width: 52px;
    padding: 5px 6px;
}

.major-history-switch-btn.active {
    background: var(--accent);
    color: #ffffff;
    box-shadow: 0 1px 2px rgba(37, 99, 235, 0.2);
}

.history-match-badge.strong {
    color: #a7f3d0;
    border-color: #368267;
    background: rgba(22, 163, 74, 0.16);
}

.history-match-badge.probable {
    color: #93c5fd;
    border-color: #4d83d8;
    background: rgba(37, 99, 235, 0.18);
}

.history-match-badge.weak {
    color: #fde68a;
    border-color: #9a7b24;
    background: rgba(202, 138, 4, 0.18);
}

.president-history-body {
    padding: 14px 12px 10px;
    background: var(--history-bg-2);
}

.president-history-card.collapsed .president-history-body {
    display: none;
}

.history-place {
    display: flex;
    flex-direction: column;
    gap: 2px;
    margin-bottom: 14px;
}

.history-place strong {
    color: var(--history-text);
    font-size: 12px;
    line-height: 1.18;
    text-transform: capitalize;
}

.history-place small {
    color: var(--history-muted);
    font-size: 10px;
    font-weight: 600;
    text-transform: capitalize;
}

.president-history-grid {
    display: grid;
    gap: 12px;
}

.president-history-year-group {
    display: grid;
    gap: 5px;
}

.history-year-label {
    color: var(--history-soft);
    font-size: 9px;
    font-weight: 700;
    line-height: 1;
    padding-left: 1px;
}

.history-year-rows {
    display: grid;
    gap: 2px;
}

.president-history-row {
    display: grid;
    grid-template-columns: 34px minmax(0, 1fr) auto;
    align-items: center;
    gap: 7px;
    min-height: 38px;
    padding: 7px 9px;
    border: 1px solid var(--history-row-border);
    background: var(--history-row);
}

.president-history-row:first-child {
    border-radius: 8px 8px 3px 3px;
}

.president-history-row:last-child {
    border-radius: 3px 3px 8px 8px;
}

.president-history-row:only-child {
    border-radius: 8px;
}

.history-turn-pill {
    min-width: 24px;
    padding: 0 4px;
    height: 20px;
    border-radius: 6px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: #e9f7ff;
    color: #1d4f7a;
    font-size: 8px;
    font-weight: 900;
}

.president-history-row:nth-child(2) .history-turn-pill {
    background: #ecf8df;
    color: #3f6f20;
}

.history-winner {
    display: flex;
    align-items: center;
    gap: 7px;
    min-width: 0;
}

.history-party-dot {
    width: 7px;
    height: 7px;
    border-radius: 2px;
    flex: 0 0 auto;
    box-shadow: none;
}

.history-winner div,
.history-stats {
    min-width: 0;
    display: flex;
    flex-direction: column;
    line-height: 1.2;
}

.history-winner strong {
    color: var(--history-text);
    font-size: 11px;
    font-weight: 800;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.history-winner small,
.history-stats small {
    color: var(--history-muted);
    font-size: 9px;
    font-weight: 600;
}

.history-stats {
    text-align: right;
    white-space: nowrap;
}

.history-stats strong {
    color: var(--history-text);
    font-size: 12px;
    font-weight: 900;
}

/* ===== LAYOUT PRINCIPAL (FLOATING PANELS) ===== */
.app {
    position: relative;
    width: 100vw;
    height: 100vh;
    overflow: hidden;
    box-sizing: border-box;
}

#mapPanel {
    position: absolute;
    inset: 0;
    z-index: 1;
    border: none;
    border-radius: 0;
    background: transparent;
}

#map {
    height: 100%;
    width: 100%;
    background: var(--bg);
}

/* Floating side panels */
.side {
    position: absolute;
    top: 12px;
    bottom: 12px;
    width: 400px;
    z-index: 100;
    display: flex;
    flex-direction: column;
    min-width: 0;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.25s ease;
    overflow: hidden;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.25), 0 2px 8px rgba(0, 0, 0, 0.15);
}

.side-left {
    left: 12px;
}

.side-right {
    right: 12px;
}

/* Resize handles - positioned between panel and map */
.resize-handle {
    position: absolute;
    top: 12px;
    bottom: 12px;
    width: 8px;
    cursor: col-resize;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 110;
    flex-shrink: 0;
    transition: opacity 0.25s ease;
}

#resizeHandleLeft {
    left: 412px;  /* 400px panel + 12px gap */
}

#resizeHandleRight {
    right: 412px;
}

.resize-handle::after {
    content: '';
    display: block;
    width: 3px;
    height: 40px;
    background: var(--border);
    border-radius: 2px;
    transition: background 0.15s, height 0.15s;
}

.resize-handle:hover::after {
    background: var(--accent);
    height: 60px;
}

.panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    transition: background 0.2s, border-color 0.2s;
}

/* ===== COLLAPSED PANELS ===== */
/* When collapsed: panel slides off-screen and becomes invisible */
.panel.side.panel-collapsed {
    transform: translateX(0);
    width: 0 !important;
    min-width: 0 !important;
    opacity: 0;
    pointer-events: none;
    border: none !important;
    box-shadow: none !important;
    padding: 0 !important;
    overflow: hidden;
}

.side-left.panel-collapsed {
    transform: translateX(-100%) !important;
}

.side-right.panel-collapsed {
    transform: translateX(100%) !important;
}

.panel-collapsed .body,
.panel-collapsed #sideLeftBody,
.panel-collapsed #sideRightBody {
    display: none !important;
}

.panel-collapsed .head .title,
.panel-collapsed .head #btnAppGuide,
.panel-collapsed .head #themeToggle {
    display: none !important;
}

.panel-collapsed .head {
    display: none !important;
}

/* Hide resize handles when panel is collapsed */
.app:has(#sideLeftPanel.panel-collapsed) #resizeHandleLeft {
    opacity: 0;
    pointer-events: none;
}

.app:has(#sideRightPanel.panel-collapsed) #resizeHandleRight {
    opacity: 0;
    pointer-events: none;
}

/* ===== FLOATING TOGGLE TABS (visible when collapsed) ===== */
.panel-expand-tab {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    z-index: 120;
    width: 24px;
    height: 64px;
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--muted);
    display: none;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.panel-expand-tab:hover {
    color: var(--text);
    background: var(--surface-2);
    width: 28px;
}

#expandTabLeft {
    left: 0;
    border-radius: 0 var(--radius) var(--radius) 0;
    border-left: none;
}

#expandTabRight {
    right: 0;
    border-radius: var(--radius) 0 0 var(--radius);
    border-right: none;
}

/* Show expand tabs when panels are collapsed */
.app:has(#sideLeftPanel.panel-collapsed) #expandTabLeft {
    display: flex;
}

.app:has(#sideRightPanel.panel-collapsed) #expandTabRight {
    display: flex;
}

/* Panel collapse button */
.panel-collapse-btn {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--muted);
    border-radius: var(--radius);
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 16px;
    line-height: 1;
    padding: 0;
    flex-shrink: 0;
    transition: color 0.15s, border-color 0.15s;
}

.panel-collapse-btn:hover {
    color: var(--text);
    border-color: var(--text);
}


/* ===== CABEÇALHO ===== */
.head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    border-bottom: 1px solid var(--border);
    gap: 8px;
    flex-shrink: 0;
}

.title {
    font-size: 13px;
    font-weight: 600;
    letter-spacing: -0.01em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ===== CORPO / SCROLL ===== */
.body {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 10px 12px;
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-width: thin;
    scrollbar-color: var(--border) transparent;
}

.body.drag-scroll-enabled {
    cursor: grab;
}

.body.drag-scroll-enabled.dragging-scroll {
    cursor: grabbing;
    user-select: none;
}

.body::-webkit-scrollbar {
    width: 6px;
}

.body::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 3px;
}

.panel-credit {
    margin-top: auto;
    padding: 14px 6px 4px;
    color: var(--muted);
    font-size: 11px;
    line-height: 1.35;
    text-align: center;
}

.panel-credit span {
    display: block;
}

.panel-credit a {
    color: var(--accent);
    font-weight: 800;
    text-decoration: none;
}

.panel-credit a:hover {
    text-decoration: underline;
}

/* ===== SEÇÕES ===== */
.section {
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 10px 12px;
}

.section h3 {
    margin: 0 0 8px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--muted);
}

.section-hidden {
    display: none;
}

/* ===== SEÇÕES COLAPSÁVEIS ===== */
.section-collapsible {
    padding: 0;
}

.section-collapsible .section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 9px 12px;
    cursor: pointer;
    user-select: none;
    transition: background 0.15s;
}

.section-collapsible .section-header:hover {
    background: var(--surface);
}

.section-collapsible .section-header h3 {
    margin: 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.section-collapsible .section-header h3::before {
    content: '▼';
    font-size: 8px;
    transition: transform 0.2s;
}

.section-collapsible.collapsed .section-header h3::before {
    transform: rotate(-90deg);
}

.section-collapsible .section-body {
    padding: 0 12px 12px;
    max-height: 9999px;
    overflow: hidden;
    transition: max-height 0.5s cubic-bezier(0.4, 0, 0.2, 1),
        padding 0.3s ease,
        opacity 0.3s ease;
    opacity: 1;
}

.section-collapsible.collapsed .section-body {
    max-height: 0;
    padding-top: 0;
    padding-bottom: 0;
    opacity: 0;
    pointer-events: none;
    /* Evita cliques fantasmas */
}

/* Badge de contagem nas seções */
.section-badge {
    background: var(--accent);
    color: #fff;
    font-size: 10px;
    font-weight: 600;
    padding: 2px 6px;
    border-radius: 10px;
    margin-left: auto;
}

/* Seta do neighborhoodProfile */
#neighborhoodProfile .section-header h3 span:first-child {
    transition: transform 0.2s;
    display: inline-block;
}

#neighborhoodProfile.collapsed .section-header h3 span:first-child {
    transform: rotate(-90deg);
}

/* ===== GRID / ROWS ===== */
.row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.ctrl {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.ctrl label {
    font-size: 11px;
    font-weight: 500;
    color: var(--muted);
}

/* ===== INPUTS & SELECTS ===== */
.select,
.search-input,
.combobox-input {
    width: 100%;
    padding: 8px 10px;
    font-size: 13px;
    font-family: inherit;
    color: var(--text);
    background: var(--input-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    outline: none;
    transition: border-color 0.15s;
    appearance: none;
}

.select {
    cursor: pointer;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23737373' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
}

.select:focus,
.search-input:focus,
.combobox-input:focus {
    border-color: var(--accent);
}

.select:disabled,
.search-input:disabled,
.combobox-input:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.searchwrap {
    position: relative;
}

/* ===== BOTÕES ===== */
.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 16px;
    font-size: 14px;
    font-weight: 500;
    font-family: inherit;
    color: var(--text);
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    transition: all 0.15s;
}

.button:hover {
    background: var(--border);
}

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

.button.primary {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}

.button.primary:hover {
    background: var(--accent-hover);
}

.button.cta-ready {
    box-shadow: 0 8px 24px rgba(37, 99, 235, 0.16);
    transform: translateY(-1px);
}

.button.pending-action {
    border-color: var(--accent);
    color: var(--accent);
    box-shadow: 0 0 0 1px rgba(37, 99, 235, 0.16), 0 10px 30px rgba(37, 99, 235, 0.12);
}

.button.ghost {
    background: transparent;
    border-color: transparent;
}

.button.ghost:hover {
    background: var(--surface-2);
}

.button.toggle.active {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}

/* ===== CHIPS ===== */
.chip-group {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
}

.chip-button {
    padding: 5px 10px;
    font-size: 12px;
    font-weight: 500;
    font-family: inherit;
    color: var(--text-sec);
    background: var(--input-bg);
    border: 1px solid var(--border);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.15s;
    white-space: nowrap;
}

.chip-button:hover {
    border-color: var(--accent);
    color: var(--text);
}

.chip-button:disabled,
.chip-button.disabled {
    cursor: not-allowed;
    opacity: 0.42;
    filter: grayscale(0.25);
    box-shadow: none;
}

.chip-button:disabled:hover,
.chip-button.disabled:hover {
    border-color: var(--border);
    color: var(--text-sec);
}

.chip-button.active {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}

.chip-button.hidden {
    display: none;
}

.viz-section {
    background: var(--surface);
    border-color: rgba(37, 99, 235, 0.28);
    box-shadow: 0 8px 24px rgba(37, 99, 235, 0.08);
}

.viz-section .section-header {
    background: rgba(37, 99, 235, 0.06);
}

.viz-section .section-header h3 {
    color: var(--accent);
}

.viz-mode-group {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.viz-mode-chip {
    min-width: 0;
    min-height: 54px;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: center;
    gap: 3px;
    padding: 9px 10px;
    text-align: left;
    white-space: normal;
    line-height: 1.15;
}

.viz-mode-chip.active {
    box-shadow: 0 8px 18px rgba(37, 99, 235, 0.2);
}

.viz-mode-title {
    font-size: 13px;
    font-weight: 700;
}

.viz-mode-desc {
    color: var(--muted);
    font-size: 10px;
    font-weight: 500;
}

.viz-mode-chip.active .viz-mode-desc {
    color: rgba(255, 255, 255, 0.82);
}

.shift-compare-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.shift-compare-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 6px;
}

.shift-compare-head label {
    margin: 0;
}

.shift-help {
    position: relative;
    flex: 0 0 auto;
}

.shift-help summary {
    list-style: none;
    border: 1px solid rgba(37, 99, 235, 0.26);
    border-radius: 6px;
    background: rgba(37, 99, 235, 0.08);
    color: var(--accent);
    cursor: pointer;
    font-size: 10px;
    font-weight: 800;
    line-height: 1;
    padding: 6px 7px;
    user-select: none;
}

.shift-help summary::-webkit-details-marker {
    display: none;
}

.shift-help[open] summary {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}

.shift-help-popover {
    position: absolute;
    right: 0;
    top: calc(100% + 6px);
    z-index: 1100;
    width: 258px;
    padding: 10px 11px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
    box-shadow: 0 14px 34px rgba(15, 23, 42, 0.16), 0 2px 8px rgba(15, 23, 42, 0.08);
    color: var(--text);
}

.shift-help-popover strong {
    display: block;
    margin-bottom: 6px;
    font-size: 11px;
    font-weight: 900;
    text-transform: uppercase;
}

.shift-help-popover p {
    margin: 0 0 7px;
    color: var(--text-sec);
    font-size: 11px;
    line-height: 1.35;
}

.shift-help-popover p:last-child {
    margin-bottom: 0;
}

.shift-help-red,
.shift-help-blue {
    font-weight: 900;
}

.shift-help-red {
    color: #cf3339;
}

.shift-help-blue {
    color: #1d7fbd;
}

.shift-compare-row>div {
    min-width: 0;
}

.shift-compare-row small {
    display: block;
    margin-bottom: 4px;
    color: var(--muted);
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
}

/* ===== TOOLBAR ===== */
.toolbar {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

/* ===== TABS (Filtros) ===== */
.filter-tabs {
    display: flex;
    background: var(--input-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 3px;
    gap: 2px;
    margin-bottom: 14px;
    overflow-x: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
    flex-shrink: 0;
    cursor: grab;
    user-select: none;
    scroll-behavior: smooth;
}

.filter-tabs::-webkit-scrollbar {
    display: none;
}

.filter-tabs.dragging-tabs {
    cursor: grabbing;
}

.tab-btn {
    flex: 0 0 auto;
    padding: 6px 10px;
    font-size: 11px;
    font-weight: 600;
    font-family: inherit;
    text-align: center;
    color: var(--muted);
    background: transparent;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.15s;
    white-space: nowrap;
}

.tab-btn:hover {
    color: var(--text);
}

.tab-btn.active {
    background: var(--surface);
    color: var(--accent);
}

.tab-content {
    animation: fadeIn 0.2s ease;
}

.tab-content.hidden {
    display: none;
}

/* ===== FILTER GROUP ===== */
.filter-group {
    margin-bottom: 12px;
}

.filter-group h4 {
    margin: 0 0 12px;
    font-size: 12px;
    font-weight: 500;
    color: var(--muted);
}

/* ===== SLIDERS ===== */
.slider-box {
    margin-bottom: 16px;
}

.slider-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 8px;
}

.slider-label {
    font-size: 12px;
    color: var(--muted);
}

.slider-value {
    font-size: 14px;
    font-weight: 600;
    color: var(--accent);
    margin-left: auto;
}

.slider-header .select {
    width: auto !important;
    min-width: 118px;
    height: 32px;
    padding: 6px 30px 6px 10px !important;
    font-size: 12px !important;
    font-weight: 600;
    color: var(--text);
    background-color: var(--surface);
    border: 1px solid var(--border);
    border-radius: 6px;
    box-shadow: 0 1px 0 rgba(0, 0, 0, 0.03);
}

.slider-header .select:hover {
    border-color: var(--muted);
    background-color: var(--input-bg);
}

.slider-header .select:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.12);
}

#selectEscolaridade {
    min-width: 164px;
}

#selectIdadeGenero,
#selectEscolaridadeGenero {
    min-width: 112px;
}

/* Slider Simples */
.slider-wrapper {
    position: relative;
    height: 24px;
    display: flex;
    align-items: center;
}

.slider-wrapper::before {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    height: 4px;
    background: var(--border);
    border-radius: 2px;
}

.simple-slider {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 4px;
    background: transparent;
    border-radius: 2px;
    outline: none;
    cursor: pointer;
    position: relative;
    z-index: 2;
}

.simple-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 16px;
    height: 16px;
    background: #fff;
    border: 2px solid var(--accent);
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

.simple-slider::-moz-range-thumb {
    width: 14px;
    height: 14px;
    background: #fff;
    border: 2px solid var(--accent);
    border-radius: 50%;
    cursor: pointer;
}

.simple-slider::-moz-range-track {
    height: 4px;
    background: transparent;
    border-radius: 2px;
}

/* Slider Duplo (Renda) */
.dual-slider-container {
    position: relative;
    height: 24px;
    margin: 12px 0 16px;
    user-select: none;
}

.dual-track {
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    height: 4px;
    background: var(--border);
    border-radius: 2px;
    transform: translateY(-50%);
}

.dual-range {
    position: absolute;
    top: 50%;
    height: 4px;
    background: var(--accent);
    border-radius: 2px;
    transform: translateY(-50%);
    z-index: 1;
}

.dual-thumb {
    position: absolute;
    top: 50%;
    width: 16px;
    height: 16px;
    background: #fff;
    border: 2px solid var(--accent);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    cursor: grab;
    z-index: 2;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

.dual-thumb:active {
    cursor: grabbing;
    transform: translate(-50%, -50%) scale(1.1);
}

.dual-values {
    display: flex;
    justify-content: space-between;
    font-size: 13px;
    font-weight: 500;
    color: var(--text);
}

/* Barra de disponibilidade */
.availability-bar {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    height: 6px;
    background: repeating-linear-gradient(45deg,
            #334155,
            #334155 3px,
            #475569 3px,
            #475569 6px);
    border-radius: 3px;
    z-index: 0;
    opacity: 1;
}

[data-theme="light"] .availability-bar {
    background: repeating-linear-gradient(45deg,
            #cbd5e1,
            #cbd5e1 3px,
            #94a3b8 3px,
            #94a3b8 6px);
}

.slider-wrapper .availability-bar {
    z-index: 1;
}

.slider-wrapper .simple-slider {
    z-index: 2;
    background: transparent !important;
}

/* ===== CARDS DE CANDIDATOS ===== */
.grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.cand {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 12px;
    background: var(--input-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    transition: border-color 0.15s;
}

.cand:hover {
    border-color: var(--accent);
}

.cand-header {
    display: flex;
    align-items: flex-start;
    gap: 8px;
}

.swatch {
    width: 12px;
    height: 12px;
    border-radius: 3px;
    flex-shrink: 0;
    border: 1px solid rgba(128, 128, 128, 0.3);
}

.swatch-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    padding: 0;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 7px;
    cursor: pointer;
    flex-shrink: 0;
    transition: border-color 0.15s, background 0.15s, transform 0.15s;
}

.swatch-button:hover {
    border-color: var(--accent);
    background: var(--surface);
    transform: translateY(-1px);
}

.swatch-button:focus-visible {
    outline: 2px solid rgba(37, 99, 235, 0.28);
    outline-offset: 2px;
}

.swatch-button .swatch {
    width: 12px;
    height: 12px;
}

.candidate-color-popover {
    position: fixed;
    z-index: 3000;
    width: min(280px, calc(100vw - 24px));
}

.candidate-color-popover.hidden {
    display: none;
}

.candidate-color-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: 0 18px 48px rgba(0, 0, 0, 0.22);
    padding: 12px;
}

.candidate-color-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 10px;
}

.candidate-color-kicker {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--muted);
}

.candidate-color-name {
    font-size: 13px;
    font-weight: 700;
    color: var(--text);
    line-height: 1.2;
}

.candidate-color-close {
    width: 26px;
    height: 26px;
    border: 1px solid var(--border);
    border-radius: 7px;
    background: var(--surface-2);
    color: var(--muted);
    cursor: pointer;
    font-size: 18px;
    line-height: 1;
}

.candidate-color-preview-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px;
    margin-bottom: 10px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 10px;
}

.candidate-color-preview {
    width: 34px;
    height: 34px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: transparent;
    flex-shrink: 0;
}

.candidate-color-meta {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.candidate-color-meta span {
    font-size: 11px;
    color: var(--muted);
}

.candidate-color-meta strong {
    font-size: 12px;
    color: var(--text);
}

.candidate-color-presets {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 8px;
    margin-bottom: 10px;
}

.candidate-color-advanced {
    margin-bottom: 10px;
}

.candidate-color-picker-btn {
    width: 100%;
    height: 34px;
    border: 1px dashed var(--border);
    border-radius: 8px;
    background: var(--surface-2);
    color: var(--text-sec);
    font: inherit;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: border-color 0.15s, color 0.15s, background 0.15s;
}

.candidate-color-picker-btn:hover {
    border-color: var(--accent);
    color: var(--accent);
    background: var(--surface);
}

.candidate-color-advanced input[type="color"] {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
    pointer-events: none;
}

.candidate-color-chip {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    aspect-ratio: 1;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--surface-2);
    padding: 0;
    cursor: pointer;
}

.candidate-color-chip span {
    width: 18px;
    height: 18px;
    border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, 0.32);
}

.candidate-color-chip.active {
    border-color: var(--accent);
    box-shadow: 0 0 0 1px rgba(37, 99, 235, 0.15);
}

.candidate-color-field {
    display: flex;
    flex-direction: column;
    gap: 5px;
    margin-bottom: 12px;
}

.candidate-color-field span {
    font-size: 11px;
    font-weight: 600;
    color: var(--muted);
}

.candidate-color-field input {
    width: 100%;
    height: 36px;
    padding: 0 10px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--input-bg);
    color: var(--text);
    font: inherit;
}

.candidate-color-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

.cand-info {
    flex: 1;
    min-width: 0;
}

.cand h4 {
    margin: 0;
    font-size: 13px;
    font-weight: 600;
    line-height: 1.3;
    word-wrap: break-word;
}

.cand small {
    font-size: 11px;
    color: var(--muted);
}

.cand-stats {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
}

.bigPct {
    font-size: 18px;
    font-weight: 700;
    line-height: 1;
}

.smallVotos {
    font-size: 12px;
    color: var(--muted);
}

/* Status Badge */
.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    padding: 3px 6px;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    border-radius: 4px;
    margin-top: 6px;
}

.status-badge svg {
    width: 10px;
    height: 10px;
}

.status-badge.eleito {
    background: var(--ok);
    color: #fff;
}

.status-badge.segundo-turno {
    background: var(--warn);
    color: #000;
}

.status-badge.nao-eleito {
    background: var(--err);
    color: #fff;
}

.status-badge.inapto {
    background: var(--err);
    color: #fff;
    opacity: 0.8;
}

.status-badge.suplente {
    background: var(--warn);
    color: #fff;
}

/* Borda lateral por status */
.cand[data-status="ELEITO"] {
    border-left: 3px solid var(--ok);
}

.cand[data-status="2° TURNO"] {
    border-left: 3px solid var(--warn);
}

.cand[data-status="NÃO ELEITO"] {
    border-left: 3px solid var(--err);
}

.cand[data-status="SUPLENTE"] {
    border-left: 3px solid var(--warn);
}

.cand[data-status="INAPTO"] {
    border-left: 3px dashed var(--err);
}

/* ===== VER MAIS / VER MENOS ===== */
.cand-hidden {
    display: none !important;
}

.btn-ver-mais {
    width: 100%;
    margin-top: 8px;
    padding: 8px 12px;
    font-size: 12px;
    font-weight: 600;
    font-family: inherit;
    color: var(--accent);
    background: transparent;
    border: 1px dashed var(--accent);
    border-radius: var(--radius);
    cursor: pointer;
    transition: all 0.15s;
    text-align: center;
    opacity: 0.8;
}

.btn-ver-mais:hover {
    background: rgba(59, 130, 246, 0.08);
    opacity: 1;
}


.tabs {
    display: flex;
    gap: 6px;
    margin-bottom: 12px;
}

.tab {
    padding: 6px 12px;
    font-size: 13px;
    font-weight: 500;
    color: var(--muted);
    background: var(--input-bg);
    border: 1px solid var(--border);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.15s;
}

.tab:hover {
    border-color: var(--accent);
}

.tab.active {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}

/* ===== MÉTRICAS ===== */
.footer {
    font-size: 13px;
    color: var(--muted);
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--border);
}

.metrics-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.metric-item {
    background: var(--input-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 10px;
}

.metric-item span {
    display: block;
    font-size: 11px;
    color: var(--muted);
    margin-bottom: 2px;
}

.metric-item strong {
    font-size: 15px;
    font-weight: 600;
}

/* ===== PERFIL DA VIZINHANÇA ===== */
.profile-header {
    background: var(--input-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px;
    margin-bottom: 14px;
    text-align: center;
    position: relative;
}

.profile-renda {
    font-size: 20px;
    font-weight: 700;
    color: var(--ok);
    margin-top: 4px;
}

/* Botão de Info do Censo */
.info-button {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--muted);
    width: 20px;
    height: 20px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 700;
    font-family: serif;
    cursor: pointer;
    transition: all 0.2s;
}

.info-button:hover {
    background: var(--surface);
    border-color: var(--text);
    color: var(--text);
}

/* Proteção contra rotação na Renda Média */
.profile-renda-box span {
    transform: none !important;
    writing-mode: horizontal-tb !important;
    display: inline-block !important;
}

@keyframes blinkOpacity {

    0%,
    100% {
        opacity: 0.5;
    }

    50% {
        opacity: 1;
    }
}

.blinking {
    animation: blinkOpacity 2s infinite ease-in-out;
    border-color: var(--accent);
    color: var(--accent);
}

/* Header clicável do neighborhoodProfile */
#neighborhoodProfile>.section-header {
    background: var(--input-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    transition: background 0.15s;
}

#neighborhoodProfile>.section-header:hover {
    background: var(--surface);
}

#neighborhoodProfile>.section-body {
    padding-top: 14px;
}

.profile-section {
    margin-bottom: 14px;
}

.profile-section h4 {
    margin: 0 0 8px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--muted);
    padding: 6px 0;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: color 0.15s;
}

.profile-section h4:hover {
    color: var(--accent);
}

.profile-section h4::before {
    content: '▼';
    font-size: 7px;
    transition: transform 0.2s;
}

.profile-section.collapsed h4::before {
    transform: rotate(-90deg);
}

.profile-section .profile-content {
    max-height: 500px;
    overflow: hidden;
    transition: max-height 0.25s ease, opacity 0.2s;
}

.profile-section.collapsed .profile-content {
    max-height: 0;
    opacity: 0;
}

/* Layout compacto em grid para barras */
.profile-grid-compact {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 4px 12px;
}

.profile-grid-compact .bar-chart-row {
    margin-bottom: 3px;
}

.profile-grid-compact .bar-chart-label {
    width: 65px;
    font-size: 11px;
}

.profile-grid-compact .bar-value {
    width: 35px;
    font-size: 11px;
}

/* Barras de gráfico */
.bar-chart-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
    font-size: 12px;
}

.bar-chart-label {
    width: 80px;
    text-align: right;
    flex-shrink: 0;
    color: var(--text-sec);
}

.bar-track {
    flex: 1;
    height: 6px;
    background: var(--border);
    border-radius: 3px;
    overflow: hidden;
}

.bar-fill {
    height: 100%;
    border-radius: 3px;
}

.bar-value {
    width: 40px;
    text-align: right;
    font-weight: 600;
    font-size: 12px;
}

.age-pyramid {
    display: grid;
    gap: 5px;
    padding: 2px 0;
}

.age-pyramid-head,
.age-pyramid-row {
    display: grid;
    grid-template-columns: minmax(90px, 1fr) 58px minmax(90px, 1fr);
    align-items: center;
    column-gap: 8px;
}

.age-pyramid-head {
    color: var(--muted);
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
}

.age-pyramid-legend {
    display: flex;
    justify-content: center;
    gap: 14px;
    color: var(--text-sec);
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
}

.age-pyramid-legend span {
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

.age-pyramid-dot {
    width: 8px;
    height: 8px;
    border-radius: 2px;
    display: inline-block;
}

.age-pyramid-dot-f {
    background: #ec4899;
}

.age-pyramid-dot-m {
    background: var(--accent);
}

.age-pyramid-head span:first-child {
    text-align: right;
}

.age-pyramid-head span:last-child {
    text-align: left;
}

.age-pyramid-label {
    color: var(--text-sec);
    font-size: 11px;
    font-weight: 700;
    text-align: center;
    white-space: nowrap;
}

.education-gender-pyramid .age-pyramid-row {
    grid-template-columns: minmax(72px, 1fr) 96px minmax(72px, 1fr);
}

.education-gender-pyramid .age-pyramid-label {
    font-size: 10px;
    white-space: normal;
    line-height: 1.1;
}

.age-pyramid-side {
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
}

.age-pyramid-left {
    justify-content: flex-end;
    border-right: 1px solid var(--border);
    padding-right: 8px;
}

.age-pyramid-right {
    justify-content: flex-start;
    border-left: 1px solid var(--border);
    padding-left: 8px;
}

.age-pyramid-bar {
    height: 12px;
    border-radius: 4px;
    min-width: 2px;
}

.age-pyramid-left .age-pyramid-bar {
    background: #ec4899;
}

.age-pyramid-right .age-pyramid-bar {
    background: var(--accent);
}

.age-pyramid-value {
    width: 42px;
    color: var(--text-sec);
    font-size: 10px;
    font-weight: 700;
    white-space: nowrap;
}

.age-pyramid-left .age-pyramid-value {
    text-align: right;
}

.empty-profile-note {
    color: var(--muted);
    font-size: 12px;
    padding: 8px 0;
    text-align: center;
}

.hover-info-tooltip {
    position: fixed;
    left: 0;
    top: 0;
    z-index: 4000;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.12s ease;
    background: rgba(20, 20, 20, 0.94);
    color: #f5f5f5;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 6px;
    padding: 6px 8px;
    font-size: 11px;
    font-weight: 600;
    line-height: 1.2;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
    white-space: nowrap;
}

.hover-info-tooltip.visible {
    opacity: 1;
}

[data-theme="light"] .hover-info-tooltip {
    background: rgba(255, 255, 255, 0.96);
    color: #1f2937;
    border-color: rgba(0, 0, 0, 0.08);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
}

/* Saneamento */
.saneamento-grid {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 6px;
    text-align: center;
}

.saneamento-item {
    background: var(--input-bg);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 8px;
}

.saneamento-val {
    font-size: 14px;
    font-weight: 700;
    display: block;
}

.saneamento-lbl {
    font-size: 10px;
    color: var(--muted);
}

/* ===== COMBOBOX ===== */
.combobox-container {
    position: relative;
}

.combobox-arrow {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    width: 12px;
    height: 12px;
    color: var(--muted);
    pointer-events: none;
}

.combobox-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-top: 4px;
    max-height: 200px;
    overflow-y: auto;
    z-index: 1000;
    display: none;
    box-shadow: var(--shadow);
}

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

.combobox-item {
    padding: 10px 12px;
    font-size: 14px;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    border-bottom: 1px solid var(--border);
}

.combobox-item:last-child {
    border-bottom: none;
}

.combobox-item:hover,
.combobox-item.selected {
    background: var(--accent);
    color: #fff;
}

.item-meta {
    font-size: 12px;
    font-weight: 600;
    opacity: 0.9;
}

/* ===== SUMMARY BOX ===== */
.summary-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.summary-box {
    background: var(--input-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px;
    cursor: pointer;
    transition: all 0.15s;
}

.summary-box:hover {
    border-color: var(--accent);
}

.summary-box.comparison-only {
    cursor: default;
}

.summary-box.comparison-only:hover {
    border-color: var(--border);
}

.summary-box .cargo-title {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--muted);
    margin: 0 0 8px;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--border);
}

.summary-box h5 {
    margin: 0;
    font-size: 14px;
    font-weight: 600;
}

.summary-box p {
    margin: 2px 0 0;
    font-size: 12px;
    color: var(--muted);
}

.summary-box .margin {
    font-size: 13px;
    font-weight: 700;
    color: var(--warn);
    margin-top: 6px;
}

.summary-box-dual {
    display: grid;
    gap: 6px;
}

.summary-box-dual .dual-item {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 8px;
}

.summary-box-dual .dual-item span {
    display: block;
    font-size: 10px;
    font-weight: 600;
    color: var(--muted);
    margin-bottom: 4px;
}

.summary-box-dual .dual-item[data-status="INAPTO"] span {
    color: var(--err);
}

.summary-box-dual .dual-item[data-status="ELEITO"] span {
    color: var(--ok);
}

/* ===== BAIRRO LIST ===== */
.bairro-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px;
    background: var(--input-bg);
    border: 1px solid var(--border);
    border-radius: 6px;
    margin-bottom: 6px;
    transition: all 0.15s;
}

.bairro-item:hover {
    border-color: var(--accent);
}

.bairro-item-check {
    cursor: pointer;
}

.bairro-item-content {
    flex: 1;
    cursor: pointer;
}

.bairro-item-name {
    font-weight: 600;
    font-size: 13px;
}

.bairro-item-info {
    font-size: 11px;
    color: var(--muted);
    display: flex;
    justify-content: space-between;
    margin-top: 2px;
}

.bairro-item-margin {
    color: var(--warn);
    font-weight: 600;
}

/* ===== MODAIS ===== */
.info-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    z-index: 9999;
    display: none;
    justify-content: center;
    align-items: center;
    padding: 20px;
    opacity: 0;
    transition: opacity 0.2s;
}

.info-overlay.visible {
    display: flex;
    opacity: 1;
}

.info-modal {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 24px;
    max-width: 560px;
    width: 100%;
    position: relative;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    max-height: 80vh;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--border) transparent;
}

.info-modal::-webkit-scrollbar {
    width: 5px;
}
.info-modal::-webkit-scrollbar-track {
    background: transparent;
}
.info-modal::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 3px;
}

.wide-modal {
    max-width: 750px;
    max-height: 85vh;
    overflow-y: auto;
}

.info-modal h3 {
    margin: 0 0 16px;
    font-size: 16px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
}

.info-modal p {
    margin-bottom: 12px;
    line-height: 1.6;
    font-size: 14px;
    color: var(--text-sec);
}

.info-close {
    position: sticky;
    top: -24px;
    float: right;
    margin: -8px -8px 8px 8px;
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--muted);
    font-size: 14px;
    cursor: pointer;
    padding: 3px 8px;
    border-radius: 4px;
    z-index: 10;
    line-height: 1.4;
}

.info-close:hover {
    background: var(--surface-2);
    color: var(--text);
}

/* Guia de Uso */
.guide-content h3 {
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 16px;
}

.guide-content h4 {
    margin: 20px 0 10px;
    font-size: 13px;
    font-weight: 600;
    color: var(--accent);
    text-transform: uppercase;
}

.guide-content p {
    margin-bottom: 12px;
    line-height: 1.6;
}

.guide-content ul {
    margin-bottom: 14px;
    padding-left: 20px;
    color: var(--text-sec);
}

.guide-content li {
    margin-bottom: 6px;
    line-height: 1.5;
}

.guide-content strong {
    color: var(--text);
}

.guide-content a {
    color: var(--accent);
}

/* Botão Info (i) */
.info-button {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    border: 1px solid var(--muted);
    background: transparent;
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
    font-family: serif;
    cursor: pointer;
    transition: all 0.15s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.info-button:hover,
.info-button.blinking {
    border-color: var(--accent);
    color: var(--accent);
}

.info-button.blinking {
    animation: pulse 2s infinite;
}

@keyframes pulse {

    0%,
    100% {
        box-shadow: 0 0 0 0 rgba(59, 130, 246, 0.4);
    }

    50% {
        box-shadow: 0 0 0 6px rgba(59, 130, 246, 0);
    }
}

/* ===== LEAFLET OVERRIDES ===== */
.leaflet-tooltip {
    background: var(--surface) !important;
    border: 1px solid var(--accent) !important;
    color: var(--text) !important;
    box-shadow: var(--shadow) !important;
    border-radius: 6px !important;
    padding: 6px 10px !important;
    font-family: inherit !important;
}

.leaflet-tooltip.feature-map-tooltip {
    padding: 0 !important;
    border: 1px solid rgba(37, 99, 235, 0.22) !important;
    border-radius: 8px !important;
    background: rgba(255, 255, 255, 0.96) !important;
    color: #171717 !important;
    box-shadow: 0 12px 32px rgba(15, 23, 42, 0.16), 0 2px 8px rgba(15, 23, 42, 0.08) !important;
    overflow: hidden;
    backdrop-filter: blur(6px);
}

[data-theme="dark"] .leaflet-tooltip.feature-map-tooltip {
    background: rgba(28, 28, 25, 0.97) !important;
    color: #f4f4ee !important;
    border-color: rgba(148, 163, 184, 0.22) !important;
    box-shadow: 0 14px 34px rgba(0, 0, 0, 0.42), 0 2px 8px rgba(0, 0, 0, 0.28) !important;
}

.basic-map-tooltip {
    min-width: 170px;
    max-width: 260px;
    padding: 8px 10px;
    line-height: 1.2;
}

.basic-map-tooltip strong,
.shift-tooltip-head strong {
    display: block;
    color: inherit;
    font-size: 11px;
    font-weight: 800;
    line-height: 1.18;
    text-transform: uppercase;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.basic-map-tooltip small,
.shift-tooltip-head small {
    display: block;
    margin-top: 3px;
    color: #737373;
    font-size: 10px;
    font-weight: 700;
    line-height: 1.1;
    text-transform: uppercase;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

[data-theme="dark"] .basic-map-tooltip small,
[data-theme="dark"] .shift-tooltip-head small {
    color: #b8b8ad;
}

.shift-tooltip {
    --shift-color: #2563eb;
    width: 270px;
    line-height: 1.15;
}

.shift-tooltip-head {
    padding: 9px 11px 8px;
    border-bottom: 1px solid rgba(229, 229, 229, 0.9);
}

[data-theme="dark"] .shift-tooltip-head {
    border-bottom-color: rgba(66, 66, 60, 0.95);
}

.shift-tooltip-swing {
    display: flex;
    align-items: center;
    gap: 7px;
    padding: 8px 11px;
    color: var(--shift-color);
    background: color-mix(in srgb, var(--shift-color) 9%, transparent);
    border-bottom: 1px solid color-mix(in srgb, var(--shift-color) 18%, transparent);
    font-size: 11px;
    font-weight: 800;
}

.shift-tooltip-swing b {
    font-size: 12px;
}

.shift-tooltip-arrow {
    display: inline-grid;
    place-items: center;
    width: 20px;
    height: 20px;
    border-radius: 999px;
    color: #ffffff;
    background: var(--shift-color);
    font-size: 13px;
    line-height: 1;
}

.shift-tooltip-results {
    padding: 7px 9px 8px;
    display: grid;
    gap: 5px;
}

.shift-tooltip-row {
    display: grid;
    grid-template-columns: 34px minmax(0, 1fr) 36px 46px;
    align-items: center;
    gap: 6px;
    min-height: 24px;
    padding: 4px 5px;
    border-radius: 5px;
    background: rgba(245, 245, 245, 0.9);
    font-size: 10px;
}

[data-theme="dark"] .shift-tooltip-row {
    background: rgba(40, 40, 36, 0.95);
}

.shift-tooltip-row span {
    color: #737373;
    font-weight: 800;
}

.shift-tooltip-row strong {
    min-width: 0;
    color: inherit;
    font-size: 10px;
    font-weight: 850;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.shift-tooltip-row em {
    color: #737373;
    font-size: 9px;
    font-style: normal;
    font-weight: 800;
    text-align: right;
}

.shift-tooltip-row b {
    color: inherit;
    font-size: 10px;
    font-weight: 900;
    text-align: right;
}

.shift-tooltip-row.muted {
    opacity: 0.72;
}

.leaflet-tooltip-left::before,
.leaflet-tooltip-right::before {
    border-left-color: var(--accent) !important;
    border-right-color: var(--accent) !important;
}

.leaflet-tile-container {
    filter: var(--map-tiles-filter, none);
}

/* ===== SELEÇÃO BOX (Arrastar) ===== */
.selection-box {
    position: absolute;
    border: 1px solid var(--accent);
    background: rgba(59, 130, 246, 0.15);
    z-index: 2000;
    pointer-events: none;
    display: none;
}

/* ===== CAROUSEL ===== */
.carousel-wrapper {
    position: relative;
    overflow: hidden;
}

.results-carousel {
    display: flex;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    scrollbar-width: none;
    cursor: grab;
}

.results-carousel::-webkit-scrollbar {
    display: none;
}

.results-carousel.grabbing {
    cursor: grabbing;
    scroll-snap-type: none;
}

.results-page {
    min-width: 100%;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    scroll-snap-align: start;
    padding: 2px;
}

.party-results-page {
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.party-result-card {
    min-width: 0;
    display: grid;
    gap: 12px;
    align-content: start;
}

.party-result-header {
    margin-bottom: 0;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: start;
    gap: 12px;
}

.party-result-info {
    min-width: 0;
}

.party-result-title {
    margin: 0;
    overflow-wrap: anywhere;
    word-break: break-word;
}

.party-result-subtitle {
    font-size: 0.7rem;
    color: var(--muted);
    margin-top: 4px;
    overflow-wrap: anywhere;
    word-break: break-word;
}

.party-result-badge {
    font-size: 0.8rem;
    gap: 4px;
    max-width: 100%;
    justify-self: end;
    align-self: start;
    white-space: nowrap;
}

.party-result-stats {
    display: flex;
    justify-content: space-between;
    align-items: end;
    gap: 12px;
    min-width: 0;
}

.party-result-votes {
    min-width: 0;
}

.party-result-action {
    font-size: 10px;
    opacity: 0.6;
    align-self: flex-end;
    white-space: nowrap;
    flex-shrink: 0;
}

.carousel-arrow {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 32px;
    height: 32px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 50%;
    color: var(--text);
    cursor: pointer;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    transition: all 0.15s;
}

.carousel-arrow:hover {
    background: var(--surface-2);
    transform: translateY(-50%) scale(1.05);
}

.carousel-arrow.disabled {
    opacity: 0.3;
    pointer-events: none;
}

.carousel-arrow.prev {
    left: 0;
}

.carousel-arrow.next {
    right: 0;
}

.carousel-paginator {
    text-align: center;
    font-size: 12px;
    color: var(--muted);
    margin-top: 6px;
}

@media (max-width: 640px) {
    .results-page {
        grid-template-columns: 1fr;
    }

    .party-result-header {
        grid-template-columns: 1fr;
    }

    .party-result-badge {
        justify-self: start;
    }

    .party-result-stats {
        flex-direction: column;
        align-items: flex-start;
    }
}

/* ===== ANIMAÇÕES ===== */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(6px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.animation-fade {
    animation: fadeIn 0.3s ease;
}

/* ===== LOADING STATES & TRANSITIONS ===== */

/* Transição suave para seções */
.section {
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.section.loading {
    opacity: 0.6;
    pointer-events: none;
}

/* Spinner inline para botões */
.button.loading {
    position: relative;
    color: transparent;
    pointer-events: none;
}

.button.loading::after {
    content: '';
    position: absolute;
    width: 18px;
    height: 18px;
    top: 50%;
    left: 50%;
    margin-left: -9px;
    margin-top: -9px;
    border: 2px solid transparent;
    border-top-color: currentColor;
    border-right-color: currentColor;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

.button.primary.loading::after {
    border-top-color: #fff;
    border-right-color: #fff;
}

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

/* Skeleton loading para cards */
.skeleton {
    background: linear-gradient(90deg,
            var(--border) 0%,
            var(--surface-2) 50%,
            var(--border) 100%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: var(--radius);
}

@keyframes shimmer {
    0% {
        background-position: 200% 0;
    }

    100% {
        background-position: -200% 0;
    }
}

/* Skeleton cards para resultados */
.skeleton-card {
    height: 100px;
    background: var(--input-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    position: relative;
    overflow: hidden;
}

.skeleton-card::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg,
            transparent 0%,
            rgba(255, 255, 255, 0.05) 50%,
            transparent 100%);
    animation: shimmer 1.5s infinite;
    background-size: 200% 100%;
}

/* Chip loading state */
.chip-button {
    transition: all 0.2s ease, transform 0.15s ease;
}

.chip-button:active {
    transform: scale(0.95);
}

.chip-button.loading {
    position: relative;
    color: transparent;
}

.chip-button.loading::after {
    content: '';
    position: absolute;
    width: 14px;
    height: 14px;
    top: 50%;
    left: 50%;
    margin: -7px 0 0 -7px;
    border: 2px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

/* Fade transition para conteúdo */
.fade-content {
    transition: opacity 0.25s ease;
}

.fade-content.fading {
    opacity: 0;
}

/* Loader overlay aprimorado com spinner */
.loader-overlay {
    position: absolute;
    inset: 0;
    background: rgba(10, 10, 10, 0.85);
    color: var(--text);
    display: none;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 16px;
    font-size: 14px;
    font-weight: 500;
    text-align: center;
    z-index: 100;
    backdrop-filter: blur(4px);
    padding: 28px;
}

.loader-overlay::before {
    content: '';
    width: 40px;
    height: 40px;
    border: 3px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.loader-overlay::after {
    content: '';
    width: min(320px, 72%);
    height: 8px;
    border-radius: 999px;
    background:
        linear-gradient(90deg, var(--accent), var(--accent-hover)) 0 0 / 30% 100% no-repeat,
        rgba(255, 255, 255, 0.08);
    animation: loaderBarIndeterminate 1.1s ease-in-out infinite;
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.05);
}

.loader-overlay[data-progress-mode="determinate"]::after {
    animation: none;
    background:
        linear-gradient(90deg, var(--accent), var(--accent-hover)) 0 0 / var(--loader-progress, 0%) 100% no-repeat,
        rgba(255, 255, 255, 0.08);
}

[data-theme="light"] .loader-overlay {
    background: rgba(255, 255, 255, 0.85);
}

[data-theme="light"] .loader-overlay::after {
    background:
        linear-gradient(90deg, var(--accent), var(--accent-hover)) 0 0 / 30% 100% no-repeat,
        rgba(15, 23, 42, 0.08);
    box-shadow: inset 0 0 0 1px rgba(15, 23, 42, 0.08);
}

.loader-overlay.visible {
    display: flex;
}

/* Pulse animation para elementos ativos */
@keyframes pulse-glow {

    0%,
    100% {
        box-shadow: 0 0 0 0 rgba(59, 130, 246, 0.4);
    }

    50% {
        box-shadow: 0 0 0 8px rgba(59, 130, 246, 0);
    }
}

.button.primary.loading {
    animation: pulse-glow 1.5s ease-in-out infinite;
}

/* Progress bar para carregamento */
.progress-bar {
    width: 100%;
    height: 3px;
    background: var(--border);
    border-radius: 2px;
    overflow: hidden;
    margin-top: 8px;
}

.progress-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent), var(--accent-hover));
    border-radius: 2px;
    width: 0%;
    transition: width 0.3s ease;
}

.progress-bar.indeterminate .progress-bar-fill {
    width: 30%;
    animation: indeterminate 1.5s ease-in-out infinite;
}

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

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

@keyframes loaderBarIndeterminate {
    0% {
        background-size: 18% 100%, 100% 100%;
        background-position: -40% 0, 0 0;
    }

    100% {
        background-size: 32% 100%, 100% 100%;
        background-position: 140% 0, 0 0;
    }
}

/* Slide transition para seções */
.section-slide {
    transition: max-height 0.3s ease, opacity 0.3s ease, padding 0.3s ease;
    overflow: hidden;
}

.section-slide.collapsed {
    max-height: 0;
    opacity: 0;
    padding-top: 0;
    padding-bottom: 0;
}

/* Content loader para resultados */
#resultsContent {
    transition: opacity 0.2s ease;
    min-height: 100px;
}

#resultsContent.loading {
    opacity: 0.5;
    pointer-events: none;
}

/* Grid com animação de entrada */
.grid .cand {
    animation: fadeSlideIn 0.3s ease backwards;
}

.grid .cand:nth-child(1) {
    animation-delay: 0.05s;
}

.grid .cand:nth-child(2) {
    animation-delay: 0.1s;
}

.grid .cand:nth-child(3) {
    animation-delay: 0.15s;
}

.grid .cand:nth-child(4) {
    animation-delay: 0.2s;
}

.grid .cand:nth-child(5) {
    animation-delay: 0.25s;
}

.grid .cand:nth-child(6) {
    animation-delay: 0.3s;
}

@keyframes fadeSlideIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Barras de porcentagem animadas */
.bar-fill {
    transition: width 0.5s ease;
}

/* Transição para profile sections */
.profile-section {
    transition: opacity 0.2s ease;
}

.profile-section.loading {
    opacity: 0.5;
}

/* Toast notification (para mensagens rápidas) */
.toast {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px 20px;
    font-size: 14px;
    font-weight: 500;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    z-index: 10000;
    opacity: 0;
    transition: transform 0.3s ease, opacity 0.3s ease;
}

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

.toast.success {
    border-left: 3px solid var(--ok);
}

.toast.error {
    border-left: 3px solid var(--err);
}

.toast.info {
    border-left: 3px solid var(--accent);
}

/* ===== RESPONSIVE ===== */
@media (max-width: 1500px) {
    .side {
        width: 340px;
    }
    #resizeHandleLeft {
        left: 352px;
    }
    #resizeHandleRight {
        right: 352px;
    }
}

@media (max-width: 1100px) {
    .side {
        position: relative;
        top: auto;
        bottom: auto;
        left: auto !important;
        right: auto !important;
        width: 100% !important;
        margin-top: 12px;
        box-shadow: none;
    }

    .app {
        display: flex;
        flex-direction: column;
        height: auto;
        overflow: auto;
    }

    #mapPanel {
        position: relative;
        height: 55vh;
        min-height: 300px;
    }

    .resize-handle {
        display: none;
    }

    .panel-expand-tab {
        display: none !important;
    }

    .panel.side.panel-collapsed {
        transform: none !important;
        width: 100% !important;
        opacity: 1;
        pointer-events: auto;
    }
}

/* ===== HIDDEN/OPTION ===== */
.option-hidden {
    display: none;
}

/* ===== NAV TABS (se usado) ===== */
.nav-tabs {
    display: flex;
    background: var(--input-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 3px;
    gap: 2px;
    margin-bottom: 14px;
}

.nav-tab-btn {
    flex: 1;
    padding: 8px;
    font-size: 12px;
    font-weight: 600;
    font-family: inherit;
    text-align: center;
    color: var(--muted);
    background: transparent;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.15s;
}

.nav-tab-btn:hover {
    color: var(--text);
}

.nav-tab-btn.active {
    background: var(--surface);
    color: var(--accent);
}

/* ========================================
   APOIO A GOVERNADOR - NOVOS ESTILOS
   ======================================== */

/* Badge de apoio nos cards de partido/coligação */
.sb-gov-support {
    font-size: 0.7rem;
    color: var(--accent);
    margin-top: 3px;
    font-weight: 500;
    font-style: italic;
}

/* Apoio na lista de candidatos (modal) */
.cand-details-panel .gov-support,
div[style*="Apoio:"] {
    font-size: 0.65rem !important;
    color: var(--accent) !important;
    margin-top: 2px;
    font-style: italic;
}

/* Hover effect nos cards com apoio */
.summary-box:hover .sb-gov-support {
    color: var(--accent-hover, #60a5fa);
}

/* Badge de apoio nos cards da carousel */
.cand div[style*="↑"] {
    font-size: 0.7rem;
    color: var(--accent);
    margin-top: 4px;
    font-weight: 500;
    font-style: italic;
}

/* ============================================
   HISTÓRICO ELEITORAL - ESTILOS MINIMALISTAS
   ============================================ */

/* Modal Base */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 10000;
    display: none;
    align-items: center;
    justify-content: center;
}

.modal.visible {
    display: flex;
}

.modal-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
}

.modal-container {
    position: relative;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.4);
    max-width: 900px;
    width: 90vw;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    animation: modalSlideIn 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-20px) scale(0.95);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
}

.modal-header h2 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    color: var(--text);
}

.modal-close {
    background: none;
    border: none;
    font-size: 28px;
    line-height: 1;
    color: var(--muted);
    cursor: pointer;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    transition: all 0.2s;
}

.modal-close:hover {
    background: var(--surface-2);
    color: var(--text);
}

.modal-body {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    scrollbar-width: thin;
    scrollbar-color: var(--border) transparent;
}

.modal-body::-webkit-scrollbar {
    width: 8px;
}

.modal-body::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 4px;
}

/* History Modal Specific */
.history-modal {
    max-width: 1000px;
}

/* Loading States */
.history-loading,
.history-error,
.history-empty {
    padding: 60px 20px;
    text-align: center;
    color: var(--muted);
    font-size: 14px;
}

.history-error {
    color: var(--err);
}

/* Header Info */
.history-header {
    margin-bottom: 20px;
}

.history-info {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 12px;
    padding: 14px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.history-info-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.history-info-item .label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--muted);
    font-weight: 600;
}

.history-info-item .value {
    font-size: 14px;
    color: var(--text);
    font-weight: 500;
}

/* Tabs */
.history-tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 20px;
    padding: 4px;
    background: var(--surface-2);
    border-radius: var(--radius);
    border: 1px solid var(--border);
}

.history-tab {
    flex: 1;
    padding: 8px 12px;
    background: none;
    border: none;
    border-radius: 5px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-sec);
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.history-tab:hover {
    background: var(--surface);
    color: var(--text);
}

.history-tab.active {
    background: var(--accent);
    color: white;
    box-shadow: 0 2px 4px rgba(59, 130, 246, 0.3);
}

/* Content */
.history-content {
    min-height: 300px;
}

/* Timeline */
.history-timeline {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* Election Card - Estilo Minimalista Americano */
.history-election-card {
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    transition: all 0.2s;
}

.history-election-card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    border-color: var(--accent);
}

.history-election-card.current {
    border-left: 3px solid var(--accent);
    background: linear-gradient(to right, rgba(59, 130, 246, 0.05), var(--surface-2));
}

/* Year Badge */
.election-year {
    display: inline-block;
    font-size: 12px;
    font-weight: 700;
    color: var(--accent);
    padding: 4px 10px;
    background: rgba(59, 130, 246, 0.1);
    border-radius: 4px;
    margin-bottom: 12px;
}

/* Winner Display */
.election-winner {
    display: grid;
    grid-template-columns: 3px 1fr auto;
    gap: 12px;
    align-items: center;
    margin-bottom: 16px;
}

.winner-bar {
    width: 3px;
    height: 40px;
    border-radius: 2px;
}

.winner-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.winner-name {
    font-size: 16px;
    font-weight: 600;
    color: var(--text);
}

.winner-party {
    font-size: 12px;
    color: var(--muted);
    font-weight: 500;
}

.winner-pct {
    font-size: 24px;
    font-weight: 700;
    color: var(--text);
    font-variant-numeric: tabular-nums;
}

/* Details Table */
.election-details {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--border);
}

.results-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.results-table thead {
    border-bottom: 1px solid var(--border);
}

.results-table th {
    text-align: left;
    padding: 8px 12px;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--muted);
    font-weight: 600;
}

.results-table td {
    padding: 10px 12px;
    color: var(--text);
    border-bottom: 1px solid rgba(128, 128, 128, 0.1);
}

.results-table tbody tr:last-child td {
    border-bottom: none;
}

.results-table tbody tr:hover {
    background: var(--surface);
}

/* Runoff (2º Turno) */
.election-runoff {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
}

.runoff-label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--muted);
    font-weight: 600;
    margin-bottom: 12px;
}

.runoff-bars {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.runoff-candidate {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.runoff-candidate.winner .runoff-name {
    font-weight: 700;
}

.runoff-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 13px;
}

.runoff-name {
    font-weight: 500;
    color: var(--text);
}

.runoff-votes {
    font-size: 12px;
    color: var(--muted);
    font-variant-numeric: tabular-nums;
}

.runoff-bar-bg {
    height: 8px;
    background: var(--surface);
    border-radius: 4px;
    overflow: hidden;
    border: 1px solid var(--border);
}

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

/* Responsive */
@media (max-width: 768px) {
    .modal-container {
        width: 95vw;
        max-height: 90vh;
    }

    .history-tabs {
        flex-wrap: wrap;
    }

    .history-tab {
        font-size: 11px;
        padding: 6px 8px;
    }

    .history-info {
        grid-template-columns: 1fr;
    }

    .winner-pct {
        font-size: 20px;
    }

    .results-table {
        font-size: 12px;
    }

    .results-table th,
    .results-table td {
        padding: 6px 8px;
    }
}

/* Button no Results Box */
#btnLocationHistory {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    padding: 6px 10px !important;
}

#btnLocationHistory svg {
    flex-shrink: 0;
}

/* ============================================
   HISTÓRICO ELEITORAL - ESTILOS MINIMALISTAS
   ============================================ */

/* Modal Base */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 10000;
    display: none;
    align-items: center;
    justify-content: center;
}

.modal.visible {
    display: flex;
}

.modal-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
}

.modal-container {
    position: relative;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.4);
    max-width: 900px;
    width: 90vw;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    animation: modalSlideIn 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-20px) scale(0.95);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
}

.modal-header h2 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    color: var(--text);
}

.modal-close {
    background: none;
    border: none;
    font-size: 28px;
    line-height: 1;
    color: var(--muted);
    cursor: pointer;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    transition: all 0.2s;
}

.modal-close:hover {
    background: var(--surface-2);
    color: var(--text);
}

.modal-body {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    scrollbar-width: thin;
    scrollbar-color: var(--border) transparent;
}

.modal-body::-webkit-scrollbar {
    width: 8px;
}

.modal-body::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 4px;
}

/* History Modal Specific */
.history-modal {
    max-width: 1000px;
}

/* Loading States */
.history-loading,
.history-error,
.history-empty {
    padding: 60px 20px;
    text-align: center;
    color: var(--muted);
    font-size: 14px;
}

.history-error {
    color: var(--err);
}

/* Header Info */
.history-header {
    margin-bottom: 20px;
}

.history-info {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 12px;
    padding: 14px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.history-info-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.history-info-item .label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--muted);
    font-weight: 600;
}

.history-info-item .value {
    font-size: 14px;
    color: var(--text);
    font-weight: 500;
}

/* Tabs */
.history-tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 20px;
    padding: 4px;
    background: var(--surface-2);
    border-radius: var(--radius);
    border: 1px solid var(--border);
}

.history-tab {
    flex: 1;
    padding: 8px 12px;
    background: none;
    border: none;
    border-radius: 5px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-sec);
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.history-tab:hover {
    background: var(--surface);
    color: var(--text);
}

.history-tab.active {
    background: var(--accent);
    color: white;
    box-shadow: 0 2px 4px rgba(59, 130, 246, 0.3);
}

/* Content */
.history-content {
    min-height: 300px;
}

/* Timeline */
.history-timeline {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* Election Card - Estilo Minimalista Americano */
.history-election-card {
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    transition: all 0.2s;
}

.history-election-card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    border-color: var(--accent);
}

.history-election-card.current {
    border-left: 3px solid var(--accent);
    background: linear-gradient(to right, rgba(59, 130, 246, 0.05), var(--surface-2));
}

/* Year Badge */
.election-year {
    display: inline-block;
    font-size: 12px;
    font-weight: 700;
    color: var(--accent);
    padding: 4px 10px;
    background: rgba(59, 130, 246, 0.1);
    border-radius: 4px;
    margin-bottom: 12px;
}

/* Winner Display */
.election-winner {
    display: grid;
    grid-template-columns: 3px 1fr auto;
    gap: 12px;
    align-items: center;
    margin-bottom: 16px;
}

.winner-bar {
    width: 3px;
    height: 40px;
    border-radius: 2px;
}

.winner-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.winner-name {
    font-size: 16px;
    font-weight: 600;
    color: var(--text);
}

.winner-party {
    font-size: 12px;
    color: var(--muted);
    font-weight: 500;
}

.winner-pct {
    font-size: 24px;
    font-weight: 700;
    color: var(--text);
    font-variant-numeric: tabular-nums;
}

/* Details Table */
.election-details {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--border);
}

.results-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.results-table thead {
    border-bottom: 1px solid var(--border);
}

.results-table th {
    text-align: left;
    padding: 8px 12px;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--muted);
    font-weight: 600;
}

.results-table td {
    padding: 10px 12px;
    color: var(--text);
    border-bottom: 1px solid rgba(128, 128, 128, 0.1);
}

.results-table tbody tr:last-child td {
    border-bottom: none;
}

.results-table tbody tr:hover {
    background: var(--surface);
}

/* Runoff (2º Turno) */
.election-runoff {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
}

.runoff-label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--muted);
    font-weight: 600;
    margin-bottom: 12px;
}

.runoff-bars {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.runoff-candidate {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.runoff-candidate.winner .runoff-name {
    font-weight: 700;
}

.runoff-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 13px;
}

.runoff-name {
    font-weight: 500;
    color: var(--text);
}

.runoff-votes {
    font-size: 12px;
    color: var(--muted);
    font-variant-numeric: tabular-nums;
}

.runoff-bar-bg {
    height: 8px;
    background: var(--surface);
    border-radius: 4px;
    overflow: hidden;
    border: 1px solid var(--border);
}

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

/* Responsive */
@media (max-width: 768px) {
    .modal-container {
        width: 95vw;
        max-height: 90vh;
    }

    .history-tabs {
        flex-wrap: wrap;
    }

    .history-tab {
        font-size: 11px;
        padding: 6px 8px;
    }

    .history-info {
        grid-template-columns: 1fr;
    }

    .winner-pct {
        font-size: 20px;
    }

    .results-table {
        font-size: 12px;
    }

    .results-table th,
    .results-table td {
        padding: 6px 8px;
    }
}

/* Button no Results Box */
#btnLocationHistory {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    padding: 6px 10px !important;
}

#btnLocationHistory svg {
    flex-shrink: 0;
}

/* ============================================
   MODO DESEMPENHO - ESTATÍSTICAS E LEGENDA
   ============================================ */

.performance-stats-box {
    margin-top: 12px;
    padding: 10px 12px;
    background: var(--surface-2);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    animation: fadeIn 0.3s ease;
}

.stats-legend {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.legend-gradient-wrapper {
    position: relative;
    height: 24px;
    display: flex;
    align-items: center;
}

.legend-gradient {
    height: 10px;
    border-radius: 6px;
    width: 100%;
    border: 1px solid var(--border);
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
}

.performance-slider {
    position: absolute;
    width: 100%;
    height: 24px;
    opacity: 0;
    cursor: pointer;
    z-index: 3;
}

.slider-indicator {
    position: absolute;
    width: 4px;
    height: 20px;
    background: var(--text);
    border-radius: 2px;
    top: 50%;
    transform: translate(-50%, -50%);
    z-index: 2;
    pointer-events: none;
    box-shadow: 0 0 4px rgba(0, 0, 0, 0.3);
    transition: left 0.05s ease;
}

.legend-labels {
    display: flex;
    justify-content: space-between;
    font-size: 11px;
    font-weight: 600;
}

.legend-min {
    color: var(--muted);
}

.legend-max {
    color: var(--text);
}

.legend-filter {
    color: var(--accent);
    font-weight: 700;
}

.stats-summary {
    margin-top: 8px;
    text-align: center;
    color: var(--muted);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    flex-wrap: wrap;
}

.stats-summary small {
    font-size: 11px;
}

.reset-filter-btn {
    background: var(--accent);
    color: white;
    border: none;
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.reset-filter-btn:hover {
    background: var(--accent-hover);
    transform: scale(1.02);
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-4px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ============================================
   DEPUTY SEARCH & COMPARISON MODE
   ============================================ */

.deputy-search-box {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.search-input-wrapper {
    position: relative;
}

.search-input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--text);
    font-size: 13px;
    transition: all 0.2s;
}

.search-input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 2px rgba(var(--accent-rgb), 0.2);
}

.search-input::placeholder {
    color: var(--muted);
}

.search-results {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    max-height: 200px;
    overflow-y: auto;
    z-index: 100;
    display: none;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.search-results.visible {
    display: block;
}

.search-result-item {
    padding: 8px 12px;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    border-bottom: 1px solid var(--border);
    transition: background 0.15s;
}

.search-result-item:last-child {
    border-bottom: none;
}

.search-result-item:hover {
    background: var(--surface-2);
}

.search-result-item.highlighted {
    background: var(--surface-2);
    outline: 1px solid var(--accent);
}

.search-result-item.selected {
    background: var(--accent);
    color: white;
}

.search-result-name {
    font-weight: 600;
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.search-result-number {
    color: var(--muted);
    font-family: monospace;
    font-size: 11px;
}

.search-result-party {
    font-size: 10px;
    padding: 2px 6px;
    border-radius: 3px;
    background: var(--surface-2);
    color: var(--muted);
}

.comparison-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    min-height: 24px;
}

.comparison-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    color: white;
    animation: chipIn 0.2s ease;
}

@keyframes chipIn {
    from {
        opacity: 0;
        transform: scale(0.8);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

.comparison-chip .chip-number {
    font-family: monospace;
    font-size: 10px;
    opacity: 0.8;
}

.comparison-chip .chip-party {
    font-size: 9px;
    opacity: 0.7;
}

.comparison-chip .chip-remove {
    cursor: pointer;
    opacity: 0.7;
    transition: opacity 0.15s;
    font-size: 14px;
    line-height: 1;
}

.comparison-chip .chip-remove:hover {
    opacity: 1;
}

.comparison-hint {
    color: var(--muted);
    font-size: 10px;
    text-align: center;
}

.comparison-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 8px;
    padding: 8px;
    background: var(--surface-2);
    border-radius: var(--radius);
}

.comparison-legend-item {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 11px;
}

.comparison-legend-color {
    width: 12px;
    height: 12px;
    border-radius: 2px;
}

/* ============================================
   INDICADOR DE MEMÓRIA
   ============================================ */

#memoryIndicator {
    padding: 4px 8px;
    background: var(--surface-2);
    border-radius: 6px;
    border: 1px solid var(--border);
    transition: all 0.3s;
}

#memoryStatus.ok {
    color: var(--ok);
    font-weight: 600;
}

#memoryStatus.warn {
    color: var(--warn);
    font-weight: 600;
}

#memoryStatus.critical {
    color: var(--err);
    font-weight: 700;
    animation: pulse 1.5s infinite;
}

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.6;
    }
}

/* ===== ISE FACTOR SELECTOR ===== */
.ise-factor-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: 1;
    min-width: 120px;
}

.ise-factor-group-label {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--muted);
    padding: 0 2px;
}

.ise-factor-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}

.ise-factor-chip {
    padding: 4px 9px;
    font-size: 11px;
    font-weight: 500;
    font-family: inherit;
    color: var(--text-sec);
    background: var(--input-bg);
    border: 1px solid var(--border);
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.15s;
    white-space: nowrap;
}

.ise-factor-chip:hover {
    border-color: var(--accent);
    color: var(--text);
}

.ise-factor-chip.active {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
    font-weight: 600;
}
.method-card {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 12px;
}

[data-theme="light"] .method-card {
    background: #f8f9fa;
}

/* Filtro de candidatos ISE */
.ise-candidate-filter {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin: 0 16px 12px 16px;
    padding: 10px 12px;
    background: rgba(255,255,255,0.03);
    border: 1px solid var(--border);
    border-radius: 8px;
}

.ise-candidate-filter-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.ise-candidate-filter-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.ise-mode-pills {
    display: flex;
    gap: 4px;
    background: var(--input-bg);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 3px;
}

.ise-mode-pill {
    flex: 1;
    padding: 4px 10px;
    font-size: 11px;
    font-weight: 600;
    font-family: inherit;
    color: var(--muted);
    background: transparent;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.15s;
    white-space: nowrap;
}

.ise-mode-pill:hover { color: var(--text); }

.ise-mode-pill.active {
    background: var(--accent);
    color: #fff;
}

.ise-candidate-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    min-height: 28px;
}

.ise-cand-chip {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    border: 2px solid;
    cursor: pointer;
    transition: all 0.15s;
    user-select: none;
}

.ise-cand-chip.inactive {
    opacity: 0.35;
    filter: grayscale(0.5);
}

.ise-cand-chip .chip-x {
    font-size: 13px;
    opacity: 0.7;
    line-height: 1;
}
.ise-cand-chip .chip-x:hover { opacity: 1; }

/* Mano a mano - destaque */
.ise-mano-badge {
    font-size: 10px;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 4px;
    background: rgba(255,255,255,0.08);
    color: var(--muted);
    letter-spacing: 0.03em;
}

/* Tooltip do ISE */
#ise-tooltip {
    background: rgba(20, 20, 20, 0.95);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 6px;
    color: #f1f1f1;
    font-size: 11px;
    pointer-events: none;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(8px);
    width: 200px;
    transition: left 0.1s ease, top 0.1s ease;
}

[data-theme="light"] #ise-tooltip {
    background: rgba(255, 255, 255, 0.95);
    border: 1px solid rgba(0, 0, 0, 0.1);
    color: #333;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
}

#ise-tooltip .tt-h {
    padding: 8px 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

[data-theme="light"] #ise-tooltip .tt-h {
    border-bottom: 1px solid rgba(0, 0, 0, 0.08);
}

#ise-tooltip .tt-name {
    font-weight: 600;
    font-size: 13px;
    max-width: 130px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

#ise-tooltip .tt-idx {
    font-weight: 700;
    color: #fff;
    background: rgba(255, 255, 255, 0.1);
    padding: 2px 6px;
    border-radius: 4px;
}

[data-theme="light"] #ise-tooltip .tt-idx {
    color: #000;
    background: rgba(0, 0, 0, 0.05);
}

#ise-tooltip .tt-b {
    padding: 8px 12px;
}

#ise-tooltip .tt-bairro {
    color: #a1a1aa;
    margin-bottom: 6px;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

[data-theme="light"] #ise-tooltip .tt-bairro {
    color: #555;
}

#ise-tooltip .tt-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
}

#ise-tooltip .tt-pct {
    font-size: 15px;
    font-weight: 700;
    color: #fff;
}

[data-theme="light"] #ise-tooltip .tt-pct {
    color: #000;
}

#ise-tooltip .tt-faixa {
    display: inline-block;
    padding: 2px 6px;
    border-radius: 4px;
    font-weight: 600;
    font-size: 10px;
    margin-top: 4px;
}

#ise-tooltip .faixa-baixo {
    background: rgba(74, 158, 255, 0.15);
    color: #4a9eff;
}

#ise-tooltip .faixa-medio {
    background: rgba(245, 200, 66, 0.15);
    color: #f5c842;
}

#ise-tooltip .faixa-alto {
    background: rgba(255, 107, 74, 0.15);
    color: #ff6b4a;
}

/* ============================================
   MOBILE NAVIGATION BAR
   ============================================ */
.mobile-nav {
    display: none;
}

/* ============================================
   MOBILE RESPONSIVE — ≤768px
   ============================================ */
@media (max-width: 768px) {

    :root {
        --mobile-nav-height: calc(52px + env(safe-area-inset-bottom, 0px));
        --mobile-sheet-max-height: calc(100dvh - var(--mobile-nav-height) - 8px);
        --mobile-sheet-height: min(50dvh, var(--mobile-sheet-max-height));
    }

    /* ----- MOBILE NAV BAR ----- */
    .mobile-nav {
        display: flex;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        z-index: 500;
        background: var(--surface);
        border-top: 1px solid var(--border);
        padding: 4px 0;
        padding-bottom: calc(4px + env(safe-area-inset-bottom, 0px));
        gap: 0;
        box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.25);
    }

    .mobile-nav-btn {
        flex: 1;
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 2px;
        background: transparent;
        border: none;
        color: var(--muted);
        font-size: 9px;
        font-weight: 600;
        font-family: inherit;
        cursor: pointer;
        padding: 5px 4px;
        transition: color 0.2s;
        -webkit-tap-highlight-color: transparent;
    }

    .mobile-nav-btn.active {
        color: var(--accent);
    }

    .mobile-nav-btn svg {
        width: 20px;
        height: 20px;
    }

    /* ----- APP LAYOUT ----- */
    .app {
        display: block;
        width: 100vw;
        height: 100vh;
        height: 100dvh;
        overflow: hidden;
    }

    /* ----- MAP FULLSCREEN ----- */
    #mapPanel {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: var(--mobile-nav-height);
        z-index: 1;
        border-radius: 0;
        border: none;
    }

    #map {
        height: 100%;
        width: 100%;
    }

    #map,
    #map .leaflet-container,
    #mapPanel {
        touch-action: pan-x pan-y pinch-zoom;
    }

    /* ----- HIDE DESKTOP ELEMENTS ----- */
    .resize-handle,
    .panel-expand-tab,
    .panel-collapse-btn {
        display: none !important;
    }

    /* ----- SIDE PANELS AS BOTTOM SHEETS ----- */
    .side {
        position: fixed !important;
        top: auto !important;
        bottom: 0 !important;
        left: 0 !important;
        right: 0 !important;
        width: 100% !important;
        height: min(var(--mobile-sheet-height), var(--mobile-sheet-max-height));
        max-height: var(--mobile-sheet-max-height);
        z-index: 400;
        border-radius: 14px 14px 0 0;
        box-shadow: 0 -8px 32px rgba(0, 0, 0, 0.35);
        transform: translateY(100%);
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1),
            height 0.24s cubic-bezier(0.4, 0, 0.2, 1);
        /* Space for mobile nav */
        padding-bottom: env(safe-area-inset-bottom, 0px);
        pointer-events: none;
    }

    .side.mobile-sheet-open {
        transform: translateY(0) !important;
        pointer-events: auto;
    }

    /* Override collapsed state on mobile */
    .panel.side.panel-collapsed {
        transform: translateY(100%) !important;
        width: 100% !important;
        opacity: 1;
        pointer-events: none;
        border: 1px solid var(--border) !important;
        box-shadow: 0 -8px 32px rgba(0, 0, 0, 0.35) !important;
    }

    .panel.side.panel-collapsed.mobile-sheet-open {
        transform: translateY(0) !important;
        width: 100% !important;
        opacity: 1;
        pointer-events: auto;
    }

    .panel-collapsed .body,
    .panel-collapsed #sideLeftBody,
    .panel-collapsed #sideRightBody {
        display: flex !important;
    }

    .panel-collapsed .head {
        display: flex !important;
    }

    .panel-collapsed .head .title,
    .panel-collapsed .head #btnAppGuide,
    .panel-collapsed .head #themeToggle {
        display: inline-flex !important;
    }

    /* Drag handle indicator on mobile sheets */
    .side .head::before {
        content: '';
        position: absolute;
        top: 5px;
        left: 50%;
        transform: translateX(-50%);
        width: 32px;
        height: 3px;
        background: var(--border);
        border-radius: 2px;
    }

    .side .head {
        position: relative;
        min-height: 36px;
        padding: 10px 10px 6px;
        cursor: grab;
        touch-action: none;
    }

    /* ----- BODY SCROLL ----- */
    .side .body {
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        gap: 5px;
        padding: 6px 8px calc(8px + env(safe-area-inset-bottom, 0px));
        touch-action: pan-y;
    }

    /* Seções mais compactas */
    .section {
        padding: 7px 9px;
    }

    .section h3 {
        margin-bottom: 5px;
        font-size: 9px;
    }

    .section-collapsible .section-header {
        padding: 6px 9px;
    }

    .section-collapsible .section-body {
        padding: 0 9px 8px;
    }

    /* Inputs menores */
    .select,
    .search-input,
    .combobox-input {
        padding: 6px 8px;
        font-size: 11px;
    }

    .select {
        padding-right: 26px;
        background-position: right 8px center;
        background-size: 10px;
    }

    /* Botões menores */
    .button {
        padding: 6px 10px;
        font-size: 11px;
    }

    /* Linha de controles */
    .row {
        gap: 6px;
    }

    .ctrl label {
        font-size: 9px;
    }

    /* Toolbar */
    .toolbar {
        gap: 4px;
    }

    /* ----- FLOATING MAP CONTROLS ----- */
    #mapFloatingControls {
        top: 8px !important;
        left: 8px !important;
        right: auto !important;
    }

    #mapFloatingControls .select {
        font-size: 11px !important;
        padding: 5px 24px 5px 9px !important;
    }

    /* ----- LOADER OVERLAY ----- */
    .loader-overlay {
        z-index: 300;
    }

    /* ----- GRIDS & CARDS ----- */
    .grid {
        grid-template-columns: 1fr !important;
    }

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

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

    .row {
        grid-template-columns: 1fr !important;
    }

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

    /* ----- CHIP GROUPS ----- */
    .chip-group {
        gap: 3px;
    }

    .chip-button {
        padding: 3px 7px;
        font-size: 10px;
        border-radius: 4px;
    }

    /* ----- FILTER TABS ----- */
    .filter-tabs {
        gap: 1px;
        padding: 2px;
        margin-bottom: 8px;
    }

    .tab-btn {
        padding: 4px 5px;
        font-size: 9px;
    }

    /* ----- SLIDERS (touch-friendly) ----- */
    .simple-slider::-webkit-slider-thumb {
        width: 18px;
        height: 18px;
    }

    .simple-slider::-moz-range-thumb {
        width: 16px;
        height: 16px;
    }

    .dual-thumb {
        width: 18px;
        height: 18px;
    }

    .dual-values {
        font-size: 10px;
    }

    /* ----- COMBOBOX ----- */
    .combobox-dropdown {
        max-height: 200px;
    }

    .combobox-item {
        padding: 7px 10px;
        font-size: 11px;
    }

    /* ----- MODALS ----- */
    .info-modal {
        max-width: 100%;
        max-height: 90vh;
        border-radius: 12px 12px 0 0;
        margin: auto 0 0 0;
    }

    .info-overlay {
        align-items: flex-end;
        padding: 0;
    }

    .wide-modal {
        max-width: 100%;
    }

    .modal-container {
        width: 100vw;
        max-height: 90vh;
        border-radius: 12px 12px 0 0;
    }

    /* ----- RESULTS BOX ----- */
    .tabs {
        gap: 3px;
        margin-bottom: 6px;
    }

    .tab {
        padding: 4px 8px;
        font-size: 10px;
        border-radius: 4px;
    }

    .results-page {
        grid-template-columns: 1fr;
    }

    #resultsContent {
        min-height: 48px;
    }

    /* Candidatos: lista compacta horizontal (mobile-first) */
    #resultsContent .grid {
        display: flex;
        flex-direction: column;
        gap: 1px;
        background: var(--border);
        border: 1px solid var(--border);
        border-radius: 8px;
        overflow: hidden;
    }

    .grid .cand {
        animation-duration: 0.15s;
    }

    /* Card vira linha horizontal compacta com swatch colorido */
    .cand {
        display: grid;
        grid-template-columns: 10px 1fr auto;
        grid-template-rows: auto auto;
        gap: 0;
        padding: 6px 8px;
        border-radius: 0 !important;
        border: none !important;
        background: var(--surface) !important;
        align-items: center;
        column-gap: 7px;
        row-gap: 0;
        min-height: 0;
    }

    /* Swatch — coluna 1, ocupa as 2 linhas, círculo compacto */
    .cand .swatch {
        display: block !important;
        grid-column: 1;
        grid-row: 1 / 3;
        width: 10px;
        height: 10px;
        border-radius: 50%;
        flex-shrink: 0;
        align-self: center;
    }

    /* Nome + partido ficam na mesma linha */
    .cand-header {
        grid-column: 2;
        grid-row: 1;
        display: flex;
        align-items: baseline;
        gap: 5px;
        flex-wrap: nowrap;
        min-width: 0;
    }

    .cand h4 {
        font-size: 11px;
        font-weight: 600;
        line-height: 1;
        margin: 0;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .cand small {
        font-size: 9px;
        color: var(--muted);
        white-space: nowrap;
        font-weight: 400;
        flex-shrink: 0;
    }

    /* % + votos ficam na segunda linha */
    .cand-stats {
        grid-column: 2;
        grid-row: 2;
        display: flex;
        align-items: center;
        gap: 5px;
        margin-top: 1px;
    }

    .bigPct {
        font-size: 13px;
        font-weight: 700;
        line-height: 1;
    }

    .smallVotos {
        font-size: 9px;
        color: var(--muted);
        font-weight: 400;
    }

    /* Badge na terceira coluna — ocupa as 2 linhas */
    .status-badge {
        grid-column: 3;
        grid-row: 1 / 3;
        gap: 2px;
        padding: 2px 5px;
        font-size: 8px;
        white-space: nowrap;
        align-self: center;
        margin-top: 0;
        flex-shrink: 0;
    }

    .status-badge svg {
        width: 8px;
        height: 8px;
    }

    /* Métricas compactas */
    .metrics-grid {
        gap: 4px;
    }

    .metric-item {
        padding: 6px 8px;
    }

    .metric-item span {
        font-size: 9px;
    }

    .metric-item strong {
        font-size: 12px;
    }

    /* ----- ISE SECTION ----- */
    .ise-mode-pills {
        flex-wrap: nowrap;
    }

    .ise-mode-pill {
        font-size: 9px;
        padding: 3px 6px;
    }

    .ise-candidate-filter {
        margin: 0 6px 8px 6px;
    }

    .ise-factor-group {
        min-width: 80px;
    }

    .ise-factor-chip {
        font-size: 9px;
        padding: 3px 6px;
    }

    /* ----- TOAST ----- */
    .toast {
        bottom: 60px;
        max-width: 90vw;
        font-size: 11px;
    }

    /* ----- PROFILE GRID ----- */
    .profile-grid-compact {
        grid-template-columns: 1fr;
    }

    /* ----- SEARCH RESULTS ----- */
    .search-results {
        max-height: 200px;
    }

    .search-result-item {
        padding: 7px 10px;
        font-size: 11px;
    }

    /* ----- TITLE & TEXT SIZING ----- */
    .title {
        font-size: 11px;
    }

    .section h3 {
        font-size: 9px;
    }

    #resultsTitle {
        font-size: 10px;
        line-height: 1.1;
        text-transform: uppercase;
        letter-spacing: 0.01em;
    }

    #resultsSubtitle {
        font-size: 9px;
        line-height: 1.2;
    }

    /* ----- HISTORY MODAL MOBILE ----- */
    .history-tabs {
        flex-wrap: wrap;
    }

    .history-tab {
        font-size: 10px;
        padding: 5px 7px;
    }

    /* ----- CANDIDATE DETAILS ----- */
    .cand-details-panel {
        font-size: 11px;
    }

    /* ----- CAROUSEL ----- */
    .carousel-arrow {
        width: 24px;
        height: 24px;
    }

    /* ----- LEAFLET CONTROLS ----- */
    .leaflet-control-zoom {
        margin-top: 8px !important;
        margin-left: 8px !important;
    }

    .leaflet-control-zoom a {
        width: 30px !important;
        height: 30px !important;
        line-height: 30px !important;
        font-size: 16px !important;
    }

    /* ----- GUIDE CONTENT ----- */
    .guide-content {
        font-size: 11px;
    }

    .guide-content h3 {
        font-size: 13px;
    }

    .guide-content h4 {
        font-size: 11px;
    }

    /* ----- PAINEL DE CONTROLES (aba esquerda) ----- */
    #sideLeftPanel .head {
        min-height: 34px;
        padding: 8px 10px 5px;
    }

    /* Botão primário de carregar dados */
    #sideLeftBody .button.primary {
        padding: 7px 10px;
        font-size: 11px;
    }

    /* Botões secundários / ghost */
    #sideLeftBody .button:not(.primary) {
        padding: 5px 8px;
        font-size: 10px;
    }

    /* Chips de eleição (Gerais 2022, Mun. 2024…) */
    #sideLeftBody .chip-group {
        gap: 3px;
        flex-wrap: wrap;
    }

    /* Seções internas do controle */
    #sideLeftBody .section {
        padding: 6px 8px;
    }

    #sideLeftBody .section h3 {
        font-size: 9px;
        margin-bottom: 4px;
    }

    /* Selects do painel de controles */
    #sideLeftBody .select {
        padding: 5px 26px 5px 7px;
        font-size: 11px;
    }

    /* Labels dos sliders */
    #sideLeftBody .dual-values {
        font-size: 10px;
    }
}
