/* Page frame: header, icon rail, then one view at a time (map, dashboard, staff). */

body {
    height: 100vh;
    overflow: hidden;
    display: grid;
    grid-template-rows: var(--header-h) 1fr;
}

/* Header */
.app-header {
    position: relative;
    z-index: 50;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--sp-4);
    padding: var(--sp-2) var(--sp-4);
    background: var(--c-white);
    color: var(--c-black);
    border-bottom: 1px solid var(--c-slate-200);
    box-shadow: var(--shadow-md);
}

.app-header__brand {
    display: flex;
    align-items: center;
    gap: var(--sp-4);
    min-width: 0;
}

.app-header__logo {
    height: 40px;
    width: auto;
    padding: 2px 6px;
    background: var(--c-logo-plate);
    border-radius: var(--radius-md);
}

.app-header__title {
    font-size: var(--fs-xl);
    font-weight: 400;
    line-height: 1.25;
}

.app-header__subtitle {
    margin-top: var(--sp-1);
    font-size: 14px;
    text-transform: uppercase;
}

.app-header__actions {
    display: flex;
    flex-shrink: 0;
    align-items: center;
    gap: var(--sp-4);
}

.app-header__tag {
    font-size: var(--fs-xl);
    font-weight: 700;
}

/* Body: icon rail + the active view */
.app-body {
    display: grid;
    grid-template-columns: var(--nav-w) minmax(0, 1fr);
    min-height: 0;
}

.view {
    min-width: 0;
    min-height: 0;
}

/* Map view: left panel, map, right panel */
.view--map {
    display: grid;
    grid-template-columns: var(--panel-left-w) minmax(0, 1fr) var(--panel-right-w);
    transition: grid-template-columns 0.2s ease;
}

/* Right panel hidden: the map takes its width */
.app-body--insights-hidden .view--map {
    grid-template-columns: var(--panel-left-w) minmax(0, 1fr) 0;
}

.app-body--insights-hidden .panel--right {
    padding: 0;
    overflow: hidden;
    border: 0;
    visibility: hidden;
}

/* Dashboard and staff views scroll on their own */
.view--page {
    overflow-y: auto;
    background: var(--c-page);
}

/* Icon rail */
.app-nav {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    padding: var(--sp-4) 0;
    background: var(--c-white);
    border-right: 1px solid var(--c-slate-200);
}

.app-nav__group {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: var(--sp-2);
}

.app-nav__group--bottom {
    margin-top: auto;
}

/* Side panels */
.panel {
    z-index: 10;
    overflow-y: auto;
    padding: var(--sp-4);
    background: var(--c-white);
}

.panel--left {
    display: flex;
    flex-direction: column;
    gap: var(--sp-6);
    border-right: 1px solid var(--c-slate-200);
    box-shadow: var(--shadow-sm);
}

.panel--right {
    display: flex;
    flex-direction: column;
    gap: var(--sp-3);
    padding-top: 0;
    background: var(--c-slate-50);
    border-left: 1px solid var(--c-slate-200);
}

/* Map */
.map-area {
    position: relative;
    background: var(--c-slate-200);
}

.map {
    position: absolute;
    inset: 0;
    z-index: 1;
}

/* Narrow screens: stack everything and let the page scroll */
@media (max-width: 900px) {
    body {
        height: auto;
        overflow: auto;
    }

    .app-header__subtitle,
    .app-header__tag {
        display: none;
    }

    .app-header__title {
        font-size: var(--fs-lg);
    }

    .app-body,
    .view--map,
    .app-body--insights-hidden .view--map {
        grid-template-columns: 1fr;
    }

    .app-nav {
        flex-direction: row;
        justify-content: space-between;
        padding: var(--sp-1) var(--sp-4);
        border-right: 0;
        border-bottom: 1px solid var(--c-slate-200);
    }

    .app-nav__group,
    .app-nav__group--bottom {
        flex-direction: row;
        gap: var(--sp-2);
        margin-top: 0;
    }

    .view--page {
        overflow: visible;
    }

    .map-area {
        order: -1;
        height: 60vh;
    }

    .panel {
        overflow: visible;
        border: 0;
    }

    .app-body--insights-hidden .panel--right {
        display: none;
    }
}
