/* 1. Переменные */
:root {
    --earth: #8B5A2B;
    --sage: #8A9B6E;
    --moss: #4A7C59;
    --sand: #D7C0A9;
    --clay: #D77A61;
    --sky: #A7C4C2;
    --stone: #9da2a0;
    --light-sand: #F0E8DE;
    --light-stone: #E8E8E8;
    --bg-primary: #B8D1C6;
    --card-bg: #C5D9C1;
    --header-bg: #D7C0A9;
    --footer-bg: #D7C0A9;
    --input-bg: #D7C0A9;
    --input-bg-hover: rgba(0, 0, 0, 0.1);
    --text-primary: #2F4858;
    --link-color: #4A7C59;
    --border-color: #8A9B6E;
    --border-radius: 12px;
    --standard-width: 400px;
    --gutter: 0.5rem;
    --card-padding: 1rem;
}

/* 2. Базовые стили */
body {
    font-family: system-ui, -apple-system, sans-serif;
    line-height: 1.6;
    color: var(--text-primary);
    background-color: var(--bg-primary);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    margin: 0;
    overflow-x: hidden;
}

/* 3. Контейнеры и макет */
main {
    flex-grow: 1;
    width: calc(100% - 2rem);
    max-width: 1600px;
    margin: 0 auto;
    overflow-x: hidden;
}

main.container,
main.container-xl {
    background: var(--card-bg);
    border-radius: var(--border-radius);
    padding: 1.5rem;
    margin: 0 auto;
    width: 100%;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
}

main.container.d-flex.flex-column.flex-grow-1.py-4 {
    background: var(--bg-primary);
    border-radius: var(--border-radius);
}

/* 4. Навигация и футер */
.navbar,
.footer {
    background-color: var(--header-bg);
    border-radius: var(--border-radius);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    width: calc(100% - 2rem);
    max-width: 1600px;
    margin: 1rem auto;
    padding: 0.5rem;
}

/* 5. Компоненты */

/* 5.1 Кнопки */
.btn {
    border-radius: var(--border-radius);
    padding: 0.6rem 1.5rem;
    transition: all 0.3s ease;
    border: 2px solid;
    font-weight: normal;
    text-transform: none;
}

.btn-icon {
    padding: 0.4rem;
    line-height: 1;
    width: 2.5rem;
    height: 2.5rem;
    position: relative;
}

.btn-primary {
    background-color: var(--moss);
    border-color: var(--moss);
    color: white;
}

.btn-primary:hover {
    background-color: #3a6b4a;
    border-color: #3a6b4a;
    transform: translateY(-2px);
}

.btn-secondary {
    background-color: var(--stone);
    border-color: var(--stone);
    color: white;
}

.btn-secondary:hover {
    background-color: #8a8f8d;
    border-color: #8a8f8d;
    transform: translateY(-2px);
}

.btn-register {
    background-color: var(--moss);
    border-color: var(--moss);
    color: white;
    padding: 0.6rem 1rem;
}

.btn-register:hover {
    background-color: #3a6b4a;
    border-color: #3a6b4a;
    transform: translateY(-2px);
}

.btn-login {
    border: 2px solid var(--moss);
    color: var(--moss);
    background: none;
    padding: 0.4rem;
}

.btn-login:hover {
    background-color: var(--moss);
    color: white;
    transform: translateY(-2px);
}

.btn-highlight {
    border-color: var(--moss);
    color: var(--moss);
    background: none;
}

.btn-highlight:hover {
    background-color: var(--moss);
    color: white;
}

.btn-profile {
    background: var(--moss);
    border-color: var(--moss);
    color: white;
}

.btn-profile:hover {
    background: #3a6b4a;
    border-color: #3a6b4a;
    transform: translateY(-2px);
}

.btn-shadow-danger,
.btn-shadow {
    border-color: var(--clay);
    color: var(--moss);
    background: none;
}

.btn-shadow-danger:hover,
.btn-shadow:hover {
    background-color: var(--clay);
    color: white;
}

.btn-edit,
.btn-change-password {
    background: transparent;
    border: 2px solid var(--clay);
    color: var(--clay);
    width: 2.5rem;
    height: 2.5rem;
    border-radius: var(--border-radius);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.btn-edit:hover,
.btn-change-password:hover {
    background: var(--clay);
    color: white;
    transform: translateY(-2px);
}

.btn-edit[aria-label]::after,
.btn-change-password[aria-label]::after {
    content: attr(aria-label);
    position: absolute;
    top: -2rem;
    left: 50%;
    transform: translateX(-50%);
    background-color: var(--light-sand);
    color: var(--text-primary);
    padding: 4px 8px;
    border-radius: 5px;
    font-size: 0.75rem;
    white-space: nowrap;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease, visibility 0s ease 0.2s;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    pointer-events: none;
}

.btn-edit:hover[aria-label]::after,
.btn-change-password:hover[aria-label]::after {
    opacity: 1;
    visibility: visible;
    transition: opacity 0.2s ease, visibility 0s;
}

.navbar .btn-icon,
.navbar .theme-toggle {
    width: 2.5rem;
    height: 2.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--border-radius);
    transition: all 0.3s ease;
    font-size: 1.1rem;
}

.navbar .btn-icon[aria-label]::after,
.navbar .theme-toggle[aria-label]::after {
    content: attr(aria-label);
    position: absolute;
    top: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    background-color: var(--light-sand);
    color: var(--text-primary);
    padding: 4px 8px;
    border-radius: 5px;
    font-size: 0.75rem;
    white-space: nowrap;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: transform 0.3s ease, opacity 0s, visibility 0s 0.3s;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    pointer-events: none;
}

.navbar .btn-icon:hover[aria-label]::after,
.navbar .btn-icon:focus[aria-label]::after,
.navbar .theme-toggle:hover[aria-label]::after,
.navbar .theme-toggle:focus[aria-label]::after {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(5px);
    transition: transform 0.3s ease, opacity 0s, visibility 0s;
}

.theme-toggle {
    background: none;
    border: 2px solid var(--stone);
    color: var(--text-primary);
    padding: 0.4rem;
    width: 2.5rem;
    height: 2.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--border-radius);
    transition: all 0.3s ease;
}

.theme-toggle:hover {
    background-color: var(--stone);
    color: white;
    transform: translateY(-2px);
}

/* 5.2 Карточка профиля */
.profile-card {
    background: var(--card-bg);
    border-radius: var(--border-radius);
    padding: 1.5rem;
    margin: 1rem 0;
}

.profile-header {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    margin-bottom: 1.5rem;
}

.header-content {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 1rem;
    flex-grow: 1;
}

.profile-avatar {
    width: 100px;
    height: 100px;
    background: var(--moss);
    color: white;
    font-size: 2.5rem;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.profile-info h1 {
    margin: 0;
    font-size: 1.75rem;
    color: var(--text-primary);
}

.profile-info .lead {
    margin: 0;
    color: var(--stone);
}

.action-buttons {
    display: flex;
    flex-direction: row;
    gap: 0.5rem;
    align-items: center;
    margin-top: 0.5rem;
}

.profile-details {
    margin-top: 1.5rem;
}

.detail-container {
    display: flex;
    flex-wrap: wrap;
    gap: var(--gutter);
    width: 100%;
}

.detail-card {
    background: var(--light-sand);
    border-radius: var(--border-radius);
    padding: var(--card-padding);
    border: 1px solid rgba(0, 0, 0, 0.1);
    flex: 1 1 calc(33.33% - (var(--gutter) * 2 / 3));
    min-width: 250px;
    box-sizing: border-box;
}

.detail-card h3 {
    margin: 0 0 1rem;
    font-size: 1.25rem;
    color: var(--text-primary);
}

.detail-card h3 i {
    margin-right: 0.5rem;
}

.detail-item {
    margin-bottom: 0.75rem;
}

.detail-item:last-child {
    margin-bottom: 0;
}

/* 5.3 Модальные окна */
.modal-content {
    border: 2px solid var(--border-color);
    border-radius: var(--border-radius);
    overflow: hidden;
}

.modal-header {
    background: var(--header-bg);
    border-bottom: 2px solid var(--border-color);
    padding: 1.5rem;
}

.modal-title {
    font-size: 1.5rem;
    color: var(--text-primary);
    margin: 0;
}

.modal-body {
    background: var(--card-bg);
    padding: 1.5rem;
    max-height: calc(70vh - 100px); /* Адаптивная высота с прокруткой */
    overflow-y: auto;
}

.modal-footer {
    background: var(--footer-bg);
    border-top: 2px solid var(--border-color);
    padding: 1rem;
}

.modal-body .modal-group {
    margin-bottom: 1rem;
}

.modal-body .modal-group:last-child {
    margin-bottom: 0;
}

.modal-body a {
    color: var(--link-color);
    text-decoration: none;
}

.modal-body a:hover {
    text-decoration: underline;
}

.modal-footer a.registration-link {
    color: var(--moss);
    text-decoration: none;
}

.modal-footer a.registration-link:hover {
    text-decoration: underline;
    color: #3a6b4a;
}

.modal .custom-select-options {
    z-index: 1010; /* Увеличен для модального окна */
}

/* 5.4 Формы и поля ввода */
.form-label {
    font-weight: 600;
    margin-bottom: 0.5rem;
    display: block;
}

.form-control {
    height: 50px;
    padding: 0.75rem 1.25rem;
    border: 2px solid var(--border-color);
    border-radius: var(--border-radius);
    background: var(--light-sand);
    color: var(--text-primary);
    font-size: 1rem;
    font-family: system-ui, -apple-system, sans-serif;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
}

.form-control:focus {
    border-color: var(--moss);
    box-shadow: 0 0 0 3px rgba(74, 124, 89, 0.2);
    background: var(--light-sand);
    color: var(--text-primary);
}

.form-control::placeholder {
    color: var(--stone);
    opacity: 0.7;
}

.input-group {
    position: relative;
    display: flex;
    align-items: stretch;
    border: 2px solid var(--border-color);
    border-radius: var(--border-radius);
    background: var(--input-bg);
    transition: all 0.3s ease;
    height: 50px;
    box-sizing: border-box;
}

.input-group:focus-within {
    border-color: var(--moss);
    box-shadow: 0 0 0 3px rgba(74, 124, 89, 0.2);
}

.input-group .form-control {
    border: none;
    border-radius: var(--border-radius) 0 0 var(--border-radius);
    height: 100%;
    padding: 0.75rem;
    background: transparent;
    flex: 1;
    box-sizing: border-box;
}

.input-group .toggle-password {
    background: none;
    border: none;
    padding: 0 12px;
    position: relative;
    z-index: 10;
    border-top-right-radius: var(--border-radius);
    border-bottom-right-radius: var(--border-radius);
    height: 100%;
    width: 40px;
    transition: background 0.2s ease;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: auto;
    margin: 0;
    box-sizing: border-box;
    line-height: 1;
}

.input-group .toggle-password:hover {
    background: var(--input-bg-hover);
}

.input-group .toggle-password:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(74, 124, 89, 0.2);
}

/* 5.5 Кастомный селект */
.custom-select-wrapper {
    position: relative;
    width: 100%;
}

.custom-select {
    position: relative;
    border: 2px solid var(--border-color);
    border-radius: var(--border-radius);
    background: var(--light-sand);
    cursor: pointer;
    height: 50px;
    display: flex;
    align-items: center;
    padding: 0.75rem 1.25rem;
    color: var(--text-primary);
}

.custom-select-display {
    flex-grow: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.custom-select-options {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    border: 2px solid var(--border-color);
    border-radius: var(--border-radius);
    background: var(--light-sand);
    margin-top: 2px;
    list-style: none;
    padding: 0;
    z-index: 1000;
    max-height: calc(50vh - 50px); /* Адаптивная высота */
    overflow-y: auto;
    display: none;
    animation: slideDown 0.3s forwards;
}

.custom-select-options li {
    padding: 0.5rem 1rem;
    cursor: pointer;
}

.custom-select-options li:hover {
    background: var(--sand);
    color: var(--text-primary);
}

.custom-select.active .custom-select-options {
    display: block;
}

/* 5.6 Поиск */
.search-container {
    position: relative;
    width: 100%;
    max-width: 500px;
}

.search-container .form-control.search-input {
    padding-left: 2.5rem;
    background-color: #F3ECE7;
    transition: border-color 0.3s ease-in-out, box-shadow 0.3s ease-in-out;
    font-size: 1rem;
}

.search-container .form-control.search-input:focus {
    padding-left: 2.5rem;
    border-color: var(--moss);
    box-shadow: 0 0 0 3px rgba(74, 124, 89, 0.2);
    background-color: #F3ECE7;
}

.search-container .form-control.search-input.compact-search {
    width: 100%;
    height: 40px;
    font-size: 1rem;
    padding: 0.5rem 0.75rem 0.5rem 2.5rem;
    background: #F3ECE7;
    border: 2px solid var(--border-color);
    border-radius: var(--border-radius);
    transition: border-color 0.3s ease-in-out, box-shadow 0.3s ease-in-out;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' fill='%232F3232' viewBox='0 0 24 24'%3E%3Cpath d='M11.375 10.344a6.375 0 1 0-1.375 1.375h-.001c.03.04.062.078.098.115l3.375.375h0a3 3 0 0 0 1.375-1.375l-3.375-3.375a3.007 3.007 0 0 0-.115-.1zM12 6.375a5.375 0 1 1-11 0 5.375 0 1 1 11 0z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: left 0.75rem center;
    background-size: 20px;
}

.search-container .form-control.search-input.compact-search:focus {
    border-color: var(--moss);
    box-shadow: 0 0 0 3px rgba(74, 124, 89, 0.2);
    background-image: none;
    padding-left: 0.75rem;
}

.search-container .form-control.search-input.compact-search::placeholder {
    color: var(--stone);
    opacity: 0.7;
}

.search-container .search-tooltip {
    visibility: hidden;
    position: absolute;
    background: #E8DED5;
    color: var(--text-primary);
    padding: 0.5rem 1rem;
    border-radius: 5px;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
    white-space: nowrap;
    z-index: 1002;
    opacity: 0;
    transition: opacity 0.3s ease, transform 0.3s ease;
    font-size: 0.85rem;
    font-weight: bold;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    margin-bottom: 8px;
}

.search-container:hover .search-tooltip {
    visibility: visible;
    opacity: 1;
    transform: translateX(-50%) translateY(-4px);
}

/* 5.7 Автодополнение */
@keyframes slideDown {
    0% { opacity: 0; transform: translateY(-10px); }
    100% { opacity: 1; transform: translateY(0); }
}

.autocomplete-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background-color: var(--input-bg);
    border: 2px solid var(--border-color);
    border-radius: 0 0 var(--border-radius) var(--border-radius);
    z-index: 1000;
    max-height: 250px;
    overflow-y: auto;
    display: none;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
}

.autocomplete-dropdown.active {
    display: block;
    animation: slideDown 0.3s forwards;
}

.suggestion-item {
    padding: 8px 12px;
    cursor: pointer;
    transition: background-color 0.2s ease;
    display: flex;
    align-items: center;
    color: var(--text-primary);
}

.suggestion-item:hover,
.suggestion-item.active {
    background-color: var(--light-sand);
}

.suggestion-content {
    display: flex;
    align-items: center;
    gap: 8px;
}

.suggestion-icon {
    color: var(--moss);
    font-size: 1.2rem;
}

.suggestion-title {
    font-weight: normal;
    color: var(--earth);
}

/* 5.8 Информационные иконки и тултипы */
@keyframes pulse {
    0% { transform: translateY(-0.7rem) scale(1); }
    50% { transform: translateY(-0.7rem) scale(1.1); }
    100% { transform: translateY(-0.7rem) scale(1); }
}

.custom-info-icon {
    position: relative;
    display: inline-block;
    vertical-align: middle;
    margin-left: 0.5rem;
}

.custom-info-icon .question-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1rem;
    height: 1rem;
    font-size: 0.7rem;
    font-weight: bold;
    color: white;
    background: var(--moss);
    border-radius: 50%;
    cursor: pointer;
    transform: translateY(-0.3rem);
    vertical-align: middle;
    animation: pulse 2s infinite ease-in-out;
    transition: transform 0.3s ease, background 0.2s ease;
}

.custom-info-icon:hover .question-icon,
.custom-info-icon.active .question-icon {
    transform: translateY(-0.3rem) scale(1.05);
    background: #3a6b4a;
    animation: none;
}

.custom-info-icon .custom-tooltip {
    visibility: hidden;
    position: absolute;
    background: #E8DED5;
    color: var(--text-primary);
    padding: 0.5rem 1rem;
    border-radius: 5px;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
    white-space: normal;
    z-index: 1001;
    opacity: 0;
    transition: opacity 0.3s ease, transform 0.3s ease;
    font-size: 0.85rem;
    top: -100%;
    left: 100%;
    margin-left: 8px;
    transform: translateY(0);
    min-width: 205px;
    overflow-wrap: break-word;
}

.custom-info-icon:hover .custom-tooltip,
.custom-info-icon.active .custom-tooltip {
    visibility: visible;
    opacity: 1;
    transform: translateY(-5px);
}

/* 5.9 Страницы About и Privacy */
.privacy-content,
.about-content {
    max-width: 800px;
    margin: 0 auto;
    padding: 2rem;
    background: var(--sand);
    border-radius: var(--border-radius);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
}

.privacy-content h1,
.about-content h1 {
    font-size: 2rem;
    color: var(--text-primary);
    border-bottom: 2px solid var(--border-color);
    padding-bottom: 0.5rem;
}

.privacy-content h2,
.about-content h2 {
    font-size: 1.5rem;
    color: var(--moss);
    margin: 2rem 0 1rem;
}

.privacy-content p,
.about-content p,
.about-content ul {
    font-size: 14px;
    color: var(--text-primary);
    margin-bottom: 2rem;
}

.about-content ul {
    padding-left: 14px;
    margin-left: 14px;
}

.privacy-content a,
.about-content a {
    color: var(--link-color);
    text-decoration: none;
}

.privacy-content a:hover,
.about-content a:hover {
    text-decoration: underline;
}

.privacy-content .hr,
.about-content .hr-content {
    border-top: 1px dashed var(--border-color);
    margin: 2rem 0;
}

/* 5.10 Детали продукта */
.product-detail-wrapper {
    background: var(--light-sand);
    border-radius: var(--border-radius);
    padding: 1rem;
    margin: 0 auto;
    max-width: 1200px;
    width: 90%;
    box-sizing: border-box;
    position: relative;
    overflow-x: visible;
}

.product-detail-wrapper .nutrient-grid,
.product-detail-wrapper .suggestions {
    display: flex;
    flex-wrap: wrap;
    gap: var(--gutter);
    width: 100%;
    max-width: 100%;
    margin-bottom: 1.5rem;
}

.product-detail-wrapper .nutrient-group,
.product-detail-wrapper .suggestions-group {
    display: flex;
    flex-direction: column;
    gap: var(--gutter);
    width: 100%;
}

.product-detail-wrapper .nutrient-group-inner,
.product-detail-wrapper .suggestions-group-inner {
    display: flex;
    flex-wrap: wrap;
    gap: var(--gutter);
    width: 100%;
    align-items: flex-start;
}

.product-detail-wrapper .nutrient-group-wrapper,
.product-detail-wrapper .suggestions-group-wrapper {
    display: flex;
    flex-wrap: wrap;
    gap: var(--gutter);
    width: max-content;
}

.product-detail-wrapper .nutrient-category,
.product-detail-wrapper .mineral-category,
.product-detail-wrapper .suggestions-item,
.product-detail-wrapper .suggestions-category {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 0.75rem;
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-width: 0;
    box-sizing: border-box;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    white-space: normal;
}

.product-detail-wrapper .nutrient-category-group .nutrient-category,
.product-detail-wrapper .suggestions-group-inner .suggestions-category {
    margin-bottom: var(--gutter);
}

.product-detail-wrapper .nutrient-category-group .nutrient-category:last-child,
.product-detail-wrapper .suggestions-group-inner .suggestions-category:last-child {
    margin-bottom: 0;
}

.product-detail-wrapper .nutrient-group-inner .nutrient-group,
.product-detail-wrapper .suggestions-group-inner .suggestions-group {
    display: flex;
    flex-direction: column;
    gap: var(--gutter);
    width: 100%;
}

.product-detail-wrapper .nutrient-group-inner .nutrient-group .nutrient-category,
.product-detail-wrapper .suggestions-group-inner .suggestions-group .suggestions-category {
    flex: 1 1 auto;
}

.product-detail-wrapper .nutrient-group-inner .mineral-category {
    flex: 1 1 auto;
}

.product-detail-wrapper .nutrient-group-inner .mineral-category.single-mineral {
    min-width: 280px;
}

.product-detail-wrapper .mineral-grid {
    display: flex;
    flex-direction: row;
    gap: var(--gutter);
    align-items: flex-start;
}

.product-detail-wrapper .mineral-grid .sub-category {
    flex: 1 1 auto;
    min-width: 0;
}

.product-detail-wrapper .sub-category.macro-minerals,
.product-detail-wrapper .sub-category.micro-minerals {
    margin-left: 0;
    padding: 0.75rem;
    border-left: none;
    margin-top: 0.5rem;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    min-height: auto;
    background: transparent;
    position: relative;
}

.product-detail-wrapper .mineral-grid .macro-minerals + .micro-minerals::before {
    content: '';
    position: absolute;
    left: -0.5rem;
    top: 0;
    height: 100%;
    width: 2px;
    background-color: var(--stone);
}

.product-detail-wrapper .sub-category .mineral-content {
    flex-grow: 0;
    padding: 0.25rem 0;
}

.product-detail-wrapper .custom-info-icon .custom-tooltip {
    top: -100%;
    left: 100%;
    margin-left: 8px;
    transform: translateY(0);
}

.product-detail-wrapper .custom-info-icon:hover .custom-tooltip,
.product-detail-wrapper .custom-info-icon.active .custom-tooltip {
    transform: translateY(-5px);
}

.category-header {
    font-size: 1.25rem;
    border-bottom: 2px solid var(--sage);
    padding-bottom: 0.5rem;
    margin-bottom: 0.75rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    line-height: 1.2;
}

.category-header .nutrient-name {
    color: var(--moss);
    font-weight: 600;
}

.sub-category {
    margin-left: 1rem;
    padding-left: 0.75rem;
    border-left: 2px solid var(--stone);
    margin-top: 0.5rem;
    margin-bottom: 0.5rem;
}

.nutrient-item {
    display: flex;
    flex-direction: column;
    padding: 0.25rem 0;
    gap: 0.25rem;
    font-size: 1rem;
    line-height: normal;
    white-space: normal;
}

.nutrient-name {
    color: var(--sage);
    font-size: 1rem;
    line-height: normal;
    flex: 0 0 auto;
    word-break: break-word;
    font-weight: 400;
}

.nutrient-amount {
    color: var(--earth);
    font-size: 1rem;
    line-height: normal;
    flex: 0 0 auto;
    margin-left: 0;
    white-space: nowrap;
}

.nutrient-category .nutrient-amount:not(.category-header .nutrient-amount) {
    font-weight: 400;
    margin-top: 0.5rem;
    display: block;
}

.category-header .nutrient-amount {
    color: var(--earth);
    font-weight: 600;
    margin-left: 0.5rem;
}

.unit {
    font-size: 1rem;
    color: var(--stone);
    line-height: normal;
    vertical-align: baseline;
}

.nutrient-amount .text-muted.small {
    font-size: 1rem;
    line-height: normal;
    vertical-align: baseline;
    margin-left: 0.25rem;
}

.nutrient-category .sub-category .ms-3 .nutrient-item {
    margin-left: 1rem;
}

.text-muted.small.mb-2 {
    color: var(--sky);
    font-size: 0.9rem;
    margin-bottom: 0.5rem;
}

/* 5.11 Приветственная карточка */
div.col-12.col-md-10.col-lg-11.col-xl-9,
div.card.welcome-card.shadow-sm.p-4.text-center {
    border-radius: var(--border-radius);
}

div.card.welcome-card.shadow-sm.p-4.text-center {
    background: var(--light-sand);
}

.welcome-title {
    color: var(--text-primary);
    font-size: 1.75rem;
    margin-bottom: 1rem;
}

.welcome-text {
    color: var(--stone);
    font-size: 1rem;
}

/* 5.12 Уведомления */
.alert {
    margin-bottom: 1rem;
    border-radius: var(--border-radius);
}

#globalSuccess {
    z-index: 1050;
    max-width: 600px;
    top: 20px;
}

/* 6. Темная тема */
body.dark-mode {
    --bg-primary: #1A2F28;
    --text-primary: #E0EAE4;
    --card-bg: #2A3B32;
    --header-bg: #3A4540;
    --footer-bg: #3A4540;
    --input-bg: #3A454C;
    --link-color: #8A9B6E;
    --light-sand: #3A454C;
    --light-stone: #3A4540;
    --border-color: #8A9B6E;

    background-color: var(--bg-primary);
}

body.dark-mode .profile-card,
body.dark-mode .modal-body {
    background: var(--card-bg);
}

body.dark-mode .detail-card {
    background: var(--light-sand);
    border-color: rgba(255, 255, 255, 0.1);
}

body.dark-mode .profile-info h1,
body.dark-mode .modal-title {
    color: var(--text-primary);
}

body.dark-mode .profile-info .lead {
    color: var(--stone);
}

body.dark-mode .form-control {
    border-color: var(--sage);
    background: var(--input-bg);
    color: var(--text-primary);
}

body.dark-mode .form-control:focus {
    border-color: var(--moss);
    box-shadow: 0 0 0 3px rgba(74, 124, 89, 0.2);
    background: var(--input-bg);
    color: var(--text-primary);
}

body.dark-mode .custom-select {
    border-color: var(--sage);
    background: var(--input-bg);
    color: var(--text-primary);
}

body.dark-mode .custom-select-options {
    border-color: var(--sage);
    background: var(--input-bg);
    max-height: calc(50vh - 50px); /* Адаптивная высота в темной теме */
}

body.dark-mode .custom-select-options li {
    color: var(--text-primary);
}

body.dark-mode .custom-select-options li:hover {
    background: var(--light-sand);
}

body.dark-mode .input-group {
    border-color: var(--sage);
    background: var(--input-bg);
}

body.dark-mode .input-group .form-control {
    background: transparent;
    color: var(--text-primary);
}

body.dark-mode .input-group .toggle-password {
    background: rgba(255, 255, 255, 0.05);
}

body.dark-mode .input-group .toggle-password:hover {
    background: rgba(255, 255, 255, 0.1);
}

body.dark-mode .modal-content {
    background: #2A3B32;
    border-color: var(--sage);
}

body.dark-mode .modal-header,
body.dark-mode .modal-footer {
    background: var(--header-bg);
    border-color: var(--sage);
}

body.dark-mode .nutrient-name {
    color: #8A9B6E;
}

body.dark-mode .nutrient-amount {
    color: #8B5A2B;
}

body.dark-mode .unit {
    color: var(--stone);
}

body.dark-mode .category-header,
body.dark-mode .sub-category {
    border-color: var(--sage);
}

body.dark-mode .modal-footer a {
    color: var(--moss);
}

body.dark-mode .modal-footer a:hover {
    color: #3a6b4a;
}

body.dark-mode .autocomplete-dropdown {
    background: var(--input-bg);
    border-color: var(--sage);
}

body.dark-mode .suggestion-item:hover,
body.dark-mode .suggestion-item.active {
    background: #4F5A55; /* Более контрастный фон для подсказок */
}

body.dark-mode .suggestion-icon {
    color: var(--sage);
}

body.dark-mode .suggestion-title {
    color: var(--moss);
}

body.dark-mode .custom-info-icon .question-icon {
    background: #8A9B6E;
    color: #1A2F28;
}

body.dark-mode .custom-info-icon:hover .question-icon,
body.dark-mode .custom-info-icon.active .question-icon {
    background: #A7C4C2;
}

body.dark-mode .custom-info-icon .custom-tooltip {
    background: #4F5A55;
    color: var(--text-primary);
}

body.dark-mode .search-container .form-control.search-input,
body.dark-mode .search-container .form-control.search-input:focus {
    background-color: #4D423D;
}

body.dark-mode .search-container .form-control.search-input.compact-search {
    background: #4D423D;
}

body.dark-mode .search-container .search-tooltip {
    background: #4F5A55;
    font-size: 0.85rem;
    font-weight: bold;
}

body.dark-mode .category-header .nutrient-name {
    color: #4A7C59;
}

body.dark-mode .text-muted.small.mb-2 {
    color: #A7C4C2;
}

body.dark-mode .privacy-content,
body.dark-mode .about-content {
    background: #3A4540;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
}

body.dark-mode .privacy-content h1,
body.dark-mode .about-content h1,
body.dark-mode .privacy-content h2,
body.dark-mode .about-content h2 {
    color: #E0EAE4;
}

body.dark-mode .privacy-content a,
body.dark-mode .about-content a {
    color: #8A9B6E;
}

body.dark-mode .privacy-content a:hover,
body.dark-mode .about-content a:hover {
    color: #A7C4C2;
}

body.dark-mode .product-detail-wrapper .nutrient-category {
    background: var(--card-bg);
    border-color: var(--border-color);
}

body.dark-mode .mineral-grid .macro-minerals + .micro-minerals::before {
    background-color: var(--sage);
}

body.dark-mode .btn-edit[aria-label]::after,
body.dark-mode .btn-change-password[aria-label]::after {
    background-color: var(--light-sand);
    color: var(--text-primary);
}

/* 7. Медиа-запросы */
@media (max-width: 1200px) {
    .detail-card {
        flex: 1 1 calc(33% - (var(--gutter) * 2 / 3));
        min-width: 220px;
    }

    .product-detail-wrapper .nutrient-group-inner,
    .product-detail-wrapper .suggestions-group-inner,
    .product-detail-wrapper .nutrient-category,
    .product-detail-wrapper .mineral-category,
    .product-detail-wrapper .suggestions-item,
    .product-detail-wrapper .suggestions-category {
        flex-basis: 25%;
    }
}

@media (max-width: 992px) {
    .detail-card {
        flex: 1 1 calc(50% - (var(--gutter) / 2));
        min-width: 200px;
    }

    .product-detail-wrapper .nutrient-group-inner,
    .product-detail-wrapper .suggestions-group-inner,
    .product-detail-wrapper .nutrient-category,
    .product-detail-wrapper .mineral-category,
    .product-detail-wrapper .suggestions-item,
    .product-detail-wrapper .suggestions-category {
        flex-basis: 33.333%;
    }
}

@media (max-width: 768px) {
    :root {
        --border-radius: 8px;
    }

    .container-xl,
    main.container,
    main.container-xl {
        width: calc(100% - 1rem);
        margin: 0 0.5rem;
    }

    .navbar,
    .footer {
        width: calc(100% - 1rem);
        margin: 0.5rem auto;
    }

    .navbar .btn-icon,
    .navbar .theme-toggle {
        width: 2rem;
        height: 2rem;
        font-size: 1rem;
    }

    .navbar .ms-auto.d-flex {
        gap: 1rem;
        justify-content: flex-end;
    }

    .profile-header {
        flex-direction: column;
        align-items: center;
        text-align: center;
    }

    .header-content {
        flex-direction: column;
    }

    .detail-container,
    .profile-details .row {
        flex-direction: column;
        gap: 1rem;
    }

    .detail-card {
        flex: 1 1 100%;
        min-width: 100%;
    }

    .custom-info-icon .custom-tooltip,
    .custom-info-container .custom-suggestion {
        max-width: 300px;
        width: calc(100% - 20px);
        font-size: 0.8rem;
        margin: 0.5rem;
        top: calc(100% + 10px);
        left: 50%;
        transform: translateX(-50%);
    }

    .custom-info-icon:hover .custom-tooltip,
    .custom-info-icon.active .custom-tooltip,
    .custom-info-container:hover .custom-suggestion,
    .custom-info-container.active .custom-suggestion {
        transform: translateX(-50%) translateY(5px);
    }

    .product-detail-wrapper .custom-info-icon .custom-tooltip {
        top: 100%;
        left: 50%;
        margin-left: 0;
        transform: translateX(-50%) translateY(10px);
    }

    .product-detail-wrapper .custom-info-icon:hover .custom-tooltip,
    .product-detail-wrapper .custom-info-icon.active .custom-tooltip {
        transform: translateX(-50%) translateY(15px);
    }

    .product-detail-wrapper .nutrient-grid,
    .product-detail-wrapper .suggestions {
        flex-direction: column;
    }

    .product-detail-wrapper .nutrient-category,
    .product-detail-wrapper .mineral-category,
    .product-detail-wrapper .suggestions-item,
    .product-detail-wrapper .suggestions-category,
    .product-detail-wrapper .nutrient-group-inner .nutrient-group,
    .product-detail-wrapper .suggestions-group-inner .suggestions-group,
    .product-detail-wrapper .suggestions-group-inner .suggestion {
        flex-basis: 100%;
    }

    .product-detail-wrapper .mineral-grid,
    .product-detail-wrapper .suggestions-grid {
        flex-direction: column;
    }

    .product-detail-wrapper .sub-category.macro-minerals,
    .product-detail-wrapper .sub-category.micro-minerals,
    .product-detail-wrapper .sub-category.macro-suggestion,
    .product-detail-wrapper .sub-category.micro-suggestion {
        margin-left: 0;
        border-left: none;
        min-width: 100%;
    }

    .product-detail-wrapper .mineral-grid .macro-minerals + .micro-minerals::before,
    .product-detail-wrapper .suggestions-grid .macro-suggestion + .micro-suggestion::before {
        display: none;
    }

    .modal-body {
        max-height: calc(80vh - 80px); /* Увеличено для мобильных */
    }

    .custom-select-options {
        max-height: calc(40vh - 30px); /* Уменьшено для мобильных */
    }
}