/* =============================================================================
   DASHBOARD.CSS - Стили страницы дашборда (3 колонки подразделений)
   ============================================================================= */

/* Сетка подразделений */
.departments-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1px;
    background-color: #e2e8f0;
    height: calc(100vh - 50px);
}

.department-column {
    background-color: white;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Заголовки подразделений */
.department-header {
    padding: 8px 12px;
    font-weight: 600;
    font-size: 13px;
    color: white;
    display: flex;
    align-items: center;
    gap: 6px;
    border-bottom: 2px solid rgba(0,0,0,0.1);
}

/* Фильтр по продукту в колонке */
.department-filter-container {
    padding: 8px;
    background-color: #fafbfc;
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.department-filter-input {
    font-size: 12px;
    height: 28px;
    flex: 1;
}

.department-icon {
    font-size: 16px;
}

.dept-cooking {
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
}

.dept-filling {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
}

.dept-packaging {
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
}

/* Контент подразделения */
.department-content {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
    background-color: #fafbfc;
}

/* Scrollbar: использовать class="custom-scrollbar" из base.css */

/* Группа дат */
.date-group {
    margin-bottom: 12px;
}

.date-header {
    position: sticky;
    top: 0;
    z-index: 10;

    font-weight: 600;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.03em;

    padding: 5px 10px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-radius: 4px;
    margin-bottom: 6px;

    box-shadow: 0 1px 3px rgba(0,0,0,0.1);

    /* Flex для размещения даты и статистики */
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
}

/* Статистика в заголовках подразделений */
.dept-stats {
    font-size: 0.75rem;
    font-weight: 400;
    opacity: 0.9;
    margin-left: auto;
    white-space: nowrap;
}

/* Статистика в заголовках дат */
.date-stats {
    font-size: 0.7rem;
    font-weight: 400;
    opacity: 0.85;
    text-transform: none;
    letter-spacing: normal;
}

/* iOS-style toggle для cross-department фильтрации */
.cross-filter-toggle {
    position: relative;
    display: inline-block;
    width: 36px;
    height: 20px;
    margin-left: 8px;
    flex-shrink: 0;
}

.cross-filter-toggle .toggle-input {
    opacity: 0;
    width: 0;
    height: 0;
}

.cross-filter-toggle .toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(255, 255, 255, 0.3);
    transition: 0.3s;
    border-radius: 20px;
}

.cross-filter-toggle .toggle-slider:before {
    position: absolute;
    content: "";
    height: 16px;
    width: 16px;
    left: 2px;
    bottom: 2px;
    background-color: white;
    transition: 0.3s;
    border-radius: 50%;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.cross-filter-toggle .toggle-input:checked + .toggle-slider {
    background-color: rgba(255, 255, 255, 0.6);
}

.cross-filter-toggle .toggle-input:checked + .toggle-slider:before {
    transform: translateX(16px);
    background-color: #28a745;
}

/* Контейнер для заказов */
.orders-container {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-height: 10px;
}

/* =============================================================================
   Карточка заказа - КОМПАКТНАЯ
   ============================================================================= */

.order-card {
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 4px;
    padding: 6px 8px;
    cursor: default;
    transition: all 0.15s ease;
    position: relative;
    animation: fadeIn 0.2s ease-out;
}

/* Компактный хедер карточки */
.card-header-compact {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
    margin-bottom: 4px;
}

.card-header-left {
    display: flex;
    align-items: center;
    gap: 4px;
    min-width: 0;
}

.card-header-right {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

/* Номер недели (компактный) */
.order-week {
    font-size: 10px;
    font-weight: 700;
    color: #1e40af;
    font-family: 'SF Mono', 'Monaco', 'Courier New', monospace;
}

.header-dot {
    color: #94a3b8;
    font-size: 10px;
}

/* Номер заказа */
.order-num {
    font-weight: 600;
    color: #667eea;
    font-size: 10px;
    font-family: 'SF Mono', 'Monaco', 'Courier New', monospace;
    white-space: nowrap;
}

/* Кнопки действий — скрыты по умолчанию */
.card-actions {
    display: flex;
    gap: 2px;
    opacity: 0;
    transition: opacity 0.15s;
}

.order-card:hover .card-actions {
    opacity: 1;
}

.action-btn {
    width: 18px;
    height: 18px;
    padding: 0;
    background: transparent;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #94a3b8;
    border-radius: 3px;
    transition: all 0.15s;
}

.action-btn:hover {
    background: rgba(102, 126, 234, 0.1);
    color: #667eea;
}

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

/* Статус в хедере */
.card-header-right .order-status {
    margin: 0;
    flex-shrink: 0;
}

/* =============================================================================
   Мета-строка (количество • партия • характеристика)
   ============================================================================= */

.order-meta-line {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 10px;
    color: #64748b;
    margin-bottom: 3px;
    flex-wrap: wrap;
}

.meta-qty {
    font-weight: 600;
    color: #0c4a6e;
}

.meta-qty-others {
    color: #10b981;
    font-weight: 500;
    font-size: 10px;
    margin-left: 2px;
}

.meta-batch {
    color: #64748b;
}

.meta-char {
    font-weight: 500;
    color: #667eea;
    text-transform: uppercase;
    font-size: 9px;
}

.meta-sep {
    color: #cbd5e1;
    font-size: 8px;
}

/* =============================================================================
   Компактные даты связей (со стрелками)
   ============================================================================= */

.related-dates-compact {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-wrap: wrap;
    margin-top: 3px;
    font-size: 9px;
}

.related-dates-compact .related-date-badge {
    padding: 1px 4px;
    border-radius: 2px;
    font-size: 9px;
    font-weight: 500;
}

.date-arrow {
    color: #94a3b8;
    font-size: 10px;
}

/* =============================================================================
   Бейджи характеристик (компактные, в мета-строке)
   ============================================================================= */

.char-badge {
    display: inline-block;
    padding: 1px 5px;
    border-radius: 3px;
    font-size: 9px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    color: white;
    background: #667eea;
}

.char-badge[data-char="wb"] {
    background: #8b5cf6;
}

.char-badge[data-char="ozon"] {
    background: #3b82f6;
}

.char-badge[data-char="ozon fresh"] {
    background: #06b6d4;
}

.char-badge[data-char="опт"] {
    background: #10b981;
}

.char-badge[data-char="мп"] {
    background: #64748b;
}

/* Fallback — старые стили для совместимости */
.card-header {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 6px;
}

.week-number-compact {
    display: inline-block;
    font-size: 10px;
    font-weight: 700;
    color: #1e40af;
}

.order-number-compact {
    font-weight: 600;
    color: #667eea;
    font-size: 10px;
    font-family: 'SF Mono', 'Monaco', 'Courier New', monospace;
}

.order-card:hover {
    border-color: #cbd5e1;
    box-shadow: 0 2px 4px rgba(0,0,0,0.06);
}

.order-card::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    background: #94a3b8;
    border-radius: 4px 0 0 4px;
    opacity: 0;
    transition: opacity 0.15s;
}

.order-card:hover::before {
    opacity: 1;
}

/* Состояния карточки */
.order-card.selected {
    border-color: #667eea;
    background: linear-gradient(to right, #f0f3ff 0%, white 100%);
    box-shadow: 0 0 0 2px rgba(102, 126, 234, 0.2);
}

.order-card.selected::before {
    background: #667eea;
    opacity: 1;
    width: 4px;
}

.order-card.highlighted {
    border-color: #f59e0b;
    background: linear-gradient(to right, #fffbeb 0%, white 100%);
    box-shadow: 0 0 0 2px rgba(245, 158, 11, 0.15);
}

.order-card.highlighted::before {
    background: #f59e0b;
    opacity: 1;
    width: 4px;
}

.order-card.filtered-active {
    border-color: #667eea;
    background: linear-gradient(to right, #f0f3ff 0%, white 100%);
    box-shadow: 0 0 0 2px rgba(102, 126, 234, 0.2);
}

.order-card.filtered-active::before {
    background: #667eea;
    opacity: 1;
    width: 4px;
}

/* Кнопка фильтрации (базовые стили) */
.filter-related-btn {
    width: 22px;
    height: 22px;
    padding: 0;
    background: rgba(102, 126, 234, 0.1);
    border: 1px solid rgba(102, 126, 234, 0.2);
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #667eea;
    transition: all 0.2s;
    z-index: 10;
}

.filter-related-btn:hover {
    background: rgba(102, 126, 234, 0.25);
    border-color: #667eea;
    box-shadow: 0 0 0 2px rgba(102, 126, 234, 0.15);
}

.filter-related-btn:active {
    transform: scale(0.95);
}

.filter-related-btn.active {
    background: #667eea;
    border-color: #667eea;
    color: white;
    box-shadow: 0 0 0 2px rgba(102, 126, 234, 0.3);
}

.filter-related-btn.active:hover {
    background: #764ba2;
    border-color: #764ba2;
}

.filter-related-btn svg {
    pointer-events: none;
}

/* Индикатор неполной цепочки — компактный */
.incomplete-chain-indicator {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 14px;
    height: 14px;
    background: #f59e0b;
    border-radius: 50%;
    color: white;
    font-size: 9px;
    font-weight: 700;
    cursor: help;
    flex-shrink: 0;
    margin-left: 2px;
}

.incomplete-chain-indicator:hover {
    transform: scale(1.15);
}

.incomplete-chain-indicator svg {
    width: 8px;
    height: 8px;
    stroke-width: 2.5;
}

/* Индикатор временных интервалов — компактный */
.interval-indicator {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    cursor: help;
    margin-left: 2px;
    flex-shrink: 0;
    transition: transform 0.15s;
}

.interval-indicator:hover {
    transform: scale(1.1);
}

.interval-indicator svg {
    width: 10px;
    height: 10px;
    stroke: white;
    flex-shrink: 0;
}

/* Желтый вариант */
.interval-indicator-yellow {
    background-color: #fbbf24;
}

/* Красный вариант */
.interval-indicator-red {
    background-color: #ef4444;
}

/* Индикатор доступности материалов */
.availability-indicator {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    cursor: pointer;
    margin-left: 4px;
    transition: transform 0.15s ease;
}

.availability-indicator:hover {
    transform: scale(1.15);
}

.availability-shortage {
    background-color: #f59e0b;
    color: white;
}

.availability-shortage svg {
    width: 10px;
    height: 10px;
    stroke: white;
}

/* Содержимое карточки */
.order-number {
    font-weight: 600;
    color: #667eea;
    font-size: 11px;
    margin-bottom: 3px;
    font-family: 'SF Mono', 'Monaco', 'Courier New', monospace;
}

.product-name {
    font-size: 11px;
    color: #1e293b;
    margin-bottom: 2px;
    line-height: 1.25;
    font-weight: 500;
    /* Ограничение в 2 строки */
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.quantity-info {
    font-size: 11px;
    color: #64748b;
    display: flex;
    align-items: center;
    gap: 4px;
    margin-bottom: 3px;
}

.quantity-value {
    display: inline-block;
    background: linear-gradient(135deg, #e0f2fe 0%, #bae6fd 100%);
    padding: 1px 6px;
    border-radius: 3px;
    font-weight: 600;
    font-size: 11px;
    color: #0c4a6e;
    font-family: 'SF Mono', 'Monaco', 'Courier New', monospace;
}

.batch-info {
    font-size: 11px;
    color: #64748b;
    display: flex;
    align-items: center;
    gap: 4px;
    margin-bottom: 3px;
}

.batch-number {
    display: inline-block;
    background: linear-gradient(135deg, #f1f5f9 0%, #e2e8f0 100%);
    padding: 1px 6px;
    border-radius: 3px;
    font-weight: 600;
    font-size: 11px;
    color: #475569;
    font-family: 'SF Mono', 'Monaco', 'Courier New', monospace;
}

/* Комментарий */
.comment-info {
    margin-top: 4px;
    margin-bottom: 4px;
    font-size: 10px;
    color: #64748b;
    display: flex;
    align-items: flex-start;
    gap: 4px;
    padding: 3px 6px;
    background: #f8fafc;
    border-radius: 3px;
    border-left: 2px solid #cbd5e1;
}

.comment-info svg {
    flex-shrink: 0;
    margin-top: 1px;
    color: #94a3b8;
}

.comment-text {
    flex: 1;
    line-height: 1.4;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    word-break: break-word;
}

.comment-info:hover {
    background: #f1f5f9;
    border-left-color: #94a3b8;
}

.comment-info:hover svg {
    color: #667eea;
}

.order-status {
    display: inline-block;
    font-size: 10px;
    padding: 2px 6px;
    border-radius: 3px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

/* Статусы заказов - новая палитра */
.status-completed {
    background: #166534;
    color: white;
}

.status-ready {
    background: #86efac;
    color: #166534;
}

.status-plan {
    background: #a3e635;
    color: #365314;
}

.status-inprogress {
    background: #fbbf24;
    color: #78350f;
}

.status-waiting {
    background: #a78bfa;
    color: #5b21b6;
}

.status-quarantine {
    background: #fb923c;
    color: #9a3412;
}

.status-nomaterials {
    background: #f87171;
    color: #991b1b;
}

.status-partial {
    background: #f472b6;
    color: #9d174d;
}

/* Пустое состояние */
.empty-state {
    text-align: center;
    color: #94a3b8;
    padding: 24px 12px;
    font-style: italic;
    font-size: 12px;
}

/* Утилиты */
.mt-2 {
    margin-top: 4px;
}

/* Адаптивность */
@media (max-width: 1400px) {
    body {
        font-size: 12px;
    }

    .product-name {
        font-size: 11px;
    }

    .order-card {
        padding: 5px 7px;
    }
}

@media (max-width: 1200px) {
    .departments-grid {
        grid-template-columns: 1fr;
        height: auto;
    }

    .department-column {
        min-height: 400px;
    }
}

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

/* Контейнер для статуса с кнопкой редактирования */
.status-edit-container {
    display: flex;
    align-items: center;
    gap: 4px;
}

/* Кнопка редактирования статуса */
.edit-status-btn {
    width: 16px;
    height: 16px;
    padding: 0;
    margin-left: 2px;
    background: transparent;
    border: none;
    cursor: pointer;
    opacity: 0.5;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.edit-status-btn:hover {
    opacity: 1;
    transform: scale(1.1);
}

/* Кнопка редактирования даты (стиль как у show-related-modal-btn) */
.edit-date-btn {
    width: 22px;
    height: 22px;
    padding: 0;
    background: rgba(102, 126, 234, 0.1);
    border: 1px solid rgba(102, 126, 234, 0.2);
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #667eea;
    transition: all 0.2s;
}

.edit-date-btn:hover {
    background: rgba(102, 126, 234, 0.25);
    border-color: #667eea;
    box-shadow: 0 0 0 2px rgba(102, 126, 234, 0.15);
}

.edit-date-btn:active {
    transform: scale(0.95);
}

/* Inline date editor */
.inline-date-editor {
    font-size: 11px;
    padding: 2px 6px;
    border: 1px solid #667eea;
    border-radius: 3px;
    height: 20px;
    background: white;
}

/* Status change dropdown */
.status-change-menu {
    font-size: 11px;
    min-width: 150px;
    max-height: 200px;
    overflow-y: auto;
    z-index: 1050; /* Выше чем карточки */
}

.status-change-menu .dropdown-item {
    padding: 4px 12px;
    font-size: 11px;
}

.status-change-menu .dropdown-item:hover {
    background-color: #f1f5f9;
}

/* Оборудование badge (рядом со статусом) */
.equipment-badge-container {
    display: flex;
    align-items: center;
    gap: 2px;
}

.equipment-badge {
    display: inline-block;
    font-size: 10px;
    padding: 2px 6px;
    border-radius: 3px;
    font-weight: 600;
    background: #e0f2fe;
    color: #0369a1;
    cursor: pointer;
    white-space: nowrap;
}

.equipment-badge.equipment-unknown {
    background: #f1f5f9;
    color: #94a3b8;
    font-style: italic;
}

.equipment-badge:hover {
    opacity: 0.85;
}

.edit-equipment-btn {
    width: 16px;
    height: 16px;
    padding: 0;
    margin-left: 2px;
    background: transparent;
    border: none;
    cursor: pointer;
    opacity: 0.5;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.edit-equipment-btn:hover {
    opacity: 1;
    transform: scale(1.1);
}

.equipment-change-menu {
    font-size: 11px;
    min-width: 150px;
    max-height: 200px;
    overflow-y: auto;
    z-index: 1050;
}

.equipment-change-menu .dropdown-item {
    padding: 4px 12px;
    font-size: 11px;
}

.equipment-change-menu .dropdown-item:hover {
    background-color: #f1f5f9;
}

/* Дополнительные визуальные улучшения */

/* Оптимизация для больших списков */
.date-group:last-child {
    margin-bottom: 0;
}

.orders-container:empty::after {
    content: '—';
    color: #cbd5e1;
    font-size: 11px;
    display: block;
    text-align: center;
    padding: 8px;
}

/* =============================================================================
   Модальное окно для связанных заказов
   ============================================================================= */

.modal-related .modal-content {
    border-radius: 8px;
    border: 1px solid #e2e8f0;
}

.modal-related .modal-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-bottom: none;
    padding: 16px 20px;
}

.modal-related .modal-title {
    font-size: 16px;
    font-weight: 600;
}

/* .btn-close стили вынесены в base.css */

.modal-related .modal-body {
    padding: 0;
    max-height: 85vh;
    overflow-y: auto;
}

/* Сетка подразделений внутри модалки (3 колонки) */
.modal-departments-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1px;
    background-color: #e2e8f0;
    min-height: 400px;
}

.modal-department-column {
    background-color: white;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Заголовок подразделения в модалке */
.modal-department-header {
    padding: 8px 12px;
    font-weight: 600;
    font-size: 13px;
    color: white;
    display: flex;
    align-items: center;
    gap: 6px;
    border-bottom: 2px solid rgba(0,0,0,0.1);
}

.modal-department-header.dept-cooking {
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
}

.modal-department-header.dept-filling {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
}

.modal-department-header.dept-packaging {
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
}

/* Контент подразделения в модалке */
.modal-department-content {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
    background-color: #fafbfc;
}

/* Scrollbar: использовать class="custom-scrollbar" из base.css */

/* Кнопки показа модалок (знак вопроса и граф) */
.show-related-modal-btn,
.show-graph-btn {
    width: 22px;
    height: 22px;
    padding: 0;
    background: rgba(102, 126, 234, 0.1);
    border: 1px solid rgba(102, 126, 234, 0.2);
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #667eea;
    transition: all 0.2s;
}

.show-related-modal-btn:hover,
.show-graph-btn:hover {
    background: rgba(102, 126, 234, 0.25);
    border-color: #667eea;
    box-shadow: 0 0 0 2px rgba(102, 126, 234, 0.15);
}

.show-related-modal-btn:active,
.show-graph-btn:active {
    transform: scale(0.95);
}

.show-related-modal-btn svg,
.show-graph-btn svg {
    pointer-events: none;
}

/* Подсветка связей в модальном окне */
.modal-source-order {
    border-left: 3px solid #667eea !important;
}

.modal-source-order .product-name {
    font-weight: 700;
}

.modal-hover-highlight {
    box-shadow: 0 0 0 2px #22c55e !important;
}

.modal-click-highlight {
    box-shadow: 0 0 0 2px #eab308 !important;
}

/* Отступ между днями в модальном окне */
#relatedOrdersBody .date-header {
    margin-top: 16px;
}

#relatedOrdersBody .date-header:first-child {
    margin-top: 0;
}

/* Адаптивность для модалки */
@media (max-width: 1400px) {
    .modal-related .modal-dialog {
        max-width: 90vw;
    }
}

@media (max-width: 992px) {
    .modal-related .modal-body {
        max-height: 80vh;
    }

    .modal-departments-grid {
        grid-template-columns: 1fr;
    }
}

/* Характеристики на карточке заказа */
.characteristics-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: 6px;
    margin-bottom: 4px;
}

/* Бейджи статуса производственной цепочки */
.chain-status-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: 4px;
    margin-bottom: 6px;
}

.chain-status-badge {
    display: inline-block;
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    white-space: nowrap;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
    transition: transform 0.1s, box-shadow 0.1s;
    cursor: help;
    font-family: 'SF Mono', 'Monaco', 'Courier New', monospace;
}

.chain-status-badge:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

/* Цветовые классы */
.chain-status-red {
    background: linear-gradient(135deg, #fee2e2 0%, #fecaca 100%);
    color: #991b1b;
    border: 1px solid #fca5a5;
}

.chain-status-yellow {
    background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
    color: #92400e;
    border: 1px solid #fbbf24;
}

.chain-status-green {
    background: linear-gradient(135deg, #d1fae5 0%, #a7f3d0 100%);
    color: #065f46;
    border: 1px solid #6ee7b7;
}

.chain-status-neutral {
    background: linear-gradient(135deg, #f1f5f9 0%, #e2e8f0 100%);
    color: #475569;
    border: 1px solid #cbd5e1;
}

/* Бейджи с датами связанных заказов */
.related-dates-badges {
    display: flex;
    flex-direction: column;
    gap: 2px;
    margin-top: 4px;
    font-size: 0.7rem;
}

.related-dates-group {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-wrap: wrap;
}

.related-dates-label {
    color: #666;
    font-weight: 500;
    min-width: 28px;
}

.related-date-badge {
    padding: 1px 4px;
    border-radius: 3px;
    font-size: 0.65rem;
}

/* Белый текст для тёмных badge */
.related-date-badge.status-completed,
.related-date-badge.status-inprogress,
.related-date-badge.status-waiting,
.related-date-badge.status-quarantine,
.related-date-badge.status-nomaterials,
.related-date-badge.status-partial {
    color: white;
}

/* Фильтр статусов в колонках подразделений (dropdown) */
.dept-status-dropdown {
    font-size: 11px;
    padding: 3px 8px;
    height: 24px;
    border: 1px solid #e2e8f0;
    background: white;
    color: #475569;
    border-radius: 4px;
    white-space: nowrap;
}

.dept-status-dropdown:hover,
.dept-status-dropdown:focus {
    border-color: #667eea;
    background: #f8fafc;
}

.dept-status-dropdown::after {
    margin-left: 4px;
    vertical-align: middle;
}

.dept-status-menu {
    font-size: 11px;
    min-width: 140px;
    max-height: 200px;
    overflow-y: auto;
    padding: 4px 0;
}

.dept-status-menu .dropdown-item {
    padding: 4px 10px;
    cursor: pointer;
}

.dept-status-menu .dropdown-item:hover {
    background-color: #f1f5f9;
}

.dept-status-menu .dropdown-item label {
    cursor: pointer;
    font-size: 11px;
}

.dept-status-menu .form-check-input {
    width: 12px;
    height: 12px;
    margin-top: 0;
}

/* =============================================================================
   Excel-подобный Dropdown Filter для подразделений
   ============================================================================= */

.dept-filter-dropdown {
    position: relative;
    display: inline-block;
}

.dept-filter-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    font-size: 12px;
    color: #475569;
    cursor: pointer;
    transition: all 0.2s;
    height: 28px;
}

.dept-filter-btn:hover {
    border-color: #667eea;
    background: #f8fafc;
}

.dept-filter-btn.active {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-color: #667eea;
    color: white;
}

.dept-filter-btn.active .filter-chevron {
    stroke: white;
}

.filter-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    background: #667eea;
    color: white;
    border-radius: 9px;
    font-size: 10px;
    font-weight: 700;
}

.dept-filter-btn.active .filter-badge {
    background: white;
    color: #667eea;
}

.filter-chevron {
    transition: transform 0.2s;
}

.dept-filter-dropdown.open .filter-chevron {
    transform: rotate(180deg);
}

/* Dropdown menu */
.dept-filter-menu {
    position: absolute;
    top: 100%;
    left: 0;
    z-index: 1050;
    min-width: 280px;
    max-width: 320px;
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
    margin-top: 4px;
    display: none;
    overflow: hidden;
}

.dept-filter-dropdown.open .dept-filter-menu {
    display: block;
}

/* Field selector */
.filter-field-select {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    background: #f8fafc;
    border-bottom: 1px solid #e2e8f0;
}

.filter-field-select label {
    font-size: 11px;
    color: #64748b;
    font-weight: 500;
    margin: 0;
}

.filter-field-selector {
    flex: 1;
    padding: 4px 8px;
    font-size: 12px;
    border: 1px solid #e2e8f0;
    border-radius: 4px;
    background: white;
    color: #1e293b;
    cursor: pointer;
}

.filter-field-selector:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 2px rgba(102, 126, 234, 0.2);
}

/* Search input */
.filter-search {
    padding: 8px 12px;
    border-bottom: 1px solid #e2e8f0;
}

.filter-search-input {
    width: 100%;
    padding: 6px 10px;
    font-size: 12px;
    border: 1px solid #e2e8f0;
    border-radius: 4px;
    background: white;
}

.filter-search-input:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 2px rgba(102, 126, 234, 0.2);
}

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

/* Action buttons (top) */
.filter-actions-top {
    display: flex;
    gap: 8px;
    padding: 8px 12px;
    border-bottom: 1px solid #e2e8f0;
    background: #f8fafc;
}

.filter-actions-top button {
    flex: 1;
    padding: 4px 8px;
    font-size: 11px;
    font-weight: 500;
    border: 1px solid #e2e8f0;
    border-radius: 4px;
    background: white;
    color: #475569;
    cursor: pointer;
    transition: all 0.15s;
}

.filter-actions-top button:hover {
    background: #667eea;
    border-color: #667eea;
    color: white;
}

/* Values list */
.filter-values-list {
    max-height: 220px;
    overflow-y: auto;
    padding: 4px 0;
}

/* Scrollbar: использовать class="custom-scrollbar" из base.css */

.filter-value-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    cursor: pointer;
    transition: background 0.1s;
    margin: 0;
}

.filter-value-item:hover {
    background: #f1f5f9;
}

.filter-value-checkbox {
    width: 14px;
    height: 14px;
    cursor: pointer;
    accent-color: #667eea;
    margin: 0;
}

.filter-value-text {
    font-size: 12px;
    color: #1e293b;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Action buttons (bottom) */
.filter-actions-bottom {
    padding: 8px 12px;
    background: #f8fafc;
    border-top: 1px solid #e2e8f0;
}

.reset-filter-btn {
    width: 100%;
    padding: 6px 12px;
    font-size: 11px;
    font-weight: 500;
    border: 1px solid #e2e8f0;
    border-radius: 4px;
    background: white;
    color: #64748b;
    cursor: pointer;
    transition: all 0.15s;
}

.reset-filter-btn:hover {
    background: #fee2e2;
    border-color: #fca5a5;
    color: #dc2626;
}

/* =============================================================================
   Dashboard Filter Panel (Header)
   ============================================================================= */

/* Контейнер с иконкой фильтра */
.filter-panel-container {
    position: relative;
    display: inline-block;
    margin-left: auto;
}

/* Кнопка-иконка фильтра */
.filter-panel-toggle {
    position: relative;
    width: 32px;
    height: 32px;
    padding: 0;
    background: rgba(255,255,255,0.15);
    border: 1px solid rgba(255,255,255,0.3);
    border-radius: 4px;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.filter-panel-toggle:hover {
    background: rgba(255,255,255,0.25);
    border-color: rgba(255,255,255,0.5);
}

.filter-panel-toggle.active {
    background: rgba(255,255,255,0.35);
    border-color: white;
}

/* Бейдж с количеством активных фильтров (в filter panel toggle) */
.filter-panel-toggle .filter-badge {
    position: absolute;
    top: -6px;
    right: -6px;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    background: #ef4444;
    color: white;
    border-radius: 9px;
    font-size: 10px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Выпадающая панель фильтров */
.filter-panel {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 8px;
    width: 320px;
    max-height: 80vh;
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
    display: none;
    flex-direction: column;
    z-index: 1050;
    overflow: hidden;
}

.filter-panel.open {
    display: flex;
}

/* Заголовок панели */
.filter-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    flex-shrink: 0;
}

.filter-panel-title {
    font-weight: 600;
    font-size: 14px;
}

.filter-panel-close {
    background: none;
    border: none;
    color: white;
    font-size: 20px;
    cursor: pointer;
    padding: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0.8;
    transition: opacity 0.2s;
    line-height: 1;
}

.filter-panel-close:hover {
    opacity: 1;
}

/* Тело панели */
.filter-panel-body {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
}

/* Секция фильтра */
.filter-section {
    margin-bottom: 16px;
}

.filter-section:last-child {
    margin-bottom: 0;
}

.filter-section-label {
    display: block;
    font-size: 11px;
    font-weight: 600;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    margin-bottom: 8px;
}

/* Dropdown внутри панели */
.filter-section .dropdown-toggle {
    width: 100%;
    text-align: left;
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 13px;
    padding: 8px 12px;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    background: white;
    color: #1e293b;
}

.filter-section .dropdown-toggle:hover {
    border-color: #667eea;
    background: #f8fafc;
}

.filter-section .dropdown-menu {
    width: 100%;
    font-size: 13px;
    max-height: 200px;
    overflow-y: auto;
}

/* Диапазон дат */
.filter-date-range {
    display: flex;
    align-items: center;
    gap: 8px;
}

.filter-date-range input {
    flex: 1;
    font-size: 13px;
    padding: 8px 10px;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    background: white;
    color: #1e293b;
}

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

.filter-date-separator {
    color: #94a3b8;
    font-size: 12px;
}

/* Input поле */
.filter-section input[type="text"] {
    width: 100%;
    font-size: 13px;
    padding: 8px 12px;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    background: white;
    color: #1e293b;
}

.filter-section input[type="text"]:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

/* Чекбоксы */
.filter-checkbox {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    font-size: 13px;
    color: #475569;
    margin: 0;
    padding: 8px 0;
}

.filter-checkbox .form-check-input {
    width: 16px;
    height: 16px;
    margin: 0;
    cursor: pointer;
    accent-color: #667eea;
}

/* Scrollbar: использовать class="custom-scrollbar" из base.css */
