:root {
    /* --- Oceanic Professional Palette --- */
    --bg0: #f8fafc;
    /* ultra-light cool slate */
    --bg1: #e2e8f0;
    /* soft ocean mist */
    --bg2: #1e293b;
    /* deep navy for high contrast */

    --card: rgba(255, 255, 255, 0.85);
    /* crisp white glass */
    --card2: rgba(241, 245, 249, 0.9);
    /* subtle blue-grey secondary */
    --border: rgba(30, 58, 95, 0.12);
    /* elegant, thin navy borders */

    --tx: #0f172a;
    /* slate-950 for elite readability */
    --mut: #475569;
    /* sophisticated slate grey */

    --pri: #006994;
    /* Deep Sea Blue primary */
    --pri-light: #e0f2fe;
    /* soft sky blue tint */
    --ok: #0d9488;
    /* teal-tinted success */
    --warn: #d97706;
    /* amber sunrise warning */
    --bad: #be123c;
    /* deep coral/rose alert */

    --shadow: 0 10px 25px -5px rgba(15, 23, 42, 0.08);
    --radius: 16px;
}

* {
    box-sizing: border-box;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

body {
    margin: 0;
    min-height: 100vh;
    color: var(--tx);
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background:
        radial-gradient(circle at 12% 10%, rgba(0, 105, 148, 0.1), transparent 55%),
        radial-gradient(circle at 90% 90%, rgba(13, 148, 136, 0.08), transparent 55%),
        linear-gradient(180deg, var(--bg1), var(--bg0));
    background-repeat: no-repeat;
    background-size: cover;
    background-attachment: fixed;
}

.shell {
    display: flex;
    min-height: 100vh;
}

.main {
    margin-top: 68px;
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

/* --- Topbar & Navigation --- */

.topbar {
    position: fixed;
    inset: 0 0 auto 0;
    height: 68px;
    background: rgba(255, 255, 255, 0.30);
    backdrop-filter: blur(18px) saturate(1.4);
    -webkit-backdrop-filter: blur(18px) saturate(1.4);
    border-bottom: 1px solid var(--border);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
    z-index: 1200;
}

.topbar-inner {
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between; /* Pushes brand to left and actions to right */
    padding: 0 1.5rem;
    max-width: 100%;
}

/* --- Left Side: Logo + Title --- */
.brand {
    display: flex;
    align-items: center;
    gap: 12px; /* Space between logo and text */
    flex-shrink: 0;
}

/* Remove default padding/borders from the header wrapper inside brand */
.brand .sb-header {
    padding: 0;
    border: none;
    background: transparent;
}

.sb-title {
    color: var(--pri);
    font-weight: 800;
    font-size: 1.1rem;
    letter-spacing: 0.03em;
    white-space: nowrap; /* Prevents title from wrapping to 2nd line */
}

/* --- Right Side: Search + Manual --- */
.topbar-left {
    display: flex;
    align-items: center;
    gap: 20px; /* Space between search and button */
}

.search-box {
    margin-right: 1rem;
    position: relative;
    width: 15.0rem;
}

.search-box input {
    width: 100%;
    padding: 8px 14px 8px 35px; /* Leave room for an icon if needed */
    background: #fff;
    border-radius: 10px;
    border: 1px solid var(--border);
    font-size: 0.85rem;
}

#searchResults {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--card);
    border-top: none;
    max-height: 220px;
    overflow-y: auto;
    list-style: none;
    padding: 0;
    margin: 0;
    z-index: 9999;
}

.manual-actions {
    display: flex;
    align-items: center;
}

.manual-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: var(--pri);
    color: white !important; /* Ensure text is white on blue */
    border-radius: 10px;
    text-decoration: none;
    font-size: 0.85rem;
    transition: background 0.2s ease;
}

.manual-btn:hover {
    transform: translateY(-1px);
}

.nav-a {
    color: var(--mut);
    padding: 0.75rem 1rem;
    margin: 0.25rem 0.8rem;
    border-radius: 12px;
    font-weight: 600;
    text-decoration: none;
    font-size: 0.88rem;
    display: flex;
    align-items: center;
    gap: .5rem;
}

.nav-a:hover {
    background: var(--pri-light);
    color: var(--pri);
    padding-left: 1.25rem;
}

.nav-a.active {
    background: var(--pri);
    color: #ffffff;
    box-shadow: 0 4px 12px rgba(0, 105, 148, 0.2);
}

.logo {
    height: 50px;
    width: auto;
}

.north-arrow {
    margin-bottom: 20px !important;
    margin-left: 20px !important;
}

.north-arrow img {
    width: 50px;
    /* Adjust size as needed */
    height: auto;
}

/* --- Sidebar Panels --- */

.sb-head {
    padding: 1rem 1.05rem .9rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: .7rem;
}

.sb-title {
    color: var(--pri);
    font-weight: 700;
    letter-spacing: 0.02em;
    font-size: clamp(0.95rem, 2.5vw, 1.3rem);
    text-transform: uppercase;
}

.layer-group {
    background: var(--card);
    backdrop-filter: blur(8px);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: .75rem .85rem;
    margin-bottom: .75rem;
    box-shadow: var(--shadow);
}

.layer-item {
    display: flex;
    align-items: center;
    gap: .55rem;
    font-size: .78rem;
    font-weight: 600;
    padding: .35rem .45rem;
    border-radius: 10px;
    cursor: pointer;
    transition: all .2s ease;
}

.layer-title {
    font-size: .7rem;
    font-weight: 800;
    text-transform: uppercase;
    color: var(--mut);
    margin-bottom: .5rem;
    border-bottom: 1px solid var(--border);
    padding-bottom: .25rem;
}

.layer-panel details details {
    margin-left: 16px;
}

/* --- UI Components --- */

.cardx {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem;
    box-shadow: var(--shadow);
    backdrop-filter: blur(10px);
}

.cardx:hover {
    transform: translateY(-2px);
    border-color: var(--pri);
    background: #fff;
}

/* --- Interactive Map Elements --- */

.dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--ok);
    box-shadow: 0 0 0 4px rgba(13, 148, 136, .1);
}

.dot.warn {
    background: var(--warn);
    box-shadow: 0 0 0 4px rgba(217, 119, 6, .1);
}

.dot.bad {
    background: var(--bad);
    box-shadow: 0 0 0 4px rgba(190, 18, 60, .1);
}

.sev {
    border-radius: 6px;
    padding: .1rem .5rem;
    font-size: .7rem;
    font-weight: 700;
    text-transform: uppercase;
}

.sev.high {
    color: #fff;
    background: var(--bad);
}

.sev.med {
    color: var(--tx);
    background: #fef3c7;
    border: 1px solid #fde68a;
}

.sev.low {
    color: #fff;
    background: var(--ok);
}

/* --- Accordion / Details --- */

details summary {
    list-style: none;
    cursor: pointer;
    font-size: .78rem;
    font-weight: 700;
    color: var(--pri-dark);
    padding: .5rem .75rem;
    border-radius: 10px;
    background: #fff;
    border: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: .4rem;
}

details summary::before {
    content: "→";
    font-size: .9rem;
    transition: transform .2s;
}

details[open] summary::before {
    transform: rotate(90deg);
}

#map {
    border-radius: 5px;
    border: 1px solid var(--border);
    background: #eee;
    height: calc(100vh - 70px);
    overflow: hidden;
}

/* --- Scrollbars --- */

::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-thumb {
    background: var(--bg2);
    border-radius: 10px;
    opacity: 0.3;
}

::-webkit-scrollbar-track {
    background: transparent;
}

/* --- Responsive Media Queries --- */

@media (max-width: 1024px) {
    .search-box {
        width: 12rem;
    }

    .kpi-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 900px) {
    .sb-title {
        font-size: 0.9rem;
    }
    .search-box {
        width: 180px;
    }
}

@media (max-width: 768px) {

    .sb-title,
    .sb-sub,
    .sec,
    .nav-a span:not(.icon) {
        display: none;
    }

    .topbar-inner {
        padding: 0 0.75rem;
    }

    .search-box {
        width: 8rem;
    }

    .kpi-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 600px) {
    .manual-btn span {
        display: none; /* Only show icon on very small screens */
    }
    .sb-title {
        display: none; /* Hide long title on mobile */
    }
}