.app-shell {
    --sidebar-expanded-width: 272px;
    --sidebar-width: var(--sidebar-expanded-width);
    --sidebar-toggle-size: 32px;
    display: grid;
    grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
    min-height: 100vh;
    position: relative;
    transition: grid-template-columns 220ms ease;
}

body:has(.fill-page) .app-shell {
    --sidebar-expanded-width: 232px;
    --sidebar-width: var(--sidebar-expanded-width);
    grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
}

.sidebar {
    position: relative;
    overflow: hidden;
    background:
        linear-gradient(180deg, #071936 0%, #081b3b 58%, #091c3d 100%);
    color: #f6f2ea;
    padding: 24px 18px;
    border-right: 1px solid rgba(201, 169, 107, 0.16);
    transition:
        transform 220ms ease,
        opacity 220ms ease;
    transform: translateX(0);
    transform-origin: left center;
}

.sidebar::after {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 520px;
    background:
        linear-gradient(180deg, rgba(7, 25, 54, 0) 0%, rgba(7, 25, 54, 0.12) 22%, rgba(7, 25, 54, 0.34) 48%, rgba(7, 25, 54, 0) 100%),
        url("../img/sidebar-bg.png") no-repeat left bottom;
    background-size: 100% auto;
    opacity: 1;
    pointer-events: none;
    z-index: 0;
}

.sidebar > * {
    position: relative;
    z-index: 1;
}

body:has(.fill-page) .sidebar {
    padding: 30px 0 28px;
    background:
        radial-gradient(circle at -8% 118%, rgba(201, 169, 107, 0.08), transparent 26%),
        linear-gradient(180deg, #071936 0%, #081b3b 58%, #091c3d 100%);
    border-right-color: rgba(201, 169, 107, 0.12);
}

body:has(.fill-page) .sidebar::after {
    height: 520px;
    background:
        linear-gradient(180deg, rgba(7, 25, 54, 0) 0%, rgba(7, 25, 54, 0.14) 22%, rgba(7, 25, 54, 0.36) 48%, rgba(7, 25, 54, 0) 100%),
        url("../img/sidebar-bg.png") no-repeat left bottom;
    background-size: 100% auto;
    opacity: 1;
}

.brand {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 28px;
}

body:has(.fill-page) .brand {
    padding: 0 22px;
    margin-bottom: 34px;
}

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

.brand-mark {
    width: 44px;
    height: 44px;
    border-radius: 14px;
    display: grid;
    place-items: center;
    background: linear-gradient(180deg, #d6bc88 0%, #c9a96b 100%);
    color: var(--color-primary-deep);
    font-weight: 700;
    letter-spacing: 0.03em;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.32);
}

.brand-mark.large {
    width: 64px;
    height: 64px;
    border-radius: 18px;
    font-size: 1.25rem;
}

.brand-title {
    font-size: 1rem;
    font-weight: 700;
    line-height: 1.2;
    color: #f7f3eb;
}

.brand-subtitle {
    margin-top: 4px;
    font-size: 0.875rem;
    color: rgba(244, 235, 217, 0.72);
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

body:has(.fill-page) .sidebar-nav {
    gap: 6px;
}

.nav-link {
    position: relative;
    display: flex;
    align-items: center;
    min-height: 46px;
    padding: 0 14px;
    border: 1px solid transparent;
    border-radius: 14px;
    color: rgba(247, 243, 235, 0.82);
    font-weight: 500;
}

body:has(.fill-page) .nav-link {
    min-height: 58px;
    padding: 0 24px;
    border-radius: 0;
    border-left: 0;
    border-right: 0;
    color: rgba(247, 243, 235, 0.86);
}

.nav-link:hover {
    background: rgba(255, 255, 255, 0.05);
    color: #fffaf2;
}

.nav-link.active {
    background: rgba(201, 169, 107, 0.12);
    border-color: rgba(201, 169, 107, 0.18);
    color: #fff7ea;
}

body:has(.fill-page) .nav-link.active {
    background: rgba(255, 255, 255, 0.06);
    border-color: transparent;
}

.nav-link.active::before {
    content: "";
    position: absolute;
    left: 8px;
    top: 11px;
    bottom: 11px;
    width: 3px;
    border-radius: 999px;
    background: var(--color-gold);
}

body:has(.fill-page) .nav-link.active::before {
    left: auto;
    right: 0;
    top: 12px;
    bottom: 12px;
    width: 4px;
    background: linear-gradient(180deg, #dcc18b 0%, #c9a96b 100%);
    box-shadow: -1px 0 10px rgba(201, 169, 107, 0.14);
}

.main-shell {
    min-width: 0;
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.sidebar-toggle {
    position: absolute;
    top: 24px;
    left: calc(var(--sidebar-width) - (var(--sidebar-toggle-size) / 2));
    width: var(--sidebar-toggle-size);
    height: var(--sidebar-toggle-size);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    border: 1px solid rgba(201, 169, 107, 0.2);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.92);
    color: #21304f;
    box-shadow: 0 8px 18px rgba(15, 23, 42, 0.08);
    cursor: pointer;
    z-index: 4;
    transition:
        left 220ms ease,
        transform 220ms ease,
        background-color 180ms ease,
        border-color 180ms ease,
        color 180ms ease,
        box-shadow 180ms ease;
}

.sidebar-toggle:hover {
    background: #ffffff;
    border-color: rgba(201, 169, 107, 0.32);
    color: #101935;
}

.sidebar-toggle-icon {
    font-size: 20px;
    line-height: 1;
    transform: translateY(-1px);
}

.app-shell.sidebar-collapsed {
    --sidebar-width: 0px;
    grid-template-columns: 0 minmax(0, 1fr);
}

body:has(.fill-page) .app-shell.sidebar-collapsed {
    --sidebar-width: 0px;
    grid-template-columns: 0 minmax(0, 1fr);
}

.app-shell.sidebar-collapsed .sidebar {
    transform: translateX(calc(-1 * var(--sidebar-expanded-width)));
    opacity: 0.98;
    width: 0;
    min-width: 0;
    border-right-width: 0;
    padding-left: 0;
    padding-right: 0;
}

.app-shell.sidebar-collapsed .sidebar-toggle {
    left: 10px;
}

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 18px;
    padding: 24px 28px 0;
}

body:has(.fill-page) .topbar {
    padding: 30px 30px 0;
    gap: 24px;
}

.page-heading {
    min-width: 0;
}

body:has(.fill-page) .page-heading {
    position: relative;
    padding-bottom: 26px;
}

.page-title {
    margin: 0;
    font-size: clamp(1.85rem, 2.1vw, 2.15rem);
    font-weight: 700;
    letter-spacing: -0.02em;
    line-height: 1.15;
}

body:has(.fill-page) .page-title {
    font-size: 3rem;
    font-weight: 700;
    letter-spacing: -0.045em;
    line-height: 1.05;
    color: #101935;
}

body:has(.fill-page) .page-heading::after {
    content: "";
    position: absolute;
    left: 2px;
    bottom: 0;
    width: 52px;
    height: 4px;
    border-radius: 999px;
    background: linear-gradient(90deg, #cba867 0%, #d5b77f 100%);
}

.page-subtitle {
    display: none;
    margin: 8px 0 0;
    color: var(--muted);
    font-size: 0.95rem;
    line-height: 1.5;
}

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

.language-switcher {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 4px 0;
}

.language-switcher-label {
    color: var(--muted);
    font-size: 0.9rem;
    font-weight: 500;
}

.language-switcher-options {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px;
    border: 1px solid rgba(148, 163, 184, 0.18);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.82);
}

.language-switcher-option {
    min-height: 32px;
    padding: 0 12px;
    border: 0;
    border-radius: 999px;
    background: transparent;
    color: var(--text-soft);
    font-size: 0.88rem;
    font-weight: 600;
    cursor: pointer;
    box-shadow: none;
}

.language-switcher-option.active {
    background: rgba(13, 27, 61, 0.1);
    color: var(--primary);
}

.language-switcher-option:hover {
    color: var(--text);
}

.user-chip {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    padding: 4px 0;
    border: 0;
    background: transparent;
    box-shadow: none;
}

.user-chip-name {
    font-weight: 600;
}

.user-chip-role {
    margin-top: 2px;
    color: var(--muted);
    font-size: 0.84rem;
}

.page-content {
    padding: 0 28px 28px;
}

body:has(.fill-page) .page-content {
    padding: 0 30px 28px;
}

.page-grid {
    display: grid;
    gap: 20px;
}

.page-grid.two-column {
    grid-template-columns: minmax(320px, 420px) minmax(0, 1fr);
}

.login-body {
    min-height: 100vh;
    display: grid;
    place-items: center;
}

.login-shell {
    width: min(100%, 440px);
    padding: 24px;
}

@media (max-width: 960px) {
    .app-shell {
        grid-template-columns: 1fr;
    }

    .sidebar {
        display: none;
    }

    .sidebar-toggle {
        display: none;
    }

    .page-grid.two-column {
        grid-template-columns: 1fr;
    }

    .topbar {
        padding: 18px 18px 0;
        flex-direction: column;
        align-items: flex-start;
        gap: 14px;
    }

    .topbar-actions {
        width: 100%;
        justify-content: flex-start;
    }

    .user-chip {
        align-items: flex-start;
    }

    .page-content {
        padding: 0 18px 18px;
    }
}
