html, body {
    height: 100%;
}

body {
    padding: 0;
    overflow: hidden;
}

.dashboard-map {
    position: fixed;
    inset: 0;
    z-index: 1;
    background:
        radial-gradient(circle at top left, rgba(59, 130, 246, 0.12), transparent 28%),
        linear-gradient(180deg, #0b1220, #111827);
}

.dashboard-topbar {
    position: fixed;
    top: 18px;
    left: 18px;
    right: 18px;
    z-index: 12;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
    padding: 16px 18px;
    border-radius: 24px;
    background: rgba(15, 23, 42, 0.82);
    border: 1px solid rgba(148, 163, 184, 0.14);
    box-shadow: 0 24px 50px rgba(2, 6, 23, 0.38);
    backdrop-filter: blur(18px);
}

.topbar-brand {
    display: flex;
    align-items: center;
    gap: 14px;
}

.topbar-brand img {
    width: 56px;
    height: 56px;
    border-radius: 18px;
    border: 1px solid rgba(148, 163, 184, 0.14);
    background: rgba(15, 23, 42, 0.92);
}

.topbar-brand h1 {
    font-size: 24px;
    margin-bottom: 4px;
}

.topbar-brand p {
    color: var(--text-soft);
    font-size: 13px;
}

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

.company-picker {
    min-width: 220px;
}

.map-stats {
    position: fixed;
    left: 18px;
    bottom: 18px;
    z-index: 11;
    display: grid;
    grid-template-columns: repeat(4, minmax(96px, 1fr));
    gap: 12px;
    width: min(560px, calc(100vw - 36px));
}

.map-stat {
    padding: 16px;
    border-radius: 18px;
    background: rgba(15, 23, 42, 0.8);
    border: 1px solid rgba(148, 163, 184, 0.14);
    box-shadow: 0 18px 36px rgba(2, 6, 23, 0.28);
    backdrop-filter: blur(16px);
}

.map-stat span {
    display: block;
    color: var(--text-soft);
    font-size: 11px;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    margin-bottom: 8px;
}

.map-stat strong {
    font-size: 26px;
}

.dashboard-sidebar {
    position: fixed;
    top: 96px;
    right: 18px;
    bottom: 18px;
    width: min(560px, calc(100vw - 36px));
    z-index: 14;
    display: flex;
    flex-direction: column;
    border-radius: 28px;
    background: rgba(15, 23, 42, 0.9);
    border: 1px solid rgba(148, 163, 184, 0.14);
    box-shadow: 0 24px 60px rgba(2, 6, 23, 0.42);
    backdrop-filter: blur(18px);
    transform: translateX(0);
    transition: transform 0.24s ease;
}

.dashboard-sidebar.closed {
    transform: translateX(calc(100% + 26px));
}

.sidebar-header {
    display: flex;
    justify-content: space-between;
    gap: 14px;
    padding: 22px 22px 12px;
}

.sidebar-header h2 {
    font-size: 22px;
    margin-bottom: 6px;
}

.sidebar-header p {
    color: var(--text-soft);
    font-size: 13px;
}

.sidebar-close {
    width: 40px;
    height: 40px;
    border: 1px solid rgba(148, 163, 184, 0.14);
    background: rgba(148, 163, 184, 0.08);
    color: var(--text);
    border-radius: 999px;
    cursor: pointer;
    font-size: 22px;
    line-height: 1;
}

.sidebar-body {
    display: grid;
    grid-template-rows: auto auto minmax(0, 1fr);
    gap: 14px;
    min-height: 0;
    padding: 0 22px 22px;
}

.tab-list {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(96px, 1fr));
    gap: 8px;
}

.tab-button {
    text-align: center;
    padding: 12px 14px;
    border-radius: 999px;
    border: 1px solid rgba(148, 163, 184, 0.14);
    background: rgba(15, 23, 42, 0.46);
    color: var(--text);
    cursor: pointer;
    font-weight: 600;
}

.tab-button.active {
    background: rgba(59, 130, 246, 0.18);
    border-color: rgba(59, 130, 246, 0.34);
}

.panel-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.panel-scroll {
    overflow: auto;
    padding-right: 4px;
}

.entity-grid {
    display: grid;
    gap: 14px;
}

.entity-card {
    border: 1px solid rgba(148, 163, 184, 0.14);
    border-radius: 20px;
    padding: 18px;
    background: rgba(15, 23, 42, 0.46);
}

.entity-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 12px;
}

.entity-card-header h3 {
    font-size: 18px;
    margin-bottom: 4px;
}

.entity-meta {
    display: grid;
    gap: 6px;
    color: var(--text-soft);
    font-size: 13px;
}

.entity-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 14px;
}

.sub-list {
    margin-top: 14px;
    display: grid;
    gap: 10px;
}

.sub-item {
    padding: 12px 14px;
    border-radius: 16px;
    background: rgba(148, 163, 184, 0.08);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 14px;
}

.sub-item-details {
    display: grid;
    gap: 4px;
}

.sub-item-details strong {
    font-size: 14px;
}

.empty-state {
    padding: 22px;
    border: 1px dashed rgba(148, 163, 184, 0.2);
    border-radius: 18px;
    text-align: center;
    color: var(--text-soft);
}

.policy-card {
    display: grid;
    gap: 16px;
    border: 1px solid rgba(249, 115, 22, 0.24);
    border-radius: 20px;
    padding: 18px;
    background:
        linear-gradient(180deg, rgba(249, 115, 22, 0.13), rgba(15, 23, 42, 0.48)),
        rgba(15, 23, 42, 0.56);
}

.policy-card-header {
    display: grid;
    gap: 8px;
}

.policy-card-header h3 {
    font-size: 20px;
}

.policy-card-header p {
    color: var(--text-soft);
    font-size: 13px;
}

.policy-chip {
    width: fit-content;
    padding: 6px 10px;
    border-radius: 999px;
    background: rgba(249, 115, 22, 0.18);
    color: #fed7aa;
    border: 1px solid rgba(249, 115, 22, 0.28);
    font-size: 11px;
    font-weight: 800;
    text-transform: uppercase;
}

.policy-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}

.policy-section-title {
    margin-top: 2px;
    color: #fdba74;
    font-size: 12px;
    font-weight: 800;
    text-transform: uppercase;
}

.policy-actions {
    display: flex;
    justify-content: flex-end;
}

.policy-result {
    max-height: 260px;
    overflow: auto;
    direction: ltr;
    text-align: left;
    white-space: pre-wrap;
    border-radius: 14px;
    padding: 14px;
    background: rgba(2, 6, 23, 0.55);
    border: 1px solid rgba(148, 163, 184, 0.14);
    color: #dbeafe;
    font-size: 12px;
}

.map-selection-summary {
    margin-bottom: 14px;
    padding: 12px 14px;
    border-radius: 16px;
    border: 1px solid rgba(59, 130, 246, 0.24);
    background: rgba(59, 130, 246, 0.12);
    color: var(--text);
    font-size: 13px;
}

.map-legend {
    position: fixed;
    top: 108px;
    left: 18px;
    z-index: 10;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    max-width: min(620px, calc(100vw - 54px));
    padding: 12px 14px;
    border-radius: 18px;
    background: rgba(15, 23, 42, 0.8);
    border: 1px solid rgba(148, 163, 184, 0.14);
    backdrop-filter: blur(16px);
}

.map-mode-indicator {
    position: fixed;
    left: 50%;
    top: 108px;
    transform: translateX(-50%);
    z-index: 13;
    display: none;
    padding: 12px 18px;
    border-radius: 999px;
    background: rgba(15, 23, 42, 0.88);
    border: 1px solid rgba(59, 130, 246, 0.34);
    box-shadow: 0 20px 40px rgba(2, 6, 23, 0.3);
    color: var(--text);
    font-size: 13px;
    font-weight: 600;
    backdrop-filter: blur(16px);
}

.map-mode-indicator.show {
    display: block;
}

.legend-item {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--text-soft);
    font-size: 12px;
}

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

.legend-dot.admin {
    background: #f59e0b;
}

.legend-dot.online {
    background: #22c55e;
}

.legend-dot.offline {
    background: #94a3b8;
}

.legend-ring {
    border: 2px solid rgba(59, 130, 246, 0.8);
    background: rgba(59, 130, 246, 0.15);
}

.user-marker {
    width: 16px;
    height: 16px;
    border-radius: 999px;
    border: 3px solid rgba(255, 255, 255, 0.95);
    box-shadow: 0 8px 20px rgba(15, 23, 42, 0.45);
}

.user-marker.admin {
    background: #f59e0b;
}

.user-marker.online {
    background: #22c55e;
}

.user-marker.offline {
    background: #94a3b8;
}

.leaflet-popup-content-wrapper,
.leaflet-popup-tip {
    background: rgba(15, 23, 42, 0.92);
    color: var(--text);
}

.leaflet-control-zoom a {
    background: rgba(15, 23, 42, 0.92);
    color: var(--text);
    border-color: rgba(148, 163, 184, 0.14);
}

@media (max-width: 980px) {
    .dashboard-topbar {
        flex-direction: column;
        align-items: stretch;
    }

    .topbar-controls {
        justify-content: stretch;
    }

    .company-picker {
        flex: 1 1 100%;
    }

    .dashboard-sidebar {
        top: 176px;
    }

    .map-stats {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        width: min(360px, calc(100vw - 36px));
    }
}

@media (max-width: 720px) {
    .dashboard-topbar,
    .dashboard-sidebar,
    .map-legend,
    .map-stats {
        left: 10px;
        right: 10px;
        width: auto;
    }

    .dashboard-topbar {
        top: 10px;
    }

    .map-legend {
        top: 154px;
    }

    .map-mode-indicator {
        top: 154px;
        width: calc(100vw - 20px);
        text-align: center;
    }

    .dashboard-sidebar {
        top: 210px;
        bottom: 10px;
    }

    .map-stats {
        bottom: 10px;
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .policy-grid {
        grid-template-columns: 1fr;
    }
}
