/*
 * AR-Factory — слой примитивов вьюх (фаза 2).
 * Паттерны портированы из эталона ar-factory-enterprise: page-head, summary,
 * kpi-strip, panel/toolbar/table, bulk-bar, pager, empty-state, confirm-dialog.
 * Всё под префиксом fx-, чтобы не конфликтовать с inline-CSS mp-dashboard.
 * Токены — только из ar-brand.css.
 */

/* ---------- Шапка страницы ---------- */
.fx-page-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 24px;
}
.fx-eyebrow {
    font-size: 10px;
    font-weight: 650;
    color: var(--text-dim);
    letter-spacing: .05em;
    text-transform: uppercase;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 8px;
}
.fx-eyebrow::before {
    content: "";
    display: block;
    height: 8px;
    width: 3px;
    border-radius: 1px;
    background: var(--primary);
}
.fx-page-title {
    font-family: var(--font-display);
    font-size: 27px;
    line-height: 1.2;
    margin: 0;
    font-weight: 700;
    letter-spacing: -.025em;
    color: var(--text-primary);
}
.fx-page-description {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 9px;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 7px;
}
.fx-page-description-tags {
    display: inline-flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 7px;
}
.fx-page-description-note { color: var(--text-dim); }
.fx-head-actions {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
    padding-top: 16px;
}
.fx-page-head-main {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

/* ---------- Summary-полоса ---------- */
.fx-summary {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 16px 20px;
    background: var(--surface-0);
    border: 1px solid var(--border-default);
    border-left: 3px solid var(--warning);
    border-radius: var(--radius-md);
    margin-bottom: 20px;
}
.fx-summary__icon {
    color: var(--warning);
    padding-top: 2px;
    display: inline-flex;
    flex: none;
}
.fx-summary__icon svg { width: 16px; height: 16px; }
.fx-summary__content { min-width: 0; flex: 1; }
.fx-summary__content h2 { font-size: 13px; margin: 0 0 4px; font-weight: 650; }
.fx-summary__content ul { margin: 4px 0 0; padding-left: 18px; font-size: 12px; color: var(--text-muted); line-height: 1.8; }
.fx-summary__content p {
    font-size: 11px;
    line-height: 1.6;
    color: var(--text-muted);
    max-width: 720px;
    margin: 0;
}
.fx-summary .btn { margin: auto 0; min-height: 36px; font-size: 11px; }
.fx-summary .fx-dismiss {
    width: 28px;
    height: 28px;
    margin: -4px -8px 0 0;
}
/* Технические детали ошибки — свернуты под friendly-текстом */
.fx-error-detail { display: inline-block; margin-left: 6px; font-size: 11px; }
.fx-error-detail summary {
    display: inline;
    cursor: pointer;
    color: var(--text-dim);
    text-decoration: underline dotted;
    text-underline-offset: 3px;
}
.fx-error-detail code {
    display: inline;
    font-size: 10.5px;
    color: var(--text-dim);
    word-break: break-all;
}

/* ---------- KPI-полоса ---------- */
.fx-kpi-strip {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    background: var(--surface-0);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-lg);
    margin-bottom: 24px;
    padding: 20px 0;
}
.fx-kpi { padding: 0 20px; border-right: 1px solid var(--border-subtle); min-width: 0; }
.fx-kpi:last-child { border-right: 0; }
.fx-kpi__label {
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--text-muted);
    font-size: 11px;
    margin-bottom: 8px;
}
.fx-kpi__value {
    font-size: 26px;
    line-height: 1.1;
    font-weight: 650;
    letter-spacing: -.035em;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}
.fx-kpi__value.is-good { color: var(--success); }
.fx-kpi__value.is-bad { color: var(--danger); }
.fx-kpi__note {
    font-size: 10px;
    color: var(--text-dim);
    margin-top: 8px;
    display: flex;
    align-items: center;
    gap: 5px;
}

/* ---------- Панель ---------- */
.fx-panel {
    border: 1px solid var(--border-default);
    background: var(--surface-0);
    border-radius: var(--radius-lg);
    overflow: hidden;
}
/* Панель с overflow:hidden режет абсолютные .fx-dropdown__list по краю.
   Пока внутри сфокусированный контрол (открытый дропдаун держит фокус на
   своей кнопке) — отпускаем клип, список выпадает поверх соседних панелей. */
.fx-panel:focus-within { overflow: visible; }
.fx-panel-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    min-height: 56px;
    gap: 16px;
    border-bottom: 1px solid var(--border-subtle);
}
.fx-panel-top h2 {
    margin: 0;
    font-size: 15px;
    font-weight: 700;
    letter-spacing: -.01em;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}
.fx-panel-top-note {
    font-size: var(--text-xs);
    color: var(--text-dim);
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
}
.fx-panel-top > div { min-width: 0; }

/* ---------- Тулбар / поля ---------- */
.fx-toolbar {
    display: flex;
    align-items: flex-end;
    gap: 12px;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-subtle);
    flex-wrap: wrap;
}
.fx-field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.fx-field > label, .fx-field-label { font-size: 11px; color: var(--text-muted); font-weight: 600; }
.fx-field.grow { flex: 1; }
.fx-search-wrap { position: relative; display: flex; align-items: center; }
.fx-search-wrap > .fx-search-icon {
    position: absolute;
    left: 12px;
    color: var(--text-dim);
    width: 16px;
    height: 16px;
    pointer-events: none;
}
.fx-search-wrap input { padding-left: 36px; padding-right: 38px; width: 100%; }
.fx-search-clear { position: absolute; right: 3px; width: 32px; height: 32px; }
.fx-toolbar-actions {
    margin-left: auto;
    display: flex;
    align-items: flex-end;
    gap: 8px;
    flex-wrap: wrap;
}
.fx-att-chip { border: 0; cursor: pointer; font-family: inherit; }
.fx-att-chip:hover { filter: brightness(0.97); }

/* ---------- Таблица ---------- */
.fx-table-area { position: relative; }
.fx-table-scroll {
    max-height: 560px;
    overflow: auto;
    overscroll-behavior-x: contain;
    scrollbar-width: thin;
    scrollbar-color: color-mix(in srgb, var(--ink) 14%, transparent) transparent;
    max-width: 100%;
    /* Крайние тени как индикатор продолжения таблицы за обрезом:
       cover-градиенты (local) прячут тень у самого края прокрутки. */
    background:
        linear-gradient(to right, var(--surface-0) 30%, transparent) left / 32px 100% no-repeat local,
        linear-gradient(to left, var(--surface-0) 30%, transparent) right / 32px 100% no-repeat local,
        radial-gradient(farthest-side at 0 50%, color-mix(in srgb, var(--text-primary) 22%, transparent), transparent) left / 12px 100% no-repeat scroll,
        radial-gradient(farthest-side at 100% 50%, color-mix(in srgb, var(--text-primary) 22%, transparent), transparent) right / 12px 100% no-repeat scroll;
    background-color: var(--surface-0);
}
.fx-table-scroll:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: -2px; }

/* Липкая первая колонка: аккаунт остаётся на месте при горизонтальной
   прокрутке широких таблиц (max-settings ~1180px при ~790px видимых). */
.fx-table--sticky-first th:first-child,
.fx-table--sticky-first td:first-child {
    position: sticky;
    left: 0;
    z-index: 2;
    background: var(--surface-0);
    box-shadow: 1px 0 0 var(--border-subtle);
}
.fx-table--sticky-first thead th:first-child { z-index: 3; background: var(--surface-1); }
.fx-table--sticky-first tbody tr:hover td:first-child { background: var(--surface-1); }
.fx-table--sticky-first tbody tr.is-selected td:first-child { background: color-mix(in srgb, var(--surface-active) 65%, var(--surface-0)); }
.fx-table { border-collapse: collapse; width: 100%; font-size: 12px; }
.fx-table th {
    position: sticky;
    top: 0;
    z-index: 1;
    background: var(--surface-1);
    color: var(--text-muted);
    font-size: 10px;
    font-weight: 600;
    text-align: left;
    height: 40px;
    border-bottom: 1px solid var(--border-default);
    white-space: nowrap;
    padding: 0 12px;
}
.fx-table td {
    padding: 10px 12px;
    min-height: 64px;
    height: 64px;
    border-bottom: 1px solid var(--border-subtle);
    vertical-align: middle;
    color: var(--text-primary);
}
.fx-table tr:last-child td { border-bottom: 0; }
.fx-table tbody tr { transition: background var(--motion-fast); }
.fx-table tbody tr:hover { background: var(--surface-1); }
.fx-table tbody tr.is-selected { background: color-mix(in srgb, var(--surface-active) 65%, var(--surface-0)); }

.fx-sort-button {
    min-height: 36px;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 0;
    color: inherit;
    font: inherit;
    background: transparent;
    border: 0;
    cursor: pointer;
    white-space: nowrap;
}
.fx-sort-button:hover { color: var(--primary); }
.fx-sort-button svg { height: 12px; width: 12px; flex: none; }
.fx-sort-button .fx-sort-icon { display: inline-flex; opacity: .45; }
.fx-table th[aria-sort="ascending"] .fx-sort-icon,
.fx-table th[aria-sort="descending"] .fx-sort-icon { opacity: 1; color: var(--primary); }

.fx-col-check { width: 50px; }
.fx-check-hit {
    min-width: 40px;
    min-height: 40px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    border-radius: var(--radius-sm);
    margin: -8px;
}
.fx-check-hit:hover { background: var(--surface-2); }
.fx-check-hit input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--primary); margin: 0; cursor: pointer; }

.fx-numeric { text-align: right; font-variant-numeric: tabular-nums; }
.fx-row-title {
    display: block;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-weight: 600;
    font-size: 12px;
    text-align: left;
    padding: 2px 0;
    color: var(--text-primary);
    background: transparent;
    border: 0;
    cursor: pointer;
}
.fx-row-title:hover:not(:disabled) { color: var(--primary); text-decoration: underline; text-underline-offset: 3px; }
.fx-row-subline {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 3px;
    white-space: nowrap;
}
.fx-number-main { font-size: 12px; font-weight: 550; font-variant-numeric: tabular-nums; white-space: nowrap; }
.fx-number-note { font-size: 11px; color: var(--text-muted); margin-top: 2px; white-space: nowrap; }

.fx-status-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 7px;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    background: var(--surface-2);
    font-size: 10px;
    font-weight: 550;
    white-space: nowrap;
    line-height: 1.4;
}
.fx-status-badge.is-active { background: var(--success-bg); color: var(--success); }
.fx-status-badge.is-warning { background: var(--warning-bg); color: var(--warning); }
.fx-status-badge.is-error { background: var(--error-bg); color: var(--danger); }
.fx-status-badge.is-info { background: var(--info-bg); color: var(--info); }
.fx-status-badge.is-neutral { color: var(--text-dim); background: var(--surface-2); }

/* ---------- Bulk-панель ---------- */
.fx-bulk-bar {
    padding: 12px 20px;
    background: var(--surface-2);
    border-bottom: 1px solid var(--border-default);
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 64px;
    flex-wrap: wrap;
}
.fx-bulk-bar.is-selected { background: var(--surface-active); }
.fx-bulk-count { font-size: 12px; font-weight: 650; margin-right: auto; display: flex; align-items: center; gap: 8px; }
.fx-bulk-bar .btn { min-height: 36px; font-size: 11px; }

/* ---------- Футер таблицы / пагинация ---------- */
.fx-table-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: 12px 20px;
    min-height: 60px;
    border-top: 1px solid var(--border-subtle);
    font-size: 10px;
    color: var(--text-dim);
    flex-wrap: wrap;
}
.fx-pager { display: flex; align-items: center; gap: 8px; }
.fx-pager select { width: 66px; min-height: 32px; font-size: 11px; padding: 4px 28px 4px 8px; }
.fx-pager .icon-btn { width: 32px; height: 32px; }
.fx-page-number {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: var(--radius-sm);
    color: var(--primary);
    background: var(--surface-active);
    font-weight: 650;
    font-variant-numeric: tabular-nums;
}

/* ---------- Пустое состояние / скелетон ---------- */
.fx-empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 56px 24px;
    min-height: 340px;
    background: var(--surface-0);
}
.fx-empty-state h2 { font-size: 19px; letter-spacing: -.02em; margin: 0 0 8px; font-weight: 650; }
.fx-empty-state p { max-width: 410px; font-size: 12px; color: var(--text-muted); line-height: 1.8; margin: 0; }
.fx-empty-state__actions {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 24px;
}
.fx-skeleton-row {
    height: 64px;
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 24px;
    border-bottom: 1px solid var(--border-subtle);
}
.fx-skeleton { height: 9px; background: var(--surface-3); border-radius: 3px; width: 16%; display: block; }
.fx-skeleton-row .fx-skeleton:first-child { width: 34%; }

/* ---------- Утилиты раскладки ---------- */
.fx-stack { display: grid; gap: 12px; }
.fx-inline { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.fx-empty-state.is-compact { min-height: auto; padding: 24px; }
.fx-empty-state.is-compact h2 { font-size: 14px; }

/* Панель-<details> с шевроном */
.fx-panel--disclosure > summary {
    min-height: 56px;
    padding: 0 20px;
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    list-style: none;
    font-size: 13px;
    font-weight: 650;
    color: var(--text-primary);
    border-bottom: 1px solid transparent;
}
.fx-panel--disclosure > summary::-webkit-details-marker { display: none; }
.fx-panel--disclosure > summary::after {
    content: "";
    margin-left: auto;
    width: 8px;
    height: 8px;
    border-right: 2px solid var(--text-dim);
    border-bottom: 2px solid var(--text-dim);
    transform: rotate(45deg);
    transition: transform var(--motion-fast) var(--ease-standard);
}
.fx-panel--disclosure[open] > summary { border-bottom-color: var(--border-subtle); }
.fx-panel--disclosure[open] > summary::after { transform: rotate(225deg); }
.fx-panel--disclosure > summary svg { width: 16px; height: 16px; color: var(--text-muted); flex: none; }
.fx-panel--disclosure > .fx-panel__body { padding: 16px 20px; }

/* ---------- Confirm-диалог (нативный <dialog>) ---------- */
.fx-confirm {
    padding: 0;
    border: 1px solid var(--border-default);
    background: var(--surface-0);
    color: var(--text-primary);
    box-shadow: var(--shadow-pop);
    overflow: auto;
    max-height: calc(100dvh - 40px);
    max-width: calc(100vw - 32px);
    border-radius: var(--radius-lg);
    width: 420px;
}
.fx-confirm::backdrop { background: rgba(15, 11, 10, .54); }
.fx-confirm[open] { animation: fx-pop-in var(--motion-base) var(--ease-standard); }
.fx-confirm__head {
    padding: 20px 24px;
    display: flex;
    align-items: center;
    gap: 16px;
    border-bottom: 1px solid var(--border-subtle);
}
.fx-confirm__head > div { flex: 1; min-width: 0; }
.fx-confirm__head h2 { font-size: 18px; margin: 0; font-weight: 650; }
.fx-confirm__body { padding: 24px; }
.fx-confirm__body p { font-size: 13px; color: var(--text-muted); line-height: 1.8; margin: 0; }
.fx-confirm__detail {
    background: var(--surface-1);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 12px 16px;
    margin-top: 16px;
    color: var(--text-primary);
    font-size: 12px;
}
.fx-confirm__footer {
    padding: 16px 24px;
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 8px;
    border-top: 1px solid var(--border-subtle);
    background: var(--surface-1);
}
.fx-confirm.is-danger .fx-confirm__accept {
    border-color: var(--danger);
    background: var(--danger);
    color: var(--on-primary);
}
.fx-confirm.is-danger .fx-confirm__accept:disabled { opacity: .45; }
.fx-confirm__typed { margin-top: 14px; display: grid; gap: 6px; }
.fx-confirm__typed-label { font-size: 12px; color: var(--text-muted); }
.fx-confirm__typed .input-field { width: 100%; }

/* ---------- Плотность ---------- */
html.ar-density-compact .fx-table td { padding: 6px 12px; min-height: 44px; height: 44px; }
html.ar-density-compact .fx-row-subline,
html.ar-density-compact .fx-number-note { display: none; }
html.ar-density-compact .fx-skeleton-row { height: 44px; padding: 12px 20px; }

/* ---------- Адаптив ---------- */
@media (max-width: 1024px) {
    .fx-toolbar { padding: 16px; }
    .fx-panel-top { padding: 0 16px; }
    .fx-table-footer { padding: 12px 16px; }
    .fx-bulk-bar { padding: 12px 16px; }
}
@media (max-width: 768px) {
    .fx-page-head { flex-direction: column; }
    /* Действия шапки — одна скроллящаяся строка: 5–6 кнопок не должны
       занимать пол-экрана сеткой и вытеснять рабочие данные за сгиб. */
    .fx-head-actions {
        width: 100%;
        padding-top: 0;
        padding-bottom: 4px;
        display: flex;
        flex-wrap: nowrap;
        gap: 8px;
        overflow-x: auto;
        scrollbar-width: none;
    }
    .fx-head-actions::-webkit-scrollbar { display: none; }
    .fx-head-actions .btn { flex: none; min-width: 0; padding-inline: 12px; }
    /* Summary: кнопка действия уходит на свою строку, текст не сжимается
       в узкую колонку рядом с ней. */
    .fx-summary { flex-wrap: wrap; }
    .fx-summary .btn, .fx-summary .btn-secondary { width: 100%; margin: 4px 0 0; }
    .fx-kpi-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); padding: 12px 0; }
    .fx-kpi { padding: 8px 16px; }
    .fx-kpi:nth-child(3) { border-right: 0; }
    .fx-kpi:nth-child(n+3) { border-top: 1px solid var(--border-subtle); }
    .fx-toolbar { flex-direction: column; align-items: stretch; }
    .fx-toolbar-actions { margin-left: 0; }
    .fx-field, .fx-field.grow { width: 100%; }
    .fx-table-footer { flex-wrap: wrap; }
}
@media (prefers-reduced-motion: reduce) {
    .fx-confirm[open] { animation: none; }
    .fx-table tbody tr { transition: none; }
}

/* ---------- Автозагрузка ---------- */
/* AUTOLOAD WORKSPACE */
.autoload-pipeline > .pipe-status,
.autoload-pipeline > .stats-grid,
.autoload-pipeline > .sync-timestamp { display:none; }
.autoload-pipeline .pipe-step .btn-primary { min-height:40px; background:var(--primary); color:var(--on-primary); }
.autoload-pipeline .pipe-step .btn-primary:hover { background:var(--primary-hover); }
.autoload-pipeline .pipe-step .btn-primary:active { background:var(--primary-pressed); }
.autoload-pipeline .pipe-step .btn-primary:focus-visible { outline:2px solid var(--focus-ring); outline-offset:2px; }
.autoload-pipeline .pipe-step[data-state="blocked"] .btn-primary { background:var(--warning); color:var(--on-primary); }
.autoload-pipeline .pipe-step[data-state="busy"] .btn-primary { background:var(--warning); color:var(--on-primary); }

.autoload-workspace { display:grid; grid-template-columns:minmax(0,2fr) minmax(280px,1fr); gap:16px; align-items:start; }
/* Настройки автозагрузки встроены в карточку-сводку: bleed до краёв панели */
.autoload-run-summary > .autoload-section { border:0; border-radius:0; background:transparent; margin:20px -20px -20px; border-top:1px solid var(--border-subtle); }
.autoload-run-summary > .autoload-section > .autoload-header { padding-block:12px; border-bottom:0; }
.autoload-run-summary > .autoload-section > .autoload-body { border-top:1px solid var(--border-subtle); }
.autoload-run-summary,
.autoload-finance,
.autoload-connection,
.autoload-max-card { min-width:0; }
.autoload-section-head,
.autoload-connection-head { display:flex; align-items:flex-start; justify-content:space-between; gap:12px; }
.autoload-head-actions { display:flex; align-items:center; gap:10px; flex-wrap:wrap; justify-content:flex-end; }
.autoload-skip-link { background:none; border:0; padding:0; font:inherit; font-size:var(--text-xs); color:var(--text-muted); text-decoration:underline dotted; text-underline-offset:3px; cursor:pointer; }
.autoload-skip-link:hover { color:var(--text-primary); }
.autoload-skip-link:focus-visible { outline:2px solid var(--focus-ring); outline-offset:2px; }
.autoload-section-title { display:flex; align-items:center; gap:8px; margin:0; color:var(--text-primary); font-size:var(--text-lg); }
.autoload-state { display:inline-flex; align-items:center; gap:6px; margin:6px 0 0; color:var(--text-muted); font-size:var(--text-sm); }
.autoload-state__dot { width:8px; height:8px; border-radius:var(--radius-full); background:var(--text-dim); }
.autoload-state[data-tone="success"] .autoload-state__dot { background:var(--success); }
.autoload-state[data-tone="warning"] .autoload-state__dot { background:var(--warning); }
.autoload-facts { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:12px; margin-top:20px; }
.autoload-fact { min-width:0; padding-inline-end:12px; border-inline-end:1px solid var(--border-subtle); }
.autoload-fact:last-child { padding-inline-end:0; border-inline-end:0; }
.autoload-fact__label { display:block; color:var(--text-muted); font-size:var(--text-xs); }
.autoload-fact__value { display:block; margin-top:4px; color:var(--text-primary); font-size:var(--text-md); font-weight:700; font-variant-numeric:tabular-nums; }
.autoload-fact__value[data-tone="warning"] { color:var(--warning); }
.autoload-fact__value[data-tone="danger"] { color:var(--danger); }
.autoload-run-actions { display:flex; gap:8px; margin-top:20px; flex-wrap:wrap; }
.autoload-finance dl { display:grid; gap:0; margin:14px 0 16px; }
.autoload-finance dl div { display:flex; justify-content:space-between; gap:12px; padding:12px 0; border-block-start:1px solid var(--border-subtle); }
.autoload-finance dt { color:var(--text-muted); }
.autoload-finance dd { margin:0; color:var(--text-primary); font-size:var(--text-lg); font-weight:700; font-variant-numeric:tabular-nums; }
.autoload-finance .finance-balance dd { font-size:var(--text-2xl); font-weight:800; }
.finance-tariff { display:flex; align-items:center; justify-content:flex-end; flex-wrap:wrap; gap:6px; }
.finance-tariff-until { color:var(--text-muted); font-size:var(--text-sm); font-weight:500; }
.finance-usage dd { min-width:120px; font-size:var(--text-sm); font-weight:600; text-align:right; }
.finance-usage .vw-progress-track { height:5px; }
.status-pill.is-warn { border-color:var(--warning-border); background:var(--warning-bg); color:var(--warning); }
.autoload-stack { display:grid; gap:16px; align-content:start; min-width:0; }
.autoload-connection__icon { display:grid; width:32px; height:32px; place-items:center; border:1px solid var(--border-default); border-radius:var(--radius-md); color:var(--info); }
.autoload-connection__identity { display:flex; gap:10px; min-width:0; }
.autoload-connection__title { margin:0; color:var(--text-primary); font-size:var(--text-md); }
.autoload-connection__meta { margin:2px 0 0; color:var(--text-muted); font-size:var(--text-sm); }
.autoload-connection__actions { display:flex; flex-wrap:wrap; gap:8px; margin-top:16px; }
.autoload-max-list { display:grid; gap:8px; margin-top:16px; }
.autoload-max-row { display:flex; align-items:flex-start; justify-content:space-between; gap:6px 12px; padding:10px 0; border-block-start:1px solid var(--border-subtle); flex-wrap:wrap; }
.autoload-max-row .autoload-route-chips { justify-content:flex-start; }
.autoload-max-row__name { display:block; color:var(--text-primary); font-weight:700; }
.autoload-max-row__source { display:block; margin-top:2px; color:var(--text-muted); font-size:var(--text-xs); }
.autoload-route-chips { display:flex; justify-content:flex-end; flex-wrap:wrap; gap:4px; }
.autoload-route-chip { padding:2px 6px; border:1px solid var(--info-border); border-radius:var(--radius-sm); background:var(--info-bg); color:var(--info); font-size:var(--text-xs); white-space:nowrap; }
.autoload-summary-more { margin:8px 0 0; color:var(--text-muted); font-size:var(--text-sm); }
.autoload-secondary-note { margin:12px 0 0; color:var(--text-muted); font-size:var(--text-sm); }
.autoload-account-actions { display:flex; flex-wrap:wrap; justify-content:flex-end; gap:8px; }
.autoload-secondary-details > .autoload-secondary-details__body { padding:0 20px 20px; }
.autoload-secondary-details .info-grid { margin-top:0; }
.autoload-skeleton { display:grid; gap:4px; padding:4px 0 8px; }
.autoload-skeleton .fx-skeleton-row { height:auto; padding:8px 0; gap:12px; border-bottom:0; }
.autoload-skeleton .fx-skeleton-row .fx-skeleton:first-child { width:auto; }
.autoload-skeleton__grid { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:0 24px; }
@media (prefers-reduced-motion: no-preference) {
    .autoload-skeleton .fx-skeleton { animation: ar-skel-pulse 1.4s ease-in-out infinite; }
}
@keyframes ar-skel-pulse { 0%,100% { opacity:1; } 50% { opacity:.45; } }
@media (max-width:1024px) { .autoload-workspace { grid-template-columns:minmax(0,1fr); } .autoload-account-actions { width:100%; justify-content:flex-start; } }
@container dashboard (max-width:720px) { .autoload-facts { grid-template-columns:minmax(0,1fr); } .autoload-fact { padding:0 0 12px; border-inline-end:0; border-block-end:1px solid var(--border-subtle); } .autoload-fact:last-child { padding-bottom:0; border-block-end:0; } }

/* Патчи поверх fx-примитивов */
.autoload-run-summary.fx-panel,
.autoload-finance.fx-panel,
.autoload-connection.fx-panel,
.autoload-max-card.fx-panel { padding: 20px; }
header.fx-page-head.pipe-head { overflow: visible; }
/* END AUTOLOAD WORKSPACE */

/* CTA «Выгрузить в Avito» — 3D-pressable: приподнятая кнопка с ребром,
   при нажатии вдавливается (ребро схлопывается, кнопка садится). */
.btn-deploy {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    min-height: 46px;
    padding: 0 22px;
    margin-inline-start: auto;
    border: 0;
    border-radius: var(--radius-lg);
    background: var(--success);
    color: var(--on-primary);
    font: inherit;
    font-weight: 700;
    font-size: 12px;
    letter-spacing: .07em;
    text-transform: uppercase;
    cursor: pointer;
    overflow: hidden;
    box-shadow:
        0 6px 0 color-mix(in srgb, var(--success) 58%, #000),
        0 14px 24px -10px color-mix(in srgb, var(--success) 85%, transparent);
    transform: translateY(0);
    transition: transform var(--motion-fast) var(--ease-standard),
                box-shadow var(--motion-fast) var(--ease-standard),
                background-color var(--motion-fast) var(--ease-standard);
}
.btn-deploy::before {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: inherit;
    background: linear-gradient(to top, rgba(0,0,0,.20), transparent 55%);
    pointer-events: none;
}
.btn-deploy::after {
    content: "";
    position: absolute;
    top: 4px;
    left: 14px;
    width: 26px;
    height: 10px;
    border-radius: var(--radius-full);
    background: rgba(255,255,255,.38);
    filter: blur(2px);
    pointer-events: none;
}
.btn-deploy:hover:not(:disabled) {
    background: color-mix(in srgb, var(--success) 92%, #fff);
}
.btn-deploy:active:not(:disabled) {
    transform: translateY(6px);
    box-shadow:
        0 0 0 color-mix(in srgb, var(--success) 58%, #000),
        0 5px 10px -6px color-mix(in srgb, var(--success) 85%, transparent);
}
.btn-deploy:focus-visible {
    outline: 2px solid var(--focus-ring);
    outline-offset: 3px;
}
.btn-deploy:disabled {
    opacity: .55;
    cursor: not-allowed;
    box-shadow: 0 3px 0 color-mix(in srgb, var(--success) 55%, #000);
}
.btn-deploy__mark {
    display: grid;
    place-items: center;
    width: 22px;
    height: 22px;
    flex: none;
    border-radius: var(--radius-md);
    background: #fff;
}
.btn-deploy__label {
    position: relative;
    text-shadow: 0 1px 2px rgba(0,0,0,.25);
}


/* ACCOUNTS HUB — пресеты реестра аккаунтов (Обзор / Деньги и пуши / MAX-маршруты) */
.fx-tabs {
    display: flex;
    gap: 4px;
    align-items: center;
    margin: 0 0 var(--space-4);
    padding: 4px;
    width: fit-content;
    max-width: 100%;
    overflow-x: auto;
    background: var(--surface-1);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
}
.fx-tab {
    appearance: none;
    border: 0;
    background: transparent;
    color: var(--muted);
    font: inherit;
    font-weight: 600;
    font-size: var(--text-sm);
    padding: 8px 16px;
    border-radius: var(--radius-md);
    cursor: pointer;
    white-space: nowrap;
    transition: color var(--motion-fast) var(--ease-standard), background var(--motion-fast) var(--ease-standard);
}
.fx-tab:hover { color: var(--text); background: color-mix(in srgb, var(--ink) 5%, transparent); }
.fx-tab.is-active {
    color: var(--text);
    background: var(--surface-raised);
    box-shadow: 0 0 0 1px var(--border-default), 0 1px 3px color-mix(in srgb, #000 18%, transparent);
}
.fx-tab:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 2px; }

/* MAX-маршруты: чип группы в строке аккаунта */
.max-route-stack { display: grid; gap: 6px; }
.max-route-chip {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 4px 8px;
    padding: 6px 10px;
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    background: var(--surface-1);
    font-size: 12px;
}
.max-route-chip .badge { align-self: center; }

/* Мастер MAX-группы — slide-over поверх текущего экрана */
.max-wizard-overlay {
    position: fixed;
    inset: 0;
    z-index: 320;
    display: flex;
    justify-content: flex-end;
}
.max-wizard-scrim {
    position: absolute;
    inset: 0;
    background: color-mix(in srgb, #000 42%, transparent);
    backdrop-filter: blur(3px);
}
.max-wizard-sheet {
    position: relative;
    width: min(640px, 100%);
    height: 100%;
    display: flex;
    flex-direction: column;
    background: var(--surface-0, var(--bg));
    border-left: 1px solid var(--border-default);
    box-shadow: -24px 0 60px -30px rgba(0,0,0,.55);
    outline: none;
    animation: maxWizardIn var(--motion-base) var(--ease-standard);
}
@keyframes maxWizardIn {
    from { transform: translateX(48px); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}
.max-wizard-sheet__head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: var(--space-4);
    padding: var(--space-4) var(--space-5);
    border-bottom: 1px solid var(--border-subtle);
    flex: none;
}
.max-wizard-sheet__head h2 { margin: 0 0 4px; font-size: var(--text-lg); }
.max-wizard-sheet__body {
    flex: 1;
    overflow-y: auto;
    padding: var(--space-4) var(--space-5) var(--space-6);
}
.max-wizard-close {
    appearance: none;
    border: 1px solid var(--border-subtle);
    background: var(--surface-1);
    color: var(--muted);
    width: 36px;
    height: 36px;
    border-radius: var(--radius-md);
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
    flex: none;
    transition: color var(--motion-fast), background var(--motion-fast);
}
.max-wizard-close:hover { color: var(--text); background: color-mix(in srgb, var(--ink) 6%, transparent); }
.max-wizard-close:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 2px; }
@media (max-width: 640px) {
    .max-wizard-sheet { width: 100%; border-left: 0; }
    .fx-tabs { width: 100%; }
}

/* === Экскурсия «Помощь» по экрану «Доп. MAX-группы» ===
   Spotlight: дырка вырезана огромной тенью; поповер позиционируется
   из JS (maxTour.pop), на мобильной — bottom-sheet поверх контента. */
.max-tour {
    position: fixed;
    inset: 0;
    z-index: 430; /* поверх мастера (320), ниже тостов (500) */
    /* read-only: оверлей перехватывает все клики — боевые контролы
       под туром инертны, живой остаётся только поповер. */
    pointer-events: auto;
}
.max-tour-pop,
.max-tour-pop * { pointer-events: auto; }
.max-tour > *:not(.max-tour-pop) { pointer-events: none; }
.max-tour > .max-tour-scrim { pointer-events: auto; } /* клик по затемнению без цели — закрыть */
.max-tour-scrim {
    position: absolute;
    inset: 0;
    background: color-mix(in srgb, #000 42%, transparent);
}
.max-tour-spot {
    position: fixed;
    border-radius: var(--radius-lg);
    box-shadow: 0 0 0 9999px color-mix(in srgb, #000 42%, transparent);
    outline: 2px solid var(--accent);
    outline-offset: 2px;
    pointer-events: none;
    transition: top var(--motion-base) var(--ease-standard),
                left var(--motion-base) var(--ease-standard),
                width var(--motion-base) var(--ease-standard),
                height var(--motion-base) var(--ease-standard);
}
.max-tour-pop {
    position: fixed;
    width: min(360px, calc(100vw - 32px));
    max-height: calc(100vh - 16px);
    overflow-y: auto;
    background: var(--surface-0, var(--bg));
    border: 1px solid var(--border-default);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-pop);
    padding: var(--space-4);
    pointer-events: auto;
    transition: top var(--motion-base) var(--ease-standard),
                left var(--motion-base) var(--ease-standard);
}
.max-tour-pop__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3);
    margin-bottom: var(--space-2);
}
.max-tour-pop__head .max-wizard-close { width: 28px; height: 28px; font-size: 16px; }
.max-tour-progress {
    font-size: var(--text-xs);
    font-weight: 600;
    letter-spacing: .04em;
    text-transform: uppercase;
    color: var(--muted);
}
.max-tour-title { margin: 0 0 6px; font-size: var(--text-md); line-height: 1.3; }
.max-tour-text { margin: 0 0 var(--space-3); font-size: var(--text-sm); color: var(--muted); line-height: 1.55; }
.max-tour-actions {
    display: flex;
    align-items: center;
    gap: var(--space-2);
}
.max-tour-actions .btn-primary { flex: 1; }
.max-tour-actions .max-mini-btn { margin-left: auto; min-height: 32px; }
@media (max-width: 699px) {
    /* Поповер всегда нижней шторкой — цель может быть за кадром. */
    .max-tour-pop {
        top: auto !important;
        left: 8px !important;
        right: 8px;
        bottom: calc(8px + var(--safe-bottom, 0px));
        width: auto;
    }
}
@media (prefers-reduced-motion: reduce) {
    .max-tour-spot, .max-tour-pop { transition: none; }
}
/* При нуле неопределённых доставок панель схлопывается в одну строку:
   заголовок + статус + кнопка внутри fx-panel-top, без нижней зоны. */
.max-recon-clean {
    margin-left: auto;
    font-size: var(--text-sm);
    color: var(--muted);
}
.max-reconciliation-panel.is-clean { border-style: dashed; }
.max-reconciliation-panel.is-clean .fx-panel-top {
    border-bottom: none;
    min-height: 44px;
    padding-top: 4px;
    padding-bottom: 4px;
    flex-wrap: wrap;
    row-gap: 4px;
}
.max-reconciliation-panel.is-clean .fx-panel-top h2 {
    font-size: var(--text-sm);
    font-weight: 600;
    color: var(--text-dim);
}
@media (max-width: 560px) {
    .max-recon-clean { width: 100%; margin-left: 0; order: 3; }
}
