@import url('open-iconic/font/css/open-iconic-bootstrap.min.css');
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

/* =============================================
   ПЕРЕМЕННЫЕ БРЕНДА COPYPASTE
   ============================================= */
:root {
    --cp-yellow:       #f5c518;
    --cp-yellow-hover: #e6b800;
    --cp-blue:         #1a56db;
    --cp-blue-hover:   #1447b5;
    --cp-dark:         #1a1a2e;
    --cp-text:         #1a1a1a;
    --cp-muted:        #6b7280;
    --cp-border:       #e5e7eb;
    --cp-bg:           #f9fafb;
    --cp-white:        #ffffff;
}

html, body {
    font-family: 'Inter', 'Helvetica Neue', Helvetica, Arial, sans-serif;
    color: var(--cp-text);
    background: var(--cp-bg);
    margin: 0;
}

h1:focus { outline: none; }

a, .btn-link {
    color: var(--cp-blue);
    text-decoration: none;
}
a:hover { color: var(--cp-blue-hover); }

/* =============================================
   LAYOUT
   ============================================= */
.page {
    position: relative;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* --- Сайдбар --- */
.sidebar {
    background: var(--cp-dark);
}

.top-row {
    background: var(--cp-white);
    border-bottom: 1px solid var(--cp-border);
    height: 3.5rem;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding: 0 1.5rem;
}

.top-row a {
    color: var(--cp-muted);
    font-size: 0.85rem;
}
.top-row a:hover { color: var(--cp-blue); }

/* --- Логотип --- */
.navbar-brand {
    font-size: 1.2rem;
    font-weight: 800;
    color: var(--cp-yellow) !important;
    letter-spacing: 0.5px;
    text-decoration: none;
}

.navbar-toggler {
    background: none;
    border: 1px solid rgba(255,255,255,0.25);
}

/* --- Навигация --- */
.nav-item { margin: 2px 0; }

.nav-link {
    color: rgba(255,255,255,0.68) !important;
    font-size: 0.88rem;
    font-weight: 500;
    border-radius: 6px;
    padding: 9px 12px !important;
    transition: all 0.15s;
    display: flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
}

.nav-link:hover {
    color: #fff !important;
    background: rgba(255,255,255,0.08);
}

.nav-link.active {
    color: var(--cp-dark) !important;
    background: var(--cp-yellow) !important;
    font-weight: 700;
}

.nav-scrollable { padding: 8px; }

@media (min-width: 641px) {
    .page { flex-direction: row; }
    .sidebar { width: 220px; min-height: 100vh; position: sticky; top: 0; }
    .top-row { position: sticky; top: 0; z-index: 10; }
    .content { padding-top: 1.1rem; }
    main { flex: 1; }
}

/* =============================================
   BOOTSTRAP ПЕРЕОПРЕДЕЛЕНИЯ
   ============================================= */
.btn-primary {
    background: var(--cp-yellow);
    border-color: var(--cp-yellow);
    color: var(--cp-dark);
    font-weight: 700;
}
.btn-primary:hover {
    background: var(--cp-yellow-hover);
    border-color: var(--cp-yellow-hover);
    color: var(--cp-dark);
}

.btn:focus, .btn:active:focus,
.form-control:focus,
.form-check-input:focus {
    box-shadow: 0 0 0 3px rgba(245,197,24,0.25);
}

/* =============================================
   BLAZOR СЛУЖЕБНЫЕ
   ============================================= */
.valid.modified:not([type=checkbox]) { outline: 1px solid #16a34a; }
.invalid { outline: 1px solid #dc2626; }
.validation-message { color: #dc2626; font-size: 0.85rem; }

#blazor-error-ui {
    background: #fefce8;
    border-top: 1px solid #fde047;
    bottom: 0; left: 0;
    padding: 0.6rem 1.25rem 0.7rem 1.25rem;
    position: fixed;
    width: 100%;
    z-index: 1000;
    display: none;
}
#blazor-error-ui .dismiss {
    cursor: pointer;
    position: absolute;
    right: 0.75rem;
    top: 0.5rem;
}
.blazor-error-boundary {
    background: #fef2f2;
    border-left: 4px solid #dc2626;
    padding: 1rem 1.5rem;
    color: #991b1b;
    border-radius: 4px;
}
.blazor-error-boundary::after { content: "Произошла ошибка." }

/* =============================================
   CP КОМПОНЕНТЫ
   ============================================= */

/* --- Карточка --- */
.cp-card {
    background: var(--cp-white);
    border: 1px solid var(--cp-border);
    border-radius: 8px;
    margin-bottom: 20px;
    overflow: hidden;
    box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}

.cp-card-body { padding: 20px 24px; }

/* --- Шапка карточки --- */
.cp-header {
    background: var(--cp-dark);
    color: #fff;
    padding: 14px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.cp-header h2 {
    margin: 0;
    font-size: 1rem;
    font-weight: 700;
    letter-spacing: 0.3px;
}

/* --- Кнопки --- */
.btn-cp-primary {
    background: var(--cp-yellow);
    border: none;
    color: var(--cp-dark);
    padding: 9px 22px;
    border-radius: 6px;
    font-weight: 700;
    font-size: 0.9rem;
    cursor: pointer;
    transition: background 0.15s, transform 0.1s;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}
.btn-cp-primary:hover {
    background: var(--cp-yellow-hover);
    transform: translateY(-1px);
}
.btn-cp-primary:active { transform: translateY(0); }

.btn-cp-secondary {
    background: var(--cp-white);
    border: 1px solid var(--cp-border);
    color: var(--cp-muted);
    padding: 9px 22px;
    border-radius: 6px;
    font-weight: 500;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.15s;
}
.btn-cp-secondary:hover {
    border-color: #9ca3af;
    color: var(--cp-text);
}

.btn-cp-delete {
    background: none;
    border: 1px solid var(--cp-border);
    border-radius: 5px;
    padding: 4px 9px;
    cursor: pointer;
    font-size: 0.78rem;
    color: var(--cp-muted);
    transition: all 0.15s;
}
.btn-cp-delete:hover {
    border-color: #dc2626;
    color: #dc2626;
    background: #fef2f2;
}

/* --- Поля ввода --- */
.cp-label {
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--cp-muted);
    text-transform: uppercase;
    letter-spacing: 0.6px;
    margin-bottom: 5px;
    display: block;
}

.cp-input {
    border: 1.5px solid var(--cp-border);
    border-radius: 6px;
    padding: 9px 12px;
    width: 100%;
    font-size: 0.92rem;
    color: var(--cp-text);
    background: var(--cp-white);
    transition: border 0.15s, box-shadow 0.15s;
    font-family: inherit;
}
.cp-input:focus {
    border-color: var(--cp-yellow);
    outline: none;
    box-shadow: 0 0 0 3px rgba(245,197,24,0.2);
}

/* --- Поиск --- */
.cp-search-wrap { position: relative; }
.cp-search-wrap::before {
    content: "🔍";
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 0.82rem;
    pointer-events: none;
}
.cp-search {
    border: 1.5px solid var(--cp-border);
    border-radius: 6px;
    padding: 9px 12px 9px 36px;
    width: 100%;
    max-width: 340px;
    font-size: 0.9rem;
    color: var(--cp-text);
    font-family: inherit;
    transition: border 0.15s, box-shadow 0.15s;
}
.cp-search:focus {
    border-color: var(--cp-yellow);
    outline: none;
    box-shadow: 0 0 0 3px rgba(245,197,24,0.2);
}

/* --- Таблица --- */
.cp-table { width: 100%; border-collapse: collapse; }

.cp-table thead tr { background: var(--cp-dark); color: #fff; }
.cp-table thead th {
    padding: 10px 14px;
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    white-space: nowrap;
}

.cp-table tbody tr {
    border-bottom: 1px solid var(--cp-border);
    transition: background 0.1s;
    cursor: pointer;
}
.cp-table tbody tr:hover { background: #f0f9ff; }
.cp-table tbody td {
    padding: 10px 14px;
    font-size: 0.9rem;
    color: var(--cp-text);
}

/* Активная строка */
.cp-row-active { background: #fffbeb !important; }
.cp-row-active td:first-child {
    border-left: 3px solid var(--cp-yellow);
}

/* --- Бейдж --- */
.cp-badge {
    background: #fefce8;
    color: #92400e;
    border: 1px solid var(--cp-yellow);
    border-radius: 20px;
    padding: 2px 10px;
    font-size: 0.75rem;
    font-weight: 700;
}

/* --- Дата --- */
.cp-date { color: #9ca3af; font-size: 0.8rem; }

/* --- Ошибка --- */
.cp-error {
    background: #fef2f2;
    border-left: 3px solid #dc2626;
    padding: 10px 14px;
    border-radius: 4px;
    color: #991b1b;
    font-size: 0.88rem;
}

/* --- Пустое состояние --- */
.cp-empty {
    text-align: center;
    padding: 48px 24px;
    color: #9ca3af;
    font-size: 0.95rem;
}

/* =============================================
   ПАНЕЛЬ РЕДАКТИРОВАНИЯ МАТЕРИАЛА
   ============================================= */
.cp-edit-panel { margin-bottom: 20px; }

/* --- Секция наценок --- */
.cp-markup-section {
    margin-top: 24px;
    padding-top: 20px;
    border-top: 2px solid var(--cp-yellow);
}

.cp-markup-section-header {
    font-size: 0.78rem;
    font-weight: 700;
    color: var(--cp-text);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}
.cp-markup-section-header small {
    font-size: 0.78rem;
    font-weight: 400;
    color: var(--cp-muted);
    text-transform: none;
    letter-spacing: 0;
}

/* --- Инлайн таблица наценок --- */
.cp-markup-inline-table {
    width: 100%;
    max-width: 460px;
    border-collapse: collapse;
    border: 1px solid var(--cp-border);
    border-radius: 6px;
    overflow: hidden;
}

.cp-markup-inline-table thead tr { background: #f3f4f6; }
.cp-markup-inline-table thead th {
    padding: 8px 12px;
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    color: var(--cp-muted);
    border-bottom: 1px solid var(--cp-border);
}
.cp-markup-inline-table thead th:hover { color: var(--cp-blue); }

.cp-markup-inline-table tbody tr {
    border-bottom: 1px solid var(--cp-border);
    transition: background 0.1s;
}
.cp-markup-inline-table tbody tr:last-child { border-bottom: none; }
.cp-markup-inline-table tbody tr:hover { background: #fffbeb; }
.cp-markup-inline-table tbody td { padding: 5px 8px; }

/* Строка добавления */
.cp-markup-add-row { background: #f9fafb; }
.cp-markup-add-row:hover { background: #f9fafb !important; }

/* Инлайн поле */
.cp-inline-input {
    border: 1.5px solid var(--cp-border);
    border-radius: 5px;
    padding: 5px 9px;
    width: 120px;
    font-size: 0.88rem;
    color: var(--cp-text);
    font-family: inherit;
    background: var(--cp-white);
    transition: border 0.15s;
}
.cp-inline-input:focus {
    border-color: var(--cp-yellow);
    outline: none;
    box-shadow: 0 0 0 2px rgba(245,197,24,0.2);
}

/* Кнопки + и − */
.cp-inline-btn {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: none;
    font-size: 1rem;
    font-weight: 700;
    line-height: 1;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
}
.cp-inline-btn-add {
    background: var(--cp-yellow);
    color: var(--cp-dark);
}
.cp-inline-btn-add:hover {
    background: var(--cp-yellow-hover);
    transform: scale(1.1);
}
.cp-inline-btn-delete {
    background: #f3f4f6;
    color: #9ca3af;
}
.cp-inline-btn-delete:hover {
    background: #fee2e2;
    color: #dc2626;
}

/* =============================================
   ТИП МАТЕРИАЛА — АВТОДОПОЛНЕНИЕ
   ============================================= */

.cp-type-dropdown {
    position: absolute;
    top: calc(100% - 2px);
    left: 0;
    right: 0;
    background: #fff;
    border: 1.5px solid var(--cp-yellow);
    border-top: none;
    border-radius: 0 0 6px 6px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    z-index: 100;
    max-height: 220px;
    overflow-y: auto;
}

.cp-type-option {
    padding: 8px 12px;
    font-size: 0.88rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: background 0.1s;
    white-space: pre;
}

.cp-type-option:hover { background: #fffbeb; }

.cp-type-path {
    font-size: 0.75rem;
    color: #9ca3af;
    margin-left: auto;
    white-space: normal;
    font-weight: 400;
}

/* Выбранный тип — чип */
.cp-type-chip {
    display: inline-flex;
    align-items: center;
    background: #fffbeb;
    border: 1px solid var(--cp-yellow);
    border-radius: 20px;
    padding: 3px 10px;
    font-size: 0.8rem;
    font-weight: 600;
    color: #92400e;
}

/* Маленький чип в таблице */
.cp-type-chip-sm {
    display: inline-block;
    background: #f0f9ff;
    border: 1px solid #bae6fd;
    border-radius: 20px;
    padding: 2px 8px;
    font-size: 0.75rem;
    color: #0369a1;
    font-weight: 500;
}

/* Кнопка очистки типа */
.cp-clear-btn {
    background: none;
    border: none;
    color: #9ca3af;
    cursor: pointer;
    font-size: 0.8rem;
    padding: 2px 4px;
    line-height: 1;
    transition: color 0.15s;
}
.cp-clear-btn:hover { color: #dc2626; }

/* =============================================
   СТАНДАРТНЫЕ РАЗМЕРЫ — СТРОКА ПО УМОЛЧАНИЮ
   ============================================= */

.cp-size-default td:first-child {
    border-left: 3px solid var(--cp-yellow);
}

/* Чекбокс */

/* =============================================
   УРОВНИ ТИПОВ МАТЕРИАЛОВ
   ============================================= */
.cp-level-badge {
    display: inline-block;
    border-radius: 20px;
    padding: 2px 10px;
    font-size: 0.75rem;
    font-weight: 600;
}

.cp-level-1 {
    background: #1a1a2e;
    color: #fff;
}

.cp-level-2 {
    background: #fffbeb;
    color: #92400e;
    border: 1px solid var(--cp-yellow);
}

.cp-level-3 {
    background: #f0f9ff;
    color: #0369a1;
    border: 1px solid #bae6fd;
}

.cp-type-option-disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* Кнопка добавить подтип */

/* Секция в навигации */
.cp-nav-section {
    padding: 16px 16px 4px 16px;
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: 1px;
    color: rgba(255,255,255,0.3);
    text-transform: uppercase;
}

/* =============================================
   ПЕРЕКЛЮЧАТЕЛЬ ЕДИНИЦ ИЗМЕРЕНИЯ
   ============================================= */

.cp-unit-label {
    font-size: 0.68rem;
    font-weight: 600;
    color: #9ca3af;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    white-space: nowrap;
}

.cp-unit-row th {
    background: transparent;
    padding-bottom: 2px;
}

/* =============================================
   ТАБЫ
   ============================================= */
.cp-tabs {
    display: flex;
    border-bottom: 2px solid var(--cp-border);
    margin-bottom: 20px;
    gap: 2px;
}

.cp-tab {
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    padding: 9px 20px;
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--cp-muted);
    cursor: pointer;
    transition: all 0.15s;
    font-family: inherit;
}

.cp-tab:hover { color: var(--cp-dark); }

.cp-tab.active {
    color: var(--cp-dark);
    border-bottom-color: var(--cp-yellow);
}

.cp-tab-body { padding-top: 4px; }

/* =============================================
   ФИЛЬТР ТИПА КОНТРАГЕНТА
   ============================================= */
.cp-type-filter {
    display: inline-flex;
    border: 1.5px solid var(--cp-border);
    border-radius: 6px;
    overflow: hidden;
}

.cp-filter-btn {
    background: #fff;
    border: none;
    border-right: 1px solid var(--cp-border);
    padding: 7px 14px;
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    color: var(--cp-muted);
    transition: all 0.15s;
    font-family: inherit;
}

.cp-filter-btn:last-child { border-right: none; }
.cp-filter-btn:hover { background: #f9fafb; color: var(--cp-dark); }
.cp-filter-btn.active { background: var(--cp-yellow); color: var(--cp-dark); }

/* =============================================
   БЕЙДЖИ ТИПА КОНТРАГЕНТА
   ============================================= */
.cp-ctype-badge {
    display: inline-block;
    border-radius: 20px;
    padding: 2px 10px;
    font-size: 0.75rem;
    font-weight: 600;
}

.cp-ctype-supplier {
    background: #f0fdf4;
    border: 1px solid #86efac;
    color: #166534;
}

.cp-ctype-customer {
    background: #eff6ff;
    border: 1px solid #93c5fd;
    color: #1d4ed8;
}

.cp-ctype-both {
    background: #fffbeb;
    border: 1px solid var(--cp-yellow);
    color: #92400e;
}

/* =============================================
   ПОДВАЛ ТАБЛИЦЫ
   ============================================= */
.cp-table-footer {
    padding: 10px 24px;
    font-size: 0.82rem;
    color: var(--cp-muted);
    border-top: 1px solid var(--cp-border);
    background: #f9fafb;
}

/* =============================================
   СКЛАДСКИЕ ДОКУМЕНТЫ
   ============================================= */

/* Бейджи типа документа */
.cp-doc-type-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    border-radius: 6px;
    padding: 3px 10px;
    font-size: 0.78rem;
    font-weight: 700;
}

.cp-doc-receipt    { background:#f0fdf4; border:1px solid #86efac; color:#166534; }
.cp-doc-writeoff   { background:#fef2f2; border:1px solid #fca5a5; color:#991b1b; }
.cp-doc-processing { background:#fffbeb; border:1px solid #fde047; color:#92400e; }
.cp-doc-transfer   { background:#eff6ff; border:1px solid #93c5fd; color:#1d4ed8; }
.cp-doc-inventory  { background:#f5f3ff; border:1px solid #c4b5fd; color:#6d28d9; }

/* Статус-бейджи */
.cp-status-badge {
    display: inline-block;
    border-radius: 20px;
    padding: 2px 10px;
    font-size: 0.75rem;
    font-weight: 700;
}

.cp-status-draft     { background:#f3f4f6; border:1px solid #d1d5db; color:#6b7280; }
.cp-status-posted    { background:#f0fdf4; border:1px solid #86efac; color:#166534; }
.cp-status-void { background:#fef2f2; border:1px solid #fca5a5; color:#991b1b; }

/* Кнопка Провести */
.btn-cp-post {
    background: #166534;
    border: none;
    color: #fff;
    padding: 9px 22px;
    border-radius: 6px;
    font-weight: 700;
    font-size: 0.9rem;
    cursor: pointer;
    transition: background 0.15s;
    font-family: inherit;
}
.btn-cp-post:hover { background: #14532d; }

/* Кнопка Отменить проведение */
.btn-cp-cancel-doc {
    background: none;
    border: 1.5px solid #fca5a5;
    color: #991b1b;
    padding: 7px 18px;
    border-radius: 6px;
    font-weight: 600;
    font-size: 0.88rem;
    cursor: pointer;
    font-family: inherit;
    transition: all 0.15s;
}
.btn-cp-cancel-doc:hover { background: #fef2f2; }

/* Инфо о проведении */
.cp-posted-info {
    font-size: 0.88rem;
    color: #166534;
    font-weight: 600;
    padding: 8px 12px;
    background: #f0fdf4;
    border-radius: 6px;
    border: 1px solid #86efac;
}

/* Итого документа */
.cp-doc-total {
    margin-top: 12px;
    padding: 10px 16px;
    background: #fffbeb;
    border: 1px solid var(--cp-yellow);
    border-radius: 6px;
    font-size: 0.9rem;
    text-align: right;
    max-width: 820px;
}

/* =============================================
   ПЛОТНОСТЬ С НАДСТРОЧНЫМ ИНДЕКСОМ
   ============================================= */
.cp-density-unit {
    font-size: 0.75rem;
    color: #6b7280;
    font-weight: 500;
    margin-left: 4px;
}

.cp-density-unit sup {
    font-size: 0.6rem;
    vertical-align: super;
    line-height: 0;
}

.cp-density-badge {
    display: inline-flex;
    align-items: baseline;
    gap: 2px;
    background: #f0f9ff;
    border: 1px solid #bae6fd;
    border-radius: 20px;
    padding: 2px 8px;
    font-size: 0.82rem;
    font-weight: 600;
    color: #0369a1;
    white-space: nowrap;
}

.cp-density-badge sup {
    font-size: 0.6rem;
    vertical-align: super;
    line-height: 0;
}

/* Центрирование содержимого th с кнопками */
.cp-markup-inline-table thead th {
    vertical-align: bottom;
    text-align: center;
}

.cp-markup-inline-table thead th:first-child,
.cp-markup-inline-table thead th:last-child {
    width: 36px;
}

/* =============================================
   ДЕРЕВО ТИПОВ МАТЕРИАЛОВ
   ============================================= */
.cp-type-tree {
    padding: 8px 0 16px;
}

/* ── Уровень 1 — Тип ── */
.cp-tree-l1 {
    margin-bottom: 6px;
}

.cp-tree-row-l1 {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px 10px 12px;
    cursor: pointer;
    border-radius: 8px;
    background: #f3f4f6;
    transition: background 0.12s;
    margin: 0 16px;
}

.cp-tree-row-l1:hover { background: #e5e7eb; }

.cp-tree-name-l1 {
    font-size: 1rem;
    font-weight: 700;
    color: #111827;
    flex: 1;
}

/* ── Уровень 2 — Подтип ── */
.cp-tree-l2 {
    margin: 3px 16px 3px 40px;
}

.cp-tree-row-l2 {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 14px 7px 10px;
    cursor: pointer;
    border-radius: 7px;
    background: #eff6ff;
    transition: background 0.12s;
}

.cp-tree-row-l2:hover { background: #dbeafe; }

.cp-tree-name-l2 {
    font-size: 0.9rem;
    font-weight: 600;
    color: #1e40af;
    flex: 1;
}

.cp-tree-indent-l2 {
    color: #93c5fd;
    font-size: 0.85rem;
}

/* ── Уровень 3 — Вид ── */
.cp-tree-l3 {
    margin: 2px 16px 2px 68px;
}

.cp-tree-row-l3 {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 5px 12px 5px 10px;
    cursor: pointer;
    border-radius: 6px;
    background: #f0fdf4;
    transition: background 0.12s;
}

.cp-tree-row-l3:hover { background: #dcfce7; }

.cp-tree-name-l3 {
    font-size: 0.85rem;
    font-weight: 500;
    color: #166534;
    flex: 1;
}

.cp-tree-indent-l3 {
    color: #86efac;
    font-size: 0.8rem;
}

/* ── Общее ── */
.cp-tree-toggle {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 0.65rem;
    color: #9ca3af;
    padding: 2px 4px;
    min-width: 18px;
    transition: color 0.12s;
}
.cp-tree-toggle:hover { color: #374151; }

.cp-tree-toggle-spacer { display: inline-block; min-width: 18px; }

.cp-tree-path {
    font-size: 0.72rem;
    color: #9ca3af;
}

.cp-tree-actions {
    display: flex;
    align-items: center;
    gap: 4px;
    opacity: 0;
    transition: opacity 0.15s;
}

.cp-tree-row-l1:hover .cp-tree-actions,
.cp-tree-row-l2:hover .cp-tree-actions,
.cp-tree-row-l3:hover .cp-tree-actions { opacity: 1; }

.cp-row-active-inline > .cp-tree-row-l1,
.cp-row-active-inline > .cp-tree-row-l2,
.cp-row-active-inline > .cp-tree-row-l3 {
    background: #fffbeb !important;
    outline: 2px solid var(--cp-yellow);
}

.cp-row-active-inline .cp-tree-actions { opacity: 1; }

/* ── Кнопки + добавить подтип/вид ── */
.cp-tree-add-btn {
    border: none;
    border-radius: 50%;
    width: 22px;
    height: 22px;
    font-size: 0.85rem;
    font-weight: 700;
    line-height: 1;
    cursor: pointer;
    transition: all 0.15s;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Кнопка + у уровня 1 → создаёт подтип (синий) */
.cp-tree-add-l2 {
    background: #dbeafe;
    color: #1d4ed8;
}
.cp-tree-add-l2:hover {
    background: #3b82f6;
    color: #fff;
}

/* Кнопка + у уровня 2 → создаёт вид (зелёный) */
.cp-tree-add-l3 {
    background: #dcfce7;
    color: #166534;
}
.cp-tree-add-l3:hover {
    background: #22c55e;
    color: #fff;
}

/* =============================================
   ФИНАНСОВЫЕ СЧЕТА
   ============================================= */
.cp-acc-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 16px;
    padding: 16px 24px;
}

.cp-acc-card {
    border: 1.5px solid #e5e7eb;
    border-radius: 12px;
    padding: 16px;
    cursor: pointer;
    transition: all 0.15s;
    background: #fff;
    position: relative;
}

.cp-acc-card:hover { border-color: #d1d5db; box-shadow: 0 2px 8px rgba(0,0,0,0.06); transform: translateY(-1px); }
.cp-acc-card-active { border-color: var(--cp-yellow) !important; background: #fffbeb; }
.cp-acc-card-archived { opacity: 0.5; }

.cp-acc-card-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
}

.cp-acc-icon { font-size: 1.6rem; line-height: 1; }
.cp-acc-icon-lg { font-size: 1.8rem; }

.cp-acc-name {
    font-weight: 700;
    font-size: 0.95rem;
    color: #111827;
    line-height: 1.2;
}

.cp-acc-type {
    font-size: 0.75rem;
    color: #9ca3af;
    margin-top: 1px;
}

.cp-acc-balance {
    font-size: 1.5rem;
    font-weight: 800;
    color: #111827;
    letter-spacing: -0.5px;
}

.cp-acc-balance-neg { color: #dc2626; }

.cp-acc-note {
    font-size: 0.75rem;
    color: #9ca3af;
    margin-top: 6px;
}

.cp-acc-archived-badge {
    position: absolute;
    top: 10px;
    right: 10px;
    font-size: 0.68rem;
    background: #f3f4f6;
    border: 1px solid #d1d5db;
    color: #6b7280;
    border-radius: 4px;
    padding: 1px 6px;
}

.cp-acc-total {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 8px;
    padding: 12px 24px;
    border-top: 1px solid #f3f4f6;
    font-size: 0.9rem;
    color: #6b7280;
}

.cp-acc-total strong {
    font-size: 1.1rem;
    color: #111827;
}

/* Поле с префиксом валюты */
.cp-input-prefix-wrap {
    position: relative;
    display: flex;
    align-items: center;
}

.cp-input-prefix {
    position: absolute;
    left: 12px;
    font-size: 0.9rem;
    color: #6b7280;
    font-weight: 600;
    pointer-events: none;
    z-index: 1;
}

.cp-input-prefixed { padding-left: 26px !important; }

/* =============================================
   КАТЕГОРИИ ФИНАНСОВ
   ============================================= */
.cp-cat-group-header {
    font-size: 0.72rem;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    padding: 6px 24px 4px;
    color: #9ca3af;
}

.cp-cat-group-income  { color: #16a34a; }
.cp-cat-group-expense { color: #dc2626; }

.cp-dir-badge {
    display: inline-block;
    border-radius: 20px;
    padding: 2px 10px;
    font-size: 0.75rem;
    font-weight: 700;
}

.cp-dir-income   { background: #f0fdf4; border: 1px solid #86efac; color: #166534; }
.cp-dir-expense  { background: #fef2f2; border: 1px solid #fca5a5; color: #991b1b; }
.cp-dir-transfer { background: #eff6ff; border: 1px solid #93c5fd; color: #1d4ed8; }

/* =============================================
   ТРАНЗАКЦИИ
   ============================================= */
.cp-dir-selector {
    display: flex;
    gap: 8px;
}

.cp-dir-btn {
    flex: 1;
    padding: 10px 16px;
    border: 2px solid #e5e7eb;
    border-radius: 8px;
    background: #f9fafb;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
    color: #6b7280;
}

.cp-dir-btn:hover { background: #f3f4f6; border-color: #d1d5db; }

.cp-dir-btn.active-income  { background: #f0fdf4; border-color: #22c55e; color: #166534; }
.cp-dir-btn.active-expense { background: #fef2f2; border-color: #ef4444; color: #991b1b; }
.cp-dir-btn.active-transfer { background: #eff6ff; border-color: #3b82f6; color: #1d4ed8; }

.cp-amount-input {
    font-size: 1.1rem;
    font-weight: 700;
}

.cp-txn-summary {
    display: flex;
    gap: 1px;
    background: #f3f4f6;
    border-top: 1px solid #f3f4f6;
    border-bottom: 1px solid #f3f4f6;
}

.cp-txn-sum-item {
    flex: 1;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 20px;
    background: #fff;
    font-size: 0.85rem;
    color: #6b7280;
}

.cp-txn-sum-item strong { font-size: 1rem; font-weight: 800; }
.cp-txn-sum-income strong  { color: #16a34a; }
.cp-txn-sum-expense strong { color: #dc2626; }

.cp-pos { color: #16a34a; }
.cp-neg { color: #dc2626; }

/* Статусы транзакций */
.cp-status-completed { background: #f0fdf4; border: 1px solid #86efac; color: #166534; }
.cp-status-pending   { background: #fffbeb; border: 1px solid #fcd34d; color: #92400e; }
.cp-status-cancelled { background: #f9fafb; border: 1px solid #d1d5db; color: #9ca3af; }

/* =============================================
   ДАШБОРД
   ============================================= */
.cp-dashboard {
    padding: 0;
}

.cp-dash-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px 16px;
    background: #fff;
    border-radius: 12px;
    border: 1px solid #e5e7eb;
    margin-bottom: 16px;
}

.cp-kpi-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
    margin-bottom: 16px;
}

.cp-kpi-card {
    border-radius: 12px;
    padding: 18px 20px;
    border: 1.5px solid transparent;
}

.cp-kpi-income  { background: #f0fdf4; border-color: #86efac; }
.cp-kpi-expense { background: #fef2f2; border-color: #fca5a5; }
.cp-kpi-profit  { background: #f0fdf4; border-color: #4ade80; }
.cp-kpi-loss    { background: #fef2f2; border-color: #f87171; }
.cp-kpi-balance { background: #eff6ff; border-color: #93c5fd; }

.cp-kpi-label {
    font-size: 0.75rem;
    font-weight: 700;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 6px;
}

.cp-kpi-value {
    font-size: 1.6rem;
    font-weight: 800;
    color: #111827;
    letter-spacing: -0.5px;
    line-height: 1.1;
}

.cp-kpi-sub {
    font-size: 0.75rem;
    color: #9ca3af;
    margin-top: 4px;
}

.cp-dash-row {
    display: flex;
    gap: 12px;
    margin-bottom: 16px;
    align-items: flex-start;
}

.cp-dash-block {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 18px 20px;
}

.cp-dash-block-title {
    font-size: 0.82rem;
    font-weight: 800;
    color: #374151;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 14px;
}

/* Прогресс-бар для баланса счетов */
.cp-acc-balance-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
}

.cp-progress-bar {
    height: 8px;
    background: #f3f4f6;
    border-radius: 4px;
    overflow: hidden;
    width: 100%;
}

.cp-progress-fill {
    height: 100%;
    border-radius: 4px;
    transition: width 0.4s ease;
    min-width: 2px;
}

/* Бар-чарт по категориям */
.cp-cat-bar-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}

.cp-cat-bar-label {
    font-size: 0.8rem;
    color: #374151;
    min-width: 120px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.cp-cat-bar-track {
    flex: 1;
    height: 10px;
    background: #f3f4f6;
    border-radius: 5px;
    overflow: hidden;
}

.cp-cat-bar-fill {
    height: 100%;
    border-radius: 5px;
    transition: width 0.4s ease;
    min-width: 3px;
    opacity: 0.85;
}

.cp-cat-bar-value {
    font-size: 0.78rem;
    font-weight: 700;
    color: #374151;
    min-width: 80px;
    text-align: right;
    white-space: nowrap;
}

@media (max-width: 1100px) {
    .cp-kpi-grid  { grid-template-columns: repeat(2, 1fr); }
    .cp-dash-row  { flex-direction: column; }
}

/* =============================================
   ДИАЛОГ ПОДТВЕРЖДЕНИЯ УДАЛЕНИЯ
   ============================================= */
.cp-confirm-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.45);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: cp-fade-in 0.12s ease;
}

@keyframes cp-fade-in {
    from { opacity: 0; }
    to   { opacity: 1; }
}

.cp-confirm-box {
    background: #fff;
    border-radius: 16px;
    padding: 32px 36px;
    max-width: 400px;
    width: 90%;
    box-shadow: 0 20px 60px rgba(0,0,0,0.2);
    text-align: center;
    animation: cp-slide-up 0.15s ease;
}

@keyframes cp-slide-up {
    from { transform: translateY(16px); opacity: 0; }
    to   { transform: translateY(0);    opacity: 1; }
}

.cp-confirm-icon {
    font-size: 2.4rem;
    margin-bottom: 12px;
}

.cp-confirm-title {
    font-size: 1.1rem;
    font-weight: 800;
    color: #111827;
    margin-bottom: 8px;
}

.cp-confirm-message {
    font-size: 0.88rem;
    color: #6b7280;
    margin-bottom: 24px;
    line-height: 1.5;
}

.cp-confirm-actions {
    display: flex;
    gap: 10px;
    justify-content: center;
}

.btn-cp-danger {
    background: #dc2626;
    color: #fff;
    border: none;
    border-radius: 8px;
    padding: 9px 22px;
    font-size: 0.88rem;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.15s;
}

.btn-cp-danger:hover { background: #b91c1c; }

/* =============================================
   ЗАКАЗЫ КЛИЕНТОВ
   ============================================= */
.cp-order-status-badge {
    display: inline-block;
    border-radius: 20px;
    padding: 3px 12px;
    font-size: 0.78rem;
    font-weight: 700;
    white-space: nowrap;
}

.cp-order-new          { background: #eff6ff; border: 1px solid #93c5fd; color: #1d4ed8; }
.cp-order-confirmed    { background: #f0fdf4; border: 1px solid #86efac; color: #166534; }
.cp-order-inproduction { background: #fef3c7; border: 1px solid #fcd34d; color: #92400e; }
.cp-order-ready        { background: #ecfdf5; border: 1px solid #6ee7b7; color: #065f46; }
.cp-order-shipped      { background: #f5f3ff; border: 1px solid #c4b5fd; color: #5b21b6; }
.cp-order-paid         { background: #f0fdf4; border: 1px solid #4ade80; color: #14532d; }
.cp-order-cancelled    { background: #f9fafb; border: 1px solid #d1d5db; color: #9ca3af; }

.cp-row-overdue { background: #fff7f7 !important; }
.cp-overdue-text { color: #dc2626; font-weight: 600; }

.cp-order-totals {
    margin-top: 12px;
    border-top: 2px solid #f3f4f6;
    padding-top: 10px;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 4px;
}

.cp-order-total-row {
    display: flex;
    gap: 24px;
    font-size: 0.88rem;
    color: #6b7280;
    min-width: 280px;
    justify-content: space-between;
}

.cp-order-total-main {
    font-size: 1rem;
    color: #111827;
    border-top: 1px solid #e5e7eb;
    padding-top: 6px;
    margin-top: 2px;
}

.cp-success {
    background: #f0fdf4;
    border: 1px solid #86efac;
    color: #166534;
    border-radius: 8px;
    padding: 10px 14px;
    font-size: 0.88rem;
}

/* =============================================
   ПОЛОСКИ ОПЛАТЫ И ОТГРУЗКИ
   ============================================= */
.cp-order-bars {
    display: flex;
    flex-direction: column;
    gap: 14px;
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    padding: 14px 18px;
    margin-bottom: 16px;
}

.cp-order-bar-row { display: flex; flex-direction: column; gap: 6px; }

.cp-order-bar-label {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.82rem;
    font-weight: 700;
    color: #374151;
}

.cp-order-bar-nums {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.85rem;
}

.cp-bar-track {
    height: 10px;
    background: #e5e7eb;
    border-radius: 5px;
    overflow: hidden;
}

.cp-bar-fill {
    height: 100%;
    border-radius: 5px;
    transition: width 0.4s ease;
    min-width: 0;
}

.cp-bar-paid { background: linear-gradient(90deg, #22c55e, #16a34a); }
.cp-bar-ship { background: linear-gradient(90deg, #a78bfa, #7c3aed); }

.cp-bar-done {
    background: #f0fdf4;
    border: 1px solid #86efac;
    color: #166534;
    border-radius: 10px;
    padding: 1px 8px;
    font-size: 0.72rem;
    font-weight: 700;
}

/* Мини-полоски в таблице */
.cp-mini-bar-wrap {
    display: flex;
    flex-direction: column;
    gap: 3px;
    min-width: 160px;
}

.cp-mini-bar-track {
    height: 6px;
    background: #e5e7eb;
    border-radius: 3px;
    overflow: hidden;
}

.cp-mini-bar-fill {
    height: 100%;
    border-radius: 3px;
    transition: width 0.3s ease;
    min-width: 0;
}

.cp-mini-bar-label {
    font-size: 0.72rem;
    color: #6b7280;
    white-space: nowrap;
}

/* Статус-бейджи — обновлённые */
.cp-order-confirming { background: #fef3c7; border: 1px solid #fcd34d; color: #92400e; }
.cp-order-completed  { background: #f0fdf4; border: 1px solid #4ade80; color: #14532d; }

/* ═══════════════════════════════════════════════
   INLINE EDITOR ROW (вставляется под активной строкой)
   ══════════════════════════════════════════════ */
.cp-inline-editor-row td {
    background: transparent !important;
    border: none !important;
    padding: 0 !important;
}

.cp-inline-editor {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.55s cubic-bezier(0.4, 0, 0.2, 1),
                opacity 0.45s ease,
                transform 0.45s ease;
    opacity: 0;
    transform: translateY(-10px);
}

.cp-inline-editor.cp-inline-editor-open {
    max-height: 2400px;
    opacity: 1;
    transform: translateY(0);
    transition: max-height 0.55s cubic-bezier(0, 0, 0.2, 1),
                opacity 0.4s ease,
                transform 0.4s ease;
}

.cp-inline-editor-inner {
    background: #fff;
    border: 2px solid #6366f1;
    border-top: 3px solid #6366f1;
    border-radius: 0 0 12px 12px;
    padding: 20px 24px 24px;
    margin: 0 4px 8px;
    box-shadow: 0 8px 32px rgba(99, 102, 241, 0.12), 0 2px 8px rgba(0,0,0,0.07);
    position: relative;
}

/* Стрелка указатель на активную строку */
.cp-inline-editor-arrow {
    position: absolute;
    top: -10px;
    left: 48px;
    width: 0;
    height: 0;
    border-left: 10px solid transparent;
    border-right: 10px solid transparent;
    border-bottom: 10px solid #6366f1;
}

.cp-inline-editor-arrow::after {
    content: '';
    position: absolute;
    top: 2px;
    left: -9px;
    width: 0;
    height: 0;
    border-left: 9px solid transparent;
    border-right: 9px solid transparent;
    border-bottom: 9px solid #fff;
}

/* Активная строка таблицы при открытом редакторе */
tr.cp-row-active td {
    background: #eef2ff !important;
    border-bottom: none;
}

/* Единицы измерения прямо в заголовке таблицы */
.cp-unit-switcher {
    display: flex;
    gap: 2px;
    flex-wrap: nowrap;
    margin-top: 2px;
}

.cp-unit-btn {
    padding: 3px 9px;
    font-size: 0.72rem;
    font-weight: 700;
    border: 1px solid var(--cp-border);
    background: #fff;
    color: var(--cp-muted);
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.15s;
    line-height: 1.5;
    white-space: nowrap;
    letter-spacing: 0.3px;
}

.cp-unit-btn:hover {
    background: #fffbeb;
    border-color: var(--cp-yellow);
    color: var(--cp-dark);
}

.cp-unit-btn.active {
    background: var(--cp-yellow);
    border-color: #d97706;
    color: var(--cp-dark);
    box-shadow: 0 1px 3px rgba(217,119,6,0.2);
}

/* ── Список оплат / накладных в заказе ── */
.cp-payment-list {
    margin-top: 6px;
}

.cp-payment-list-toggle {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    font-size: 0.78rem;
    font-weight: 600;
    color: #166534;
    background: #f0fdf4;
    border: 1px solid #86efac;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.15s;
}

.cp-payment-list-toggle:hover {
    background: #dcfce7;
}

.cp-payment-chevron {
    font-size: 0.65rem;
    opacity: 0.7;
}

.cp-payment-items {
    margin-top: 4px;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    overflow: hidden;
}

.cp-payment-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 7px 12px;
    font-size: 0.8rem;
    border-bottom: 1px solid #f3f4f6;
    flex-wrap: wrap;
}

.cp-payment-item:last-child {
    border-bottom: none;
}

.cp-payment-item:nth-child(even) {
    background: #f9fafb;
}

.cp-payment-date {
    color: #9ca3af;
    font-size: 0.75rem;
    white-space: nowrap;
    min-width: 100px;
}

.cp-payment-amount {
    font-weight: 700;
    white-space: nowrap;
}

.cp-payment-account {
    color: #374151;
    font-weight: 500;
}

.cp-payment-desc {
    color: #9ca3af;
    font-size: 0.75rem;
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Список — по умолчанию на всю ширину */
.cp-splitview-list {
    flex: 1 1 auto;
    min-width: 0;
}

/* Когда редактор открыт — список фиксируется в 300px */
.cp-splitview-open .cp-splitview-list {
    flex: 0 0 300px;
    width: 300px;
    min-width: 300px;
    max-width: 300px;
}

/* Панель редактора */
.cp-splitview-panel {
    flex: 1 1 auto;
    min-width: 0;
    position: sticky;
    top: 16px;
    max-height: calc(100vh - 32px);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

/* ── Компонент StockDocumentEditor ── */
.cp-doc-editor {
    display: flex;
    flex-direction: column;
    height: 100%;
    max-height: calc(100vh - 32px);
    background: #fff;
    border: 1px solid var(--cp-border);
    border-radius: 12px;
    overflow: hidden;
    animation: cp-editor-in 0.22s cubic-bezier(0.2, 0, 0.2, 1);
}

@keyframes cp-editor-in {
    from { opacity: 0; transform: translateX(20px); }
    to   { opacity: 1; transform: translateX(0); }
}

.cp-doc-editor-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 12px 18px;
    background: var(--cp-dark);
    color: #fff;
    flex-shrink: 0;
}

.cp-doc-editor-body {
    flex: 1 1 auto;
    overflow-y: auto;
    padding: 18px 20px;
}

.cp-doc-editor-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    padding-top: 14px;
    margin-top: 10px;
    border-top: 1px solid var(--cp-border);
}

/* Итог в таблице строк */
.cp-inline-total {
    text-align: right;
    padding: 7px 12px;
    font-size: 0.88rem;
    background: #fffbeb;
    border-top: 2px solid var(--cp-yellow);
    border-radius: 0 0 6px 6px;
}

/* ═══════════════════════════════════════════════
   СКЛАДСКИЕ ДОКУМЕНТЫ — оверлей-редактор
   ═══════════════════════════════════════════════ */

/* Обёртка страницы */
.cp-sdoc-wrap {
    position: relative;
}

/* Полупрозрачная подложка */
.cp-sdoc-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.18);
    z-index: 100;
    cursor: pointer;
    animation: cp-fade-in 0.18s ease;
}

@keyframes cp-fade-in {
    from { opacity: 0; }
    to   { opacity: 1; }
}

/* Панель редактора — фиксированная справа */
.cp-sdoc-panel {
    position: fixed;
    top: 0;
    right: 0;
    width: 62%;
    max-width: 860px;
    height: 100vh;
    z-index: 101;
    display: flex;
    flex-direction: column;
    animation: cp-slide-in 0.24s cubic-bezier(0.2, 0, 0.2, 1);
}

@keyframes cp-slide-in {
    from { transform: translateX(40px); opacity: 0; }
    to   { transform: translateX(0);    opacity: 1; }
}

/* ── Сам компонент редактора ── */
.cp-doc-editor {
    display: flex;
    flex-direction: column;
    height: 100%;
    background: #fff;
    border-left: 3px solid var(--cp-yellow);
    box-shadow: -6px 0 32px rgba(0, 0, 0, 0.18);
    overflow: hidden;
}

.cp-doc-editor-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 14px 20px;
    background: var(--cp-dark);
    color: #fff;
    flex-shrink: 0;
}

.cp-doc-editor-body {
    flex: 1 1 auto;
    overflow-y: auto;
    padding: 20px 24px;
}

.cp-doc-editor-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    padding-top: 14px;
    margin-top: 10px;
    border-top: 1px solid var(--cp-border);
}

/* Итог таблицы строк */
.cp-inline-total {
    text-align: right;
    padding: 7px 12px;
    font-size: 0.88rem;
    background: #fffbeb;
    border-top: 2px solid var(--cp-yellow);
    border-radius: 0 0 6px 6px;
}

/* ── Секции документа (переработка/инвентаризация) ── */
.cp-doc-section {
    margin-top: 12px;
}

.cp-doc-section-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.8rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    padding: 7px 12px;
    border-radius: 6px 6px 0 0;
    border: 1px solid;
    border-bottom: none;
    margin-bottom: 0;
}

.cp-doc-section-title small {
    font-weight: 400;
    text-transform: none;
    letter-spacing: 0;
    font-size: 0.75rem;
    opacity: 0.75;
}

.cp-doc-section-input {
    background: #fff7ed;
    border-color: #fed7aa;
    color: #c2410c;
}

.cp-doc-section-output {
    background: #f0fdf4;
    border-color: #86efac;
    color: #166534;
}

.cp-doc-section .cp-markup-inline-table {
    border-radius: 0 0 6px 6px;
    border: 1px solid #e5e7eb;
}

/* ── Формы контрагентов ── */
.cp-form-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 0.75rem;
    font-weight: 600;
    white-space: nowrap;
}

.cp-form-legal {
    background: #eff6ff;
    border: 1px solid #93c5fd;
    color: #1d4ed8;
}

.cp-form-person {
    background: #f5f3ff;
    border: 1px solid #c4b5fd;
    color: #5b21b6;
}

/* ═══════════════════════════════════════════════
   3-ПАНЕЛЬНЫЙ LAYOUT (оборудование и аналоги)
   Порядок: [Список] → [Панель функции] → [Панель оборудования]
   Панель оборудования всегда прижата к правому краю.
   Панель функции появляется ЛЕВЕЕ панели оборудования.
   ═══════════════════════════════════════════════ */

.cp-triple-wrap {
    display: flex;
    flex-direction: row;
    height: calc(100vh - 80px);
    overflow: hidden;
    position: relative;
}

/* ── Список — занимает всё свободное место слева ── */
.cp-triple-list {
    flex: 1 1 auto;
    min-width: 160px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transition: flex 0.25s ease, min-width 0.25s ease;
}

/* Когда открыт хотя бы один редактор — список сужается до min */
.cp-triple-list-narrow {
    flex: 0 0 200px;
    min-width: 160px;
    max-width: 220px;
}

.cp-triple-list .cp-card {
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
    border-radius: 0;
    border-right: 2px solid var(--cp-border);
}

/* ── CSS-переменные для ширин панелей (управляются JS) ── */
:root {
    --cp-panel-main-w: 880px;
    --cp-panel-func-w: 560px;
    --cp-panel-tech-w: 860px;
}

/* ── Панели оборудования — фиксированы к правому краю ── */
.cp-triple-panel {
    position: fixed;
    top: 0;
    height: 100vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.cp-triple-panel .cp-doc-editor {
    height: 100%;
    display: flex;
    flex-direction: column;
}

.cp-triple-panel .cp-doc-editor-body {
    flex: 1;
    overflow-y: auto;
}

/* ── Панель оборудования — прижата к правому краю, z-index:101 ── */
.cp-triple-panel-main {
    right: 0;
    width: var(--cp-panel-main-w);
    background: #fff;
    border-left: 2px solid var(--cp-border);
    box-shadow: -6px 0 32px rgba(0, 0, 0, 0.14);
    z-index: 101;
    animation: cp-slide-in 0.22s cubic-bezier(0.2, 0, 0.2, 1);
}

/* Панель функции сдвигается вместе с основной */
.cp-triple-panel-func {
    right: var(--cp-panel-main-w);
    width: var(--cp-panel-func-w);
    background: #fff;
    border-left: 3px solid var(--cp-yellow);
    box-shadow: -6px 0 24px rgba(0, 0, 0, 0.12);
    z-index: 102;
    animation: cp-slide-in 0.22s cubic-bezier(0.2, 0, 0.2, 1);
}

/* Панель расходников — слева от панели оборудования */
.cp-triple-panel-cons {
    right: var(--cp-panel-main-w);
    width: var(--cp-panel-func-w);
    background: #fff;
    border-left: 3px solid #f59e0b;
    box-shadow: -6px 0 24px rgba(0, 0, 0, 0.12);
    z-index: 102;
    animation: cp-slide-in 0.22s cubic-bezier(0.2, 0, 0.2, 1);
}

/* ── Ручка изменения ширины панели ── */
.cp-resize-handle {
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    width: 6px;
    cursor: ew-resize;
    z-index: 10;
    background: transparent;
    transition: background 0.15s;
    flex-shrink: 0;
}
.cp-resize-handle:hover,
.cp-resize-handle:active {
    background: rgba(232, 184, 0, 0.30);
}
body.cp-resizing {
    cursor: ew-resize !important;
    user-select: none !important;
}
body.cp-resizing * {
    pointer-events: none !important;
}
body.cp-resizing .cp-resize-handle {
    pointer-events: auto !important;
}

/* Технологии: панель с переменной шириной */
.cp-sdoc-panel-resizable {
    width: var(--cp-panel-tech-w) !important;
    max-width: 92vw !important;
}

.cp-consumable-type-panel-resizable {
    width: var(--cp-panel-consumable-w, 520px) !important;
    max-width: 92vw !important;
}

.cp-mfr-suggestion:hover {
    background: #f9fafb;
}

/* ── Backdrop оборудования — под обеими панелями ── */
.cp-equip-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.18);
    z-index: 100;
    animation: cp-fade-in 0.18s ease;
}

/* ── Badge-счётчик в табах ── */
.cp-badge-sm {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 9px;
    background: rgba(255, 255, 255, 0.2);
    color: inherit;
    font-size: 0.72rem;
    font-weight: 700;
    margin-left: 4px;
}

.cp-tab.active .cp-badge-sm {
    background: var(--cp-yellow);
    color: var(--cp-dark);
}

