/* ============================================
   KAMPANJA MAPA - DASHBOARD STYLES
   ============================================ */

:root,
:root[data-theme="dark"] {
    /* Typography */
    --font-primary: 'Space Grotesk', -apple-system, sans-serif;
    --font-mono: 'JetBrains Mono', monospace;
    
    /* Spacing */
    --space-xs: 4px;
    --space-sm: 8px;
    --space-md: 16px;
    --space-lg: 24px;
    --space-xl: 32px;
    
    /* Border Radius */
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    
    /* Status Colors (same for both themes) */
    --status-ok: #10b981;
    --status-wait: #f59e0b;
    --status-warn: #f97316;
    --status-alert: #ef4444;
    
    /* Dark Theme Colors (default) */
    --bg-primary: #0a0e17;
    --bg-secondary: #111827;
    --bg-tertiary: #1e2a3a;
    --bg-card: #162032;
    
    --text-primary: #f0f4f8;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    
    --accent-primary: #3b82f6;
    --accent-secondary: #8b5cf6;
    --accent-glow: rgba(59, 130, 246, 0.3);
    
    --border-color: #2d3a4f;
    --border-glow: rgba(59, 130, 246, 0.5);
    
    --logo-gradient: linear-gradient(135deg, #3b82f6, #8b5cf6);
}

/* Light Theme */
:root[data-theme="light"] {
    --bg-primary: #f0f4f8;
    --bg-secondary: #ffffff;
    --bg-tertiary: #e2e8f0;
    --bg-card: #ffffff;
    
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #64748b;
    
    --accent-primary: #2563eb;
    --accent-secondary: #7c3aed;
    --accent-glow: rgba(37, 99, 235, 0.15);
    
    --border-color: #cbd5e1;
    --border-glow: rgba(37, 99, 235, 0.2);
    
    --logo-gradient: linear-gradient(135deg, #2563eb, #7c3aed);
}

/* Reset & Base */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html, body {
    height: 100%;
}

/* Only hide overflow on pages with app-container (coordinator dashboard) */
body.no-scroll {
    overflow: hidden;
}

body {
    font-family: var(--font-primary);
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.5;
}

/* App Container */
.app-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    background: var(--bg-primary);
    transition: background-color 0.3s ease;
}

:root[data-theme="dark"] .app-container {
    background: 
        radial-gradient(ellipse at top left, rgba(59, 130, 246, 0.08) 0%, transparent 50%),
        radial-gradient(ellipse at bottom right, rgba(139, 92, 246, 0.08) 0%, transparent 50%),
        var(--bg-primary);
}

:root[data-theme="light"] .app-container {
    background: 
        radial-gradient(ellipse at top left, rgba(37, 99, 235, 0.05) 0%, transparent 50%),
        radial-gradient(ellipse at bottom right, rgba(124, 58, 237, 0.05) 0%, transparent 50%),
        var(--bg-primary);
}

/* Compact Stats */
.stats-compact {
    display: flex;
    gap: var(--space-md);
    margin-left: auto;
}

.stat-compact {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.stat-compact strong {
    color: var(--accent-primary);
    font-family: var(--font-mono);
}

/* Theme Switch - Compact */
.theme-switch {
    cursor: pointer;
    flex-shrink: 0;
}

.theme-switch-track {
    position: relative;
    width: 52px;
    height: 26px;
    background: linear-gradient(135deg, #1e3a5f 0%, #0f172a 100%);
    border-radius: 13px;
    padding: 2px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.3);
    transition: all 0.3s ease;
}

:root[data-theme="light"] .theme-switch-track {
    background: linear-gradient(135deg, #60a5fa 0%, #3b82f6 100%);
}

.theme-switch-icon {
    font-size: 11px;
    z-index: 1;
    transition: all 0.3s ease;
    padding: 0 5px;
}

.theme-switch-icon.sun {
    opacity: 0.4;
}

.theme-switch-icon.moon {
    opacity: 1;
}

:root[data-theme="light"] .theme-switch-icon.sun {
    opacity: 1;
}

:root[data-theme="light"] .theme-switch-icon.moon {
    opacity: 0.4;
}

.theme-switch-thumb {
    position: absolute;
    width: 22px;
    height: 22px;
    background: linear-gradient(135deg, #f0f4f8 0%, #e2e8f0 100%);
    border-radius: 50%;
    top: 2px;
    left: 2px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
    transition: all 0.3s cubic-bezier(0.68, -0.15, 0.32, 1.15);
}

:root[data-theme="light"] .theme-switch-thumb {
    left: calc(100% - 24px);
    background: linear-gradient(135deg, #fbbf24 0%, #f59e0b 100%);
    box-shadow: 0 1px 4px rgba(245, 158, 11, 0.4);
}

.theme-switch:hover .theme-switch-thumb {
    transform: scale(1.05);
}

/* Main Content */
.main-content {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* Map Section - defined with #map below */

.map-controls {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    padding: var(--space-sm) var(--space-md);
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    transition: background-color 0.3s ease, border-color 0.3s ease;
}

.control-group {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.control-group select,
.control-group input {
    padding: 6px 10px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: var(--font-primary);
    font-size: 0.8rem;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s, background-color 0.3s ease;
}

.control-group select:focus,
.control-group input:focus {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 2px var(--accent-glow);
}

.control-group select {
    min-width: 160px;
    cursor: pointer;
}

.control-group input {
    min-width: 180px;
}

/* Map */
#map {
    flex: 1;
    min-height: 0;
    height: 100%;
    width: 100%;
    background: var(--bg-tertiary);
}

.map-section {
    flex: 1;
    display: flex;
    flex-direction: column;
    position: relative;
    min-height: 0;
    overflow: hidden;
}

/* Custom Leaflet Styles */
.leaflet-container {
    background: var(--bg-tertiary);
    font-family: var(--font-primary);
}

.leaflet-popup-content-wrapper {
    background: var(--bg-card);
    color: var(--text-primary);
    border-radius: var(--radius-md);
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
    border: 1px solid var(--border-color);
}

.leaflet-popup-tip {
    background: var(--bg-card);
}

.leaflet-popup-content {
    margin: var(--space-md);
    font-size: 0.875rem;
}

.popup-title {
    font-weight: 600;
    font-size: 1rem;
    margin-bottom: var(--space-xs);
    color: var(--accent-primary);
}

.popup-subtitle {
    color: var(--text-secondary);
    font-size: 0.8rem;
    margin-bottom: var(--space-sm);
}

.popup-stats {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-xs);
}

.popup-stat {
    display: flex;
    justify-content: space-between;
    padding: var(--space-xs) 0;
    border-bottom: 1px solid var(--border-color);
}

.popup-stat:last-child {
    border-bottom: none;
}

/* Legend */
.legend {
    position: absolute;
    bottom: var(--space-lg);
    left: var(--space-lg);
    background: var(--bg-card);
    padding: var(--space-md);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    z-index: 1000;
    min-width: 160px;
}

.legend h4 {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: var(--space-sm);
}

.legend-item {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-xs) 0;
    font-size: 0.8rem;
}

.legend-color {
    width: 16px;
    height: 16px;
    border-radius: 3px;
    border: 1px solid rgba(255,255,255,0.2);
}

/* Sidebar */
.sidebar {
    width: 360px;
    background: var(--bg-secondary);
    border-left: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: background-color 0.3s ease, border-color 0.3s ease;
}

.panel {
    padding: var(--space-md);
    border-bottom: 1px solid var(--border-color);
}

.panel h3 {
    font-size: 0.875rem;
    font-weight: 600;
    margin-bottom: var(--space-md);
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

/* Info Panel */
.info-panel .hint {
    color: var(--text-muted);
    font-size: 0.875rem;
    font-style: italic;
}

.bm-details.hidden {
    display: none;
}

.bm-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-sm);
}

.bm-number {
    font-family: var(--font-mono);
    font-size: 0.875rem;
    color: var(--accent-primary);
    background: var(--bg-tertiary);
    padding: var(--space-xs) var(--space-sm);
    border-radius: var(--radius-sm);
}

.bm-status {
    font-size: 1.25rem;
}

.bm-status.ok { color: var(--status-ok); }
.bm-status.wait { color: var(--status-wait); }
.bm-status.warn { color: var(--status-warn); }
.bm-status.alert { color: var(--status-alert); }

#bmName {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: var(--space-xs);
    line-height: 1.3;
}

.bm-location {
    font-size: 0.875rem;
    color: var(--accent-primary);
    margin-bottom: var(--space-xs);
    font-weight: 500;
}

.bm-address {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-bottom: var(--space-md);
}

.field-notes {
    background: var(--bg-tertiary);
    border-left: 3px solid var(--status-warn);
    padding: var(--space-sm) var(--space-md);
    margin-bottom: var(--space-md);
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

.field-notes.hidden {
    display: none;
}

.field-notes-label {
    font-size: 0.7rem;
    color: var(--status-warn);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    display: block;
    margin-bottom: var(--space-xs);
}

.field-notes p {
    font-size: 0.8rem;
    color: var(--text-secondary);
    line-height: 1.4;
    margin: 0;
}

.bm-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--space-sm);
    margin-bottom: var(--space-md);
}

.bm-stat {
    background: var(--bg-tertiary);
    padding: var(--space-sm);
    border-radius: var(--radius-sm);
    text-align: center;
}

.bm-stat .label {
    display: block;
    font-size: 0.7rem;
    color: var(--text-muted);
    text-transform: uppercase;
    margin-bottom: 2px;
}

.bm-stat .value {
    font-family: var(--font-mono);
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
}

.status-buttons h5 {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-bottom: var(--space-sm);
}

.btn-group {
    display: flex;
    gap: var(--space-sm);
}

.status-btn {
    flex: 1;
    padding: var(--space-sm);
    border: 2px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: var(--bg-tertiary);
    font-size: 1.25rem;
    cursor: pointer;
    transition: all 0.2s;
}

.status-btn:hover {
    transform: translateY(-2px);
}

.status-btn.ok:hover, .status-btn.ok.active {
    border-color: var(--status-ok);
    background: rgba(16, 185, 129, 0.2);
}

.status-btn.wait:hover, .status-btn.wait.active {
    border-color: var(--status-wait);
    background: rgba(245, 158, 11, 0.2);
}

.status-btn.warn:hover, .status-btn.warn.active {
    border-color: var(--status-warn);
    background: rgba(249, 115, 22, 0.2);
}

.status-btn.alert:hover, .status-btn.alert.active {
    border-color: var(--status-alert);
    background: rgba(239, 68, 68, 0.2);
}

.notes-section {
    margin-top: var(--space-md);
}

.notes-section label {
    display: block;
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-bottom: var(--space-xs);
}

.notes-section textarea {
    width: 100%;
    height: 80px;
    padding: var(--space-sm);
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: var(--font-primary);
    font-size: 0.875rem;
    resize: none;
    outline: none;
}

.notes-section textarea:focus {
    border-color: var(--accent-primary);
}

.btn-save {
    margin-top: var(--space-sm);
    padding: var(--space-sm) var(--space-md);
    background: var(--accent-primary);
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    font-family: var(--font-primary);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s;
}

.btn-save:hover {
    background: var(--accent-secondary);
}

/* List Panel */
.list-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-md);
}

.panel-header h3 {
    margin-bottom: 0;
}

.filter-buttons {
    display: flex;
    gap: var(--space-xs);
}

.filter-btn {
    padding: var(--space-xs) var(--space-sm);
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 0.75rem;
    cursor: pointer;
    transition: all 0.2s;
}

.filter-btn:hover,
.filter-btn.active {
    background: var(--accent-primary);
    border-color: var(--accent-primary);
    color: white;
}

.bm-list {
    flex: 1;
    overflow-y: auto;
    margin: 0 calc(-1 * var(--space-md));
    padding: 0 var(--space-md);
}

.bm-list-item {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-sm);
    margin-bottom: var(--space-xs);
    background: var(--bg-tertiary);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.2s;
    border: 1px solid transparent;
}

.bm-list-item:hover {
    background: var(--bg-card);
    border-color: var(--border-color);
}

.bm-list-item.selected {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 2px var(--accent-glow);
}

.bm-list-item .bm-num {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: var(--accent-primary);
    min-width: 40px;
}

.bm-list-item .bm-name {
    flex: 1;
    font-size: 0.8rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.bm-list-item .bm-voters {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: var(--text-muted);
}

.bm-list-item .bm-indicator {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text-muted);
}

.bm-list-item .bm-indicator.ok { background: var(--status-ok); }
.bm-list-item .bm-indicator.wait { background: var(--status-wait); }
.bm-list-item .bm-indicator.warn { background: var(--status-warn); }
.bm-list-item .bm-indicator.alert { background: var(--status-alert); }

/* Scrollbar */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-secondary);
}

::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* Light theme Leaflet popup */
:root[data-theme="light"] .leaflet-popup-content-wrapper {
    background: var(--bg-card);
    color: var(--text-primary);
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
}

:root[data-theme="light"] .leaflet-popup-tip {
    background: var(--bg-card);
}

/* ============================================
   RESPONSIVE - TABLET
   ============================================ */
@media (max-width: 1024px) {
    /* Coordinator dashboard tablet adjustments */
    .app-container .main-content {
        flex-direction: column;
    }
    
    .app-container .sidebar {
        width: 100%;
        max-height: 40vh;
    }
    
    .app-container .map-section {
        min-height: 50vh;
    }
}

/* ============================================
   MOBILE INTERFACE - COMPLETE REWRITE
   Clean, native-feeling mobile experience
   ============================================ */
@media (max-width: 768px) {
    /* === RESET FOR MOBILE - Only for coordinator dashboard === */
    body.no-scroll {
        overflow: hidden;
        position: fixed;
        width: 100%;
        height: 100%;
    }
    
    body.no-scroll html {
        overflow: hidden;
    }
    
    .app-container {
        height: 100%;
        height: 100dvh; /* Dynamic viewport height for mobile browsers */
    }
    
    /* === HEADER - Minimal bar (ONLY for coordinator dashboard) === */
    .app-container .header {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        z-index: 100;
        height: 48px;
        min-height: 48px;
        padding: 0 12px;
        gap: 8px;
        flex-wrap: nowrap;
        align-items: center;
        background: var(--bg-secondary);
        border-bottom: none;
    }
    
    .app-container .header-brand h1 {
        font-size: 0.95rem;
        white-space: nowrap;
    }
    
    .app-container .municipality-selector {
        flex: 1;
        min-width: 0;
        margin: 0;
        overflow: hidden;
    }
    
    .app-container .municipality-selector label {
        display: none;
    }
    
    .app-container .municipality-selector select,
    .app-container .municipality-selector span {
        width: 100%;
        padding: 6px 10px;
        font-size: 14px;
        border-radius: 8px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    
    .app-container .stats-compact,
    .app-container .admin-link,
    .app-container .theme-switch {
        display: none !important;
    }
    
    .app-container #userMenuContainer {
        flex-shrink: 0;
    }
    
    .app-container .user-info {
        padding: 4px;
    }
    
    .app-container .user-avatar {
        width: 32px;
        height: 32px;
    }
    
    .app-container .user-name,
    .app-container .dropdown-arrow {
        display: none;
    }
    
    /* === MAIN CONTENT (coordinator dashboard only) === */
    .app-container .main-content {
        flex-direction: column;
        padding-top: 48px; /* Header height */
        padding-bottom: 48px; /* Collapsed sidebar height */
        height: 100%;
    }
    
    /* === MAP SECTION - Full screen behind bottom sheet === */
    .app-container .map-section {
        position: fixed;
        top: 48px;
        left: 0;
        right: 0;
        bottom: 0;
        min-height: unset;
        z-index: 1;
    }
    
    /* === MAP CONTROLS - Floating pills === */
    .app-container .map-controls {
        position: absolute;
        top: 8px;
        left: 8px;
        right: 8px;
        z-index: 1000; /* Above map tiles */
        background: transparent;
        border: none;
        padding: 0;
        gap: 6px;
        flex-wrap: wrap;
        pointer-events: none; /* Allow map interaction through gaps */
    }
    
    .app-container .control-group {
        background: var(--bg-card);
        border-radius: 20px;
        padding: 0;
        box-shadow: 0 2px 8px rgba(0,0,0,0.25);
        border: 1px solid var(--border-color);
        pointer-events: auto; /* Re-enable for controls */
    }
    
    .app-container .control-group select,
    .app-container .control-group input {
        background: transparent;
        border: none;
        padding: 10px 14px;
        font-size: 14px;
        min-width: unset;
        border-radius: 20px;
    }
    
    .app-container .control-group select:focus,
    .app-container .control-group input:focus {
        box-shadow: none;
    }
    
    .app-container .control-group input {
        width: 150px;
    }
    
    .app-container .control-group input::placeholder {
        color: var(--text-muted);
    }
    
    /* Location toggle */
    .app-container .location-toggle .toggle-label {
        background: transparent;
        border: none;
        padding: 10px 14px;
        border-radius: 20px;
    }
    
    /* === LEGEND - Hidden on mobile for dashboard === */
    .app-container .legend {
        display: none !important;
    }
    
    /* === SIDEBAR - Native bottom sheet === */
    .app-container .sidebar {
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        width: 100%;
        max-height: 50vh; /* Maximum half screen */
        height: 50vh;
        z-index: 50;
        background: var(--bg-secondary);
        border: none;
        border-radius: 20px 20px 0 0;
        box-shadow: 0 -2px 20px rgba(0,0,0,0.2);
        transform: translateY(0);
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        display: flex;
        flex-direction: column;
        overflow: hidden;
    }
    
    /* Collapsed state - show handle only */
    .app-container .sidebar.collapsed {
        transform: translateY(calc(100% - 48px));
    }
    
    /* Drag handle area - touch target */
    .app-container .sidebar-handle {
        display: flex !important;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        width: 100%;
        height: 48px;
        min-height: 48px;
        padding: 0;
        cursor: grab;
        touch-action: none;
        flex-shrink: 0;
        background: var(--bg-secondary);
    }
    
    .app-container .sidebar-handle::before {
        content: '';
        width: 40px;
        height: 4px;
        background: var(--text-muted);
        border-radius: 2px;
        opacity: 0.5;
    }
    
    .app-container .sidebar-handle:active {
        cursor: grabbing;
    }
    
    .app-container .sidebar-handle:active::before {
        opacity: 1;
        background: var(--accent-primary);
    }
    
    /* === PANELS inside sidebar (coordinator dashboard only) === */
    .app-container .panel {
        padding: 0 16px 16px;
    }
    
    .app-container .panel h3 {
        font-size: 15px;
        font-weight: 600;
        margin-bottom: 12px;
    }
    
    /* Info panel - shown when BM selected */
    .app-container .info-panel {
        display: none;
        border-bottom: 1px solid var(--border-color);
        padding-bottom: 12px;
        margin-bottom: 8px;
    }
    
    .app-container .info-panel.visible {
        display: block;
    }
    
    .app-container .info-panel .hint {
        display: none;
    }
    
    .app-container .bm-details {
        display: block !important;
    }
    
    .app-container .bm-header {
        margin-bottom: 8px;
    }
    
    .app-container .bm-number {
        font-size: 13px;
        padding: 4px 8px;
    }
    
    .app-container .close-details-btn {
        width: 32px;
        height: 32px;
    }
    
    .app-container #bmName {
        font-size: 15px;
        margin-bottom: 4px;
    }
    
    .app-container .bm-location {
        font-size: 13px;
        margin-bottom: 2px;
    }
    
    .app-container .bm-address {
        font-size: 12px;
        margin-bottom: 12px;
    }
    
    .app-container .bm-stats {
        grid-template-columns: repeat(3, 1fr);
        gap: 8px;
    }
    
    .app-container .bm-stat {
        padding: 8px;
        border-radius: 8px;
    }
    
    .app-container .bm-stat .label {
        font-size: 10px;
    }
    
    .app-container .bm-stat .value {
        font-size: 16px;
    }
    
    .app-container .notes-section {
        display: none; /* Use fullscreen table for notes on mobile */
    }
    
    /* === LIST PANEL === */
    .app-container .list-panel {
        flex: 1;
        display: flex;
        flex-direction: column;
        min-height: 0;
        overflow: hidden;
    }
    
    .app-container .panel-header {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 0 16px;
        margin-bottom: 8px;
        flex-shrink: 0;
    }
    
    .app-container .panel-header h3 {
        margin: 0;
        font-size: 15px;
    }
    
    .app-container .fullscreen-table-btn {
        padding: 8px 14px;
        font-size: 13px;
        border-radius: 16px;
    }
    
    /* BM List - scrollable */
    .app-container .bm-list {
        flex: 1;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        padding: 0 16px 20px;
        margin: 0;
    }
    
    .app-container .bm-list-item {
        display: flex;
        align-items: center;
        padding: 14px 12px;
        margin-bottom: 6px;
        border-radius: 12px;
        min-height: 50px;
        background: var(--bg-tertiary);
    }
    
    .app-container .bm-list-item:active {
        transform: scale(0.98);
        opacity: 0.9;
    }
    
    .app-container .bm-list-item .bm-num {
        font-size: 14px;
        font-weight: 600;
        min-width: 36px;
    }
    
    .app-container .bm-list-item .bm-name {
        font-size: 14px;
        line-height: 1.3;
    }
    
    .app-container .bm-list-item .bm-voters {
        font-size: 13px;
        white-space: nowrap;
        margin-left: 8px;
    }
    
    .app-container .bm-list-item .bm-indicator {
        width: 10px;
        height: 10px;
        margin-left: 8px;
        flex-shrink: 0;
    }
    
    /* === NO DATA MESSAGE === */
    .app-container .no-data-message {
        padding: 40px 24px;
    }
    
    .app-container .no-data-message .icon {
        font-size: 48px;
        margin-bottom: 16px;
    }
    
    .app-container .no-data-message h2 {
        font-size: 20px;
        margin-bottom: 8px;
    }
    
    .app-container .no-data-message p {
        font-size: 15px;
        line-height: 1.5;
    }
    
    /* === USER DROPDOWN (global for all pages) === */
    .user-dropdown {
        position: fixed;
        top: 52px;
        right: 8px;
        left: auto;
        min-width: 220px;
        border-radius: 12px;
    }
}

/* ============================================
   SMALL MOBILE (iPhone SE, etc) - Coordinator dashboard
   ============================================ */
@media (max-width: 380px) {
    .app-container .header {
        padding: 0 8px;
    }
    
    .app-container .header-brand h1 {
        font-size: 0.9rem;
    }
    
    .app-container .control-group input {
        width: 120px;
    }
    
    .app-container .bm-list-item {
        padding: 12px 10px;
    }
    
    .app-container .bm-list-item .bm-name {
        font-size: 13px;
    }
}

/* ============================================
   USER MENU STYLES
   ============================================ */

.user-menu {
    position: relative;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    padding: 8px 12px;
    border-radius: 8px;
    transition: background 0.2s;
}

.user-info:hover {
    background: var(--bg-tertiary);
}

.user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
}

.user-name {
    font-size: 0.9rem;
}

.dropdown-arrow {
    font-size: 0.7rem;
    color: var(--text-muted);
}

.user-dropdown {
    display: none;
    position: absolute;
    top: 100%;
    right: 0;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    min-width: 200px;
    margin-top: 8px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.3);
    z-index: 100;
}

.user-dropdown.active {
    display: block;
}

.dropdown-header {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-color);
}

.dropdown-header strong {
    display: block;
}

.dropdown-header small {
    color: var(--text-muted);
    font-size: 0.8rem;
}

.user-role {
    display: inline-block;
    margin-top: 4px;
    font-size: 0.75rem;
    padding: 2px 8px;
    background: var(--accent-primary);
    color: white;
    border-radius: 10px;
}

.dropdown-item {
    display: block;
    width: 100%;
    padding: 10px 16px;
    background: none;
    border: none;
    text-align: left;
    color: var(--text-primary);
    font-family: var(--font-primary);
    font-size: 0.9rem;
    cursor: pointer;
    transition: background 0.2s;
}

.dropdown-item:hover {
    background: var(--bg-tertiary);
}

.dropdown-divider {
    height: 1px;
    background: var(--border-color);
}

.logout-btn:hover {
    background: rgba(239, 68, 68, 0.15);
    color: var(--status-alert);
}

/* ============================================
   ADMIN PAGES - MOBILE RESPONSIVE
   ============================================ */
@media (max-width: 768px) {
    /* Allow normal scrolling on admin pages */
    body:not(.no-scroll) {
        min-height: 100vh;
        min-height: 100dvh;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    /* Admin container */
    body:not(.no-scroll) .container {
        padding: 16px;
    }
    
    /* Admin header */
    body:not(.no-scroll) .header {
        flex-direction: column;
        gap: 12px;
        padding-bottom: 16px;
        margin-bottom: 20px;
    }
    
    body:not(.no-scroll) .header-left {
        width: 100%;
        flex-direction: column;
        gap: 12px;
    }
    
    body:not(.no-scroll) .header-left .logo {
        font-size: 1.4rem;
    }
    
    body:not(.no-scroll) .header-left .back-link {
        font-size: 0.85rem;
        padding: 6px 12px;
    }
    
    /* Stats cards */
    body:not(.no-scroll) .stats-row {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
    }
    
    body:not(.no-scroll) .stat-card {
        padding: 16px;
    }
    
    body:not(.no-scroll) .stat-value {
        font-size: 1.5rem;
    }
    
    body:not(.no-scroll) .stat-label {
        font-size: 0.75rem;
    }
    
    /* Tables - horizontal scroll */
    body:not(.no-scroll) .table-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    body:not(.no-scroll) table {
        min-width: 600px;
    }
    
    body:not(.no-scroll) th,
    body:not(.no-scroll) td {
        padding: 10px 12px;
        font-size: 0.85rem;
    }
    
    /* Filters */
    body:not(.no-scroll) .filters {
        flex-direction: column;
        gap: 12px;
    }
    
    body:not(.no-scroll) .filter-group {
        width: 100%;
    }
    
    body:not(.no-scroll) .filter-group input,
    body:not(.no-scroll) .filter-group select {
        flex: 1;
        min-width: unset;
        width: 100%;
    }
    
    /* Upload section */
    body:not(.no-scroll) .upload-section {
        padding: 16px;
    }
    
    body:not(.no-scroll) .upload-row {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }
    
    body:not(.no-scroll) .upload-row label {
        min-width: unset;
    }
    
    body:not(.no-scroll) .upload-row select,
    body:not(.no-scroll) .upload-row input {
        width: 100%;
    }
    
    body:not(.no-scroll) .file-type-tabs {
        flex-wrap: wrap;
        gap: 6px;
    }
    
    body:not(.no-scroll) .file-type-tab {
        padding: 6px 12px;
        font-size: 0.8rem;
    }
    
    /* Request cards (admin-users) */
    body:not(.no-scroll) .request-card {
        padding: 16px;
    }
    
    body:not(.no-scroll) .request-header {
        flex-wrap: wrap;
    }
    
    body:not(.no-scroll) .request-avatar {
        width: 40px;
        height: 40px;
    }
    
    body:not(.no-scroll) .request-actions {
        flex-direction: column;
        gap: 8px;
    }
    
    body:not(.no-scroll) .request-actions .btn {
        width: 100%;
        justify-content: center;
    }
    
    body:not(.no-scroll) .request-actions .municipality-select {
        width: 100%;
    }
    
    /* Section titles */
    body:not(.no-scroll) .section-title {
        font-size: 1.1rem;
    }
    
    /* User cell in tables */
    body:not(.no-scroll) .user-cell {
        min-width: 150px;
    }
    
    body:not(.no-scroll) .user-cell img {
        width: 32px;
        height: 32px;
    }
    
    /* Legend row */
    body:not(.no-scroll) .legend {
        gap: 12px;
    }
    
    body:not(.no-scroll) .legend-item {
        font-size: 0.75rem;
    }
    
    /* Toast position */
    body:not(.no-scroll) .toast {
        left: 16px;
        right: 16px;
        bottom: 16px;
    }
}

/* Very small screens */
@media (max-width: 380px) {
    body:not(.no-scroll) .container {
        padding: 12px;
    }
    
    body:not(.no-scroll) .stats-row {
        grid-template-columns: 1fr;
    }
    
    body:not(.no-scroll) .header-left .logo {
        font-size: 1.2rem;
    }
}

