/* Reset y Variables */
* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
    --primary-color: #7c3aed;
    --secondary-color: #a78bfa;
    --accent-color: #f43f5e;
    --bg-color: #0f0f0f;
    --card-bg: #1a1a2e;
    --text-primary: #e4e4e7;
    --text-secondary: #9ca3af;
    --border-color: #2d2d44;
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.4);
    --green: #10b981;
    --red: #ef4444;
    --yellow: #f59e0b;
    --blue: #3b82f6;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-primary);
    line-height: 1.6;
    -webkit-tap-highlight-color: transparent;
    overscroll-behavior: none;
}

.app-container { min-height: 100vh; display: flex; flex-direction: column; }

/* ========== HEADER ========== */
.app-header {
    background: linear-gradient(135deg, #16162a 0%, #1e1b4b 50%, #312e81 100%);
    color: white;
    padding: 1rem 1.5rem;
    box-shadow: 0 4px 20px rgba(0,0,0,0.5);
    position: sticky;
    top: 0;
    z-index: 100;
    border-bottom: 1px solid rgba(124,58,237,0.3);
}

.header-content {
    max-width: 1600px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
}

.logo-section { display: flex; align-items: center; gap: 1rem; }
.title-section h1 { font-size: 1.25rem; font-weight: 700; white-space: nowrap; }

.header-actions { display: flex; align-items: center; gap: 0.75rem; flex: 1; justify-content: flex-end; }

.search-box { position: relative; width: 100%; max-width: 350px; }
.search-box input {
    width: 100%; padding: 0.625rem 1rem 0.625rem 2.75rem;
    border: 1px solid var(--border-color); border-radius: 50px; font-size: 0.875rem;
    background: rgba(15,15,15,0.8); color: var(--text-primary); outline: none;
    transition: all 0.3s ease;
}
.search-box input::placeholder { color: var(--text-secondary); }
.search-box input:focus { background: rgba(26,26,46,0.95); box-shadow: 0 0 0 3px rgba(124,58,237,0.3); border-color: var(--primary-color); }
.search-icon { position: absolute; left: 0.875rem; top: 50%; transform: translateY(-50%); color: var(--text-secondary); }

/* Toolbar */
.header-toolbar { display: flex; gap: 0.375rem; }
.toolbar-btn {
    display: flex; align-items: center; gap: 0.375rem;
    padding: 0.5rem 0.75rem; background: rgba(255,255,255,0.06);
    border: 1px solid var(--border-color); border-radius: 0.5rem;
    color: var(--text-secondary); cursor: pointer; font-size: 0.75rem;
    font-weight: 600; transition: all 0.2s; white-space: nowrap;
}
.toolbar-btn:hover { color: white; border-color: var(--primary-color); background: rgba(124,58,237,0.15); }
.toolbar-btn.active { color: white; background: var(--primary-color); border-color: var(--primary-color); }
.toolbar-label { display: none; }
@media (min-width: 900px) { .toolbar-label { display: inline; } }

/* ========== SIDEBAR ========== */
.main-content { display: flex; flex: 1; max-width: 1600px; width: 100%; margin: 0 auto; }

.sidebar {
    width: 260px; background: #12121f; border-right: 1px solid var(--border-color);
    overflow-y: auto; height: calc(100vh - 70px); position: sticky; top: 70px;
}
.sidebar-header { padding: 1.25rem; border-bottom: 1px solid var(--border-color); }
.sidebar-header h2 { font-size: 1rem; font-weight: 600; margin-bottom: 0.375rem; }
.camera-count { display: inline-block; padding: 0.2rem 0.6rem; background: var(--primary-color); color: white; border-radius: 50px; font-size: 0.7rem; font-weight: 600; }
.municipality-nav { padding: 0.25rem 0; }
.municipality-item {
    display: flex; align-items: center; justify-content: space-between;
    padding: 0.625rem 1.25rem; cursor: pointer; transition: all 0.2s;
    border-left: 3px solid transparent; font-size: 0.875rem;
}
.municipality-item:hover { background: rgba(124,58,237,0.1); border-left-color: var(--secondary-color); }
.municipality-item.active { background: linear-gradient(90deg,rgba(124,58,237,0.3),transparent); color: white; border-left-color: var(--primary-color); font-weight: 600; }
.municipality-badge { display: inline-block; padding: 0.1rem 0.4rem; background: var(--border-color); border-radius: 50px; font-size: 0.7rem; font-weight: 600; }
.municipality-item.active .municipality-badge { background: rgba(255,255,255,0.3); color: white; }

/* ========== CAMERA SECTION ========== */
.camera-section { flex: 1; padding: 1.5rem; overflow-y: auto; }
.section-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1.5rem; }
.section-header h2 { font-size: 1.25rem; font-weight: 700; }
.view-controls { display: flex; gap: 0.375rem; }
.view-btn {
    padding: 0.4rem; background: var(--card-bg); border: 1px solid var(--border-color);
    border-radius: 0.5rem; cursor: pointer; transition: all 0.2s; display: flex; align-items: center; justify-content: center;
}
.view-btn:hover { background: var(--bg-color); border-color: var(--primary-color); }
.view-btn.active, .view-btn.active-mode { background: var(--primary-color); border-color: var(--primary-color); color: white; }
.view-btn svg { stroke: currentColor; }

/* Camera Grid */
.camera-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 1.25rem; }
.camera-grid.list-view { grid-template-columns: 1fr; }

.camera-card {
    background: var(--card-bg); border-radius: 0.875rem; overflow: hidden;
    box-shadow: var(--shadow-md); transition: all 0.3s ease; cursor: pointer;
    border: 1px solid var(--border-color);
}
.camera-card:hover { transform: translateY(-3px); box-shadow: 0 12px 30px rgba(124,58,237,0.15); border-color: rgba(124,58,237,0.4); }
.camera-card:active { transform: translateY(-1px); }

.camera-preview { position: relative; width: 100%; padding-top: 56.25%; background: linear-gradient(135deg,#1e1b4b,#312e81); overflow: hidden; }
.camera-preview video, .camera-preview img { position: absolute; top: 0; left: 0; width: 100%; height: 100%; object-fit: cover; }
.camera-placeholder { position: absolute; top: 0; left: 0; width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; background: linear-gradient(135deg,#1e1b4b,#312e81); }
.camera-placeholder svg { width: 48px; height: 48px; color: rgba(255,255,255,0.5); }
.camera-status { position: absolute; top: 0.75rem; right: 0.75rem; padding: 0.3rem 0.6rem; background: rgba(16,185,129,0.9); backdrop-filter: blur(10px); color: white; border-radius: 50px; font-size: 0.7rem; font-weight: 600; display: flex; align-items: center; gap: 0.3rem; }
.status-dot { width: 7px; height: 7px; border-radius: 50%; background: white; animation: pulse 2s infinite; }
.status-dot.dot-inactive { background: #fca5a5; animation: none; }
@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:0.5} }

.camera-card.camera-inactive { opacity: 0.55; filter: grayscale(40%); }
.camera-card.camera-inactive:hover { opacity: 0.8; filter: grayscale(20%); }
.camera-status.status-inactive { background: rgba(239,68,68,0.85); }

.inactive-overlay { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 3rem 2rem; text-align: center; color: var(--text-secondary); background: var(--card-bg); border-radius: 12px; min-height: 250px; }
.inactive-overlay svg { margin-bottom: 1rem; opacity: 0.5; color: #ef4444; }
.inactive-overlay h3 { font-size: 1.1rem; color: #ef4444; margin-bottom: 0.375rem; }
.inactive-overlay p { max-width: 380px; line-height: 1.5; font-size: 0.875rem; }

.camera-info { padding: 1rem; }
.camera-name { font-size: 0.9rem; font-weight: 600; margin-bottom: 0.375rem; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.camera-location { display: flex; align-items: start; gap: 0.375rem; color: var(--text-secondary); font-size: 0.8rem; margin-bottom: 0.5rem; }
.camera-location svg { flex-shrink: 0; margin-top: 0.1rem; }
.camera-municipality { display: inline-block; padding: 0.2rem 0.6rem; background: rgba(124,58,237,0.15); color: var(--secondary-color); border-radius: 50px; font-size: 0.7rem; font-weight: 600; }

.list-view .camera-card { display: flex; flex-direction: row; }
.list-view .camera-preview { width: 260px; padding-top: 0; height: 160px; }
.list-view .camera-info { flex: 1; display: flex; flex-direction: column; justify-content: center; }

/* Loading */
.loading { display: none; flex-direction: column; align-items: center; justify-content: center; padding: 4rem 2rem; }
.loading.active { display: flex; }
.spinner { width: 40px; height: 40px; border: 3px solid var(--border-color); border-top-color: var(--primary-color); border-radius: 50%; animation: spin 1s linear infinite; }
@keyframes spin { to{transform:rotate(360deg)} }
.loading p { margin-top: 0.75rem; color: var(--text-secondary); font-size: 0.875rem; }

/* ========== MODAL ========== */
.modal { display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.92); z-index: 1000; align-items: center; justify-content: center; padding: 1rem; }
.modal.active { display: flex; }
.modal-content { background: #16162a; border-radius: 1rem; max-width: 1100px; width: 100%; max-height: 92vh; overflow: hidden; position: relative; box-shadow: 0 25px 50px rgba(0,0,0,0.7); border: 1px solid var(--border-color); }
.modal-close { position: absolute; top: 0.75rem; right: 0.75rem; width: 36px; height: 36px; border: none; background: rgba(0,0,0,0.5); backdrop-filter: blur(10px); color: white; font-size: 1.25rem; border-radius: 50%; cursor: pointer; z-index: 10; display: flex; align-items: center; justify-content: center; transition: all 0.2s; }
.modal-close:hover { background: rgba(0,0,0,0.7); transform: rotate(90deg); }
.modal-header { padding: 1.25rem 1.5rem; border-bottom: 1px solid var(--border-color); display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.modal-header-text { flex: 1; min-width: 0; }
.modal-header h2 { font-size: 1.2rem; font-weight: 700; margin-bottom: 0.25rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding-right: 2.5rem; }
.modal-header p { color: var(--text-secondary); font-size: 0.8rem; }
.modal-actions { display: flex; gap: 0.375rem; flex-shrink: 0; }
.modal-action-btn {
    width: 38px; height: 38px; border-radius: 0.5rem; border: 1px solid var(--border-color);
    background: rgba(255,255,255,0.05); color: var(--text-secondary); cursor: pointer;
    display: flex; align-items: center; justify-content: center; transition: all 0.2s;
}
.modal-action-btn:hover { color: white; border-color: var(--primary-color); background: rgba(124,58,237,0.2); }
.modal-action-btn.recording { color: var(--red); border-color: var(--red); background: rgba(239,68,68,0.15); animation: recPulse 1s ease infinite; }
@keyframes recPulse { 0%,100%{opacity:1} 50%{opacity:0.6} }

.modal-body { padding: 1.25rem; }
.video-container { position: relative; width: 100%; padding-top: 56.25%; background: #000; border-radius: 0.5rem; overflow: hidden; }
.video-container video { position: absolute; top: 0; left: 0; width: 100%; height: 100%; transition: transform 0.15s ease-out; transform-origin: center center; }

/* Recording Indicator */
.recording-indicator { position: absolute; top: 12px; left: 12px; display: none; align-items: center; gap: 6px; background: rgba(0,0,0,0.7); backdrop-filter: blur(8px); padding: 4px 10px; border-radius: 20px; z-index: 15; font-size: 0.75rem; font-weight: 700; color: white; }
.recording-indicator.active { display: flex; }
.rec-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--red); animation: recBlink 1s ease infinite; }
@keyframes recBlink { 0%,100%{opacity:1} 50%{opacity:0.2} }
.rec-text { color: var(--red); }

/* Screenshot Flash */
.screenshot-flash { position: absolute; top: 0; left: 0; width: 100%; height: 100%; background: white; opacity: 0; pointer-events: none; z-index: 20; transition: opacity 0.1s; }
.screenshot-flash.flash { opacity: 0.6; transition: none; }

/* ========== PTZ ========== */
.ptz-controls { position: absolute; bottom: 50px; right: 12px; display: flex; flex-direction: column; align-items: center; gap: 10px; z-index: 15; opacity: 0; transition: opacity 0.3s ease; pointer-events: none; }
.video-container:hover .ptz-controls, .ptz-controls.ptz-active { opacity: 1; pointer-events: auto; }
.ptz-dpad { display: grid; grid-template-areas: ". up ." "left ctr right" ". down ."; grid-template-columns: 34px 34px 34px; grid-template-rows: 34px 34px 34px; gap: 2px; }
.ptz-btn { display: flex; align-items: center; justify-content: center; border: none; border-radius: 50%; background: rgba(0,0,0,0.65); backdrop-filter: blur(8px); color: white; cursor: pointer; transition: all 0.15s; padding: 0; }
.ptz-btn svg { width: 16px; height: 16px; }
.ptz-btn:hover { background: rgba(99,102,241,0.8); transform: scale(1.1); }
.ptz-btn:active { background: rgba(99,102,241,1); transform: scale(0.95); }
.ptz-up { grid-area: up; } .ptz-down { grid-area: down; } .ptz-left { grid-area: left; } .ptz-right { grid-area: right; }
.ptz-center { grid-area: ctr; background: rgba(0,0,0,0.75); border: 2px solid rgba(255,255,255,0.2); }
.ptz-center:hover { border-color: rgba(99,102,241,0.8); background: rgba(99,102,241,0.5); }
.ptz-zoom { display: flex; align-items: center; gap: 5px; background: rgba(0,0,0,0.65); backdrop-filter: blur(8px); border-radius: 20px; padding: 3px 7px; }
.ptz-zoom .ptz-btn { width: 28px; height: 28px; background: rgba(255,255,255,0.1); }
.ptz-zoom .ptz-btn svg { width: 14px; height: 14px; }
.ptz-zoom-label { color: white; font-size: 0.7rem; font-weight: 600; font-family: monospace; min-width: 30px; text-align: center; user-select: none; }
.video-container.ptz-dragging { cursor: grabbing !important; }
.video-container.ptz-zoomed { cursor: grab; }

/* ========== MAP PANEL ========== */
.map-panel { display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: #0a0a14; z-index: 950; flex-direction: column; }
.map-panel.active { display: flex; }
.map-panel-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 0.625rem 1rem; background: linear-gradient(135deg,#16162a,#1e1b4b,#312e81);
    border-bottom: 1px solid var(--border-color); flex-shrink: 0;
}
.map-title-section { display: flex; align-items: center; gap: 0.625rem; }
.map-title-section h2 { font-size: 1rem; font-weight: 700; color: var(--text-primary); }
.map-stats { font-size: 0.7rem; color: var(--text-secondary); background: rgba(0,0,0,0.3); padding: 0.2rem 0.5rem; border-radius: 50px; }
.map-controls-bar { display: flex; align-items: center; gap: 0.5rem; }
.map-toggle-label { display: flex; align-items: center; gap: 0.375rem; font-size: 0.75rem; color: var(--text-secondary); cursor: pointer; }
.map-toggle-label input { accent-color: var(--primary-color); }
.map-close-btn { padding: 0.375rem; background: rgba(255,255,255,0.05); border: 1px solid var(--border-color); border-radius: 0.375rem; cursor: pointer; color: var(--text-secondary); transition: all 0.2s; display: flex; align-items: center; justify-content: center; }
.map-close-btn:hover { color: white; background: rgba(255,255,255,0.1); }
.map-container { flex: 1; background: #1a1a2e; }

/* ========== MONITOR PANEL ========== */
.monitor-panel { display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: #0a0a14; z-index: 950; flex-direction: column; }
.monitor-panel.active { display: flex; }
.monitor-header {
    display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 0.5rem;
    padding: 0.625rem 1rem; background: linear-gradient(135deg,#16162a,#1e1b4b,#312e81);
    border-bottom: 1px solid var(--border-color); flex-shrink: 0;
}
.monitor-title-section { display: flex; align-items: center; gap: 0.625rem; }
.monitor-title-section h2 { font-size: 1rem; font-weight: 700; }
.monitor-badge { font-size: 0.65rem; padding: 0.2rem 0.5rem; border-radius: 50px; font-weight: 600; background: var(--border-color); color: var(--text-secondary); }
.monitor-badge.running { background: rgba(16,185,129,0.2); color: var(--green); }
.monitor-controls-bar { display: flex; align-items: center; gap: 0.375rem; }
.monitor-action-btn {
    display: flex; align-items: center; gap: 0.3rem; padding: 0.4rem 0.75rem;
    background: rgba(16,185,129,0.15); border: 1px solid rgba(16,185,129,0.3); border-radius: 0.375rem;
    color: var(--green); cursor: pointer; font-size: 0.75rem; font-weight: 600; transition: all 0.2s;
}
.monitor-action-btn:hover { background: rgba(16,185,129,0.25); }
.monitor-action-btn.secondary { background: rgba(255,255,255,0.05); border-color: var(--border-color); color: var(--text-secondary); }
.monitor-action-btn.secondary:hover { color: white; }
.monitor-action-btn.stop { background: rgba(239,68,68,0.15); border-color: rgba(239,68,68,0.3); color: var(--red); }
.monitor-close-btn { padding: 0.375rem; background: rgba(255,255,255,0.05); border: 1px solid var(--border-color); border-radius: 0.375rem; cursor: pointer; color: var(--text-secondary); display: flex; align-items: center; justify-content: center; transition: all 0.2s; }
.monitor-close-btn:hover { color: white; }

.monitor-stats-bar { display: flex; gap: 0.5rem; padding: 0.75rem 1rem; border-bottom: 1px solid var(--border-color); background: rgba(0,0,0,0.3); flex-wrap: wrap; }
.monitor-stat { flex: 1; min-width: 70px; text-align: center; padding: 0.5rem; background: rgba(255,255,255,0.03); border-radius: 0.5rem; }
.stat-value { display: block; font-size: 1.25rem; font-weight: 700; color: var(--green); }
.stat-value.stat-red { color: var(--red); }
.stat-value.stat-yellow { color: var(--yellow); }
.stat-value.stat-blue { color: var(--blue); font-size: 0.85rem; }
.stat-label { font-size: 0.65rem; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.5px; }

.monitor-log { flex: 1; overflow-y: auto; padding: 0.75rem; }
.monitor-log-empty { display: flex; flex-direction: column; align-items: center; justify-content: center; height: 100%; color: var(--text-secondary); text-align: center; padding: 2rem; opacity: 0.5; }
.monitor-log-empty p { font-size: 0.875rem; max-width: 300px; }

.log-entry { display: flex; align-items: center; gap: 0.625rem; padding: 0.5rem 0.75rem; border-radius: 0.375rem; font-size: 0.8rem; margin-bottom: 0.25rem; animation: logSlide 0.3s ease; }
@keyframes logSlide { from{opacity:0;transform:translateX(-10px)} to{opacity:1;transform:translateX(0)} }
.log-entry.log-activated { background: rgba(16,185,129,0.1); border-left: 3px solid var(--green); }
.log-entry.log-deactivated { background: rgba(239,68,68,0.1); border-left: 3px solid var(--red); }
.log-entry.log-info { background: rgba(59,130,246,0.1); border-left: 3px solid var(--blue); }
.log-entry.log-check { background: rgba(255,255,255,0.02); border-left: 3px solid var(--border-color); }
.log-time { font-family: monospace; color: var(--text-secondary); font-size: 0.7rem; flex-shrink: 0; }
.log-icon { width: 18px; height: 18px; flex-shrink: 0; }
.log-msg { flex: 1; min-width: 0; }
.log-cam { font-weight: 600; color: var(--text-primary); }

/* ========== MULTIVIEW ========== */
.multiview-panel { display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: #0a0a14; z-index: 950; flex-direction: column; }
.multiview-panel.active { display: flex; }
.multiview-header { display: flex; align-items: center; justify-content: space-between; padding: 0.625rem 1rem; background: linear-gradient(135deg,#16162a,#1e1b4b,#312e81); border-bottom: 1px solid var(--border-color); flex-shrink: 0; }
.multiview-title-section { display: flex; align-items: center; gap: 0.625rem; }
.multiview-title-section h2 { font-size: 1rem; font-weight: 700; }
.multiview-count { display: inline-block; padding: 0.15rem 0.5rem; background: var(--primary-color); color: white; border-radius: 50px; font-size: 0.65rem; font-weight: 600; }
.multiview-controls { display: flex; align-items: center; gap: 0.375rem; }
.grid-selector { display: flex; gap: 0.2rem; background: rgba(0,0,0,0.3); padding: 0.2rem; border-radius: 0.375rem; }
.grid-option { padding: 0.3rem; background: transparent; border: 1px solid transparent; border-radius: 0.25rem; cursor: pointer; color: var(--text-secondary); transition: all 0.2s; display: flex; align-items: center; justify-content: center; }
.grid-option:hover { color: var(--text-primary); background: rgba(124,58,237,0.2); }
.grid-option.active { background: var(--primary-color); color: white; border-color: var(--primary-color); }
.multiview-fullscreen-btn, .multiview-clear-btn, .multiview-close-btn { padding: 0.3rem; background: rgba(255,255,255,0.05); border: 1px solid var(--border-color); border-radius: 0.25rem; cursor: pointer; color: var(--text-secondary); transition: all 0.2s; display: flex; align-items: center; justify-content: center; }
.multiview-fullscreen-btn:hover { color: var(--primary-color); border-color: var(--primary-color); }
.multiview-clear-btn:hover { color: var(--red); border-color: var(--red); }
.multiview-close-btn:hover { color: white; background: rgba(255,255,255,0.1); }

.multiview-grid { flex: 1; display: grid; gap: 2px; padding: 2px; background: #0a0a14; overflow: hidden; }
.multiview-grid[data-layout="2x2"] { grid-template-columns: 1fr 1fr; grid-template-rows: 1fr 1fr; }
.multiview-grid[data-layout="3x3"] { grid-template-columns: repeat(3,1fr); grid-template-rows: repeat(3,1fr); }
.multiview-grid[data-layout="4x4"] { grid-template-columns: repeat(4,1fr); grid-template-rows: repeat(4,1fr); }
.multiview-slot { position: relative; background: #12121f; border: 1px solid var(--border-color); border-radius: 0.25rem; overflow: hidden; display: flex; align-items: center; justify-content: center; cursor: pointer; transition: border-color 0.2s; }
.multiview-slot:hover { border-color: var(--primary-color); }
.multiview-slot.occupied { cursor: default; }
.multiview-slot-empty { display: flex; flex-direction: column; align-items: center; gap: 0.375rem; color: var(--text-secondary); opacity: 0.4; pointer-events: none; }
.multiview-slot:hover .multiview-slot-empty { opacity: 0.7; }
.multiview-slot-empty svg { width: 28px; height: 28px; }
.multiview-slot-empty span { font-size: 0.65rem; }
.multiview-slot video { position: absolute; top: 0; left: 0; width: 100%; height: 100%; object-fit: contain; background: #000; }
.multiview-slot-overlay { position: absolute; bottom: 0; left: 0; right: 0; padding: 0.4rem 0.5rem; background: linear-gradient(transparent,rgba(0,0,0,0.85)); display: flex; align-items: flex-end; justify-content: space-between; z-index: 2; opacity: 0; transition: opacity 0.2s; }
.multiview-slot:hover .multiview-slot-overlay { opacity: 1; }
.multiview-slot-info { flex: 1; min-width: 0; }
.multiview-slot-name { font-size: 0.7rem; font-weight: 600; color: white; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.multiview-slot-municipality { font-size: 0.575rem; color: rgba(255,255,255,0.6); }
.multiview-slot-remove { flex-shrink: 0; width: 22px; height: 22px; background: rgba(244,63,94,0.8); border: none; border-radius: 50%; color: white; cursor: pointer; display: flex; align-items: center; justify-content: center; font-size: 0.8rem; font-weight: bold; transition: all 0.2s; margin-left: 0.375rem; }
.multiview-slot-remove:hover { background: #f43f5e; transform: scale(1.15); }
.multiview-slot-loading { position: absolute; top: 50%; left: 50%; transform: translate(-50%,-50%); z-index: 3; }
.multiview-slot-loading .spinner { width: 24px; height: 24px; border-width: 2px; }
.multiview-slot-inactive { position: absolute; top: 50%; left: 50%; transform: translate(-50%,-50%); z-index: 3; display: flex; flex-direction: column; align-items: center; gap: 0.375rem; color: #9ca3af; font-size: 0.75rem; }
.multiview-panel.fullscreen { z-index: 9999; }

/* Picker */
.multiview-picker { display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.85); z-index: 960; align-items: center; justify-content: center; padding: 1rem; }
.multiview-picker.active { display: flex; }
.picker-content { background: #16162a; border: 1px solid var(--border-color); border-radius: 0.875rem; width: 100%; max-width: 650px; max-height: 80vh; display: flex; flex-direction: column; overflow: hidden; }
.picker-header { display: flex; align-items: center; justify-content: space-between; padding: 1rem 1.25rem; border-bottom: 1px solid var(--border-color); }
.picker-header h3 { font-size: 1rem; font-weight: 700; }
.picker-close { width: 30px; height: 30px; background: rgba(255,255,255,0.05); border: 1px solid var(--border-color); border-radius: 50%; color: var(--text-secondary); cursor: pointer; display: flex; align-items: center; justify-content: center; font-size: 1.125rem; transition: all 0.2s; }
.picker-close:hover { background: rgba(255,255,255,0.1); color: white; }
.picker-search { padding: 0.75rem 1.25rem; border-bottom: 1px solid var(--border-color); }
.picker-search input { width: 100%; padding: 0.5rem 0.875rem; background: #0f0f0f; border: 1px solid var(--border-color); border-radius: 0.375rem; color: var(--text-primary); font-size: 0.8rem; outline: none; }
.picker-search input:focus { border-color: var(--primary-color); }
.picker-search input::placeholder { color: var(--text-secondary); }
.picker-list { flex: 1; overflow-y: auto; padding: 0.375rem; }
.picker-item { display: flex; align-items: center; gap: 0.625rem; padding: 0.5rem 0.75rem; border-radius: 0.375rem; cursor: pointer; transition: background 0.15s; }
.picker-item:hover { background: rgba(124,58,237,0.15); }
.picker-item.disabled { opacity: 0.3; cursor: not-allowed; pointer-events: none; }
.picker-item-icon { width: 32px; height: 32px; background: linear-gradient(135deg,#1e1b4b,#312e81); border-radius: 0.375rem; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.picker-item-icon svg { width: 16px; height: 16px; color: rgba(255,255,255,0.7); }
.picker-item-info { flex: 1; min-width: 0; }
.picker-item-name { font-size: 0.8rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.picker-item-location { font-size: 0.7rem; color: var(--text-secondary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.picker-item-badge { flex-shrink: 0; padding: 0.1rem 0.4rem; background: rgba(124,58,237,0.15); color: var(--secondary-color); border-radius: 50px; font-size: 0.625rem; font-weight: 600; }

/* ========== LEAFLET MAP CUSTOMIZATION ========== */
.leaflet-container { background: #1a1a2e !important; }
.map-popup-content { font-size: 0.8rem; max-width: 220px; }
.map-popup-content h4 { font-size: 0.85rem; margin-bottom: 0.25rem; color: #1e1b4b; }
.map-popup-content p { color: #666; margin-bottom: 0.25rem; }
.map-popup-content .popup-status { display: inline-block; padding: 0.15rem 0.5rem; border-radius: 50px; font-size: 0.65rem; font-weight: 600; color: white; }
.map-popup-content .popup-active { background: var(--green); }
.map-popup-content .popup-inactive { background: var(--red); }
.map-popup-content .popup-btn { display: inline-block; margin-top: 0.375rem; padding: 0.3rem 0.75rem; background: var(--primary-color); color: white; border: none; border-radius: 0.375rem; font-size: 0.7rem; font-weight: 600; cursor: pointer; }

/* Sidebar overlay */
.sidebar-overlay { display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.6); z-index: 89; backdrop-filter: blur(4px); }
.sidebar-overlay.active { display: block; }

/* Menu toggle */
.menu-toggle { display: none; background: none; border: none; color: white; cursor: pointer; padding: 0.375rem; border-radius: 0.375rem; transition: background 0.2s; }
.menu-toggle:hover { background: rgba(255,255,255,0.1); }

/* Scrollbar */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: #0a0a14; }
::-webkit-scrollbar-thumb { background: #2d2d44; border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--primary-color); }

/* ========== RESPONSIVE ========== */
@media (max-width: 1024px) {
    .menu-toggle { display: flex; align-items: center; justify-content: center; }
    .sidebar { position: fixed; left: -280px; top: 0; height: 100vh; width: 260px; z-index: 90; transition: left 0.3s ease; }
    .sidebar.active { left: 0; box-shadow: 4px 0 30px rgba(0,0,0,0.5); }
    .camera-section { padding: 1.25rem; width: 100%; }
    .camera-grid { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
}

@media (max-width: 768px) {
    .app-header { padding: 0.75rem; }
    .header-content { gap: 0.5rem; }
    .title-section h1 { font-size: 1rem; }
    .search-box { max-width: none; }
    .search-box input { padding: 0.5rem 0.75rem 0.5rem 2.25rem; font-size: 0.8rem; }
    .camera-section { padding: 0.75rem; }
    .section-header { margin-bottom: 0.75rem; flex-wrap: wrap; gap: 0.5rem; }
    .section-header h2 { font-size: 1rem; }
    .camera-grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 0.75rem; }
    .camera-card { border-radius: 0.625rem; }
    .camera-info { padding: 0.75rem; }
    .camera-name { font-size: 0.8rem; }
    .camera-location { font-size: 0.7rem; }
    .list-view .camera-card { flex-direction: column; }
    .list-view .camera-preview { width: 100%; padding-top: 56.25%; height: auto; }
    .modal { padding: 0; }
    .modal-content { border-radius: 0; max-height: 100vh; height: 100vh; }
    .modal-header { padding: 0.75rem 1rem; }
    .modal-header h2 { font-size: 1rem; padding-right: 2.5rem; }
    .modal-body { padding: 0.5rem; }
    .ptz-controls { bottom: 40px; right: 6px; }
    .ptz-dpad { grid-template-columns: 28px 28px 28px; grid-template-rows: 28px 28px 28px; gap: 1px; }
    .ptz-btn svg { width: 13px; height: 13px; }
    .ptz-zoom .ptz-btn { width: 24px; height: 24px; }
    .ptz-zoom-label { font-size: 0.6rem; }
    /* Mobile bottom nav override */
    .header-toolbar { gap: 0.25rem; }
    .toolbar-btn { padding: 0.375rem 0.5rem; }
}

@media (max-width: 480px) {
    .app-header { padding: 0.5rem 0.625rem; }
    .title-section h1 { font-size: 0.875rem; }
    .camera-grid { grid-template-columns: 1fr 1fr; gap: 0.5rem; }
    .camera-info { padding: 0.5rem; }
    .camera-name { font-size: 0.75rem; -webkit-line-clamp: 1; }
    .camera-location { display: none; }
    .camera-municipality { font-size: 0.6rem; padding: 0.15rem 0.4rem; }
    .camera-status { top: 0.375rem; right: 0.375rem; padding: 0.2rem 0.4rem; font-size: 0.6rem; }
    .status-dot { width: 5px; height: 5px; }
    .view-controls { gap: 0.2rem; }
    .view-btn { padding: 0.3rem; }
    .view-btn svg { width: 16px; height: 16px; }
    .modal-action-btn { width: 32px; height: 32px; }
    .modal-action-btn svg { width: 15px; height: 15px; }
}

/* Ultra small phones */
@media (max-width: 360px) {
    .camera-grid { grid-template-columns: 1fr; }
    .search-box input { font-size: 0.75rem; }
}
