/* ============================================================
   Orders — модуль «Приказы»
   Часть 1: подвкладки, фильтры, таблица, карточки, метки
   ============================================================ */

/* --------------------------------------------------------
   Подвкладки
   -------------------------------------------------------- */
.orders-subtabs {
    display: flex;
    align-items: center;
    gap: var(--space-1);
    border-bottom: 1px solid var(--border-default);
    margin-bottom: var(--space-5);
    position: relative;
    overflow-x: auto;
    overflow-y: hidden;
    padding-bottom: 0;
    -webkit-overflow-scrolling: touch;
}

.orders-subtabs::-webkit-scrollbar { display: none; }
.orders-subtabs {
    -ms-overflow-style: none;
    scrollbar-width: none;
}

.orders-subtab {
    position: relative;
    padding: 10px 16px;
    font-size: var(--fs-sm);
    font-weight: var(--fw-medium);
    color: var(--text-secondary);
    background: transparent;
    border: none;
    border-radius: 0;
    cursor: pointer;
    white-space: nowrap;
    transition: color var(--duration-fast) var(--ease);
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    margin-bottom: -1px;
}

.orders-subtab:hover { color: var(--text-primary); }

.orders-subtab.is-active {
    color: var(--text-primary);
    font-weight: var(--fw-semibold);
}

.orders-subtab.is-active::after {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 2px;
    background: var(--accent-primary);
    border-radius: 2px 2px 0 0;
}

.orders-subtab-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 20px;
    height: 18px;
    padding: 0 6px;
    border-radius: var(--radius-full);
    background: var(--bg-subtle);
    color: var(--text-tertiary);
    font-size: 11px;
    font-weight: var(--fw-medium);
    line-height: 1;
}

.orders-subtab.is-active .orders-subtab-count {
    background: var(--accent-subtle);
    color: var(--accent-text);
}

/* ============================================================
   Панель фильтров — 2 строки, симметричная раскладка
   ============================================================ */
.orders-filters {
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
    margin-bottom: var(--space-5);
    padding: var(--space-4);
    background: var(--bg-surface);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-lg);
}

/* Общий класс для строк — используется flex-wrap на средних экранах */
.orders-filters-row {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    flex-wrap: wrap;
}

/* Строка 1: поиск растягивается, остальные фиксированные */
.orders-filters-row-1 .orders-filters-search {
    flex: 1 1 280px;
    min-width: 220px;
    max-width: 100%;
}

.orders-filters-row-1 .orders-filters-select {
    flex: 0 0 auto;
    width: 170px;
}

.orders-filters-row-1 .orders-filters-select select {
    height: 36px;
}

/* Строка 2: пикеры фиксированные, потом пружина, потом действия */
.orders-filters-row-2 .orders-filter-picker-slot {
    flex: 0 0 auto;
    width: 220px;
    min-width: 0;
}

.orders-filters-spacer {
    flex: 1 1 20px;
    min-width: 0;
}

.orders-filters-actions {
    display: flex;
    gap: var(--space-2);
    align-items: center;
    flex: 0 0 auto;
}

/* Кнопки Excel / Сброс / Регистрация — одинаковой ширины */
.btn-filters-equal {
    min-width: 100px;
    justify-content: center;
    padding-left: var(--space-3);
    padding-right: var(--space-3);
    white-space: nowrap;
}

/* Активный фильтр — точка-индикатор */
.orders-filter-active {
    position: relative;
}

.orders-filter-active::after {
    content: '';
    position: absolute;
    top: 4px;
    right: 6px;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--accent-primary);
    pointer-events: none;
}

/* --------------------------------------------------------
   Адаптив панели фильтров
   -------------------------------------------------------- */

/* Планшет: 600–1099 — строки переносятся */
@media (max-width: 1099px) {
    .orders-filters-row-1 .orders-filters-select {
        flex: 1 1 calc(50% - var(--space-3) / 2);
        width: auto;
        min-width: 140px;
    }

    .orders-filters-row-1 .orders-filters-search {
        flex: 1 1 100%;
        max-width: none;
    }

    .orders-filters-row-2 .orders-filter-picker-slot {
        flex: 1 1 calc(50% - var(--space-3) / 2);
        width: auto;
        min-width: 200px;
    }

    .orders-filters-spacer {
        flex: 1 1 100%;
        height: 0;
    }

    .orders-filters-actions {
        flex: 1 1 100%;
        justify-content: flex-end;
        margin-top: var(--space-2);
        padding-top: var(--space-3);
        border-top: 1px solid var(--border-subtle);
    }
}

/* Мобильный: < 600 — всё в столбик */
@media (max-width: 599px) {
    .orders-filters {
        padding: var(--space-3);
    }

    .orders-filters-row-1 .orders-filters-select,
    .orders-filters-row-2 .orders-filter-picker-slot {
        flex: 1 1 100%;
        width: auto;
        min-width: 0;
    }

    .orders-filters-actions {
        justify-content: stretch;
    }

    .orders-filters-actions .btn-filters-equal {
        flex: 1;
        min-width: 0;
    }
}

/* ============================================================
   Filter Picker — мультивыбор сотрудников
   Desktop: popover. Mobile: bottom-sheet.
   ============================================================ */

.orders-filter-picker-slot {
    min-width: 0;
    position: relative;
}

/* --------------------------------------------------------
   Триггер
   -------------------------------------------------------- */
.filter-picker-trigger {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    height: 36px;
    padding: 0 var(--space-3);
    background: var(--bg-surface);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
    cursor: pointer;
    user-select: none;
    transition: all var(--duration-fast) var(--ease);
    font-size: var(--fs-sm);
    color: var(--text-primary);
    min-width: 0;
    overflow: hidden;
    width: 100%;
}

.filter-picker-trigger:hover {
    border-color: var(--border-strong);
}

.filter-picker-trigger:focus-visible {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: var(--shadow-focus);
}

.filter-picker-trigger.is-active {
    border-color: var(--accent-primary);
    background: var(--accent-subtle);
}

.filter-picker-trigger.is-open {
    border-color: var(--accent-primary);
    box-shadow: var(--shadow-focus);
}

.filter-picker-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    color: var(--text-tertiary);
}

.filter-picker-trigger.is-active .filter-picker-icon {
    color: var(--accent-text);
}

.filter-picker-icon svg {
    width: 16px;
    height: 16px;
}

.filter-picker-text {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 1px;
    flex: 1;
    min-width: 0;
    line-height: 1.15;
}

.filter-picker-label {
    font-size: 10px;
    font-weight: var(--fw-semibold);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-tertiary);
    white-space: nowrap;
}

.filter-picker-value {
    font-size: var(--fs-sm);
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}

.filter-picker-trigger.is-active .filter-picker-value {
    color: var(--accent-text);
    font-weight: var(--fw-medium);
}

.filter-picker-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    border-radius: var(--radius-full);
    background: var(--accent-primary);
    color: var(--text-inverse);
    font-size: 11px;
    font-weight: var(--fw-semibold);
    flex-shrink: 0;
    line-height: 1;
}

.filter-picker-chevron {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 14px;
    height: 14px;
    color: var(--text-tertiary);
    flex-shrink: 0;
    transition: transform var(--duration-fast) var(--ease);
}

.filter-picker-chevron svg {
    width: 14px;
    height: 14px;
}

.filter-picker-trigger.is-open .filter-picker-chevron {
    transform: rotate(180deg);
}

/* --------------------------------------------------------
   Поповер (desktop)
   -------------------------------------------------------- */
.filter-picker-popover {
    position: fixed;
    z-index: var(--z-dropdown);
    width: 340px;
    max-height: 440px;
    background: var(--bg-surface);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    opacity: 0;
    transform: translateY(-4px);
    transition: opacity 120ms var(--ease), transform 120ms var(--ease);
}

.filter-picker-popover:not(.is-closing) {
    opacity: 1;
    transform: translateY(0);
}

.filter-picker-popover.is-closing {
    opacity: 0;
    transform: translateY(-4px);
}

/* Шапка поповера */
.filter-picker-head {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-3);
    border-bottom: 1px solid var(--border-subtle);
    background: var(--bg-surface-2);
    flex-shrink: 0;
}

.filter-picker-head .input-group {
    flex: 1;
    min-width: 0;
}

.filter-picker-head .form-control {
    height: 32px;
    font-size: var(--fs-sm);
}

.filter-picker-close {
    width: 32px;
    height: 32px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    color: var(--text-tertiary);
    background: transparent;
    border: none;
    cursor: pointer;
    flex-shrink: 0;
    transition: all var(--duration-fast) var(--ease);
}

.filter-picker-close:hover {
    background: var(--bg-subtle);
    color: var(--text-primary);
}

.filter-picker-close svg {
    width: 16px;
    height: 16px;
}

/* Список */
.filter-picker-list {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: var(--space-1);
}

.filter-picker-item {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: 8px 10px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background var(--duration-fast) var(--ease);
    user-select: none;
}

.filter-picker-item:hover {
    background: var(--bg-subtle);
}

.filter-picker-item input[type="checkbox"] {
    appearance: none;
    -webkit-appearance: none;
    width: 16px;
    height: 16px;
    margin: 0;
    flex-shrink: 0;
    background: var(--bg-surface);
    border: 1.5px solid var(--border-strong);
    border-radius: var(--radius-xs);
    cursor: pointer;
    transition: all var(--duration-fast) var(--ease);
    position: relative;
}

.filter-picker-item input[type="checkbox"]:hover {
    border-color: var(--accent-primary);
}

.filter-picker-item input[type="checkbox"]:checked {
    background: var(--accent-primary);
    border-color: var(--accent-primary);
}

.filter-picker-item input[type="checkbox"]:checked::after {
    content: '';
    position: absolute;
    left: 4px;
    top: 1px;
    width: 5px;
    height: 9px;
    border: solid var(--text-inverse);
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

.filter-picker-item input[type="checkbox"]:focus-visible {
    box-shadow: var(--shadow-focus);
}

.filter-picker-item-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.filter-picker-item-name {
    font-size: var(--fs-sm);
    font-weight: var(--fw-medium);
    color: var(--text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    line-height: 1.3;
}

.filter-picker-item-sub {
    font-size: 12px;
    color: var(--text-tertiary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    line-height: 1.3;
}

.filter-picker-empty,
.filter-picker-loading {
    padding: 32px 20px;
    text-align: center;
    font-size: var(--fs-sm);
    color: var(--text-tertiary);
}

.filter-picker-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
}

/* Футер */
.filter-picker-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3);
    padding: var(--space-3);
    border-top: 1px solid var(--border-subtle);
    background: var(--bg-surface-2);
    flex-shrink: 0;
}

.filter-picker-footer-hint {
    font-size: 12px;
    color: var(--text-secondary);
}

.filter-picker-clear {
    display: inline-flex;
    align-items: center;
    gap: var(--space-1);
    padding: 4px 10px;
    font-size: 12px;
    font-weight: var(--fw-medium);
    color: var(--accent-text);
    background: transparent;
    border: 1px solid var(--accent-border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--duration-fast) var(--ease);
}

.filter-picker-clear:hover {
    background: var(--accent-subtle);
    border-color: var(--accent-primary);
}

/* --------------------------------------------------------
   Mobile: <600 — bottom-sheet
   -------------------------------------------------------- */
@media (max-width: 599px) {
    .filter-picker-popover {
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        top: auto !important;
        width: 100%;
        max-height: 80vh;
        border-radius: var(--radius-lg) var(--radius-lg) 0 0;
        border-bottom: none;
        box-shadow: 0 -8px 24px rgba(15, 20, 25, 0.15);
        transform: translateY(100%);
        transition: transform 220ms cubic-bezier(0.4, 0, 0.2, 1);
    }

    .filter-picker-popover:not(.is-closing) {
        transform: translateY(0);
    }

    .filter-picker-popover.is-closing {
        transform: translateY(100%);
    }

    .filter-picker-head {
        padding: var(--space-4);
        padding-bottom: var(--space-3);
    }

    .filter-picker-head .form-control {
        height: 40px;
    }

    .filter-picker-item {
        padding: 12px;
        min-height: 56px;
    }

    .filter-picker-item input[type="checkbox"] {
        width: 20px;
        height: 20px;
    }

    .filter-picker-item input[type="checkbox"]:checked::after {
        left: 5px;
        top: 2px;
        width: 6px;
        height: 10px;
    }

    .filter-picker-footer {
        padding: var(--space-4);
        padding-bottom: calc(var(--space-4) + env(safe-area-inset-bottom, 0px));
    }

    .filter-picker-clear {
        padding: 8px 14px;
        font-size: 13px;
    }
}

/* ============================================================
   Таблица приказов
   ============================================================ */
.orders-table-wrap {
    background: var(--bg-surface);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.orders-table {
    width: 100%;
    font-size: var(--fs-sm);
    border-collapse: collapse;
}

.orders-table thead th {
    padding: 10px 14px;
    text-align: left;
    font-size: 11px;
    font-weight: var(--fw-semibold);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-tertiary);
    background: var(--bg-surface-2);
    border-bottom: 1px solid var(--border-default);
    white-space: nowrap;
    user-select: none;
}

.orders-table thead th.is-sortable {
    cursor: pointer;
    transition: color var(--duration-fast) var(--ease);
}

.orders-table thead th.is-sortable:hover {
    color: var(--text-secondary);
}

.orders-table thead th.is-sortable::after {
    content: '';
    display: inline-block;
    width: 6px;
    height: 6px;
    margin-left: 6px;
    border-right: 1.5px solid currentColor;
    border-bottom: 1.5px solid currentColor;
    transform: rotate(45deg) translateY(-2px);
    opacity: 0;
    transition: opacity var(--duration-fast) var(--ease);
}

.orders-table thead th.is-sortable:hover::after { opacity: 0.4; }
.orders-table thead th.is-sorted-asc::after,
.orders-table thead th.is-sorted-desc::after { opacity: 1; }
.orders-table thead th.is-sorted-desc::after { transform: rotate(-135deg) translateY(-2px); }

.orders-table tbody td {
    padding: 12px 14px;
    border-bottom: 1px solid var(--border-subtle);
    vertical-align: middle;
    color: var(--text-primary);
    height: 44px;
}

.orders-table tbody tr:last-child td { border-bottom: none; }

.orders-table tbody tr {
    transition: background var(--duration-fast) var(--ease);
    cursor: pointer;
}

.orders-table tbody tr:hover { background: var(--bg-surface-2); }
.orders-table tbody tr:hover .orders-row-actions { opacity: 1; }

.orders-cell-number {
    font-family: var(--font-mono);
    font-size: 13px;
    font-weight: var(--fw-semibold);
    color: var(--text-primary);
    white-space: nowrap;
    letter-spacing: -0.01em;
}

.orders-cell-number .orders-dsp-mark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 16px;
    padding: 0 5px;
    margin-right: 6px;
    border-radius: var(--radius-xs);
    background: #fdf6e3;
    color: #8a6508;
    border: 1px solid #ecd99a;
    font-family: var(--font-sans);
    font-size: 9px;
    font-weight: var(--fw-bold);
    letter-spacing: 0.05em;
    vertical-align: middle;
}

.orders-cell-number .orders-file-mark {
    display: inline-flex;
    width: 14px;
    height: 14px;
    margin-left: 4px;
    color: var(--text-tertiary);
    vertical-align: middle;
}

.orders-cell-date {
    white-space: nowrap;
    color: var(--text-secondary);
    font-variant-numeric: tabular-nums;
    font-size: 13px;
}

.orders-cell-type {
    color: var(--text-secondary);
    font-size: 13px;
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.orders-cell-dev {
    font-size: 13px;
    color: var(--text-primary);
    max-width: 180px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.orders-participants {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
    color: var(--text-secondary);
}

.orders-participants-stack {
    display: inline-flex;
    align-items: center;
}

.orders-participants-avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--accent-subtle);
    color: var(--accent-text);
    font-size: 9px;
    font-weight: var(--fw-semibold);
    border: 1.5px solid var(--bg-surface);
    margin-left: -6px;
    flex-shrink: 0;
    text-transform: uppercase;
}

.orders-participants-avatar:first-child { margin-left: 0; }

.orders-participants-more {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--bg-subtle);
    color: var(--text-secondary);
    font-size: 9px;
    font-weight: var(--fw-semibold);
    border: 1.5px solid var(--bg-surface);
    margin-left: -6px;
    flex-shrink: 0;
}

.orders-participants-empty {
    color: var(--text-tertiary);
    font-size: 12px;
}

.orders-cell-desc {
    max-width: 280px;
    color: var(--text-secondary);
    font-size: 13px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.orders-status {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    white-space: nowrap;
}

.orders-status::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
    flex-shrink: 0;
}

.orders-status.is-active { color: var(--color-success-text); }
.orders-status.is-active::before { background: var(--color-success); }

.orders-status.is-inactive { color: var(--text-tertiary); }
.orders-status.is-inactive::before { background: var(--text-tertiary); }

.orders-cell-actions {
    width: 48px;
    text-align: right;
    padding-right: 12px !important;
}

.orders-row-actions {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: var(--radius-sm);
    color: var(--text-tertiary);
    background: transparent;
    opacity: 0.4;
    transition: all var(--duration-fast) var(--ease);
    cursor: pointer;
}

.orders-row-actions:hover {
    background: var(--bg-subtle);
    color: var(--text-primary);
    opacity: 1;
}

.orders-row-actions svg {
    width: 16px;
    height: 16px;
}

.orders-table-empty {
    text-align: center;
    padding: var(--space-12) var(--space-6) !important;
    color: var(--text-secondary);
}

.orders-table-empty .orders-empty-icon {
    display: block;
    margin: 0 auto var(--space-3);
    width: 48px;
    height: 48px;
    color: var(--text-tertiary);
    opacity: 0.5;
}

.orders-table-empty .orders-empty-title {
    font-size: var(--fs-lg);
    font-weight: var(--fw-semibold);
    color: var(--text-primary);
    margin-bottom: var(--space-2);
}

.orders-table-empty .orders-empty-text {
    font-size: var(--fs-sm);
    color: var(--text-secondary);
    max-width: 400px;
    margin: 0 auto var(--space-4);
}

/* ============================================================
   Карточки «Мои приказы»
   ============================================================ */
.orders-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
    gap: var(--space-3);
}

@media (max-width: 600px) {
    .orders-cards { grid-template-columns: 1fr; }
}

.order-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-lg);
    padding: var(--space-4);
    cursor: pointer;
    transition: all var(--duration-base) var(--ease);
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
    position: relative;
}

.order-card:hover {
    border-color: var(--border-strong);
    box-shadow: var(--shadow-md);
    transform: translateY(-1px);
}

.order-card-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: var(--space-2);
}

.order-card-number {
    font-family: var(--font-mono);
    font-size: 14px;
    font-weight: var(--fw-semibold);
    color: var(--text-primary);
    letter-spacing: -0.01em;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.order-card-date {
    font-size: 12px;
    color: var(--text-tertiary);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.order-card-title {
    font-size: var(--fs-base);
    font-weight: var(--fw-medium);
    color: var(--text-primary);
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    min-height: 40px;
}

.order-card-meta {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding-top: var(--space-3);
    border-top: 1px solid var(--border-subtle);
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: auto;
}

.order-card-meta-row {
    display: flex;
    align-items: center;
    gap: 6px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.order-card-meta-row svg {
    width: 12px;
    height: 12px;
    color: var(--text-tertiary);
    flex-shrink: 0;
}

.order-card-actions {
    display: flex;
    gap: var(--space-2);
    padding-top: var(--space-3);
    border-top: 1px solid var(--border-subtle);
}

.order-card-actions .btn { flex: 1; }

.order-card-status {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 11px;
    font-weight: var(--fw-medium);
    padding: 3px 8px;
    border-radius: var(--radius-sm);
    white-space: nowrap;
}

.order-card-status.is-active {
    background: var(--color-success-bg);
    color: var(--color-success-text);
    border: 1px solid var(--color-success-border);
}

.order-card-status.is-active::before {
    content: '';
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: var(--color-success);
}

.order-card-status.is-inactive {
    background: var(--bg-subtle);
    color: var(--text-tertiary);
    border: 1px solid var(--border-default);
}

.order-card-status.is-inactive::before {
    content: '';
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: var(--text-tertiary);
}

/* ============================================================
   Dropdown «⋯»
   ============================================================ */
.orders-dropdown {
    position: fixed;
    min-width: 220px;
    max-width: 280px;
    max-height: 360px;
    overflow-y: auto;
    background: var(--bg-surface);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    padding: var(--space-1);
    z-index: var(--z-dropdown);
    opacity: 0;
    transform: translateY(-4px) scale(0.98);
    transition: opacity 120ms var(--ease), transform 120ms var(--ease);
    pointer-events: none;
}

.orders-dropdown.is-open {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

.orders-dropdown-item {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    width: 100%;
    padding: 7px 10px;
    border-radius: var(--radius-sm);
    font-size: var(--fs-sm);
    font-weight: var(--fw-medium);
    color: var(--text-primary);
    background: transparent;
    text-align: left;
    cursor: pointer;
    transition: background var(--duration-fast) var(--ease);
    white-space: nowrap;
    border: none;
    font-family: inherit;
}

.orders-dropdown-item:hover,
.orders-dropdown-item.is-focused { background: var(--bg-subtle); }

.orders-dropdown-item svg {
    width: 15px;
    height: 15px;
    color: var(--text-tertiary);
    flex-shrink: 0;
}

.orders-dropdown-item:hover svg,
.orders-dropdown-item.is-focused svg { color: var(--text-secondary); }

.orders-dropdown-item.is-danger { color: var(--color-danger-text); }
.orders-dropdown-item.is-danger svg { color: var(--color-danger); }
.orders-dropdown-item.is-danger:hover { background: var(--color-danger-bg); }

.orders-dropdown-item-hint {
    margin-left: auto;
    font-size: 10px;
    color: var(--text-tertiary);
    font-family: var(--font-mono);
    padding-left: var(--space-2);
}

.orders-dropdown-sep {
    height: 1px;
    margin: var(--space-1) 0;
    background: var(--border-subtle);
    border: none;
}

.orders-dropdown-header {
    padding: 6px 10px 4px;
    font-size: 10px;
    font-weight: var(--fw-semibold);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-tertiary);
}

/* ============================================================
   Скелетоны
   ============================================================ */
.orders-skeleton-row td {
    padding: 12px 14px;
    border-bottom: 1px solid var(--border-subtle);
    height: 44px;
}

.orders-skeleton-bar {
    height: 10px;
    border-radius: var(--radius-xs);
    background: linear-gradient(90deg,
        var(--bg-subtle) 0%,
        var(--border-subtle) 50%,
        var(--bg-subtle) 100%);
    background-size: 200% 100%;
    animation: orders-skeleton-shimmer 1.4s ease-in-out infinite;
}

@keyframes orders-skeleton-shimmer {
    0%   { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

.orders-skeleton-bar.w-40 { width: 40%; }
.orders-skeleton-bar.w-60 { width: 60%; }
.orders-skeleton-bar.w-80 { width: 80%; }
.orders-skeleton-bar.w-30 { width: 30%; }

.order-card-skeleton {
    background: var(--bg-surface);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-lg);
    padding: var(--space-4);
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
}

.order-card-skeleton .skeleton-title {
    height: 16px;
    width: 50%;
}

.order-card-skeleton .skeleton-line {
    height: 12px;
    width: 80%;
}

.order-card-skeleton .skeleton-line.short { width: 40%; }

/* ============================================================
   Пустое состояние карточек
   ============================================================ */
.orders-empty-cards {
    grid-column: 1 / -1;
    text-align: center;
    padding: var(--space-12) var(--space-6);
    color: var(--text-secondary);
}

.orders-empty-cards svg {
    width: 56px;
    height: 56px;
    margin: 0 auto var(--space-4);
    color: var(--text-tertiary);
    opacity: 0.5;
}

.orders-empty-cards .orders-empty-title {
    font-size: var(--fs-lg);
    font-weight: var(--fw-semibold);
    color: var(--text-primary);
    margin-bottom: var(--space-2);
}

.orders-empty-cards .orders-empty-text {
    font-size: var(--fs-sm);
    max-width: 400px;
    margin: 0 auto var(--space-5);
}

/* ============================================================
   Пагинация
   ============================================================ */
.orders-pagination {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-4);
    margin-top: var(--space-5);
    padding-top: var(--space-4);
    border-top: 1px solid var(--border-subtle);
    flex-wrap: wrap;
}

.orders-pagination-info {
    font-size: var(--fs-sm);
    color: var(--text-tertiary);
}

.orders-pagination-pages {
    display: flex;
    gap: 2px;
    align-items: center;
}

.orders-pagination-size {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    font-size: var(--fs-sm);
    color: var(--text-secondary);
}

.orders-pagination-size select {
    width: auto;
    height: 30px;
    padding: 0 var(--space-6) 0 var(--space-3);
    font-size: var(--fs-sm);
}

/* ============================================================
   Форма регистрации приказа
   ============================================================ */
.orders-register {
    max-width: 900px;
    margin: 0 auto;
}

.orders-register-section {
    background: var(--bg-surface);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-lg);
    padding: var(--space-5);
    margin-bottom: var(--space-4);
}

.orders-register-section-title {
    font-size: var(--fs-base);
    font-weight: var(--fw-semibold);
    color: var(--text-primary);
    margin-bottom: var(--space-4);
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding-bottom: var(--space-3);
    border-bottom: 1px solid var(--border-subtle);
}

.orders-register-section-title svg {
    width: 18px;
    height: 18px;
    color: var(--text-tertiary);
}

.orders-register-section-title .orders-register-step {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: var(--accent-subtle);
    color: var(--accent-text);
    font-size: 11px;
    font-weight: var(--fw-bold);
    font-family: var(--font-mono);
}

.orders-dropzone {
    border: 2px dashed var(--border-strong);
    border-radius: var(--radius-md);
    padding: var(--space-6) var(--space-5);
    text-align: center;
    cursor: pointer;
    transition: all var(--duration-base) var(--ease);
    background: var(--bg-surface-2);
}

.orders-dropzone:hover {
    border-color: var(--accent-primary);
    background: var(--accent-subtle);
}

.orders-dropzone.is-dragover {
    border-color: var(--accent-primary);
    background: var(--accent-subtle);
    transform: scale(1.005);
}

.orders-dropzone.is-disabled {
    opacity: 0.5;
    cursor: not-allowed;
    border-style: solid;
}

.orders-dropzone-icon {
    width: 40px;
    height: 40px;
    margin: 0 auto var(--space-3);
    color: var(--text-tertiary);
}

.orders-dropzone-title {
    font-size: var(--fs-base);
    font-weight: var(--fw-medium);
    color: var(--text-primary);
    margin-bottom: 4px;
}

.orders-dropzone-hint {
    font-size: var(--fs-xs);
    color: var(--text-tertiary);
}

.orders-dropzone-file {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-3) var(--space-4);
    background: var(--bg-surface);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
    margin-top: var(--space-3);
    font-size: var(--fs-sm);
}

.orders-dropzone-file svg {
    width: 18px;
    height: 18px;
    color: var(--accent-primary);
    flex-shrink: 0;
}

.orders-dropzone-file-info { flex: 1; min-width: 0; }

.orders-dropzone-file-name {
    font-weight: var(--fw-medium);
    color: var(--text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.orders-dropzone-file-size {
    font-size: var(--fs-xs);
    color: var(--text-tertiary);
    margin-top: 1px;
}

.orders-dropzone-file-remove {
    width: 28px;
    height: 28px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    color: var(--text-tertiary);
    cursor: pointer;
    background: transparent;
    border: none;
    transition: all var(--duration-fast) var(--ease);
    flex-shrink: 0;
}

.orders-dropzone-file-remove:hover {
    background: var(--color-danger-bg);
    color: var(--color-danger);
}

.orders-dsp-notice {
    display: flex;
    gap: var(--space-3);
    padding: var(--space-3) var(--space-4);
    background: var(--color-warning-bg);
    border: 1px solid var(--color-warning-border);
    border-radius: var(--radius-md);
    font-size: var(--fs-sm);
    color: var(--color-warning-text);
    line-height: 1.5;
    margin-bottom: var(--space-4);
}

.orders-dsp-notice svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    margin-top: 1px;
}

/* ============================================================
   Участники — мультивыбор в форме
   ============================================================ */
.orders-participants-picker {
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
    background: var(--bg-surface);
    max-height: 320px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.orders-participants-search {
    padding: var(--space-3);
    border-bottom: 1px solid var(--border-subtle);
    background: var(--bg-surface-2);
}

.orders-participants-list {
    overflow-y: auto;
    padding: var(--space-2);
    flex: 1;
    max-height: 260px;
}

.orders-participant-item {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-2) var(--space-3);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background var(--duration-fast) var(--ease);
    font-size: var(--fs-sm);
}

.orders-participant-item:hover { background: var(--bg-subtle); }

.orders-participant-item input[type="checkbox"] {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    cursor: pointer;
}

.orders-participant-info { flex: 1; min-width: 0; }

.orders-participant-name {
    font-weight: var(--fw-medium);
    color: var(--text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.orders-participant-dept {
    font-size: var(--fs-xs);
    color: var(--text-tertiary);
    margin-top: 1px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.orders-participants-selected {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    padding: var(--space-2) var(--space-3);
    background: var(--bg-surface-2);
    border-bottom: 1px solid var(--border-subtle);
    min-height: 40px;
    align-items: center;
}

.orders-participant-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 8px;
    background: var(--accent-subtle);
    color: var(--accent-text);
    border: 1px solid var(--accent-border);
    border-radius: var(--radius-full);
    font-size: 11px;
    font-weight: var(--fw-medium);
    white-space: nowrap;
    line-height: 1;
}

.orders-participant-chip-remove {
    width: 14px;
    height: 14px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: transparent;
    border: none;
    color: currentColor;
    cursor: pointer;
    padding: 0;
    transition: background var(--duration-fast) var(--ease);
    flex-shrink: 0;
}

.orders-participant-chip-remove:hover { background: rgba(0, 0, 0, 0.1); }
.orders-participant-chip-remove svg { width: 9px; height: 9px; }

/* ============================================================
   Модалка цепочки
   ============================================================ */
.orders-chain-tree {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.orders-chain-node {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-3) var(--space-4);
    border-radius: var(--radius-md);
    background: var(--bg-surface-2);
    border: 1px solid var(--border-subtle);
    font-size: var(--fs-sm);
    transition: all var(--duration-fast) var(--ease);
}

.orders-chain-node:hover { background: var(--bg-subtle); }

.orders-chain-node.is-current {
    background: var(--accent-subtle);
    border-color: var(--accent-border);
    font-weight: var(--fw-semibold);
}

.orders-chain-node.is-parent { margin-left: 0; }

.orders-chain-node.is-child {
    margin-left: 24px;
    position: relative;
}

.orders-chain-node.is-child::before {
    content: '';
    position: absolute;
    left: -12px;
    top: 50%;
    width: 12px;
    height: 1px;
    background: var(--border-strong);
}

.orders-chain-node-num {
    font-family: var(--font-mono);
    font-weight: var(--fw-semibold);
    color: var(--text-primary);
    flex-shrink: 0;
}

.orders-chain-node-date {
    color: var(--text-tertiary);
    font-size: var(--fs-xs);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.orders-chain-node-desc {
    flex: 1;
    min-width: 0;
    color: var(--text-secondary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    margin-left: var(--space-2);
}

.orders-chain-arrow {
    text-align: center;
    color: var(--text-tertiary);
    font-size: 12px;
    padding: 2px 0;
}

/* ============================================================
   Адаптив — таблица превращается в карточки
   ============================================================ */
@media (max-width: 900px) {
    .orders-filters { padding: var(--space-3); }
}

@media (max-width: 720px) {
    .orders-table-wrap { border-radius: var(--radius-md); }
    .orders-table thead { display: none; }

    .orders-table tbody tr {
        display: block;
        padding: var(--space-4);
        border-bottom: 1px solid var(--border-default);
        position: relative;
    }

    .orders-table tbody tr:last-child { border-bottom: none; }

    .orders-table tbody td {
        display: block;
        padding: 4px 0;
        height: auto;
        border: none;
    }

    .orders-table tbody td::before {
        content: attr(data-label);
        display: inline-block;
        min-width: 100px;
        font-size: 11px;
        text-transform: uppercase;
        letter-spacing: 0.04em;
        color: var(--text-tertiary);
        font-weight: var(--fw-semibold);
    }

    .orders-table tbody td.orders-cell-actions {
        position: absolute;
        top: var(--space-3);
        right: var(--space-3);
        width: auto;
        text-align: right;
    }

    .orders-table tbody td.orders-cell-actions::before { display: none; }
    .orders-row-actions { opacity: 1; }
    .orders-cell-desc { max-width: none; white-space: normal; display: block; }
}

@media (max-width: 600px) {
    .orders-subtabs { margin-bottom: var(--space-4); }
    .orders-subtab { padding: 10px 12px; font-size: 13px; }
}

/* ============================================================
   Печать
   ============================================================ */
@media print {
    .sidebar,
    .header,
    .orders-filters,
    .orders-subtabs,
    .orders-cell-actions,
    .orders-pagination,
    .filter-picker-trigger,
    .filter-picker-popover,
    .btn {
        display: none !important;
    }

    .content { padding: 0; }
    .orders-table-wrap { border: none; box-shadow: none; }

    .orders-table thead th {
        background: white;
        border-bottom: 2px solid #000;
    }

    .orders-table tbody tr { page-break-inside: avoid; }
}

/* ============================================================
   CHAIN — цепочка приказов
   ============================================================ */
.chain-tree {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 4px 0;
}

.chain-group-label {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-tertiary);
    margin: 12px 0 4px;
    padding-left: 4px;
}

.chain-group-label:first-child { margin-top: 0; }

.chain-node {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    background: var(--bg-surface-2);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    font-size: 14px;
    cursor: pointer;
    transition: all 120ms var(--ease);
    position: relative;
}

.chain-node:hover {
    background: var(--bg-subtle);
    border-color: var(--border-strong);
}

.chain-node.is-current {
    background: var(--accent-subtle);
    border-color: var(--accent-border);
    cursor: default;
}

.chain-node.is-current:hover { background: var(--accent-subtle); }
.chain-node.is-parent { margin-left: 0; }
.chain-node.is-child { margin-left: 28px; }

.chain-node.is-child::before {
    content: '';
    position: absolute;
    left: -16px;
    top: 50%;
    width: 16px;
    height: 1px;
    background: var(--border-strong);
}

.chain-node.is-child::after {
    content: '';
    position: absolute;
    left: -16px;
    top: -6px;
    bottom: 50%;
    width: 1px;
    background: var(--border-strong);
}

.chain-node-num {
    font-family: var(--font-mono);
    font-weight: 600;
    color: var(--text-primary);
    letter-spacing: -0.01em;
    flex-shrink: 0;
}

.chain-node.is-current .chain-node-num { color: var(--accent-text); }

.chain-node-date {
    font-size: 12px;
    color: var(--text-tertiary);
    font-variant-numeric: tabular-nums;
    flex-shrink: 0;
    white-space: nowrap;
}

.chain-node-desc {
    flex: 1;
    min-width: 0;
    color: var(--text-secondary);
    font-size: 13px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.chain-node-status {
    font-size: 11px;
    padding: 2px 8px;
    border-radius: var(--radius-sm);
    flex-shrink: 0;
}

.chain-node-status.is-active {
    background: var(--color-success-bg);
    color: var(--color-success-text);
}

.chain-node-status.is-inactive {
    background: var(--bg-subtle);
    color: var(--text-tertiary);
}

.chain-node-badge {
    font-size: 10px;
    padding: 2px 8px;
    border-radius: var(--radius-sm);
    background: var(--accent-primary);
    color: var(--text-inverse);
    font-weight: 600;
    letter-spacing: 0.02em;
    flex-shrink: 0;
    text-transform: uppercase;
}

/* ============================================================
   Мультивыбор — чекбокс + подсветка + bulk-bar
   ============================================================ */
.orders-cell-checkbox {
    width: 40px;
    padding-left: 16px !important;
    padding-right: 4px !important;
}

.orders-cell-checkbox input[type="checkbox"] {
    width: 16px;
    height: 16px;
    cursor: pointer;
    accent-color: var(--accent-primary);
}

.orders-table thead th.orders-cell-checkbox input[type="checkbox"] {
    width: 14px;
    height: 14px;
}

.orders-table tbody tr.is-selected {
    background: var(--accent-subtle) !important;
}

.orders-table tbody tr.is-selected:hover {
    background: var(--accent-subtle) !important;
    filter: brightness(0.98);
}

.orders-bulk-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    background: var(--accent-subtle);
    border: 1px solid var(--accent-border);
    border-radius: var(--radius-md);
    margin-bottom: 12px;
    animation: slideDown 200ms var(--ease);
}

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

.orders-bulk-count {
    font-size: 13px;
    font-weight: 600;
    color: var(--accent-text);
}

.orders-bulk-spacer { flex: 1; }

/* ============================================================
   Пустое состояние цепочки
   ============================================================ */
.chain-empty {
    padding: 40px 20px;
    text-align: center;
    color: var(--text-secondary);
}

.chain-empty svg {
    width: 48px;
    height: 48px;
    color: var(--text-tertiary);
    opacity: 0.5;
    margin-bottom: 12px;
}

.chain-empty-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.chain-empty-text {
    font-size: 13px;
    max-width: 320px;
    margin: 0 auto;
    line-height: 1.5;
}

/* ============================================================
   «Текущий» в цепочке — без овала
   ============================================================ */

.chain-node-current-label {
    font-size: 11px;
    color: var(--text-tertiary);
    font-weight: 400;
    white-space: nowrap;
    flex-shrink: 0;
}