*, *::before, *::after {
    box-sizing: border-box;
}

html, body {
    min-height: 100%;
}

body {
    background: var(--ap-bg);
    color: var(--ap-text);
    font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    font-size: .875rem;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--ap-orange-dark); }
a:hover { color: var(--ap-orange-dark); }

:focus-visible {
    outline: 3px solid rgba(242,142,14,.35);
    outline-offset: 2px;
}

.ap-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--ap-sidebar-w);
    height: 100vh;
    background: linear-gradient(180deg, var(--ap-sidebar-bg) 0%, var(--ap-sidebar-bg-2) 100%);
    color: var(--ap-text);
    display: flex;
    flex-direction: column;
    z-index: 1040;
    overflow: hidden;
    box-sizing: border-box;
    transition: width .25s ease, transform .25s ease;
    border-right: 1px solid var(--ap-border);
    box-shadow: none;
}

.ap-sidebar-inner {
    display: flex;
    min-height: 0;
    flex: 1 1 auto;
    flex-direction: column;
    overflow: hidden;
}

.ap-sidebar-brand {
    width: 100%;
    min-width: 0;
    box-sizing: border-box;
    display: flex;
    align-items: center;
    color: inherit;
    text-decoration: none;
    gap: .875rem;
    padding: 1.5rem 1.25rem;
    min-height: 92px;
    border-bottom: 1px solid var(--ap-border);
}

.ap-sidebar-brand-mark {
    width: 2.75rem;
    height: 2.75rem;
    border-radius: .95rem;
    background: var(--ap-orange);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 1.2rem;
    flex: 0 0 auto;
}

.ap-sidebar-brand-text {
    display: flex;
    flex-direction: column;
    min-width: 0;
}
.ap-sidebar-brand-text strong { color:var(--ap-text); font-size:1.3rem; letter-spacing:-.05em; font-weight:800; }
.ap-sidebar-brand-text small { color:var(--ap-muted); font-size:.7rem; }
.ap-sidebar-brand-logo { width:100%; max-height:52px; object-fit:contain; object-position:left center; }

.ap-sidebar-nav {
    flex: 1 1 auto;
    min-width: 0;
    min-height: 0;
    padding: 1.25rem .5rem 1rem;
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-width: none;
    -ms-overflow-style: none;
}
.ap-sidebar-nav::-webkit-scrollbar {
    display: none;
}

.ap-nav-section-label {
    padding: 1.75rem 1rem .6rem;
    letter-spacing: .1em;
    color: var(--ap-muted);
    font-size: .65rem;
    font-weight: 700;
    text-transform: uppercase;
}

.ap-nav-link {
    width: calc(100% - 1rem);
    min-width: 0;
    box-sizing: border-box;
    display: flex;
    align-items: center;
    color: var(--ap-muted);
    text-decoration: none;
    overflow: hidden;
    margin: 4px .5rem;
    padding: .6rem .8rem !important;
    border-radius: .75rem !important;
    gap: .75rem !important;
    position: relative;
    font-weight: 500;
}
.ap-nav-link:hover {
    color: var(--ap-orange-dark);
    background: var(--ap-orange-light) !important;
}
.ap-nav-link.active,
.ap-nav-link[aria-current="page"] {
    color: #fff;
    background: var(--ap-orange) !important;
    box-shadow: 0 4px 10px rgba(230,107,18,.16);
}
.ap-nav-link-icon {
    width: 32px;
    height: 32px;
    border-radius: .75rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    flex: 0 0 auto;
}
.ap-nav-link.active .ap-nav-link-icon,
.ap-nav-link[aria-current="page"] .ap-nav-link-icon {
    background: rgba(255,255,255,.18);
}
.ap-nav-link-text {
    min-width: 0;
    flex: 1 1 auto;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.ap-nav-badge {
    flex: 0 0 auto;
    box-shadow: none;
}

.ap-sidebar-user {
    flex: 0 0 auto;
    min-width: 0;
    box-sizing: border-box;
    padding: .75rem;
    border-top: 1px solid var(--ap-border);
}
.ap-sidebar-user-toggle {
    width: 100%;
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: .75rem;
    color: var(--ap-text);
    background: var(--ap-surface-2);
    border: 0;
    border-radius: 1rem;
    text-align: left;
    min-width: 0;
    box-sizing: border-box;
    overflow: hidden;
}
.ap-sidebar-user-text {
    display: flex;
    flex-direction: column;
    min-width: 0;
}
.ap-sidebar-user-text strong,
.ap-sidebar-user-text small {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.ap-sidebar-user-text small { color: var(--ap-muted); font-size:.72rem; }
.ap-sidebar-user-menu { border-radius: 1rem; border-color: var(--ap-border); }

.ap-avatar {
    width: 2.6rem;
    height: 2.6rem;
    border-radius: 50%;
    background: var(--ap-orange-light);
    color: var(--ap-orange-dark);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    flex: 0 0 auto;
}

.ap-topbar {
    position: sticky;
    top: 0;
    height: auto;
    min-height: var(--ap-topbar-h);
    margin-left: var(--ap-sidebar-w);
    width: calc(100% - var(--ap-sidebar-w));
    padding: .8rem 1.75rem;
    background: rgba(255,255,255,.96);
    border-bottom: 1px solid var(--ap-border);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    box-shadow: none;
    z-index: 1030;
    overflow: visible;
    transition: box-shadow .2s ease, background .2s ease, margin-left .25s ease, width .25s ease;
}
.ap-topbar.is-scrolled {
    box-shadow: 0 12px 30px rgba(16,24,40,.08);
}
.ap-topbar,
.ap-topbar > * {
    display: flex;
    align-items: center;
    gap: 1rem;
}
.ap-topbar-start,
.ap-topbar-end {
    flex: 0 0 auto;
}
.ap-topbar-heading {
    display: flex;
    flex-direction: column;
    min-width: 0;
}
.ap-topbar-breadcrumb {
    font-size: .65rem;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: var(--ap-muted);
}
.ap-topbar-title {
    color: var(--ap-text);
    font-size: 1rem;
    font-weight: 600;
}
.ap-topbar-end {
    margin-left: auto;
    min-width: 0;
    justify-content: flex-end;
}
.ap-topbar-slot {
    display: flex;
    align-items: center;
    gap: .75rem;
    flex-wrap: wrap;
    min-width: 0;
    justify-content: flex-end;
}
.ap-topbar-slot > * {
    min-width: 0;
}
.ap-sidebar-collapse-toggle,
.ap-hamburger {
    border: 1px solid var(--ap-border);
    background: var(--ap-surface);
    color: var(--ap-text);
    border-radius: .65rem;
    min-height: 2.75rem;
    padding: 0 .9rem;
    display: inline-flex;
    align-items: center;
    gap: .45rem;
}
.ap-hamburger {
   display: none;
}

.ap-main {
   margin-left: var(--ap-sidebar-w);
   min-height: calc(100vh - var(--ap-topbar-offset));
   transition: margin-left .25s ease;
}
.ap-content {
   padding: 1.75rem;
}
.ap-content > :first-child {
   margin-top: 0 !important;
}

body.ap-sidebar-collapsed {
   --ap-sidebar-w: var(--ap-sidebar-w-collapsed);
}
body.ap-sidebar-collapsed .ap-sidebar-brand-text,
body.ap-sidebar-collapsed .ap-nav-section-label,
body.ap-sidebar-collapsed .ap-nav-link-text,
body.ap-sidebar-collapsed .ap-nav-badge,
body.ap-sidebar-collapsed .ap-sidebar-user-text {
    display: none !important;
}
body.ap-sidebar-collapsed .ap-nav-link {
    justify-content: center;
    padding-inline: .4rem !important;
}
body.ap-sidebar-collapsed .ap-sidebar-user-toggle {
    justify-content: center;
}
body.ap-sidebar-collapsed .ap-sidebar-user-menu {
    margin-left: .5rem;
}
body.ap-sidebar-collapsed .ap-sidebar-brand {
    padding-inline: .8rem;
    justify-content: center;
}
body.ap-sidebar-collapsed .ap-sidebar-brand-logo {
    max-height: 36px;
}

.ap-sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.45);
    z-index: 1039;
}
.ap-sidebar-overlay.show {
    display: block;
}

.ap-auth-shell {
    min-height: 100vh;
    padding: 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.map-page {
    min-height: 100dvh;
    height: 100dvh;
    display: flex;
    flex-direction: column;
}
.map-page .ap-topbar {
    position: relative;
    flex: 0 0 auto;
    min-height: var(--ap-topbar-h);
    padding-top: .5rem;
    padding-bottom: .5rem;
    align-items: stretch;
    margin-left: var(--ap-sidebar-w);
    width: calc(100% - var(--ap-sidebar-w));
    overflow: visible;
}
.map-page .ap-topbar > .d-flex {
    align-items: center;
    flex-wrap: nowrap;
    gap: .75rem 1rem;
}
.map-page .ap-topbar .ap-topbar-title {
    font-size: 1.05rem;
    white-space: nowrap;
}
.map-page .ap-main {
    flex: 1 1 auto;
    min-height: 0 !important;
    height: auto;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.map-page .ap-content {
    display: flex;
    flex: 1 1 auto;
    flex-direction: column;
    min-height: 0;
    padding: 0;
}

@media (max-width: 991.98px) {
    .ap-sidebar {
        width: min(88vw, 320px);
        transform: translateX(-100%);
    }
    .ap-sidebar.open {
        transform: translateX(0);
    }
    .ap-topbar {
        margin-left: 0;
        width: 100%;
        padding: .85rem 1rem;
        flex-wrap: wrap;
    }
    .ap-main {
        margin-left: 0;
    }
    .ap-hamburger {
        display: inline-flex;
    }
    .ap-sidebar-collapse-toggle {
        display: none !important;
    }
    .map-page .ap-topbar {
        width: 100%;
        margin-left: 0;
    }
}

@media (max-width: 575.98px) {
    .ap-content {
        padding: 1rem;
    }

    @media (prefers-reduced-motion: reduce) {
        .ap-sidebar, .ap-topbar, .ap-main { transition: none; }
    }
    .ap-auth-shell {
        padding: 1rem;
    }
}
