:root {
    --primary: #0f172a;
    --primary-light: #1e293b;
    --accent-red: #dc2626;
    --accent-red-hover: #b91c1c;
    --accent-blue: #0284c7;
    --bg-body: #f1f5f9;
    --card-bg: #ffffff;
    --text-main: #0f172a;
    --text-muted: #64748b;
    --border-color: #cbd5e1;
    --status-pendiente: #f59e0b;
    --status-proceso: #3b82f6;
    --status-resuelta: #10b981;
    --status-critica: #ef4444;
}

* { box-sizing: border-box; margin: 0; padding: 0; font-family: 'Segoe UI', system-ui, -apple-system, sans-serif; }

html, body { height: 100vh; width: 100vw; margin: 0; padding: 0; background-color: var(--bg-body); color: var(--text-main); display: flex; flex-direction: column; overflow: hidden; }

#login-overlay { position: fixed; top: 0; left: 0; width: 100vw; height: 100vh; background: rgba(15, 23, 42, 0.95); backdrop-filter: blur(8px); z-index: 9999; display: flex; justify-content: center; align-items: center; }
.login-corner-logo { position: absolute; bottom: 30px; width: 160px; height: auto; z-index: 10000; background: rgba(255, 255, 255, 0.95); padding: 12px; border-radius: 8px; box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3); transition: transform 0.3s ease; }
.login-corner-logo:hover { transform: translateY(-5px); }
.login-corner-logo.left { left: 30px; }
.login-corner-logo.right { right: 30px; }
.login-card { background: #ffffff; width: 100%; max-width: 420px; padding: 2.5rem; border-radius: 12px; box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.3); text-align: center; }
.login-shield-img { width: 110px; height: auto; margin: 0 auto 1.2rem auto; display: block; }
.login-card h2 { font-size: 1.5rem; color: var(--primary); margin-bottom: 0.3rem; font-weight: 700; }
.login-card p { color: var(--text-muted); font-size: 0.875rem; margin-bottom: 1.8rem; }
.form-group { margin-bottom: 1.2rem; text-align: left; }
.form-group label { display: block; font-size: 0.85rem; font-weight: 600; color: var(--primary); margin-bottom: 0.4rem; }
.form-control { width: 100%; padding: 0.65rem 0.85rem; border: 1px solid var(--border-color); border-radius: 6px; font-size: 0.95rem; transition: border-color 0.2s, box-shadow 0.2s; }
.form-control:focus { outline: none; border-color: var(--accent-blue); box-shadow: 0 0 0 3px rgba(2, 132, 199, 0.15); }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem; padding: 0.7rem 1.2rem; border-radius: 6px; font-weight: 600; font-size: 0.95rem; cursor: pointer; border: none; transition: all 0.2s; }
.btn-primary { background-color: var(--accent-red); color: #ffffff; width: 100%; }
.btn-primary:hover { background-color: var(--accent-red-hover); }
.btn-secondary { background-color: #e2e8f0; color: var(--primary); }
.btn-secondary:hover { background-color: #cbd5e1; }
.btn-danger { background-color: #ef4444; color: white; }
.btn-danger:hover { background-color: #dc2626; }
.btn-success { background-color: #10b981; color: white; }
.btn-success:hover { background-color: #059669; }
.login-error { color: var(--accent-red); font-size: 0.85rem; margin-top: 1rem; display: none; font-weight: 600; }

header { background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%); color: #ffffff; padding: 1rem 2rem; box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15); display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 1rem; z-index: 100; flex-shrink: 0; }
.header-brand { display: flex; align-items: center; gap: 1.2rem; }
.header-logo-img { height: 48px; width: auto; background-color: rgba(255, 255, 255, 0.95); padding: 4px 8px; border-radius: 6px; }
.header-brand h1 { font-size: 1.6rem; letter-spacing: 0.5px; font-weight: 800; }
.header-brand p { font-size: 0.8rem; color: #94a3b8; text-transform: uppercase; letter-spacing: 1px; }
.header-status { display: flex; align-items: center; gap: 1.5rem; }
.emergency-badge { background-color: rgba(220, 38, 38, 0.2); border: 1px solid #ef4444; color: #fca5a5; padding: 0.4rem 0.9rem; border-radius: 20px; font-size: 0.85rem; font-weight: 600; display: flex; align-items: center; gap: 0.5rem; }
.user-info { display: flex; align-items: center; gap: 0.8rem; background: rgba(255, 255, 255, 0.1); padding: 0.4rem 0.8rem; border-radius: 6px; font-size: 0.85rem; }
.btn-logout { background: transparent; border: 1px solid #64748b; color: #cbd5e1; padding: 0.3rem 0.6rem; border-radius: 4px; font-size: 0.8rem; cursor: pointer; }
.btn-logout:hover { background: rgba(255, 255, 255, 0.15); color: #fff; }

.app-container { display: flex; flex: 1; overflow: hidden; min-height: 0; }
nav.sidebar { width: 250px; min-width: 180px; max-width: 500px; background-color: #ffffff; display: flex; flex-direction: column; padding: 1rem 0; flex-shrink: 0; border-right: 1px solid var(--border-color); overflow-y: auto; scrollbar-width: thin; }
.resizer-main { width: 6px; background-color: var(--border-color); cursor: col-resize; transition: background-color 0.2s; z-index: 10; }
.resizer-main:hover, .resizer-main.active { background-color: var(--accent-blue); }
.nav-item { display: flex; align-items: center; gap: 0.8rem; padding: 0.85rem 1.5rem; color: var(--text-muted); text-decoration: none; font-weight: 600; font-size: 0.9rem; cursor: pointer; transition: all 0.2s; border-left: 4px solid transparent; }
.nav-item:hover { background-color: #f8fafc; color: var(--primary); }
.nav-item.active { background-color: #f0f9ff; color: var(--accent-blue); border-left-color: var(--accent-blue); }

main.content { flex: 1; padding: 1.5rem; display: flex; flex-direction: column; min-height: 0; overflow: hidden; }
.tab-page { display: none; flex: 1; flex-direction: column; min-height: 0; }
.tab-page.active { display: flex; }
.tab-scroll-area { flex: 1; overflow-y: auto; min-height: 0; padding-right: 0.5rem; }
.page-title { font-size: 1.3rem; font-weight: 700; color: var(--primary); margin-bottom: 1.2rem; display: flex; align-items: center; gap: 0.6rem; flex-shrink: 0; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1.2rem; }
.split-container { display: flex; flex-direction: row; width: 100%; flex: 1; align-items: stretch; min-height: 0; }
.split-left { flex-shrink: 0; width: 40%; min-width: 350px; display: flex; flex-direction: column; min-height: 0; }
.split-resizer { width: 8px; background-color: var(--border-color); cursor: col-resize; margin: 0 0.5rem 1.5rem 0.5rem; border-radius: 4px; transition: background-color 0.2s; z-index: 10; }
.split-resizer:hover, .split-resizer.active { background-color: var(--accent-blue); }
.split-right { flex: 1; min-width: 300px; display: flex; flex-direction: column; min-height: 0; }

.panel-card { background: var(--card-bg); border-radius: 8px; border: 1px solid var(--border-color); box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05); display: flex; flex-direction: column; flex: 1; min-height: 0; margin-bottom: 0; }
.panel-card > form { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.panel-card .card-header { font-weight: 700; font-size: 1.05rem; color: var(--primary); padding: 1.2rem; border-bottom: 1px solid var(--border-color); display: flex; justify-content: space-between; align-items: center; flex-shrink: 0; background-color: #ffffff; border-radius: 8px 8px 0 0; z-index: 10; }
.panel-card .card-body { padding: 1.2rem; overflow-y: auto; flex: 1; min-height: 0; }
.panel-card .card-body.p-0 { padding: 0; }
.card-normal { background: var(--card-bg); border-radius: 8px; border: 1px solid var(--border-color); box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05); padding: 1.2rem; margin-bottom: 1.5rem; }
.card-normal .card-header { font-weight: 700; font-size: 1.05rem; color: var(--primary); padding: 0 0 0.5rem 0; margin-bottom: 1rem; border-bottom: 1px solid #f1f5f9; display: flex; justify-content: space-between; align-items: center; }

.card-header.sticky-header { position: sticky; top: -1.2rem; background-color: var(--card-bg); z-index: 50; margin-left: -1.2rem; margin-right: -1.2rem; margin-top: -1.2rem; margin-bottom: 1rem; padding: 1.2rem 1.2rem 1rem 1.2rem; border-bottom: 1px solid var(--border-color); border-top-left-radius: 8px; border-top-right-radius: 8px; box-shadow: 0 4px 6px -4px rgba(0,0,0,0.05); }

.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 0.8rem; }
.span-2 { grid-column: span 2; } .span-3 { grid-column: span 3; } .span-full { grid-column: 1 / -1; }
select.form-control { background-color: #fff; cursor: pointer; }

#map, #map-aviso, #map-visor, #map-cortes { flex: 1; min-height: 250px; width: 100%; border-radius: 6px; border: 1px solid var(--border-color); margin-top: 0.5rem; z-index: 1; }
#map-visor, #map-cortes { margin-top: 0; border-radius: 0 0 8px 8px; border: none; height: 100%; }

.scroll-box { border: 1px solid var(--border-color); padding: 0.6rem; max-height: 180px; overflow-y: auto; border-radius: 6px; background-color: #fafafa; margin-bottom: 1rem; }
.media-gallery { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.media-item { width: 65px; height: 65px; border-radius: 6px; border: 1px solid #cbd5e1; object-fit: cover; cursor: pointer; transition: transform 0.2s; background-color: #f1f5f9; display: flex; justify-content: center; align-items: center; color: var(--text-muted); font-size: 1.5rem; }
.media-item:hover { transform: scale(1.05); border-color: var(--accent-blue); color: var(--accent-blue); }

.table-controls { display: flex; justify-content: space-between; align-items: center; background: #f8fafc; padding: 0.5rem; border-radius: 6px; flex-wrap: wrap; margin: 1.2rem 1.2rem 0.5rem 1.2rem; }
.filter-group { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.filter-btn { background: #ffffff; border: 1px solid var(--border-color); padding: 0.4rem 0.8rem; font-size: 0.8rem; font-weight: 600; color: var(--text-muted); cursor: pointer; border-radius: 4px; transition: all 0.2s; }
.filter-btn:hover { background: #f1f5f9; }
.filter-btn.active { background: var(--accent-blue); color: white; border-color: var(--accent-blue); }

.table-responsive { width: 100%; }
table { width: 100%; border-collapse: collapse; font-size: 0.875rem; text-align: left; }
th { background-color: #f8fafc; color: var(--text-muted); font-weight: 700; padding: 0.75rem 0.9rem; border-bottom: 2px solid var(--border-color); text-transform: uppercase; font-size: 0.75rem; letter-spacing: 0.5px; position: sticky; top: 0; z-index: 5; }
th.sortable { cursor: pointer; user-select: none; transition: background 0.2s; }
th.sortable:hover { background: #e2e8f0; color: var(--primary); }
th.sortable i { margin-left: 0.4rem; color: #cbd5e1; }
td { padding: 0.75rem 0.9rem; border-bottom: 1px solid #f1f5f9; color: var(--text-main); vertical-align: middle; }
tr:hover { background-color: #f8fafc; }

.badge { display: inline-block; padding: 0.25rem 0.6rem; border-radius: 12px; font-size: 0.75rem; font-weight: 700; text-transform: uppercase; text-align: center; }

@keyframes badge-blink-critica { 0%, 100% { background: #fee2e2; color: #991b1b; box-shadow: 0 0 0 0 rgba(220, 38, 38, 0.4); } 50% { background: #ef4444; color: #ffffff; box-shadow: 0 0 8px 2px rgba(220, 38, 38, 0.6); } }
@keyframes badge-blink-alta { 0%, 100% { background: #ffedd5; color: #9a3412; opacity: 1; } 50% { opacity: 0.6; } }
@keyframes badge-blink-media { 0%, 100% { opacity: 1; } 50% { opacity: 0.7; } }
@keyframes badge-blink-pendiente { 0%, 100% { background: #fef3c7; color: #b45309; } 50% { background: #fde68a; color: #d97706; box-shadow: 0 0 5px rgba(245, 158, 11, 0.5); } }

.badge-critica { animation: badge-blink-critica 0.8s infinite; border: 1px solid #ef4444; }
.badge-alta { background: #ffedd5; color: #9a3412; animation: badge-blink-alta 1.5s infinite; border: 1px solid #ea580c; }
.badge-media { background: #fef3c7; color: #92400e; animation: badge-blink-media 3s infinite; }
.badge-baja { background: #e0f2fe; color: #075985; }
.badge-pendiente { animation: badge-blink-pendiente 1.5s infinite; }
.badge-en_proceso { background: #dbeafe; color: #1e40af; }
.badge-resuelta { background: #d1fae5; color: #065f46; }
.badge-archivado { background: #cbd5e1; color: #334155; }

.resource-card { border: 1px solid var(--border-color); border-radius: 6px; padding: 1rem; display: flex; flex-direction: column; gap: 0.5rem; background: #fafafa; }
.resource-header { display: flex; justify-content: space-between; align-items: center; font-weight: 700; }
.status-dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.dot-disponible { background: #10b981; } .dot-asignado { background: #f59e0b; } .dot-fuera { background: #ef4444; }

.kpi-card { background: #fff; border: 1px solid var(--border-color); border-radius: 8px; padding: 1.2rem; display: flex; align-items: center; gap: 1rem; }
.kpi-icon { width: 50px; height: 50px; border-radius: 8px; display: flex; align-items: center; justify-content: center; font-size: 1.4rem; color: #fff; }
.kpi-num { font-size: 1.6rem; font-weight: 800; line-height: 1; }
.kpi-label { font-size: 0.8rem; color: var(--text-muted); margin-top: 0.2rem; text-transform: uppercase; }
.event-info-box { background: #f0fdf4; border: 1px solid #16a34a; padding: 1rem; border-radius: 6px; margin-bottom: 1rem; }
.event-info-box h3 { color: #166534; font-size: 1.1rem; margin-bottom: 0.4rem; }
.event-info-box p { font-size: 0.9rem; color: #14532d; }

.custom-map-icon { border-radius: 50%; display: flex; justify-content: center; align-items: center; color: white; border: 2px solid white; box-shadow: 0 2px 5px rgba(0,0,0,0.5); font-size: 14px; }
.custom-map-icon i { margin: 0; padding: 0; }
@keyframes pulso-critica { 0% { box-shadow: 0 0 0 0 rgba(220, 38, 38, 0.8); transform: scale(1); } 50% { box-shadow: 0 0 0 12px rgba(220, 38, 38, 0); transform: scale(1.1); } 100% { box-shadow: 0 0 0 0 rgba(220, 38, 38, 0); transform: scale(1); } }
@keyframes pulso-alta { 0% { box-shadow: 0 0 0 0 rgba(234, 88, 12, 0.7); transform: scale(1); } 50% { box-shadow: 0 0 0 10px rgba(234, 88, 12, 0); transform: scale(1.05); } 100% { box-shadow: 0 0 0 0 rgba(234, 88, 12, 0); transform: scale(1); } }
@keyframes pulso-media { 0% { box-shadow: 0 0 0 0 rgba(245, 158, 11, 0.6); } 50% { box-shadow: 0 0 0 8px rgba(245, 158, 11, 0); } 100% { box-shadow: 0 0 0 0 rgba(245, 158, 11, 0); } }
.anim-pulso-critica { animation: pulso-critica 0.6s infinite; }
.anim-pulso-alta { animation: pulso-alta 1.2s infinite; }
.anim-pulso-media { animation: pulso-media 2.5s infinite; }

@media (max-width: 1024px) {
    html, body { overflow: auto; height: auto; }
    .app-container { flex-direction: column; overflow: visible; height: auto; }
    nav.sidebar { width: 100% !important; max-width: none; flex-direction: row; overflow-x: auto; border-bottom: 1px solid var(--border-color); }
    .resizer-main, .split-resizer { display: none; }
    main.content { overflow: visible; min-height: auto; }
    .tab-page, .tab-scroll-area { overflow: visible; min-height: auto; height: auto; }
    .split-container { flex-direction: column; height: auto; min-height: auto; }
    .split-left, .split-right { width: 100% !important; min-height: auto; margin-bottom: 1rem; padding-right:0; }
    .panel-card { height: 600px; }
    .grid-2, .grid-3 { grid-template-columns: 1fr; }
    .nav-item { border-left: none; border-bottom: 3px solid transparent; padding: 0.8rem 1rem; white-space: nowrap; }
    .nav-item.active { border-left-color: transparent; border-bottom-color: var(--accent-blue); }
}

/* EFECTO MODO CARRUSEL PARA EL PANEL TÁCTICO */
.tour-highlight {
    transform: scale(1.05) !important;
    border-left: 6px solid #10b981 !important;
    background: #f0fdf4 !important;
    box-shadow: 0 10px 15px -3px rgba(0,0,0,0.3) !important;
    z-index: 10;
    position: relative;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
.tour-highlight strong {
    font-size: 1.1rem !important;
    color: #065f46 !important;
}