/* Спейсер в потоке документа — высота задаётся в topbar.js под реальную высоту панели */
.app-topbar-spacer {
    width: 100%;
    flex-shrink: 0;
    pointer-events: none;
}

.app-topbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    width: 100%;
    z-index: 900;
    background: #ffffff;
    border-bottom: 1px solid #e5e7eb;
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.06);
    font-family: 'Inter', 'Nunito', sans-serif;
    font-synthesis-weight: none;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

.app-topbar-inner {
    width: 100%;
    padding: 0 12px;
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 56px;
    min-width: 0;
    box-sizing: border-box;
}

.app-top-logo {
    flex-shrink: 0;
    font-size: 1.2rem;
    font-weight: 900;
    font-family: 'Inter', 'Nunito', sans-serif;
    color: #0f172a;
    text-decoration: none;
    letter-spacing: -0.02em;
}

/* Ссылки + «Предметы»: переносятся на новые строки, без горизонтального скролла */
.app-topbar-nav-block {
    flex: 1 1 160px;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px 10px;
    min-width: 0;
}

.app-top-nav-links {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px 10px;
    min-width: 0;
}

/* Три предмета — всегда видны (в т.ч. для детей), без выпадающего меню */
.app-top-subjects {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px 8px;
    padding-right: 8px;
    margin-right: 4px;
    border-right: 1px solid #e2e8f0;
}

.app-top-logo span {
    color: #3b82f6;
}

.app-top-link {
    color: #475569;
    text-decoration: none;
    font-weight: 700;
    font-size: 0.88rem;
    padding: 6px 10px;
    border-radius: 8px;
    transition: background 0.15s, color 0.15s;
    line-height: 1.25;
    text-align: center;
}

.app-top-link:hover {
    background: #f1f5f9;
    color: #0f172a;
}
.app-top-dropdown {
    position: relative;
    flex-shrink: 0;
}
.app-top-dropdown-toggle {
    border: 0;
    background: transparent;
    cursor: pointer;
}
.app-top-dropdown-menu {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    min-width: 180px;
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    box-shadow: 0 8px 22px rgba(15, 23, 42, 0.12);
    padding: 6px;
    display: none;
    z-index: 200;
}
.app-top-dropdown.is-open .app-top-dropdown-menu {
    display: block;
}
.app-top-dropdown-item {
    display: block;
    text-decoration: none;
    color: #334155;
    font-size: 0.86rem;
    font-weight: 700;
    border-radius: 8px;
    padding: 8px 10px;
}
.app-top-dropdown-item:hover {
    background: #f1f5f9;
    color: #0f172a;
}

.app-topbar-right {
    flex: 0 1 auto;
    margin-left: auto;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: 6px;
    min-width: 0;
    max-width: 100%;
}

.app-topbar #admin-link-wrap {
    margin-bottom: 0;
    margin-right: 8px;
}

.app-topbar #admin-link-wrap a {
    color: #3b82f6;
    font-size: 0.85rem;
    font-weight: 700;
    text-decoration: none;
}

.app-topbar .btn-download {
    margin-bottom: 0;
    padding: 6px 12px;
    font-size: 0.82rem;
    border-radius: 6px;
}

.app-topbar .auth-panel {
    margin-top: 0;
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 6px;
}

.app-topbar .auth-panel form {
    gap: 5px;
}

.app-topbar .auth-panel input[type="text"],
.app-topbar .auth-panel input[type="password"] {
    padding: 6px 8px;
    font-size: 0.82rem;
    min-width: 100px;
    border-radius: 6px;
}

.app-topbar .auth-panel button {
    padding: 6px 12px;
    font-size: 0.82rem;
    font-weight: 700;
    border-radius: 6px;
}

.app-topbar .auth-user {
    gap: 10px;
    font-size: 0.9rem;
    font-weight: 700;
}

.page-with-topbar {
    padding-top: 10px;
}

@media (min-width: 900px) {
    .app-topbar-inner {
        padding: 0 28px;
        gap: 12px 20px;
    }
    .app-top-link {
        padding: 6px 14px;
    }
}

/* Узкий экран / планшет портрет: строка 1 — логотип и действия; строка 2 — навигация на всю ширину */
@media (max-width: 899px) {
    /* На телефоне верхнее меню НЕ фиксируем: скроллится вместе со страницей */
    .app-topbar {
        position: static;
        box-shadow: none;
    }
    .app-topbar-spacer {
        display: none !important;
        height: 0 !important;
    }

    .app-topbar-inner {
        min-height: auto;
        align-items: flex-start;
        padding: 10px 12px;
        row-gap: 10px;
    }
    .app-top-logo {
        order: 1;
    }
    .app-topbar-right {
        order: 2;
        margin-left: auto;
        justify-content: flex-end;
        max-width: calc(100% - 120px);
    }
    .app-topbar-nav-block {
        order: 3;
        flex: 1 1 100%;
        width: 100%;
        padding-top: 8px;
        border-top: 1px solid #e5e7eb;
    }
    .app-top-link {
        font-size: 0.82rem;
        padding: 8px 10px;
    }
    .app-topbar .auth-panel {
        flex-wrap: wrap;
        justify-content: flex-end;
    }
    .app-topbar .auth-user {
        font-size: 0.82rem;
        flex-wrap: wrap;
        justify-content: flex-end;
    }
}
