/* Общие стили — адаптивная вёрстка, mobile-first */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: #f5f5f5;
    font-size: 16px;
    line-height: 1.5;
    color: #1a1a1a;
    overflow-x: hidden;
    -webkit-tap-highlight-color: transparent;
}

a {
    color: #2563eb;
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

/* Страница входа — как в проекте cargo */
.login-page {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
    padding-left: max(20px, env(safe-area-inset-left));
    padding-right: max(20px, env(safe-area-inset-right));
}

.login-container {
    background: white;
    border-radius: 10px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.2);
    padding: 40px;
    width: 100%;
    max-width: 400px;
}

.login-container h1 {
    text-align: center;
    margin-bottom: 30px;
    color: #333;
    font-size: 24px;
}

.login-container h2 {
    margin-bottom: 20px;
    color: #333;
    font-size: 18px;
}

.login-container .error {
    background: #fee;
    color: #c33;
    padding: 12px;
    border-radius: 5px;
    margin-bottom: 20px;
    border: 1px solid #fcc;
}

.login-container .success {
    background: #efe;
    color: #3c3;
    padding: 12px;
    border-radius: 5px;
    margin-bottom: 20px;
    border: 1px solid #cfc;
}

.msg {
    padding: 0.75rem 1rem;
    border-radius: 8px;
    margin-bottom: 1rem;
}
.msg.success {
    background: #f0fdf4;
    color: #166534;
    border-left: 4px solid #22c55e;
}
.msg.error {
    background: #fef2f2;
    color: #991b1b;
    border-left: 4px solid #dc2626;
}

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

.login-container label {
    display: block;
    margin-bottom: 5px;
    color: #555;
    font-weight: 500;
}

.login-container .password-wrapper {
    position: relative;
}

.login-container input[type="text"],
.login-container input[type="password"] {
    width: 100%;
    padding: 12px 40px 12px 12px;
    border: 2px solid #ddd;
    border-radius: 5px;
    font-size: 16px;
    transition: border-color 0.3s;
    box-sizing: border-box;
}

.login-container .password-toggle {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    cursor: pointer;
    font-size: 18px;
    color: #666;
    padding: 5px;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
}

.login-container .password-toggle:hover {
    color: #667eea;
}

.login-container input[type="text"]:focus,
.login-container input[type="password"]:focus {
    outline: none;
    border-color: #667eea;
}

.login-container button[type="submit"] {
    width: 100%;
    padding: 12px;
    background: #667eea;
    color: white;
    border: none;
    border-radius: 5px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.3s;
}

.login-container button[type="submit"]:hover {
    background: #5568d3;
}

.login-container .password-reset-link {
    text-align: center;
    margin-top: 15px;
}

.login-container .password-reset-link a {
    color: #667eea;
    text-decoration: none;
    font-size: 14px;
}

.login-container .password-reset-link a:hover {
    text-decoration: underline;
}

.login-container .password-reset-form {
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid #eee;
}

.login-container .password-reset-form a {
    display: block;
    text-align: center;
    margin-top: 10px;
    color: #667eea;
    text-decoration: none;
}

/* Шапка — как в проекте cargo, без переключателя языков */
.header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 15px 20px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    position: sticky;
    top: 0;
    z-index: 1000;
}

.header-content {
    max-width: 1400px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 15px;
    width: 100%;
}

.header-left {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
    flex: 1;
}

.header-right {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
    flex: 0 0 auto;
}

.header-button {
    padding: 8px 16px;
    background: rgba(255,255,255,0.2);
    border: 1px solid rgba(255,255,255,0.3);
    color: white;
    border-radius: 5px;
    cursor: pointer;
    text-decoration: none;
    font-size: 14px;
    transition: background 0.3s;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    -webkit-appearance: none;
    appearance: none;
}

.header-button:hover {
    background: rgba(255,255,255,0.3);
    color: white;
}

.header-button-icon {
    font-size: 16px;
}

.notif-badge {
    background: #dc2626;
    color: #fff;
    font-size: 0.75rem;
    padding: 0.15rem 0.4rem;
    border-radius: 10px;
    margin-left: 0.25rem;
}

/* Фиксированный футер для официанта и повара (не скроллится) */
.has-role-footer .main-content {
    padding-bottom: 80px;
}

.role-footer {
    position: fixed;
    bottom: 16px;
    left: 50%;
    transform: translateX(-50%);
    width: auto;
    max-width: 140px;
    display: flex;
    justify-content: center;
    align-items: center;
    background: #fff;
    border-radius: 50px;
    padding: 10px 20px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.12);
    z-index: 1000;
    border: 1px solid #e5e7eb;
}

.role-footer-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-decoration: none;
    color: #4b5563;
    font-size: 12px;
    font-weight: 500;
    padding: 0;
    border-radius: 0;
    transition: color 0.2s;
}

.role-footer-item:hover {
    color: #667eea;
}

.role-footer-item--center {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.role-footer-icon-wrap {
    position: relative;
    display: inline-block;
    margin-bottom: 6px;
}

.role-footer-icon {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
    font-size: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.4);
    transition: transform 0.2s, box-shadow 0.2s;
}

.role-footer-item:hover .role-footer-icon {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.5);
}

.role-footer-icon--bell {
    font-size: 24px;
}

.role-footer-label {
    line-height: 1.2;
}

.role-footer-badge {
    position: absolute;
    top: -2px;
    right: -2px;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    background: #dc2626;
    color: #fff;
    font-size: 11px;
    font-weight: 600;
    line-height: 18px;
    text-align: center;
    border-radius: 50%;
    border: 2px solid #fff;
    box-sizing: border-box;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Контент */
.main-content {
    max-width: 1400px;
    margin: 20px auto;
    padding: 0 20px;
}

.page-title {
    margin: 0 0 1rem;
    font-size: 1.25rem;
    color: #333;
    word-wrap: break-word;
    overflow-wrap: break-word;
}
.page-title-count {
    color: #64748b;
    font-weight: 500;
}

/* Сетки и карточки */
.card {
    background: white;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    padding: 30px;
    margin-bottom: 1rem;
}

.card h2 {
    color: #667eea;
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 2px solid #667eea;
}

.grid {
    display: grid;
    gap: 1rem;
}

@media (min-width: 600px) {
    .grid-2 {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (min-width: 900px) {
    .grid-3 {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* Кнопки и формы */
.btn {
    display: inline-block;
    padding: 0.5rem 1rem;
    border-radius: 5px;
    font-size: 0.9rem;
    cursor: pointer;
    border: none;
    text-align: center;
    transition: background 0.3s;
}

.btn-primary {
    background: #667eea;
    color: white;
}

.btn-primary:hover {
    background: #5568d3;
}

/* Кнопки Excel: скачивание шаблона, выгрузка отчёта — единый стиль по всему приложению */
.btn-export-excel {
    background: #d4edda;
    color: #155724;
    border: 2px solid #28a745;
    text-decoration: none;
    padding: 0 1rem;
    border-radius: 8px;
    font-size: 0.95rem;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    height: 38px;
    box-sizing: border-box;
    transition: background 0.3s, border-color 0.3s;
}

.btn-export-excel:hover {
    background: #28a745;
    color: #fff;
    border-color: #218838;
}

/* Панель «Заказы на складе» — поиск и кнопки */
.available-search-form {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    flex: 1;
    min-width: 0;
}
.available-search-form #clientPhoneInput,
.available-search-form input[type="text"][name="search"] {
    padding: 8px 12px;
    border: 2px solid #c4b5fd;
    border-radius: 6px;
    min-width: 180px;
    flex: 1;
    box-sizing: border-box;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12), 0 1px 2px rgba(0, 0, 0, 0.08);
    transition: box-shadow 0.2s, border-color 0.2s;
}
.available-search-form #clientPhoneInput:focus,
.available-search-form input[type="text"][name="search"]:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.25);
}
.available-toolbar-buttons {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

/* Кнопка «Найти товары» — такой же размер, как «Выгрузить в Excel» */
.available-toolbar .btn-toolbar-equal {
    height: 38px;
    padding: 0 1rem;
    border-radius: 8px;
    font-size: 0.95rem;
    font-weight: 600;
    box-sizing: border-box;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.available-toolbar a.btn-toolbar-equal {
    text-decoration: none;
    min-height: 38px;
}

/* Период в статистике: одна высота для полей дат, кнопки «Применить» и «Выгрузить» */
.stats-period-nav .input-cafe {
    height: 38px;
    box-sizing: border-box;
}

.stats-period-nav .btn {
    height: 38px;
    box-sizing: border-box;
    padding: 0 1rem;
    display: inline-flex;
    align-items: center;
}

.btn-secondary {
    background: #e5e7eb;
    color: #1a1a1a;
}

.btn-secondary:hover {
    background: #d1d5db;
}

.btn-danger {
    background: #dc3545;
    color: white;
}

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

/* Автодополнение продукта (списание, закуп, приём закупа, меню) */
.product-autocomplete-wrap { position: relative; display: inline-block; min-width: 200px; }
.product-autocomplete-wrap .product-autocomplete { width: 100%; min-width: 180px; box-sizing: border-box; }
.product-autocomplete-list { position: absolute; left: 0; top: 100%; z-index: 10; background: #fff; border: 1px solid #cbd5e1; border-top: none; border-radius: 0 0 6px 6px; max-height: 200px; overflow-y: auto; box-shadow: 0 4px 6px -1px rgba(0,0,0,0.1); min-width: 100%; display: none; }
.product-autocomplete-list.show { display: block; }
.product-autocomplete-list [role="option"] { padding: 0.4rem 0.6rem; cursor: pointer; }
.product-autocomplete-list [role="option"]:hover, .product-autocomplete-list [role="option"].highlight { background: #f1f5f9; }
.product-autocomplete-wrap .product-unit-display { display: none; color: #475569; margin-left: 0.25rem; }
.product-autocomplete-wrap.product-selected .product-unit-display { display: inline; }
.form-hint { font-size: 0.9rem; color: #64748b; margin-bottom: 0.75rem; }

/* Модальное окно уведомлений (успех/ошибка) — единый стиль по проекту */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 10000;
    justify-content: center;
    align-items: center;
    padding: 16px;
    box-sizing: border-box;
}

.modal-overlay.show {
    display: flex;
}

/* Модальное окно для просмотра фото */
.photo-modal-overlay {
    background: rgba(0, 0, 0, 0.92) !important;
    cursor: pointer;
    justify-content: center;
    align-items: center;
}
.photo-modal-overlay .photo-modal-inner {
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    max-width: 95vw;
    max-height: 95vh;
    cursor: default;
}
.photo-modal-overlay .photo-modal-inner img {
    max-width: 95vw;
    max-height: 90vh;
    width: auto;
    height: auto;
    display: block;
    border-radius: 8px;
}
.photo-modal-close {
    position: absolute;
    top: -12px;
    right: -12px;
    width: 44px;
    height: 44px;
    background: rgba(0, 0, 0, 0.6);
    color: #fff;
    border: 2px solid rgba(255, 255, 255, 0.5);
    border-radius: 50%;
    cursor: pointer;
    font-size: 24px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1;
    transition: background 0.2s;
    -webkit-tap-highlight-color: transparent;
}
.photo-modal-close:hover,
.photo-modal-close:active {
    background: rgba(255, 255, 255, 0.25);
}

.modal-content {
    background: white;
    border-radius: 10px;
    padding: 24px 28px;
    max-width: 360px;
    width: 100%;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    animation: modalSlideIn 0.3s ease;
    box-sizing: border-box;
}

@keyframes modalSlideIn {
    from { transform: translateY(-50px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.modal-message {
    font-size: 16px;
    margin-bottom: 20px;
    line-height: 1.5;
    text-align: center;
}

.modal-success .modal-message {
    color: #155724;
}

.modal-error .modal-message {
    color: #721c24;
}

.modal-success .modal-content {
    border-top: 4px solid #28a745;
}

.modal-error .modal-content {
    border-top: 4px solid #dc3545;
}

/* Модальное окно с формой — шире для полей */
.modal-content.modal-form {
    max-width: 540px;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-form .modal-title {
    font-size: 1.25rem;
    color: #333;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid #e5e7eb;
}

/* Модальное окно редактирования — желтоватый фон, чтобы отличать от добавления */
.modal-form-edit {
    background: #fffbeb;
    border: 1px solid #fde68a;
    box-shadow: 0 10px 40px rgba(251, 191, 36, 0.15);
}

.modal-form-edit .modal-title {
    border-bottom-color: #fde68a;
}

/* Кнопки действий в таблице расходов — как в разделах Пользователи, Cargo */
.expense-actions {
    display: flex;
    gap: 8px;
    flex-wrap: nowrap;
    justify-content: flex-end;
    align-items: center;
}

.expense-actions .btn-edit {
    padding: 8px 14px;
    background: #667eea;
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.2s;
}

.expense-actions .btn-edit:hover {
    background: #5568d3;
}

.expense-actions .btn-delete {
    padding: 8px 14px;
    background: #dc3545;
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.2s;
}

.expense-actions .btn-delete:hover {
    background: #c82333;
}

/* Кнопка редактирования в таблице сотрудников */
.staff-btn-edit {
    padding: 8px 14px;
    background: #667eea;
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.2s;
}

.staff-btn-edit:hover {
    background: #5568d3;
}

.staff-actions {
    display: flex;
    justify-content: flex-end;
    align-items: center;
}

.staff-btn-add {
    padding: 8px 14px;
    font-size: 13px;
}

/* Бонус/штраф — форма, причина в конце строки */
.bonus-penalty-form-row {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 12px;
}

.bonus-reason-cell {
    flex: 1 1 200px;
    min-width: 200px;
}

/* Бонусы и штрафы — панель фильтров */
.bp-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 16px;
    margin-bottom: 16px;
}
.bp-filter-form {
    flex: 1;
    min-width: 0;
}
.bp-filter-row {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 12px;
}
.bp-filter-item {
    flex: 0 0 auto;
}
.bp-filter-item label {
    display: block;
    font-size: 0.85rem;
    margin-bottom: 6px;
    color: #555;
}
.bp-filter-item select,
.bp-filter-item input {
    padding: 8px 10px;
    border: 2px solid #ddd;
    border-radius: 5px;
    font-size: 14px;
}
.bp-search-cell {
    flex: 1;
    min-width: 160px;
}
.bp-search-cell input {
    width: 100%;
    min-width: 160px;
    box-sizing: border-box;
}
.bp-buttons-cell {
    flex: 0 0 auto;
}
.bp-buttons {
    display: flex;
    gap: 8px;
}
.bp-actions-row {
    display: flex;
    align-items: center;
    gap: 12px;
}
.bp-bulk-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
    padding: 10px 0;
}

/* Кнопка удаления в таблице бонусов/штрафов — как в Расходах, Пользователях */
.bp-delete-one {
    padding: 8px 14px;
    background: #dc3545 !important;
    color: white !important;
    border: none !important;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
}
.bp-delete-one:hover {
    background: #c82333 !important;
}

.modal-ok-btn {
    width: 100%;
    padding: 12px;
    background: #667eea;
    color: white;
    border: none;
    border-radius: 5px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.3s;
}

.modal-ok-btn:hover {
    background: #5568d3;
}

/* Модальное окно подтверждения (две кнопки: Отмена / OK) */
.modal-actions {
    display: flex;
    gap: 0.75rem;
    margin-top: 20px;
}

.modal-actions .modal-ok-btn {
    flex: 1;
}

.modal-actions .modal-cancel-btn {
    flex: 1;
    padding: 12px;
    background: #e5e7eb;
    color: #1a1a1a;
    border: none;
    border-radius: 5px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.3s;
}

.modal-actions .modal-cancel-btn:hover {
    background: #d1d5db;
}

@media (max-width: 480px) {
    .modal-content {
        padding: 20px 24px;
        max-width: none;
        margin: 0 8px;
    }
    .modal-message {
        font-size: 15px;
        margin-bottom: 18px;
    }
    .modal-confirm-buttons {
        flex-direction: column;
    }
}

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

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

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

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: #667eea;
}

/* Финансовый учёт — выбор периода */
.finance-period-form {
    margin: 0;
}
.finance-period-fields {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 12px 16px;
}
.finance-period-fields .form-group {
    margin: 0;
    flex: 0 0 auto;
}
.finance-period-fields .form-group label {
    display: block;
    margin-bottom: 6px;
    font-size: 0.9rem;
    font-weight: 500;
    color: #555;
}
.finance-period-fields .form-group input[type="date"] {
    min-width: 172px;
    width: 172px;
    padding: 10px 12px;
    padding-right: 44px; /* место для иконки календаря */
    border: 2px solid #ddd;
    border-radius: 5px;
    font-size: 16px;
    box-sizing: border-box;
}
.finance-period-fields .form-group input[type="date"]:focus {
    outline: none;
    border-color: #667eea;
}
.finance-period-submit {
    flex: 0 0 auto;
}
.finance-period-info {
    margin: 12px 0 0 0;
    color: #64748b;
    font-size: 0.9rem;
}
.finance-summary-card {
    transition: border-color 0.2s, background-color 0.2s;
}
.finance-summary-card:hover {
    border-color: #667eea !important;
    background-color: #f8fafc;
}
.finance-summary-card-active {
    border-color: #667eea !important;
    background-color: #eef2ff;
}

/* Цвета статуса оплаты */
.payment-status.payment-full { color: #16a34a; font-weight: 600; }
.payment-status.payment-partial { color: #ca8a04; font-weight: 600; }
.payment-status.payment-free { color: #6366f1; font-weight: 600; }
.payment-status.payment-discount { color: #d97706; font-weight: 600; }

/* Цвета статуса заказа в пути */
.order-status-transit.status-loaded { color: #2563eb; font-weight: 600; }
.order-status-transit.status-sent { color: #6366f1; font-weight: 600; }
.order-status-transit.status-arrived { color: #059669; font-weight: 600; }
.order-status-transit.status-on_delivery { color: #d97706; font-weight: 600; }

/* Индикаторная лампа статуса заказа (поиск и др.) */
.order-status-light { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; }
.order-status-light .status-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.order-status-light.status-new .status-dot { background: #3b82f6; }
.order-status-light.status-loaded .status-dot { background: #2563eb; }
.order-status-light.status-sent .status-dot { background: #6366f1; }
.order-status-light.status-arrived .status-dot { background: #059669; }
.order-status-light.status-on_delivery .status-dot { background: #d97706; }
.order-status-light.status-delivered .status-dot { background: #16a34a; }
@media (max-width: 480px) {
    .finance-period-fields .form-group input[type="date"] {
        min-width: 152px;
        width: 152px;
        padding-right: 40px;
    }
}

/* Расходы — форма добавления */
.expense-add-form {
    max-width: 720px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 16px;
}
.expense-add-row {
    display: grid;
    grid-template-columns: 1fr 120px 160px;
    gap: 16px;
    align-items: end;
}
.expense-add-category {
    min-width: 0;
    position: relative;
}
.expense-add-category input {
    width: 100%;
    padding: 12px 14px;
    font-size: 16px;
    box-sizing: border-box;
}
.expense-add-amount input {
    width: 100%;
    padding: 12px;
    font-size: 16px;
}
.expense-add-date input {
    width: 100%;
    padding: 12px;
    font-size: 16px;
}
.expense-add-comment textarea {
    width: 100%;
    min-height: 80px;
    padding: 12px 14px;
    font-size: 16px;
    border: 2px solid #ddd;
    border-radius: 5px;
    resize: vertical;
    font-family: inherit;
    box-sizing: border-box;
}
.expense-add-comment textarea:focus {
    outline: none;
    border-color: #667eea;
}
.expense-edit-form {
    max-width: 560px;
}
.expense-edit-form .expense-add-category input {
    width: 100%;
    padding: 12px 14px;
    font-size: 16px;
    box-sizing: border-box;
}
@media (max-width: 600px) {
    .expense-add-row {
        grid-template-columns: 1fr 1fr;
    }
    .expense-add-category {
        grid-column: 1 / -1;
    }
}
/* Кнопки формы в модальном окне — по центру */
.expense-modal-buttons {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: center;
}

/* Расходы — панель фильтров */
.expenses-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 16px;
    margin-bottom: 16px;
}
.expenses-filter-form {
    flex: 1;
    min-width: 0;
}
.expenses-filter-row {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 12px;
}
.expenses-filter-item {
    flex: 0 0 auto;
}
.expenses-filter-item label {
    display: block;
    font-size: 0.85rem;
    margin-bottom: 6px;
    color: #555;
}
.expenses-filter-item select,
.expenses-filter-item input {
    padding: 8px 10px;
    border: 2px solid #ddd;
    border-radius: 5px;
    font-size: 14px;
}
.expenses-filter-item select:focus,
.expenses-filter-item input:focus {
    outline: none;
    border-color: #667eea;
}
.expenses-filter-item input[type="date"] {
    min-width: 130px;
}
.expenses-search-cell {
    flex: 1;
    min-width: 160px;
}
.expenses-search-cell input {
    width: 100%;
    min-width: 160px;
    box-sizing: border-box;
}
.expenses-buttons-cell {
    flex: 0 0 auto;
}
.expenses-buttons {
    display: flex;
    gap: 8px;
}
.expenses-summary {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}
.expenses-total {
    font-weight: 600;
    font-size: 1.1rem;
}
@media (max-width: 768px) {
    .expenses-filter-row {
        width: 100%;
    }
    .expenses-search-cell {
        flex: 1 1 100%;
    }
    .expenses-summary {
        width: 100%;
    }
}

/* Создание заказа — секции и сетка */
.create-order-form {
    max-width: 720px;
    margin-left: auto;
    margin-right: auto;
}
.create-order-form .form-section {
    margin-bottom: 1.75rem;
    padding-bottom: 1.75rem;
    border-bottom: 1px solid #eee;
}
.create-order-form .form-section:last-of-type {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}
.form-section-title {
    font-size: 0.95rem;
    font-weight: 600;
    color: #667eea;
    margin: 0 0 1rem;
    letter-spacing: 0.02em;
}
.form-row {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0 1.5rem;
}
@media (min-width: 560px) {
    .form-row {
        grid-template-columns: repeat(2, 1fr);
    }
}
.form-actions {
    margin-top: 1.5rem;
    padding-top: 1rem;
    border-top: 1px solid #eee;
}
.create-order-form .btn-submit {
    width: 100%;
    padding: 12px 20px;
    font-size: 1rem;
    font-weight: 600;
}
.form-hint {
    display: block;
    font-size: 0.8rem;
    color: #888;
    margin-top: 6px;
}
.create-order-form .file-input {
    padding: 8px;
    font-size: 0.9rem;
}

.payment-notice-required {
    color: #dc2626;
}
.payment-notice-optional {
    font-size: 0.85em;
    color: #888;
    font-weight: normal;
}
.debt-display {
    margin-top: 12px;
    padding: 10px 14px;
    border-radius: 8px;
    font-size: 0.95rem;
}
.debt-display.debt-amount {
    background: #fef2f2;
    color: #991b1b;
    border-left: 4px solid #dc2626;
}
.debt-display.debt-zero {
    background: #f0fdf4;
    color: #166534;
    border-left: 4px solid #22c55e;
}
.debt-display.debt-overpaid {
    background: #eff6ff;
    color: #1e40af;
    border-left: 4px solid #3b82f6;
}

/* Превью фото груза */
.photo-previews {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 12px;
}
.photo-preview-card {
    position: relative;
    width: 80px;
    height: 80px;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 1px 4px rgba(0,0,0,0.15);
    background: #f0f0f0;
}
.photo-preview-card img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
.photo-preview-remove {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 24px;
    height: 24px;
    padding: 0;
    border: none;
    border-radius: 50%;
    background: rgba(0,0,0,0.6);
    color: #fff;
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}
.photo-preview-remove:hover {
    background: rgba(220, 38, 38, 0.9);
}

/* Загрузить в машину — раскрывающиеся строки (как в Cargo) */
.load-orders-list {
    display: flex;
    flex-direction: column;
    gap: 0;
}
.load-order-item {
    border: 1px solid #e0e0e0;
    border-radius: 5px;
    margin-bottom: 10px;
    overflow: hidden;
    transition: box-shadow 0.3s;
    background: #f8f9fa;
}
.load-order-item:hover {
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}
.load-order-header {
    display: grid;
    grid-template-columns: auto 1fr auto;
    gap: 15px;
    padding: 15px;
    align-items: center;
    cursor: pointer;
}
.load-order-check-wrap {
    margin: 0;
    display: flex;
    align-items: center;
    cursor: pointer;
}
.load-order-check-wrap input[type="checkbox"] {
    width: 20px;
    height: 20px;
    cursor: pointer;
}
.load-order-summary {
    display: flex;
    gap: 20px;
    font-size: 14px;
    flex-wrap: wrap;
    align-items: center;
}
.load-order-summary span {
    white-space: nowrap;
}
.load-order-actions {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-shrink: 0;
}
.btn-load-row {
    padding: 8px 16px;
    font-size: 14px;
}
.btn-expand-row {
    background: #6c757d;
    color: white;
    min-width: 40px;
    padding: 8px 15px;
    border: none;
    border-radius: 5px;
    font-size: 14px;
    cursor: pointer;
    white-space: nowrap;
    flex-shrink: 0;
    transition: background 0.3s;
}
.btn-expand-row:hover {
    background: #5a6268;
}
.load-order-item.expanded .btn-expand-row,
.order-row-expandable.expanded .btn-expand-row {
    background: #495057;
}
.load-order-item.expanded .btn-expand-row:hover,
.order-row-expandable.expanded .btn-expand-row:hover {
    background: #3d4146;
}
.load-order-details {
    display: none;
    padding: 15px;
    border-top: 1px solid #ddd;
    background: white;
}
.load-order-details.active {
    display: block;
}
.load-order-details-content {
    margin-bottom: 16px;
    font-size: 0.9rem;
}
.load-order-details-content p {
    margin: 6px 0;
}
.load-order-inputs {
    margin-bottom: 0;
    padding: 12px;
    background: #e7f3ff;
    border: 1px solid #b3d9ff;
    border-radius: 5px;
}
.load-order-inputs .form-group {
    margin-bottom: 12px;
}
.load-order-inputs .form-group:last-child {
    margin-bottom: 0;
}
.load-order-highlight {
    background: #fef9c3 !important;
    border-color: #facc15 !important;
}
.load-order-highlight:focus {
    background: #fef08a !important;
    border-color: #eab308 !important;
}
.load-form-actions {
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid #eee;
}
.card-await-send {
    background: #fffbeb;
    border: 1px solid #fde68a;
    box-shadow: 0 2px 10px rgba(251, 191, 36, 0.15);
}
.card-await-send h2 {
    color: #b45309;
    border-bottom-color: #facc15;
}
.await-send-block {
    margin-bottom: 15px;
    padding: 15px;
    background: rgba(254, 249, 195, 0.6);
    border-radius: 8px;
    border: 1px solid #fde68a;
}
.await-send-block p {
    margin: 0 0 8px;
    word-break: break-word;
}
.await-send-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.await-send-collapsible .await-send-header {
    cursor: pointer;
}
.await-send-collapsible .await-send-header strong {
    flex: 1;
}
.await-send-body {
    margin-top: 0.5rem;
}
.await-send-collapsible.order-card-collapsed .await-send-body.order-card-body {
    display: none;
}
.await-send-collapsible.order-card-expanded .await-send-body.order-card-body {
    display: block;
}
.await-send-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 12px;
}
.await-send-form {
    display: inline-block;
}
@media (max-width: 480px) {
    .await-send-block {
        padding: 12px;
    }
    .await-send-form {
        display: block;
    }
    .await-send-form .btn {
        width: 100%;
    }
}

/* Отправленные посылки — вложенные заказы (двойное раскрытие) */
.sent-orders-list {
    margin-top: 12px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.sent-order-item {
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    overflow: hidden;
    background: #f8fafc;
}
.sent-order-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    cursor: pointer;
    font-size: 14px;
}
.sent-order-header:hover {
    background: #f1f5f9;
}
.sent-order-header strong {
    color: #1e293b;
    font-weight: 700;
}
.sent-order-expand {
    flex-shrink: 0;
    font-size: 12px;
    color: #64748b;
}
.sent-order-item.expanded .sent-order-expand {
    color: #667eea;
}
.sent-order-details {
    display: none;
    padding: 12px 12px 12px 28px;
    border-top: 1px solid #e2e8f0;
    background: white;
    font-size: 0.9rem;
}
.sent-order-details.active {
    display: block;
}
.sent-order-details p {
    margin: 4px 0;
}

.load-orders-select-all {
    margin-bottom: 12px;
}
.load-orders-select-all label {
    cursor: pointer;
    font-size: 14px;
}
.bulk-actions {
    margin-bottom: 15px;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 5px;
    display: none;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
}
.bulk-actions.show {
    display: flex;
}
.btn-bulk-load {
    padding: 10px 20px;
}
.btn-bulk-delete {
    background: #dc3545;
    color: white;
    padding: 10px 20px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-weight: 600;
}
.btn-bulk-delete:hover {
    background: #c82333;
}
.btn-delete-row {
    background: #dc3545;
    color: white;
    width: 36px;
    height: 36px;
    padding: 0;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.3s;
}
.btn-delete-row:hover {
    background: #c82333;
}
.btn-delete-row svg {
    flex-shrink: 0;
}
.modal-confirm .modal-confirm-buttons {
    display: flex;
    gap: 12px;
    margin-top: 20px;
}
.modal-btn-cancel {
    flex: 1;
    padding: 12px;
    background: #e5e7eb;
    color: #374151;
    border: none;
    border-radius: 5px;
    font-size: 16px;
    cursor: pointer;
}
.modal-btn-cancel:hover {
    background: #d1d5db;
}
.modal-btn-ok {
    flex: 1;
    padding: 12px;
    background: #667eea;
    color: white;
    border: none;
    border-radius: 5px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
}
.modal-btn-ok:hover {
    background: #5568d3;
}
@media (max-width: 768px) {
    .load-order-header {
        grid-template-columns: auto 1fr;
        gap: 10px;
    }
    .load-order-actions {
        grid-column: 1 / -1;
    }
    .load-order-summary {
        flex-direction: column;
        align-items: flex-start;
    }
}

/* Загрузка в машину — мобильная: колонки в столбик, кнопки компактно */
@media (max-width: 576px) {
    .load-order-header {
        grid-template-columns: 1fr;
        grid-template-rows: auto auto auto;
    }
    .load-order-check-wrap {
        order: 1;
    }
    .load-order-summary {
        order: 2;
    }
    .load-order-actions {
        order: 3;
        flex-wrap: wrap;
        gap: 8px;
    }
    .load-order-summary span {
        white-space: normal;
        word-break: break-word;
        overflow-wrap: break-word;
    }
    .bulk-actions {
        flex-direction: column;
        align-items: stretch;
    }
    .bulk-actions .btn {
        width: 100%;
    }
    .load-order-inputs .form-group input {
        font-size: 16px;
    }
}

/* Обёртка и кнопка показа пароля в формах (управление пользователями и др.) */
.page-container .password-wrapper {
    position: relative;
    display: block;
}

.page-container .password-wrapper input {
    padding-right: 44px;
    box-sizing: border-box;
}

.page-container .password-toggle {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    margin: 0;
    padding: 4px;
    width: 32px;
    height: 32px;
    min-width: 32px;
    min-height: 32px;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 18px;
    color: #666;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
}

.page-container .password-toggle:hover {
    color: #667eea;
    background: rgba(102, 126, 234, 0.08);
}

/* Обёртка для горизонтального скролла таблиц на мобильных */
.table-wrapper {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin: 0.5rem 0;
}

.card[style*="overflow-x"] {
    -webkit-overflow-scrolling: touch;
}

/* Столы и QR: форма добавления стола */
.table-add-form {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-top: 1rem;
}

/* Общий вид полей ввода (как на вкладке QR) */
.input-cafe {
    padding: 0.5rem 0.75rem;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    font-size: 0.95rem;
    transition: border-color 0.2s;
    box-sizing: border-box;
}

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

.input-cafe::placeholder {
    color: #94a3b8;
}

/* Ревизия: форма списания — поля в одну строку, фиксированная ширина */
.revision-writeoff-form {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    width: 100%;
    min-width: 0;
}

.revision-writeoff-form .input-cafe[name="quantity"] {
    width: 7em;
    min-width: 7em;
    flex-shrink: 0;
}

.revision-writeoff-form .input-cafe[name="reason"] {
    flex: 1;
    min-width: 0;
}

.revision-writeoff-form .btn {
    flex-shrink: 0;
}

.table-add-form .table-name-input {
    padding: 0.5rem 0.75rem;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    font-size: 1rem;
    min-width: 200px;
    max-width: 320px;
    transition: border-color 0.2s;
}

.table-add-form .table-name-input:focus {
    outline: none;
    border-color: #667eea;
}

.table-add-form .table-name-input::placeholder {
    color: #94a3b8;
}

/* Столы и QR: редактирование в строке таблицы */
.table-qr-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    width: 100%;
    min-width: 0;
}

.table-qr-actions form.table-update-form {
    display: flex;
    flex: 1;
    align-items: center;
    gap: 0.5rem;
    min-width: 0;
}

.table-qr-actions .table-name-input {
    flex: 1;
    min-width: 0;
    max-width: none;
    padding: 0.5rem 0.75rem;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    font-size: 0.95rem;
    transition: border-color 0.2s;
}

.table-qr-actions .table-name-input:focus {
    outline: none;
    border-color: #667eea;
}

.table-qr-actions .table-name-input::placeholder {
    color: #94a3b8;
}

.table-qr-actions .btn-group {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-shrink: 0;
}

.table-qr-actions .btn-group form.table-delete-form {
    display: inline-flex;
    align-items: center;
}

/* «Сохранить» и «Печать QR» — одинаковая ширина и высота */
.table-qr-actions .btn-group .btn-secondary,
.table-qr-actions .btn-group a.btn-secondary {
    width: 8rem;
    min-width: 8rem;
    height: 36px;
    padding: 0 0.75rem;
    text-align: center;
    box-sizing: border-box;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.table-qr-actions .btn-group a.btn {
    text-decoration: none;
}

.table-qr-actions .btn {
    flex-shrink: 0;
}

.table-delete-form {
    display: inline-flex;
    align-items: center;
}

.btn-icon-delete {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    padding: 0;
    border: none;
    border-radius: 8px;
    background: #fee2e2;
    color: #dc2626;
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
}

.btn-icon-delete:hover {
    background: #dc2626;
    color: white;
}

.btn-icon-delete svg {
    display: block;
}

/* Техническая карта (админ): аккуратные формы */
.tc-unit-form {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    flex-wrap: wrap;
}

.tc-unit-form input[type="text"] {
    width: 400px;
    max-width: 100%;
    padding: 10px 12px;
    border: 2px solid #ddd;
    border-radius: 6px;
    font-size: 16px;
}

.tc-units-list {
    margin-top: 0.5rem;
    color: #64748b;
    font-size: 0.95rem;
}

.table-inline-form {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
    width: 100%;
}

.table-inline-form input[type="text"],
.table-inline-form select {
    padding: 8px 10px;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    font-size: 14px;
    max-width: 260px;
}

.table-inline-form button {
    white-space: nowrap;
}

/* В таблицах: название тянется, селект + кнопка справа */
.table-inline-form input[type="text"] {
    flex: 1 1 320px;
    max-width: none;
}

.table-inline-form select {
    flex: 0 0 auto;
    margin-left: auto;
}

table {
    width: 100%;
    min-width: 320px;
    border-collapse: collapse;
    background: white;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
}
@media (max-width: 480px) {
    table {
        min-width: 400px;
    }
    .table-wrapper table {
        min-width: 360px;
        font-size: 13px;
    }
    .table-wrapper th,
    .table-wrapper td {
        padding: 8px 6px;
    }
}

th,
td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid #eee;
}

th {
    background: #f8f9fa;
    font-weight: 600;
    color: #667eea;
}

tr:hover {
    background: #f8f9fa;
}

/* Цены на блюда: широкая колонка «Блюдо», действия в конце строки */
.dish-prices-table .dish-prices-col-name {
    min-width: 280px;
    width: 45%;
}
.dish-prices-table .dish-prices-col-actions {
    text-align: right;
    white-space: nowrap;
}
.dish-prices-table .dish-prices-form {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    justify-content: flex-end;
    margin-left: auto;
}
.dish-prices-table .dish-prices-form .input-cafe {
    width: 100px;
    box-sizing: border-box;
}

/* Навигация по разделам */
.nav-tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 30px;
    border-bottom: 2px solid #ddd;
    flex-wrap: wrap;
}

.nav-tabs a {
    padding: 10px 20px;
    background: none;
    border: none;
    border-bottom: 3px solid transparent;
    cursor: pointer;
    font-size: 16px;
    color: #666;
    text-decoration: none;
    transition: all 0.3s;
}

.nav-tabs a:hover {
    color: #667eea;
    background: rgba(102, 126, 234, 0.05);
}

.nav-tabs a.active {
    color: #667eea;
    border-bottom-color: #667eea;
    font-weight: 600;
}

/* Dashboard cards */
.dashboard {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 250px), 1fr));
    gap: 16px;
    margin-top: 20px;
}
@media (max-width: 480px) {
    .dashboard {
        grid-template-columns: 1fr;
        gap: 12px;
    }
}

.dashboard-card {
    background: white;
    border-radius: 10px;
    padding: 30px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    text-align: center;
    cursor: pointer;
    transition: transform 0.3s, box-shadow 0.3s;
    text-decoration: none;
    color: inherit;
    display: block;
}

.dashboard-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 5px 20px rgba(0,0,0,0.15);
    text-decoration: none;
}

.dashboard-card h2 {
    color: #667eea;
    margin-bottom: 10px;
    font-size: 24px;
    line-height: 1.25;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.dashboard-card .icon {
    font-size: 48px;
    margin-bottom: 15px;
}
.dashboard-card-count.pending {
    color: #dc2626;
    font-weight: 700;
}

/* Stats cards */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.stat-card {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 25px;
    border-radius: 10px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
}

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

.stat-card.negative {
    background: linear-gradient(135deg, #dc3545 0%, #fd7e14 100%);
}

.stat-card.warning {
    background: linear-gradient(135deg, #ffc107 0%, #fd7e14 100%);
}

.stat-card h3 {
    margin: 0 0 15px 0;
    font-size: 16px;
    opacity: 0.9;
    font-weight: 500;
}

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

.stat-card .sub-value {
    font-size: 14px;
    opacity: 0.8;
}

.stats-period-nav a {
    color: #2563eb;
    text-decoration: none;
}

.stats-period-nav a:hover {
    text-decoration: underline;
}

.stats-period-nav a.active {
    font-weight: 600;
    color: #667eea;
}

/* Page container */
.page-container {
    background: white;
    border-radius: 10px;
    padding: 30px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    overflow-wrap: break-word;
    word-wrap: break-word;
}

.page-container .card p {
    word-break: break-word;
    overflow-wrap: break-word;
}

/* Tabs */
.tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 30px;
    border-bottom: 2px solid #ddd;
}

.tab {
    padding: 10px 20px;
    background: none;
    border: none;
    border-bottom: 3px solid transparent;
    cursor: pointer;
    font-size: 16px;
    color: #666;
}

.tab.active {
    color: #667eea;
    border-bottom-color: #667eea;
}

.tab-content {
    display: none;
}

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

/* Блюда и рецептура — карточки меню с фото (адаптивная сетка) */
.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    border: 0;
}

.menu-dishes-section {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.5rem;
}
@media (min-width: 560px) {
    .menu-dishes-section {
        grid-template-columns: repeat(2, 1fr);
    }
}
@media (min-width: 900px) {
    .menu-dishes-section {
        grid-template-columns: repeat(3, 1fr);
    }
}

.dish-card {
    display: flex;
    flex-direction: column;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.06);
    transition: box-shadow 0.2s, border-color 0.2s;
}

.dish-card:hover {
    box-shadow: 0 4px 16px rgba(102, 126, 234, 0.12);
    border-color: #c7d2fe;
}

/* Фото блюда — сверху, фиксированные пропорции, адаптивно */
.dish-card-photo-wrap {
    position: relative;
    width: 100%;
    aspect-ratio: 4 / 3;
    background: #f1f5f9;
    overflow: hidden;
}

.dish-card-photo-wrap .dish-card-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.dish-photo-replace {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 0.5rem;
    background: linear-gradient(transparent, rgba(0,0,0,0.6));
    text-align: center;
}

.dish-photo-change-btn {
    display: inline-block;
    padding: 0.35rem 0.75rem;
    font-size: 0.8rem;
    color: #fff;
    background: rgba(255,255,255,0.2);
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.2s;
}
.dish-photo-change-btn:hover {
    background: rgba(255,255,255,0.35);
}

.dish-card-photo-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 140px;
}

.dish-photo-upload {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.dish-photo-add-label {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 1.5rem;
    cursor: pointer;
    color: #64748b;
    font-size: 0.9rem;
    text-align: center;
    border: 2px dashed #cbd5e1;
    border-radius: 8px;
    margin: 0.75rem;
    transition: border-color 0.2s, color 0.2s;
}
.dish-photo-add-label:hover {
    border-color: #667eea;
    color: #667eea;
}

.dish-photo-add-icon {
    font-size: 2rem;
    opacity: 0.8;
}

.dish-card-body {
    padding: 1rem 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    flex: 1;
    min-width: 0;
}

.dish-card-header {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid #e2e8f0;
}

.dish-card-name {
    font-size: 1.1rem;
    font-weight: 600;
    color: #334155;
    line-height: 1.3;
    display: block;
    width: 100%;
}

.dish-card-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem 1rem;
    font-size: 0.8rem;
    color: #64748b;
}

.dish-card-meta .badge {
    display: inline-flex;
    align-items: center;
    padding: 0.2rem 0.5rem;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 600;
}

.dish-card-meta .badge-available {
    background: #d1fae5;
    color: #065f46;
}

.dish-card-meta .badge-unavailable {
    background: #fee2e2;
    color: #991b1b;
}

.dish-card-form {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem 1rem;
    margin-bottom: 1rem;
}

.dish-card-form input[type="text"],
.dish-card-form input[type="number"] {
    padding: 0.4rem 0.6rem;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    font-size: 0.9rem;
}

.dish-card-form label {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.875rem;
    color: #475569;
}

.dish-recipe-list {
    list-style: none;
    padding: 0;
    margin: 0 0 1rem 0;
}

.dish-recipe-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.4rem 0.75rem;
    margin-bottom: 0.25rem;
    background: #f1f5f9;
    border-radius: 6px;
    font-size: 0.9rem;
}

.dish-recipe-item:hover {
    background: #e2e8f0;
}

.dish-recipe-item .remove-btn {
    padding: 0.15rem 0.4rem;
    font-size: 0.8rem;
    min-width: auto;
}

.dish-add-recipe-form {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
    padding-top: 0.75rem;
    border-top: 1px dashed #e2e8f0;
}

.dish-add-recipe-form select {
    padding: 0.4rem 0.6rem;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    font-size: 0.9rem;
    min-width: 120px;
}

.dish-add-recipe-form input[type="number"] {
    width: 80px;
    padding: 0.4rem 0.6rem;
}

.menu-add-form .form-group {
    display: grid;
    gap: 0.75rem;
    max-width: 360px;
}

.menu-hint {
    font-size: 0.9rem;
    color: #64748b;
    margin-bottom: 1rem;
    padding: 0.75rem 1rem;
    background: #f0f9ff;
    border-radius: 8px;
    border-left: 3px solid #667eea;
}

.cooking-order-table-label {
    color: #64748b;
    font-weight: 600;
}

.cooking-order-card {
    background: #fef2f2;
    border-color: #fca5a5;
}

.done-order-card {
    background: #f0fdf4;
    border-color: #86efac;
}

/* Collapsible order cards (waiter & cook) */
.order-card-collapsible {
    cursor: pointer;
}
.order-card-collapsible > strong {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.order-card-body {
    margin-top: 0.35rem;
}
.order-card-toggle-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    margin-left: auto;
    border-radius: 999px;
    border: 1px solid #cbd5f5;
    background: #eef2ff;
    box-shadow: 0 1px 2px rgba(15,23,42,0.08);
    font-size: 0.9rem;
    color: #4f46e5;
    vertical-align: middle;
    flex-shrink: 0;
    transition: transform 0.15s ease, background 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}
.order-card-collapsible:hover .order-card-toggle-icon {
    background: #e0e7ff;
    border-color: #818cf8;
    box-shadow: 0 2px 4px rgba(15,23,42,0.15);
}
.order-card-collapsed .order-card-body {
    display: none;
}
.order-card-expanded .order-card-body {
    display: block;
}
.order-card-expanded table.order-card-body {
    display: table !important;
}
.order-card-collapsed .order-card-toggle-icon {
    transform: rotate(-90deg);
}
.order-card-expanded .order-card-toggle-icon {
    transform: rotate(0deg);
}

.waiter-no-dishes-hint {
    font-size: 0.95rem;
    color: #b45309;
    margin-bottom: 1rem;
    padding: 1rem;
    background: #fffbeb;
    border-radius: 8px;
    border-left: 4px solid #f59e0b;
}

/* Форма «Добавить блюдо»: десктоп — поле блюда на всю ширину строки; мобильная — 2 строки (блюдо сверху, остальное снизу) */
.waiter-add-dish-form {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: stretch;
    min-width: 0;
    width: 100%;
    box-sizing: border-box;
}
.waiter-add-dish-form input[type="hidden"] {
    flex: 0 0 0;
    width: 0;
    min-width: 0;
    margin: 0;
    padding: 0;
    overflow: hidden;
}
.waiter-add-dish-cell {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    box-sizing: border-box;
}
.waiter-add-dish-cell-label {
    font-size: 0.875rem;
    color: #475569;
    white-space: nowrap;
}
.waiter-add-dish-cell .input-cafe,
.waiter-add-dish-cell .waiter-add-dish-btn {
    width: 100%;
    min-width: 0;
    height: 38px;
    box-sizing: border-box;
}
.waiter-add-dish-cell-btn .waiter-add-dish-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
/* Десктоп: форма в одну строку на всю ширину, поле блюда тянется до конца строки */
@media (min-width: 640px) {
    .waiter-add-dish-form {
        flex-wrap: nowrap;
    }
    .waiter-add-dish-cell-dish {
        flex: 1 1 0%;
        min-width: 0;
        max-width: none;
    }
    .waiter-add-dish-cell-dish .input-cafe {
        width: 100%;
        max-width: 100%;
    }
    .waiter-add-dish-form .waiter-add-dish-cell:not(.waiter-add-dish-cell-dish) {
        flex: 0 0 120px;
    }
}
/* Мобильная: строго 2 строки — 1) поле блюда на всю ширину, 2) кол-во, порция, кнопка */
@media (max-width: 639px) {
    .waiter-add-dish-form {
        flex-wrap: wrap;
    }
    .waiter-add-dish-cell-dish {
        flex: 0 0 100%;
        width: 100%;
        max-width: 100%;
    }
    .waiter-add-dish-form .waiter-add-dish-cell:not(.waiter-add-dish-cell-dish) {
        flex: 1 1 0;
        min-width: 80px;
    }
}

/* Блок: форма добавления блюда + строка поиска; на мобильной поиск сверху */
.waiter-add-dish-block {
    display: flex;
    flex-direction: column;
}

/* Строка поиска: на десктопе «Или поиск», на мобильной «Поиск» и строка выше выбора блюда */
.waiter-dish-search-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
    margin-top: 0.75rem;
}
.waiter-search-label-mobile {
    display: none;
}
.waiter-search-label-desktop {
    display: inline;
}
.waiter-dish-search-input {
    flex: 1 1 200px;
    min-width: 0;
}
.waiter-dish-search-info {
    color: #64748b;
}
@media (min-width: 640px) {
    .waiter-dish-search-input {
        flex: 1 1 320px;
        max-width: 420px;
    }
}
@media (max-width: 639px) {
    .waiter-add-dish-block .waiter-dish-search-row {
        order: -1;
        margin-top: 0;
        margin-bottom: 0.75rem;
    }
    .waiter-search-label-mobile {
        display: inline;
    }
    .waiter-search-label-desktop {
        display: none;
    }
    .waiter-dish-search-input {
        flex: 1 1 100%;
        width: 100%;
        max-width: none;
    }
}

.cook-orders-hint {
    font-size: 0.875rem;
    color: #64748b;
    margin-bottom: 1rem;
}

/* Cook orders status highlighting */
.cook-order-card {
    border-width: 2px;
    border-style: solid;
    border-radius: 10px;
}
.cook-order-card--new {
    background: #fef2f2; /* light red */
    border-color: #fecaca;
}
.cook-order-card--in-progress {
    background: #fffbeb; /* light yellow */
    border-color: #facc15;
}
.cook-order-card--done {
    background: #ecfdf3; /* light green */
    border-color: #4ade80;
}

/* User management styles */
.user-item {
    padding: 15px;
    border: 1px solid #ddd;
    border-radius: 8px;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 15px;
    background: white;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    transition: box-shadow 0.2s;
}

.user-item:hover {
    box-shadow: 0 2px 6px rgba(0,0,0,0.1);
}

.user-info {
    flex: 1;
    display: flex;
    gap: 20px;
    align-items: center;
    flex-wrap: wrap;
}

.user-info-item {
    font-size: 14px;
}

.user-info-item strong {
    color: #667eea;
    margin-right: 5px;
    font-weight: 600;
}

.user-actions {
    display: flex;
    gap: 10px;
}

.btn-edit {
    padding: 10px 20px;
    background: #667eea;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 500;
    transition: background 0.2s;
    font-size: 14px;
}

.btn-edit:hover {
    background: #5568d3;
}

.btn-delete {
    padding: 10px 20px;
    background: #dc3545;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 500;
    transition: background 0.2s;
    font-size: 14px;
}

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

/* Report styles */
.report-controls {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
    margin-bottom: 20px;
    padding: 20px;
    background: #f8f9fa;
    border-radius: 5px;
}

.report-controls label {
    display: block;
    margin-bottom: 5px;
    font-weight: 500;
}

.report-controls input,
.report-controls select {
    width: 100%;
    padding: 8px;
    border: 2px solid #ddd;
    border-radius: 5px;
    box-sizing: border-box;
}

.report-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 20px;
}

.report-table th,
.report-table td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid #ddd;
}

.report-table th {
    background: #f8f9fa;
    font-weight: 600;
    color: #667eea;
}

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

/* Отчёты: форма с выбором вида и дат */
.report-controls-v2 {
    margin-bottom: 16px;
}

.report-form-inline {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.report-form-inline label {
    display: flex;
    align-items: center;
    gap: 6px;
    margin: 0;
}

.report-form-inline .report-label {
    font-weight: 500;
    color: #475569;
}

.report-form-inline .input-cafe,
.report-form-inline .report-select {
    height: 38px;
    box-sizing: border-box;
    min-width: 140px;
}

.report-form-inline .report-select {
    min-width: 160px;
}

.report-form-inline .btn {
    height: 38px;
    box-sizing: border-box;
    padding: 0 1rem;
    display: inline-flex;
    align-items: center;
}

/* Одна строка: вид отчёта растянут, даты и кнопка справа */
.report-form-one-row {
    flex-wrap: nowrap;
}
.report-form-one-row .report-type-cell {
    flex: 1;
    min-width: 0;
}
.report-form-one-row .report-type-cell .report-select {
    flex: 1;
    min-width: 120px;
    width: 100%;
}
.report-form-one-row .report-date-cell {
    flex-shrink: 0;
}

.report-form-one-row .report-export-cell {
    flex-shrink: 0;
}

@media (max-width: 640px) {
    .report-form-one-row {
        flex-wrap: wrap;
    }
    .report-form-inline .report-type-cell,
    .report-form-inline .report-date-cell,
    .report-form-inline .report-export-cell {
        width: 100%;
    }
    .report-form-inline .input-cafe,
    .report-form-inline .report-select {
        min-width: 0;
        width: 100%;
    }
    .stats-period-nav {
        flex-wrap: wrap;
        gap: 10px;
    }
}

.report-period-caption {
    margin: -8px 0 20px;
    color: #64748b;
    font-size: 0.95rem;
}

.report-description {
    margin: 0 0 16px;
    padding: 10px 14px;
    background: #f1f5f9;
    border-radius: 8px;
    color: #475569;
    font-size: 0.95rem;
    line-height: 1.45;
}

.cash-info-block {
    margin: 0 0 20px;
    padding: 12px 16px;
    background: #f1f5f9;
    border-radius: 8px;
    color: #475569;
    font-size: 0.95rem;
    line-height: 1.5;
}

.cash-balance-display {
    text-align: center;
    margin: 16px 0;
}

.cash-balance-amount {
    font-size: 2.5rem;
    font-weight: 700;
}

.cash-balance-amount.cash-balance-positive {
    color: #15803d;
}

.cash-balance-amount.cash-balance-negative {
    color: #b91c1c;
}

.cash-balance-meta {
    text-align: center;
    color: #64748b;
    font-size: 0.95rem;
    margin-top: 0;
}

/* Блок «Закрыть кассу» и «Передать деньги» — центрирование каждой строки */
.cash-actions-block {
    text-align: center;
    margin-top: 1rem;
    max-width: 380px;
    margin-left: auto;
    margin-right: auto;
}

.cash-actions-block .cash-close-form {
    margin-bottom: 1.25rem;
}

.cash-actions-block .cash-close-form .btn {
    display: inline-block;
}

.cash-actions-block .cash-actions-title {
    margin: 0 0 1rem;
    text-align: center;
}

.cash-transfer-form {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
    width: 100%;
}

/* Строка = подпись + поле: общий левый край, блок по центру страницы */
.cash-transfer-form .cash-transfer-label {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 0.5rem;
    width: 100%;
    max-width: 320px;
}

.cash-transfer-form .cash-transfer-label-text {
    flex-shrink: 0;
    width: 82px;
    text-align: right;
}

.cash-transfer-form .cash-transfer-input-amount {
    width: 140px;
    box-sizing: border-box;
}

.cash-transfer-form .cash-transfer-input-desc {
    width: 220px;
    box-sizing: border-box;
}

.cash-transfer-form .cash-transfer-submit {
    margin-top: 0.25rem;
}

/* Блок «Касса закрыта» — центрирование */
.cash-open-block {
    text-align: center;
    max-width: 340px;
    margin-left: auto;
    margin-right: auto;
}

.cash-open-block .cash-open-status {
    margin-bottom: 1rem;
}

.cash-open-form {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
}

.cash-open-form .cash-open-label {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    width: 100%;
}

.cash-open-form .cash-open-label-text {
    min-width: 120px;
    text-align: right;
}

.cash-open-form .input-cafe {
    width: 140px;
    box-sizing: border-box;
}

.cash-open-form .cash-open-submit {
    margin-top: 0.25rem;
}

.report-extra-card {
    margin-top: 20px;
    padding: 16px;
    background: #f8fafc;
    border-radius: 8px;
}

.report-orders-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 24px;
}

.report-block {
    padding: 12px;
    background: #f8fafc;
    border-radius: 8px;
}

/* Status badges */
.status-badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
}

.status-accepted { background: #fff3cd; color: #856404; }
.status-sent { background: #d1ecf1; color: #0c5460; }
.status-customs_processed { background: #d4edda; color: #155724; }
.status-arrived_kg { background: #cfe2ff; color: #084298; }
.status-delivered { background: #d1e7dd; color: #0f5132; }

/* Mobile responsive */
@media (max-width: 768px) {
    .header {
        padding: 10px 12px;
        padding-top: max(10px, env(safe-area-inset-top));
    }

    .header-content {
        flex-direction: row;
        flex-wrap: wrap;
        gap: 8px;
        justify-content: space-between;
    }

    .header-left,
    .header-right {
        flex: 0 0 auto;
        justify-content: flex-start;
        flex-wrap: nowrap;
    }

    .header-right {
        justify-content: flex-end;
    }

    .header-button {
        flex: 0 0 auto;
        text-align: center;
        min-width: 0;
        padding: 8px 10px;
        font-size: 13px;
    }

    .header-button-icon {
        font-size: 14px;
    }

    .main-content {
        padding: 0 12px;
        padding-left: max(12px, env(safe-area-inset-left));
        padding-right: max(12px, env(safe-area-inset-right));
    }

    .has-role-footer .main-content {
        padding-bottom: calc(80px + env(safe-area-inset-bottom));
    }

    .page-container {
        padding: 15px;
    }

    .card {
        padding: 18px;
    }

    .nav-tabs {
        display: flex;
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        gap: 6px;
        margin-bottom: 20px;
        padding-bottom: 4px;
        border-bottom: 2px solid #ddd;
    }

    .nav-tabs a {
        flex: 0 0 auto;
        padding: 8px 14px;
        font-size: 14px;
        white-space: nowrap;
    }

    .role-footer {
        bottom: max(16px, env(safe-area-inset-bottom));
    }

    .user-item {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
    }

    .user-info {
        flex-direction: column;
        align-items: flex-start;
    }

    .user-actions {
        flex-wrap: wrap;
    }
}

@media (max-width: 480px) {
    .header {
        padding: 8px 10px;
    }

    .header-button {
        padding: 6px 8px;
        font-size: 12px;
    }

    .header-button-icon {
        font-size: 12px;
    }

    .login-container {
        padding: 1.25rem;
    }

    .card {
        padding: 14px;
    }

    .page-container {
        padding: 12px;
    }

    .main-content {
        margin: 12px auto;
    }

    .stat-card .value {
        font-size: 24px;
    }

    .dashboard-card {
        padding: 20px;
    }

    .dashboard-card .icon {
        font-size: 40px;
    }

    .dashboard-card h2 {
        font-size: 18px;
    }

    th, td {
        padding: 10px 8px;
        font-size: 14px;
    }
}

/* ========== Адаптивность: курьеры РФ и КР ========== */
@media (max-width: 768px) {
    .page-toolbar,
    .available-toolbar {
        flex-direction: column;
        align-items: stretch;
    }
    .available-search-form {
        flex-direction: column;
        flex: 1 1 100%;
        width: 100%;
    }
    .available-search-form #clientPhoneInput,
    .available-search-form input[type="text"][name="search"] {
        width: 100%;
        min-width: 0;
    }
    .available-toolbar-buttons {
        width: 100%;
        display: flex;
        gap: 8px;
    }
    .sent-shipment-item .load-order-summary span,
    .load-order-item .load-order-summary span {
        word-break: break-word;
        overflow-wrap: break-word;
    }
    .sent-order-header span:last-child {
        word-break: break-word;
        overflow-wrap: break-word;
    }
    .load-order-actions {
        flex-wrap: wrap;
        gap: 6px;
    }
    .modal-confirm .modal-comment-block textarea {
        max-width: 100%;
        box-sizing: border-box;
    }
}

@media (max-width: 576px) {
    .page-container {
        padding: 12px;
    }
    .card {
        padding: 14px;
    }
    .card h2 {
        font-size: 1.1rem;
    }
    .page-title {
        font-size: 1.1rem;
    }
    .page-toolbar .btn,
    .page-toolbar a.btn {
        width: 100%;
        justify-content: center;
        min-height: 44px;
        box-sizing: border-box;
    }
    /* Кнопки Искать и Выгрузить в Excel — одинаковая ширина на мобильных */
    .available-toolbar-buttons .btn,
    .available-toolbar-buttons a.btn {
        flex: 1;
        min-width: 0;
        justify-content: center;
        min-height: 44px;
        box-sizing: border-box;
    }
    .load-order-inputs .form-group input {
        width: 100%;
        max-width: none;
        font-size: 16px;
    }
    .load-order-details-content p,
    .sent-order-details p {
        word-break: break-word;
    }
    .form-actions .btn {
        width: 100%;
    }
    .card form .form-group input,
    .card form .form-group select,
    .card form .form-group textarea {
        width: 100%;
        max-width: none;
        box-sizing: border-box;
    }
    .dashboard-card h2 {
        font-size: 0.95rem;
        line-height: 1.3;
    }
    .dashboard-card-count {
        display: inline-block;
    }
}

@media (max-width: 400px) {
    .header-button {
        padding: 6px 6px;
        font-size: 11px;
    }
    .header-button-icon {
        font-size: 12px;
    }
}

/* ========== Адаптивность: администратор, бухгалтер, notebook ========== */
@media (max-width: 1024px) {
    .dashboard {
        grid-template-columns: repeat(2, 1fr);
        gap: 14px;
    }
    .main-content {
        padding: 0 16px;
    }
    .page-container {
        padding: 20px;
    }
    .card {
        padding: 20px;
    }
}

@media (max-width: 768px) {
    .dashboard {
        grid-template-columns: 1fr;
        gap: 12px;
    }
    .finance-period-fields {
        flex-direction: column;
        align-items: stretch;
    }
    .finance-period-fields .form-group {
        flex: 1 1 100%;
    }
    .finance-period-fields .form-group input[type="date"] {
        width: 100%;
        min-width: 0;
        max-width: none;
    }
    .bp-filter-row {
        flex-direction: column;
        align-items: stretch;
    }
    .bp-filter-item input,
    .bp-filter-item select {
        width: 100%;
        min-width: 0;
    }
    .bp-search-cell {
        min-width: 0;
    }
    .stats-cards,
    .finance-summary {
        grid-template-columns: 1fr;
    }
    .stats-card,
    .finance-summary-card {
        min-width: 0;
    }
    .order-details-content {
        grid-template-columns: 1fr !important;
    }
    .order-details-content p {
        word-break: break-word;
        overflow-wrap: break-word;
    }
    .bulk-actions {
        flex-direction: column;
        align-items: stretch;
    }
    .bulk-actions .btn {
        width: 100%;
        justify-content: center;
    }
    .role-filters {
        flex-wrap: wrap;
        gap: 8px;
    }
    .role-filter-btn {
        flex: 1 1 45%;
        min-width: 0;
        text-align: center;
        padding: 10px 8px;
    }
    .btn-expand-row {
        min-width: 36px;
        padding: 6px 10px;
    }
    .table-wrapper table {
        font-size: 13px;
    }
    .table-wrapper th,
    .table-wrapper td {
        padding: 8px 6px;
    }
}

@media (max-width: 576px) {
    .search-page .search-form {
        flex-direction: column;
    }
    .search-page .search-form input {
        width: 100%;
        min-width: 0;
    }
    .search-page .search-form .btn {
        width: 100%;
    }
}

/* Клиент: таблица на малых экранах */
@media (max-width: 640px) {
    .client-order-table {
        font-size: 13px;
    }
}

/* Модальные окна: адаптивность на узких экранах */
@media (max-width: 480px) {
    .modal-content {
        max-width: calc(100vw - 24px);
        margin: 0 12px;
    }
    .modal-form .form-group input,
    .modal-form .form-group select,
    .modal-form .form-group textarea {
        width: 100%;
        max-width: none;
    }
    .modal-form-grid {
        grid-template-columns: 1fr !important;
    }
}
