:root {
    --navy: #071b33;
    --navy2: #0b2545;
    --red: #d90429;
    --blue: #0b3c6f;
    --text: #102033;
    --muted: #60708a;
    --border: rgba(159, 184, 214, 0.34);
    --soft: #eef4fb;
    --success: #0f8a5f;
    --warning: #f59e0b;
    --danger: #d90429;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: Arial, Helvetica, sans-serif;
    color: var(--text);
    background:
        radial-gradient(circle at 12% 0%, rgba(217,4,41,.10), transparent 30%),
        radial-gradient(circle at 92% 6%, rgba(11,60,111,.14), transparent 32%),
        #f3f7fc;
}

a { color: inherit; text-decoration: none; }
a:hover { text-decoration: none; }

.login-body {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 28px;
    background:
        radial-gradient(circle at 14% 12%, rgba(217,4,41,.24), transparent 30%),
        radial-gradient(circle at 88% 14%, rgba(46,134,255,.22), transparent 30%),
        linear-gradient(140deg,#06172C 0%,#0B3C6F 48%,#06172C 100%);
}

.login-card {
    width: min(460px, 100%);
    border-radius: 34px;
    padding: 34px;
    background: #fff;
    box-shadow: 0 28px 90px rgba(0,0,0,.36);
}

.login-logo {
    width: 78px;
    height: 78px;
    border-radius: 24px;
    display: grid;
    place-items: center;
    background: #f4f7fb;
    border: 1px solid #dde3ec;
    margin-bottom: 22px;
}

.login-logo img { width: 78%; height: 78%; object-fit: contain; }

.eyebrow {
    display: inline-flex;
    border-radius: 999px;
    padding: 7px 12px;
    background: #e9f1fb;
    color: #0b3c6f;
    font-size: 11px;
    font-weight: 950;
    letter-spacing: .1em;
    text-transform: uppercase;
    margin-bottom: 12px;
}

.login-card h1 { margin: 0 0 8px; font-size: 34px; letter-spacing: -.06em; }
.login-card p { margin: 0 0 22px; color: var(--muted); line-height: 1.45; }

.form-stack { display: grid; gap: 16px; }
label { display: grid; gap: 7px; font-size: 13px; color: #475467; font-weight: 800; }

input, select, textarea {
    width: 100%;
    border: 1px solid #dbe5f1;
    border-radius: 14px;
    padding: 12px 13px;
    min-height: 46px;
    font-size: 15px;
    color: var(--text);
    background: #fff;
}

button, .button {
    border: 0;
    min-height: 44px;
    border-radius: 14px;
    padding: 11px 16px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 900;
    cursor: pointer;
}

.primary-button { background: var(--red); color: #fff; }
.secondary-button { background: #eef4fb; color: #102033; }

.alert { border-radius: 16px; padding: 13px 15px; margin: 0 0 16px; font-weight: 800; }
.alert-error { background: #ffe0e6; color: #7a101f; }
.alert-success { background: #dcfce7; color: #07513a; }
.alert-warning { background: #fff3cd; color: #704600; }

.layout {
    display: grid;
    grid-template-columns: 330px minmax(0,1fr);
    min-height: 100vh;
}

.sidebar {
    position: relative;
    z-index: 20;
    overflow: hidden;
    background:
        linear-gradient(180deg, rgba(7,27,51,.98), rgba(8,36,67,.98)),
        repeating-linear-gradient(0deg, rgba(255,255,255,.025) 0 1px, transparent 1px 6px);
    color: #fff;
    padding: 30px 22px;
    box-shadow: 10px 0 38px rgba(7,27,51,.22);
}

.sidebar-brand {
    min-height: 82px;
    padding: 14px;
    border-radius: 24px;
    background: rgba(255,255,255,.08);
    border: 1px solid rgba(255,255,255,.14);
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 34px;
}

.sidebar-logo {
    width: 56px;
    height: 56px;
    border-radius: 18px;
    background: rgba(255,255,255,.08);
    display: grid;
    place-items: center;
    overflow: hidden;
    flex: 0 0 auto;
}

.sidebar-logo img { width: 82%; height: 82%; object-fit: contain; }

.sidebar-brand strong {
    display: block;
    font-size: 20px;
    font-weight: 950;
    line-height: 1.06;
    letter-spacing: -0.03em;
    text-shadow: 1px 2px 0 rgba(0,0,0,.34);
}

.sidebar-brand span {
    display: block;
    margin-top: 4px;
    font-size: 13px;
    line-height: 1.14;
    color: rgba(235,244,255,.82);
}

.nav-section {
    margin: 20px 10px 10px;
    color: rgba(221,231,245,.62);
    font-size: 12px;
    font-weight: 950;
    letter-spacing: .16em;
    text-transform: uppercase;
}

.nav { display: grid; gap: 10px; }

.nav a {
    position: relative;
    display: grid;
    gap: 5px;
    min-height: 76px;
    padding: 17px 20px 15px 20px;
    border-radius: 20px;
    color: #fff;
    background:
        linear-gradient(180deg, rgba(17,45,76,.74), rgba(10,31,55,.84));
    border: 1px solid rgba(126,166,210,.22);
    font-size: 20px;
    line-height: 1.08;
    letter-spacing: -0.025em;
    font-weight: 950;
    align-content: center;
    text-shadow: 1px 2px 0 rgba(0,0,0,.35);
    overflow: hidden;
    box-shadow: inset 0 1px 0 rgba(255,255,255,.045), 0 8px 20px rgba(0,0,0,.14);
    transition: transform .16s ease, border-color .16s ease, box-shadow .16s ease, background .16s ease;
}

.nav a::before {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: inherit;
    padding: 2px;
    background: linear-gradient(135deg, rgba(46,134,255,.70), rgba(46,134,255,.05) 36%, rgba(255,255,255,0) 56%);
    -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
    pointer-events: none;
    opacity: .78;
}

.nav a small {
    display: block;
    color: rgba(221,231,245,.78);
    font-size: 13px;
    font-weight: 850;
    line-height: 1.15;
    margin-top: 3px;
}

.nav a:hover {
    transform: translateY(-1px);
    border-color: rgba(124,180,255,.42);
    box-shadow: 0 14px 30px rgba(0,0,0,.20), inset 0 1px 0 rgba(255,255,255,.05);
}

.nav a.active {
    background: linear-gradient(135deg, rgba(217,4,41,.95), rgba(43,45,90,.86) 72%, rgba(11,60,111,.82));
    border-color: rgba(124,180,255,.54);
    box-shadow: 0 16px 36px rgba(0,0,0,.22);
}

.nav a.active::before {
    background: linear-gradient(135deg, rgba(255,255,255,.75), rgba(255,138,0,.70) 14%, rgba(255,79,129,.48) 48%, rgba(110,168,255,.64) 100%);
    opacity: .86;
}

.logout-form { margin-top: 26px; }
.logout-form button { width: 100%; background: rgba(255,255,255,.07); color: #fff; }

.content {
    position: relative;
    z-index: 1;
    min-width: 0;
    padding: 34px;
    overflow: hidden;
}

.content::before {
    content: "";
    position: fixed;
    inset: 0 0 0 330px;
    background: url("/public/street_sentinel_logo.png") center 28% / 520px auto no-repeat;
    opacity: .045;
    pointer-events: none;
    z-index: -1;
}

.topbar { display: flex; justify-content: space-between; gap: 18px; align-items: flex-start; margin-bottom: 24px; }
.topbar h1 { margin: 0; font-size: 38px; letter-spacing: -.05em; }
.topbar p { margin: 6px 0 0; color: var(--muted); line-height: 1.45; }

.hero {
    border-radius: 30px;
    border: 1px solid var(--border);
    background: linear-gradient(135deg, rgba(255,255,255,.92), rgba(238,246,255,.88));
    box-shadow: 0 18px 50px rgba(16,24,39,.08);
    padding: 26px;
    margin-bottom: 22px;
}

.hero h2 { margin: 0 0 8px; font-size: 30px; letter-spacing: -.04em; }
.hero p { margin: 0; color: var(--muted); line-height: 1.5; }

.stats-grid { display: grid; grid-template-columns: repeat(6, minmax(150px, 1fr)); gap: 16px; margin-bottom: 20px; }
.stat-card, .panel { background: rgba(255,255,255,.88); border: 1px solid var(--border); border-radius: 22px; box-shadow: 0 12px 34px rgba(16,24,39,.07); }
.stat-card { padding: 20px; border-top: 5px solid #91a4be; }
.stat-card.success { border-top-color: var(--success); }
.stat-card.warning { border-top-color: var(--warning); }
.stat-card.danger { border-top-color: var(--danger); }
.stat-card span { color: #5e6d86; display: block; font-weight: 950; font-size: 11px; text-transform: uppercase; letter-spacing: .08em; }
.stat-card strong { display: block; margin-top: 10px; font-size: 32px; letter-spacing: -.05em; }
.stat-card small { display: block; color: var(--muted); margin-top: 5px; font-weight: 700; }

.panel { padding: 22px; margin-bottom: 20px; }
.panel-header { display: flex; justify-content: space-between; gap: 16px; align-items: flex-start; margin-bottom: 16px; }
.panel-header h2 { margin: 0; font-size: 23px; letter-spacing: -.03em; }
.panel-header p { margin: 5px 0 0; color: var(--muted); }

.table-wrap { width: 100%; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; min-width: 850px; }
th, td { text-align: left; padding: 13px 12px; border-bottom: 1px solid rgba(150,168,195,.30); vertical-align: top; }
th { color: #5d6d85; font-size: 11px; text-transform: uppercase; letter-spacing: .08em; font-weight: 950; }
td small { display: block; margin-top: 4px; color: var(--muted); }

.badge { display: inline-flex; padding: 5px 9px; border-radius: 999px; font-size: 12px; font-weight: 950; background: #eef4fb; color: #22344e; }
.badge-success { background: #d1fae5; color: #065f46; }
.badge-warning { background: #fef3c7; color: #92400e; }
.badge-danger { background: #fee2e2; color: #991b1b; }

.cards-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px,1fr)); gap: 14px; }
.info-card { background: rgba(255,255,255,.72); border: 1px solid var(--border); border-radius: 20px; padding: 18px; }
.info-card h3 { margin: 0 0 8px; }

.form-grid { display: grid; grid-template-columns: repeat(3, minmax(180px,1fr)); gap: 14px; align-items: end; }
.form-grid .wide { grid-column: span 2; }
.empty { color: var(--muted); font-style: italic; }
.code-pill { display: inline-flex; padding: 8px 11px; border-radius: 12px; background: #e9f1fb; border: 1px solid #dbe5f1; color: #0b3c6f; font-weight: 950; letter-spacing: .05em; }

@media (max-width: 1200px) {
    .layout { grid-template-columns: 1fr; }
    .sidebar { position: static; }
    .content::before { inset: 0; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 720px) {
    .content { padding: 18px; }
    .stats-grid, .form-grid { grid-template-columns: 1fr; }
    .form-grid .wide { grid-column: span 1; }
    .topbar { flex-direction: column; }
}


/* CPF OPERATIONS MAP */
.topbar-actions,
.hero-actions {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.hero-actions {
    justify-content: flex-start;
    margin-top: 18px;
}

.map-command-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(150px, 1fr));
    gap: 16px;
    margin-bottom: 20px;
}

.small-stat-text {
    font-size: 18px !important;
    line-height: 1.2 !important;
    letter-spacing: -0.02em !important;
}

.map-panel {
    padding: 18px;
}

.cpf-operations-map {
    width: 100%;
    height: 620px;
    min-height: 520px;
    border-radius: 22px;
    overflow: hidden;
    border: 1px solid var(--border);
    background: #dbeafe;
    box-shadow: inset 0 0 0 1px rgba(255,255,255,.3);
}

.cpf-operations-map .leaflet-container,
.cpf-operations-map.leaflet-container {
    width: 100%;
    height: 100%;
    font-family: Arial, Helvetica, sans-serif;
}

.cpf-operations-map .leaflet-tile {
    max-width: none !important;
    max-height: none !important;
}

.map-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
    justify-content: flex-end;
}

.map-legend span {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--muted);
    font-weight: 900;
    font-size: 12px;
}

.legend-dot {
    width: 12px;
    height: 12px;
    border-radius: 999px;
    display: inline-block;
}

.alert-dot { background: var(--danger); }
.ready-dot { background: var(--success); }
.busy-dot { background: var(--warning); }
.stale-dot { background: #64748b; }

.cpf-map-div-icon {
    background: transparent !important;
    border: 0 !important;
}

.cpf-map-marker {
    width: 30px !important;
    height: 30px !important;
    border-radius: 999px !important;
    display: grid !important;
    place-items: center !important;
    color: #fff !important;
    font-size: 14px !important;
    line-height: 30px !important;
    font-weight: 950 !important;
    border: 3px solid rgba(255,255,255,.92) !important;
    box-shadow: 0 10px 24px rgba(15,23,42,.35) !important;
}

.cpf-map-marker.incident {
    background: var(--danger) !important;
    animation: cpfPulse 1.7s infinite;
}

.cpf-map-marker.responder.ready {
    background: var(--success) !important;
}

.cpf-map-marker.responder.busy {
    background: var(--warning) !important;
    color: #111827 !important;
}

.cpf-map-marker.responder.stale,
.cpf-map-marker.responder.offline {
    background: #64748b !important;
}

.map-popup h3 {
    margin: 0 0 8px;
    color: #0f172a;
    font-size: 16px;
}

.map-popup p {
    margin: 5px 0;
    color: #334155;
    font-size: 13px;
}

@keyframes cpfPulse {
    0% {
        box-shadow: 0 0 0 0 rgba(217,4,41,.55), 0 10px 24px rgba(15,23,42,.35);
    }
    70% {
        box-shadow: 0 0 0 13px rgba(217,4,41,0), 0 10px 24px rgba(15,23,42,.35);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(217,4,41,0), 0 10px 24px rgba(15,23,42,.35);
    }
}

@media (max-width: 1100px) {
    .map-command-grid {
        grid-template-columns: repeat(2, minmax(150px, 1fr));
    }
    .cpf-operations-map {
        height: 540px;
    }
}

@media (max-width: 720px) {
    .topbar-actions,
    .hero-actions,
    .map-legend {
        justify-content: flex-start;
    }
    .map-command-grid {
        grid-template-columns: 1fr;
    }
    .cpf-operations-map {
        height: 430px;
        min-height: 430px;
    }
}

/* CPF OPERATIONS MAP - OPENLAYERS STABLE RENDER FIX
   Matches the Security Operations Map engine and avoids Leaflet tile stretching/blank tile issues. */
.cpf-operations-map {
    position: relative !important;
    width: 100% !important;
    height: 620px !important;
    min-height: 520px !important;
    border-radius: 22px !important;
    overflow: hidden !important;
    border: 1px solid var(--border) !important;
    background: #dbeafe !important;
    box-shadow: inset 0 0 0 1px rgba(255,255,255,.3) !important;
}

.cpf-operations-map .ol-viewport,
.cpf-operations-map .ol-unselectable,
.cpf-operations-map .ol-layer,
.cpf-operations-map canvas {
    max-width: none !important;
    max-height: none !important;
}

.cpf-operations-map .ol-control button {
    min-height: 0 !important;
    border-radius: 4px !important;
    padding: 0 !important;
    box-shadow: none !important;
}

.map-popup-card {
    display: none;
    min-width: 230px;
    max-width: 320px;
    padding: 14px 16px;
    border-radius: 16px;
    background: #ffffff;
    border: 1px solid rgba(148, 163, 184, 0.35);
    box-shadow: 0 18px 42px rgba(15, 23, 42, 0.28);
    color: #0f172a;
}

.map-popup-card h3 {
    margin: 0 0 8px;
    color: #0f172a;
    font-size: 16px;
    font-weight: 950;
}

.map-popup-card p {
    margin: 5px 0;
    color: #334155;
    font-size: 13px;
    line-height: 1.35;
}

@media (max-width: 1100px) {
    .cpf-operations-map {
        height: 540px !important;
    }
}

@media (max-width: 720px) {
    .cpf-operations-map {
        height: 430px !important;
        min-height: 430px !important;
    }
}
