:root {
    --bg: #08111f;
    --bg-elev: rgba(10, 20, 38, 0.84);
    --bg-card: rgb(234, 236, 239, 1.0);
    --muted-card: rgba(218, 220, 227, 1.0);
    --muted-card-text: #797f87;
    --text-card: #000;
    --text-info-card: darkblue;
    --line: rgba(130, 178, 255, 0.16);
    --text: #ecf4ff;
    --muted: #90a7c6;
    --gold: #D4AF37;
    --accent: #3da1ff;
    --success: #1ec892;
    --warning: #f8bc3a;
    --danger: #ff5c80;
    --shadow: 0 18px 48px rgba(0, 0, 0, 0.35);
    --radius: 20px;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; font-family: Inter, Segoe UI, Arial, sans-serif; background: var(--bg); color: var(--text); height: 100%; }
a { color: inherit; text-decoration: none; }
button, input, select { font: inherit; }
.glass-panel { backdrop-filter: blur(18px); background: var(--bg-elev); border: 1px solid var(--line); box-shadow: var(--shadow); }
.theme-dark { min-height: 100vh; }
.login-page {
    background: url('/img/skyline.png') no-repeat center center fixed;
    background-size: cover;
}
.login-shell { min-height: 100vh; display: grid; place-items: center; padding: 32px; background: linear-gradient(rgba(8, 17, 31, 0.9), rgba(8, 17, 31, 0.0)); position: relative; }
.branding-top-left { position: absolute; top: 32px; left: 32px; }
.branding-top-left img { height: 100px; width: auto; }
.login-container { display: flex; align-items: stretch; gap: 40px; max-width: 1000px; width: 100%; }
.login-info { flex: 1; display: flex; flex-direction: column; justify-content: center; padding: 20px; }
.info-line-1 { font-size: 1.0rem; font-weight: 300; color: var(--accent); letter-spacing: 0.2em; margin: 0 0 10px; font-family: 'Arial', sans-serif; }
.info-line-2 { font-size: 2.4rem; font-weight: 700; margin: 0 0 20px; font-family: 'Arial', sans-serif; }
.info-line-3 { font-size: 1rem; color: var(--muted); line-height: 1.6; margin-bottom: 40px; font-family: 'Arial', sans-serif; }
.info-grid { display: grid; grid-template-columns: auto 1fr; gap: 20px; align-items: center; margin-top: auto; padding-top: 10px; }
.info-icon {
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(61, 161, 255, 0.1);
    border: 1px solid var(--line);
    border-radius: 12px;
    font-size: 1.4rem;
    color: var(--text);
}
.text-upper { font-weight: 400; font-size: 1.0rem; color: var(--text); }
.text-lower { color: var(--muted); font-size: 0.9rem; }
.login-card { width: min(480px, 100%); border-radius: 28px; padding: 32px; flex-shrink: 0; }
.brand-row {
    align-items: center;
    margin-bottom: 18px;
}
.brand-badge {
    width: 100%;
    display: flex;
    justify-content: center;
}
.brand-badge img { width: 100px; height: 100px; }
.eyebrow { margin: 0 0 6px; color: var(--gold); text-transform: uppercase; letter-spacing: .14em; font-size: .78rem; }
.login-card h1 { margin: 0; font-size: 2rem; }
.login-copy { color: var(--muted); line-height: 1.6; margin-bottom: 24px; }
.login-form { display: grid; gap: 18px; }
.field { display: grid; gap: 8px; }
.input-container { position: relative; display: flex; align-items: center; }
.input-container i { position: absolute; left: 16px; color: var(--muted); pointer-events: none; }
.input { width: 100%; border-radius: 14px; border: 1px solid var(--muted); background: rgba(7, 15, 29, 0.95); color: var(--text); padding: 14px 16px 14px 44px; transition: border-color 0.2s, box-shadow 0.2s; }
.input[type="password"] { width: 100%; border-radius: 14px; border: 1px solid var(--muted); background: rgba(7, 15, 29, 0.95); color: var(--text); padding: 14px 16px 14px 44px; transition: border-color 0.2s, box-shadow 0.2s; }
.input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 2px rgba(61, 161, 255, 0.2); }
.btn-primary, .btn-inline, .btn-ghost { border: 0; border-radius: 14px; cursor: pointer; transition: .2s ease; }
.btn-primary { background: linear-gradient(135deg, #1f7ef1, #42b3ff); color: white; padding: 14px 18px; display: inline-flex; gap: 10px; align-items: center; justify-content: center; }
.btn-inline, .btn-ghost { background: rgba(61, 161, 255, 0.70); color: var(--text); padding: 10px 12px; display: inline-flex; align-items: center; gap: 8px; }
.btn-primary:hover, .btn-inline:hover, .btn-ghost:hover, .rail-btn:hover { transform: translateY(-1px); }
.alert { padding: 14px 16px; border-radius: 14px; margin-bottom: 18px; }
.alert.danger { background: rgba(255, 92, 128, 0.12); border: 1px solid rgba(255, 92, 128, 0.25); color: #ffd8e1; }
.app-shell { position: relative; min-height: 100vh; overflow: hidden; }
.map-wrapper, #map { position: absolute; inset: 0; }
.top-filters { position: absolute; top: 18px; left: 104px; right: 24px; z-index: 1010; display: flex; align-items: center; gap: 20px; padding: 14px 18px; border-radius: 22px; }
.brand-inline { display: flex; align-items: center; gap: 12px; min-width: 220px; }
.brand-inline i { font-size: 24px; color: var(--accent); }
.brand-inline span { display: block; color: var(--muted); font-size: .86rem; }
.filters-grid { display: flex; flex-wrap: wrap; gap: 10px; flex: 1; }
.toggle-pill { position: relative; }
.toggle-pill input { position: absolute; opacity: 0; }
.toggle-pill span { display: inline-flex; align-items: center; border-radius: 999px; border: 1px solid var(--line); padding: 10px 14px; color: var(--muted); background: rgba(255,255,255,.02); cursor: pointer; }
.toggle-pill input:checked + span { background: rgba(61, 161, 255, .16); color: var(--text); border-color: rgba(61, 161, 255, .3); }
.session-box { display: flex; align-items: center; gap: 12px; }
.left-rail { position: absolute; top: 96px; left: 24px; z-index: 1010; width: 64px; border-radius: 28px; padding: 12px 10px; display: grid; gap: 12px; }
.rail-btn { width: 44px; height: 44px; border-radius: 14px; border: 0; background: transparent; color: var(--muted); cursor: pointer; font-size: 18px; }
.rail-btn.active { background: rgba(61, 161, 255, .16); color: white; }
.floating-panel-stack { position: absolute; top: 96px; left: 104px; bottom: 24px; width: min(420px, calc(100vw - 180px)); z-index: 1000; pointer-events: none; }
.side-panel { position: absolute; inset: 0; border-radius: 26px; padding: 0; opacity: 0; transform: translateX(-18px); transition: .24s ease; pointer-events: none; overflow: hidden; display: flex; flex-direction: column; }
.side-panel.visible { opacity: 1; transform: translateX(0); pointer-events: auto; }
.panel-wide { width: min(760px, calc(100vw - 170px)); }
.panel-header-fixed { padding: 20px 20px 10px; border-bottom: 1px solid var(--line); background: var(--bg-elev); }
.panel-head { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin-bottom: 18px; }
.panel-head h2 { margin: 0; font-size: 1.1rem; }
.incident-filters { display: grid; gap: 12px; margin-bottom: 10px; }
.dark-input { background: rgba(0, 0, 0, 0.3) !important; border-color: var(--line) !important; }
.criticity-filters { display: flex; flex-wrap: wrap; gap: 8px; }
.criticity-pill { position: relative; }
.criticity-pill input { position: absolute; opacity: 0; }
.criticity-pill span { display: inline-flex; align-items: center; border-radius: 999px; border: 1px solid var(--line); padding: 6px 12px; color: var(--muted); background: rgba(255,255,255,.02); cursor: pointer; font-size: 0.75rem; transition: all 0.2s; }
.criticity-pill input:checked + span { color: var(--text); border-color: rgba(255, 255, 255, 0.4); }

.criticity-pill.critica input:checked + span { background: var(--danger); color: white; border-color: var(--danger); }
.criticity-pill.alta input:checked + span { background: #ff7e9d; color: white; border-color: #ff7e9d; }
.criticity-pill.media input:checked + span { background: var(--warning); color: #000; border-color: var(--warning); }
.criticity-pill.baja input:checked + span { background: var(--success); color: white; border-color: var(--success); }
.criticity-pill.all input:checked + span { background: var(--accent); color: white; border-color: var(--accent); }

.scrollable-list { flex: 1; overflow-y: auto; padding: 20px; display: grid; gap: 14px; }
.case-list { display: grid; gap: 14px; }
.case-card, .prediction-card { border-radius: 20px; padding: 16px; background: var(--bg-card); color: var(--text-info-card); border: 1px solid var(--line); cursor: pointer; transition: transform 0.2s, box-shadow 0.2s; }
.case-card:hover { transform: translateY(-2px); box-shadow: 0 4px 12px rgba(0,0,0,0.1); }
.case-card.active { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent); }
.case-card.muted { background: var(--muted-card); color: var(--muted-card-text); }
.case-top, .case-meta { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.case-card h3, .prediction-card h3 { margin: 12px 0 8px; }
.case-card p, .prediction-card p { margin: 0 0 10px; color: var(--text-info-card); line-height: 1.5; }
.pill { display: inline-flex; align-items: center; padding: 8px 10px; border-radius: 999px; font-size: .82rem; }
.pill.danger { background: rgba(255, 92, 128, .14); color: #ffdce5; }
.pill.info { background: rgba(61, 161, 255, .14); color: #cde6ff; }
.priority { border-radius: 999px; padding: 6px 10px; font-size: .78rem; }
.priority.alta, .priority.critica { background: rgba(255, 92, 128, .70); color: #ffd9e2; }
.priority.media { background: rgba(248, 188, 58, .70); color: #ffe5ac; }
.priority.baja { background: rgba(30, 200, 146, .70); color: #d1f7ea; }
.incident-detail-card {
    position: absolute;
    top: 96px;
    left: calc(104px + min(420px, calc(100vw - 180px)) + 24px);
    bottom: 24px;
    width: calc(150ch * 0.78);
    max-width: calc(100vw - (104px + min(420px, calc(100vw - 180px)) + 48px));
    z-index: 1000;
    border-radius: 26px;
    display: none;
    flex-direction: column;
    overflow: hidden;
    font-family: Arial, sans-serif;
    font-size: 0.78em;
}
.incident-detail-card.visible {
    display: flex;
}
.detail-section {
    margin-bottom: 20px;
}
.detail-section h4 {
    margin: 0 0 8px;
    color: var(--accent);
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1rem;
}
.detail-section p {
    margin: 0;
    line-height: 1.6;
    color: var(--text);
    white-space: pre-wrap;
    word-break: break-word;
}
.prediction-card { display: grid; grid-template-columns: 72px 1fr; gap: 14px; align-items: start; }
.prediction-score { width: 72px; height: 72px; display: grid; place-items: center; border-radius: 18px; background: linear-gradient(135deg, #103765, #1d79d5); font-weight: 700; }
.data-table { width: 100%; border-collapse: collapse; }
.data-table th, .data-table td { padding: 14px 12px; border-bottom: 1px solid var(--line); text-align: left; }
iframe { width: 100%; min-height: 70vh; border: 0; border-radius: 18px; background: #06101d; }
.settings-grid { display: grid; gap: 16px; }
.login-footer {
    position: absolute;
    bottom: 32px;
    width: 100%;
    display: flex;
    justify-content: center;
    padding: 0 32px;
}
.footer-grid {
    display: flex;
    gap: 40px;
    align-items: center;
    color: var(--muted);
    font-size: 0.9rem;
}
.footer-item {
    display: flex;
    align-items: center;
    gap: 10px;
}
.footer-item i {
    color: var(--text);
}
.footer-item a:hover {
    color: var(--text);
    text-decoration: underline;
}
.footer-logo {
    width: 24px;
    height: 24px;
}

@media (max-width: 900px) {
    .login-container { flex-direction: column; align-items: center; }
    .login-info { text-align: center; }
    .info-grid { justify-content: center; }
    .footer-grid { flex-direction: column; gap: 15px; text-align: center; }
    .login-footer { bottom: 20px; }
}

@media (max-width: 1200px) {
    .top-filters { left: 24px; top: 24px; }
    .left-rail { top: auto; bottom: 24px; left: 24px; grid-auto-flow: column; width: auto; }
    .floating-panel-stack { left: 24px; top: 118px; width: min(420px, calc(100vw - 48px)); }
    .incident-detail-card {
        left: 24px;
        top: calc(118px + 100% - 24px); /* This might not work as intended for same height, but media queries often stack or hide */
        width: min(420px, calc(100vw - 48px));
        max-width: none;
        height: auto;
        bottom: auto;
    }
}
@media (max-width: 768px) {
    .top-filters { position: relative; inset: auto; margin: 16px; }
    .left-rail { bottom: 16px; left: 16px; right: 16px; justify-content: space-between; }
    .floating-panel-stack { left: 16px; right: 16px; width: auto; bottom: 88px; }
}
