/* ============================================
   PRN MELAKA - Election Analytics Platform
   Sidebar Layout | Bloomberg Inspired | Web 3.0
   ============================================ */

:root {
    /* Primary Colors - Prussian Blue */
    --prussian-blue: #003153;
    --prussian-blue-dark: #00243d;
    --prussian-blue-light: #004a7c;
    
    /* Secondary Colors - Slate Gray */
    --slate-gray: #708090;
    --slate-gray-dark: #4a5568;
    --slate-gray-light: #94a3b8;
    
    /* Accent Colors */
    --border-blue: #1e5a8a;
    --border-blue-light: #2d7ab8;
    --highlight-blue: #0ea5e9;
    
    /* Party Colors */
    --bn-color: #000080;
    --ph-color: #dc2626;
    --pn-color: #15803d;
    --other-color: #6b7280;
    
    /* Status Colors */
    --positive: #22c55e;
    --negative: #ef4444;
    --warning: #eab308;
    --neutral: #64748b;
    
    /* Background Colors */
    --bg-primary: #001829;
    --bg-secondary: #002240;
    --bg-card: #00304d;
    --bg-hover: #003d5c;
    --bg-sidebar: #001520;
    
    /* Text Colors */
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #8b9cb8;
    
    /* Typography */
    --font-mono: 'IBM Plex Mono', monospace;
    --font-sans: 'Plus Jakarta Sans', sans-serif;
    
    /* Spacing */
    --spacing-xs: 4px;
    --spacing-sm: 8px;
    --spacing-md: 16px;
    --spacing-lg: 24px;
    --spacing-xl: 32px;
    
    /* Sidebar */
    --sidebar-width: 260px;
    --sidebar-collapsed: 60px;
    --topbar-height: 56px;
    
    /* Border */
    --border-width: 1px;
    --border-radius: 4px;
}

/* Reset & Base */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 14px;
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-sans);
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.6;
    overflow-x: hidden;
    font-weight: 500;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ============================================
   APP CONTAINER - Sidebar Layout
   ============================================ */
.app-container {
    display: flex;
    min-height: 100vh;
}

/* ============================================
   SIDEBAR
   ============================================ */
.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-sidebar);
    border-right: var(--border-width) solid var(--border-blue);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    z-index: 1000;
    transition: width 0.3s ease, transform 0.3s ease;
}

.sidebar.collapsed {
    width: var(--sidebar-collapsed);
}

.sidebar.collapsed .logo-text,
.sidebar.collapsed .section-title,
.sidebar.collapsed .nav-label,
.sidebar.collapsed .badge-soon,
.sidebar.collapsed .chevron,
.sidebar.collapsed .status-text,
.sidebar.collapsed .version {
    display: none;
}

.sidebar.collapsed .nav-section-content {
    display: none !important;
}

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--spacing-md);
    border-bottom: var(--border-width) solid var(--border-blue);
    min-height: 70px;
}

.logo {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
}

.logo-flag {
    width: 36px;
    height: 24px;
    border-radius: 2px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

.logo-icon {
    font-size: 1.5rem;
    color: var(--highlight-blue);
}

.logo-text {
    font-size: 0.875rem;
    font-weight: 700;
    letter-spacing: 1px;
    color: var(--text-primary);
    line-height: 1.2;
}

.logo-text small {
    font-size: 0.65rem;
    color: var(--text-secondary);
    font-weight: 500;
    letter-spacing: 1.5px;
}

.sidebar-toggle {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: var(--spacing-xs);
    border-radius: var(--border-radius);
    transition: all 0.2s;
}

.sidebar-toggle:hover {
    color: var(--highlight-blue);
    background: var(--bg-hover);
}

.sidebar.collapsed .sidebar-toggle svg {
    transform: rotate(180deg);
}

/* Sidebar Navigation */
.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: var(--spacing-md) 0;
}

.sidebar-nav::-webkit-scrollbar {
    width: 4px;
}

.sidebar-nav::-webkit-scrollbar-thumb {
    background: var(--border-blue);
    border-radius: 2px;
}

.nav-section {
    margin-bottom: var(--spacing-sm);
}

.nav-section-header {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    width: 100%;
    padding: var(--spacing-sm) var(--spacing-md);
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    font-family: var(--font-sans);
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.5px;
    text-align: left;
    transition: all 0.2s;
}

.nav-section-header:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.section-icon {
    font-size: 1rem;
}

.section-title {
    flex: 1;
}

.badge-soon {
    font-size: 0.5rem;
    padding: 2px 6px;
    background: var(--warning);
    color: var(--bg-primary);
    border-radius: 2px;
    letter-spacing: 1px;
}

.chevron {
    transition: transform 0.2s;
}

.nav-section-content.expanded + .nav-section-header .chevron,
.nav-section-header[aria-expanded="true"] .chevron {
    transform: rotate(180deg);
}

.nav-section-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
}

.nav-section-content.expanded {
    max-height: 300px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    padding: var(--spacing-sm) var(--spacing-md);
    padding-left: calc(var(--spacing-md) + var(--spacing-lg));
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.75rem;
    transition: all 0.2s;
    border-left: 2px solid transparent;
}

.nav-item:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.nav-item.active {
    background: rgba(14, 165, 233, 0.1);
    color: var(--highlight-blue);
    border-left-color: var(--highlight-blue);
}

.nav-item.disabled {
    opacity: 0.4;
    pointer-events: none;
}

.nav-icon {
    font-size: 0.875rem;
}

/* Sidebar Footer */
.sidebar-footer {
    padding: var(--spacing-md);
    border-top: var(--border-width) solid var(--border-blue);
}

.data-status {
    display: flex;
    align-items: center;
    gap: var(--spacing-xs);
}

.status-dot {
    width: 8px;
    height: 8px;
    background: var(--positive);
    border-radius: 50%;
    animation: pulse 2s infinite;
}

.status-text {
    font-size: 0.625rem;
    color: var(--positive);
    letter-spacing: 1px;
}

.version {
    font-size: 0.625rem;
    color: var(--text-muted);
}

/* ============================================
   MAIN WRAPPER
   ============================================ */
.main-wrapper {
    flex: 1;
    margin-left: var(--sidebar-width);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    transition: margin-left 0.3s ease;
}

.sidebar.collapsed + .main-wrapper {
    margin-left: var(--sidebar-collapsed);
}

/* ============================================
   TOP BAR
   ============================================ */
.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--spacing-sm) var(--spacing-lg);
    background: var(--bg-secondary);
    border-bottom: var(--border-width) solid var(--border-blue);
    height: var(--topbar-height);
    position: sticky;
    top: 0;
    z-index: 100;
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
}

.mobile-menu-btn {
    display: none;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: var(--spacing-xs);
}

.breadcrumb {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    font-size: 0.875rem;
}

.breadcrumb-item {
    color: var(--text-muted);
}

.breadcrumb-item.current {
    color: var(--text-primary);
    font-weight: 600;
}

.breadcrumb-separator {
    color: var(--border-blue);
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: var(--spacing-lg);
}

/* Volatility Index Gauge */
.volatility-index {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: var(--spacing-xs) var(--spacing-md);
    background: var(--bg-card);
    border: var(--border-width) solid var(--border-blue);
    border-radius: var(--border-radius);
}

.vi-label {
    font-size: 0.5rem;
    color: var(--text-muted);
    letter-spacing: 1px;
}

.vi-gauge {
    position: relative;
    width: 60px;
    height: 30px;
}

.gauge-svg {
    width: 100%;
    height: 100%;
}

.vi-value {
    position: absolute;
    bottom: -2px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--warning);
}

.vi-status {
    font-size: 0.5rem;
    color: var(--warning);
    letter-spacing: 1px;
}

/* Live Indicator */
.live-indicator {
    display: flex;
    align-items: center;
    gap: var(--spacing-xs);
}

.pulse {
    width: 8px;
    height: 8px;
    background: var(--positive);
    border-radius: 50%;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.7); }
    50% { opacity: 0.7; box-shadow: 0 0 0 6px rgba(34, 197, 94, 0); }
}

.live-text {
    font-size: 0.625rem;
    color: var(--positive);
    letter-spacing: 1px;
}

.timestamp {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* ============================================
   PAGE CONTENT
   ============================================ */
.page-content {
    flex: 1;
    padding: var(--spacing-lg);
    overflow-y: auto;
}

.page {
    display: none;
}

.page.active {
    display: block;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ============================================
   STATS ROW
   ============================================ */
.stats-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: var(--spacing-md);
    margin-bottom: var(--spacing-lg);
}

.stat-card {
    background: var(--bg-card);
    border: var(--border-width) solid var(--border-blue);
    border-radius: var(--border-radius);
    padding: var(--spacing-md);
    text-align: center;
}

.stat-card.wide {
    grid-column: span 2;
}

.stat-label {
    font-size: 0.625rem;
    color: var(--text-muted);
    letter-spacing: 1px;
    margin-bottom: var(--spacing-xs);
}

.stat-value {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.2;
}

.stat-value.bn-color { color: #4169e1; }
.stat-value.ph-color { color: var(--ph-color); }
.stat-value.pn-color { color: var(--pn-color); }

.stat-change {
    font-size: 0.75rem;
    margin-top: var(--spacing-xs);
}

.stat-change.positive { color: var(--positive); }
.stat-change.negative { color: var(--negative); }

.stat-sublabel {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-top: var(--spacing-xs);
}

/* ============================================
   SEAT PROGRESS BAR
   ============================================ */
.seat-progress-section {
    background: var(--bg-card);
    border: var(--border-width) solid var(--border-blue);
    border-radius: var(--border-radius);
    padding: var(--spacing-md) var(--spacing-lg);
    margin-bottom: var(--spacing-lg);
}

.seat-progress-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--spacing-sm);
}

.seat-total-label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-primary);
}

.majority-labels {
    display: flex;
    gap: var(--spacing-lg);
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.seat-progress-bar {
    position: relative;
    margin-bottom: var(--spacing-sm);
}

.seat-bar-container {
    position: relative;
    height: 40px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 6px;
    overflow: visible;
}

.seat-bar {
    height: 100%;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: width 0.5s ease;
}

.seat-bar.bn-bar {
    background: linear-gradient(90deg, #0052a5, #003d7a);
}

.seat-bar.ph-bar {
    background: linear-gradient(90deg, #ef4444, #dc2626);
}

.seat-bar.pn-bar {
    background: linear-gradient(90deg, #0ea5e9, #0284c7);
}

.seat-bar-text {
    font-size: 0.95rem;
    font-weight: 700;
    color: #fff;
    text-shadow: 0 1px 2px rgba(0,0,0,0.3);
}

.majority-marker {
    position: absolute;
    top: -5px;
    bottom: -5px;
    width: 3px;
    border-radius: 2px;
    z-index: 10;
}

.majority-marker.simple-majority {
    background: #f59e0b;
    box-shadow: 0 0 8px rgba(245, 158, 11, 0.5);
}

.majority-marker.two-thirds-majority {
    background: #22c55e;
    box-shadow: 0 0 8px rgba(34, 197, 94, 0.5);
}

.seat-progress-legend {
    display: flex;
    justify-content: center;
    gap: var(--spacing-xl);
    margin-top: var(--spacing-sm);
}

.seat-progress-legend .legend-item {
    display: flex;
    align-items: center;
    gap: var(--spacing-xs);
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.legend-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
}

.legend-dot.simple {
    background: #f59e0b;
}

.legend-dot.two-thirds {
    background: #22c55e;
}

/* Responsive */
@media (max-width: 768px) {
    .seat-progress-header {
        flex-direction: column;
        align-items: flex-start;
        gap: var(--spacing-xs);
    }
    
    .majority-labels {
        gap: var(--spacing-md);
        font-size: 0.7rem;
    }
    
    .seat-bar-container {
        height: 35px;
    }
    
    .seat-bar-text {
        font-size: 0.8rem;
    }
    
    .seat-progress-legend {
        gap: var(--spacing-md);
    }
    
    .seat-progress-legend .legend-item {
        font-size: 0.75rem;
    }
}

/* ============================================
   DASHBOARD GRID
   ============================================ */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    gap: var(--spacing-md);
}

.dashboard-grid.single-col {
    grid-template-columns: 1fr;
}

/* Module Base */
.module {
    background: var(--bg-card);
    border: var(--border-width) solid var(--border-blue);
    border-radius: var(--border-radius);
    overflow: hidden;
}

.module-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--spacing-md);
    border-bottom: var(--border-width) solid var(--border-blue);
    background: var(--bg-secondary);
}

.module-header h2 {
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 1px;
    color: var(--text-secondary);
}

.module-content {
    padding: var(--spacing-md);
}

/* Module Sizes */
.seat-distribution { grid-column: span 4; }
.party-performance { grid-column: span 4; }
.top-majorities { grid-column: span 4; }
.urban-rural { grid-column: span 4; }
.turnout-analysis { grid-column: span 4; }
.results-table { grid-column: span 8; }
.voter-demographics { grid-column: span 8; }
.voter-demographics.wide { grid-column: span 12; }
.vote-migration { grid-column: span 4; }
.results-full { grid-column: span 12; }
.analysis-card { grid-column: span 6; }
.map-container { grid-column: span 12; }
.ethnic-analysis { grid-column: span 12; }
.simulation-container { grid-column: span 12; }

/* Info Badge */
.info-badge {
    font-size: 0.5rem;
    padding: 2px 6px;
    background: var(--warning);
    color: var(--bg-primary);
    border-radius: 2px;
    letter-spacing: 1px;
}

/* Search Input */
.module-search input {
    background: var(--bg-primary);
    border: var(--border-width) solid var(--border-blue);
    border-radius: var(--border-radius);
    padding: var(--spacing-xs) var(--spacing-sm);
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: 0.8rem;
    width: 180px;
}

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

.module-search input:focus {
    outline: none;
    border-color: var(--highlight-blue);
}

/* ============================================
   SEAT DISTRIBUTION - PICTOGRAM
   ============================================ */
.parliament-viz {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: var(--spacing-sm) 0;
    gap: var(--spacing-md);
}

.pictogram-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 6px;
    max-width: 280px;
}

.pictogram-seat {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s, background 0.2s;
}

.pictogram-seat svg {
    width: 22px;
    height: 22px;
}

.pictogram-seat:hover {
    transform: scale(1.15);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    z-index: 10;
}

.pictogram-seat.bn {
    background: rgba(65, 105, 225, 0.15);
    color: #4169e1;
    border: 1px solid rgba(65, 105, 225, 0.3);
}

.pictogram-seat.bn:hover {
    background: rgba(65, 105, 225, 0.3);
}

.pictogram-seat.ph {
    background: rgba(220, 38, 38, 0.15);
    color: #dc2626;
    border: 1px solid rgba(220, 38, 38, 0.3);
}

.pictogram-seat.ph:hover {
    background: rgba(220, 38, 38, 0.3);
}

.pictogram-seat.pn {
    background: rgba(21, 128, 61, 0.15);
    color: #15803d;
    border: 1px solid rgba(21, 128, 61, 0.3);
}

.pictogram-seat.pn:hover {
    background: rgba(21, 128, 61, 0.3);
}

.pictogram-seat.other {
    background: rgba(107, 114, 128, 0.15);
    color: #6b7280;
    border: 1px solid rgba(107, 114, 128, 0.3);
}

.pictogram-total {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
}

.pictogram-total .total-number {
    font-size: 32px;
    font-weight: 800;
    color: var(--text-primary);
    line-height: 1;
}

.pictogram-total .total-label {
    font-size: 10px;
    font-weight: 600;
    color: var(--text-muted);
    letter-spacing: 2px;
}

/* Custom Seat Tooltip (Mobile Friendly) */
.seat-tooltip {
    position: absolute;
    z-index: 9999;
    background: var(--bg-card);
    border: 1px solid var(--border-blue);
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
    min-width: 200px;
    max-width: 280px;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s, visibility 0.2s;
    pointer-events: none;
}

.seat-tooltip.visible {
    opacity: 1;
    visibility: visible;
}

.seat-tooltip-header {
    padding: 8px 12px;
    border-radius: 7px 7px 0 0;
    display: flex;
    gap: 8px;
    align-items: center;
}

.seat-tooltip-header.bn {
    background: linear-gradient(135deg, #0052a5, #003d7a);
}

.seat-tooltip-header.ph {
    background: linear-gradient(135deg, #ef4444, #dc2626);
}

.seat-tooltip-header.pn {
    background: linear-gradient(135deg, #22c55e, #16a34a);
}

.seat-tooltip-code {
    font-size: 0.7rem;
    font-weight: 700;
    color: rgba(255, 255, 255, 0.8);
    background: rgba(0, 0, 0, 0.2);
    padding: 2px 6px;
    border-radius: 4px;
}

.seat-tooltip-name {
    font-size: 0.85rem;
    font-weight: 700;
    color: #fff;
}

.seat-tooltip-body {
    padding: 10px 12px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.seat-tooltip-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.seat-tooltip-icon {
    font-size: 0.9rem;
    width: 20px;
    text-align: center;
}

.seat-tooltip-value {
    font-size: 0.8rem;
    color: var(--text-primary);
}

/* Legacy styles kept for compatibility */
.hemicycle-svg {
    width: 100%;
    max-width: 320px;
    height: auto;
}

.hemicycle-seat {
    cursor: pointer;
    transition: transform 0.2s, filter 0.2s;
    transform-origin: center;
}

.hemicycle-seat:hover {
    filter: brightness(1.3) drop-shadow(0 0 6px currentColor);
    transform: scale(1.15);
}

.hemicycle-total {
    font-size: 28px;
    font-weight: 800;
    fill: var(--text-primary);
    font-family: var(--font-sans);
}

.seat-dot {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    transition: transform 0.2s, box-shadow 0.2s;
    cursor: pointer;
}

.seat-dot:hover {
    transform: scale(1.3);
    box-shadow: 0 0 10px currentColor;
}

.seat-dot.bn { background: #4169e1; }
.seat-dot.ph { background: var(--ph-color); }
.seat-dot.pn { background: var(--pn-color); }
.seat-dot.other { background: var(--other-color); }

.seat-legend {
    display: flex;
    justify-content: center;
    gap: var(--spacing-lg);
    margin-top: var(--spacing-md);
    padding-top: var(--spacing-md);
    border-top: var(--border-width) solid var(--border-blue);
}

.legend-item {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
}

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

.legend-color.bn { background: #4169e1; }
.legend-color.ph { background: var(--ph-color); }
.legend-color.pn { background: var(--pn-color); }

.legend-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.legend-value {
    font-size: 0.875rem;
    font-weight: 700;
    color: var(--text-primary);
}

/* ============================================
   PARTY PERFORMANCE CHART - DONUT STYLE
   ============================================ */
.party-performance .module-content {
    padding: var(--spacing-md);
}

.donut-chart-wrapper {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
    height: 100%;
}

.donut-chart-container {
    position: relative;
    width: 160px;
    height: 160px;
    flex-shrink: 0;
}

.donut-chart-container canvas {
    width: 100% !important;
    height: 100% !important;
}

.donut-center-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    pointer-events: none;
}

.donut-total {
    display: block;
    font-size: 16px;
    font-weight: 800;
    color: var(--text-primary);
    line-height: 1.1;
}

.donut-label {
    display: block;
    font-size: 7px;
    font-weight: 600;
    color: var(--text-muted);
    letter-spacing: 0.5px;
    margin-top: 2px;
}

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

.donut-legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 0;
}

.legend-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

.legend-name {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-primary);
    min-width: 50px;
}

.legend-value {
    font-size: 12px;
    font-weight: 700;
    color: var(--text-primary);
    margin-left: auto;
    font-family: var(--font-mono);
}

.legend-pct {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    min-width: 40px;
    text-align: right;
    font-family: var(--font-mono);
}

/* Party Vote Share Responsive */
@media (max-width: 768px) {
    .donut-chart-wrapper {
        flex-direction: column;
        align-items: center;
        gap: var(--spacing-md);
    }
    
    .donut-chart-container {
        width: 140px;
        height: 140px;
    }
    
    .donut-total {
        font-size: 14px;
    }
    
    .donut-label {
        font-size: 6px;
    }
    
    .donut-legend {
        width: 100%;
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: center;
        gap: var(--spacing-sm);
    }
    
    .donut-legend-item {
        flex: 0 0 auto;
        min-width: 45%;
        padding: 6px 8px;
        background: rgba(255, 255, 255, 0.03);
        border-radius: 6px;
    }
    
    .legend-name {
        font-size: 11px;
        min-width: auto;
    }
    
    .legend-value {
        font-size: 11px;
    }
    
    .legend-pct {
        font-size: 10px;
        min-width: 35px;
    }
}

@media (max-width: 480px) {
    .donut-chart-container {
        width: 120px;
        height: 120px;
    }
    
    .donut-total {
        font-size: 12px;
    }
    
    .donut-legend-item {
        min-width: 100%;
        justify-content: space-between;
    }
    
    .legend-name {
        font-size: 10px;
    }
    
    .legend-value {
        font-size: 10px;
    }
    
    .legend-pct {
        font-size: 9px;
    }
}

/* ============================================
   TOP MAJORITIES
   ============================================ */
.majority-bars {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-sm);
}

.majority-item {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
}

.majority-label-wrapper {
    display: flex;
    align-items: center;
    gap: 6px;
    width: 110px;
    flex-shrink: 0;
}

.majority-party-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.majority-party-dot.bn { background: #4169e1; }
.majority-party-dot.ph { background: var(--ph-color); }
.majority-party-dot.pn { background: var(--pn-color); }
.majority-party-dot.other { background: #6b7280; }

.majority-label {
    font-size: 0.625rem;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.majority-bar-container {
    flex: 1;
    height: 14px;
    background: var(--bg-primary);
    border-radius: 2px;
    overflow: hidden;
}

.majority-bar {
    height: 100%;
    border-radius: 2px;
    transition: width 0.5s ease;
}

.majority-bar.bn { background: linear-gradient(90deg, #4169e1, #6495ed); }
.majority-bar.ph { background: linear-gradient(90deg, var(--ph-color), #f87171); }
.majority-bar.pn { background: linear-gradient(90deg, var(--pn-color), #4ade80); }

.majority-value {
    width: 50px;
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-primary);
    text-align: right;
}

.majority-legend {
    display: flex;
    justify-content: center;
    gap: var(--spacing-lg);
    margin-top: var(--spacing-md);
    padding-top: var(--spacing-sm);
    border-top: 1px solid var(--border-blue);
}

.majority-legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.7rem;
    color: var(--text-muted);
    font-weight: 600;
}

.majority-legend-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
}

.majority-legend-dot.bn { background: #4169e1; }
.majority-legend-dot.ph { background: var(--ph-color); }
.majority-legend-dot.pn { background: var(--pn-color); }

/* ============================================
   URBAN VS RURAL
   ============================================ */
.ur-comparison-new {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--spacing-md);
    height: 100%;
}

.ur-card {
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid var(--border-blue);
    border-radius: 10px;
    padding: var(--spacing-md);
    display: flex;
    flex-direction: column;
    align-items: center;
    transition: all 0.2s ease;
}

.ur-card:hover {
    border-color: rgba(59, 130, 246, 0.4);
    background: rgba(15, 23, 42, 0.8);
}

.urban-card {
    border-left: 3px solid #3b82f6;
}

.rural-card {
    border-left: 3px solid #22c55e;
}

.ur-card-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: var(--spacing-sm);
}

.urban-card .ur-card-header {
    color: #60a5fa;
}

.rural-card .ur-card-header {
    color: #4ade80;
}

.ur-card-header svg {
    opacity: 0.8;
}

.ur-card-header span {
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 1.5px;
}

.ur-card-seats {
    font-size: 2.5rem;
    font-weight: 800;
    color: var(--text-primary);
    line-height: 1;
}

.ur-card-label {
    font-size: 0.6rem;
    color: var(--text-muted);
    letter-spacing: 1px;
    margin-bottom: var(--spacing-sm);
}

.ur-stacked-bar {
    width: 100%;
    height: 8px;
    background: rgba(30, 41, 59, 0.8);
    border-radius: 4px;
    overflow: hidden;
    display: flex;
    margin-bottom: var(--spacing-sm);
}

.ur-bar-segment {
    height: 100%;
    transition: width 0.5s ease;
}

.ur-bar-segment.bn { background: #4169e1; }
.ur-bar-segment.ph { background: var(--ph-color); }
.ur-bar-segment.pn { background: var(--pn-color); }

.ur-party-legend {
    display: flex;
    justify-content: center;
    gap: var(--spacing-md);
    width: 100%;
}

.ur-legend-item {
    display: flex;
    align-items: center;
    gap: 4px;
}

.ur-legend-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
}

.ur-legend-dot.bn { background: #4169e1; }
.ur-legend-dot.ph { background: var(--ph-color); }
.ur-legend-dot.pn { background: var(--pn-color); }

.ur-legend-label {
    font-size: 0.65rem;
    font-weight: 600;
    color: var(--text-muted);
}

.ur-legend-value {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--text-primary);
    min-width: 16px;
    text-align: right;
}

/* Urban vs Rural Responsive */
@media (max-width: 768px) {
    .ur-comparison-new {
        grid-template-columns: 1fr;
        gap: var(--spacing-sm);
    }
    
    .ur-card {
        padding: var(--spacing-sm);
    }
    
    .ur-card-seats {
        font-size: 2rem;
    }
    
    .ur-party-legend {
        gap: var(--spacing-sm);
        flex-wrap: wrap;
    }
    
    .ur-legend-label {
        font-size: 0.6rem;
    }
    
    .ur-legend-value {
        font-size: 0.7rem;
    }
}

@media (max-width: 480px) {
    .ur-card {
        padding: var(--spacing-xs);
    }
    
    .ur-card-header span {
        font-size: 0.6rem;
    }
    
    .ur-card-header svg {
        width: 14px;
        height: 14px;
    }
    
    .ur-card-seats {
        font-size: 1.6rem;
    }
    
    .ur-card-label {
        font-size: 0.5rem;
    }
    
    .ur-stacked-bar {
        height: 6px;
    }
    
    .ur-party-legend {
        gap: 6px;
    }
    
    .ur-legend-dot {
        width: 8px;
        height: 8px;
    }
    
    .ur-legend-label {
        font-size: 0.55rem;
    }
    
    .ur-legend-value {
        font-size: 0.65rem;
        min-width: 14px;
    }
}

/* ============================================
   TURNOUT ANALYSIS
   ============================================ */
.turnout-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 4px;
}

.turnout-cell {
    aspect-ratio: 1;
    border-radius: 2px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.5rem;
    font-weight: 600;
    color: var(--text-primary);
    cursor: pointer;
    transition: transform 0.2s;
}

.turnout-cell:hover {
    transform: scale(1.1);
    z-index: 1;
}

.turnout-scale {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--spacing-sm);
    margin-top: var(--spacing-md);
    font-size: 0.625rem;
    color: var(--text-muted);
}

.scale-gradient {
    width: 100px;
    height: 8px;
    background: linear-gradient(90deg, var(--negative), var(--warning), var(--positive));
    border-radius: 4px;
}

/* ============================================
   RESULTS TABLE
   ============================================ */
.table-container {
    max-height: 280px;
    overflow-y: auto;
}

.table-container.full-height {
    max-height: 500px;
}

.table-container::-webkit-scrollbar {
    width: 6px;
}

.table-container::-webkit-scrollbar-track {
    background: var(--bg-primary);
}

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

.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table th,
.data-table td {
    padding: var(--spacing-sm) var(--spacing-md);
    text-align: left;
    border-bottom: var(--border-width) solid var(--border-blue);
}

.data-table th {
    font-size: 0.625rem;
    font-weight: 600;
    color: var(--text-muted);
    letter-spacing: 1px;
    background: var(--bg-secondary);
    position: sticky;
    top: 0;
}

.data-table td {
    font-size: 0.75rem;
    color: var(--text-primary);
}

.data-table tr:hover td {
    background: var(--bg-hover);
}

.party-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 2px;
    font-size: 0.625rem;
    font-weight: 600;
    letter-spacing: 1px;
}

.party-badge.bn { background: rgba(65, 105, 225, 0.2); color: #4169e1; }
.party-badge.ph { background: rgba(220, 38, 38, 0.2); color: var(--ph-color); }
.party-badge.pn { background: rgba(21, 128, 61, 0.2); color: var(--pn-color); }

/* ============================================
   DEMOGRAPHICS
   ============================================ */

/* Demographics Grid Layout */
.demographics-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--spacing-md);
}

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

.voter-demographics,
.age-demographics {
    min-height: 500px;
}

.demographics-chart {
    height: 900px;
}

.demographics-summary {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: var(--spacing-sm);
    margin-top: var(--spacing-md);
    padding-top: var(--spacing-md);
    border-top: var(--border-width) solid var(--border-blue);
}

.demo-stat {
    text-align: center;
}

.demo-label {
    display: block;
    font-size: 0.625rem;
    color: var(--text-muted);
    letter-spacing: 1px;
}

.demo-value {
    display: block;
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-top: 2px;
}

/* Age Distribution Chart */
.age-chart-container {
    height: 400px;
    transition: height 0.3s ease;
}

.age-demographics[data-mode="byDun"] .age-chart-container {
    height: 900px;
}

.age-summary {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--spacing-sm);
    margin-top: var(--spacing-md);
    padding-top: var(--spacing-md);
    border-top: var(--border-width) solid var(--border-blue);
}

.age-stat {
    text-align: center;
    padding: var(--spacing-sm);
    background: var(--bg-secondary);
    border-radius: var(--border-radius);
    border: 1px solid var(--border-blue);
}

.age-label {
    display: block;
    font-size: 0.7rem;
    color: var(--text-muted);
    letter-spacing: 0.5px;
    margin-bottom: var(--spacing-xs);
}

.age-value {
    display: block;
    font-size: 1.25rem;
    font-weight: 700;
    font-family: var(--font-mono);
}

.age-stat:nth-child(1) .age-value {
    color: #22c55e;
}

.age-stat:nth-child(2) .age-value {
    color: #f59e0b;
}

.age-stat:nth-child(3) .age-value {
    color: #ef4444;
}

/* Vote Migration */
.vote-migration .module-content {
    height: 280px;
}

/* ============================================
   PLACEHOLDER CONTENT
   ============================================ */
.placeholder-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 200px;
    color: var(--text-muted);
}

.placeholder-content.large {
    min-height: 400px;
}

.placeholder-icon {
    font-size: 3rem;
    margin-bottom: var(--spacing-md);
    opacity: 0.5;
}

.placeholder-text {
    font-size: 0.875rem;
    letter-spacing: 1px;
}

/* ============================================
   FOOTER
   ============================================ */
.dashboard-footer {
    display: flex;
    justify-content: space-between;
    padding: var(--spacing-md) var(--spacing-lg);
    background: var(--bg-secondary);
    border-top: var(--border-width) solid var(--border-blue);
    font-size: 0.625rem;
    color: var(--text-muted);
    letter-spacing: 1px;
}

.footer-left {
    display: flex;
    gap: var(--spacing-md);
}

.footer-right {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
}

.footer-logo {
    height: 24px;
    width: auto;
    object-fit: contain;
}

.separator {
    color: var(--border-blue);
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 1200px) {
    .dashboard-grid {
        grid-template-columns: repeat(6, 1fr);
    }
    
    .seat-distribution,
    .party-performance,
    .top-majorities,
    .urban-rural,
    .turnout-analysis,
    .results-table,
    .voter-demographics,
    .vote-migration,
    .analysis-card {
        grid-column: span 6;
    }
    
    .results-table,
    .voter-demographics.wide,
    .results-full,
    .map-container,
    .ethnic-analysis,
    .simulation-container {
        grid-column: span 6;
    }
}

@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }
    
    .sidebar.mobile-open {
        transform: translateX(0);
    }
    
    .main-wrapper {
        margin-left: 0;
    }
    
    .mobile-menu-btn {
        display: block;
    }
    
    /* Sticky header on mobile */
    .topbar {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        z-index: 1000;
    }
    
    /* Add padding to page content to account for fixed header */
    .page-content {
        padding-top: calc(var(--topbar-height) + var(--spacing-md));
    }
    
    .topbar-right {
        gap: var(--spacing-sm);
    }
    
    .volatility-index {
        display: none;
    }
    
    .timestamp {
        display: none;
    }
    
    .stats-row {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .dashboard-grid {
        grid-template-columns: 1fr;
    }
    
    .seat-distribution,
    .party-performance,
    .top-majorities,
    .urban-rural,
    .turnout-analysis,
    .results-table,
    .voter-demographics,
    .voter-demographics.wide,
    .vote-migration,
    .results-full,
    .analysis-card,
    .map-container,
    .ethnic-analysis,
    .simulation-container {
        grid-column: span 1;
    }
}

/* ============================================
   ANIMATIONS
   ============================================ */
.module {
    animation: moduleIn 0.4s ease forwards;
    opacity: 0;
}

@keyframes moduleIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.module:nth-child(1) { animation-delay: 0.05s; }
.module:nth-child(2) { animation-delay: 0.1s; }
.module:nth-child(3) { animation-delay: 0.15s; }
.module:nth-child(4) { animation-delay: 0.2s; }
.module:nth-child(5) { animation-delay: 0.25s; }
.module:nth-child(6) { animation-delay: 0.3s; }

/* ============================================
   DUN RESULTS PAGE - Card Layout
   ============================================ */
.results-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: var(--spacing-md);
    margin-bottom: var(--spacing-lg);
    padding: var(--spacing-md);
    background: var(--bg-card);
    border: 1px solid var(--border-blue);
    border-radius: var(--border-radius);
}

.results-summary-cards {
    display: flex;
    gap: var(--spacing-md);
}

.summary-card {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    padding: var(--spacing-sm) var(--spacing-md);
    background: var(--bg-secondary);
    border-radius: var(--border-radius);
    border: 1px solid var(--border-blue);
}

.summary-icon {
    width: 36px;
    height: 36px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
}

.summary-icon.bn-bg { background: rgba(0, 0, 128, 0.3); }
.summary-icon.ph-bg { background: rgba(220, 38, 38, 0.3); }
.summary-icon.pn-bg { background: rgba(21, 128, 61, 0.3); }

.summary-content {
    display: flex;
    flex-direction: column;
}

.summary-label {
    font-size: 11px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.summary-value {
    font-size: 20px;
    font-weight: 700;
    color: var(--text-primary);
}

.results-filter {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
}

.filter-group {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
}

.filter-group label {
    font-size: 12px;
    color: var(--text-secondary);
}

.filter-group select {
    padding: var(--spacing-sm) var(--spacing-md);
    background: var(--bg-secondary);
    border: 1px solid var(--border-blue);
    border-radius: var(--border-radius);
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
}

.filter-group select:focus {
    outline: none;
    border-color: var(--highlight-blue);
}

.search-box {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    padding: var(--spacing-sm) var(--spacing-md);
    background: var(--bg-secondary);
    border: 1px solid var(--border-blue);
    border-radius: var(--border-radius);
}

.search-box svg {
    color: var(--text-muted);
}

.search-box input {
    border: none;
    background: transparent;
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: 13px;
    width: 160px;
}

.search-box input:focus {
    outline: none;
}

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

/* DUN Cards Grid */
.dun-cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(380px, 1fr));
    gap: var(--spacing-lg);
    padding-bottom: var(--spacing-xl);
}

/* Individual DUN Card */
.dun-card {
    background: var(--bg-card);
    border: 1px solid var(--border-blue);
    border-radius: 8px;
    overflow: hidden;
    transition: all 0.3s ease;
    animation: cardIn 0.4s ease forwards;
    opacity: 0;
}

.dun-card:hover {
    border-color: var(--highlight-blue);
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

@keyframes cardIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Card Header */
.dun-card-header {
    padding: var(--spacing-md);
    border-bottom: 1px solid var(--border-blue);
    position: relative;
}

.dun-card-header::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
}

.dun-card.bn .dun-card-header::before { background: var(--bn-color); }
.dun-card.ph .dun-card-header::before { background: var(--ph-color); }
.dun-card.pn .dun-card-header::before { background: var(--pn-color); }

.dun-title-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: var(--spacing-sm);
}

.dun-code {
    font-size: 11px;
    color: var(--text-muted);
    letter-spacing: 1px;
    text-transform: uppercase;
}

.dun-name {
    font-size: 16px;
    font-weight: 700;
    color: var(--text-primary);
    margin-top: 2px;
}

.parliament-info {
    font-size: 11px;
    font-weight: 500;
    color: var(--text-muted);
    margin-top: 2px;
    letter-spacing: 0.3px;
}

.winner-badge {
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.5px;
}

.winner-badge.bn { background: var(--bn-color); color: white; }
.winner-badge.ph { background: var(--ph-color); color: white; }
.winner-badge.pn { background: var(--pn-color); color: white; }

/* Card Stats */
.dun-stats-row {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--spacing-sm);
    margin-top: var(--spacing-md);
}

.dun-stat {
    text-align: center;
    padding: var(--spacing-sm);
    background: var(--bg-secondary);
    border-radius: var(--border-radius);
}

.dun-stat-label {
    font-size: 9px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    display: block;
    margin-bottom: 2px;
}

.dun-stat-value {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
}

.dun-stat-value.highlight {
    color: var(--highlight-blue);
}

/* Candidates Section */
.dun-candidates {
    padding: var(--spacing-md);
}

.candidates-title {
    font-size: 11px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600;
    margin-bottom: var(--spacing-sm);
}

.candidate-item {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
    padding: var(--spacing-sm) 0;
    border-bottom: 1px solid rgba(30, 90, 138, 0.3);
}

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

.candidate-rank {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 700;
    flex-shrink: 0;
}

.candidate-rank.rank-1 {
    background: linear-gradient(135deg, #fbbf24, #f59e0b);
    color: #1a1a1a;
}

.candidate-rank.rank-2 {
    background: linear-gradient(135deg, #9ca3af, #6b7280);
    color: white;
}

.candidate-rank.rank-3 {
    background: linear-gradient(135deg, #d97706, #b45309);
    color: white;
}

.candidate-rank.rank-other {
    background: var(--bg-secondary);
    color: var(--text-muted);
}

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

.candidate-name {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.candidate-party {
    font-size: 11px;
    padding: 2px 6px;
    border-radius: 3px;
    display: inline-block;
    margin-top: 2px;
    font-weight: 600;
}

.candidate-party.bn { background: rgba(0, 0, 128, 0.3); color: #6b8cff; }
.candidate-party.ph { background: rgba(220, 38, 38, 0.3); color: #ff6b6b; }
.candidate-party.pn { background: rgba(21, 128, 61, 0.3); color: #6bff9a; }
.candidate-party.other { background: rgba(107, 114, 128, 0.3); color: #9ca3af; }

.candidate-votes {
    text-align: right;
    flex-shrink: 0;
}

.candidate-vote-count {
    font-size: 14px;
    font-weight: 700;
    color: var(--text-primary);
}

.candidate-vote-pct {
    font-size: 10px;
    color: var(--text-secondary);
}

/* Vote Progress Bar */
.vote-bar-container {
    padding: 0 var(--spacing-md) var(--spacing-md);
}

.vote-bar {
    height: 6px;
    background: var(--bg-secondary);
    border-radius: 3px;
    overflow: hidden;
    display: flex;
}

.vote-bar-segment {
    height: 100%;
    transition: width 0.5s ease;
}

.vote-bar-segment.bn { background: var(--bn-color); }
.vote-bar-segment.ph { background: var(--ph-color); }
.vote-bar-segment.pn { background: var(--pn-color); }
.vote-bar-segment.other { background: var(--other-color); }

/* Loading Placeholder */
.loading-placeholder {
    grid-column: 1 / -1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: var(--spacing-xl);
    color: var(--text-muted);
    gap: var(--spacing-md);
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border-blue);
    border-top-color: var(--highlight-blue);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* Demographic Bar Styles */
.dun-demographic-bar {
    padding: var(--spacing-md);
    border-top: 1px solid rgba(30, 90, 138, 0.3);
    background: rgba(0, 49, 83, 0.3);
}

.demographic-title {
    font-size: 11px;
    color: var(--text-muted);
    text-transform: uppercase;
    font-weight: 600;
    letter-spacing: 1px;
    margin-bottom: var(--spacing-sm);
}

.demographic-segments {
    height: 8px;
    background: var(--bg-secondary);
    border-radius: 4px;
    overflow: hidden;
    display: flex;
    margin-bottom: var(--spacing-sm);
}

.demographic-segment {
    height: 100%;
    transition: width 0.5s ease;
}

.demographic-segment.melayu { background: #22c55e; }
.demographic-segment.cina { background: #ef4444; }
.demographic-segment.india { background: #f59e0b; }
.demographic-segment.lain { background: #8b5cf6; }

.demographic-labels {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: space-between;
}

.demo-label {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-secondary);
}

.demo-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.demo-label.melayu .demo-dot { background: #22c55e; }
.demo-label.cina .demo-dot { background: #ef4444; }
.demo-label.india .demo-dot { background: #f59e0b; }
.demo-label.lain .demo-dot { background: #8b5cf6; }

/* Responsive for DUN Cards */
@media (max-width: 768px) {
    .results-header {
        flex-direction: column;
        align-items: stretch;
    }
    
    .results-summary-cards {
        justify-content: center;
    }
    
    .results-filter {
        flex-direction: column;
        align-items: stretch;
    }
    
    .dun-cards-grid {
        grid-template-columns: 1fr;
    }
    
    .search-box input {
        width: 100%;
    }
}

/* ============================================
   ANALYSIS PAGE STYLES
   ============================================ */

/* Analysis Summary Bar */
.analysis-summary-bar {
    display: flex;
    justify-content: center;
    gap: var(--spacing-md);
    padding: var(--spacing-md);
    background: var(--bg-card);
    border: 1px solid var(--border-blue);
    border-radius: var(--border-radius);
    margin-bottom: var(--spacing-lg);
    flex-wrap: wrap;
}

.analysis-stat-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: var(--spacing-sm) var(--spacing-lg);
    border-right: 1px solid var(--border-blue);
}

.analysis-stat-item:last-child {
    border-right: none;
}

.analysis-stat-item.highlight {
    padding: var(--spacing-sm) var(--spacing-md);
    border-radius: var(--border-radius);
}

.analysis-stat-item.highlight.bn { background: rgba(0, 0, 128, 0.2); }
.analysis-stat-item.highlight.ph { background: rgba(220, 38, 38, 0.2); }
.analysis-stat-item.highlight.pn { background: rgba(21, 128, 61, 0.2); }

.analysis-stat-label {
    font-size: 11px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600;
}

.analysis-stat-value {
    font-size: 24px;
    font-weight: 700;
    color: var(--text-primary);
}

/* Analysis Grid */
.analysis-grid {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-lg);
}

/* Row wrapper for paired cards */
.analysis-row {
    display: flex;
    gap: var(--spacing-lg);
    align-items: stretch;
}

.analysis-row .analysis-card {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.analysis-grid .analysis-card {
    display: flex;
    flex-direction: column;
    overflow: visible;
}

.analysis-grid .analysis-card .module-header {
    flex-shrink: 0;
}

.analysis-grid .analysis-card .module-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    overflow: visible;
}

.analysis-grid .analysis-card.wide {
    width: 100%;
}

/* Analysis Tables */
.analysis-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
}

.analysis-table th {
    background: var(--bg-secondary);
    padding: var(--spacing-sm) var(--spacing-md);
    text-align: left;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    font-size: 10px;
    letter-spacing: 0.5px;
    border-bottom: 1px solid var(--border-blue);
}

.analysis-table td {
    padding: var(--spacing-sm) var(--spacing-md);
    border-bottom: 1px solid rgba(30, 90, 138, 0.2);
    color: var(--text-primary);
}

.analysis-table tbody tr:hover {
    background: rgba(30, 90, 138, 0.1);
}

.analysis-table.compact td,
.analysis-table.compact th {
    padding: var(--spacing-xs) var(--spacing-sm);
}

/* Coalition Badge in Tables */
.coalition-badge {
    display: inline-flex;
    align-items: center;
    gap: var(--spacing-xs);
    padding: 2px 8px;
    border-radius: 4px;
    font-weight: 600;
    font-size: 11px;
}

.coalition-badge.bn { background: rgba(0, 0, 128, 0.3); color: #6b8cff; }
.coalition-badge.ph { background: rgba(220, 38, 38, 0.3); color: #ff6b6b; }
.coalition-badge.pn { background: rgba(21, 128, 61, 0.3); color: #6bff9a; }
.coalition-badge.other { background: rgba(107, 114, 128, 0.3); color: #9ca3af; }

/* Majority Highlight Cards */
.majority-highlight-container,
.age-highlight-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--spacing-md);
    height: 100%;
}

.majority-highlight-card,
.age-highlight-card {
    padding: var(--spacing-md);
    border-radius: var(--border-radius);
    text-align: center;
    background: var(--bg-secondary);
    border: 1px solid var(--border-blue);
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-height: 140px;
}

.majority-highlight-card.highest { border-left: 3px solid #fbbf24; }
.majority-highlight-card.lowest { border-left: 3px solid #ef4444; }
.age-highlight-card.youngest { border-left: 3px solid #22c55e; }
.age-highlight-card.oldest { border-left: 3px solid #8b5cf6; }

.highlight-label,
.age-label {
    font-size: 10px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: var(--spacing-xs);
}

.highlight-dun,
.age-dun {
    font-size: 11px;
    color: var(--highlight-blue);
    font-weight: 600;
    margin-bottom: var(--spacing-xs);
}

.highlight-value {
    font-size: 28px;
    font-weight: 700;
    color: var(--text-primary);
}

.highlight-candidate,
.age-candidate {
    font-size: 11px;
    color: var(--text-secondary);
    margin-top: var(--spacing-xs);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.age-value {
    font-size: 20px;
    font-weight: 700;
    color: var(--text-primary);
    margin-top: var(--spacing-xs);
}

/* Gender Analysis */
.gender-analysis-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--spacing-md);
    height: 100%;
}

.gender-card {
    padding: var(--spacing-lg);
    border-radius: var(--border-radius);
    text-align: center;
    background: var(--bg-secondary);
    border: 1px solid var(--border-blue);
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

.gender-card.male { border-top: 3px solid #3b82f6; }
.gender-card.female { border-top: 3px solid #ec4899; }

.gender-icon {
    font-size: 32px;
    margin-bottom: var(--spacing-sm);
}

.gender-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: var(--spacing-sm);
}

.gender-stats {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-xs);
}

.gender-contested {
    font-size: 28px;
    font-weight: 700;
    color: var(--text-primary);
}

.gender-won {
    font-size: 12px;
    color: var(--highlight-blue);
    font-weight: 600;
}

/* Deposit Summary */
.deposit-summary {
    display: flex;
    justify-content: center;
    margin-bottom: var(--spacing-md);
}

.deposit-total {
    text-align: center;
    padding: var(--spacing-md);
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
    border-radius: var(--border-radius);
}

.deposit-count {
    display: block;
    font-size: 36px;
    font-weight: 700;
    color: #ef4444;
}

.deposit-label {
    font-size: 11px;
    color: var(--text-muted);
    text-transform: uppercase;
}

/* Party Ranking Styles */
.party-ranking-container {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-lg);
}

.party-ranking-card {
    background: var(--bg-secondary);
    border-radius: var(--border-radius);
    padding: var(--spacing-md);
    border-left: 4px solid var(--border-blue);
}

.party-ranking-card.bn { border-left-color: var(--bn-color); }
.party-ranking-card.ph { border-left-color: var(--ph-color); }
.party-ranking-card.pn { border-left-color: var(--pn-color); }

.party-ranking-header {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    margin-bottom: var(--spacing-md);
    padding-bottom: var(--spacing-sm);
    border-bottom: 1px solid var(--border-blue);
}

.party-badge {
    font-size: 12px;
    font-weight: 700;
    padding: 4px 12px;
    border-radius: var(--border-radius);
}

.party-badge.bn { background: var(--bn-color); color: white; }
.party-badge.ph { background: var(--ph-color); color: white; }
.party-badge.pn { background: var(--pn-color); color: white; }

.party-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-secondary);
}

.ranking-grid {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-sm);
    overflow: visible;
}

/* New Party Row Layout */
.party-ranking-row {
    background: var(--bg-card);
    border-radius: var(--border-radius);
    padding: var(--spacing-sm) var(--spacing-md);
    display: flex;
    align-items: flex-start;
    gap: var(--spacing-md);
    overflow: visible;
}

.party-row-header {
    flex-shrink: 0;
    width: 80px;
    padding-top: 4px;
}

.party-label {
    font-size: 12px;
    font-weight: 700;
    padding: 4px 10px;
    border-radius: var(--border-radius);
    display: inline-block;
}

.party-label.bn { background: var(--bn-color); color: white; }
.party-label.ph { background: var(--ph-color); color: white; }
.party-label.pn { background: var(--pn-color); color: white; }

.ranking-columns {
    flex: 1;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--spacing-sm);
    overflow: visible;
}

.ranking-col {
    background: var(--bg-secondary);
    border-radius: var(--border-radius);
    padding: var(--spacing-xs) var(--spacing-sm);
    min-height: 60px;
    overflow: visible;
}

.rank-header-mini {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-bottom: var(--spacing-xs);
    padding-bottom: 4px;
    border-bottom: 1px solid rgba(30, 90, 138, 0.2);
}

.rank-icon {
    font-size: 12px;
}

.rank-num {
    font-size: 11px;
    font-weight: 700;
    color: var(--text-secondary);
}

.rank-total {
    margin-left: auto;
    font-size: 11px;
    font-weight: 700;
    background: var(--bg-hover);
    padding: 2px 6px;
    border-radius: 8px;
    color: var(--highlight-blue);
}

.dun-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    overflow: visible;
}

.dun-chip {
    font-size: 10px;
    font-weight: 600;
    padding: 3px 6px;
    border-radius: 3px;
    background: var(--bg-hover);
    color: var(--text-secondary);
}

.dun-chip.winner {
    background: rgba(251, 191, 36, 0.15);
    color: #fbbf24;
    border: 1px solid rgba(251, 191, 36, 0.3);
}

.dun-chip.second {
    background: rgba(156, 163, 175, 0.15);
    color: #d1d5db;
    border: 1px solid rgba(156, 163, 175, 0.3);
}

.dun-chip.third {
    background: rgba(217, 119, 6, 0.15);
    color: #f59e0b;
    border: 1px solid rgba(217, 119, 6, 0.3);
}

/* DUN Chip Tooltip */
.dun-chip {
    position: relative;
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.dun-chip:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    z-index: 100;
}

.dun-chip::after {
    content: attr(data-name) "\A━━━━━━━━━━━━\APemenang: " attr(data-winner) "\AParti: " attr(data-party) "\A%Undi: " attr(data-votepct) "%\AMajoriti: " attr(data-majority);
    white-space: pre-wrap;
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    color: var(--text-primary);
    padding: 10px 14px;
    border-radius: 8px;
    font-size: 11px;
    font-weight: 500;
    line-height: 1.6;
    min-width: 180px;
    text-align: left;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease, visibility 0.2s ease;
    pointer-events: none;
    z-index: 1000;
    border: 1px solid var(--border-blue);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

.dun-chip::before {
    content: '';
    position: absolute;
    bottom: calc(100% + 2px);
    left: 50%;
    transform: translateX(-50%);
    border: 6px solid transparent;
    border-top-color: #16213e;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease, visibility 0.2s ease;
    pointer-events: none;
    z-index: 1001;
}

.dun-chip:hover::after,
.dun-chip:hover::before {
    opacity: 1;
    visibility: visible;
}

/* Tooltip position adjustment for edge cases */
.ranking-col:last-child .dun-chip::after {
    left: auto;
    right: 0;
    transform: translateX(0);
}

.ranking-col:last-child .dun-chip::before {
    left: auto;
    right: 10px;
    transform: translateX(0);
}

.empty {
    font-size: 10px;
    color: var(--text-muted);
    font-style: italic;
}

/* Legacy styles kept for compatibility */
.ranking-column {
    background: var(--bg-card);
    border-radius: var(--border-radius);
    padding: var(--spacing-sm);
}

.ranking-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--spacing-sm);
    padding-bottom: var(--spacing-xs);
    border-bottom: 1px solid rgba(30, 90, 138, 0.3);
}

.rank-badge {
    font-size: 12px;
    font-weight: 700;
}

.rank-badge.gold { color: #fbbf24; }
.rank-badge.silver { color: #9ca3af; }
.rank-badge.bronze { color: #d97706; }

.rank-count {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    background: var(--bg-secondary);
    padding: 2px 8px;
    border-radius: 10px;
}

.ranking-dun-list {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    max-height: 150px;
    overflow-y: auto;
}

.dun-tag {
    font-size: 10px;
    font-weight: 600;
    padding: 4px 8px;
    border-radius: 4px;
    background: var(--bg-hover);
    color: var(--text-secondary);
    white-space: nowrap;
}

.dun-tag.winner {
    background: rgba(251, 191, 36, 0.2);
    color: #fbbf24;
    border: 1px solid rgba(251, 191, 36, 0.3);
}

.dun-tag.second {
    background: rgba(156, 163, 175, 0.2);
    color: #d1d5db;
    border: 1px solid rgba(156, 163, 175, 0.3);
}

.dun-tag.third {
    background: rgba(217, 119, 6, 0.2);
    color: #fbbf24;
    border: 1px solid rgba(217, 119, 6, 0.3);
}

.no-data {
    font-size: 12px;
    color: var(--text-muted);
    font-style: italic;
}

@media (max-width: 768px) {
    .ranking-grid {
        grid-template-columns: 1fr;
    }
    
    .party-ranking-row {
        flex-direction: column;
        gap: var(--spacing-sm);
    }
    
    .party-row-header {
        width: 100%;
    }
    
    .ranking-columns {
        grid-template-columns: 1fr;
    }
}

/* Corners Chart */
.corners-chart-container {
    height: 250px;
    margin-bottom: var(--spacing-md);
}

.corners-summary {
    display: flex;
    justify-content: center;
    gap: var(--spacing-lg);
    padding-top: var(--spacing-md);
    border-top: 1px solid var(--border-blue);
}

.corner-stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: var(--spacing-sm) var(--spacing-md);
    background: var(--bg-secondary);
    border-radius: var(--border-radius);
    min-width: 80px;
}

.corner-count {
    font-size: 24px;
    font-weight: 700;
    color: var(--highlight-blue);
}

.corner-label {
    font-size: 10px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Winners Table Container */
.winners-table-container {
    max-height: 400px;
    overflow-y: auto;
    position: relative;
}

.winners-table-container::-webkit-scrollbar {
    width: 6px;
}

.winners-table-container::-webkit-scrollbar-track {
    background: var(--bg-secondary);
}

.winners-table-container::-webkit-scrollbar-thumb {
    background: var(--border-blue);
    border-radius: 3px;
}

/* Sticky header for winners table */
.winners-table thead {
    position: sticky;
    top: 0;
    z-index: 10;
}

.winners-table thead th {
    background: var(--bg-secondary);
    box-shadow: 0 1px 0 var(--border-blue);
}

/* Progress Bar for Vote Percentage */
.vote-progress {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
}

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

.vote-progress-fill {
    height: 100%;
    border-radius: 3px;
    transition: width 0.5s ease;
}

.vote-progress-fill.bn { background: var(--bn-color); }
.vote-progress-fill.ph { background: var(--ph-color); }
.vote-progress-fill.pn { background: var(--pn-color); }
.vote-progress-fill.other { background: var(--other-color); }

.vote-progress-value {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-primary);
    min-width: 45px;
    text-align: right;
}

/* Responsive Analysis Page */
@media (max-width: 1200px) {
    .analysis-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: var(--spacing-md);
    }
    
    .analysis-grid .analysis-card {
        min-height: 260px;
    }
}

@media (max-width: 1024px) {
    .analysis-row {
        flex-direction: column;
    }
    
    .analysis-grid .analysis-card {
        min-height: auto;
    }
    
    .corners-chart-container {
        height: 200px;
    }
}

@media (max-width: 768px) {
    .analysis-summary-bar {
        flex-direction: column;
        align-items: center;
    }
    
    .analysis-stat-item {
        border-right: none;
        border-bottom: 1px solid var(--border-blue);
        width: 100%;
        padding: var(--spacing-sm);
    }
    
    .analysis-stat-item:last-child {
        border-bottom: none;
    }
    
    .majority-highlight-container,
    .age-highlight-container,
    .gender-analysis-container {
        grid-template-columns: 1fr;
    }
    
    .majority-highlight-card,
    .age-highlight-card,
    .gender-card {
        min-height: 120px;
    }
    
    .corners-summary {
        flex-wrap: wrap;
        gap: var(--spacing-sm);
    }
    
    .corner-stat {
        min-width: 70px;
    }
    
    .winners-table-container {
        max-height: 300px;
    }
    
    /* Analysis Table Responsive */
    .analysis-table th,
    .analysis-table td {
        padding: var(--spacing-xs) var(--spacing-sm);
        font-size: 11px;
    }
    
    /* Party Ranking Responsive */
    .party-ranking-card {
        padding: var(--spacing-sm);
    }
    
    .party-ranking-header {
        flex-wrap: wrap;
    }
    
    .party-name {
        font-size: 12px;
    }
    
    .dun-chip {
        font-size: 9px;
        padding: 2px 5px;
    }
    
    .rank-total {
        font-size: 10px;
    }
    
    /* Highlight Cards Responsive */
    .highlight-value {
        font-size: 22px;
    }
    
    .highlight-candidate,
    .age-candidate {
        font-size: 10px;
    }
    
    /* Gender Cards Responsive */
    .gender-icon {
        font-size: 24px;
    }
    
    .gender-contested {
        font-size: 22px;
    }
    
    .gender-won {
        font-size: 11px;
    }
    
    /* Deposit Summary */
    .deposit-count {
        font-size: 28px;
    }
}

/* Extra small devices (phones, 480px and down) */
@media (max-width: 480px) {
    /* Analysis Summary Bar - Extra Small */
    .analysis-summary-bar {
        padding: var(--spacing-sm);
        gap: var(--spacing-xs);
    }
    
    .analysis-stat-item {
        padding: var(--spacing-xs);
    }
    
    .analysis-stat-value {
        font-size: 18px;
    }
    
    .analysis-stat-label {
        font-size: 9px;
    }
    
    /* Cards - Extra Small */
    .analysis-card {
        margin-bottom: var(--spacing-sm);
    }
    
    .module-header h2 {
        font-size: 11px;
    }
    
    /* Highlight Cards - Extra Small */
    .majority-highlight-card,
    .age-highlight-card {
        padding: var(--spacing-sm);
        min-height: 100px;
    }
    
    .highlight-label,
    .age-label {
        font-size: 9px;
    }
    
    .highlight-dun,
    .age-dun {
        font-size: 10px;
    }
    
    .highlight-value {
        font-size: 18px;
    }
    
    .age-value {
        font-size: 16px;
    }
    
    .highlight-candidate,
    .age-candidate {
        font-size: 9px;
    }
    
    /* Gender Cards - Extra Small */
    .gender-card {
        padding: var(--spacing-sm);
    }
    
    .gender-icon {
        font-size: 20px;
        margin-bottom: var(--spacing-xs);
    }
    
    .gender-label {
        font-size: 10px;
    }
    
    .gender-contested {
        font-size: 18px;
    }
    
    .gender-won {
        font-size: 10px;
    }
    
    /* Tables - Extra Small */
    .analysis-table {
        font-size: 10px;
    }
    
    .analysis-table th,
    .analysis-table td {
        padding: 4px 6px;
        font-size: 9px;
    }
    
    .analysis-table th {
        font-size: 8px;
    }
    
    /* Coalition Badge - Extra Small */
    .coalition-badge {
        padding: 2px 6px;
        font-size: 9px;
    }
    
    /* Corner Stats - Extra Small */
    .corners-summary {
        gap: var(--spacing-xs);
        justify-content: space-around;
    }
    
    .corner-stat {
        padding: var(--spacing-xs);
        min-width: 60px;
    }
    
    .corner-count {
        font-size: 18px;
    }
    
    .corner-label {
        font-size: 8px;
    }
    
    /* Deposit Summary - Extra Small */
    .deposit-total {
        padding: var(--spacing-sm);
    }
    
    .deposit-count {
        font-size: 24px;
    }
    
    .deposit-label {
        font-size: 10px;
    }
    
    /* Party Ranking - Extra Small */
    .party-ranking-card {
        padding: var(--spacing-xs);
    }
    
    .party-badge {
        font-size: 10px;
        padding: 3px 8px;
    }
    
    .party-name {
        font-size: 11px;
    }
    
    .party-label {
        font-size: 10px;
        padding: 3px 8px;
    }
    
    .rank-header-mini {
        gap: 2px;
    }
    
    .rank-icon {
        font-size: 10px;
    }
    
    .rank-num {
        font-size: 9px;
    }
    
    .rank-total {
        font-size: 9px;
        padding: 1px 4px;
    }
    
    .dun-chip {
        font-size: 8px;
        padding: 2px 4px;
    }
    
    .ranking-col {
        padding: var(--spacing-xs);
        min-height: 50px;
    }
    
    /* Corners Chart - Extra Small */
    .corners-chart-container {
        height: 180px;
    }
}

/* ============================================
   PERFORMANCE PAGE STYLES
   ============================================ */

.performance-header {
    text-align: center;
    margin-bottom: var(--spacing-lg);
    padding: var(--spacing-lg);
    background: linear-gradient(135deg, var(--bg-card), var(--bg-secondary));
    border-radius: var(--border-radius);
    border: 1px solid var(--border-blue);
}

.performance-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: var(--spacing-xs);
    letter-spacing: 1px;
}

.performance-subtitle {
    color: var(--text-muted);
    font-size: 0.9rem;
}

/* Performance Chart */
.performance-chart-container {
    height: 350px;
    position: relative;
}

/* Coalition Performance Grid */
.coalition-perf-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--spacing-md);
}

@media (max-width: 1200px) {
    .coalition-perf-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    .coalition-perf-grid {
        grid-template-columns: 1fr;
    }
}

.coalition-perf-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-blue);
    border-radius: var(--border-radius);
    padding: var(--spacing-md);
    border-left: 4px solid var(--coal-color, var(--border-blue));
    transition: all 0.2s ease;
}

.coalition-perf-card:hover {
    background: var(--bg-hover);
    transform: translateY(-2px);
}

.coal-header {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    margin-bottom: var(--spacing-xs);
}

.coal-icon {
    font-size: 1rem;
    flex-shrink: 0;
}

.coal-name {
    font-family: var(--font-mono);
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-primary);
}

.coal-fullname {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-bottom: var(--spacing-sm);
}

.coal-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--spacing-xs);
    border-top: 1px solid var(--border-blue);
    padding-top: var(--spacing-sm);
}

.coal-stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}

.coal-stat .stat-number {
    font-family: var(--font-mono);
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--coal-color, var(--text-primary));
    line-height: 1;
    margin-bottom: 4px;
}

.coal-stat .stat-label {
    font-size: 0.55rem;
    color: var(--text-muted);
    text-transform: uppercase;
    line-height: 1.2;
    letter-spacing: -0.02em;
}

/* Party Performance Table */
#partyPerformanceTable {
    width: 100%;
}

#partyPerformanceTable th,
#partyPerformanceTable td {
    padding: var(--spacing-sm) var(--spacing-md);
    text-align: center;
}

#partyPerformanceTable th:first-child,
#partyPerformanceTable td:first-child {
    text-align: left;
}

#partyPerformanceTable .party-name {
    font-weight: 600;
}

#partyPerformanceTable .num-cell {
    font-family: var(--font-mono);
    font-size: 0.85rem;
}

#partyPerformanceTable .num-cell.total {
    font-weight: 700;
    color: var(--highlight-blue);
}

#partyPerformanceTable .trend-cell {
    font-size: 1rem;
}

#partyPerformanceTable .trend-cell.positive {
    color: var(--positive);
}

#partyPerformanceTable .trend-cell.negative {
    color: var(--negative);
}

#partyPerformanceTable .trend-cell.neutral {
    color: var(--text-muted);
}

/* Notable Party Row */
#partyPerformanceTable .notable-row {
    background: linear-gradient(90deg, rgba(249, 115, 22, 0.1), transparent);
}

#partyPerformanceTable .party-notable {
    display: inline-block;
    font-size: 0.65rem;
    color: #f97316;
    background: rgba(249, 115, 22, 0.15);
    padding: 2px 6px;
    border-radius: 3px;
    margin-left: 6px;
    font-family: var(--font-mono);
    cursor: help;
    border: 1px solid rgba(249, 115, 22, 0.3);
}

#partyPerformanceTable .cell-ph {
    background: rgba(239, 68, 68, 0.15);
    color: #ef4444;
    font-weight: 600;
}

#partyPerformanceTable .cell-pn {
    background: rgba(14, 165, 233, 0.15);
    color: #0ea5e9;
    font-weight: 600;
}

/* Coalition Timeline */
.timeline-container {
    padding: var(--spacing-md);
}

.timeline {
    position: relative;
    padding-left: var(--spacing-xl);
}

.timeline::before {
    content: '';
    position: absolute;
    left: 8px;
    top: 0;
    bottom: 0;
    width: 2px;
    background: linear-gradient(to bottom, var(--border-blue), var(--highlight-blue), var(--border-blue));
}

.timeline-item {
    position: relative;
    margin-bottom: var(--spacing-lg);
    padding-bottom: var(--spacing-lg);
    border-bottom: 1px dashed rgba(139, 156, 184, 0.2);
}

.timeline-item:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

.timeline-marker {
    position: absolute;
    left: -24px;
    top: 0;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--bg-card);
    border: 3px solid var(--border-blue);
}

.timeline-marker.bn {
    border-color: #0052a5;
    background: rgba(0, 82, 165, 0.3);
}

.timeline-marker.ph {
    border-color: #ef4444;
    background: rgba(239, 68, 68, 0.3);
}

.timeline-item.highlight .timeline-marker {
    width: 22px;
    height: 22px;
    left: -26px;
    animation: pulse 2s infinite;
}

.timeline-item.highlight .timeline-content {
    background: linear-gradient(135deg, rgba(239, 68, 68, 0.1), transparent);
    padding: var(--spacing-md);
    border-radius: var(--border-radius);
    border: 1px solid rgba(239, 68, 68, 0.3);
}

.timeline-period {
    font-family: var(--font-mono);
    font-size: 0.9rem;
    color: var(--highlight-blue);
    font-weight: 600;
    margin-bottom: var(--spacing-xs);
}

.timeline-title {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: var(--spacing-xs);
}

.timeline-desc {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: var(--spacing-sm);
    line-height: 1.5;
}

.timeline-stats {
    display: flex;
    gap: var(--spacing-md);
}

.timeline-stat {
    font-family: var(--font-mono);
    font-size: 0.8rem;
    padding: var(--spacing-xs) var(--spacing-sm);
    border-radius: var(--border-radius);
    background: rgba(0, 82, 165, 0.2);
}

.timeline-stat.bn {
    color: #0052a5;
    border: 1px solid rgba(0, 82, 165, 0.4);
}

.timeline-stat.ph {
    color: #ef4444;
    background: rgba(239, 68, 68, 0.2);
    border: 1px solid rgba(239, 68, 68, 0.4);
}

.timeline-stat.opp {
    color: var(--text-muted);
    background: rgba(107, 114, 128, 0.2);
    border: 1px solid rgba(107, 114, 128, 0.4);
}

/* Key Insights Grid */
.insights-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: var(--spacing-md);
}

.insight-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-blue);
    border-radius: var(--border-radius);
    padding: var(--spacing-md);
    display: flex;
    align-items: flex-start;
    gap: var(--spacing-md);
    border-left: 3px solid var(--insight-color, var(--highlight-blue));
    transition: all 0.2s ease;
}

.insight-card:hover {
    background: var(--bg-hover);
    transform: translateX(4px);
}

.insight-icon {
    font-size: 1.5rem;
    flex-shrink: 0;
}

.insight-content {
    flex: 1;
}

.insight-title {
    font-size: 0.7rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: var(--spacing-xs);
}

.insight-value {
    font-family: var(--font-mono);
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--insight-color, var(--text-primary));
    margin-bottom: var(--spacing-xs);
}

.insight-detail {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.insight-card.highlight-card {
    background: rgba(239, 68, 68, 0.1);
    border-color: #ef4444;
    animation: pulse-highlight 2s ease-in-out infinite;
}

@keyframes pulse-highlight {
    0%, 100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4); }
    50% { box-shadow: 0 0 0 8px rgba(239, 68, 68, 0); }
}

/* PRU15 Highlight Section */
.pru15-highlight-grid {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-lg);
}

.pru15-context {
    background: linear-gradient(135deg, rgba(14, 165, 233, 0.1) 0%, rgba(239, 68, 68, 0.1) 100%);
    border: 1px solid var(--border-blue);
    border-radius: var(--border-radius);
    padding: var(--spacing-md);
}

.pru15-context h3 {
    color: var(--text-primary);
    margin-bottom: var(--spacing-sm);
    font-size: 1rem;
}

.pru15-context p {
    color: var(--text-secondary);
    font-size: 0.85rem;
    margin-bottom: var(--spacing-xs);
}

.pru15-context .warning-note {
    background: rgba(251, 191, 36, 0.15);
    border-left: 3px solid #fbbf24;
    padding: var(--spacing-sm);
    border-radius: 0 var(--border-radius) var(--border-radius) 0;
    color: #fbbf24;
    font-size: 0.8rem;
    margin-top: var(--spacing-sm);
}

.pru15-comparison-cards {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--spacing-md);
}

.pru15-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-blue);
    border-radius: var(--border-radius);
    padding: var(--spacing-md);
    text-align: center;
}

.pru15-card.bn-fall {
    border-color: #ef4444;
    background: linear-gradient(180deg, rgba(239, 68, 68, 0.15) 0%, var(--bg-secondary) 100%);
}

.pru15-card.pn-rise {
    border-color: #22c55e;
    background: linear-gradient(180deg, rgba(34, 197, 94, 0.15) 0%, var(--bg-secondary) 100%);
}

.pru15-card.ph-recover {
    border-color: #ef4444;
    background: linear-gradient(180deg, rgba(239, 68, 68, 0.1) 0%, var(--bg-secondary) 100%);
}

.pru15-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--spacing-sm);
}

.status-badge {
    font-size: 0.7rem;
    padding: 2px 8px;
    border-radius: 12px;
}

.status-badge.fall {
    background: rgba(239, 68, 68, 0.2);
    color: #ef4444;
}

.status-badge.rise {
    background: rgba(34, 197, 94, 0.2);
    color: #22c55e;
}

.pru15-card-numbers {
    margin: var(--spacing-md) 0;
}

.number-comparison {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--spacing-sm);
}

.old-number {
    font-family: var(--font-mono);
    font-size: 1.5rem;
    color: var(--text-muted);
    text-decoration: line-through;
}

.arrow {
    font-size: 1.2rem;
    color: var(--text-muted);
}

.new-number {
    font-family: var(--font-mono);
    font-size: 2rem;
    font-weight: 700;
}

.new-number.fall {
    color: #ef4444;
}

.new-number.rise {
    color: #22c55e;
}

.change-indicator {
    font-family: var(--font-mono);
    font-size: 0.9rem;
    font-weight: 600;
    margin-top: var(--spacing-xs);
}

.change-indicator.negative {
    color: #ef4444;
}

.change-indicator.positive {
    color: #22c55e;
}

.pru15-card-detail {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.pru15-analysis {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-sm);
}

.analysis-item {
    display: flex;
    align-items: flex-start;
    gap: var(--spacing-sm);
    background: var(--bg-secondary);
    border: 1px solid var(--border-blue);
    border-radius: var(--border-radius);
    padding: var(--spacing-sm);
}

.analysis-icon {
    font-size: 1.2rem;
    flex-shrink: 0;
}

.analysis-text {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.analysis-text strong {
    color: var(--text-primary);
}

/* Timeline PRU15 specific */
.timeline-item.pru15-item {
    border-left-color: #22c55e;
}

.timeline-item.pru15-item .timeline-desc {
    color: #fbbf24;
    font-weight: 500;
}

.timeline-stats.three-way {
    display: flex;
    gap: var(--spacing-sm);
    flex-wrap: wrap;
}

.timeline-stat.bn-fall {
    background: rgba(239, 68, 68, 0.2) !important;
    color: #ef4444 !important;
    animation: blink-fall 1s ease-in-out infinite;
}

@keyframes blink-fall {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

/* Table PRU15 column */
.pru15-col {
    background: rgba(34, 197, 94, 0.1);
    border-left: 2px solid #22c55e;
}

.pru15-cell {
    background: rgba(34, 197, 94, 0.05);
}

.coalition-mini {
    display: inline-block;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
}

.coalition-mini.bn {
    background: rgba(0, 82, 165, 0.2);
    color: #0052a5;
}

.coalition-mini.ph {
    background: rgba(239, 68, 68, 0.2);
    color: #ef4444;
}

.coalition-mini.pn {
    background: rgba(34, 197, 94, 0.2);
    color: #22c55e;
}

/* Coal stat PRU15 */
.coal-stat.pru15-stat {
    border-top: 1px dashed var(--border-blue);
    padding-top: var(--spacing-xs);
    margin-top: var(--spacing-xs);
}

.coal-stat.pru15-stat .stat-label {
    color: #22c55e;
}

@media (max-width: 768px) {
    .pru15-comparison-cards {
        grid-template-columns: 1fr;
    }
}

/* Module Width Classes */
.module.full-width {
    grid-column: 1 / -1;
}

.module.double-width {
    grid-column: span 2;
}

/* Dashboard Grid Variants */
.dashboard-grid.triple-col {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--spacing-md);
}

/* Coalition badge variants */
.coalition-badge.pr {
    background: rgba(34, 197, 94, 0.2);
    color: #22c55e;
}

.coalition-badge.ba {
    background: rgba(34, 197, 94, 0.2);
    color: #22c55e;
}

/* Control Select */
.control-select {
    background: var(--bg-secondary);
    border: 1px solid var(--border-blue);
    color: var(--text-primary);
    padding: var(--spacing-xs) var(--spacing-sm);
    border-radius: var(--border-radius);
    font-family: var(--font-sans);
    font-size: 0.8rem;
    cursor: pointer;
}

.control-select:hover {
    border-color: var(--highlight-blue);
}

.control-select:focus {
    outline: none;
    border-color: var(--highlight-blue);
}

@keyframes pulse {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4);
    }
    50% {
        box-shadow: 0 0 0 8px rgba(239, 68, 68, 0);
    }
}

/* Performance Page Responsive */
@media (max-width: 1200px) {
    .dashboard-grid.triple-col {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .module.double-width {
        grid-column: span 2;
    }
}

@media (max-width: 768px) {
    .dashboard-grid.triple-col {
        grid-template-columns: 1fr;
    }
    
    .module.double-width,
    .module.full-width {
        grid-column: 1;
    }
    
    .performance-chart-container {
        height: 250px;
    }
    
    .coalition-perf-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .insights-grid {
        grid-template-columns: 1fr;
    }
    
    .timeline-stats {
        flex-direction: column;
        gap: var(--spacing-xs);
    }
    
    /* Party Performance Table Responsive */
    .module.party-table .table-wrapper {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    #partyPerformanceTable {
        min-width: 700px;
    }
    
    #partyPerformanceTable th,
    #partyPerformanceTable td {
        padding: var(--spacing-xs) var(--spacing-sm);
        font-size: 0.7rem;
        white-space: nowrap;
    }
    
    #partyPerformanceTable .party-name {
        font-size: 0.7rem;
    }
    
    #partyPerformanceTable .num-cell {
        font-size: 0.7rem;
    }
    
    #partyPerformanceTable .trend-cell {
        font-size: 0.85rem;
    }
    
    #partyPerformanceTable .party-notable {
        font-size: 0.55rem;
        padding: 1px 4px;
        margin-left: 4px;
    }
}

@media (max-width: 480px) {
    #partyPerformanceTable {
        min-width: 600px;
    }
    
    #partyPerformanceTable th,
    #partyPerformanceTable td {
        padding: 4px 6px;
        font-size: 0.65rem;
    }
    
    #partyPerformanceTable .party-name {
        font-size: 0.65rem;
    }
    
    #partyPerformanceTable .num-cell {
        font-size: 0.65rem;
    }
}

/* ============================================
   FORTRESS VS SWING SEATS PAGE STYLES
   ============================================ */

.fortress-header {
    text-align: center;
    margin-bottom: var(--spacing-lg);
    padding: var(--spacing-lg);
    background: linear-gradient(135deg, var(--bg-card), var(--bg-secondary));
    border-radius: var(--border-radius);
    border: 1px solid var(--border-blue);
}

.fortress-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: var(--spacing-xs);
    letter-spacing: 1px;
}

.fortress-subtitle {
    color: var(--text-muted);
    font-size: 0.9rem;
}

/* Fortress Layout */
.dashboard-grid.fortress-layout {
    display: grid;
    grid-template-columns: 2fr 1fr;
    grid-template-rows: auto auto auto;
    gap: var(--spacing-md);
}

.fortress-map-module {
    grid-row: span 2;
}

.fortress-stats {
    grid-column: 2;
}

.fortress-list {
    grid-column: 2;
}

/* Swing List Full Width */
.swing-list-full {
    grid-column: 1 / -1;
}

.swing-list-full .module-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: var(--spacing-sm);
}

.swing-legend {
    display: flex;
    gap: var(--spacing-md);
    font-size: 0.75rem;
}

.swing-seats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: var(--spacing-sm);
}

/* Swing Card Styles */
.swing-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-blue);
    border-radius: var(--border-radius);
    padding: var(--spacing-sm);
    transition: all 0.2s ease;
}

.swing-card.swing {
    border-left: 3px solid #ef4444;
}

.swing-card.competitive {
    border-left: 3px solid #eab308;
}

.swing-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.swing-card-header {
    display: flex;
    align-items: center;
    gap: var(--spacing-xs);
    margin-bottom: var(--spacing-xs);
    flex-wrap: wrap;
}

.swing-code {
    font-family: var(--font-mono);
    font-weight: 700;
    color: var(--accent-blue);
    font-size: 0.8rem;
}

.swing-name {
    color: var(--text-secondary);
    font-size: 0.75rem;
    flex: 1;
}

.swing-badge {
    font-size: 0.6rem;
    padding: 2px 6px;
    border-radius: 3px;
    font-weight: 600;
}

.swing-badge.swing {
    background: rgba(239, 68, 68, 0.2);
    color: #ef4444;
}

.swing-badge.competitive {
    background: rgba(234, 179, 8, 0.2);
    color: #eab308;
}

.swing-card-parties {
    display: flex;
    flex-wrap: wrap;
    gap: 3px;
    margin-bottom: var(--spacing-xs);
}

.swing-party {
    font-size: 0.55rem;
    padding: 1px 4px;
    border-radius: 2px;
    font-family: var(--font-mono);
}

.swing-party.bn {
    background: rgba(0, 82, 165, 0.2);
    color: #4d9fff;
}

.swing-party.ph {
    background: rgba(239, 68, 68, 0.2);
    color: #ff8080;
}

.swing-party.pn {
    background: rgba(14, 165, 233, 0.2);
    color: #5dd3ff;
}

.swing-party.other {
    background: rgba(107, 114, 128, 0.2);
    color: #9ca3af;
}

.swing-card-coalitions {
    font-size: 0.65rem;
    color: var(--text-muted);
}

@media (max-width: 1400px) {
    .swing-seats-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 1000px) {
    .swing-seats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

.fortress-table-module {
    grid-column: 1 / -1;
}

/* Map Container */
.fortress-map-container {
    position: relative;
    width: 100%;
    height: 500px;
    background: var(--bg-secondary);
    border-radius: var(--border-radius);
    overflow: hidden;
}

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

.fortress-polygon {
    cursor: pointer;
    transition: all 0.2s ease;
}

.fortress-polygon:hover {
    filter: brightness(1.2);
}

.map-label {
    font-family: var(--font-mono);
    font-size: 10px;
    fill: var(--bg-primary);
    font-weight: 700;
    pointer-events: none;
    text-shadow: 0 0 3px rgba(255,255,255,0.5);
}

/* Map Legend Inline */
.map-legend-inline {
    display: flex;
    gap: var(--spacing-md);
    font-size: 0.75rem;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: var(--spacing-xs);
    color: var(--text-secondary);
}

.legend-color {
    width: 14px;
    height: 14px;
    border-radius: 3px;
}

.legend-color.fortress {
    background: #22c55e;
}

.legend-color.competitive {
    background: #eab308;
}

.legend-color.swing {
    background: #ef4444;
}

/* Map Tooltip */
.map-tooltip {
    display: none;
    position: absolute;
    background: rgba(0, 24, 41, 0.95);
    border: 1px solid var(--border-blue);
    border-radius: var(--border-radius);
    padding: var(--spacing-sm) var(--spacing-md);
    pointer-events: none;
    z-index: 100;
    min-width: 180px;
}

.tooltip-title {
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: var(--spacing-xs);
}

.tooltip-category {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    padding: 2px 8px;
    border-radius: 3px;
    display: inline-block;
    margin-bottom: var(--spacing-xs);
}

.tooltip-category.fortress {
    background: rgba(34, 197, 94, 0.2);
    color: #22c55e;
}

.tooltip-category.competitive {
    background: rgba(234, 179, 8, 0.2);
    color: #eab308;
}

.tooltip-category.swing {
    background: rgba(239, 68, 68, 0.2);
    color: #ef4444;
}

.tooltip-detail {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* Fortress Stats Grid */
.fortress-stats-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: var(--spacing-sm);
}

.fortress-stat-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-blue);
    border-radius: var(--border-radius);
    padding: var(--spacing-md);
    text-align: center;
}

.fortress-stat-card.fortress {
    border-left: 3px solid #22c55e;
}

.fortress-stat-card.competitive {
    border-left: 3px solid #eab308;
}

.fortress-stat-card.swing {
    border-left: 3px solid #ef4444;
}

.fortress-stat-card.dominant {
    border-left: 3px solid #0052a5;
}

.fortress-stat-card .stat-icon {
    font-size: 1.5rem;
    margin-bottom: var(--spacing-xs);
}

.fortress-stat-card .stat-value {
    font-family: var(--font-mono);
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
}

.fortress-stat-card .stat-label {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-bottom: var(--spacing-xs);
}

.fortress-stat-card .stat-detail {
    font-size: 0.7rem;
    color: var(--text-muted);
}

/* Seats List */
.seats-list {
    max-height: 300px;
    overflow-y: auto;
}

.party-fortress-group {
    margin-bottom: var(--spacing-md);
}

.party-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--spacing-xs);
}

.party-badge {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    padding: 2px 8px;
    border-radius: 3px;
    font-weight: 600;
}

.party-badge.bn {
    background: rgba(0, 82, 165, 0.2);
    color: #0052a5;
}

.party-badge.ph {
    background: rgba(239, 68, 68, 0.2);
    color: #ef4444;
}

.party-badge.pn {
    background: rgba(14, 165, 233, 0.2);
    color: #0ea5e9;
}

.party-count {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.seats-chips {
    display: flex;
    flex-wrap: wrap;
    gap: var(--spacing-xs);
}

/* Fortress Cards Grid */
.fortress-cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: var(--spacing-xs);
}

.fortress-card {
    display: flex;
    align-items: center;
    gap: var(--spacing-xs);
    padding: 4px 8px;
    background: rgba(34, 197, 94, 0.15);
    border: 1px solid rgba(34, 197, 94, 0.3);
    border-radius: 4px;
    min-width: 0;
}

.fortress-code {
    font-family: var(--font-mono);
    font-size: 0.7rem;
    font-weight: 700;
    color: #22c55e;
    flex-shrink: 0;
}

.fortress-name {
    font-size: 0.65rem;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.seat-chip {
    font-family: var(--font-mono);
    font-size: 0.7rem;
    padding: 3px 8px;
    border-radius: 3px;
    background: var(--bg-hover);
    color: var(--text-secondary);
    cursor: default;
}

.seat-chip.fortress {
    background: rgba(34, 197, 94, 0.15);
    color: #22c55e;
    border: 1px solid rgba(34, 197, 94, 0.3);
}

/* Swing Seat Items */
.swing-seat-item {
    background: var(--bg-secondary);
    border: 1px solid var(--border-blue);
    border-radius: var(--border-radius);
    padding: var(--spacing-sm);
    margin-bottom: var(--spacing-sm);
}

.swing-seat-item.swing {
    border-left: 3px solid #ef4444;
}

.swing-seat-item.competitive {
    border-left: 3px solid #eab308;
}

.swing-seat-header {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    margin-bottom: var(--spacing-xs);
}

.seat-code {
    font-family: var(--font-mono);
    font-weight: 700;
    color: var(--text-primary);
}

.seat-name {
    color: var(--text-secondary);
    font-size: 0.85rem;
}

.category-badge {
    margin-left: auto;
    font-size: 0.65rem;
    padding: 2px 6px;
    border-radius: 3px;
}

.category-badge.swing {
    background: rgba(239, 68, 68, 0.2);
    color: #ef4444;
}

.category-badge.competitive {
    background: rgba(234, 179, 8, 0.2);
    color: #eab308;
}

.swing-parties {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-bottom: var(--spacing-xs);
}

.mini-badge {
    font-size: 0.6rem;
    padding: 1px 5px;
    border-radius: 2px;
    font-family: var(--font-mono);
}

.mini-badge.bn {
    background: rgba(0, 82, 165, 0.2);
    color: #0052a5;
}

.mini-badge.ph {
    background: rgba(239, 68, 68, 0.2);
    color: #ef4444;
}

.mini-badge.pn {
    background: rgba(14, 165, 233, 0.2);
    color: #0ea5e9;
}

.mini-badge.other {
    background: rgba(107, 114, 128, 0.2);
    color: #9ca3af;
}

.swing-coalitions {
    font-size: 0.7rem;
    color: var(--text-muted);
}

/* Fortress Table */
#fortressTable .parl-cell {
    white-space: nowrap;
}

#fortressTable .parl-code {
    font-family: var(--font-mono);
    font-weight: 600;
    color: var(--accent-blue);
    font-size: 0.75rem;
}

#fortressTable .parl-name {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

#fortressTable .code-cell {
    font-family: var(--font-mono);
    font-weight: 600;
}

#fortressTable .name-cell {
    font-size: 0.85rem;
}

#fortressTable .party-cell {
    display: inline-block;
    font-size: 0.7rem;
    padding: 2px 6px;
    border-radius: 3px;
    font-family: var(--font-mono);
}

#fortressTable .party-cell.bn {
    background: rgba(0, 82, 165, 0.3);
    color: #4d9fff;
}

#fortressTable .party-cell.ph {
    background: rgba(239, 68, 68, 0.3);
    color: #ff8080;
}

#fortressTable .party-cell.pn {
    background: rgba(14, 165, 233, 0.3);
    color: #5dd3ff;
}

#fortressTable .party-cell.other {
    background: rgba(107, 114, 128, 0.3);
    color: #c9cdd4;
}

.cat-badge {
    font-size: 0.65rem;
    padding: 2px 6px;
    border-radius: 3px;
    white-space: nowrap;
}

.cat-badge.fortress {
    background: rgba(34, 197, 94, 0.2);
    color: #22c55e;
}

.cat-badge.competitive {
    background: rgba(234, 179, 8, 0.2);
    color: #eab308;
}

.cat-badge.swing {
    background: rgba(239, 68, 68, 0.2);
    color: #ef4444;
}

.dominant-badge {
    font-size: 0.7rem;
    padding: 2px 6px;
    border-radius: 3px;
    font-family: var(--font-mono);
}

.dominant-badge.bn {
    background: rgba(0, 82, 165, 0.2);
    color: #4d9fff;
}

.dominant-badge.ph {
    background: rgba(239, 68, 68, 0.2);
    color: #ff8080;
}

.dominant-badge.pn {
    background: rgba(14, 165, 233, 0.2);
    color: #5dd3ff;
}

.fortress-row {
    background: rgba(34, 197, 94, 0.05);
}

.competitive-row {
    background: rgba(234, 179, 8, 0.05);
}

.swing-row {
    background: rgba(239, 68, 68, 0.05);
}

/* Download Button */
.btn-download {
    display: flex;
    align-items: center;
    gap: var(--spacing-xs);
    background: var(--bg-secondary);
    border: 1px solid var(--border-blue);
    color: var(--text-secondary);
    padding: var(--spacing-xs) var(--spacing-sm);
    border-radius: var(--border-radius);
    font-family: var(--font-sans);
    font-size: 0.75rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-download:hover {
    background: var(--bg-hover);
    border-color: var(--highlight-blue);
    color: var(--text-primary);
}

.btn-download:active {
    transform: scale(0.98);
}

.btn-download.success {
    background: rgba(34, 197, 94, 0.2);
    border-color: #22c55e;
    color: #22c55e;
}

.btn-download svg {
    flex-shrink: 0;
}

/* Fortress Page Responsive */
@media (max-width: 1200px) {
    .dashboard-grid.fortress-layout {
        grid-template-columns: 1fr 1fr;
    }
    
    .fortress-map-module {
        grid-column: 1 / -1;
        grid-row: auto;
    }
    
    .swing-seats-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 1000px) {
    .swing-seats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    .dashboard-grid.fortress-layout {
        grid-template-columns: 1fr;
        display: flex;
        flex-direction: column;
    }
    
    /* Reset all grid positioning for mobile */
    .fortress-map-module {
        grid-column: auto;
        grid-row: auto;
        order: 1;
    }
    
    .fortress-stats {
        grid-column: auto;
        order: 2;
    }
    
    .fortress-list {
        grid-column: auto;
        order: 3;
    }
    
    .swing-list-full {
        order: 4;
    }
    
    .dominance-grid-module {
        order: 5;
    }
    
    .fortress-table-module {
        order: 6;
    }
    
    .fortress-header {
        padding: var(--spacing-md);
    }
    
    .fortress-title {
        font-size: 1.1rem;
    }
    
    .fortress-subtitle {
        font-size: 0.75rem;
    }
    
    .fortress-map-container {
        height: 300px;
    }
    
    .fortress-stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: var(--spacing-xs);
    }
    
    .fortress-stat-card {
        padding: var(--spacing-sm);
    }
    
    .fortress-stat-card .stat-value {
        font-size: 1.2rem;
    }
    
    .fortress-stat-card .stat-label {
        font-size: 0.7rem;
    }
    
    .fortress-stat-card .stat-detail {
        font-size: 0.6rem;
    }
    
    .fortress-stat-card .stat-icon {
        font-size: 1.2rem;
    }
    
    .map-legend-inline {
        flex-wrap: wrap;
        gap: var(--spacing-xs);
        font-size: 0.65rem;
    }
    
    .legend-color {
        width: 10px;
        height: 10px;
    }
    
    .swing-legend {
        gap: var(--spacing-sm);
        font-size: 0.65rem;
    }
    
    .swing-seats-grid {
        grid-template-columns: 1fr;
    }
    
    .swing-card {
        padding: var(--spacing-xs);
    }
    
    .swing-code {
        font-size: 0.7rem;
    }
    
    .swing-name {
        font-size: 0.65rem;
    }
    
    .swing-badge {
        font-size: 0.55rem;
        padding: 1px 4px;
    }
    
    .swing-party {
        font-size: 0.5rem;
        padding: 1px 3px;
    }
    
    .swing-card-coalitions {
        font-size: 0.6rem;
    }
    
    /* Dominance Grid Mobile */
    .dominance-legend {
        gap: var(--spacing-xs);
        font-size: 0.65rem;
    }
    
    .dominance-legend .legend-dot {
        width: 10px;
        height: 10px;
    }
    
    .dominance-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: var(--spacing-sm);
        padding: var(--spacing-sm);
    }
    
    .dominance-card {
        padding: var(--spacing-sm);
    }
    
    .dominance-card .dun-code {
        font-size: 0.85rem;
    }
    
    .dominance-card .dun-name {
        font-size: 0.65rem;
    }
    
    .dominance-card .dominance-percent {
        font-size: 0.6rem;
        padding: 1px 4px;
    }
    
    .dominant-party-badge {
        padding: 3px 8px;
        font-size: 0.6rem;
    }
    
    .dominance-card .win-count {
        font-size: 0.6rem;
    }
    
    .history-bar {
        gap: 2px;
    }
    
    .history-dot {
        width: 12px;
        height: 12px;
    }
    
    /* Fortress Table Mobile */
    .fortress-table-module .table-wrapper {
        overflow-x: auto;
    }
    
    #fortressTable {
        min-width: 700px;
    }
    
    #fortressTable th,
    #fortressTable td {
        padding: var(--spacing-xs);
        font-size: 0.65rem;
    }
    
    #fortressTable .parl-code,
    #fortressTable .parl-name {
        font-size: 0.6rem;
    }
    
    #fortressTable .code-cell {
        font-size: 0.65rem;
    }
    
    #fortressTable .party-cell {
        font-size: 0.55rem;
        padding: 1px 4px;
    }
    
    .cat-badge,
    .dominant-badge {
        font-size: 0.55rem;
        padding: 1px 4px;
    }
    
    /* Fortress List Mobile */
    .seats-list {
        max-height: 250px;
    }
    
    .party-badge {
        font-size: 0.65rem;
        padding: 2px 6px;
    }
    
    .party-count {
        font-size: 0.65rem;
    }
    
    .seat-chip {
        font-size: 0.6rem;
        padding: 2px 6px;
    }
    
    .fortress-cards-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .fortress-card {
        padding: 3px 6px;
    }
    
    .fortress-code {
        font-size: 0.6rem;
    }
    
    .fortress-name {
        font-size: 0.55rem;
    }
}

@media (max-width: 480px) {
    .fortress-header {
        padding: var(--spacing-sm);
    }
    
    .fortress-title {
        font-size: 0.95rem;
    }
    
    .fortress-subtitle {
        font-size: 0.65rem;
    }
    
    .fortress-map-container {
        height: 250px;
    }
    
    .fortress-stats-grid {
        grid-template-columns: 1fr 1fr;
    }
    
    .fortress-stat-card .stat-value {
        font-size: 1rem;
    }
    
    .fortress-stat-card .stat-label {
        font-size: 0.6rem;
    }
    
    .map-legend-inline {
        font-size: 0.55rem;
    }
    
    .legend-color {
        width: 8px;
        height: 8px;
    }
    
    .swing-card-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 2px;
    }
    
    .dominance-grid {
        grid-template-columns: 1fr 1fr;
        gap: var(--spacing-xs);
    }
    
    .dominance-card .dun-code {
        font-size: 0.75rem;
    }
    
    .dominance-card .dun-name {
        font-size: 0.55rem;
    }
    
    .history-dot {
        width: 10px;
        height: 10px;
    }
    
    #fortressTable {
        min-width: 600px;
    }
    
    .fortress-cards-grid {
        grid-template-columns: 1fr 1fr;
    }
}

/* =================================
   Party Dominance Grid Styles
   ================================= */

.dominance-grid-module {
    margin-top: var(--spacing-lg);
}

.dominance-grid-module .module-header {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: var(--spacing-md);
}

.dominance-legend {
    display: flex;
    flex-wrap: wrap;
    gap: var(--spacing-md);
    font-size: 0.75rem;
}

.dominance-legend .legend-item {
    display: flex;
    align-items: center;
    gap: 4px;
    color: var(--text-secondary);
}

.dominance-legend .legend-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    transition: transform 0.2s, box-shadow 0.2s;
}

.dominance-legend .legend-dot:hover {
    transform: scale(1.2);
}

.dominance-legend .legend-dot.active {
    transform: scale(1.3);
    box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.3);
}

.dominance-legend .legend-dot.umno { background: #1e40af; }
.dominance-legend .legend-dot.dap { background: #dc2626; }
.dominance-legend .legend-dot.mca { background: #2563eb; }
.dominance-legend .legend-dot.mic { background: #a855f7; }
.dominance-legend .legend-dot.pkr { background: #0891b2; }
.dominance-legend .legend-dot.amanah { background: #f97316; }
.dominance-legend .legend-dot.bersatu { background: #991b1b; }

.dominance-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: var(--spacing-md);
    padding: var(--spacing-md);
}

.dominance-card {
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    padding: var(--spacing-md);
    border: 2px solid transparent;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.dominance-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
}

.dominance-card.umno::before { background: #1e40af; }
.dominance-card.dap::before { background: #dc2626; }
.dominance-card.mca::before { background: #2563eb; }
.dominance-card.mic::before { background: #a855f7; }
.dominance-card.pkr::before { background: #0891b2; }
.dominance-card.amanah::before { background: #f97316; }
.dominance-card.bersatu::before { background: #991b1b; }
.dominance-card.other::before { background: #6b7280; }

.dominance-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.3);
}

.dominance-card.dimmed {
    opacity: 0.3;
    transform: scale(0.95);
}

.dominance-card.highlighted {
    border-color: var(--accent);
    box-shadow: 0 0 20px rgba(99, 102, 241, 0.4);
}

.dominance-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--spacing-xs);
}

.dominance-card .dun-code {
    font-weight: 700;
    font-size: 1rem;
    color: var(--text-primary);
}

.dominance-card .dominance-percent {
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--accent);
    background: rgba(99, 102, 241, 0.15);
    padding: 2px 6px;
    border-radius: var(--radius-sm);
}

.dominance-card .dun-name {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-bottom: var(--spacing-sm);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.dominant-party-badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: var(--radius-md);
    font-size: 0.7rem;
    font-weight: 700;
    color: white;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: var(--spacing-xs);
}

.dominance-card .win-count {
    font-size: 0.7rem;
    color: var(--text-secondary);
    margin-bottom: var(--spacing-sm);
}

.history-bar {
    display: flex;
    gap: 4px;
    justify-content: flex-start;
}

.history-dot {
    width: 16px;
    height: 16px;
    border-radius: 3px;
    transition: transform 0.2s;
}

.history-dot:hover {
    transform: scale(1.2);
}

.history-dot.empty {
    background: var(--border-color);
    opacity: 0.3;
}

/* Responsive for dominance grid */
@media (max-width: 768px) {
    .dominance-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: var(--spacing-sm);
    }
    
    .dominance-card {
        padding: var(--spacing-sm);
    }
    
    .dominance-legend {
        justify-content: center;
    }
}

@media (max-width: 480px) {
    .dominance-grid {
        grid-template-columns: 1fr 1fr;
    }
    
    .dominance-card .dun-name {
        font-size: 0.65rem;
    }
}

/* ===================================
   HEAD-TO-HEAD PAGE STYLES
   =================================== */

.head-to-head-layout {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-lg);
}

/* H2H Chart */
.head-to-head-chart .module-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: var(--spacing-sm);
}

.h2h-legend {
    display: flex;
    gap: var(--spacing-lg);
    font-size: 0.8rem;
}

.legend-line {
    display: inline-block;
    width: 24px;
    height: 3px;
    border-radius: 2px;
    margin-right: var(--spacing-xs);
    vertical-align: middle;
}

.legend-line.bn {
    background: linear-gradient(90deg, #1e40af, #3b82f6);
}

.legend-line.opposition {
    background: linear-gradient(90deg, #dc2626, #f97316);
}

.h2h-chart-container {
    height: 350px;
    position: relative;
}

.h2h-insights {
    margin-top: var(--spacing-md);
    padding: var(--spacing-md);
    background: var(--bg-secondary);
    border-radius: var(--border-radius);
    border-left: 3px solid var(--accent-blue);
}

.h2h-insights .insight-title {
    font-weight: 600;
    color: var(--accent-blue);
    margin-bottom: var(--spacing-xs);
    font-size: 0.85rem;
}

.h2h-insights .insight-text {
    font-size: 0.8rem;
    color: var(--text-secondary);
    line-height: 1.6;
}

.h2h-insights .crossover-highlight {
    display: inline-block;
    background: rgba(239, 68, 68, 0.2);
    color: #ef4444;
    padding: 2px 8px;
    border-radius: 4px;
    font-weight: 600;
    margin: 0 4px;
}

/* H2H Summary Cards */
.h2h-summary-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: var(--spacing-md);
}

.h2h-election-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-blue);
    border-radius: var(--border-radius);
    padding: var(--spacing-md);
    text-align: center;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.h2h-election-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
}

.h2h-election-card.bn-win::before {
    background: linear-gradient(90deg, #1e40af, #3b82f6);
}

.h2h-election-card.opposition-win::before {
    background: linear-gradient(90deg, #dc2626, #f97316);
}

.h2h-election-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.3);
}

.h2h-election-card .election-year {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: var(--spacing-xs);
}

.h2h-election-card .election-type {
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-bottom: var(--spacing-sm);
}

.h2h-election-card .seats-bar {
    display: flex;
    height: 24px;
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: var(--spacing-xs);
}

.h2h-election-card .bn-bar {
    background: linear-gradient(180deg, #3b82f6, #1e40af);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    font-weight: 600;
    color: white;
    transition: width 0.5s ease;
}

.h2h-election-card .opp-bar {
    background: linear-gradient(180deg, #f97316, #dc2626);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    font-weight: 600;
    color: white;
    transition: width 0.5s ease;
}

.h2h-election-card .winner-label {
    font-size: 0.75rem;
    font-weight: 600;
    padding: 4px 12px;
    border-radius: 12px;
    display: inline-block;
}

.h2h-election-card .winner-label.bn {
    background: rgba(59, 130, 246, 0.2);
    color: #3b82f6;
}

.h2h-election-card .winner-label.ph,
.h2h-election-card .winner-label.opposition {
    background: rgba(239, 68, 68, 0.2);
    color: #ef4444;
}

/* Margin Trends */
.margin-chart-container {
    height: 300px;
    position: relative;
}

.margin-insights {
    margin-top: var(--spacing-md);
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: var(--spacing-md);
}

.margin-insight-card {
    background: var(--bg-secondary);
    border-radius: var(--border-radius);
    padding: var(--spacing-md);
    border-left: 3px solid var(--accent-cyan);
}

.margin-insight-card .insight-label {
    font-size: 0.7rem;
    color: var(--text-muted);
    text-transform: uppercase;
    margin-bottom: var(--spacing-xs);
}

.margin-insight-card .insight-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
}

.margin-insight-card .insight-trend {
    font-size: 0.75rem;
    margin-top: var(--spacing-xs);
}

.margin-insight-card .insight-trend.up {
    color: #22c55e;
}

.margin-insight-card .insight-trend.down {
    color: #ef4444;
}

.trend-subtitle {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* Competitiveness Grid */
.competitiveness-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: var(--spacing-md);
}

.competitiveness-legend {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--spacing-md);
    margin-top: var(--spacing-lg);
    padding: var(--spacing-md);
    background: var(--bg-secondary);
    border-radius: var(--border-radius);
    font-size: 0.75rem;
}

.competitiveness-legend .legend-title {
    font-weight: 600;
    color: var(--text-secondary);
}

.competitiveness-legend .legend-item {
    display: flex;
    align-items: center;
    gap: var(--spacing-xs);
    color: var(--text-muted);
}

.competitiveness-legend .legend-dot {
    width: 12px;
    height: 12px;
    border-radius: 3px;
}

.competitiveness-legend .legend-dot.safe {
    background: linear-gradient(135deg, #22c55e, #16a34a);
}

.competitiveness-legend .legend-dot.moderate {
    background: linear-gradient(135deg, #eab308, #ca8a04);
}

.competitiveness-legend .legend-dot.marginal {
    background: linear-gradient(135deg, #f97316, #ea580c);
}

.competitiveness-legend .legend-dot.razor {
    background: linear-gradient(135deg, #ef4444, #dc2626);
}

.competitiveness-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-blue);
    border-radius: var(--border-radius);
    padding: var(--spacing-md);
}

.competitiveness-card .card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--spacing-sm);
}

.competitiveness-card .card-title {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 0.9rem;
}

.competitiveness-card .card-year {
    font-family: var(--font-mono);
    font-size: 0.8rem;
    color: var(--accent-blue);
}

.competitiveness-card .margin-categories {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-xs);
}

.margin-category {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
}

.margin-category .cat-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    width: 100px;
    flex-shrink: 0;
}

.margin-category .cat-bar {
    flex: 1;
    height: 16px;
    background: var(--bg-hover);
    border-radius: 3px;
    overflow: hidden;
}

.margin-category .cat-fill {
    height: 100%;
    border-radius: 3px;
    transition: width 0.5s ease;
}

.margin-category .cat-fill.safe {
    background: linear-gradient(90deg, #22c55e, #16a34a);
}

.margin-category .cat-fill.moderate {
    background: linear-gradient(90deg, #eab308, #ca8a04);
}

.margin-category .cat-fill.marginal {
    background: linear-gradient(90deg, #f97316, #ea580c);
}

.margin-category .cat-fill.razor {
    background: linear-gradient(90deg, #ef4444, #dc2626);
}

.margin-category .cat-count {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: var(--text-muted);
    width: 30px;
    text-align: right;
}

/* New Entrants Analysis */
.new-entrants-module .module-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: var(--spacing-sm);
}

.entrants-subtitle {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.new-entrants-summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: var(--spacing-md);
    margin-bottom: var(--spacing-lg);
}

.entrant-stat-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-blue);
    border-radius: var(--border-radius);
    padding: var(--spacing-md);
    text-align: center;
}

.entrant-stat-card .stat-icon {
    font-size: 1.5rem;
    margin-bottom: var(--spacing-xs);
}

.entrant-stat-card .stat-value {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--text-primary);
}

.entrant-stat-card .stat-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: var(--spacing-xs);
}

.new-entrants-timeline {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-md);
}

.entrant-year-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-blue);
    border-radius: var(--border-radius);
    overflow: hidden;
}

.entrant-year-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--spacing-sm) var(--spacing-md);
    background: var(--bg-hover);
    border-bottom: 1px solid var(--border-blue);
}

.entrant-year {
    font-weight: 700;
    color: var(--accent-blue);
    font-size: 1rem;
}

.entrant-election-name {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.entrant-count-badge {
    font-family: var(--font-mono);
    font-size: 0.7rem;
    padding: 3px 10px;
    border-radius: 12px;
    background: rgba(59, 130, 246, 0.2);
    color: var(--accent-blue);
}

.entrant-parties-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: var(--spacing-sm);
    padding: var(--spacing-md);
}

.entrant-party-card {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    padding: var(--spacing-sm);
    background: var(--bg-primary);
    border-radius: var(--border-radius);
    border-left: 3px solid var(--accent-cyan);
}

.entrant-party-card.success {
    border-left-color: #22c55e;
}

.entrant-party-card.failed {
    border-left-color: #ef4444;
}

.entrant-party-icon {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    flex-shrink: 0;
}

.entrant-party-icon.bn {
    background: rgba(30, 64, 175, 0.2);
}

.entrant-party-icon.ph {
    background: rgba(239, 68, 68, 0.2);
}

.entrant-party-icon.pn {
    background: rgba(14, 165, 233, 0.2);
}

.entrant-party-icon.other {
    background: rgba(107, 114, 128, 0.2);
}

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

.entrant-party-name {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 0.85rem;
}

.entrant-party-full {
    font-size: 0.7rem;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.entrant-party-stats {
    text-align: right;
}

.entrant-seats-won {
    font-family: var(--font-mono);
    font-size: 0.85rem;
    font-weight: 600;
}

.entrant-seats-won.success {
    color: #22c55e;
}

.entrant-seats-won.failed {
    color: #ef4444;
}

.entrant-success-rate {
    font-size: 0.65rem;
    color: var(--text-muted);
}

.no-new-entrants {
    padding: var(--spacing-md);
    text-align: center;
    color: var(--text-muted);
    font-size: 0.85rem;
}

/* ===================================
   BATTLEGROUND PAGE STYLES
   =================================== */

.battleground-layout {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-lg);
}

/* Coalition Tabs */
.coalition-tabs {
    display: flex;
    gap: var(--spacing-xs);
}

.coalition-tab {
    padding: 8px 20px;
    border: 1px solid var(--border-blue);
    background: var(--bg-secondary);
    color: var(--text-secondary);
    border-radius: 20px;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 600;
    transition: all 0.3s ease;
}

.coalition-tab:hover {
    background: var(--bg-hover);
}

.coalition-tab.active {
    background: var(--accent-blue);
    color: white;
    border-color: var(--accent-blue);
}

.coalition-tab[data-coalition="BN"].active {
    background: linear-gradient(135deg, #1e40af, #3b82f6);
}

.coalition-tab[data-coalition="PH"].active {
    background: linear-gradient(135deg, #dc2626, #ef4444);
}

.coalition-tab[data-coalition="PN"].active {
    background: linear-gradient(135deg, #0891b2, #06b6d4);
}

/* Battleground Description */
.battleground-description {
    padding: var(--spacing-md);
    background: var(--bg-secondary);
    border-radius: var(--border-radius);
    border-left: 3px solid var(--accent-blue);
}

.battleground-description p {
    color: var(--text-secondary);
    font-size: 0.85rem;
    margin-bottom: var(--spacing-sm);
}

.factor-pills {
    display: flex;
    flex-wrap: wrap;
    gap: var(--spacing-sm);
}

.factor-pill {
    padding: 6px 12px;
    border-radius: 16px;
    font-size: 0.75rem;
    font-weight: 500;
}

.factor-pill.margin {
    background: rgba(239, 68, 68, 0.15);
    color: #ef4444;
}

.factor-pill.swing {
    background: rgba(234, 179, 8, 0.15);
    color: #eab308;
}

.factor-pill.demographic {
    background: rgba(34, 197, 94, 0.15);
    color: #22c55e;
}

.factor-pill.turnout {
    background: rgba(59, 130, 246, 0.15);
    color: #3b82f6;
}

/* Battleground Summary */
.battleground-summary-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: var(--spacing-md);
}

.battleground-stat-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-blue);
    border-radius: var(--border-radius);
    padding: var(--spacing-md);
    text-align: center;
    position: relative;
    overflow: hidden;
}

.battleground-stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
}

.battleground-stat-card.tier1::before { background: linear-gradient(90deg, #22c55e, #16a34a); }
.battleground-stat-card.tier2::before { background: linear-gradient(90deg, #3b82f6, #2563eb); }
.battleground-stat-card.tier3::before { background: linear-gradient(90deg, #eab308, #ca8a04); }
.battleground-stat-card.tier4::before { background: linear-gradient(90deg, #6b7280, #4b5563); }
.battleground-stat-card.offensive::before { background: linear-gradient(90deg, #ef4444, #dc2626); }
.battleground-stat-card.defensive::before { background: linear-gradient(90deg, #8b5cf6, #7c3aed); }

.battleground-stat-card .stat-icon {
    font-size: 1.5rem;
    margin-bottom: var(--spacing-xs);
}

.battleground-stat-card .stat-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--text-primary);
}

.battleground-stat-card .stat-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: var(--spacing-xs);
}

/* Battleground Note */
.battleground-note {
    grid-column: 1 / -1;
    background: rgba(234, 179, 8, 0.15);
    border: 1px solid rgba(234, 179, 8, 0.3);
    border-radius: var(--border-radius);
    padding: var(--spacing-sm) var(--spacing-md);
    text-align: center;
    color: var(--text-secondary);
}

/* Priority Tiers Container */
.priority-tiers-container {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: var(--spacing-md);
}

@media (max-width: 1200px) {
    .priority-tiers-container {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    .priority-tiers-container {
        grid-template-columns: 1fr;
    }
}

.priority-tier {
    background: var(--bg-secondary);
    border: 1px solid var(--border-blue);
    border-radius: var(--border-radius);
    overflow: hidden;
}

.priority-tier-header {
    padding: var(--spacing-sm) var(--spacing-md);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.priority-tier.tier1 .priority-tier-header { background: rgba(34, 197, 94, 0.15); }
.priority-tier.tier2 .priority-tier-header { background: rgba(59, 130, 246, 0.15); }
.priority-tier.tier3 .priority-tier-header { background: rgba(234, 179, 8, 0.15); }
.priority-tier.tier4 .priority-tier-header { background: rgba(107, 114, 128, 0.15); }

.priority-tier-title {
    font-weight: 700;
    font-size: 0.9rem;
}

.priority-tier.tier1 .priority-tier-title { color: #22c55e; }
.priority-tier.tier2 .priority-tier-title { color: #3b82f6; }
.priority-tier.tier3 .priority-tier-title { color: #eab308; }
.priority-tier.tier4 .priority-tier-title { color: #6b7280; }

.priority-tier-count {
    font-family: var(--font-mono);
    font-size: 0.8rem;
    padding: 2px 8px;
    border-radius: 10px;
    background: var(--bg-primary);
    color: var(--text-secondary);
}

.priority-tier-list {
    padding: var(--spacing-sm);
    max-height: 300px;
    overflow-y: auto;
}

.priority-dun-item {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    padding: var(--spacing-xs) var(--spacing-sm);
    margin-bottom: var(--spacing-xs);
    background: var(--bg-primary);
    border-radius: 4px;
    font-size: 0.8rem;
}

.priority-dun-item:last-child {
    margin-bottom: 0;
}

.priority-dun-code {
    font-family: var(--font-mono);
    font-weight: 600;
    color: var(--accent-blue);
    min-width: 40px;
}

.priority-dun-name {
    flex: 1;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.priority-dun-score {
    font-family: var(--font-mono);
    font-weight: 600;
    font-size: 0.75rem;
    padding: 2px 6px;
    border-radius: 4px;
}

.priority-tier.tier1 .priority-dun-score { background: rgba(34, 197, 94, 0.2); color: #22c55e; }
.priority-tier.tier2 .priority-dun-score { background: rgba(59, 130, 246, 0.2); color: #3b82f6; }
.priority-tier.tier3 .priority-dun-score { background: rgba(234, 179, 8, 0.2); color: #eab308; }
.priority-tier.tier4 .priority-dun-score { background: rgba(107, 114, 128, 0.2); color: #9ca3af; }

/* Battleground Table */
#battlegroundTable .dun-code {
    font-family: var(--font-mono);
    font-weight: 600;
    color: var(--accent-blue);
    font-size: inherit;
    margin-right: 6px;
}

#battlegroundTable .dun-name {
    color: var(--text-secondary);
    font-size: inherit;
}

#battlegroundTable .tier-badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 0.7rem;
    font-weight: 600;
}

#battlegroundTable .tier-badge.tier1 {
    background: rgba(34, 197, 94, 0.2);
    color: #22c55e;
}

#battlegroundTable .tier-badge.tier2 {
    background: rgba(59, 130, 246, 0.2);
    color: #3b82f6;
}

#battlegroundTable .tier-badge.tier3 {
    background: rgba(234, 179, 8, 0.2);
    color: #eab308;
}

#battlegroundTable .tier-badge.tier4 {
    background: rgba(107, 114, 128, 0.2);
    color: #9ca3af;
}

#battlegroundTable .score-bar {
    display: flex;
    align-items: center;
    gap: var(--spacing-xs);
}

#battlegroundTable .score-bar-fill {
    height: 8px;
    border-radius: 4px;
    min-width: 20px;
}

#battlegroundTable .score-bar-fill.margin { background: linear-gradient(90deg, #ef4444, #f97316); }
#battlegroundTable .score-bar-fill.swing { background: linear-gradient(90deg, #eab308, #fbbf24); }
#battlegroundTable .score-bar-fill.demo { background: linear-gradient(90deg, #22c55e, #4ade80); }

#battlegroundTable .score-value {
    font-family: var(--font-mono);
    font-size: 0.7rem;
    color: var(--text-muted);
    min-width: 25px;
}

/* Battleground Legend */
.battleground-legend {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--spacing-md);
    margin-top: var(--spacing-lg);
    padding: var(--spacing-md);
    background: var(--bg-secondary);
    border-radius: var(--border-radius);
    font-size: 0.75rem;
}

.battleground-legend .legend-title {
    font-weight: 600;
    color: var(--text-secondary);
}

.battleground-legend .legend-item {
    display: flex;
    align-items: center;
    gap: var(--spacing-xs);
    color: var(--text-muted);
}

.battleground-legend .legend-dot {
    width: 12px;
    height: 12px;
    border-radius: 3px;
}

.battleground-legend .legend-dot.tier1 { background: linear-gradient(135deg, #22c55e, #16a34a); }
.battleground-legend .legend-dot.tier2 { background: linear-gradient(135deg, #3b82f6, #2563eb); }
.battleground-legend .legend-dot.tier3 { background: linear-gradient(135deg, #eab308, #ca8a04); }
.battleground-legend .legend-dot.tier4 { background: linear-gradient(135deg, #6b7280, #4b5563); }

/* Battleground Page Responsive */
@media (max-width: 768px) {
    .battleground-layout {
        gap: var(--spacing-md);
    }
    
    /* Module Header Responsive */
    .battleground-selector .module-header {
        flex-direction: column;
        align-items: flex-start;
        gap: var(--spacing-sm);
    }
    
    .battleground-selector .module-header h2 {
        font-size: 0.9rem;
    }
    
    /* Coalition Tabs */
    .coalition-tabs {
        width: 100%;
        justify-content: center;
    }
    
    .coalition-tab {
        padding: 6px 14px;
        font-size: 0.75rem;
    }
    
    /* Description */
    .battleground-description {
        padding: var(--spacing-sm);
    }
    
    .battleground-description p {
        font-size: 0.75rem;
    }
    
    .factor-pills {
        gap: var(--spacing-xs);
    }
    
    .factor-pill {
        padding: 4px 8px;
        font-size: 0.65rem;
    }
    
    /* Summary Grid */
    .battleground-summary-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: var(--spacing-sm);
    }
    
    .battleground-stat-card {
        padding: var(--spacing-sm);
    }
    
    .battleground-stat-card .stat-icon {
        font-size: 1.2rem;
    }
    
    .battleground-stat-card .stat-value {
        font-size: 1.5rem;
    }
    
    .battleground-stat-card .stat-label {
        font-size: 0.65rem;
    }
    
    /* Priority Tiers */
    .priority-tier-header {
        padding: var(--spacing-xs) var(--spacing-sm);
    }
    
    .priority-tier-title {
        font-size: 0.75rem;
    }
    
    .priority-tier-count {
        font-size: 0.7rem;
        padding: 1px 6px;
    }
    
    .priority-tier-list {
        padding: var(--spacing-xs);
        max-height: 200px;
    }
    
    .priority-dun-item {
        padding: var(--spacing-xs);
        font-size: 0.7rem;
        gap: var(--spacing-xs);
    }
    
    .priority-dun-code {
        min-width: 35px;
        font-size: 0.7rem;
    }
    
    .priority-dun-name {
        font-size: 0.65rem;
    }
    
    .priority-dun-score {
        font-size: 0.65rem;
        padding: 1px 4px;
    }
    
    /* Battleground Table */
    .battleground-table-module .table-wrapper {
        overflow-x: auto;
    }
    
    #battlegroundTable {
        min-width: 600px;
    }
    
    #battlegroundTable th,
    #battlegroundTable td {
        padding: var(--spacing-xs);
        font-size: 0.65rem;
    }
    
    #battlegroundTable .tier-badge {
        padding: 2px 6px;
        font-size: 0.6rem;
    }
    
    #battlegroundTable .score-bar-fill {
        height: 6px;
    }
    
    #battlegroundTable .score-value {
        font-size: 0.6rem;
        min-width: 20px;
    }
    
    /* Legend */
    .battleground-legend {
        gap: var(--spacing-sm);
        padding: var(--spacing-sm);
        font-size: 0.65rem;
        margin-top: var(--spacing-md);
    }
    
    .battleground-legend .legend-dot {
        width: 10px;
        height: 10px;
    }
    
    .battleground-legend .legend-item {
        font-size: 0.6rem;
    }
}

@media (max-width: 480px) {
    .battleground-selector .module-header h2 {
        font-size: 0.8rem;
    }
    
    .coalition-tabs {
        gap: 4px;
    }
    
    .coalition-tab {
        padding: 5px 10px;
        font-size: 0.7rem;
        border-radius: 14px;
    }
    
    .factor-pill {
        padding: 3px 6px;
        font-size: 0.6rem;
    }
    
    .battleground-summary-grid {
        grid-template-columns: 1fr 1fr;
    }
    
    .battleground-stat-card .stat-value {
        font-size: 1.2rem;
    }
    
    .battleground-stat-card .stat-label {
        font-size: 0.6rem;
    }
    
    .priority-tier-title {
        font-size: 0.7rem;
    }
    
    .priority-dun-item {
        flex-wrap: wrap;
    }
    
    .priority-dun-name {
        width: 100%;
        order: 3;
        margin-top: 2px;
    }
    
    #battlegroundTable {
        min-width: 550px;
    }
    
    .battleground-legend {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .battleground-legend .legend-item {
        font-size: 0.55rem;
    }
}

/* =========================================
   PRN vs PRU15 COMPARISON PAGE
   ========================================= */

.comparison-layout {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--spacing-lg);
}

.comparison-layout .full-width {
    grid-column: 1 / -1;
}

/* Comparison Summary Cards */
.comparison-intro {
    margin-bottom: var(--spacing-md);
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.comparison-summary-cards {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--spacing-md);
}

@media (max-width: 992px) {
    .comparison-layout {
        grid-template-columns: 1fr;
    }
    
    .comparison-summary-cards {
        grid-template-columns: 1fr;
    }
}

.comparison-coalition-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-blue);
    border-radius: var(--border-radius);
    padding: var(--spacing-lg);
    border-top: 4px solid var(--coal-color, var(--border-blue));
}

.comparison-coalition-card .coal-name {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--coal-color);
    margin-bottom: var(--spacing-xs);
}

.comparison-coalition-card .coal-fullname {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-bottom: var(--spacing-md);
}

.comparison-stats-row {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    gap: var(--spacing-sm);
    margin-bottom: var(--spacing-sm);
}

.comparison-stats-row .stat-box {
    text-align: center;
    padding: var(--spacing-sm);
    background: var(--bg-tertiary);
    border-radius: var(--border-radius);
}

.comparison-stats-row .stat-box .stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    font-family: var(--font-mono);
}

.comparison-stats-row .stat-box .stat-label {
    font-size: 0.65rem;
    color: var(--text-muted);
    text-transform: uppercase;
}

.comparison-stats-row .stat-arrow {
    font-size: 1.5rem;
    color: var(--text-muted);
}

.comparison-change {
    text-align: center;
    padding: var(--spacing-sm);
    border-radius: var(--border-radius);
    font-weight: 700;
    font-family: var(--font-mono);
    font-size: 1.1rem;
}

.comparison-change.positive {
    background: rgba(34, 197, 94, 0.15);
    color: var(--positive);
}

.comparison-change.negative {
    background: rgba(239, 68, 68, 0.15);
    color: var(--negative);
}

.comparison-change.neutral {
    background: rgba(107, 114, 128, 0.15);
    color: var(--text-muted);
}

/* Dual Map Container */
.dual-map-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--spacing-lg);
}

@media (max-width: 992px) {
    .dual-map-container {
        grid-template-columns: 1fr;
    }
}

.map-panel {
    background: var(--bg-secondary);
    border: 1px solid var(--border-blue);
    border-radius: var(--border-radius);
    overflow: hidden;
}

.map-title {
    padding: var(--spacing-sm) var(--spacing-md);
    background: var(--bg-tertiary);
    font-weight: 700;
    font-size: 0.9rem;
    text-align: center;
    border-bottom: 1px solid var(--border-blue);
}

.comparison-map {
    height: 400px;
    width: 100%;
}

.comparison-map-wrapper {
    background: var(--bg-tertiary);
    border-radius: var(--border-radius);
    padding: var(--spacing-sm);
    display: flex;
    justify-content: center;
    align-items: center;
}

.comparison-map-svg {
    width: 100%;
    height: 400px;
    background: linear-gradient(145deg, rgba(10, 15, 30, 0.9), rgba(5, 10, 20, 0.95));
    border-radius: var(--border-radius);
}

.comparison-map-svg .map-polygon {
    cursor: pointer;
    transition: fill-opacity 0.2s ease, stroke-width 0.2s ease;
}

.comparison-map-svg .map-polygon:hover {
    fill-opacity: 1;
    stroke-width: 2;
}

/* Map Zoom Controls */
.map-zoom-controls {
    display: flex;
    gap: 4px;
}

.zoom-btn {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-blue);
    border-radius: 4px;
    padding: 6px 8px;
    cursor: pointer;
    color: var(--text-light);
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.zoom-btn:hover {
    background: var(--accent-blue);
    color: white;
}

.zoom-btn svg {
    width: 14px;
    height: 14px;
}

.map-hint {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-left: var(--spacing-md);
}

.comparison-map-wrapper {
    overflow: hidden;
    cursor: grab;
    position: relative;
}

.comparison-map-wrapper:active {
    cursor: grabbing;
}

.comparison-map-wrapper.zoomed {
    cursor: move;
}

#comparisonMapTooltip {
    position: absolute;
    display: none;
    background: rgba(10, 15, 30, 0.95);
    border: 1px solid var(--border-blue);
    border-radius: var(--border-radius);
    padding: var(--spacing-sm) var(--spacing-md);
    font-size: 0.85rem;
    z-index: 1000;
    pointer-events: none;
    min-width: 180px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.5);
}

#comparisonMapTooltip .tooltip-title {
    font-weight: 700;
    color: var(--text-white);
    margin-bottom: 4px;
}

#comparisonMapTooltip .tooltip-election {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-bottom: 6px;
}

#comparisonMapTooltip .tooltip-coalition {
    color: var(--text-light);
}

#comparisonMapTooltip .tooltip-coalition strong {
    color: var(--accent-blue);
}

.map-legend-container {
    margin-top: var(--spacing-md);
    display: flex;
    justify-content: center;
}

.coalition-legend {
    display: flex;
    gap: var(--spacing-lg);
    padding: var(--spacing-sm) var(--spacing-lg);
    background: var(--bg-secondary);
    border-radius: var(--border-radius);
}

.coalition-legend .legend-item {
    display: flex;
    align-items: center;
    gap: var(--spacing-xs);
    font-size: 0.85rem;
}

.coalition-legend .legend-dot {
    width: 16px;
    height: 16px;
    border-radius: 4px;
}

.coalition-legend .legend-dot.bn { background: #0052a5; }
.coalition-legend .legend-dot.ph { background: #ef4444; }
.coalition-legend .legend-dot.pn { background: #0ea5e9; }

/* Sankey Diagram */
.sankey-container {
    height: 280px;
    position: relative;
    padding: var(--spacing-sm);
    overflow: hidden;
}

.sankey-svg {
    width: 100%;
    height: 100%;
    display: block;
}

.sankey-legend {
    padding: var(--spacing-md);
    background: var(--bg-tertiary);
    border-radius: var(--border-radius);
    margin-top: var(--spacing-md);
}

.sankey-legend-content {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: var(--spacing-xl);
    flex-wrap: wrap;
}

.sankey-legend .legend-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--spacing-xs);
}

.sankey-legend .legend-title {
    font-weight: 700;
    font-size: 0.9rem;
    color: var(--text-white);
    margin-bottom: 4px;
}

.sankey-legend .legend-items {
    display: flex;
    gap: var(--spacing-md);
}

.sankey-legend .legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.85rem;
}

.sankey-legend .legend-color {
    width: 14px;
    height: 14px;
    border-radius: 3px;
}

.sankey-legend .legend-arrow {
    font-size: 1.5rem;
    color: var(--text-muted);
    padding: 0 var(--spacing-md);
}

.sankey-summary {
    display: flex;
    justify-content: center;
    gap: var(--spacing-lg);
    margin-top: var(--spacing-md);
    padding-top: var(--spacing-md);
    border-top: 1px solid var(--border-blue);
}

.sankey-summary .summary-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.9rem;
    padding: var(--spacing-xs) var(--spacing-md);
    border-radius: var(--border-radius);
}

.sankey-summary .summary-item.flip {
    background: rgba(239, 68, 68, 0.15);
    color: #f87171;
}

.sankey-summary .summary-item.retain {
    background: rgba(34, 197, 94, 0.15);
    color: #4ade80;
}

/* Transfer Badges */
.transfer-badges-section {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: var(--spacing-lg);
    margin-top: var(--spacing-md);
    padding-top: var(--spacing-md);
    border-top: 1px solid var(--border-blue);
}

.badges-group {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    flex-wrap: wrap;
}

.badges-label {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-weight: 600;
}

.badges-list {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.transfer-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.75rem;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.transfer-badge .from-party {
    color: #94a3b8;
}

.transfer-badge .to-party {
    font-weight: 600;
}

.transfer-badge .to-party.bn { color: #60a5fa; }
.transfer-badge .to-party.ph { color: #f87171; }
.transfer-badge .to-party.pn { color: #38bdf8; }

.transfer-badge strong {
    color: #ffffff;
    margin-left: 4px;
    background: rgba(255, 255, 255, 0.15);
    padding: 1px 6px;
    border-radius: 10px;
}

.transfer-badge.retained {
    background: rgba(34, 197, 94, 0.15);
    border-color: rgba(34, 197, 94, 0.3);
}

.transfer-badge.retained .party-name {
    font-weight: 600;
}

.transfer-badge.retained .party-name.bn { color: #60a5fa; }
.transfer-badge.retained .party-name.ph { color: #f87171; }
.transfer-badge.retained .party-name.pn { color: #38bdf8; }

.transfer-badge.retained strong {
    background: rgba(34, 197, 94, 0.25);
    color: #4ade80;
}

@media (max-width: 768px) {
    .sankey-legend-content {
        flex-direction: column;
    }
    
    .sankey-legend .legend-arrow {
        transform: rotate(90deg);
    }
    
    .sankey-summary {
        flex-direction: column;
        align-items: center;
    }
    
    .transfer-badges-section {
        flex-direction: column;
        align-items: center;
    }
    
    .badges-group {
        justify-content: center;
    }
}

/* Swing & Demographic Combined Row */
.swing-demographic-row {
    background: transparent;
    border: none;
    padding: 0;
}

.swing-demo-grid {
    display: grid;
    grid-template-columns: 1fr 2fr;
    gap: var(--spacing-lg);
}

@media (max-width: 1200px) {
    .swing-demo-grid {
        grid-template-columns: 1fr;
    }
}

.swing-panel,
.demographic-panel {
    background: var(--bg-secondary);
    border: 1px solid var(--border-blue);
    border-radius: var(--border-radius);
    overflow: hidden;
}

.swing-panel .panel-header,
.demographic-panel .panel-header {
    background: linear-gradient(90deg, rgba(0, 82, 165, 0.3), transparent);
    padding: var(--spacing-sm) var(--spacing-md);
    border-bottom: 1px solid var(--border-blue);
}

.swing-panel .panel-header h3,
.demographic-panel .panel-header h3 {
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--text-white);
    margin: 0;
}

.swing-panel .panel-content,
.demographic-panel .panel-content {
    padding: var(--spacing-md);
}

/* Swing Chart */
.swing-chart-wrapper {
    height: 450px;
    position: relative;
    min-height: 400px;
}

/* Demographic Grid */
/* Demographic Grid */
.demographic-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: var(--spacing-md);
}

.demographic-category-card {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-blue);
    border-radius: var(--border-radius);
    padding: var(--spacing-md);
}

.demographic-category-card .cat-header {
    display: flex;
    flex-direction: column;
    gap: 2px;
    margin-bottom: var(--spacing-sm);
    padding-bottom: var(--spacing-sm);
    border-bottom: 1px solid var(--border-blue);
}

.demographic-category-card .cat-name {
    font-weight: 700;
    font-size: 0.95rem;
    color: var(--text-white);
}

.demographic-category-card .cat-range {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.demographic-category-card .cat-stats {
    display: flex;
    justify-content: space-around;
    gap: var(--spacing-sm);
    text-align: center;
    margin-top: var(--spacing-sm);
}

.demographic-category-card .cat-stat {
    padding: var(--spacing-sm);
    background: var(--bg-tertiary);
    border-radius: var(--border-radius);
    min-width: 50px;
}

.demographic-category-card .cat-stat .stat-value {
    font-weight: 700;
    font-family: var(--font-mono);
    font-size: 1.3rem;
}

.demographic-category-card .cat-stat .stat-label {
    font-size: 0.7rem;
    color: var(--text-muted);
    text-transform: uppercase;
    margin-top: 2px;
}

.demographic-category-card .cat-stat.bn .stat-value { color: #0052a5; }
.demographic-category-card .cat-stat.ph .stat-value { color: #ef4444; }
.demographic-category-card .cat-stat.pn .stat-value { color: #0ea5e9; }

/* Comparison Table */
#comparisonTable th,
#comparisonTable td {
    padding: var(--spacing-sm);
    text-align: center;
}

#comparisonTable th:first-child,
#comparisonTable td:first-child,
#comparisonTable th:nth-child(2),
#comparisonTable td:nth-child(2) {
    text-align: left;
}

#comparisonTable .change-cell {
    font-weight: 700;
}

#comparisonTable .change-cell.flip {
    color: var(--highlight-blue);
}

#comparisonTable .change-cell.retain {
    color: var(--text-muted);
}

.party-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
}

.party-badge.bn { background: rgba(0, 82, 165, 0.2); color: #4a9eff; }
.party-badge.ph { background: rgba(239, 68, 68, 0.2); color: #ef4444; }
.party-badge.pn { background: rgba(14, 165, 233, 0.2); color: #0ea5e9; }

/* Strategic Insights Grid */
.insights-grid-3col {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--spacing-md);
}

@media (max-width: 992px) {
    .insights-grid-3col {
        grid-template-columns: 1fr;
    }
}

.insight-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-blue);
    border-radius: var(--border-radius);
    padding: var(--spacing-md);
    border-left: 4px solid var(--insight-color, var(--border-blue));
}

.insight-card .insight-header {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    margin-bottom: var(--spacing-md);
    padding-bottom: var(--spacing-sm);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.insight-card .insight-icon {
    font-size: 1.2rem;
}

.insight-card .insight-title {
    font-weight: 700;
    font-size: 0.95rem;
    flex: 1;
    color: var(--text-primary);
}

.insight-badge {
    font-weight: 600;
    font-size: 0.75rem;
    padding: 3px 10px;
    border-radius: 12px;
    letter-spacing: 0.5px;
}

.insight-badge.positive {
    background: rgba(34, 197, 94, 0.2);
    color: #4ade80;
}

.insight-badge.negative {
    background: rgba(239, 68, 68, 0.2);
    color: #f87171;
}

.insight-card .insight-body {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-sm);
}

/* Stats Section */
.insight-section {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--spacing-sm);
}

.insight-row {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: var(--spacing-sm);
    background: rgba(255, 255, 255, 0.03);
    border-radius: 6px;
}

.row-label {
    font-size: 0.7rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.row-value {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-primary);
}

.row-value.success {
    color: #4ade80;
}

.row-value.danger {
    color: #f87171;
}

/* Detail Section */
.insight-detail {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding-top: var(--spacing-xs);
}

.detail-item {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.detail-label {
    font-size: 0.7rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.detail-text,
.detail-codes {
    font-size: 0.8rem;
    color: var(--text-primary);
    line-height: 1.4;
}

.detail-codes {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.75rem;
    color: var(--accent);
    word-break: break-word;
}

/* Note/Strategy Section */
.insight-note {
    display: flex;
    align-items: flex-start;
    gap: var(--spacing-xs);
    margin-top: var(--spacing-xs);
    padding: var(--spacing-sm);
    background: rgba(59, 130, 246, 0.1);
    border-radius: 6px;
    border-left: 3px solid var(--insight-color, var(--border-blue));
}

.insight-note.warning {
    background: rgba(245, 158, 11, 0.1);
    border-left-color: #f59e0b;
}

.note-icon {
    font-size: 0.85rem;
    flex-shrink: 0;
}

.note-text {
    font-size: 0.75rem;
    color: var(--text-secondary);
    line-height: 1.4;
}

.insight-card.bn { --insight-color: #0052a5; }
.insight-card.ph { --insight-color: #ef4444; }
.insight-card.pn { --insight-color: #0ea5e9; }

/* Responsive for Insight Cards */
@media (max-width: 768px) {
    .insight-section {
        grid-template-columns: 1fr;
    }
    
    .insight-card {
        padding: var(--spacing-sm);
    }
    
    .insight-card .insight-title {
        font-size: 0.85rem;
    }
    
    .insight-badge {
        font-size: 0.7rem;
        padding: 2px 8px;
    }
}

/* ============================================
   USER INFO & AUTH STYLES
   ============================================ */

/* User Info in Sidebar Footer */
.user-info {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    padding: var(--spacing-sm) var(--spacing-md);
    background: rgba(0, 82, 165, 0.15);
    border-radius: var(--border-radius);
    width: 100%;
}

.sidebar.collapsed .user-info {
    padding: var(--spacing-sm);
    justify-content: center;
}

.sidebar.collapsed .user-details {
    display: none;
}

.sidebar.collapsed .logout-btn {
    display: none;
}

.user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(59, 130, 246, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #60a5fa;
    flex-shrink: 0;
}

.user-details {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.user-name {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-role {
    font-size: 0.7rem;
    font-weight: 600;
    padding: 2px 6px;
    border-radius: 4px;
    width: fit-content;
    margin-top: 2px;
}

.user-role.role-admin {
    background: rgba(239, 68, 68, 0.2);
    color: #f87171;
}

.user-role.role-admin-sekretariat {
    background: rgba(234, 179, 8, 0.2);
    color: #fbbf24;
}

.user-role.role-user {
    background: rgba(34, 197, 94, 0.2);
    color: #4ade80;
}

.logout-btn {
    width: 32px;
    height: 32px;
    border-radius: 6px;
    background: rgba(239, 68, 68, 0.15);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: #f87171;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.logout-btn:hover {
    background: rgba(239, 68, 68, 0.25);
    border-color: rgba(239, 68, 68, 0.5);
}

/* ============================================
   MODAL STYLES
   ============================================ */

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s ease;
}

.modal-overlay.show {
    opacity: 1;
    visibility: visible;
}

.modal {
    background: var(--bg-secondary);
    border: 1px solid var(--border-blue);
    border-radius: 12px;
    width: 90%;
    max-width: 480px;
    max-height: 90vh;
    overflow: auto;
    transform: scale(0.95);
    transition: transform 0.2s ease;
}

.modal-overlay.show .modal {
    transform: scale(1);
}

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

.modal-header h3 {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0;
}

.modal-close {
    width: 32px;
    height: 32px;
    border: none;
    background: rgba(239, 68, 68, 0.15);
    border-radius: 6px;
    color: #f87171;
    font-size: 1.5rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.modal-close:hover {
    background: rgba(239, 68, 68, 0.25);
}

.modal-form {
    padding: var(--spacing-lg);
}

.modal-form .form-group {
    margin-bottom: var(--spacing-md);
}

.modal-form .form-label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    color: #cbd5e1;
    margin-bottom: 6px;
}

.modal-form .form-input {
    width: 100%;
    padding: 12px 14px;
    background: rgba(30, 41, 59, 0.8);
    border: 1px solid rgba(71, 85, 105, 0.5);
    border-radius: 8px;
    font-size: 0.95rem;
    color: #ffffff;
    transition: all 0.2s ease;
    font-family: inherit;
}

.modal-form .form-input:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}

.modal-form .form-input:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.modal-form select.form-input {
    cursor: pointer;
}

.modal-info {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: var(--spacing-md);
}

.modal-info strong {
    color: var(--text-primary);
}

.form-error {
    font-size: 0.85rem;
    color: #f87171;
    background: rgba(239, 68, 68, 0.15);
    border: 1px solid rgba(239, 68, 68, 0.3);
    border-radius: 6px;
    padding: 10px 12px;
    margin-bottom: var(--spacing-sm);
    display: none;
}

.form-error:not(:empty) {
    display: block;
}

.modal-actions {
    display: flex;
    gap: var(--spacing-sm);
    justify-content: flex-end;
    padding-top: var(--spacing-md);
    border-top: 1px solid var(--border-blue);
}

.modal-body {
    padding: var(--spacing-lg);
}

.modal-body p {
    color: var(--text-secondary);
    margin: 0;
}

.modal-confirm .modal-actions {
    padding: var(--spacing-md) var(--spacing-lg);
    border-top: 1px solid var(--border-blue);
}

/* Buttons */
.btn-primary {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 20px;
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
    border: none;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 600;
    color: #ffffff;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-primary:hover:not(:disabled) {
    background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
}

.btn-primary:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.btn-secondary {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 20px;
    background: transparent;
    border: 1px solid rgba(71, 85, 105, 0.5);
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-secondary:hover {
    background: rgba(71, 85, 105, 0.2);
    border-color: rgba(71, 85, 105, 0.8);
}

.btn-danger {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 20px;
    background: rgba(239, 68, 68, 0.2);
    border: 1px solid rgba(239, 68, 68, 0.4);
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 600;
    color: #f87171;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-danger:hover {
    background: rgba(239, 68, 68, 0.3);
    border-color: rgba(239, 68, 68, 0.6);
}

/* ============================================
   ADMIN PANEL STYLES
   ============================================ */

/* Admin Navigation */
.admin-section .nav-section-header {
    background: rgba(234, 179, 8, 0.1);
}

.admin-section .section-icon {
    color: #fbbf24;
}

/* User Stats Row */
.user-stats-row {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--spacing-md);
    margin-bottom: var(--spacing-lg);
}

.user-stat-card {
    background: rgba(0, 82, 165, 0.1);
    border: 1px solid rgba(59, 130, 246, 0.2);
    border-radius: var(--border-radius);
    padding: var(--spacing-md);
    text-align: center;
}

.user-stat-card .stat-value {
    display: block;
    font-size: 2rem;
    font-weight: 700;
    color: var(--text-primary);
    font-family: var(--font-mono);
}

.user-stat-card .stat-label {
    display: block;
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 4px;
}

/* Users Table */
.users-table .username-badge {
    font-family: var(--font-mono);
    font-size: 0.85rem;
    padding: 4px 8px;
    background: rgba(59, 130, 246, 0.15);
    border-radius: 4px;
    color: #60a5fa;
}

.role-badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
}

.role-badge.role-admin {
    background: rgba(239, 68, 68, 0.2);
    color: #f87171;
}

.role-badge.role-admin-sekretariat {
    background: rgba(234, 179, 8, 0.2);
    color: #fbbf24;
}

.role-badge.role-user {
    background: rgba(34, 197, 94, 0.2);
    color: #4ade80;
}

.status-badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
}

.status-badge.active {
    background: rgba(34, 197, 94, 0.2);
    color: #4ade80;
}

.status-badge.inactive {
    background: rgba(239, 68, 68, 0.2);
    color: #f87171;
}

/* Action Buttons */
.action-cell {
    width: 140px;
}

.action-buttons {
    display: flex;
    gap: 6px;
    justify-content: center;
}

.action-btn {
    width: 30px;
    height: 30px;
    border-radius: 6px;
    border: 1px solid rgba(71, 85, 105, 0.3);
    background: rgba(71, 85, 105, 0.1);
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.action-btn:hover {
    background: rgba(71, 85, 105, 0.3);
}

.action-btn.warning {
    border-color: rgba(234, 179, 8, 0.3);
    background: rgba(234, 179, 8, 0.1);
    color: #fbbf24;
}

.action-btn.warning:hover {
    background: rgba(234, 179, 8, 0.2);
}

.action-btn.danger {
    border-color: rgba(239, 68, 68, 0.3);
    background: rgba(239, 68, 68, 0.1);
    color: #f87171;
}

.action-btn.danger:hover {
    background: rgba(239, 68, 68, 0.2);
}

.action-btn.success {
    border-color: rgba(34, 197, 94, 0.3);
    background: rgba(34, 197, 94, 0.1);
    color: #4ade80;
}

.action-btn.success:hover {
    background: rgba(34, 197, 94, 0.2);
}

.action-btn.info {
    border-color: rgba(59, 130, 246, 0.3);
    background: rgba(59, 130, 246, 0.1);
    color: #60a5fa;
}

.action-btn.info:hover {
    background: rgba(59, 130, 246, 0.2);
}

/* Access Log */
.access-log-table .action-badge {
    display: inline-block;
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    background: rgba(71, 85, 105, 0.2);
    color: var(--text-secondary);
}

.action-badge.action-login {
    background: rgba(34, 197, 94, 0.2);
    color: #4ade80;
}

.action-badge.action-logout {
    background: rgba(59, 130, 246, 0.2);
    color: #60a5fa;
}

.action-badge.action-create_user {
    background: rgba(168, 85, 247, 0.2);
    color: #c084fc;
}

.action-badge.action-delete_user {
    background: rgba(239, 68, 68, 0.2);
    color: #f87171;
}

.action-badge.action-change_password,
.action-badge.action-revoke_access,
.action-badge.action-restore_access {
    background: rgba(234, 179, 8, 0.2);
    color: #fbbf24;
}

.log-details {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: var(--text-muted);
    background: rgba(0, 0, 0, 0.2);
    padding: 2px 6px;
    border-radius: 4px;
}

/* Table States */
.loading-cell,
.empty-cell,
.error-cell {
    text-align: center;
    padding: var(--spacing-xl) !important;
    color: var(--text-muted);
    font-style: italic;
}

.error-cell {
    color: #f87171;
}

/* Header Actions */
.module-header .header-actions {
    display: flex;
    gap: var(--spacing-sm);
}

@media (max-width: 768px) {
    .user-stats-row {
        grid-template-columns: 1fr;
    }
    
    .action-buttons {
        flex-wrap: wrap;
    }
    
    .user-info {
        padding: var(--spacing-xs) var(--spacing-sm);
    }
    
    .user-avatar {
        width: 30px;
        height: 30px;
    }
    
    .user-name {
        font-size: 0.8rem;
    }
    
    .user-role {
        font-size: 0.65rem;
    }
    
    .logout-btn {
        width: 28px;
        height: 28px;
    }
}

/* ============================================
   STRATEGIC ANALYSIS PAGE
   ============================================ */

.strategic-header {
    margin-bottom: var(--spacing-xl);
    padding-bottom: var(--spacing-lg);
    border-bottom: 1px solid var(--border-blue);
}

.strategic-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: var(--spacing-xs);
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
}

.strategic-subtitle {
    font-size: 0.9rem;
    color: var(--text-secondary);
    max-width: 700px;
}

/* Strategic Stats Row */
.strategic-stats-row {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: var(--spacing-md);
    margin-bottom: var(--spacing-xl);
}

.strategic-stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border-blue);
    border-radius: 8px;
    padding: var(--spacing-lg);
    display: flex;
    flex-direction: column;
    gap: var(--spacing-sm);
    position: relative;
    overflow: hidden;
    transition: all 0.3s ease;
}

.strategic-stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
}

.strategic-stat-card.high-risk::before {
    background: linear-gradient(180deg, #ef4444, #dc2626);
}

.strategic-stat-card.medium-risk::before {
    background: linear-gradient(180deg, #f59e0b, #d97706);
}

.strategic-stat-card.opportunity::before {
    background: linear-gradient(180deg, #22c55e, #16a34a);
}

.strategic-stat-card.safe::before {
    background: linear-gradient(180deg, #3b82f6, #2563eb);
}

.strategic-stat-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.strategic-stat-icon {
    font-size: 1.5rem;
}

.strategic-stat-content {
    flex: 1;
}

.strategic-stat-value {
    font-size: 2rem;
    font-weight: 700;
    font-family: var(--font-mono);
    color: var(--text-primary);
    line-height: 1.2;
}

.strategic-stat-card.high-risk .strategic-stat-value {
    color: #ef4444;
}

.strategic-stat-card.medium-risk .strategic-stat-value {
    color: #f59e0b;
}

.strategic-stat-card.opportunity .strategic-stat-value {
    color: #22c55e;
}

.strategic-stat-card.safe .strategic-stat-value {
    color: #3b82f6;
}

.strategic-stat-label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.strategic-stat-desc {
    font-size: 0.75rem;
    color: var(--text-muted);
    padding-top: var(--spacing-xs);
    border-top: 1px dashed var(--border-blue);
}

/* Strategic Layout */
.strategic-layout {
    grid-template-columns: 1.2fr 1fr;
    gap: var(--spacing-lg);
    align-items: stretch;
}

.strategic-scatter-module,
.strategic-table-module {
    display: flex;
    flex-direction: column;
}

.strategic-scatter-module .module-header,
.strategic-table-module .module-header {
    flex-shrink: 0;
}

.strategic-scatter-module .module-content {
    flex: 1;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.strategic-table-module .module-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-height: 0;
}

.strategic-table-module .table-container {
    flex: 1;
    overflow-y: auto;
    overflow-x: auto;
    min-height: 0;
}

.strategic-table-module .strategic-table {
    width: 100%;
}

.scatter-chart-container {
    flex: 1;
    min-height: 300px;
    position: relative;
}

.scatter-legend {
    flex-shrink: 0;
    display: flex;
    gap: var(--spacing-lg);
}

.scatter-legend-item {
    display: flex;
    align-items: center;
    gap: var(--spacing-xs);
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.scatter-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
}

.scatter-dot.bn {
    background: var(--bn-color);
    border: 2px solid #4040bf;
}

.scatter-dot.ph {
    background: var(--ph-color);
    border: 2px solid #ff6b6b;
}

.scatter-dot.pn {
    background: var(--pn-color);
    border: 2px solid #22c55e;
}

.scatter-zones-legend {
    display: flex;
    justify-content: center;
    gap: var(--spacing-xl);
    margin-top: var(--spacing-md);
    padding-top: var(--spacing-md);
    border-top: 1px solid var(--border-blue);
}

.zone-item {
    display: flex;
    align-items: center;
    gap: var(--spacing-xs);
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.zone-color {
    width: 16px;
    height: 16px;
    border-radius: 3px;
    opacity: 0.5;
}

.zone-item.high-risk .zone-color {
    background: #ef4444;
}

.zone-item.medium-risk .zone-color {
    background: #f59e0b;
}

.zone-item.safe .zone-color {
    background: #3b82f6;
}

/* Strategic Table */
.strategic-table {
    font-size: 0.85rem;
}

.strategic-table th {
    position: sticky;
    top: 0;
    background: var(--bg-card);
    z-index: 1;
}

.strategic-table td {
    vertical-align: middle;
}

.risk-badge {
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.risk-badge.high {
    background: rgba(239, 68, 68, 0.15);
    color: #ef4444;
    border: 1px solid rgba(239, 68, 68, 0.3);
}

.risk-badge.medium {
    background: rgba(245, 158, 11, 0.15);
    color: #f59e0b;
    border: 1px solid rgba(245, 158, 11, 0.3);
}

.risk-badge.opportunity {
    background: rgba(34, 197, 94, 0.15);
    color: #22c55e;
    border: 1px solid rgba(34, 197, 94, 0.3);
}

.risk-badge.safe {
    background: rgba(59, 130, 246, 0.15);
    color: #3b82f6;
    border: 1px solid rgba(59, 130, 246, 0.3);
}

.recommendation-text {
    font-size: 0.75rem;
    color: var(--text-muted);
    max-width: 150px;
}

/* Strategic Insights */
.strategic-insights .insights-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: var(--spacing-md);
}

.insight-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-blue);
    border-radius: 8px;
    padding: var(--spacing-lg);
    text-align: center;
    transition: all 0.3s ease;
}

.insight-card:hover {
    background: var(--bg-card);
    transform: translateY(-2px);
}

.insight-icon {
    font-size: 2rem;
    margin-bottom: var(--spacing-sm);
}

.insight-title {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: var(--spacing-xs);
}

.insight-value {
    font-size: 1.5rem;
    font-weight: 700;
    font-family: var(--font-mono);
    color: var(--highlight-blue);
    margin-bottom: var(--spacing-xs);
}

.insight-desc {
    font-size: 0.7rem;
    color: var(--text-muted);
    line-height: 1.4;
}

/* Recommendations Grid */
.strategic-recommendations .recommendations-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--spacing-md);
}

.recommendation-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-blue);
    border-radius: 8px;
    padding: var(--spacing-lg);
    position: relative;
    overflow: hidden;
}

.recommendation-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 3px;
}

.recommendation-card.priority-high::before {
    background: linear-gradient(90deg, #ef4444, #f87171);
}

.recommendation-card.priority-medium::before {
    background: linear-gradient(90deg, #f59e0b, #fbbf24);
}

.recommendation-card.priority-low::before {
    background: linear-gradient(90deg, #3b82f6, #60a5fa);
}

.recommendation-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--spacing-sm);
}

.recommendation-title {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-primary);
}

.priority-badge {
    font-size: 0.65rem;
    padding: 3px 8px;
    border-radius: 10px;
    font-weight: 600;
    text-transform: uppercase;
}

.priority-badge.high {
    background: rgba(239, 68, 68, 0.2);
    color: #ef4444;
}

.priority-badge.medium {
    background: rgba(245, 158, 11, 0.2);
    color: #f59e0b;
}

.priority-badge.low {
    background: rgba(59, 130, 246, 0.2);
    color: #3b82f6;
}

.recommendation-body {
    font-size: 0.8rem;
    color: var(--text-secondary);
    line-height: 1.5;
    margin-bottom: var(--spacing-sm);
}

.recommendation-seats {
    display: flex;
    flex-wrap: wrap;
    gap: var(--spacing-xs);
}

.seat-tag {
    font-size: 0.7rem;
    padding: 3px 8px;
    background: var(--bg-card);
    border: 1px solid var(--border-blue);
    border-radius: 4px;
    color: var(--text-secondary);
    font-family: var(--font-mono);
}

/* Responsive */
@media (max-width: 1200px) {
    .strategic-stats-row {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .strategic-layout {
        grid-template-columns: 1fr;
    }
    
    .strategic-scatter-module {
        grid-row: auto;
    }
    
    .strategic-insights .insights-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .strategic-recommendations .recommendations-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    .strategic-stats-row {
        grid-template-columns: 1fr;
    }
    
    .strategic-insights .insights-grid {
        grid-template-columns: 1fr;
    }
    
    .strategic-recommendations .recommendations-grid {
        grid-template-columns: 1fr;
    }
    
    .scatter-zones-legend {
        flex-wrap: wrap;
        justify-content: flex-start;
    }
}

/* ============================================
   GEOSPATIAL PAGE
   ============================================ */

.geospatial-header {
    margin-bottom: var(--spacing-lg);
    padding-bottom: var(--spacing-md);
    border-bottom: 1px solid var(--border-blue);
}

.geospatial-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: var(--spacing-xs);
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
}

.geospatial-subtitle {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

/* Map Controls */
.geospatial-controls {
    display: flex;
    align-items: center;
    gap: var(--spacing-lg);
    margin-bottom: var(--spacing-lg);
    padding: var(--spacing-md);
    background: var(--bg-card);
    border: 1px solid var(--border-blue);
    border-radius: 8px;
    flex-wrap: wrap;
}

.map-control-group {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
}

.map-control-group label {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-secondary);
    white-space: nowrap;
}

.map-select {
    padding: 8px 12px;
    background: var(--bg-darker);
    border: 1px solid var(--border-blue);
    border-radius: 6px;
    color: var(--text-primary);
    font-size: 0.85rem;
    font-family: inherit;
    cursor: pointer;
    min-width: 180px;
    transition: all 0.2s ease;
}

.map-select:hover,
.map-select:focus {
    border-color: var(--accent-blue);
    outline: none;
}

.map-select option {
    background: var(--bg-darker);
    color: var(--text-primary);
    padding: 8px;
}

/* Visualization dropdown with colored options */
.map-vis-select {
    font-weight: 600;
}

.map-vis-select option[data-bg] {
    padding: 10px 12px;
}

.map-vis-select option[value="winning-party"] {
    background: #0056b3;
    color: #ffffff;
}

.map-vis-select option[value="demographic-category"] {
    background: #009966;
    color: #ffffff;
}

.map-vis-select option[value="malay-pct"] {
    background: #00b377;
    color: #ffffff;
}

.map-vis-select option[value="turnout"] {
    background: #f59e0b;
    color: #000000;
}

.map-vis-select option[value="majority"] {
    background: #10b981;
    color: #ffffff;
}

.map-vis-select option[value="pn-performance"] {
    background: #009966;
    color: #ffffff;
}

/* Base layer dropdown with colored options */
.map-base-select {
    font-weight: 600;
}

.map-base-select option[value="osm"] {
    background: #4a90d9;
    color: #ffffff;
}

.map-base-select option[value="satellite"] {
    background: #2d5a27;
    color: #ffffff;
}

.map-base-select option[value="dark"] {
    background: #1a1f2e;
    color: #ffffff;
}

/* Checkbox for border only mode */
.map-checkbox-group {
    display: flex;
    align-items: center;
}

.map-checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 0.85rem;
    color: var(--text-primary);
    user-select: none;
}

.map-checkbox {
    display: none;
}

.checkbox-custom {
    width: 18px;
    height: 18px;
    border: 2px solid var(--border-blue);
    border-radius: 4px;
    background: var(--bg-darker);
    position: relative;
    transition: all 0.2s ease;
}

.map-checkbox:checked + .checkbox-custom {
    background: var(--accent-blue);
    border-color: var(--accent-blue);
}

.map-checkbox:checked + .checkbox-custom::after {
    content: '✓';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: #ffffff;
    font-size: 12px;
    font-weight: bold;
}

.checkbox-text {
    white-space: nowrap;
}

.map-checkbox-label:hover .checkbox-custom {
    border-color: var(--accent-blue);
}

.map-btn {
    padding: 8px 16px;
    background: var(--bg-darker);
    border: 1px solid var(--border-blue);
    border-radius: 6px;
    color: var(--text-primary);
    font-size: 0.85rem;
    font-family: inherit;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: var(--spacing-xs);
    transition: all 0.2s ease;
}

.map-btn:hover {
    background: var(--accent-blue);
    border-color: var(--accent-blue);
}

/* Map Layout */
.geospatial-layout {
    display: grid;
    grid-template-columns: 1fr 380px;
    gap: var(--spacing-lg);
    height: calc(100vh - 320px);
    min-height: 500px;
}

.map-main-container {
    background: var(--bg-card);
    border: 1px solid var(--border-blue);
    border-radius: 8px;
    overflow: hidden;
    position: relative;
}

.leaflet-map-container {
    width: 100%;
    height: 100%;
    min-height: 500px;
    background: var(--bg-darker);
}

/* Leaflet Custom Styles */
.leaflet-container {
    font-family: 'Plus Jakarta Sans', -apple-system, sans-serif;
    background: #1a1f2e !important;
}

.leaflet-tile-pane {
    filter: saturate(0.8) brightness(0.9);
}

.leaflet-control-zoom {
    border: none !important;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3) !important;
}

.leaflet-control-zoom a {
    background: var(--bg-card) !important;
    color: var(--text-primary) !important;
    border: 1px solid var(--border-blue) !important;
    width: 32px !important;
    height: 32px !important;
    line-height: 30px !important;
}

.leaflet-control-zoom a:hover {
    background: var(--accent-blue) !important;
}

.leaflet-control-zoom-in {
    border-radius: 6px 6px 0 0 !important;
}

.leaflet-control-zoom-out {
    border-radius: 0 0 6px 6px !important;
}

.leaflet-control-attribution {
    background: rgba(10, 15, 25, 0.8) !important;
    color: var(--text-muted) !important;
    font-size: 10px !important;
}

.leaflet-control-attribution a {
    color: var(--accent-blue) !important;
}

/* DUN Labels on Map */
.dun-label {
    background: transparent;
    border: none;
    padding: 0;
    color: #ffffff;
    font-size: 11px;
    font-weight: 700;
    white-space: nowrap;
    text-shadow: 
        1px 1px 2px rgba(0, 0, 0, 0.9),
        -1px -1px 2px rgba(0, 0, 0, 0.9),
        1px -1px 2px rgba(0, 0, 0, 0.9),
        -1px 1px 2px rgba(0, 0, 0, 0.9),
        0 0 8px rgba(0, 0, 0, 0.8);
}

.dun-label-highlight {
    color: #3b82f6;
    text-shadow: 
        1px 1px 2px rgba(0, 0, 0, 0.9),
        -1px -1px 2px rgba(0, 0, 0, 0.9),
        0 0 10px rgba(59, 130, 246, 0.5);
}

/* Custom Popup Styles */
.leaflet-popup-content-wrapper {
    background: var(--bg-card) !important;
    border: 1px solid var(--border-blue) !important;
    border-radius: 8px !important;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4) !important;
}

.leaflet-popup-content {
    margin: 12px 16px !important;
    color: var(--text-primary) !important;
    font-size: 13px !important;
}

.leaflet-popup-tip {
    background: var(--bg-card) !important;
    border: 1px solid var(--border-blue) !important;
}

.leaflet-popup-close-button {
    color: var(--text-secondary) !important;
    font-size: 18px !important;
}

.leaflet-popup-close-button:hover {
    color: var(--accent-blue) !important;
}

/* Map Popup Content */
.map-popup-header {
    font-weight: 700;
    font-size: 14px;
    color: var(--text-primary);
    margin-bottom: 8px;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--border-blue);
}

.map-popup-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 4px;
    font-size: 12px;
}

.map-popup-row .label {
    color: var(--text-secondary);
}

.map-popup-row .value {
    font-weight: 600;
    color: var(--text-primary);
}

.map-popup-party-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    margin-top: 6px;
}

/* Map Info Panel */
.map-info-panel {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-md);
    overflow-y: auto;
    padding-right: 8px;
}

.map-legend-card,
.map-info-card,
.map-stats-card {
    background: var(--bg-card);
    border: 1px solid var(--border-blue);
    border-radius: 8px;
    padding: var(--spacing-md);
}

.map-legend-card h3,
.map-info-card h3,
.map-stats-card h3 {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: var(--spacing-sm);
    padding-bottom: var(--spacing-xs);
    border-bottom: 1px solid var(--border-blue);
}

/* Legend */
.legend-content {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.legend-color {
    width: 16px;
    height: 16px;
    border-radius: 3px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    flex-shrink: 0;
}

.legend-gradient {
    height: 12px;
    border-radius: 2px;
    width: 100%;
    margin-top: var(--spacing-xs);
}

.legend-scale {
    display: flex;
    justify-content: space-between;
    font-size: 10px;
    color: var(--text-muted);
    margin-top: 4px;
}

/* DUN Info Content */
.dun-info-content {
    font-size: 0.85rem;
}

.dun-info-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: var(--spacing-sm);
    padding: var(--spacing-lg);
    color: var(--text-muted);
    text-align: center;
    font-size: 0.8rem;
}

.dun-info-placeholder .placeholder-icon {
    font-size: 1.5rem;
    opacity: 0.5;
}

.dun-info-header {
    font-weight: 700;
    font-size: 1rem;
    color: var(--text-primary);
    margin-bottom: var(--spacing-xs);
}

.dun-info-sticky-header {
    position: sticky;
    top: 0;
    background: var(--bg-card);
    padding: 12px 0 8px 0;
    margin: -12px 0 8px 0;
    z-index: 10;
    border-bottom: 1px solid var(--border-blue);
}

.dun-info-scrollable {
    padding-top: 4px;
}

.dun-info-subheader {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-bottom: var(--spacing-md);
}

.dun-info-row {
    display: flex;
    justify-content: space-between;
    padding: 4px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.dun-info-row:last-child {
    border-bottom: none;
}

.dun-info-label {
    color: var(--text-secondary);
    font-size: 0.8rem;
}

.dun-info-value {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 0.8rem;
}

/* Quick Stats Row */
.dun-quick-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    margin-bottom: 12px;
}

.quick-stat-item {
    background: var(--bg-darker);
    border-radius: 6px;
    padding: 10px 8px;
    text-align: center;
}

.quick-stat-item.highlight {
    background: linear-gradient(135deg, #0056b3, #3b82f6);
}

.quick-stat-label {
    display: block;
    font-size: 0.65rem;
    color: var(--text-muted);
    margin-bottom: 4px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.quick-stat-item.highlight .quick-stat-label {
    color: rgba(255, 255, 255, 0.8);
}

.quick-stat-value {
    display: block;
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-primary);
}

.quick-stat-item.highlight .quick-stat-value {
    color: #ffffff;
}

/* Vote Distribution Bar */
.vote-distribution-bar {
    display: flex;
    height: 8px;
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 12px;
    background: var(--bg-darker);
}

.vote-bar-segment {
    height: 100%;
    transition: all 0.3s ease;
}

.vote-bar-segment:hover {
    filter: brightness(1.2);
}

/* Candidate Results Section */
.candidate-results-section {
    margin-bottom: 8px;
}

.section-title {
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 10px;
    padding-bottom: 4px;
    border-bottom: 1px solid var(--border-blue);
}

.candidate-row {
    display: grid;
    grid-template-columns: 24px 1fr auto;
    gap: 10px;
    align-items: center;
    padding: 8px 0;
}

.candidate-row.winner {
    background: rgba(0, 86, 179, 0.1);
    margin: 0 -8px;
    padding: 8px;
    border-radius: 6px;
}

.candidate-rank {
    width: 24px;
    height: 24px;
    background: var(--bg-darker);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--text-secondary);
}

.candidate-row.winner .candidate-rank {
    background: #0056b3;
    color: #ffffff;
}

.candidate-info {
    min-width: 0;
}

.candidate-name {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 3px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.candidate-party-badge {
    display: inline-block;
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 0.6rem;
    font-weight: 600;
}

.candidate-votes {
    text-align: right;
}

.candidate-vote-count {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text-primary);
}

.candidate-vote-pct {
    font-size: 0.7rem;
    color: var(--text-secondary);
}

.candidate-vote-bar {
    height: 4px;
    background: var(--bg-darker);
    border-radius: 2px;
    margin-bottom: 6px;
    overflow: hidden;
}

.candidate-vote-bar-fill {
    height: 100%;
    border-radius: 2px;
    transition: width 0.5s ease;
}

.no-data {
    text-align: center;
    color: var(--text-muted);
    font-size: 0.8rem;
    padding: 12px;
}

.dun-party-badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    margin-top: var(--spacing-sm);
}

/* DUN History Section */
.dun-history-section {
    margin-top: var(--spacing-md);
    padding-top: var(--spacing-md);
    border-top: 1px solid var(--border-blue);
}

.dun-history-title {
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--text-primary);
    margin-bottom: var(--spacing-sm);
}

.dun-history-table {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.dun-history-row {
    display: grid;
    grid-template-columns: 42px 70px 1fr;
    gap: 6px;
    align-items: center;
    padding: 4px 6px;
    background: var(--bg-darker);
    border-radius: 4px;
    font-size: 0.75rem;
}

.history-year {
    font-weight: 700;
    color: var(--text-primary);
}

.history-party {
    padding: 2px 4px;
    border-radius: 3px;
    font-size: 0.6rem;
    font-weight: 600;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 70px;
}

.history-party.party-bn {
    background: rgba(0, 86, 179, 0.3);
    color: #4da6ff;
}

.history-party.party-pn {
    background: rgba(0, 153, 102, 0.3);
    color: #00cc88;
}

.history-party.party-ph {
    background: rgba(220, 38, 38, 0.3);
    color: #ff6b6b;
}

.history-party.party-other {
    background: rgba(156, 163, 175, 0.3);
    color: #9ca3af;
}

.history-candidate {
    color: var(--text-secondary);
    white-space: normal;
    word-wrap: break-word;
    line-height: 1.3;
}

/* Old DUN name note */
.history-old-name {
    display: block;
    font-size: 0.6rem;
    font-weight: 400;
    color: var(--text-muted);
    font-style: italic;
    margin-top: 1px;
}

.dun-history-row.has-old-name {
    padding: 6px 6px;
}

.dun-history-row.has-old-name .history-year {
    display: flex;
    flex-direction: column;
    line-height: 1.2;
}

/* Quick Stats */
.map-quick-stats {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: var(--spacing-sm);
}

.quick-stat {
    background: var(--bg-darker);
    border-radius: 6px;
    padding: var(--spacing-sm);
    text-align: center;
}

.quick-stat .stat-value {
    display: block;
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
}

.quick-stat .stat-label {
    display: block;
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-top: 2px;
}

/* Party Colors */
.party-bn {
    background: rgba(0, 86, 179, 0.2);
    color: #4da6ff;
    border: 1px solid #4da6ff;
}

.party-pn {
    background: rgba(0, 153, 102, 0.2);
    color: #00cc88;
    border: 1px solid #00cc88;
}

.party-ph {
    background: rgba(220, 38, 38, 0.2);
    color: #ff6b6b;
    border: 1px solid #ff6b6b;
}

.party-other {
    background: rgba(156, 163, 175, 0.2);
    color: #9ca3af;
    border: 1px solid #9ca3af;
}

/* Responsive Geospatial */
@media (max-width: 1200px) {
    .geospatial-layout {
        grid-template-columns: 1fr 340px;
    }
}

@media (max-width: 992px) {
    .geospatial-layout {
        grid-template-columns: 1fr;
        height: auto;
    }
    
    .map-main-container {
        height: 450px;
    }
    
    .map-info-panel {
        display: grid;
        grid-template-columns: repeat(3, 1fr);
        gap: var(--spacing-md);
    }
}

@media (max-width: 768px) {
    .geospatial-controls {
        flex-direction: column;
        align-items: stretch;
    }
    
    .map-control-group {
        flex-direction: column;
        align-items: stretch;
    }
    
    .map-select {
        min-width: 100%;
    }
    
    .map-info-panel {
        grid-template-columns: 1fr;
    }
    
    .map-main-container {
        height: 350px;
    }
}

/* ==========================================
   PRU15 2022 Detail Table Section
   ========================================== */
.pru15-detail-section {
    margin-top: var(--spacing-lg);
}

.pru15-detail-section .module-header {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
    flex-wrap: wrap;
}

.pru15-detail-section .module-badge {
    background: linear-gradient(135deg, #22c55e, #16a34a);
    color: white;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
}

.pru15-detail-note {
    background: rgba(34, 197, 94, 0.1);
    border-left: 3px solid #22c55e;
    padding: var(--spacing-sm) var(--spacing-md);
    margin-bottom: var(--spacing-md);
    font-size: 0.85rem;
    color: var(--text-secondary);
    border-radius: 0 6px 6px 0;
}

.pru15-filter-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--spacing-md);
    margin-bottom: var(--spacing-md);
    padding: var(--spacing-sm) var(--spacing-md);
    background: var(--bg-darker);
    border-radius: 8px;
    flex-wrap: wrap;
}

.pru15-filter-bar .filter-group {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
}

.pru15-filter-bar label {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.pru15-filter-bar .filter-select {
    padding: 6px 12px;
    border-radius: 6px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    font-size: 0.85rem;
}

.btn-download-excel {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    background: linear-gradient(135deg, #217346, #185c37);
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-download-excel:hover {
    background: linear-gradient(135deg, #28a058, #217346);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(33, 115, 70, 0.3);
}

.btn-download-excel:active {
    transform: translateY(0);
}

.btn-download-excel svg {
    flex-shrink: 0;
}

.pru15-detail-table-wrapper {
    max-height: 500px;
    overflow-y: auto;
    overflow-x: auto;
    padding-right: 8px;
    margin-right: -8px;
}

/* Custom scrollbar for PRU15 table */
.pru15-detail-table-wrapper::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

.pru15-detail-table-wrapper::-webkit-scrollbar-track {
    background: var(--bg-darker);
    border-radius: 4px;
}

.pru15-detail-table-wrapper::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}

.pru15-detail-table-wrapper::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

.pru15-detail-table {
    width: 100%;
    font-size: 0.85rem;
    border-collapse: separate;
    border-spacing: 0;
}

.pru15-detail-table thead {
    position: sticky;
    top: 0;
    z-index: 10;
}

.pru15-detail-table thead tr {
    box-shadow: 0 3px 6px rgba(0, 0, 0, 0.4);
}

.pru15-detail-table th {
    /* Solid opaque background - no transparency */
    background-color: #1a1f2e;
    padding: 12px 10px;
    font-weight: 600;
    text-align: left;
    white-space: nowrap;
    border-bottom: 2px solid var(--accent-color);
}

.pru15-detail-table th.num-col {
    text-align: right;
}

.pru15-detail-table td {
    padding: 10px;
    border-bottom: 1px solid var(--border-color);
    vertical-align: middle;
}

.pru15-detail-table td:last-child {
    padding-right: 16px;
}

.pru15-detail-table td.num-col {
    text-align: right;
    font-family: 'JetBrains Mono', monospace;
}

.pru15-detail-table tbody tr {
    transition: background 0.2s;
}

.pru15-detail-table tbody tr:hover {
    background: rgba(255, 255, 255, 0.05);
}

.pru15-detail-table tbody tr.winner-pn {
    background: rgba(34, 197, 94, 0.08);
}

.pru15-detail-table tbody tr.winner-ph {
    background: rgba(239, 68, 68, 0.08);
}

.pru15-detail-table tbody tr.winner-bn {
    background: rgba(0, 82, 165, 0.08);
}

.pru15-detail-table .dun-code {
    font-weight: 600;
    color: var(--text-primary);
}

.pru15-detail-table .dun-name {
    color: var(--text-secondary);
    font-size: 0.8rem;
}

.pru15-detail-table .parliament-info {
    display: flex;
    flex-direction: column;
}

.pru15-detail-table .parliament-code {
    font-weight: 600;
    color: var(--accent-color);
}

.pru15-detail-table .parliament-name {
    color: var(--text-muted);
    font-size: 0.75rem;
}

.pru15-detail-table .candidate-info {
    display: flex;
    flex-direction: column;
}

.pru15-detail-table .candidate-name {
    font-weight: 500;
    color: var(--text-primary);
}

.pru15-detail-table .candidate-party {
    color: var(--text-muted);
    font-size: 0.75rem;
}

.pru15-detail-table .party-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
}

.pru15-detail-table .coalition-badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 700;
}

.pru15-detail-table .coalition-badge.pn {
    background: rgba(34, 197, 94, 0.2);
    color: #22c55e;
}

.pru15-detail-table .coalition-badge.ph {
    background: rgba(239, 68, 68, 0.2);
    color: #ef4444;
}

.pru15-detail-table .coalition-badge.bn {
    background: rgba(0, 82, 165, 0.2);
    color: #4da6ff;
}

.pru15-detail-table .majority-positive {
    color: #22c55e;
}

.pru15-detail-table .majority-negative {
    color: #ef4444;
}

.pru15-summary-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: var(--spacing-md);
    margin-top: var(--spacing-md);
    padding: var(--spacing-md);
    background: var(--bg-darker);
    border-radius: 8px;
}

.pru15-summary-stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: var(--spacing-sm);
    background: var(--bg-card);
    border-radius: 6px;
}

.pru15-summary-stat .stat-coalition {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 4px;
}

.pru15-summary-stat .stat-coalition .coalition-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
}

.pru15-summary-stat .stat-coalition .coalition-dot.pn { background: #22c55e; }
.pru15-summary-stat .stat-coalition .coalition-dot.ph { background: #ef4444; }
.pru15-summary-stat .stat-coalition .coalition-dot.bn { background: #0052a5; }

.pru15-summary-stat .stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
}

.pru15-summary-stat .stat-label {
    font-size: 0.75rem;
    color: var(--text-muted);
}

@media (max-width: 768px) {
    .pru15-detail-table {
        font-size: 0.75rem;
    }
    
    .pru15-detail-table th,
    .pru15-detail-table td {
        padding: 6px 4px;
    }
    
    .pru15-filter-bar {
        flex-direction: column;
        align-items: flex-start;
    }
}
