/* Professional application shell and grouped navigation */

:root {
    --sidebar-width: 268px;
    --sidebar-border: rgba(148, 163, 184, 0.18);
    --sidebar-text: #dbe4f0;
    --sidebar-muted: #8fa0b8;
    --sidebar-active: rgba(37, 99, 235, 0.22);
    --sidebar-active-border: rgba(96, 165, 250, 0.55);
}

html {
    scroll-behavior: smooth;
}

body {
    min-width: 320px;
}

.skip-link {
    position: fixed;
    top: 12px;
    left: 12px;
    z-index: 20000;
    padding: 10px 14px;
    border-radius: 9px;
    background: #ffffff;
    color: #111827;
    font-weight: 700;
    text-decoration: none;
    transform: translateY(-150%);
    transition: transform 140ms ease;
}

.skip-link:focus {
    transform: translateY(0);
}

.sidebar {
    position: sticky;
    top: 0;
    width: var(--sidebar-width);
    height: 100vh;
    flex: 0 0 var(--sidebar-width);
    overflow-y: auto;
    padding: 20px 16px 18px;
    border-right: 1px solid var(--sidebar-border);
    background:
        radial-gradient(circle at top left, rgba(37, 99, 235, 0.16), transparent 33%),
        #0f172a;
    scrollbar-width: thin;
    scrollbar-color: #334155 transparent;
}

.sidebar-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 22px;
    padding: 0 4px;
}

.brand-block {
    min-width: 0;
    flex: 1;
    margin: 0;
    color: #ffffff;
    text-decoration: none;
}

.brand-block:hover .brand-logo {
    transform: translateY(-1px);
    box-shadow: 0 10px 24px rgba(37, 99, 235, 0.34);
}

.brand-logo {
    width: 44px;
    height: 44px;
    flex: 0 0 44px;
    border-radius: 13px;
    box-shadow: 0 8px 20px rgba(37, 99, 235, 0.24);
    transition: transform 140ms ease, box-shadow 140ms ease;
}

.brand-copy {
    min-width: 0;
}

.brand-copy h1 {
    overflow: hidden;
    font-size: 20px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.brand-copy p {
    color: #94a3b8;
    letter-spacing: 0.01em;
}

.sidebar-close {
    display: none;
    width: 38px;
    height: 38px;
    flex: 0 0 38px;
    border: 1px solid var(--sidebar-border);
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.05);
    color: #ffffff;
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
}

.nav-menu {
    gap: 6px;
}

.nav-menu a,
.nav-section-summary {
    -webkit-tap-highlight-color: transparent;
}

.nav-link,
.nav-section-summary {
    display: flex;
    min-height: 44px;
    align-items: center;
    gap: 11px;
    padding: 10px 12px;
    border: 1px solid transparent;
    border-radius: 11px;
    color: var(--sidebar-text);
    font-size: 14px;
    font-weight: 650;
    line-height: 1.25;
    text-decoration: none;
    transition: background 130ms ease, border-color 130ms ease, color 130ms ease;
}

.nav-link:hover,
.nav-section-summary:hover {
    border-color: rgba(148, 163, 184, 0.14);
    background: rgba(255, 255, 255, 0.055);
    color: #ffffff;
}

.nav-link.active,
.nav-section-summary.active {
    border-color: var(--sidebar-active-border);
    background: var(--sidebar-active);
    color: #ffffff;
}

.nav-link-primary {
    margin-bottom: 4px;
}

.nav-icon {
    width: 20px;
    height: 20px;
    flex: 0 0 20px;
    color: #9fb0c8;
}

.nav-link.active .nav-icon,
.nav-section-summary.active .nav-icon,
.nav-link:hover .nav-icon,
.nav-section-summary:hover .nav-icon {
    color: #bfdbfe;
}

.nav-icon svg {
    display: block;
    width: 100%;
    height: 100%;
    fill: currentColor;
}

.nav-section {
    margin: 0;
}

.nav-section > summary {
    list-style: none;
    cursor: pointer;
    user-select: none;
}

.nav-section > summary::-webkit-details-marker {
    display: none;
}

.nav-section-summary {
    justify-content: space-between;
}

.nav-section-label {
    display: flex;
    min-width: 0;
    align-items: center;
    gap: 11px;
}

.nav-caret {
    color: #8494aa;
    font-size: 18px;
    line-height: 1;
    transform: rotate(-90deg);
    transition: transform 140ms ease;
}

.nav-section[open] .nav-caret {
    transform: rotate(0deg);
}

.nav-submenu {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 2px;
    margin: 4px 0 7px 22px;
    padding: 3px 0 3px 17px;
}

.nav-submenu::before {
    position: absolute;
    top: 5px;
    bottom: 5px;
    left: 0;
    width: 1px;
    background: rgba(148, 163, 184, 0.24);
    content: "";
}

.nav-menu .nav-sublink {
    position: relative;
    padding: 8px 10px;
    border-radius: 8px;
    color: #aebbd0;
    font-size: 13px;
    font-weight: 550;
    line-height: 1.3;
}

.nav-menu .nav-sublink:hover {
    background: rgba(255, 255, 255, 0.05);
    color: #ffffff;
}

.nav-menu .nav-sublink.active {
    background: rgba(59, 130, 246, 0.14);
    color: #dbeafe;
}

.nav-menu .nav-sublink.active::before {
    position: absolute;
    top: 50%;
    left: -20px;
    width: 5px;
    height: 18px;
    border-radius: 999px;
    background: #60a5fa;
    content: "";
    transform: translateY(-50%);
}

.sidebar-footer {
    margin-top: auto;
    padding: 16px 4px 0;
    border-top-color: var(--sidebar-border);
}

.account-summary {
    display: flex;
    min-width: 0;
    align-items: center;
    gap: 10px;
    padding: 8px;
    border-radius: 11px;
    color: #ffffff;
    text-decoration: none;
}

.account-summary:hover {
    background: rgba(255, 255, 255, 0.055);
}

.account-avatar {
    width: 36px;
    height: 36px;
    flex: 0 0 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid rgba(147, 197, 253, 0.5);
    border-radius: 50%;
    background: rgba(37, 99, 235, 0.2);
    color: #dbeafe;
    font-weight: 800;
}

.account-copy {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.account-copy strong,
.account-copy small {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.account-copy strong {
    color: #f8fafc;
    font-size: 13px;
}

.account-copy small {
    color: var(--sidebar-muted);
    font-size: 11px;
}

.sign-out-link {
    display: inline-block;
    margin: 6px 0 0 54px;
    color: #93c5fd;
    font-size: 12px;
    text-decoration: none;
}

.sign-out-link:hover {
    color: #dbeafe;
    text-decoration: underline;
}

.main-content {
    padding: 26px clamp(18px, 2.5vw, 34px) 40px;
}

.topbar {
    position: relative;
    margin-bottom: 24px;
    padding: 20px 22px;
    border-radius: 17px;
}

.topbar-title-row {
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 14px;
}

.page-eyebrow {
    margin: 0 0 4px !important;
    color: var(--primary) !important;
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.topbar h2 {
    font-size: clamp(24px, 2.2vw, 31px);
    letter-spacing: -0.025em;
}

.topbar p:not(.page-eyebrow) {
    max-width: 690px;
    font-size: 14px;
}

.nav-toggle {
    display: none;
    width: 42px;
    height: 42px;
    flex: 0 0 42px;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 4px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: #ffffff;
    cursor: pointer;
}

.nav-toggle span {
    width: 18px;
    height: 2px;
    border-radius: 999px;
    background: #334155;
}

.sidebar-overlay {
    display: none;
}

.panel,
.stat-card,
.topbar {
    border-color: #e2e8f0;
    box-shadow: 0 10px 28px rgba(15, 23, 42, 0.055);
}

.panel {
    border-radius: 16px;
}

.primary-button,
.secondary-button,
.danger-button,
.action-button {
    transition: transform 110ms ease, box-shadow 110ms ease, background 110ms ease;
}

.primary-button:hover,
.secondary-button:hover,
.danger-button:hover,
.action-button:hover {
    transform: translateY(-1px);
}

.primary-button:focus-visible,
.secondary-button:focus-visible,
.danger-button:focus-visible,
.action-button:focus-visible,
.nav-link:focus-visible,
.nav-sublink:focus-visible,
.nav-section-summary:focus-visible,
.nav-toggle:focus-visible,
.sidebar-close:focus-visible {
    outline: 3px solid rgba(96, 165, 250, 0.45);
    outline-offset: 2px;
}

@media (max-width: 1000px) {
    .app-shell {
        display: block;
    }

    .sidebar {
        position: fixed;
        top: 0;
        bottom: 0;
        left: 0;
        z-index: 12000;
        width: min(88vw, 300px);
        height: 100vh;
        transform: translateX(-105%);
        transition: transform 180ms ease;
    }

    body.sidebar-open {
        overflow: hidden;
    }

    body.sidebar-open .sidebar {
        transform: translateX(0);
    }

    .sidebar-close,
    .nav-toggle {
        display: flex;
    }

    .sidebar-overlay {
        position: fixed;
        inset: 0;
        z-index: 11000;
        border: 0;
        background: rgba(15, 23, 42, 0.58);
        opacity: 0;
        pointer-events: none;
        transition: opacity 180ms ease;
    }

    body.sidebar-open .sidebar-overlay {
        display: block;
        opacity: 1;
        pointer-events: auto;
    }

    .main-content {
        width: 100%;
    }

    .topbar {
        width: 100%;
        flex-direction: row;
        align-items: center;
    }
}

@media (max-width: 720px) {
    .main-content {
        padding: 14px 12px 28px;
    }

    .topbar {
        align-items: stretch;
        gap: 16px;
        padding: 16px;
    }

    .topbar-title-row {
        align-items: flex-start;
    }

    .topbar-actions {
        width: 100%;
    }

    .topbar-actions a {
        flex: 1;
    }

    .panel {
        padding: 18px;
    }

    .panel-header {
        align-items: flex-start;
        flex-direction: column;
    }

    .panel-header > .primary-button,
    .panel-header > .secondary-button {
        width: 100%;
    }

    .stats-grid {
        grid-template-columns: 1fr 1fr;
        gap: 12px;
    }
}

@media (max-width: 460px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }

    .topbar-actions {
        flex-direction: column;
    }
}
