/* Стили для header-buttons определены ниже в общих стилях */
/* ВАЖНО: Стили для кнопок в header находятся после базового .btn для правильной специфичности */

/* ===== МОДАЛЬНОЕ ОКНО СИНХРОНИЗАЦИИ ===== */
.modal {
    display: none;
    position: fixed;
    z-index: 10000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    overflow: auto;
}

.modal-content {
    background-color: #fff;
    margin: 5% auto;
    padding: 20px;
    border-radius: 10px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    max-width: 900px;
    max-height: 80vh;
    overflow-y: auto;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #e0e0e0;
    padding-bottom: 10px;
    margin-bottom: 15px;
}

.modal-header h3 {
    margin: 0;
    font-size: 20px;
    color: #333;
}

.modal-footer {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px solid #e0e0e0;
}

.modal-body {
    padding: 10px 0;
}

.sync-action-create { color: #28a745; font-weight: 600; }
.sync-action-update { color: #007bff; font-weight: 600; }
.sync-action-delete { color: #dc3545; font-weight: 600; }

#syncPreviewTableBody tr:hover {
    background-color: #f5f5f5;
}

#syncPreviewTableBody tr.sync-selected {
    background-color: #e8f5e9;
}

#syncPreviewTableBody tr.sync-deselected {
    opacity: 0.5;
}

#add-transaction-form, #transaction-categories-page, #add-transaction-category-form {
    max-width: 900px;
    margin: 0 auto;
    padding: 20px;
}

#add-transaction-form .form-section,
#add-transaction-category-form .form-section {
    background: #f8f9fa;
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 20px;
    border: 1px solid #e9ecef;
}

#transaction-categories-page .page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.muted { color: #6c757d; font-size: 12px; }

/* ====== СТИЛИ АВТОРИЗАЦИИ ====== */

#login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.login-container {
    width: 100%;
    max-width: 400px;
    padding: 20px;
}

.login-card {
    background: white;
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    overflow: hidden;
}

.login-header {
    text-align: center;
    padding: 40px 30px 20px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.login-header h1 {
    margin: 0 0 10px 0;
    font-size: 24px;
    font-weight: 600;
}

.login-header p {
    margin: 0;
    opacity: 0.9;
    font-size: 14px;
}

.login-content {
    padding: 30px;
}

.login-input-group {
    margin-bottom: 20px;
}

.login-input-group label {
    display: block;
    margin-bottom: 8px;
    color: #333;
    font-size: 14px;
    font-weight: 500;
}

.login-input-group input {
    width: 100%;
    padding: 12px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 16px;
    transition: border-color 0.2s ease;
    box-sizing: border-box;
}

.login-input-group input:focus {
    outline: none;
    border-color: #667eea;
}

.login-submit-btn {
    width: 100%;
    padding: 12px 20px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.login-submit-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.login-submit-btn:active {
    transform: translateY(0);
}

.login-error {
    margin-top: 15px;
    padding: 10px;
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: 6px;
    color: #dc2626;
    font-size: 14px;
    text-align: center;
}

.logout-btn {
    background: #dc3545;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    transition: background 0.2s ease;
}

.logout-btn:hover {
    background: #c82333;
}

.year-selector {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s ease;
    outline: none;
}

.year-selector:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.year-selector option {
    background: white;
    color: #333;
}

/* Скрытие основного контента до авторизации */
#main-content {
    display: none;
}

#main-content.authenticated {
    display: block;
}
/* Основные стили */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    color: #333;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
}

/* Навигация */
.navbar {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-radius: 15px;
    padding: 20px;
    margin-bottom: 30px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    position: relative;
}

/* Скрыть навигацию на странице авторизации */
.navbar.hidden {
    display: none !important;
}

/* Скрыть навигацию когда страница авторизации активна */
#login-page.active ~ .navbar,
body:has(#login-page.active) .navbar {
    display: none !important;
}

.nav-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
}

.nav-brand h1 {
    color: #667eea;
    font-size: 24px;
    font-weight: 700;
    margin: 0;
}

/* Кнопка гамбургер-меню */
.mobile-menu-toggle {
    display: none;
    flex-direction: column;
    justify-content: space-around;
    width: 30px;
    height: 30px;
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 0;
    z-index: 1001;
}

.mobile-menu-toggle span {
    width: 100%;
    height: 3px;
    background: #667eea;
    border-radius: 3px;
    transition: all 0.3s ease;
}

.mobile-menu-toggle.active span:nth-child(1) {
    transform: rotate(45deg) translate(8px, 8px);
}

.mobile-menu-toggle.active span:nth-child(2) {
    opacity: 0;
}

.mobile-menu-toggle.active span:nth-child(3) {
    transform: rotate(-45deg) translate(7px, -7px);
}

.nav-links {
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
    align-items: center;
}

.nav-controls {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
}

.nav-link {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 10px 20px;
    border-radius: 25px;
    text-decoration: none;
    font-weight: 500;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 8px;
}

.nav-link:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
}

.nav-link.active {
    background: linear-gradient(135deg, #28a745 0%, #20c997 100%);
}

/* Основной контент */
.main-content {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-radius: 15px;
    padding: 30px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    min-height: 600px;
}

@media (max-width: 768px) {
    .main-content {
        padding: 15px;
        border-radius: 10px;
    }
    
    .header {
        margin-bottom: 20px;
    }
    
    .header h2 {
        font-size: 20px;
    }
    
    .header p {
        font-size: 14px;
    }
    
    /* Улучшение скролла на мобильных */
    body {
        -webkit-overflow-scrolling: touch;
    }
    
    /* Улучшение фокуса для доступности */
    *:focus {
        outline: 2px solid #667eea;
        outline-offset: 2px;
    }
    
    /* Улучшение для элементов ввода */
    input[type="text"],
    input[type="number"],
    input[type="date"],
    input[type="time"],
    input[type="email"],
    input[type="tel"],
    select,
    textarea {
        -webkit-appearance: none;
        -moz-appearance: none;
        appearance: none;
        border-radius: 8px;
    }
    
    /* Улучшение для селектов на iOS */
    select {
        background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23667eea' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
        background-repeat: no-repeat;
        background-position: right 12px center;
        padding-right: 40px;
    }
}

.page {
    display: none;
}

.page.active {
    display: block;
}

/* Стили для страницы создания товара */
#add-product-form {
    max-width: 800px;
    margin: 0 auto;
    padding: 20px;
}

/* Стили для страницы редактирования товара */
#edit-product-form {
    max-width: 800px;
    margin: 0 auto;
    padding: 20px;
}

#add-product-form .form-section {
    background: #f8f9fa;
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 20px;
    border: 1px solid #e9ecef;
}

#add-product-form .form-section h3 {
    color: #495057;
    margin-bottom: 15px;
    font-size: 18px;
    font-weight: 600;
}

#add-product-form .form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
    margin-bottom: 15px;
}

#add-product-form .form-group {
    display: flex;
    flex-direction: column;
}

#add-product-form label {
    font-weight: 500;
    margin-bottom: 5px;
    color: #495057;
}

#add-product-form input,
#add-product-form select,
#add-product-form textarea {
    padding: 10px;
    border: 1px solid #ced4da;
    border-radius: 4px;
    font-size: 14px;
    transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
}

#add-product-form input:focus,
#add-product-form select:focus,
#add-product-form textarea:focus {
    border-color: #80bdff;
    outline: 0;
    box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25);
}

#add-product-form .form-actions,
#add-sale-form .form-actions,
#edit-sale-form .form-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid #e9ecef;
    flex-wrap: wrap;
}

@media (max-width: 768px) {
    #add-product-form .form-actions,
    #add-sale-form .form-actions,
    #edit-sale-form .form-actions {
        flex-direction: column;
    }
    
    #add-product-form .form-actions .btn,
    #add-sale-form .form-actions .btn,
    #edit-sale-form .form-actions .btn {
        width: 100%;
        padding: 14px 20px;
        font-size: 16px;
    }
}

/* Стили для формы редактирования товара */
#edit-product-form .form-section {
    background: #f8f9fa;
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 20px;
    border: 1px solid #e9ecef;
}

#edit-product-form .form-section h3 {
    color: #495057;
    margin-bottom: 15px;
    font-size: 18px;
    font-weight: 600;
}

#edit-product-form .form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
    margin-bottom: 15px;
}

#edit-product-form .form-group {
    display: flex;
    flex-direction: column;
}

#edit-product-form label {
    font-weight: 500;
    margin-bottom: 5px;
    color: #495057;
}

#edit-product-form input,
#edit-product-form select,
#edit-product-form textarea {
    padding: 10px;
    border: 1px solid #ced4da;
    border-radius: 4px;
    font-size: 14px;
    transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
}

#edit-product-form input:focus,
#edit-product-form select:focus,
#edit-product-form textarea:focus {
    border-color: #80bdff;
    outline: 0;
    box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25);
}

#edit-product-form .form-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid #e9ecef;
}

/* Стили для страницы создания материала */
#add-material-form {
    max-width: 800px;
    margin: 0 auto;
    padding: 20px;
}

#add-material-form .form-section {
    background: #f8f9fa;
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 20px;
    border: 1px solid #e9ecef;
}

#add-material-form .form-section h3 {
    color: #495057;
    margin-bottom: 15px;
    font-size: 18px;
    font-weight: 600;
}

#add-material-form .form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
    margin-bottom: 15px;
}

#add-material-form .form-group {
    display: flex;
    flex-direction: column;
}

#add-material-form label {
    font-weight: 500;
    margin-bottom: 5px;
    color: #495057;
}

#add-material-form input,
#add-material-form select,
#add-material-form textarea {
    padding: 10px;
    border: 1px solid #ced4da;
    border-radius: 4px;
    font-size: 14px;
    transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
}

#add-material-form input:focus,
#add-material-form select:focus,
#add-material-form textarea:focus {
    border-color: #80bdff;
    outline: 0;
    box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25);
}

#add-material-form .form-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid #e9ecef;
}

/* Стили для страницы редактирования материала */
#edit-material-form {
    max-width: 800px;
    margin: 0 auto;
    padding: 20px;
}

#edit-material-form .form-section {
    background: #f8f9fa;
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 20px;
    border: 1px solid #e9ecef;
}

#edit-material-form .form-section h3 {
    color: #495057;
    margin-bottom: 15px;
    font-size: 18px;
    font-weight: 600;
}

#edit-material-form .form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
    margin-bottom: 15px;
}

#edit-material-form .form-group {
    display: flex;
    flex-direction: column;
}

#edit-material-form label {
    font-weight: 500;
    margin-bottom: 5px;
    color: #495057;
}

#edit-material-form input,
#edit-material-form select,
#edit-material-form textarea {
    padding: 10px;
    border: 1px solid #ced4da;
    border-radius: 4px;
    font-size: 14px;
    transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
}

#edit-material-form input:focus,
#edit-material-form select:focus,
#edit-material-form textarea:focus {
    border-color: #80bdff;
    outline: 0;
    box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25);
}

#edit-material-form .form-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid #e9ecef;
}

/* Стили для страницы категорий материалов */
#material-categories-page {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

#material-categories-page .page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

#material-categories-page .page-header h2 {
    margin: 0;
    color: #495057;
}

/* Стили для формы категории материала */
#add-material-category-form {
    max-width: 800px;
    margin: 0 auto;
    padding: 20px;
}

#add-material-category-form .form-section {
    background: #f8f9fa;
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 20px;
    border: 1px solid #e9ecef;
}

#add-material-category-form .form-section h3 {
    color: #495057;
    margin-bottom: 15px;
    font-size: 18px;
    font-weight: 600;
}

#add-material-category-form .form-row {
    display: grid;
    grid-template-columns: 1fr;
    gap: 15px;
    margin-bottom: 15px;
}

#add-material-category-form .form-group {
    display: flex;
    flex-direction: column;
}

#add-material-category-form label {
    font-weight: 500;
    margin-bottom: 5px;
    color: #495057;
}

#add-material-category-form input,
#add-material-category-form textarea {
    padding: 10px;
    border: 1px solid #ced4da;
    border-radius: 4px;
    font-size: 14px;
    transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
}

#add-material-category-form input:focus,
#add-material-category-form textarea:focus {
    border-color: #80bdff;
    outline: 0;
    box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25);
}

#add-material-category-form .form-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid #e9ecef;
}

/* Стили для страницы создания сотрудника */
#add-employee-form {
    max-width: 800px;
    margin: 0 auto;
    padding: 20px;
}

#add-employee-form .form-section {
    background: #f8f9fa;
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 20px;
    border: 1px solid #e9ecef;
}

#add-employee-form .form-section h3 {
    color: #495057;
    margin-bottom: 15px;
    font-size: 18px;
    font-weight: 600;
}

#add-employee-form .form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
    margin-bottom: 15px;
}

#add-employee-form .form-group {
    display: flex;
    flex-direction: column;
}

#add-employee-form label {
    font-weight: 500;
    margin-bottom: 5px;
    color: #495057;
}

#add-employee-form input,
#add-employee-form select,
#add-employee-form textarea {
    padding: 10px;
    border: 1px solid #ced4da;
    border-radius: 4px;
    font-size: 14px;
    transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
}

#add-employee-form input:focus,
#add-employee-form select:focus,
#add-employee-form textarea:focus {
    border-color: #80bdff;
    outline: 0;
    box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25);
}

#add-employee-form .form-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid #e9ecef;
}

/* Стили для страницы редактирования сотрудника */
#edit-employee-form {
    max-width: 800px;
    margin: 0 auto;
    padding: 20px;
}

#edit-employee-form .form-section {
    background: #f8f9fa;
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 20px;
    border: 1px solid #e9ecef;
}

#edit-employee-form .form-section h3 {
    color: #495057;
    margin-bottom: 15px;
    font-size: 18px;
    font-weight: 600;
}

#edit-employee-form .form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
    margin-bottom: 15px;
}

#edit-employee-form .form-group {
    display: flex;
    flex-direction: column;
}

#edit-employee-form label {
    font-weight: 500;
    margin-bottom: 5px;
    color: #495057;
}

#edit-employee-form input,
#edit-employee-form select,
#edit-employee-form textarea {
    padding: 10px;
    border: 1px solid #ced4da;
    border-radius: 4px;
    font-size: 14px;
    transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
}

#edit-employee-form input:focus,
#edit-employee-form select:focus,
#edit-employee-form textarea:focus {
    border-color: #80bdff;
    outline: 0;
    box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25);
}

#edit-employee-form .form-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid #e9ecef;
}

/* Стили для страницы категорий */
#categories-page {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 2px solid #e9ecef;
}

.page-header h2 {
    color: #495057;
    margin: 0;
    font-size: 24px;
    font-weight: 600;
}

/* Стили для формы категории */
#add-category-form {
    max-width: 600px;
    margin: 0 auto;
    padding: 20px;
}

#add-category-form .form-section {
    background: #f8f9fa;
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 20px;
    border: 1px solid #e9ecef;
}

#add-category-form .form-section h3 {
    color: #495057;
    margin-bottom: 15px;
    font-size: 18px;
    font-weight: 600;
}

#add-category-form .form-row {
    display: grid;
    grid-template-columns: 1fr;
    gap: 15px;
    margin-bottom: 15px;
}

#add-category-form .form-group {
    display: flex;
    flex-direction: column;
}

#add-category-form label {
    font-weight: 500;
    margin-bottom: 5px;
    color: #495057;
}

#add-category-form input,
#add-category-form textarea {
    padding: 10px;
    border: 1px solid #ced4da;
    border-radius: 4px;
    font-size: 14px;
    transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
}

#add-category-form input:focus,
#add-category-form textarea:focus {
    border-color: #80bdff;
    outline: 0;
    box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25);
}

#add-category-form .form-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid #e9ecef;
}

/* Стили для таблицы категорий */
#categories-page .data-table {
    width: 100%;
    border-collapse: collapse;
    background: white;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

#categories-page .data-table th {
    background: #f8f9fa;
    color: #495057;
    font-weight: 600;
    padding: 12px;
    text-align: left;
    border-bottom: 2px solid #e9ecef;
}

#categories-page .data-table td {
    padding: 12px;
    border-bottom: 1px solid #e9ecef;
    vertical-align: middle;
}

#categories-page .data-table tr:hover {
    background: #f8f9fa;
}

#categories-page .data-table tr:last-child td {
    border-bottom: none;
}

/* Стили для кнопок действий */
.btn-sm {
    padding: 6px 12px;
    font-size: 12px;
    border-radius: 4px;
    margin-right: 5px;
}

.btn-sm:last-child {
    margin-right: 0;
}

/* Адаптивность для мобильных устройств */
@media (max-width: 768px) {
    #add-product-form .form-row,
    #add-category-form .form-row {
        grid-template-columns: 1fr;
    }
    
    .page-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 15px;
    }
    
    .page-header {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }
    
    .page-header button,
    .page-header .btn {
        width: 100%;
        padding: 14px 20px;
        font-size: 16px;
        min-height: 44px; /* Минимальный размер для удобного нажатия */
    }
    
    /* Оптимизация кнопок для мобильных */
    .btn {
        min-height: 44px;
        padding: 12px 16px;
        font-size: 15px;
        justify-content: center;
        align-items: center;
        text-align: center;
        white-space: normal;
        word-wrap: break-word;
        overflow-wrap: break-word;
        margin: 5px 0;
        flex-shrink: 0;
        box-sizing: border-box;
        line-height: 1.4;
        position: relative;
    }
    
    /* Иконки в кнопках - правильное выравнивание */
    .btn i {
        flex-shrink: 0;
        width: auto;
        min-width: 18px;
        text-align: center;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        margin-right: 6px;
    }
    
    /* Текст в кнопках - правильное выравнивание */
    .btn {
        gap: 8px;
    }
    
    /* Убираем margin-right у последней иконки */
    .btn i:last-child {
        margin-right: 0;
        margin-left: 6px;
    }
    
    /* Если только иконка без текста */
    .btn:has(> i:only-child) {
        gap: 0;
    }
    
    /* Кнопки в header-buttons на мобильных - на всю ширину, но с одинаковыми размерами */
    .header-buttons {
        flex-direction: column;
        width: 100%;
        gap: 10px;
    }
    
    /* Мобильные стили для кнопок в header - УНИВЕРСАЛЬНЫЙ СЕЛЕКТОР */
    .header .btn,
    .header-buttons .btn,
    .header > .btn {
        width: 100% !important;
        height: 50px !important;
        min-width: auto !important;
        max-width: 100% !important;
        margin: 0 !important;
        padding: 14px 16px !important;
        font-size: 15px !important;
        font-weight: 500 !important;
        white-space: normal !important;
        word-wrap: break-word !important;
        overflow-wrap: break-word !important;
        line-height: 1.3 !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        text-align: center !important;
        overflow: hidden !important;
        flex: 0 0 100% !important;
        box-sizing: border-box !important;
        border-radius: 8px !important;
    }
    
    .header .btn i,
    .header-buttons .btn i,
    .header > .btn i {
        margin-right: 8px !important;
        flex-shrink: 0 !important;
        font-size: 15px !important;
        display: inline-flex !important;
        align-items: center !important;
        justify-content: center !important;
    }
    
    /* Кнопки в формах на всю ширину */
    .form-actions .btn,
    .form-section .btn,
    .add-item-form .btn,
    .items-section .btn {
        width: 100%;
        margin: 5px 0;
        padding: 14px 16px;
    }
    
    /* Кнопки в карточках мобильных */
    .mobile-card-actions {
        flex-direction: column;
        gap: 10px;
    }
    
    .mobile-card-actions .btn {
        width: 100%;
        margin: 0;
        padding: 12px 16px;
        justify-content: center;
        align-items: center;
        text-align: center;
    }
    
    .mobile-card-actions .btn i {
        margin-right: 8px;
        margin-left: 0;
    }
    
    .btn-sm {
        min-height: 40px;
        padding: 10px 14px;
        font-size: 14px;
        width: auto;
    }
    
    /* Оптимизация header для мобильных */
    .header {
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 15px !important;
        margin-bottom: 20px !important;
        padding-bottom: 15px !important;
    }
    
    /* Унифицированный размер заголовков на мобильных */
    .header h2,
    .page .header h2,
    #sales .header h2,
    #products .header h2,
    #materials .header h2,
    #employees .header h2,
    #transactions .header h2 {
        font-size: 20px !important;
        margin-bottom: 0 !important;
        text-align: center !important;
        font-weight: 600 !important;
        line-height: 1.2 !important;
    }
    
    /* Кнопки в header на мобильных - ВСЕ одинаковые */
    .header > .btn {
        width: 100% !important;
        min-width: auto !important;
        max-width: 100% !important;
        height: 48px !important;
        padding: 12px 16px !important;
        font-size: 14px !important;
    }
    
    .header-buttons {
        display: flex !important;
        flex-direction: column !important;
        gap: 10px !important;
        width: 100% !important;
        align-items: stretch !important;
    }
    
    /* Кнопки действий в таблицах/карточках */
    .action-buttons {
        flex-direction: column;
        gap: 8px;
        width: 100%;
        min-width: auto;
    }
    
    .action-buttons .btn {
        width: 100%;
        margin: 0;
        padding: 12px 16px;
    }
    
    #categories-page .data-table {
        font-size: 14px;
    }
    
    #categories-page .data-table th,
    #categories-page .data-table td {
        padding: 8px;
    }
}

.header {
    margin-bottom: 30px;
    padding-bottom: 20px;
    border-bottom: 2px solid #f0f0f0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.header-buttons {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: stretch;
    justify-content: flex-start;
}

/* Унифицированные стили для всех кнопок в header-buttons на всех страницах */
.header-buttons .btn,
.header .header-buttons .btn {
    height: 48px !important;
    width: 200px !important;
    min-width: 200px !important;
    max-width: 200px !important;
    padding: 12px 16px !important;
    font-size: 14px !important;
    font-weight: 500 !important;
    white-space: normal !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    text-align: center !important;
    box-sizing: border-box !important;
    flex: 0 0 200px !important;
    line-height: 1.3 !important;
    margin: 0 !important;
    border-radius: 8px !important;
    cursor: pointer !important;
    transition: all 0.3s ease !important;
    word-wrap: break-word !important;
    overflow-wrap: break-word !important;
    hyphens: auto !important;
    overflow: hidden !important;
}

/* Иконки в кнопках header-buttons - стили дублируются выше для максимальной специфичности */

.header h2 {
    color: #333;
    font-size: 24px !important;
    margin-bottom: 10px;
    font-weight: 600;
}

/* Кнопки прямо в header (для страницы Сотрудники) */
.header > .btn {
    height: 48px !important;
    width: 200px !important;
    min-width: 200px !important;
    max-width: 200px !important;
    padding: 12px 16px !important;
    font-size: 14px !important;
    font-weight: 500 !important;
    white-space: normal !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    text-align: center !important;
    box-sizing: border-box !important;
    line-height: 1.3 !important;
    margin: 0 !important;
    border-radius: 8px !important;
    word-wrap: break-word !important;
    overflow-wrap: break-word !important;
    overflow: hidden !important;
}

.header > .btn i {
    flex-shrink: 0 !important;
    margin-right: 8px !important;
    font-size: 14px !important;
}

/* Кнопки */
.btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.3s ease;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.3s ease;
    margin: 5px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    box-sizing: border-box;
}

/* НА МОБИЛЬНЫХ: ВСЕ кнопки в header ОДИНАКОВЫЕ - ПРОСТОЙ И ПРЯМОЙ ПОДХОД */
@media (max-width: 768px) {
    /* Переопределяем ВСЕ кнопки в header на мобильных */
    .header button.btn,
    .header .btn,
    .header-buttons button.btn,
    .header-buttons .btn {
        width: 100% !important;
        height: 50px !important;
        min-height: 50px !important;
        max-height: 50px !important;
        min-width: 100% !important;
        max-width: 100% !important;
        padding: 12px 16px !important;
        font-size: 15px !important;
        font-weight: 500 !important;
        white-space: normal !important;
        word-wrap: break-word !important;
        overflow-wrap: break-word !important;
        line-height: 1.3 !important;
        margin: 0 !important;
        margin-bottom: 10px !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        text-align: center !important;
        overflow: hidden !important;
        flex: none !important;
        box-sizing: border-box !important;
        border-radius: 8px !important;
    }
    
    .header button.btn:last-child,
    .header-buttons button.btn:last-child,
    .header-buttons .btn:last-child {
        margin-bottom: 0 !important;
    }
    
    .header button.btn i,
    .header .btn i,
    .header-buttons button.btn i,
    .header-buttons .btn i {
        flex-shrink: 0 !important;
        margin-right: 8px !important;
        font-size: 15px !important;
        display: inline-flex !important;
        align-items: center !important;
        justify-content: center !important;
    }
    
    .header-buttons {
        display: flex !important;
        flex-direction: column !important;
        gap: 10px !important;
        width: 100% !important;
        align-items: stretch !important;
    }
    
    .header {
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 15px !important;
    }
    
    .header h2 {
        font-size: 20px !important;
        font-weight: 600 !important;
        margin-bottom: 10px !important;
    }
}

/* КРИТИЧЕСКИ ВАЖНО: Переопределение базовых стилей .btn для кнопок в header */
.header .btn,
.header-buttons .btn,
.header > .btn {
    height: 48px !important;
    width: 200px !important;
    min-width: 200px !important;
    max-width: 200px !important;
    padding: 12px 16px !important;
    font-size: 14px !important;
    font-weight: 500 !important;
    white-space: normal !important;
    word-wrap: break-word !important;
    overflow-wrap: break-word !important;
    text-overflow: clip !important;
    margin: 0 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    text-align: center !important;
    line-height: 1.3 !important;
    overflow: hidden !important;
    box-sizing: border-box !important;
}

.header .btn i,
.header-buttons .btn i,
.header > .btn i {
    flex-shrink: 0 !important;
    margin-right: 8px !important;
    font-size: 14px !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: auto !important;
    line-height: 1 !important;
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
}

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.btn-secondary {
    background: linear-gradient(135deg, #6c757d 0%, #5a6268 100%);
}

.btn-success {
    background: linear-gradient(135deg, #28a745 0%, #20c997 100%);
}

.btn-danger {
    background: linear-gradient(135deg, #dc3545 0%, #c82333 100%);
}

.btn-warning {
    background: linear-gradient(135deg, #ffc107 0%, #e0a800 100%);
    color: #212529;
}

.btn-info {
    background: linear-gradient(135deg, #17a2b8 0%, #138496 100%);
    color: white;
}

/* Переопределение размеров для кнопок в header - приоритет над классами btn-primary и т.д. */
.header-buttons .btn-primary,
.header-buttons .btn-secondary,
.header-buttons .btn-success,
.header-buttons .btn-info,
.header-buttons .btn-warning,
.header-buttons .btn-danger,
.header > .btn-primary,
.header > .btn-secondary,
.header > .btn-success,
.header > .btn-info,
.header > .btn-warning,
.header > .btn-danger {
    height: 48px !important;
    width: 200px !important;
    min-width: 200px !important;
    max-width: 200px !important;
    padding: 12px 16px !important;
    font-size: 14px !important;
    white-space: normal !important;
    word-wrap: break-word !important;
    overflow-wrap: break-word !important;
    overflow: hidden !important;
}

/* Статистика */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.stat-card {
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    padding: 25px;
    border-radius: 15px;
    border: 1px solid #dee2e6;
    text-align: center;
    transition: transform 0.3s ease;
}

.stat-card:hover {
    transform: translateY(-5px);
}

.stat-card h3 {
    color: #495057;
    font-size: 18px;
    margin-bottom: 15px;
}

.stat-value {
    font-size: 32px;
    font-weight: 700;
    margin-bottom: 10px;
}

.stat-value.income {
    color: #28a745;
}

.stat-value.expense {
    color: #dc3545;
}

.stat-value.profit {
    color: #007bff;
}

/* Секции дашборда */
.dashboard-section {
    background: white;
    padding: 20px;
    border-radius: 15px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    margin: 20px 0;
    border: 1px solid #dee2e6;
}

.dashboard-section h3 {
    margin: 0 0 15px 0;
    color: #333;
    font-size: 18px;
    border-bottom: 2px solid #f8f9fa;
    padding-bottom: 10px;
}

/* Статусы */
.status {
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 500;
    text-transform: uppercase;
}

.status-завершен {
    background: #d4edda;
    color: #155724;
}

.status-новое {
    background: #fff3cd;
    color: #856404;
}

.status-не_оплачен {
    background: #f8d7da;
    color: #721c24;
}

/* Типы транзакций */
.transaction-type {
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 500;
}

.transaction-type.income {
    background: #d4edda;
    color: #155724;
}

.transaction-type.expense {
    background: #f8d7da;
    color: #721c24;
}

/* Центрированный текст */
.text-center {
    text-align: center;
    color: #6c757d;
    font-style: italic;
}

/* Таблицы */
.table-container {
    background: white;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table th {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 15px;
    text-align: left;
    font-weight: 600;
}

.data-table th a {
    color: white;
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 5px;
}

.data-table th a:hover {
    color: white;
    text-decoration: none;
}

.data-table th a i {
    font-size: 12px;
    opacity: 0.7;
}

.data-table td {
    padding: 15px;
    border-bottom: 1px solid #f0f0f0;
}

.data-table tr:hover {
    background: #f8f9fa;
}

/* Формы */
.form-container {
    max-width: 800px;
    margin: 0 auto;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: #333;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 12px;
    border: 2px solid #e9ecef;
    border-radius: 8px;
    font-size: 14px;
    transition: border-color 0.3s ease;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.form-row {
    display: flex;
    gap: 20px;
    margin-bottom: 20px;
}

.form-row .form-group {
    flex: 1;
}

/* Секция товаров */
.items-section {
    background: #f8f9fa;
    padding: 20px;
    border-radius: 10px;
    margin: 20px 0;
    border: 1px solid #e9ecef;
}

.items-section h3 {
    margin-bottom: 15px;
    color: #333;
}

.add-item-form {
    margin-bottom: 20px;
}

.add-item-form .form-row {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
}

@media (max-width: 768px) {
    .add-item-form .form-row {
        flex-direction: column;
        align-items: stretch;
    }
    
    .add-item-form .form-row .btn {
        width: 100%;
        margin: 0;
    }
}

.add-item-form .form-row > * {
    margin-bottom: 0;
}

.items-list {
    min-height: 100px;
    border: 2px dashed #dee2e6;
    border-radius: 8px;
    padding: 15px;
    background: white;
}

.item-row {
    display: flex;
    gap: 15px;
    margin-bottom: 10px;
    align-items: center;
    padding: 12px;
    background: #f8f9fa;
    border-radius: 8px;
    border: 1px solid #e9ecef;
}

.item-row .item-name {
    flex: 1;
    font-weight: 500;
    color: #333;
}

.item-row .item-details {
    display: flex;
    gap: 20px;
    align-items: center;
    font-size: 14px;
    color: #666;
}

.item-row .item-total {
    color: #28a745;
    font-weight: bold;
}

.item-row button {
    background: #dc3545;
    color: white;
    border: none;
    padding: 8px 12px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 12px;
}

/* Аналитика */
.chart-tabs {
    display: flex;
    margin-bottom: 20px;
    border-bottom: 2px solid #e9ecef;
}

.chart-tab-btn {
    padding: 10px 20px;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    color: #666;
    transition: all 0.3s ease;
}

.chart-tab-btn:hover {
    color: #333;
}

.chart-tab-btn.active {
    color: #007bff;
    border-bottom-color: #007bff;
}

.chart-tab-content {
    display: none;
}

.chart-tab-content.active {
    display: block;
}

.analytics-chart-section {
    margin-top: 30px;
    padding: 20px;
    background: #f8f9fa;
    border-radius: 10px;
    border: 1px solid #e9ecef;
}

.analytics-chart-section h3 {
    margin: 0 0 20px 0;
    color: #333;
    font-size: 18px;
}

.chart-container {
    position: relative;
    height: 400px;
    width: 100%;
}

.analytics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 20px;
}

.analytics-card {
    background: white;
    padding: 25px;
    border-radius: 15px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    border: 1px solid #e9ecef;
}

.analytics-card h3 {
    color: #333;
    margin-bottom: 15px;
    font-size: 18px;
}

/* Горизонтальная прокрутка для таблиц */
.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    width: 100%;
    margin: 0;
    padding: 0;
    position: relative;
}

/* На десктопе показываем таблицы, скрываем карточки */
@media (min-width: 769px) {
    .table-responsive {
        display: block !important;
    }
    
    .mobile-cards-container {
        display: none !important;
    }
}

/* На мобильных скрываем карточки по умолчанию (покажутся только в медиа-запросе) */
.mobile-cards-container {
    display: none;
}

/* Индикатор прокрутки для мобильных */
@media (max-width: 768px) {
    .table-responsive::after {
        content: '→';
        position: absolute;
        right: 10px;
        top: 50%;
        transform: translateY(-50%);
        font-size: 24px;
        color: #667eea;
        opacity: 0.5;
        pointer-events: none;
        animation: pulse 2s infinite;
    }
    
    @keyframes pulse {
        0%, 100% { opacity: 0.5; }
        50% { opacity: 0.8; }
    }
}

/* Стили для таблиц */
table {
    width: 100%;
    min-width: 600px; /* Минимальная ширина для корректного отображения */
    border-collapse: collapse;
    margin: 0;
}

/* Кнопки действий в таблицах */
.action-buttons {
    display: flex;
    gap: 5px;
    justify-content: center;
    align-items: center;
    min-width: 120px; /* Минимальная ширина для кнопок */
}

.action-buttons .btn {
    padding: 6px 10px;
    font-size: 12px;
    min-width: 35px;
    width: auto;
    margin: 0;
    flex-shrink: 0;
}

/* Колонка действий */
.actions-column {
    min-width: 120px;
    width: 120px;
    text-align: center;
}

/* Предотвращение горизонтальной прокрутки для основного контента */
html, body {
    overflow-x: hidden;
    max-width: 100%;
}

/* Адаптивность */
@media (max-width: 768px) {
    /* Общие стили для предотвращения переполнения */
    * {
        box-sizing: border-box;
    }
    
    .container {
        padding: 10px;
        width: 100%;
        max-width: 100%;
        overflow-x: hidden;
    }
    
    .page {
        width: 100%;
        max-width: 100%;
        overflow-x: hidden;
    }
    
    .form-section {
        width: 100%;
        max-width: 100%;
        overflow-x: hidden;
    }
    
    /* Мобильное меню */
    .mobile-menu-toggle {
        display: flex;
    }
    
    .nav-header {
        margin-bottom: 0;
    }
    
    .nav-links {
        display: none;
        flex-direction: column;
        width: 100%;
        gap: 10px;
        margin-top: 15px;
        padding-top: 15px;
        border-top: 1px solid #e9ecef;
    }
    
    .nav-links.active {
        display: flex;
    }
    
    .nav-link {
        width: 100%;
        text-align: center;
        padding: 12px 20px;
        font-size: 16px;
    }
    
    .nav-controls {
        width: 100%;
        flex-direction: column;
        gap: 10px;
    }
    
    .year-selector {
        width: 100%;
        padding: 12px;
        font-size: 16px;
    }
    
    .logout-btn {
        width: 100%;
        padding: 12px;
        font-size: 16px;
    }
    
    .nav-brand h1 {
        font-size: 20px;
    }
    
    /* Таблицы для мобильных - скрываем обычные таблицы */
    .table-responsive {
        display: none;
    }
    
    /* Карточный вид для таблиц на мобильных */
    .mobile-cards-container {
        display: block;
        padding: 20px 16px;
        background: #d1d5db;
        border-radius: 8px;
    }
    
    .mobile-card {
        background: white;
        border: 3px solid #9ca3af;
        border-radius: 12px;
        padding: 20px;
        margin-bottom: 28px;
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
        transition: box-shadow 0.2s ease;
        position: relative;
    }
    
    /* Увеличиваем отступ между карточками и добавляем видимый разделитель */
    .mobile-card:not(:last-child) {
        margin-bottom: 28px;
    }
    
    /* Видимая полоса-разделитель между карточками - более заметная */
    .mobile-card:not(:last-child)::after {
        content: '';
        display: block;
        position: absolute;
        bottom: -14px;
        left: 10%;
        right: 10%;
        height: 5px;
        background: #6b7280;
        border-radius: 3px;
        box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    }
    
    .mobile-card:last-child {
        margin-bottom: 0;
    }
    
    .mobile-card:active {
        box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
    }
    
    .mobile-card-header {
        display: flex;
        justify-content: space-between;
        align-items: center;
        margin-bottom: 16px;
        padding-bottom: 14px;
        border-bottom: 2px solid #dee2e6;
    }
    
    .mobile-card-title {
        font-size: 18px;
        font-weight: 700;
        color: #667eea;
        margin: 0;
    }
    
    .mobile-card-badge {
        padding: 6px 12px;
        border-radius: 20px;
        font-size: 12px;
        font-weight: 600;
    }
    
    .mobile-card-row {
        display: flex;
        justify-content: space-between;
        align-items: flex-start;
        padding: 12px 0;
        border-bottom: 1px solid #e9ecef;
    }
    
    .mobile-card-row:last-child {
        border-bottom: none;
        padding-bottom: 0;
    }
    
    .mobile-card-label {
        font-weight: 600;
        color: #6c757d;
        font-size: 14px;
        flex: 0 0 40%;
    }
    
    .mobile-card-value {
        color: #333;
        font-size: 15px;
        flex: 1;
        text-align: right;
        word-break: break-word;
    }
    
    .mobile-card-actions {
        display: flex;
        gap: 10px;
        margin-top: 16px;
        padding-top: 16px;
        border-top: 2px solid #e9ecef;
    }
    
    .mobile-card-actions .btn {
        flex: 1;
        padding: 12px;
        font-size: 14px;
        min-height: 44px;
    }
    
    
    /* Улучшение для мобильных карточек */
    .mobile-card .material-quantity {
        font-weight: 600;
    }
    
    .mobile-card .material-quantity.low-stock {
        color: #dc3545;
        font-weight: 700;
    }
    
    .mobile-card .material-quantity.critical-stock {
        color: #dc3545;
        font-weight: 700;
        background: #fff3cd;
        padding: 4px 8px;
        border-radius: 4px;
    }
    
    /* Кнопки действий для мобильных */
    .action-buttons {
        min-width: 100px;
        gap: 3px;
        flex-wrap: wrap;
    }
    
    .action-buttons .btn {
        padding: 6px 10px;
        font-size: 12px;
        min-width: 35px;
        min-height: 35px;
    }
    
    .actions-column {
        min-width: 100px;
        width: 100px;
    }
    
    /* Дополнительные стили для очень маленьких экранов */
    @media (max-width: 480px) {
        .table-responsive {
            margin: 0 -10px;
            border-radius: 0;
            border-left: none;
            border-right: none;
        }
        
        table {
            min-width: 650px;
            font-size: 12px;
        }
        
        table th,
        table td {
            padding: 6px 4px;
        }
        
        .action-buttons {
            min-width: 80px;
            gap: 2px;
        }
        
        .action-buttons .btn {
            padding: 5px 8px;
            font-size: 11px;
            min-width: 30px;
            min-height: 30px;
        }
        
        .actions-column {
            min-width: 80px;
            width: 80px;
        }
        
        .nav-brand h1 {
            font-size: 18px;
        }
    }
    
    .form-row {
        flex-direction: column;
        gap: 10px;
    }
    
    /* Улучшение форм для мобильных */
    #add-product-form,
    #edit-product-form,
    #add-material-form,
    #add-sale-form,
    #edit-sale-form-content,
    #add-transaction-form,
    #add-transaction-category-form {
        padding: 15px;
        max-width: 100%;
    }
    
    #add-product-form input,
    #add-product-form select,
    #add-product-form textarea,
    #edit-product-form input,
    #edit-product-form select,
    #edit-product-form textarea,
    #add-material-form input,
    #add-material-form select,
    #add-material-form textarea,
    #add-sale-form input,
    #add-sale-form select,
    #add-sale-form textarea,
    #edit-sale-form input,
    #edit-sale-form select,
    #edit-sale-form textarea {
        font-size: 16px; /* Предотвращает зум на iOS */
        padding: 12px;
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
        gap: 15px;
    }
    
    .stat-card {
        padding: 20px;
    }
    
    .stat-card h3 {
        font-size: 16px;
        margin-bottom: 12px;
    }
    
    .stat-value {
        font-size: 28px;
        margin-bottom: 8px;
    }
    
    .analytics-grid {
        grid-template-columns: 1fr;
    }
    
    /* Адаптивность для форм продаж */
    .form-section {
        margin-bottom: 15px;
        padding: 15px;
        padding: 15px;
    }
    
    .form-section h3 {
        font-size: 16px;
        margin-bottom: 10px;
    }
    
    .form-row {
        flex-direction: column;
        gap: 10px;
    }
    
    .form-group {
        width: 100%;
    }
    
    .form-group input,
    .form-group select {
        width: 100% !important;
        font-size: 16px !important; /* Предотвращает зум на iOS */
        padding: 12px !important;
        box-sizing: border-box !important;
        border-radius: 6px !important;
        border: 1px solid #ddd !important;
        background: white !important;
        -webkit-appearance: none !important;
        -moz-appearance: none !important;
        appearance: none !important;
    }
    
    /* Числовые поля с кнопками стрелок */
    input[type="number"] {
        -webkit-appearance: textfield !important;
        -moz-appearance: textfield !important;
        appearance: textfield !important;
        padding-right: 40px !important;
    }
    
    input[type="number"]::-webkit-outer-spin-button,
    input[type="number"]::-webkit-inner-spin-button {
        -webkit-appearance: inner-spin-button !important;
        appearance: inner-spin-button !important;
        opacity: 1 !important;
        height: 100% !important;
        width: 40px !important;
        cursor: pointer !important;
        background: #f8f9fa !important;
        border-left: 1px solid #ddd !important;
        position: relative !important;
        right: 0 !important;
        top: 0 !important;
    }
    
    /* Стили для мобильных числовых полей со стрелками */
    @media (max-width: 768px) {
        input[type="number"] {
            width: calc(100% - 50px) !important;
            padding-right: 50px !important;
            position: relative !important;
            background-color: white !important;
            -webkit-appearance: textfield !important;
            -moz-appearance: textfield !important;
            appearance: textfield !important;
        }
        
        /* Принудительно показываем стрелки */
        input[type="number"]::-webkit-outer-spin-button,
        input[type="number"]::-webkit-inner-spin-button {
            -webkit-appearance: inner-spin-button !important;
            appearance: inner-spin-button !important;
            opacity: 1 !important;
            height: 100% !important;
            width: 30px !important;
            cursor: pointer !important;
            background: #f8f9fa !important;
            border-left: 1px solid #dee2e6 !important;
            display: block !important;
            visibility: visible !important;
            pointer-events: auto !important;
            position: absolute !important;
            right: 0 !important;
            top: 0 !important;
            border-radius: 0 4px 4px 0 !important;
        }
        
        /* Если стандартные стрелки не работают, создаем кастомные */
        .mobile-spinner-container {
            position: relative;
            display: inline-block;
            width: 100%;
        }
        
        .mobile-spinner-buttons {
            position: absolute;
            right: 0;
            top: 50%;
            transform: translateY(-50%);
            width: 40px;
            height: 90%;
            background: #f8f9fa;
            border: 1px solid #dee2e6;
            border-radius: 4px;
            display: flex;
            flex-direction: column;
            z-index: 10;
            box-shadow: 0 2px 4px rgba(0,0,0,0.1);
        }
        
        .mobile-spinner-up,
        .mobile-spinner-down {
            flex: 1;
            border: none;
            background: transparent;
            font-size: 14px;
            color: #007bff;
            cursor: pointer;
            display: flex;
            align-items: center;
            justify-content: center;
            padding: 0;
            font-weight: bold;
            transition: background-color 0.2s;
            min-height: 20px;
        }
        
        .mobile-spinner-up:hover,
        .mobile-spinner-down:hover {
            background: #e9ecef;
        }
        
        .mobile-spinner-up:active,
        .mobile-spinner-down:active {
            background: #dee2e6;
        }
    }
    
    /* Убираем стрелки с селекторов */
    .form-group select {
        -webkit-appearance: menulist !important;
        -moz-appearance: menulist !important;
        appearance: menulist !important;
    }
    
    /* Специально для мобильных - убираем кастомные стрелки селекторов */
    @media (max-width: 768px) {
        .form-group select {
            -webkit-appearance: menulist !important;
            -moz-appearance: menulist !important;
            appearance: menulist !important;
            background-image: none !important;
            padding-right: 12px !important;
        }
    }
    
    /* Улучшенные селекторы для мобильных */
    .form-group select {
        -webkit-appearance: menulist !important;
        -moz-appearance: menulist !important;
        appearance: menulist !important;
        cursor: pointer !important;
        pointer-events: auto !important;
        touch-action: manipulation !important;
        padding-right: 12px !important;
    }
    
    /* Принудительная активация селекторов */
    select:focus,
    select:active,
    select:hover {
        outline: 2px solid #007bff !important;
        outline-offset: 2px !important;
        border-color: #007bff !important;
    }
    
    .form-group label {
        font-size: 14px;
        margin-bottom: 5px;
        display: block;
    }
    
    /* Кнопки */
    .btn {
        padding: 12px 20px;
        font-size: 16px;
        width: 100%;
        margin-bottom: 10px;
        box-sizing: border-box;
        word-wrap: break-word;
        white-space: normal;
        text-align: center;
        border-radius: 6px;
    }
    
    /* Кнопки с иконками */
    .btn i {
        margin-right: 8px;
    }
    
    /* Динамический блок итоговой стоимости для мобильных */
    .cost-summary.dynamic {
        position: fixed !important;
        padding: 10px 12px !important;
        font-size: 13px;
        z-index: 1000;
        box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.15);
        border-radius: 8px;
        height: auto !important;
        max-height: none !important;
        min-height: auto !important;
        overflow: visible !important;
        background: rgba(255, 255, 255, 0.95);
        backdrop-filter: blur(10px);
        width: calc(100% - 20px) !important;
        left: 10px !important;
        right: 10px !important;
    }
    
    .cost-summary.dynamic .cost-item {
        display: flex !important;
        justify-content: space-between !important;
        align-items: center !important;
        margin-bottom: 2px !important;
        margin-top: 0 !important;
        padding: 2px 0 !important;
        font-size: 13px !important;
        line-height: 1.3 !important;
        border: none !important;
    }
    
    .cost-summary.dynamic .cost-item:last-child {
        font-weight: bold;
        font-size: 14px;
        border-top: 1px solid #e9ecef !important;
        padding-top: 4px !important;
        margin-top: 4px !important;
        margin-bottom: 0 !important;
        line-height: 1.3;
    }
    
    /* Переопределяем общие правила для итогового элемента на мобильных */
    .cost-summary.dynamic .cost-item.total {
        border-top: 1px solid #e9ecef !important;
        border-bottom: none !important;
        font-size: 14px !important;
        margin-top: 4px !important;
        padding-top: 4px !important;
        margin-bottom: 0 !important;
    }
    
    /* Кнопка сворачивания для мобильных */
    .cost-summary.dynamic .collapse-btn {
        position: absolute;
        top: 5px;
        right: 5px;
        background: none;
        border: none;
        font-size: 18px;
        color: #666;
        cursor: pointer;
        padding: 5px;
        border-radius: 50%;
        width: 30px;
        height: 30px;
        display: flex;
        align-items: center;
        justify-content: center;
    }
    
    .cost-summary.dynamic .collapse-btn:hover {
        background: rgba(0, 0, 0, 0.1);
    }
    
    /* Скрытое состояние - уезжает вправо */
    .cost-summary.dynamic.collapsed {
        display: none !important;
    }
    
    
    .cost-summary.dynamic.collapsed .cost-items {
        display: none !important;
    }
    
    .cost-summary.dynamic.collapsed .collapse-btn {
        display: none !important;
    }
    
    /* Кнопка разворачивания в свернутом состоянии - НЕ ПЕРЕЗАПИСЫВАЕМ inline стили */
    /* Стили задаются через JavaScript */
    
    
    /* Показанное состояние - ПО УМОЛЧАНИЮ СКРЫТО */
    .cost-summary.dynamic:not(.collapsed) {
        transform: translateX(0);
        transition: transform 0.3s ease;
    }
    
    /* На мобильных устройствах убираем transform */
    @media (max-width: 768px) {
        .cost-summary.dynamic:not(.collapsed) {
            transform: none !important;
        }
    }
    
    /* По умолчанию окно скрыто - только для ПК */
    @media (min-width: 769px) {
        .cost-summary.dynamic {
            transform: translateX(calc(100% - 60px));
        }
    }
    
    /* Список товаров и материалов */
    .item-row {
        display: flex;
        flex-direction: column;
        gap: 6px;
        padding: 8px;
        margin-bottom: 6px;
        border-radius: 6px;
    }
    
    /* Первая строка: название и цена */
    .item-row .item-name {
        font-size: 13px;
        margin-bottom: 0;
        font-weight: 500;
        color: #333;
    }
    
    /* Вторая строка: количество и сумма */
    .item-details {
        display: flex;
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
        gap: 8px;
    }
    
    .item-details input[type="number"] {
        width: 40px;
        padding: 8px 3px;
        font-size: 13px;
        min-width: 40px;
        height: 32px;
        box-sizing: border-box;
    }
    
    .item-details span {
        font-size: 11px;
        white-space: nowrap;
    }
    
    .item-total {
        color: #28a745;
        font-weight: bold;
        font-size: 12px;
    }
    
    /* Кнопки удаления в блоках товаров */
    .item-row .btn-danger {
        width: 24px;
        height: 24px;
        padding: 0;
        font-size: 10px;
        border-radius: 4px;
        display: flex;
        align-items: center;
        justify-content: center;
        flex-shrink: 0;
    }
    
    /* Секция товаров и материалов - вертикальное расположение */
    .form-section .form-row {
        display: flex !important;
        flex-direction: column !important;
        gap: 10px !important;
        align-items: stretch !important;
        width: 100% !important;
        max-width: 100% !important;
        margin: 0 !important;
        padding: 0 !important;
    }
    
    .form-section .form-row .form-group {
        width: 100% !important;
        flex: none !important;
        max-width: 100% !important;
        box-sizing: border-box !important;
        margin: 0 !important;
        padding: 0 !important;
    }
    
    .form-section .form-row .form-group input,
    .form-section .form-row .form-group select {
        width: 100% !important;
        max-width: 100% !important;
        box-sizing: border-box !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
        margin: 0 !important;
        padding: 12px !important;
        font-size: 16px !important;
    }
    
    .form-section .form-row .btn {
        width: 100% !important;
        margin-bottom: 0 !important;
        padding: 12px 15px !important;
        white-space: normal !important;
        text-align: center !important;
        box-sizing: border-box !important;
        font-size: 14px !important;
        display: block !important;
        border-radius: 6px !important;
    }
    
    /* Специальные стили для секции товаров и материалов */
    .add-item-form .item-selection-row {
        display: flex !important;
        flex-direction: column !important;
        gap: 15px !important;
        width: 100% !important;
        max-width: 100% !important;
        box-sizing: border-box !important;
    }
    
    .add-item-form .item-selection-row .form-group {
        width: 100% !important;
        flex: none !important;
        max-width: 100% !important;
        box-sizing: border-box !important;
        margin: 0 !important;
        padding: 0 !important;
    }
    
    .add-item-form .item-selection-row .form-group input,
    .add-item-form .item-selection-row .form-group select {
        width: 100% !important;
        max-width: 100% !important;
        box-sizing: border-box !important;
        margin: 0 !important;
        padding: 12px !important;
        font-size: 16px !important;
    }
    
    .add-item-form .item-selection-row .form-group .btn {
        width: 100% !important;
        max-width: 100% !important;
        display: block !important;
        box-sizing: border-box !important;
        margin: 0 !important;
        padding: 12px 15px !important;
    }
    
    /* Дополнительные расходы - горизонтальное расположение */
    .form-section:nth-of-type(3) .form-row {
        display: grid !important;
        grid-template-columns: 1fr 1fr !important;
        gap: 10px !important;
    }
    
    .form-section:nth-of-type(3) .form-row .form-group {
        width: 100% !important;
    }
    
    .form-section:nth-of-type(3) .form-row .btn {
        grid-column: 1 / -1 !important;
        width: 100% !important;
    }
    
    /* Принудительное переопределение стилей для мобильных */
    .page#sale-form .form-section .form-row,
    .page#edit-sale-form-content .form-section .form-row,
    .page#add-sale-form .form-section .form-row {
        display: flex !important;
        flex-direction: column !important;
        gap: 10px !important;
    }
    
    .page#sale-form .form-section .form-row .form-group,
    .page#edit-sale-form-content .form-section .form-row .form-group,
    .page#add-sale-form .form-section .form-row .form-group {
        width: 100% !important;
        flex: none !important;
    }
    
    .page#sale-form .form-section .form-row .btn,
    .page#edit-sale-form-content .form-section .form-row .btn,
    .page#add-sale-form .form-section .form-row .btn {
        width: 100% !important;
        display: block !important;
    }
    
    /* Универсальные стили для всех форм на мобильных */
    .form-section .form-row {
        display: flex !important;
        flex-direction: column !important;
        gap: 15px !important;
        width: 100% !important;
        max-width: 100% !important;
        box-sizing: border-box !important;
    }
    
    .form-section .form-row .form-group {
        width: 100% !important;
        flex: none !important;
        max-width: 100% !important;
        box-sizing: border-box !important;
    }
    
    .form-section .form-row .form-group input,
    .form-section .form-row .form-group select {
        width: 100% !important;
        max-width: 100% !important;
        box-sizing: border-box !important;
    }
    
    .form-section .form-row .btn {
        width: 100% !important;
        max-width: 100% !important;
        display: block !important;
        box-sizing: border-box !important;
    }
    
    /* Принудительные стили для контейнера */
    .container {
        width: 100% !important;
        max-width: 100% !important;
        padding: 10px !important;
        box-sizing: border-box !important;
        overflow-x: hidden !important;
    }
    
    .page {
        width: 100% !important;
        max-width: 100% !important;
        box-sizing: border-box !important;
        overflow-x: hidden !important;
    }
    
    /* Дополнительные расходы */
    .form-section .form-row .form-group input {
        text-align: right;
    }
    
    /* Специальные стили для числовых полей с стрелками */
    #artist_count, #agent_cost, #transport_cost,
    #edit_artist_count, #edit_agent_cost, #edit_transport_cost {
        width: calc(100% - 50px) !important;
        padding-right: 50px !important;
    }
    
    /* Стили для полей количества в блоках товаров */
    .item-details input[type="number"] {
        width: calc(40px - 16px) !important;
        padding-right: 20px !important;
    }
    
    /* Навигационные кнопки */
    .page-header {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }
    
    .page-header .btn {
        width: 100%;
        margin-bottom: 10px;
    }
}

/* Дополнительные стили для очень маленьких экранов */
@media (max-width: 480px) {
    .container {
        padding: 5px;
    }
    
    .form-section {
        padding: 10px;
        margin-bottom: 10px;
    }
    
    .form-section h3 {
        font-size: 14px;
        margin-bottom: 8px;
    }
    
    .form-group input,
    .form-group select {
        padding: 10px;
        font-size: 16px;
    }
    
    .btn {
        padding: 10px 15px;
        font-size: 14px;
    }
    
    /* Динамический блок для очень маленьких экранов */
    .cost-summary.dynamic {
        padding: 10px 12px !important;
        font-size: 13px;
        height: auto;
        width: calc(100% - 20px) !important;
        left: 10px !important;
        right: 10px !important;
    }
    
    .cost-summary.dynamic .cost-item {
        font-size: 13px !important;
        margin-bottom: 2px !important;
        padding: 2px 0 !important;
        line-height: 1.3 !important;
    }
    
    .cost-summary.dynamic .cost-item:last-child {
        font-size: 14px;
        padding-top: 4px !important;
        margin-top: 4px !important;
        line-height: 1.3;
    }
    
    /* Товары и материалы */
    .item-row {
        padding: 6px;
        margin-bottom: 4px;
        gap: 4px;
    }
    
    .item-name {
        font-size: 11px;
        margin-bottom: 0;
    }
    
    .item-details {
        gap: 6px;
    }
    
    .item-details input[type="number"] {
        width: 35px;
        padding: 6px 2px;
        font-size: 11px;
        min-width: 35px;
        height: 28px;
        box-sizing: border-box;
    }
    
    .item-details span {
        font-size: 10px;
    }
    
    .item-total {
        font-size: 11px;
    }
    
    /* Кнопки удаления для маленьких экранов */
    .item-row .btn-danger {
        width: 20px;
        height: 20px;
        font-size: 8px;
    }
    
    /* Секция товаров и материалов */
    .form-section .form-row {
        flex-direction: column;
        gap: 8px;
        width: 100%;
        max-width: 100%;
    }
    
    .form-section .form-row .form-group {
        width: 100%;
        max-width: 100%;
    }
    
    .form-section .form-row .btn {
        width: 100%;
        margin-bottom: 8px;
        padding: 10px 12px;
        font-size: 14px;
        box-sizing: border-box;
        word-wrap: break-word;
    }
    
    /* Дополнительные расходы для маленьких экранов */
    .form-section:nth-of-type(3) .form-row {
        display: flex;
        flex-direction: column;
        gap: 8px;
    }
    
    .form-section:nth-of-type(3) .form-row .form-group {
        width: 100%;
    }
}

/* Анимации */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.page.active {
    animation: fadeIn 0.3s ease;
}

/* Секции формы */
.form-section {
    background: #f8f9fa;
    padding: 20px;
    border-radius: 10px;
    margin-bottom: 20px;
    border: 1px solid #e9ecef;
}

/* Строка выбора товаров */
.item-selection-row {
    display: grid;
    grid-template-columns: 1fr 2fr 1fr 1fr auto;
    gap: 15px;
    align-items: end;
    background: white;
    padding: 20px;
    border-radius: 8px;
    border: 1px solid #e9ecef;
    margin-bottom: 20px;
}

/* Кнопка добавления товара */
.item-selection-row .btn {
    padding: 8px 16px;
    font-size: 14px;
    white-space: nowrap;
    min-width: auto;
}

.item-selection-row .form-group {
    margin-bottom: 0;
}

.item-selection-row .form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: 500;
    color: #333;
}

.item-selection-row .form-group input,
.item-selection-row .form-group select {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
}

/* Улучшаем отображение выпадающего списка товаров */
.item-selection-row select {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
}

.item-selection-row select option {
    padding: 8px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.form-section h3 {
    margin-bottom: 15px;
    color: #333;
    font-size: 18px;
}

/* Список сотрудников */
.employees-list {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 15px;
}

.employee-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px;
    background: white;
    border-radius: 8px;
    border: 1px solid #e9ecef;
}

.employee-item input[type="checkbox"] {
    width: 18px;
    height: 18px;
}

.employee-item input[type="number"] {
    width: 100px;
    padding: 5px;
    border: 1px solid #ddd;
    border-radius: 4px;
    display: none;
}

.employee-item input[type="number"].visible {
    display: block;
}

/* Сводка стоимости */
.cost-summary {
    background: white;
    padding: 20px;
    border-radius: 8px;
    border: 1px solid #e9ecef;
    margin-bottom: 20px;
}

.cost-item {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid #f0f0f0;
}

.cost-item.total {
    border-top: 2px solid #667eea;
    border-bottom: none;
    font-size: 16px;
    margin-top: 10px;
    padding-top: 15px;
}

/* Утилиты */
.text-center {
    text-align: center;
}

.text-success {
    color: #28a745;
}

.text-danger {
    color: #dc3545;
}

.text-warning {
    color: #ffc107;
}

.text-info {
    color: #17a2b8;
}

.mb-3 {
    margin-bottom: 1rem;
}

.mt-3 {
    margin-top: 1rem;
}

/* Загрузка */
.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* ============================================
   ФИНАЛЬНЫЕ СТИЛИ ДЛЯ КНОПОК В HEADER - ПРИМЕНЯЮТСЯ В КОНЦЕ ФАЙЛА
   Эти стили имеют максимальный приоритет и переопределяют все остальные
   ============================================ */
.page .header .btn,
.page .header-buttons .btn,
.page .header > .btn,
#sales .header .btn,
#sales .header-buttons .btn,
#products .header .btn,
#products .header-buttons .btn,
#materials .header .btn,
#materials .header-buttons .btn,
#employees .header .btn,
#employees .header > .btn,
#transactions .header .btn,
#transactions .header-buttons .btn {
    height: 48px !important;
    width: 200px !important;
    min-width: 200px !important;
    max-width: 200px !important;
    padding: 12px 16px !important;
    font-size: 14px !important;
    font-weight: 500 !important;
    white-space: normal !important;
    word-wrap: break-word !important;
    overflow-wrap: break-word !important;
    text-overflow: clip !important;
    margin: 0 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    text-align: center !important;
    line-height: 1.3 !important;
    overflow: hidden !important;
    box-sizing: border-box !important;
    flex: 0 0 200px !important;
}

.page .header .btn i,
.page .header-buttons .btn i,
.page .header > .btn i,
#sales .header .btn i,
#sales .header-buttons .btn i,
#products .header .btn i,
#products .header-buttons .btn i,
#materials .header .btn i,
#materials .header-buttons .btn i,
#employees .header .btn i,
#employees .header > .btn i,
#transactions .header .btn i,
#transactions .header-buttons .btn i {
    flex-shrink: 0 !important;
    margin-right: 8px !important;
    font-size: 14px !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: auto !important;
    line-height: 1 !important;
}

/* КРИТИЧЕСКИ ВАЖНО: Переопределение для мобильных устройств - должно быть в конце */
@media (max-width: 768px) {
    /* ВСЕ кнопки в header на мобильных - УНИВЕРСАЛЬНЫЙ СЕЛЕКТОР */
    .header .btn,
    .header-buttons .btn,
    .header > .btn,
    div.header .btn,
    div.header-buttons .btn,
    div.header > .btn {
        width: 100% !important;
        height: 50px !important;
        min-width: auto !important;
        max-width: 100% !important;
        padding: 14px 16px !important;
        font-size: 15px !important;
        font-weight: 500 !important;
        white-space: normal !important;
        word-wrap: break-word !important;
        overflow-wrap: break-word !important;
        line-height: 1.3 !important;
        margin: 0 !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        text-align: center !important;
        overflow: hidden !important;
        flex: 0 0 100% !important;
        box-sizing: border-box !important;
        border-radius: 8px !important;
    }
    
    /* Иконки в кнопках header на мобильных */
    .header .btn i,
    .header-buttons .btn i,
    .header > .btn i {
        flex-shrink: 0 !important;
        margin-right: 8px !important;
        font-size: 15px !important;
        display: inline-flex !important;
        align-items: center !important;
        justify-content: center !important;
        width: auto !important;
        line-height: 1 !important;
    }
    
    /* Заголовки на мобильных - ВСЕ одинаковые */
    .header h2 {
        font-size: 20px !important;
        font-weight: 600 !important;
        margin-bottom: 10px !important;
        line-height: 1.2 !important;
    }
    
    /* header-buttons на мобильных - вертикальная раскладка */
    .header-buttons {
        display: flex !important;
        flex-direction: column !important;
        gap: 10px !important;
        width: 100% !important;
        align-items: stretch !important;
    }
    
    /* header на мобильных - вертикальная раскладка */
    .header {
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 15px !important;
    }
}

/* Унифицированный размер заголовков h2 на всех страницах */
.page .header h2,
#sales .header h2,
#products .header h2,
#materials .header h2,
#employees .header h2,
#transactions .header h2 {
    font-size: 24px !important;
    font-weight: 600 !important;
}

/* Стили для кнопок в заголовке (дубликат удален, используется выше) */

/* ============================================
   ФИНАЛЬНОЕ ПРАВИЛО ДЛЯ МОБИЛЬНЫХ - В КОНЦЕ ФАЙЛА
   Переопределяет ВСЕ остальные стили для кнопок в header
   ============================================ */
@media (max-width: 768px) {
    /* ВСЕ кнопки в header на мобильных - АБСОЛЮТНО ОДИНАКОВЫЕ */
    
    /* Адаптивность для диаграммы аналитики */
    .analytics-chart-section {
        margin-top: 20px;
        padding: 15px;
    }
    
    .chart-tabs {
        border-bottom: 1px solid #ddd;
    }
    
    .chart-tab-btn {
        padding: 8px 15px;
        font-size: 12px;
    }
    
    .chart-container {
        height: 300px;
    }
    
    /* Модальное окно для просмотра продаж по материалу */
    .modal {
        display: none;
        position: fixed;
        z-index: 1000;
        left: 0;
        top: 0;
        width: 100%;
        height: 100%;
        background-color: rgba(0, 0, 0, 0.5);
        overflow-y: auto;
    }
    
    .modal-content {
        background-color: #fefefe;
        margin: 5% auto;
        padding: 0;
        border-radius: 10px;
        width: 90%;
        max-width: 800px;
        box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
        animation: modalSlideIn 0.3s ease-out;
    }
    
    @keyframes modalSlideIn {
        from {
            transform: translateY(-50px);
            opacity: 0;
        }
        to {
            transform: translateY(0);
            opacity: 1;
        }
    }
    
    .modal-header {
        background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
        color: white;
        padding: 20px;
        border-radius: 10px 10px 0 0;
        display: flex;
        justify-content: space-between;
        align-items: center;
    }
    
    .modal-header h3 {
        margin: 0;
        font-size: 20px;
    }
    
    .modal-close {
        background: none;
        border: none;
        color: white;
        font-size: 24px;
        cursor: pointer;
        padding: 0;
        width: 30px;
        height: 30px;
        display: flex;
        align-items: center;
        justify-content: center;
        border-radius: 50%;
        transition: background-color 0.3s ease;
    }
    
    .modal-close:hover {
        background-color: rgba(255, 255, 255, 0.2);
    }
    
    .modal-body {
        padding: 20px;
        max-height: 60vh;
        overflow-y: auto;
    }
    
    .sale-item {
        background: #f8f9fa;
        border-radius: 8px;
        padding: 15px;
        margin-bottom: 15px;
        border: 1px solid #e9ecef;
        transition: transform 0.2s ease, box-shadow 0.2s ease;
    }
    
    .sale-item:hover {
        transform: translateY(-2px);
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    }
    
    .sale-header {
        display: flex;
        justify-content: space-between;
        align-items: center;
        margin-bottom: 10px;
        padding-bottom: 10px;
        border-bottom: 2px solid #e9ecef;
    }
    
    .sale-date {
        font-size: 14px;
        color: #666;
        font-weight: normal;
    }
    
    .sale-info {
        margin-bottom: 15px;
        padding: 10px;
        background: white;
        border-radius: 6px;
        border: 1px solid #f0f0f0;
    }
    
    .sale-info div {
        margin-bottom: 5px;
        font-size: 14px;
    }
    
    .sale-materials {
        background: #e3f2fd;
        border-radius: 6px;
        padding: 15px;
        border: 1px solid #bbdefb;
    }
    
    .sale-materials h4 {
        margin: 0 0 10px 0;
        color: #1976d2;
        font-size: 16px;
    }
    
    .material-detail {
        background: white;
        border-radius: 6px;
        padding: 12px;
        margin-bottom: 10px;
        border: 1px solid #ddd;
    }
    
    .material-detail div {
        margin-bottom: 8px;
        font-size: 14px;
    }
    
    .material-detail ul {
        margin: 8px 0;
        padding-left: 20px;
    }
    
    .material-detail li {
        margin-bottom: 4px;
        font-size: 14px;
    }
    button.btn,
    .btn,
    .header button,
    .header .btn,
    .header > button,
    .header > .btn,
    .header-buttons button,
    .header-buttons .btn,
    .header-buttons button.btn,
    .header-buttons .btn.btn-primary,
    .header-buttons .btn.btn-secondary,
    .header-buttons .btn.btn-success,
    .header-buttons .btn.btn-info,
    .header-buttons .btn.btn-warning {
        width: 100% !important;
        height: 50px !important;
        min-height: 50px !important;
        max-height: 50px !important;
        min-width: 100% !important;
        max-width: 100% !important;
        padding: 12px 16px !important;
        font-size: 15px !important;
        font-weight: 500 !important;
        white-space: normal !important;
        word-wrap: break-word !important;
        overflow-wrap: break-word !important;
        line-height: 1.3 !important;
        margin: 0 !important;
        margin-bottom: 10px !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        text-align: center !important;
        overflow: hidden !important;
        flex: none !important;
        flex-grow: 0 !important;
        flex-shrink: 0 !important;
        flex-basis: auto !important;
        box-sizing: border-box !important;
        border-radius: 8px !important;
    }
    
    .header-buttons button:last-child,
    .header-buttons .btn:last-child,
    .header > button:last-child,
    .header > .btn:last-child {
        margin-bottom: 0 !important;
    }
    
    button.btn i,
    .btn i,
    .header button i,
    .header .btn i,
    .header-buttons button i,
    .header-buttons .btn i {
        flex-shrink: 0 !important;
        margin-right: 8px !important;
        font-size: 15px !important;
        display: inline-flex !important;
        align-items: center !important;
        justify-content: center !important;
        width: auto !important;
        line-height: 1 !important;
    }
    
    /* Стили для вкладок материалов */
    .materials-tabs {
        display: flex;
        margin-bottom: 20px;
        border-bottom: 2px solid #e9ecef;
        gap: 2px;
    }
    
    .materials-tab-btn {
        padding: 12px 24px;
        background: none;
        border: none;
        border-bottom: 3px solid transparent;
        color: #666;
        font-size: 16px;
        cursor: pointer;
        transition: all 0.3s ease;
        font-weight: 500;
    }
    
    /* Стили для прогноза использования материалов */
    .forecast-critical {
        color: #dc3545 !important;
        background-color: #f8d7da !important;
        padding: 2px 6px;
        border-radius: 4px;
        border: 1px solid #f5c6cb;
    }
    
    .forecast-warning {
        color: #856404 !important;
        background-color: #fff3cd !important;
        padding: 2px 6px;
        border-radius: 4px;
        border: 1px solid #ffeaa7;
    }
    
    .forecast-critical:hover,
    .forecast-warning:hover {
        opacity: 0.8;
        transform: scale(1.05);
        transition: all 0.2s ease;
    }
    
    /* Стили для модального окна прогноза */
    #materialForecastModal {
        position: fixed;
        z-index: 1000;
        left: 0;
        top: 0;
        width: 100%;
        height: 100%;
        background-color: rgba(0, 0, 0, 0.5);
        display: flex;
        justify-content: center;
        align-items: center;
    }
    
    #materialForecastModal .modal-content {
        background-color: #fefefe;
        margin: auto;
        padding: 20px;
        border: 1px solid #888;
        border-radius: 8px;
        box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
        max-width: 500px;
        width: 90%;
    }
    
    #materialForecastModal .modal-header {
        display: flex;
        justify-content: space-between;
        align-items: center;
        margin-bottom: 15px;
        padding-bottom: 10px;
        border-bottom: 1px solid #eee;
    }
    
    #materialForecastModal .modal-header h3 {
        margin: 0;
        color: #333;
    }
    
    #materialForecastModal .close {
        font-size: 28px;
        font-weight: bold;
        color: #aaa;
        cursor: pointer;
        line-height: 1;
    }
    
    #materialForecastModal .close:hover {
        color: #000;
    }
    
    #materialForecastModal .modal-body {
        padding: 15px 0;
    }
    
    #materialForecastModal .forecast-info {
        line-height: 1.6;
    }
    
    #materialForecastModal .forecast-info p {
        margin: 8px 0;
    }
    
    #materialForecastModal .forecast-info strong {
        color: #333;
    }
    
    #materialForecastModal .forecast-info #modal-warning-text {
        margin-top: 15px;
        padding: 10px;
        border-radius: 4px;
        font-weight: bold;
        text-align: center;
    }
    
    .materials-tab-btn:hover {
        color: #007bff;
        background: #f8f9fa;
    }
    
    .materials-tab-btn.active {
        color: #007bff;
        border-bottom-color: #007bff;
        background: #f8f9fa;
    }
    
    .materials-tab-content {
        margin-top: 20px;
    }
    
    .materials-tab-pane {
        display: none;
    }
    
    .materials-tab-pane.active {
        display: block;
    }
    
    /* Стили для раздела остатков */
    .balance-section {
        background: white;
        border-radius: 10px;
        padding: 20px;
        box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
        border: 1px solid #e9ecef;
    }
    
    .balance-header {
        display: flex;
        justify-content: space-between;
        align-items: center;
        margin-bottom: 20px;
        flex-wrap: wrap;
        gap: 10px;
    }
    
    .balance-header h3 {
        margin: 0;
        color: #333;
        font-size: 18px;
    }
    
    .balance-controls {
        display: flex;
        gap: 10px;
    }
    
    .balance-table-container {
        margin-top: 20px;
    }
    
    /* Стили для статуса остатков */
    .status-good {
        color: #28a745;
        font-weight: bold;
    }
    
    .status-warning {
        color: #ffc107;
        font-weight: bold;
    }
    
    .status-critical {
        color: #dc3545;
        font-weight: bold;
    }
    
    /* Адаптивность для мобильных устройств */
    @media (max-width: 768px) {
        .materials-tabs {
            flex-direction: column;
            gap: 5px;
        }
        
        .materials-tab-btn {
            text-align: left;
            padding: 10px 15px;
            border-bottom: 2px solid transparent;
            border-left: 3px solid transparent;
        }
        
        .materials-tab-btn.active {
            border-left-color: #007bff;
            border-bottom-color: transparent;
        }
        
        .balance-header {
            flex-direction: column;
            align-items: flex-start;
        }
        
        .balance-controls {
            width: 100%;
            justify-content: flex-start;
        }
    }
    
    .header-buttons {
        display: flex !important;
        flex-direction: column !important;
        gap: 10px !important;
        width: 100% !important;
        align-items: stretch !important;
    }
    
    .header {
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 15px !important;
    }
    
    .header h2 {
        font-size: 20px !important;
        font-weight: 600 !important;
        margin-bottom: 10px !important;
    }
}
