.navbar {
    position: sticky;
    z-index: 1100;
    top: 0;
    padding: 0.65rem 0;
    border-bottom: 1px solid rgba(23, 53, 43, 0.09);
    background: rgba(255, 255, 255, 0.88);
    box-shadow: 0 8px 30px rgba(15, 48, 37, 0.045);
    backdrop-filter: blur(18px) saturate(150%);
}

.navbar,
.navbar * {
    box-sizing: border-box;
}

.navbar .container {
    width: min(1320px, 94vw);
    gap: 1rem;
}

.navbar-brand-group {
    flex: 0 0 auto;
}

.navbar-brand {
    gap: 0.5rem;
    color: #0b6f48;
    font-size: 1.05rem;
    font-weight: 780;
    letter-spacing: -0.025em;
}

.navbar-brand:hover {
    color: #075d3c;
}

.navbar-brand__logo {
    width: 30px;
    height: 30px;
}

.navbar-nav {
    gap: 0.12rem;
}

.nav-link {
    position: relative;
    min-height: 40px;
    padding: 0.55rem 0.58rem;
    border-radius: 11px;
    color: #52635c;
    font-size: 0.76rem;
    font-weight: 680;
    white-space: nowrap;
    transition: color 170ms ease, background 170ms ease, transform 170ms ease;
}

.nav-link:hover {
    color: #08734a;
    background: rgba(22, 166, 106, 0.07);
}

.nav-link.is-active {
    color: #08734a;
    background: #e3f6ed;
    box-shadow: inset 0 0 0 1px rgba(22, 166, 106, 0.08);
}

.nav-link.is-active::after {
    content: '';
    position: absolute;
    left: 50%;
    bottom: 0;
    width: 26px;
    height: 3px;
    border-radius: 999px;
    background: linear-gradient(90deg, #13a668, #55d79b);
    box-shadow: 0 2px 8px rgba(19, 166, 104, 0.28);
    transform: translateX(-50%);
}

.nav-link svg {
    width: 17px;
    height: 17px;
    flex: 0 0 17px;
}

.nav-link svg[fill='none'] path,
.nav-link svg[fill='none'] rect,
.nav-link svg[fill='none'] circle {
    fill: none;
    stroke: currentColor;
}

.nav-link--logout:hover {
    color: #b84d46;
    background: rgba(216, 93, 84, 0.07);
}

.nav-logout-form {
    margin: 0;
}

button.nav-link {
    width: 100%;
    border: 0;
    font: inherit;
    text-align: left;
    cursor: pointer;
}

.nav-badge {
    min-width: 18px;
    padding: 0.12rem 0.35rem;
    border: 2px solid var(--color-surface);
    border-radius: 999px;
    background: #dc5b50;
    font-size: 0.58rem;
    line-height: 1.15;
    text-align: center;
}

.nav-badge--square {
    min-width: 18px;
    height: 18px;
    padding: 0.12rem 0.35rem;
    border-radius: 999px;
}

.nav-item--theme {
    margin-left: 0.25rem;
}

.theme-toggle {
    display: grid;
    width: 40px;
    height: 40px;
    padding: 0;
    place-items: center;
    border: 1px solid rgba(23, 53, 43, 0.1);
    border-radius: 11px;
    color: #52635c;
    background: rgba(101, 118, 111, 0.055);
}

.theme-toggle:hover {
    color: #08734a;
    border-color: rgba(22, 166, 106, 0.22);
    background: rgba(22, 166, 106, 0.07);
}

.theme-toggle__icon {
    width: 18px;
    height: 18px;
}

.theme-toggle__label {
    display: none;
}

.navbar-toggle {
    width: 42px;
    height: 42px;
    border-color: rgba(23, 53, 43, 0.12);
    border-radius: 12px;
    background: rgba(101, 118, 111, 0.055);
}

.navbar-toggle span {
    width: 19px;
    background: #173c30;
}

html.theme-dark .navbar {
    border-color: rgba(153, 191, 176, 0.1);
    background: rgba(7, 17, 29, 0.88);
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.18);
}

html.theme-dark .navbar-brand {
    color: #70dfa9;
}

html.theme-dark .nav-link {
    color: #aebeb7;
}

html.theme-dark .nav-link:hover,
html.theme-dark .nav-link.is-active {
    color: #72e1aa;
    background: rgba(58, 203, 139, 0.11);
}

html.theme-dark .theme-toggle,
html.theme-dark .navbar-toggle {
    color: #aebeb7;
    border-color: rgba(153, 191, 176, 0.14);
    background: rgba(148, 163, 184, 0.07);
}

html.theme-dark .navbar-toggle span {
    background: #e6f3ed;
}

@media (min-width: 993px) and (max-width: 1240px) {
    .navbar .container {
        width: min(1160px, 96vw);
    }

    .nav-link {
        padding-inline: 0.6rem;
    }

    .nav-link > span {
        position: absolute;
        width: 1px;
        height: 1px;
        padding: 0;
        overflow: hidden;
        clip: rect(0, 0, 0, 0);
        white-space: nowrap;
        border: 0;
    }

    .nav-link.is-active::after {
        bottom: 1px;
    }
}

@media (max-width: 992px) {
    body.nav-menu-open {
        overflow: hidden;
    }

    .navbar {
        padding: 0.55rem 0;
    }

    .navbar .container {
        position: relative;
        width: min(100% - 1.5rem, 720px);
        flex-direction: row;
        align-items: center;
        gap: 0.75rem;
    }

    .navbar-brand-group {
        width: 100%;
    }

    .navbar-nav {
        position: absolute;
        top: calc(100% + 0.65rem);
        left: 0;
        right: 0;
        display: none;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 0.45rem;
        width: 100%;
        max-height: calc(100dvh - 85px);
        padding: 0.65rem;
        overflow-y: auto;
        border: 1px solid rgba(23, 53, 43, 0.11);
        border-radius: 18px;
        background: rgba(255, 255, 255, 0.97);
        box-shadow: 0 24px 65px rgba(8, 35, 26, 0.18);
        backdrop-filter: blur(20px);
    }

    .navbar-nav.is-open {
        display: grid;
        animation: nav-menu-in 180ms ease both;
    }

    .nav-item {
        width: auto;
        min-width: 0;
    }

    .nav-link {
        width: 100%;
        min-height: 58px;
        padding: 0.7rem;
        justify-content: flex-start;
        border: 1px solid rgba(23, 53, 43, 0.07);
        border-radius: 13px;
        background: #f7faf8;
        font-size: 0.76rem;
    }

    .nav-link svg {
        width: 19px;
        height: 19px;
        flex-basis: 19px;
    }

    .nav-link.is-active::after {
        top: 50%;
        right: 8px;
        bottom: auto;
        left: auto;
        width: 3px;
        height: 18px;
        transform: translateY(-50%);
    }

    .nav-item--theme {
        grid-column: 1 / -1;
        margin-left: 0;
    }

    .nav-item--theme .theme-toggle {
        display: flex;
        width: 100%;
        height: 48px;
        gap: 0.55rem;
        justify-content: center;
        border-radius: 12px;
    }

    .theme-toggle__label {
        display: inline;
        font-size: 0.72rem;
    }

    html.theme-dark .navbar-nav {
        border-color: rgba(153, 191, 176, 0.14);
        background: rgba(9, 20, 34, 0.98);
        box-shadow: 0 24px 65px rgba(0, 0, 0, 0.38);
    }

    html.theme-dark .nav-link {
        border-color: rgba(153, 191, 176, 0.08);
        background: rgba(148, 163, 184, 0.055);
    }
}

@keyframes nav-menu-in {
    from { opacity: 0; transform: translateY(-8px) scale(0.985); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

@media (max-width: 420px) {
    .navbar-nav {
        grid-template-columns: 1fr;
    }

    .nav-item--theme {
        grid-column: 1;
    }
}
