html, body {
    font-family: 'Roboto', -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif;
    /* Резервируем место под вертикальный скроллбар: его появление/исчезание
       (авто-фит гридов, диалоги) не должно менять ширину страницы — иначе
       весь layout дёргается влево-вправо. */
    scrollbar-gutter: stable;
}

/* ══════════════════════════════════════════════════════
   WMS Compact Mode — FluentUI-like density for MudBlazor
   ══════════════════════════════════════════════════════ */

/* ── Input fields: 36px height instead of 56px ── */
.mud-input.mud-input-outlined {
    margin-top: 0 !important;
}
.mud-input-control {
    margin-top: 0 !important;
}
/* Unified font size for all input controls */
.mud-input.mud-input-outlined .mud-input-slot,
.mud-input.mud-input-outlined input,
.mud-input.mud-input-outlined textarea,
.mud-input input,
.mud-input textarea,
.mud-input .mud-input-slot {
    padding-top: 6px !important;
    padding-bottom: 6px !important;
    font-size: 0.875rem !important;
}

/* Unified height for every outlined control (TextField / Select / DatePicker
   / Autocomplete / NumericField / TimePicker). Selects and pickers set
   min-height via their own slot rules — textfields only had padding, so
   they looked a bit shorter. Force the same min-height everywhere. */
.mud-input.mud-input-outlined .mud-input-slot,
.mud-input.mud-input-outlined input,
.mud-input.mud-input-outlined textarea {
    min-height: 24px !important;
    box-sizing: content-box;
}
.mud-input.mud-input-outlined {
    min-height: 36px;
}
/* Label: always shrunk (above the field) to prevent overlap with value text */
.mud-input-label {
    font-size: 0.875rem !important;
}
.mud-input-label-inputcontrol.mud-input-label-outlined,
.mud-input-label-inputcontrol.mud-shrink {
    transform: translate(14px, -9px) scale(0.85) !important;
    background: var(--mud-palette-surface);
    padding: 0 4px;
}

/* ── MudPicker popover sizing ──
   MudBlazor 9.1 default `.mud-picker-popover-paper` has min-width:16px and
   overflow-x:hidden, so the popover inherits the trigger input's width — in a
   narrow MudItem (md=2 ≈ 150px) the calendar gets clipped to ~150×408.
   Force a calendar-fit min-width and unhide overflow. Same fix covers Dialog
   variant since it also uses .mud-picker-popover-paper as the inner paper. */
.mud-picker-popover-paper {
    min-width: 340px !important;
    width: max-content !important;
    max-width: 95vw !important;
    overflow-x: visible !important;
    overflow-y: visible !important;
}
.mud-overlay-content .mud-picker-popover-paper {
    width: auto !important;
}
.mud-picker-content {
    min-width: 320px !important;
}

/* ── Select: compact dropdown ── */
.mud-select .mud-input-slot {
    padding-top: 6px !important;
    padding-bottom: 6px !important;
    min-height: 24px !important;
    font-size: 0.875rem !important;
}
.mud-select .mud-input-adornment {
    margin-top: 0 !important;
}
.mud-list-item {
    padding-top: 4px !important;
    padding-bottom: 4px !important;
    min-height: 32px !important;
    font-size: 0.8125rem;
}

/* ── NumericField: same compact sizing ── */
.mud-input-control .mud-input-adornment {
    margin-top: 0 !important;
}

/* ── Buttons: 32px height ── */
.mud-button-root:not(.mud-icon-button):not(.mud-fab) {
    padding: 4px 12px !important;
    min-height: 32px !important;
    font-size: 0.8rem;
}
.mud-button-root.mud-button-filled,
.mud-button-root.mud-button-outlined {
    min-height: 32px !important;
}

/* ── Chips: compact ── */
.mud-chip {
    height: 24px !important;
    font-size: 0.75rem !important;
}
.mud-chip .mud-chip-content {
    padding: 0 8px !important;
}

/* ── Dialog: less padding ── */
.mud-dialog .mud-dialog-content {
    padding: 12px 20px !important;
}
.mud-dialog .mud-dialog-title {
    padding: 12px 20px 8px !important;
}
.mud-dialog .mud-dialog-actions {
    padding: 8px 20px 12px !important;
}

/* ── Table cells: already dense from MudTable Dense=true, make tighter ── */
.mud-table-cell {
    padding: 4px 8px !important;
    font-size: 0.8rem;
    text-align: left;
}
.mud-table-head .mud-table-cell {
    font-size: 0.75rem;
    font-weight: 600;
    padding: 6px 8px !important;
    text-align: left;
}

body { margin: 0; }

/* Полноэкранные диалоги карточек (приход/заказ): шапка фиксирована, содержимое скроллится */
.cab-dialog-fill { display: flex; flex-direction: column; overflow: hidden !important; min-height: 0; padding: 0; }
.cab-dialog-body { flex: 1 1 auto; min-height: 0; overflow-y: auto; padding: 8px 12px; }
.cab-stat-tile { min-width: 150px; flex: 1 1 150px; }
.mud-tabs-panels { padding: 8px; }

/* Drawer / AppBar (Dense 48px), как в веб-портале */
.mud-appbar.mud-appbar-fixed-top { z-index: 1300; }
/* ClipMode=Always сам ставит drawer под AppBar; остаётся только слой ниже AppBar */
.cab-drawer { z-index: 1200; }
.cab-brand { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
img.cab-brand { flex: none; min-width: auto; }

/* Диалоги карточек документов (П3): Large, фикс. высота; на xs — на весь экран */
.cab-doc-dialog { height: 90vh; max-height: 90vh; }
.cab-tab-short { display: none; }   /* до @media: иначе перебивает его display:inline */
@media (max-width: 600px) {
    /* Специфичность выше MudDialog (.mud-dialog-width-full: width calc(100% - 64px); .mud-dialog: max-height calc(100dvh - appbar)) */
    .mud-dialog-container .mud-dialog.cab-doc-dialog {
        width: 100vw !important; max-width: 100vw !important;
        height: 100vh !important; height: 100dvh !important;
        max-height: 100vh !important; max-height: 100dvh !important;
        margin: 0 !important; border-radius: 0 !important;
    }
    /* Внутренние поля Mud (title 12/20/8, content 12/20) на телефоне съедают ширину — шапка и тело от края до края */
    .mud-dialog.cab-doc-dialog > .mud-dialog-title { padding: 0 !important; }
    .mud-dialog.cab-doc-dialog .mud-dialog-content.cab-dialog-fill { padding: 0 !important; }
    .mud-dialog.cab-doc-dialog .cab-dialog-body { padding: 4px; }
    /* Вкладки карточки: MudTabs пишет inline min-width:160px (MinimumTabWidth) — без !important три вкладки не влезают в 374px */
    .cab-doc-dialog .mud-tab { min-width: 0 !important; padding-left: 10px; padding-right: 10px; }
    .cab-doc-dialog .mud-tab .mud-tab-icon-text,
    .cab-doc-dialog .mud-tab .mud-icon-root { display: none; }
    /* Третья вкладка заказа: «Серийные номера (114)» не влезает — на телефоне короткая подпись «Сер. № (114)» */
    .cab-tab-long { display: none; }
    .cab-tab-short { display: inline; }
}
/* Планшет и узкий десктоп (601–1199px; ≤600 MudTable уходит в карточный режим — там колонки не прячем): второстепенные колонки
   списков скрыты, иначе таблица шире карточки и появляется горизонтальный скролл (при открытом боковом меню таблице остаётся
   ~720–860px на 960–1100px). На ≥1200px все колонки на месте. cab-hide-sm — ещё и самые узкие 601–759px. */
@media (min-width: 601px) and (max-width: 1199.98px) {
    .cab-hide-md { display: none !important; }
}
@media (min-width: 601px) and (max-width: 759.98px) {
    .cab-hide-sm { display: none !important; }
}
/* Поля ячеек списков на 601–1199px — по 4px (на ≥1200px обычные 8px): на 960px (боковое меню уже открыто, таблице ~676px)
   Остатки и Отгрузки иначе шире карточки на 20–44px даже без второстепенных колонок; на 601px Остатки — на 11px. */
@media (min-width: 601px) and (max-width: 1199.98px) {
    .wms-grid-fill .mud-table-cell { padding-left: 4px !important; padding-right: 4px !important; }
}
/* «Номер клиента» (у клиентов до 35 символов вида XAPU1234567|MDRHZBOL12345678) — переносится, а не распирает таблицу.
   Заголовок переносится по словам (anywhere рвал его «Ном/ер/клие/нта»); на планшете у колонки поля 4px — иначе Отгрузки на 768px шире карточки на 4px */
.mud-table-cell.cab-ref-cell { white-space: normal; }
td.mud-table-cell.cab-ref-cell { overflow-wrap: anywhere; }
@media (min-width: 601px) { .mud-table-cell.cab-ref-cell { max-width: 220px; padding-left: 4px !important; padding-right: 4px !important; } }
/* Сетка фото прихода: превью и плитка «Фото недоступно» — одинаковый блок 4:3 (inline <img> оставлял под собой ~6px строки,
   из-за чего подписи под превью были ниже, чем у плитки), подпись — блоком */
.cab-photo { display: block; width: 100%; aspect-ratio: 4 / 3; }
.cab-photo-img { object-fit: cover; border-radius: 4px; cursor: pointer; }
.cab-photo-missing { display: flex; }
.cab-photo-caption { display: block; }
/* П4: страницы-списки по паттерну веб-портала. Фильтры авто-высоты сверху, таблица забирает остаток,
   скролл внутри таблицы. 100vh - AppBar Dense 48 - pa-4 (16+16). */
.wms-page-fill { height: calc(100vh - 80px); display: flex; flex-direction: column; gap: 6px; min-height: 0; overflow: hidden; }
.wms-fill { flex: 1 1 0; min-height: 0; display: flex; flex-direction: column; overflow: hidden; }
.wms-grid-fill { flex: 1 1 auto; min-height: 0; display: flex !important; flex-direction: column; }
.wms-grid-fill > .mud-table-container { flex: 1 1 auto; min-height: 0; overflow-y: auto; overflow-x: auto; }
.wms-grid-fill > .mud-table-pagination { flex: none; }
.wms-page-fill .mud-table-cell { padding: 4px 8px; }
@media (max-width: 599.98px) {
    .wms-page-fill { height: auto; overflow: visible; }
    .wms-fill { flex: none; overflow: visible; }
    .wms-grid-fill { display: block !important; }
    .wms-grid-fill > .mud-table-container { overflow: visible; }
}
/* Выбранный пункт MudToggleGroup: белый текст на светло-синем (тёмная тема, Primary #60A5FA) читается плохо —
   берём фон темы: в светлой почти белый на тёмно-синем, в тёмной тёмный на светло-синем */
.mud-toggle-group .mud-toggle-item.mud-toggle-item-selected,
.mud-toggle-group .mud-toggle-item.mud-toggle-item-selected .mud-toggle-item-check-icon { color: var(--mud-palette-background); }

.cursor-pointer { cursor: pointer; }
.cab-tile-link { transition: background-color .15s ease; }
.cab-tile-link:hover { background-color: var(--mud-palette-action-default-hover); }
.cab-tile-link:focus-visible { outline: 2px solid var(--mud-palette-primary); outline-offset: 1px; }

.live-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: var(--mud-palette-success);
    display: inline-block;
    animation: pulse-dot 1.5s ease-in-out infinite;
}

@keyframes pulse-dot {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.5; transform: scale(1.3); }
}

/* Главная: таблицы «Последние …» — две колонки (номер + дата под ним, статус справа) помещаются в карточку */
.cab-recent-table table { table-layout: auto; width: 100%; }
.cab-recent-table th, .cab-recent-table td { padding-left: 8px; padding-right: 8px; }
.cab-recent-table .cab-recent-main { width: 100%; max-width: 0; overflow: hidden; }   /* max-width:0 + width:100% — ellipsis в auto-таблице */
/* S486: номер клиента переносом (до 3 строк, «|» — точка переноса), дата под статусом; узкие отступы — номер влезает в карточку lg=4 на 1366 */
.cab-recent-table .cab-recent-num { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; white-space: normal; overflow-wrap: anywhere; font-size: .8125rem; line-height: 1.35; }
.cab-recent-table .cab-recent-when { display: block; margin-top: 2px; font-size: .75rem; line-height: 1.3; color: var(--mud-palette-text-secondary); text-align: right; white-space: nowrap; }
.cab-recent-table.mud-simple-table th:first-child, .cab-recent-table.mud-simple-table td.cab-recent-main { padding-left: 8px; padding-right: 4px; }
.cab-recent-table.mud-simple-table th.cab-recent-status, .cab-recent-table.mud-simple-table td.cab-recent-status { white-space: nowrap; padding-left: 4px; padding-right: 4px; }
.cab-recent-table .cab-recent-date { display: block; font-size: .75rem; line-height: 1.3; color: var(--mud-palette-text-secondary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cab-recent-table .cab-recent-status { width: 1%; white-space: nowrap; text-align: right; }
/* Переключатель месяцев — в одну строку */
.cab-month-toggle .mud-toggle-item { white-space: nowrap; padding-left: 8px; padding-right: 8px; }
/* Подпись плитки — одна строка, одинаковая высота плиток */
.cab-tile-label { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* Остатки: артикул + иконка в одну строку */
.cab-sku { display: inline-flex; align-items: center; flex-wrap: nowrap; gap: 4px; white-space: nowrap; }
/* Главная: график по дням и топ артикулов (собственный CSS-график: MudChart в узкой раскладке режет подписи осей) */
.cab-trend-legend { display: flex; flex-wrap: wrap; gap: 4px 16px; margin-bottom: 10px; font-size: .8125rem; color: var(--mud-palette-text-secondary); }
.cab-trend-legend b { color: var(--mud-palette-text-primary); font-weight: 500; }
.cab-trend-dot { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 6px; }
.cab-trend-ship { background-color: var(--mud-palette-tertiary); }
.cab-trend-recv { background-color: var(--mud-palette-info); }
.cab-trend-body { display: flex; height: 220px; }
.cab-trend-y { flex: 0 0 48px; display: flex; flex-direction: column; justify-content: space-between; align-items: flex-end; padding-right: 8px; font-size: .6875rem; line-height: 1; color: var(--mud-palette-text-secondary); }
.cab-trend-plot { flex: 1 1 0; min-width: 0; display: flex; align-items: flex-end; gap: 2px; border-bottom: 1px solid var(--mud-palette-divider);
  background: linear-gradient(to bottom, var(--mud-palette-divider) 1px, transparent 1px) 0 0 / 100% 50%; }
.cab-trend-day { flex: 1 1 0; min-width: 0; height: 100%; display: flex; align-items: flex-end; justify-content: center; gap: 1px; }
.cab-trend-day:hover { background-color: var(--mud-palette-action-default-hover); }
.cab-trend-bar { flex: 1 1 0; min-width: 2px; max-width: 12px; border-radius: 2px 2px 0 0; }
.cab-trend-bar[style*="%"] { min-height: 2px; } /* ненулевое значение всегда видно */
.cab-trend-x { display: flex; gap: 2px; margin: 4px 0 0 48px; font-size: .6875rem; color: var(--mud-palette-text-secondary); }
.cab-trend-x span { flex: 1 1 0; min-width: 0; display: flex; justify-content: center; white-space: nowrap; }
.cab-top-name { min-width: 0; flex: 1 1 0; overflow: hidden; }
.cab-top-code { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cab-top-qty { flex: 0 0 auto; text-align: right; white-space: nowrap; }
/* Карточка документа: шапка — заголовок с чипами переносится внутри своего блока, кнопки всегда справа сверху */
.cab-doc-title { flex: 1 1 0; min-width: 0; gap: 8px; }
.cab-doc-actions { flex: 0 0 auto; }
/* Поля шапки: длинные значения без пробелов (номер клиента вида XAPU…|MDRHZBOL…) переносятся, а не налезают на соседнее поле */
.cab-doc-fields .mud-grid-item { min-width: 0; }
.cab-doc-fields .mud-typography { overflow-wrap: anywhere; }
/* S417: страница «Брак» */
/* Наименование артикула — переносится по словам, а не распирает таблицу на планшете */
.mud-table-cell.cab-wrap-cell { white-space: normal; }
td.mud-table-cell.cab-wrap-cell { overflow-wrap: anywhere; }
@media (min-width: 601px) { .mud-table-cell.cab-wrap-cell { max-width: 320px; } }
/* Фото: иконка + число одной строкой */
.cab-damage-photo { display: inline-flex; align-items: center; gap: 2px; cursor: pointer; }
/* S417: аудит 03.10 — карточки, тёмная тема */
/* Текущий шаг истории: обводка цветом темы (rgba(0,0,0,.2) в тёмной теме не видна) */
.cab-step-current { font-weight: 700; box-shadow: 0 0 0 3px var(--mud-palette-primary); }
/* Тёмная тема: белый текст на залитых чипах info/success/warning/error — контраст 1.9–3.4 (нужно ≥ 4.5), тёмный текст — ≥ 5.
   Класс cab-dark ставит MainLayout на <html> (диалоги рендерятся вне MudLayout) */
.cab-dark .mud-chip-filled:is(.mud-chip-color-info, .mud-chip-color-success, .mud-chip-color-warning, .mud-chip-color-error) { color: var(--mud-palette-background, #121212); }

/* S417: аудит 03.10 — списки */
/* Текст только для скринридеров (заголовок колонки без видимой подписи) */
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
/* Карточный режим таблиц (<601px, Mud: .mud-xs-table): подпись ячейки не ломается по букве, значение переносится и прижато вправо */
@media (max-width: 600px) {
    .mud-xs-table .mud-table-cell:before { white-space: nowrap; flex-shrink: 0; padding-right: 12px; padding-inline-end: 12px; }
    .mud-xs-table .mud-table-cell { text-align: end !important; overflow-wrap: anywhere; }
    /* Пустое значение (например, приход без расхождения): без подписи и высоты, 1px нижней границы строки остаётся (глобальный .mud-table-cell задаёт padding с !important) */
    .mud-xs-table.mud-table-dense .mud-table-cell.cab-card-empty { padding-top: 0 !important; padding-bottom: 0 !important; min-height: 0; }
    .mud-xs-table .mud-table-cell.cab-card-empty:before { content: none; }
}
/* Ряд фильтров: поля и чекбокс (выше полей) выровнены по вертикальному центру ячейки */
.cab-filter-row .mud-grid-item { display: flex; align-items: center; }
.cab-filter-row .mud-grid-item > * { flex: 1 1 auto; min-width: 0; }
/* S419: чип «Клиент: X» в шапке — чип по умолчанию на зелёном AppBar нечитаем (тёмный текст на тёмно-зелёном) */
.mud-appbar .mud-chip.cab-appbar-client { color: #fff; background-color: rgba(0, 0, 0, .22); }

/* LOAD-PLAN P8a: карточка плана. Страница с прокруткой окна; таблица с горизонтальной прокруткой, 3 первые колонки липкие. */
.lp-table-wrap { overflow-x: auto; }
.lp-table .mud-table-container { overflow-x: auto; }
.lp-table .mud-table-cell { padding: 4px 8px; font-size: .8125rem; }
.lp-s1, .lp-s2, .lp-s3 { position: sticky; z-index: 2; background: var(--mud-palette-surface); }
.lp-s1 { left: 0; min-width: 40px; width: 40px; }
.lp-s2 { left: 40px; min-width: 200px; width: 200px; }
.lp-s3 { left: 240px; min-width: 70px; width: 70px; }
.lp-truck-th { min-width: 130px; vertical-align: top; }
.lp-truck-head-text { white-space: pre-line; font-size: .7rem; line-height: 1.15; font-weight: 500; }
.lp-bar { height: 5px; border-radius: 2px; margin-top: 4px; }
.lp-bar-ok { background: var(--mud-palette-success); }
.lp-bar-risk { background: var(--mud-palette-error); }
.lp-bar-over { background: #7f0000; }
.lp-bar-unknown { background: var(--mud-palette-lines-default); }
.lp-sub { font-size: .7rem; color: var(--mud-palette-text-secondary); }
.lp-empty { color: var(--mud-palette-text-disabled); }
.lp-foot { font-weight: 600; vertical-align: top; }
.lp-req-row { display: flex; flex-wrap: wrap; gap: 8px; }
.lp-req-card { min-width: 260px; max-width: 380px; flex: 1 1 260px; font-size: .8125rem; }

.lp-cell-edit { display: flex; align-items: center; justify-content: center; gap: 2px; }
.lp-filter-dates { display: flex; align-items: center; gap: 8px; }
.lp-num { width: 56px; max-width: 56px; }
.lp-num input { text-align: center; padding: 2px 0 !important; }
.lp-truck-tools { display: flex; align-items: center; gap: 2px; }
.lp-type-select { width: 90px; font-size: .75rem; }
