/* ============================================================================
 * Dashboard: единый mobile-first вью, БЕЗ inner-scroll.
 * Страница скроллится естественно. На широких экранах карточки — в 2–3 колонки.
 * ==========================================================================*/

/* --- Toolbar --- */
.toolbar {
    display: flex;
    flex-direction: row;
    align-items: stretch;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 12px;
}
.toolbar__search-wrap { position: relative; display: flex; align-items: center; flex: 1 1 260px; min-width: 0; }
.toolbar__search-ic {
    position: absolute; left: 12px; width: 16px; height: 16px;
    color: var(--muted); pointer-events: none;
}
.toolbar__search {
    width: 100%;
    padding: 12px 14px 12px 36px;
    border: 1px solid var(--border);
    border-radius: 10px;
    font: inherit;
    background: var(--card-bg);
    color: var(--text);
    min-height: var(--tap);
}
.toolbar__search:focus { outline: 2px solid var(--accent); outline-offset: -2px; }
.toolbar__add {
    flex: 0 0 auto;
    padding: 12px 16px;
    white-space: nowrap;
}

/* Кнопки-триггеры фильтров в тулбаре */
.filterbtn {
    display: inline-flex; align-items: center; gap: 6px;
    flex: 0 0 auto; min-height: var(--tap);
    padding: 10px 12px;
    border: 1px solid var(--border); border-radius: 10px;
    background: var(--card-bg); color: var(--text);
    font: inherit; font-size: 13px; font-weight: 600;
    cursor: pointer; white-space: nowrap;
    transition: border-color 120ms ease, color 120ms ease;
}
.filterbtn:hover { border-color: var(--accent); }
.filterbtn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.filterbtn.is-active { border-color: var(--accent); color: var(--accent); }
.filterbtn__badge {
    display: inline-grid; place-items: center;
    min-width: 18px; height: 18px; padding: 0 5px;
    border-radius: 999px; background: var(--accent); color: var(--accent-fg);
    font-size: 11px; font-weight: 700;
}
.filterbtn__badge[hidden] { display: none; }
.filterbtn__chev { width: 14px; height: 14px; opacity: .7; transition: transform 120ms ease; }
.filterbtn[aria-expanded="true"] .filterbtn__chev { transform: rotate(180deg); }

/* --- Stats --- */
.stats-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 8px;
    margin-bottom: 12px;
}
.stat {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 10px 12px;
    display: flex; flex-direction: column; gap: 2px;
    min-height: 60px; justify-content: center;
}
.stat--status { background: var(--st-bg); color: var(--st-fg); border-color: transparent; }
.stat__num   { font-size: 22px; font-weight: 700; line-height: 1; }
.stat__label { font-size: 12px; opacity: 0.9; display: inline-flex; align-items: center; gap: 4px; }

/* --- Cards (единственный вью, mobile-first + multi-column на широких) --- */
.cards {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
}
@media (min-width: 760px)  { .cards { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (min-width: 1120px) { .cards { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (min-width: 1480px) { .cards { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
/* При переключении вида скрываем сетку карточек (иначе display:grid перебивает [hidden]) */
.cards[hidden] { display: none; }

/* ============================================================================
 * Токены статусов — единый источник цвета для плиток, легенды и статистики.
 * Класс .st-<code> задаёт --st-bg / --st-fg / --st-dot; в тёмной теме —
 * приглушённые фоны, чтобы не выбиваться из dark-палитры.
 * ==========================================================================*/
.st-pending      { --st-bg: #f3f4f6; --st-fg: #4b5563; --st-dot: #9ca3af; }
.st-in_progress  { --st-bg: #dbeafe; --st-fg: #1d4ed8; --st-dot: #1d4ed8; }
.st-submitted    { --st-bg: #fef3c7; --st-fg: #a16207; --st-dot: #d97706; }
.st-received     { --st-bg: #dcfce7; --st-fg: #166534; --st-dot: #16a34a; }
.st-not_required { --st-bg: #e5e7eb; --st-fg: #4b5563; --st-dot: #6b7280; }
.st-rejected     { --st-bg: #fee2e2; --st-fg: #991b1b; --st-dot: #dc2626; }

@media (prefers-color-scheme: dark) {
    .st-pending      { --st-bg: #1c2537;                --st-fg: #9aa4b2; --st-dot: #6b7688; }
    .st-in_progress  { --st-bg: rgba(59, 130, 246, .18); --st-fg: #93c5fd; --st-dot: #60a5fa; }
    .st-submitted    { --st-bg: rgba(217, 119, 6, .18);  --st-fg: #fcd34d; --st-dot: #f59e0b; }
    .st-received     { --st-bg: rgba(22, 163, 74, .20);   --st-fg: #86efac; --st-dot: #4ade80; }
    .st-not_required { --st-bg: rgba(148, 163, 184, .16); --st-fg: #cbd5e1; --st-dot: #94a3b8; }
    .st-rejected     { --st-bg: rgba(220, 38, 38, .20);   --st-fg: #fca5a5; --st-dot: #f87171; }
}

/* Иконка статуса (inline-svg из спрайта) */
.st-ic {
    width: 13px; height: 13px;
    flex: 0 0 auto;
    fill: none;
    stroke: currentColor;
    stroke-width: 2.25;
    stroke-linecap: round;
    stroke-linejoin: round;
    vertical-align: -2px;
}
.st-chip {
    width: 20px; height: 20px;
    flex: 0 0 auto;
    display: grid; place-items: center;
    border-radius: 6px;
    background: var(--st-bg);
    color: var(--st-fg);
}
.st-chip .st-ic { width: 12px; height: 12px; vertical-align: 0; }

.obj-card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-left: 4px solid var(--border);
    border-radius: var(--radius);
    padding: 12px;
    display: flex; flex-direction: column; gap: 10px;
    min-width: 0;
    box-shadow: var(--shadow-sm);
    transition: border-color 120ms ease, box-shadow 160ms ease, transform 160ms ease;
}
.obj-card { cursor: pointer; }
.obj-card:hover {
    border-color: color-mix(in oklab, var(--accent) 30%, var(--border));
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}
.obj-card:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.obj-card--ok  { border-left-color: #16a34a; }
.obj-card--bad { border-left-color: #dc2626; box-shadow: 0 0 0 1px rgba(220, 38, 38, 0.15); }
.obj-card--wip { border-left-color: #1d4ed8; }
/* Внутри плиток и кнопки редактирования курсор возвращаем в pointer явно — они интерактивны */
.obj-card .tile, .obj-card .btn-icon, .obj-card__expander { cursor: pointer; }
.obj-card--ok  .obj-card__shifr::before  { content: "✔ "; color: #16a34a; }
.obj-card--bad .obj-card__shifr::before  { content: "⚠ "; color: #dc2626; }
.obj-card__head {
    display: flex; justify-content: space-between; align-items: flex-start; gap: 8px;
    min-height: 62px;
}
.obj-card__title { min-width: 0; flex: 1 1 auto; }
.obj-card__right { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; flex: 0 0 auto; }
.btn-icon {
    min-width: 32px; min-height: 32px;
    padding: 2px 6px;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--muted);
    cursor: pointer;
    font-size: 16px;
    line-height: 1;
    transition: filter 100ms ease, color 100ms ease;
}
.btn-icon:hover, .btn-icon:focus-visible { color: var(--accent); border-color: var(--accent); outline: none; }
.obj-card__shifr {
    font-weight: 700; font-size: 15px;
    line-height: 1.2;
    /* одна строка + ellipsis */
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.obj-card__name {
    font-size: 13px; color: var(--muted); margin-top: 2px;
    line-height: 1.35;
    /* ровно 2 строки максимум */
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    min-height: calc(1.35em * 2);
}
/* Мета-раскладка (definition list): 4 строки фиксированной высоты для одинакового размера карточек */
.obj-card__meta {
    margin: 0;
    padding: 8px 0;
    border-top: 1px dashed var(--border);
    border-bottom: 1px dashed var(--border);
    display: flex; flex-direction: column;
    gap: 4px;
    font-size: 12px;
    color: var(--text);
}
.obj-card__meta .meta-row {
    display: grid;
    grid-template-columns: 78px minmax(0, 1fr);
    gap: 8px;
    align-items: baseline;
    min-height: 18px;
}
.obj-card__meta dt {
    font-size: 11px;
    font-weight: 600;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.02em;
}
.tile--custom {
    /* Проект-специфичная организация: dashed-рамка, отличаем от глобальных */
    border-style: dashed;
}
.obj-card__meta dd {
    margin: 0;
    /* одна строка + ellipsis, чтобы карточка не «расползалась» */
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Стековая полоса стадий: каждый сегмент = доля ячеек в конкретном статусе */
.progress-stack {
    position: relative;
    display: flex;
    height: 20px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 999px;
    overflow: hidden;
}
.progress-stack__seg { display: block; height: 100%; transition: width 240ms ease; }
.progress-stack__seg:first-child { border-top-left-radius: 999px; border-bottom-left-radius: 999px; }
.progress-stack__seg:last-child  { border-top-right-radius: 999px; border-bottom-right-radius: 999px; }
.progress-stack__text {
    position: absolute; inset: 0;
    display: flex; align-items: center; justify-content: center;
    font-size: 11px; font-weight: 700;
    color: var(--text);
    text-shadow: 0 0 3px var(--card-bg), 0 0 3px var(--card-bg);
    pointer-events: none;
}

/* Кнопка «Показать статусы по организациям» */
.obj-card__expander {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    min-height: 36px;
    padding: 6px 10px;
    background: transparent;
    border: 1px dashed var(--border);
    border-radius: 8px;
    font: inherit;
    font-size: 12px;
    color: var(--muted);
    cursor: pointer;
    transition: background 120ms ease, border-color 120ms ease;
}
.obj-card__expander:hover, .obj-card__expander:focus-visible {
    background: color-mix(in oklab, var(--accent) 6%, transparent);
    border-color: var(--accent);
    color: var(--text);
    outline: none;
}
.obj-card__chevron { transition: transform 180ms ease; display: inline-block; }
.obj-card.is-expanded .obj-card__chevron { transform: rotate(180deg); }

/* Плитки: auto-fill, натуральная высота, БЕЗ overflow.
 * Обязательно [hidden]-override — иначе `display:grid` перебивает браузерный
 * `[hidden]{display:none}` (одинаковая специфичность, автор после UA). */
.obj-card__grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 6px;
}
.obj-card__grid[hidden] { display: none; }
.tile {
    min-height: 52px;
    padding: 6px 8px;
    border: 1px solid;
    border-color: color-mix(in oklab, var(--st-fg, var(--text)) 28%, transparent);
    border-radius: 8px;
    background: var(--st-bg, var(--card-bg));
    color: var(--st-fg, var(--text));
    text-align: left;
    font: inherit;
    cursor: pointer;
    display: flex; flex-direction: column; gap: 2px;
    line-height: 1.2;
    transition: transform 100ms ease, box-shadow 120ms ease;
    min-width: 0;
}
.tile:hover { box-shadow: var(--shadow-sm); }
.tile:active { transform: scale(0.98); }
.tile:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.tile__org { font-size: 11px; font-weight: 600; opacity: 0.85; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tile__st  { font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: flex; align-items: center; gap: 4px; }
.tile__st .st-ic { opacity: 0.9; }

/* Статус объекта */
.obj-status {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 11px; font-weight: 600;
    white-space: nowrap;
}
.obj-status--в-работе  { background: #dbeafe; color: #1d4ed8; }
.obj-status--передали  { background: #dcfce7; color: #166534; }
.obj-status--unknown,
.obj-status---         { background: var(--border); color: var(--muted); }

@media (prefers-color-scheme: dark) {
    .obj-status--в-работе { background: rgba(59, 130, 246, .18); color: #93c5fd; }
    .obj-status--передали { background: rgba(22, 163, 74, .20);  color: #86efac; }
}

/* Пустое состояние (после поиска) */
.empty-state {
    text-align: center;
    padding: 32px 16px;
    color: var(--muted);
    font-size: 14px;
}

/* --- MODAL (общая для всех) --- */
.modal {
    border: none;
    padding: 0;
    background: transparent;
    max-width: 640px;
    width: calc(100vw - 24px);
    border-radius: 12px;
    overflow: hidden;
}
.modal::backdrop { background: rgba(0,0,0,0.55); }
.modal__body { background: var(--card-bg); color: var(--text); display: flex; flex-direction: column; max-height: 90vh; }
.modal__head { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.modal__head h2 { margin: 0; font-size: 17px; }
.modal__close { background: transparent; border: 0; font-size: 28px; line-height: 1; cursor: pointer; color: var(--muted); padding: 0 4px; }
.modal__content { padding: 16px; overflow: auto; }

/* Широкая модалка статусов (клик по карточке) — почти на весь экран */
.modal--wide { max-width: min(1400px, 96vw); width: 96vw; }
.modal--wide .modal__body { max-height: 92vh; }
.obj-modal__titlewrap { min-width: 0; }
.obj-modal__shifr { margin: 0; font-size: 17px; line-height: 1.2; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.obj-modal__name  { margin: 2px 0 0; font-size: 13px; }
.obj-modal__progress { margin-bottom: 14px; }
.obj-modal__progress .progress-stack { height: 24px; }
/* Внутри модалки плитки крупнее и не скрыты */
.obj-card__grid--modal {
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 8px;
}
.obj-card__grid--modal .tile { min-height: 58px; }

.modal .row { display: flex; flex-wrap: wrap; gap: 12px; font-size: 13px; margin-bottom: 12px; }
.modal .row > div { flex: 1 1 45%; min-width: 0; }
.modal .row label { display: block; font-size: 11px; color: var(--muted); margin-bottom: 4px; }
.modal input[type=text],
.modal input[type=search],
.modal select,
.modal textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font: inherit;
    background: var(--card-bg);
    color: var(--text);
    box-sizing: border-box;
}
.modal input:focus, .modal select:focus, .modal textarea:focus { outline: 2px solid var(--accent); outline-offset: -2px; }

.modal h3 { margin: 16px 0 8px; font-size: 14px; }
.preset-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 8px; }
.preset {
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 10px 12px;
    background: var(--bg);
}
.preset__head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 6px; }
.preset__name { font-weight: 600; font-size: 14px; }
.preset__to   { font-size: 11px; color: var(--muted); }
.preset__actions { font-size: 12px; color: var(--muted); }

.picker { display: flex; flex-direction: column; gap: 6px; }
.picker__results { display: flex; flex-direction: column; gap: 2px; max-height: 160px; overflow: auto; border: 1px solid var(--border); border-radius: 8px; background: var(--card-bg); }
.picker__results button { text-align: left; padding: 6px 10px; background: transparent; border: 0; font: inherit; color: var(--text); cursor: pointer; }
.picker__results button:hover { background: var(--border); }
.picker__chosen { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { display: inline-flex; align-items: center; gap: 4px; padding: 3px 8px; border-radius: 999px; background: var(--accent); color: var(--accent-fg); font-size: 12px; }
.chip button { background: transparent; border: 0; color: inherit; cursor: pointer; font-size: 14px; line-height: 1; padding: 0; }

.modal__actions { display: flex; gap: 8px; justify-content: flex-end; padding: 12px 16px; border-top: 1px solid var(--border); background: var(--card-bg); }
.btn--primary { background: var(--accent); color: var(--accent-fg); }
.btn--muted   { background: transparent; color: var(--text); border: 1px solid var(--border); }

.preview {
    background: var(--bg);
    border: 1px dashed var(--border);
    border-radius: 8px;
    padding: 10px;
    font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
    font-size: 12px;
    white-space: pre-wrap;
    max-height: 300px;
    overflow: auto;
}

.form-error { color: #b91c1c; font-size: 13px; margin: 8px 0 0; white-space: pre-wrap; }
.form-ok    { color: #166534; font-size: 13px; margin: 8px 0 0; }

/* Чек-лист организаций в форме «Новый проект» */
.orgs-checklist { margin-top: 8px; border-top: 1px solid var(--border); padding-top: 12px; }
.orgs-checklist__head {
    display: flex; align-items: center; justify-content: space-between;
    gap: 8px; margin-bottom: 8px;
}
.btn--sm { min-height: 36px; min-width: auto; padding: 6px 12px; font-size: 13px; }
.orgs-checklist__body {
    display: grid;
    grid-template-columns: 1fr;
    gap: 6px;
    max-height: 320px;
    overflow: auto;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 8px;
    background: var(--bg);
}
@media (min-width: 640px) {
    .orgs-checklist__body { grid-template-columns: 1fr 1fr; }
}
.org-row {
    display: flex; align-items: center; gap: 8px;
    padding: 6px 8px;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 6px;
    min-width: 0;
}
.org-row__name {
    flex: 1 1 auto;
    font-size: 12px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.org-row select {
    flex: 0 0 auto;
    padding: 4px 6px;
    font-size: 12px;
    min-height: 32px;
    max-width: 130px;
}
.org-row.is-new { border-color: var(--accent); background: color-mix(in oklab, var(--accent) 8%, var(--card-bg)); }
.org-row--custom { border-style: dashed; }
.org-row--excluded {
    opacity: 0.7;
    background: var(--bg);
    border-style: dotted;
}
.org-row--excluded .org-row__name { color: var(--muted); }
.org-row__remove {
    flex: 0 0 auto;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 2px 8px;
    font-size: 14px;
    line-height: 1;
    color: var(--muted);
    cursor: pointer;
}
.org-row__remove:hover { color: #b91c1c; border-color: #b91c1c; }
.org-row__restore {
    flex: 0 0 auto;
    padding: 4px 10px;
    font-size: 11px;
    background: transparent;
    color: var(--muted);
    border: 1px solid var(--border);
    border-radius: 6px;
    cursor: pointer;
}
.org-row__restore:hover { color: var(--text); border-color: var(--accent); }
.org-row__section {
    padding: 8px 0 4px;
    font-size: 11px;
    font-weight: 600;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.03em;
    border-top: 1px dashed var(--border);
    margin-top: 6px;
}
.badge-scope {
    display: inline-block;
    margin-left: 6px;
    padding: 1px 6px;
    font-size: 10px;
    font-weight: 600;
    color: var(--muted);
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 999px;
    vertical-align: middle;
}

/* Роли */
.badge--admin   { background: #7c3aed; color: #fff; }
.badge--manager { background: #0891b2; color: #fff; }
.badge--viewer  { background: #6b7280; color: #fff; }
.badge--dev     { background: #f59e0b; color: #111827; }

/* ============================================================================
 * Переключатель видов / фильтры / мультивыбор / таблица / матрица / аккордеон
 * ==========================================================================*/

/* --- View switch (сегмент-контрол) --- */
.viewswitch {
    display: inline-flex; gap: 2px;
    padding: 3px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 10px;
    margin-bottom: 12px;
}
.viewswitch__btn {
    min-height: var(--tap);
    padding: 8px 14px;
    border: 0; background: transparent;
    color: var(--muted);
    font: inherit; font-size: 13px; font-weight: 600;
    border-radius: 8px; cursor: pointer;
    transition: background 120ms ease, color 120ms ease;
}
.viewswitch__btn.is-active { background: var(--card-bg); color: var(--text); box-shadow: var(--shadow-sm); }
.viewswitch__btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
@media (max-width: 1023px) { .viewswitch__btn--matrix { display: none; } }

/* --- Filters (поповеры/шиты + активные чипы) --- */
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chips--col { flex-direction: column; align-items: stretch; }
.chips--col .chipf { justify-content: flex-start; border-radius: 8px; }
.chipf {
    display: inline-flex; align-items: center; gap: 6px;
    min-height: 36px; padding: 6px 12px;
    border: 1px solid var(--border); border-radius: 999px;
    background: var(--bg); color: var(--text);
    font: inherit; font-size: 12px; cursor: pointer;
    transition: border-color 120ms ease, background 120ms ease, color 120ms ease;
}
.chipf:hover { border-color: var(--accent); }
.chipf:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.chipf .st-ic { width: 12px; height: 12px; }
.chipf.is-on {
    border-color: transparent;
    background: var(--st-bg, var(--accent));
    color: var(--st-fg, var(--accent-fg));
    font-weight: 600;
    box-shadow: inset 0 0 0 1px color-mix(in oklab, var(--st-fg, var(--accent)) 35%, transparent);
}
#customerChips .chipf.is-on { background: var(--accent); color: var(--accent-fg); box-shadow: none; }
.filters__mode {
    min-height: 36px; padding: 6px 12px;
    border: 1px dashed var(--border); border-radius: 8px;
    background: transparent; color: var(--muted);
    font: inherit; font-size: 12px; cursor: pointer;
}
.filters__mode[data-mode="all"] { border-style: solid; color: var(--accent); border-color: var(--accent); }
.filters__count { font-size: 12px; color: var(--muted); }

/* Строка активных фильтров */
.activefilters { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.activefilters[hidden] { display: none; }
.activefilters__chips { display: flex; flex-wrap: wrap; gap: 6px; }
.activefilters .filters__count { margin-left: auto; }
.rmchip {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 4px 4px 4px 10px; border-radius: 999px;
    background: var(--st-bg, var(--accent)); color: var(--st-fg, var(--accent-fg));
    font-size: 12px; font-weight: 600;
    box-shadow: inset 0 0 0 1px color-mix(in oklab, var(--st-fg, var(--accent)) 30%, transparent);
}
.rmchip--customer { background: var(--accent); color: var(--accent-fg); box-shadow: none; }
.rmchip__x {
    display: inline-grid; place-items: center; width: 18px; height: 18px;
    border: 0; border-radius: 999px; background: color-mix(in oklab, currentColor 22%, transparent);
    color: inherit; font-size: 13px; line-height: 1; cursor: pointer;
}
.rmchip__x:hover { background: color-mix(in oklab, currentColor 38%, transparent); }

/* Поповер (десктоп) / bottom-sheet (мобила) */
.fpop-backdrop { position: fixed; inset: 0; z-index: 40; background: transparent; }
.fpop-backdrop[hidden] { display: none; }
.fpop {
    position: fixed; z-index: 41;
    width: min(340px, calc(100vw - 16px));
    background: var(--card-bg); border: 1px solid var(--border);
    border-radius: 12px; box-shadow: 0 12px 32px rgba(0, 0, 0, .22);
    padding: 12px;
}
.fpop[hidden] { display: none; }
.fpop__head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.fpop__title { font-size: 14px; font-weight: 700; }
.fpop__close {
    display: none; place-items: center; width: 32px; height: 32px;
    border: 0; background: transparent; color: var(--muted);
    font-size: 22px; line-height: 1; cursor: pointer; border-radius: 8px;
}
.fpop__search {
    width: 100%; padding: 8px 10px; margin-bottom: 10px;
    border: 1px solid var(--border); border-radius: 8px; font: inherit;
    background: var(--bg); color: var(--text);
}
.fpop .chips { max-height: min(46vh, 320px); overflow: auto; }
.fpop__foot {
    display: flex; align-items: center; gap: 8px;
    margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--border);
}
.fpop__foot-label { font-size: 12px; color: var(--muted); }

@media (max-width: 640px) {
    .fpop {
        top: auto !important; left: 0 !important; right: 0 !important; bottom: 0 !important;
        width: 100%; max-width: none;
        border-radius: 16px 16px 0 0; border-bottom: 0;
        max-height: 82vh; overflow: auto;
        padding-bottom: calc(12px + env(safe-area-inset-bottom));
        animation: fpop-up 180ms ease;
    }
    .fpop-backdrop { background: rgba(0, 0, 0, .45); }
    .fpop__close { display: inline-grid; }
    .fpop .chips { max-height: none; }
}
@keyframes fpop-up { from { transform: translateY(100%); } to { transform: none; } }

/* --- Чекбокс выбора на карточке --- */
.obj-card { position: relative; }
.cardsel { position: absolute; top: 8px; left: 8px; z-index: 2; display: grid; place-items: center; width: 28px; height: 28px; cursor: pointer; }
.cardsel__cb { width: 20px; height: 20px; cursor: pointer; accent-color: var(--accent); }
.obj-card__head { padding-left: 26px; }

/* --- Липкий бар мультивыбора --- */
.selbar {
    position: sticky; bottom: 0; z-index: 20;
    display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap;
    margin-top: 14px; padding: 10px 14px;
    padding-bottom: calc(10px + env(safe-area-inset-bottom));
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 12px 12px 0 0;
    box-shadow: var(--shadow-md);
}
.selbar[hidden] { display: none; }
.selbar__count { font-weight: 700; font-size: 14px; }
.selbar__actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* --- Табличный вид --- */
.tableview { overflow-x: auto; }
.dtable { width: 100%; border-collapse: collapse; font-size: 13px; }
.dtable th, .dtable td { padding: 10px; text-align: left; border-bottom: 1px solid var(--border); vertical-align: middle; }
.dtable thead th {
    position: sticky; top: 0; z-index: 1;
    background: var(--card-bg);
    font-size: 11px; text-transform: uppercase; letter-spacing: 0.03em;
    color: var(--muted); cursor: pointer; white-space: nowrap;
}
.dtable thead th[data-sort]:hover { color: var(--text); }
.dtable thead th.is-sorted::after { content: " ▲"; font-size: 10px; }
.dtable thead th.is-sorted[data-dir="desc"]::after { content: " ▼"; }
.dtable__cb { width: 36px; text-align: center; }
.dtable__cb input { width: 18px; height: 18px; accent-color: var(--accent); }
.dtable__shifr { font-weight: 700; white-space: nowrap; }
.dtable__row { cursor: pointer; }
.dtable__row:hover { background: color-mix(in oklab, var(--accent) 6%, transparent); }
.dtable__row--bad .dtable__shifr { color: #dc2626; }
.dtable__prog { min-width: 130px; }
.dtable__prog .progress-stack { height: 18px; }
.dtable__contract { white-space: nowrap; font-size: 12px; color: var(--muted); }
.dtable__act { text-align: right; white-space: nowrap; }
.mtx__edit { flex: 0 0 auto; min-width: 26px; min-height: 26px; padding: 0 4px; font-size: 13px; }

/* --- Матрица --- */
.mtx__scroll { overflow: auto; max-height: 78vh; border: 1px solid var(--border); border-radius: var(--radius); }
.mtx {
    border-collapse: separate; border-spacing: 0; font-size: 12px;
    width: max-content; min-width: 100%; table-layout: fixed;
}
.mtx th, .mtx td { border-bottom: 1px solid var(--border); border-right: 1px solid var(--border); }
.mtx thead th { position: sticky; top: 0; z-index: 3; background: var(--card-bg); }
.mtx__corner {
    position: sticky; left: 0; top: 0; z-index: 5;
    width: 240px; min-width: 240px; max-width: 240px;
    background: var(--card-bg); padding: 8px; text-align: left;
    font-size: 11px; color: var(--muted);
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
    box-shadow: 4px 0 8px -4px rgba(0, 0, 0, .18);
}
.mtx__orgh {
    padding: 6px; height: 130px; vertical-align: bottom; white-space: nowrap;
    width: 44px; min-width: 44px; max-width: 52px;
}
.mtx__orgh span {
    display: inline-block; writing-mode: vertical-rl; transform: rotate(180deg);
    max-height: 118px; overflow: hidden; text-overflow: ellipsis; font-weight: 600;
}
.mtx__rowh {
    position: sticky; left: 0; z-index: 2;
    width: 240px; min-width: 240px; max-width: 240px;
    padding: 0; vertical-align: middle;
    background: var(--card-bg);
    box-shadow: 4px 0 8px -4px rgba(0, 0, 0, .18);
}
.mtx__rowh-inner {
    display: flex; align-items: center; gap: 6px;
    padding: 4px 6px; min-width: 0; max-width: 240px;
    overflow: hidden;
}
.mtx__rowh-text {
    flex: 1 1 auto; min-width: 0; overflow: hidden;
    display: flex; flex-direction: column; gap: 1px;
}
.mtx__cb { flex: 0 0 auto; display: grid; place-items: center; }
.mtx__cb input { width: 16px; height: 16px; accent-color: var(--accent); }
.mtx__shifr {
    background: transparent; border: 0; font: inherit; font-weight: 700; color: var(--text);
    cursor: pointer; padding: 0; text-align: left;
    display: block; width: 100%;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.mtx__shifr:hover { color: var(--accent); }
.mtx__name {
    display: block; font-size: 11px; font-weight: 400; color: var(--muted); line-height: 1.2;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.mtx__cell { height: 40px; text-align: center; padding: 0; background: var(--st-bg, transparent); width: 44px; min-width: 44px; }
.mtx__cell--na { color: var(--muted); background: var(--bg); }
.mtx__dot {
    min-height: 0; width: 28px; height: 28px; margin: 3px auto; padding: 0;
    display: grid; place-items: center; border-radius: 6px;
    border: 1px solid color-mix(in oklab, var(--st-fg, var(--text)) 28%, transparent);
    background: transparent; color: var(--st-fg, var(--text)); cursor: pointer;
}
.mtx__dot .st-ic { width: 14px; height: 14px; }

/* --- Аккордеон (общая модалка мультивыбора) --- */
.acc { border: 1px solid var(--border); border-radius: 10px; margin-bottom: 10px; overflow: hidden; background: var(--bg); }
.acc__sum {
    display: flex; align-items: center; justify-content: space-between; gap: 10px;
    padding: 12px 14px; cursor: pointer; list-style: none; min-height: var(--tap);
}
.acc__sum::-webkit-details-marker { display: none; }
.acc__title { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.acc__done { flex: 0 0 auto; font-size: 12px; font-weight: 700; color: var(--muted); }
.acc__body { padding: 12px 14px; border-top: 1px solid var(--border); background: var(--card-bg); }
