/* Пульт по дизайн-системе «Простой стана» (вариант A): панель состояния + одна кнопка действия,
   две колонки от 1024 px, шкала суток полосой под ними. Только токены из tokens.css. */

/* ---------- Раскладка главного экрана ---------- */
main:has(.with-scale) { max-width: var(--content-max); margin: 0 auto; }
.with-scale { gap: var(--space-4); align-items: start; }
.with-scale__main { display: grid; gap: var(--space-4); grid-template-columns: minmax(0, 1fr); align-items: start; }
.with-scale__main > .stop-grid { display: contents; }
.with-scale__main > .stop-grid > * { min-width: 0; }
/* Причина указана и передач ремонта нет — правая часть пуста, смена встаёт наверх колонки */
.with-scale__main > .stop-grid > :empty { display: none; }
@media (min-width: 1024px) {
  .with-scale__main { grid-template-columns: minmax(0, 1.5fr) minmax(340px, 1fr); }
  .with-scale__main > .pult, .with-scale__main > .stop-grid > :first-child { grid-column: 1; grid-row: 1 / span 2; }
  .with-scale__main > .shift-block, .with-scale__main > .stop-grid > :last-child { grid-column: 2; }
}

/* Непринятая смена: полоса занимает собственную строку над пультом. */
.crew-strip { display: flex; align-items: center; gap: 12px; width: 100%; min-width: 0;
  padding: 8px 12px; border: 2px solid var(--warn); border-radius: var(--radius-md);
  background: var(--warn-soft); color: var(--warn-ink); }
.crew-strip > .ps-ico { flex: none; }
.crew-strip__text { flex: 1; min-width: 0; font-size: 16px; line-height: 22px; }
.with-scale > .crew-strip > button.ps-btn { flex: none; min-height: 52px; padding: 8px 20px; font-size: 17px; }
@media (max-width: 599px) {
  .crew-strip { flex-wrap: wrap; gap: 6px 8px; padding: 8px 10px; }
  .crew-strip__text { font-size: 14px; line-height: 19px; }
  .with-scale > .crew-strip > button.ps-btn { width: 100%; min-height: 48px; }
}

/* ---------- Пульт ---------- */
.pult { display: grid; gap: var(--space-4); }
.ps-state { position: relative; display: grid; gap: var(--space-2); padding: var(--space-5); border-radius: var(--radius-lg);
  background: var(--run-soft); color: var(--run-ink); }
.ps-state[data-state="stop"] { background: var(--stop-soft); color: var(--stop-ink); }
.pult-state__top { display: flex; align-items: center; gap: var(--space-3); min-height: 40px; }
.pult-state__top .report-menu, .pult-state__top > :not(.ps-state__eyebrow) { margin-left: auto; }
.ps-state__eyebrow { display: flex; align-items: center; gap: var(--space-2); font-size: 13px; line-height: 18px; font-weight: 700;
  letter-spacing: 0.08em; text-transform: uppercase; }
.ps-state__title { margin: 0; font-size: 44px; line-height: 48px; font-weight: 800; letter-spacing: -0.01em; }
.ps-state__timer { font-variant-numeric: tabular-nums; font-size: 64px; line-height: 64px; font-weight: 700; letter-spacing: -0.02em;
  display: flex; flex-wrap: wrap; align-items: baseline; gap: 0 var(--space-3); }
/* Подпись «работает уже / стоит уже» рядом с цифрами: чтобы 05:41 не читалось как время суток */
.ps-state__cap { font-size: 16px; line-height: 22px; font-weight: 600; letter-spacing: 0; opacity: .85; }
/* Нет связи с сервером дольше 30 с: данные могли устареть, таймер приглушён, кнопки остаются */
.ps-state__stale { margin: 0; font-size: 16px; line-height: 22px; font-weight: 700; color: var(--ink); }
.ps-state--stale .ps-state__timer { opacity: .45; }
.ps-state__meta { margin: 0; font-size: 16px; line-height: 24px; font-weight: 500; color: var(--ink-2); }
.ps-dot { position: relative; width: 12px; height: 12px; flex: none; border-radius: var(--radius-pill); background: var(--run); }
.ps-dot[data-tone="stop"] { background: var(--stop); }
.ps-dot[data-live]::after { content: ""; position: absolute; inset: -4px; border-radius: inherit; border: 2px solid currentColor;
  opacity: 0; animation: ps-pulse 2s ease-out infinite; }
@keyframes ps-pulse { 0% { opacity: .7; transform: scale(.6); } 100% { opacity: 0; transform: scale(1.4); } }

.ps-action { display: flex; align-items: center; gap: var(--space-4); width: 100%; min-height: var(--action-height); margin: 0;
  padding: var(--space-4) var(--space-5); border: 0; border-radius: var(--radius-lg); box-shadow: var(--shadow-action);
  cursor: pointer; text-align: left; touch-action: manipulation; transition: transform .08s ease, filter .12s ease;
  -webkit-tap-highlight-color: transparent; }
.ps-action:active { transform: translateY(2px); box-shadow: none; }
.ps-action:hover { filter: brightness(1.06); }
.ps-action--stop { background: var(--stop-strong); color: var(--on-stop); }
.ps-action--run { background: var(--run-strong); color: var(--on-run); }
.ps-action__icon { display: grid; place-items: center; width: 64px; height: 64px; flex: none; border-radius: var(--radius-pill); border: 3px solid currentColor; }
.ps-action__icon .ico { width: 30px; height: 30px; fill: currentColor; stroke: none; }
.ps-action__text { display: grid; gap: 2px; min-width: 0; }
.ps-action__label { font-size: 30px; line-height: 34px; font-weight: 800; letter-spacing: 0.01em; text-transform: uppercase; }
.ps-action__hint { font-size: 15px; line-height: 20px; font-weight: 500; opacity: .92; overflow-wrap: anywhere; }
.ps-action:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; }
@media (prefers-reduced-motion: reduce) { .ps-dot[data-live]::after { animation: none; } .ps-action { transition: none; } }

/* Телефон: компактнее, чтобы пульт и кнопка помещались на первом экране */
@media (max-width: 599px) {
  .ps-state { padding: var(--space-4); gap: var(--space-1); }
  .ps-state__title { font-size: 30px; line-height: 34px; }
  .ps-state__timer { font-size: 44px; line-height: 48px; }
  .ps-action { min-height: calc(var(--target-glove) + var(--space-4)); padding: var(--space-3) var(--space-4); gap: var(--space-3); }
  .ps-action__icon { width: 52px; height: 52px; border-width: 2.5px; }
  .ps-action__icon .ico { width: 24px; height: 24px; }
  .ps-action__label { font-size: 24px; line-height: 28px; }
  .ps-action__hint { font-size: 13px; line-height: 18px; }
}
.pult:has(.rep.is-open) { position: relative; z-index: 4; }

/* ---------- Шапка ---------- */
.topbar { flex-wrap: nowrap; gap: var(--space-3); min-height: 64px; padding: calc(8px + env(safe-area-inset-top)) var(--space-4) 8px;
  background: var(--surface); border-bottom: 1px solid var(--line); }
.topbar .brand { display: flex; align-items: center; gap: var(--space-3); min-width: 0; margin-right: auto; text-align: left; }
.brand-mark { display: grid; place-items: center; width: 40px; height: 40px; flex: none; border-radius: var(--radius-sm); background: var(--ink); color: var(--ink-inverse); }
.brand-mark .ico { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; }
/* Логотип ТМПЗ: файл tmpz-logo.svg рисуется маской цветом текста (currentColor), поэтому читается и в Дне, и в Ночи */
.brand-logo { flex: none; width: 107px; height: 28px; color: var(--ink); background: currentColor;
  -webkit-mask: url("tmpz-logo.svg") no-repeat left center / contain; mask: url("tmpz-logo.svg") no-repeat left center / contain; }
.brand-name { display: grid; min-width: 0; }
.topbar .brand-name strong { font-size: 18px; line-height: 22px; white-space: nowrap; font-weight: 800; letter-spacing: 0; text-transform: none; color: var(--ink); }
.topbar .brand-name span { font-size: 13px; line-height: 16px; font-weight: 600; letter-spacing: 0; text-transform: none; color: var(--ink-3); }
.topclock { display: grid; justify-items: end; flex: none; font-size: 22px; line-height: 26px; font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.topclock small { font-size: 13px; line-height: 16px; font-weight: 600; color: var(--ink-3); }
.topbar .theme-toggle { display: grid; place-items: center; width: var(--target-min); height: var(--target-min); flex: none; padding: 0; margin: 0;
  border-radius: var(--radius-pill); border: 1px solid var(--line); background: var(--surface); color: var(--ink); box-shadow: none; }
.topbar .theme-toggle:hover { background: var(--surface-2); }
.topbar .save-status { color: var(--ink-2); font-size: 13px; line-height: 18px; font-weight: 600; }
.save-status.online::before { background: var(--run); }
.save-status.waiting::before { background: var(--warn); }
.save-status.offline::before { background: var(--stop); }
@media (max-width: 599px) {
  .topbar { gap: var(--space-2); padding-inline: var(--space-3); }
  .topbar .brand-name { display: none; }
  /* Логотип сжимается вместе с блоком бренда (не уже 56 px): раньше блок сжимался, а логотип нет и наезжал на плашку «по сигналу» */
  .topbar .brand { flex: 0 1 86px; min-width: 56px; }
  .brand-logo { width: 100%; height: 22px; }
  .topclock { font-size: 18px; line-height: 22px; }
  .topclock small { display: none; }
}
@media (max-width: 480px) {
  /* Телефон: логотип, «По сигналу · N с», точка связи, время и лампа в 390 px без наложений — пояс «МСК» у часов прячем */
  .topbar { gap: 6px; }
  .topclock .topclock__tz { display: none; }
}

/* ---------- Навигация: снизу на телефоне и планшете, слева от 1024 px ---------- */
.appnav { position: fixed; z-index: 6; left: 0; right: 0; bottom: 0; display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr);
  gap: 2px; min-height: var(--tabbar-height); padding: 4px 6px calc(4px + env(safe-area-inset-bottom));
  background: var(--surface); border-top: 1px solid var(--line); }
.appnav .pill { display: grid; justify-items: center; align-content: center; gap: 2px; min-width: 0; min-height: var(--target-glove); margin: 0;
  padding: 6px 2px; border: 0; border-radius: var(--radius-md); background: transparent; color: var(--ink-2); box-shadow: none;
  font-size: 13px; line-height: 16px; font-weight: 600; white-space: nowrap; cursor: pointer; }
.appnav .pill[hidden] { display: none; }
.appnav .pill .ico { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.appnav .pill .pill-text { position: static; width: auto; height: auto; overflow: hidden; clip-path: none; max-width: 100%; text-overflow: ellipsis; }
.appnav .pill:hover { background: var(--surface-2); color: var(--ink); }
.appnav .pill[aria-current="page"] { background: var(--ink); color: var(--ink-inverse); }
body { padding-bottom: calc(var(--tabbar-height) + env(safe-area-inset-bottom)); }
/* Автопрокрутка к элементу в фокусе (Tab) останавливается выше нижнего меню, а не под ним */
html { scroll-padding-bottom: calc(var(--tabbar-height) + env(safe-area-inset-bottom) + var(--space-3)); }
.toast { bottom: calc(var(--tabbar-height) + 16px + env(safe-area-inset-bottom)); }
/* Телефон: сообщение во всю ширину окна поверх содержимого, над нижним меню. Раньше оно было sticky и 3 секунды сдвигало экран на ~40 px */
@media (max-width: 600px) {
  .toast { left: 8px; right: 8px; top: auto; transform: none; width: auto; max-width: none; margin: 0; padding: 12px 14px; box-sizing: border-box;
    border-radius: var(--radius-sm); font-size: 15px; text-align: center; }
}
@media (min-width: 1024px) {
  .appnav { top: 0; bottom: 0; right: auto; width: var(--rail-width); grid-auto-flow: row; grid-auto-rows: min-content; grid-auto-columns: auto;
    align-content: start; gap: var(--space-1); padding: calc(76px + env(safe-area-inset-top)) 4px var(--space-3);
    border-top: 0; border-right: 1px solid var(--line); }
  body { padding-bottom: 0; padding-left: var(--rail-width); }
  html { scroll-padding-bottom: var(--space-3); }
  .toast { bottom: calc(20px + env(safe-area-inset-bottom)); }
  /* Подпись под значком: «Показатели» не помещается в 80 px крупным шрифтом */
  .appnav .pill { font-size: 13px; padding-inline: 0; }
  .appnav .pill .pill-text { overflow: visible; text-overflow: clip; letter-spacing: -0.02em; }
}
/* Excel на телефоне — только значок */
@media (max-width: 599px) {
  .ps-state .rep-label { display: none; }
  .ps-state .rep-btn { width: 44px; padding: 0; }
}
.topbar .brand { order: -1; margin-left: 0; }
@media (max-width: 599px) { .appnav { padding-inline: 2px; } .appnav .pill { font-size: 13px; padding-inline: 0; } }

@media (min-width: 600px) { .topbar .save-status-text { white-space: nowrap; } }

/* Телефон с шестью разделами (ключ администратора): «Админ» и «Ассистент» — значками, подпись остаётся для чтения с экрана */
@media (max-width: 599px) {
  .appnav { display: flex; }
  .appnav .pill { flex: 1 1 auto; font-size: 13px; }
  /* Зона нажатия не меньше 44 px: «Пульт» с короткой подписью не должен сжиматься уже */
  .appnav .pill { min-width: 44px; }
  .appnav .pill .pill-text { overflow: visible; text-overflow: clip; letter-spacing: -0.02em; }
  .appnav #admin, .appnav #ai-ask, .appnav #conn, .appnav #nav-sklad { flex: 0 0 44px; }
  .appnav #admin .pill-text, .appnav #ai-ask .pill-text, .appnav #conn .pill-text, .appnav #nav-sklad .pill-text { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
}

@media (max-width: 599px) { .appnav { gap: 0; padding-inline: 0; } .appnav .pill { padding-inline: 0; letter-spacing: -0.01em; } }
/* 320 px: шесть пунктов с подписью 13 px и зоной не меньше 44 px вместе дают 324 px — подпись чуть плотнее, без обрезки */
@media (max-width: 359.98px) { .appnav .pill .pill-text { letter-spacing: -0.04em; } }
/* Узкая панель: с семью пунктами подписи слипаются уже ниже 380 px (раньше — ниже 335 при шести): значки по 44 px, подпись — только
   у текущего раздела. Остальные подписи остаются в aria-label и title, зона нажатия не меньше 44 px, шрифт 13 px */
@media (max-width: 599px) {
  .appnav { container-type: inline-size; }
  /* Семь пунктов (с «Параметрами»): до 379 px подпись только у текущего раздела, а длинные подписи («Параметры», «Показатели»)
     не помещаются в оставшиеся ~56–76 px на 320–349 px и у текущего: значок остаётся, название — в aria-label и title */
  @container (max-width: 379px) {
    .appnav .pill:not([aria-current="page"]) { flex: 0 0 44px; }
    .appnav .pill:not([aria-current="page"]) .pill-text { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
  }
  /* Восемь пунктов (администратору — «Ассистент» и «Склад» значками): четыре подписи помещаются только от 424 px, уже — подпись у текущего */
  @container (max-width: 423px) {
    .appnav:has(#ai-ask:not([hidden])):has(#nav-sklad:not([hidden])) .pill:not([aria-current="page"]) { flex: 0 0 44px; }
    .appnav:has(#ai-ask:not([hidden])):has(#nav-sklad:not([hidden])) .pill:not([aria-current="page"]) .pill-text { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
  }
}
/* Восемь пунктов уже 390 px: на подпись текущего остаётся меньше 82 px («Показатели» не помещается) — все пункты значками, текущий выделен фоном,
   названия остаются в aria-label и title */
@media (max-width: 389px) {
  .appnav:has(#ai-ask:not([hidden])):has(#nav-sklad:not([hidden])) .pill .pill-text { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
}
/* По ширине окна, а не панели: если подпись не помещается, мобильный Chrome расширяет окно под панель, и контейнерный запрос уже не сработал бы */
@media (max-width: 359px) {
  .appnav #nav-params[aria-current="page"] .pill-text, .appnav #nav-stats[aria-current="page"] .pill-text { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
}

/* ---------- Экраны рабочего: мастер причины, «что сделали», связь ----------
   Компоненты ps-* перенесены из bundle.css дизайн-системы; только токены из tokens.css. */
.ps-ico { width: 24px; height: 24px; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.ps-overline { font-size: 13px; line-height: 18px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-3); }
.ps-flow, .ps-pick { display: grid; gap: var(--space-4); align-content: start; min-width: 0; }
.ps-flow > * { min-width: 0; }
.ps-flow h1.q { margin: 0; font-size: 26px; line-height: 32px; font-weight: 800; color: var(--ink); }
.ps-flow .step { margin: 0; font-size: 13px; line-height: 18px; font-weight: 600; color: var(--ink-3); font-variant-numeric: tabular-nums; }
main:has(.ps-flow) > .cancel { min-height: var(--target-min); margin-top: var(--space-4); border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  background: transparent; color: var(--ink-2); font-size: 15px; line-height: 20px; font-weight: 600; }
.ps-state--compact { padding: var(--space-4); gap: var(--space-1); }
.ps-state--compact .ps-state__title { font-size: 30px; line-height: 34px; }
.ps-state--compact .ps-state__timer { font-size: 40px; line-height: 44px; }
.ps-picked { display: flex; align-items: center; gap: var(--space-3); padding: var(--space-3) var(--space-4); border-radius: var(--radius-sm); background: var(--surface-2); color: var(--ink); font-size: 16px; line-height: 22px; font-weight: 700; overflow-wrap: anywhere; }

/* Кнопки */
.ps-btn { display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2); min-height: var(--target-min); margin: 0; padding: 0 var(--space-5); border-radius: var(--radius-sm); border: 1px solid transparent; font-size: 15px; line-height: 20px; font-weight: 600; text-align: center; cursor: pointer; text-decoration: none; touch-action: manipulation; transition: filter .12s ease, transform .08s ease, background-color .12s ease; -webkit-tap-highlight-color: transparent; }
.ps-btn:active { transform: translateY(1px); }
.ps-btn--lg { min-height: var(--target-glove); font-size: 17px; border-radius: var(--radius-md); }
.ps-btn--block { width: 100%; }
.ps-btn--primary { background: var(--ink); color: var(--ink-inverse); }
.ps-btn--run { background: var(--run-strong); color: var(--on-run); }
.ps-btn--stop { background: var(--stop-strong); color: var(--on-stop); }
.ps-btn--secondary { background: var(--surface); color: var(--ink); border-color: var(--line-strong); }
.ps-btn--ghost { background: transparent; color: var(--ink); }
.ps-btn--ghost:hover, .ps-btn--secondary:hover { background: var(--surface-2); }
.ps-btn--primary:hover, .ps-btn--run:hover, .ps-btn--stop:hover { filter: brightness(1.08); }
.ps-btn[disabled], .ps-btn[aria-disabled="true"] { background: var(--surface-3); color: var(--ink-3); border-color: transparent; cursor: not-allowed; transform: none; filter: none; }
.ps-actions { display: flex; flex-wrap: wrap; gap: var(--space-2); }
.ps-actions .ps-btn { flex: 1 1 200px; }

/* Плитки причины: три группы вместо 21 кода. В узкой колонке (контейнер уже 600 px) — списком */
.ps-reasons-box { container-type: inline-size; }
.ps-reasons { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--space-3); }
.ps-reason { position: relative; display: grid; align-content: start; gap: var(--space-2); min-height: 132px; margin: 0; padding: var(--space-4); border-radius: var(--radius-md); border: 2px solid var(--line); background: var(--surface); color: var(--ink); text-align: left; cursor: pointer; touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
.ps-reason:active { transform: translateY(1px); }
.ps-reason__icon { display: grid; place-items: center; width: 44px; height: 44px; border-radius: var(--radius-sm); background: var(--plan-soft); color: var(--plan-ink); }
.ps-reason[data-zone="unplanned"] .ps-reason__icon { background: var(--unplanned-soft); color: var(--unplanned-ink); }
.ps-reason[data-zone="failure"] .ps-reason__icon { background: var(--stop-soft); color: var(--stop-ink); }
.ps-reason__title { font-size: 20px; line-height: 24px; font-weight: 800; overflow-wrap: anywhere; }
.ps-reason__sub { font-size: 13px; line-height: 18px; color: var(--ink-2); }
.ps-reason[aria-pressed="true"] { border-color: var(--zone-plan); background: var(--plan-soft); }
.ps-reason[data-zone="unplanned"][aria-pressed="true"] { border-color: var(--zone-unplanned); background: var(--unplanned-soft); }
.ps-reason[data-zone="failure"][aria-pressed="true"] { border-color: var(--zone-failure); background: var(--stop-soft); }
.ps-reason[aria-pressed="true"]::after { content: "✓"; position: absolute; top: var(--space-3); right: var(--space-3); display: grid; place-items: center; width: 28px; height: 28px; border-radius: var(--radius-pill); background: var(--ink); color: var(--ink-inverse); font-size: 16px; font-weight: 800; }
@container (max-width: 599px) {
  .ps-reasons { grid-template-columns: minmax(0, 1fr); gap: var(--space-2); }
  .ps-reason { grid-template-columns: auto minmax(0, 1fr); align-items: center; column-gap: var(--space-3); row-gap: 0; min-height: 80px; padding: var(--space-3) var(--space-4); }
  .ps-reason__icon { grid-row: span 2; }
  .ps-reason__title { font-size: 18px; line-height: 22px; padding-right: 32px; }
  .ps-reason[aria-pressed="true"]::after { top: 50%; transform: translateY(-50%); }
}

/* Чипы: уточнение причины, быстрые варианты, брак */
.ps-chips { display: flex; flex-wrap: wrap; gap: var(--space-2); }
.ps-chip { display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2); min-width: 48px; min-height: var(--target-min); margin: 0; padding: 0 var(--space-4); border-radius: var(--radius-pill); border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink); font-size: 15px; line-height: 20px; font-weight: 600; text-align: left; cursor: pointer; touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
.ps-chip:hover { background: var(--surface-2); }
.ps-chip[aria-pressed="true"] { background: var(--ink); color: var(--ink-inverse); border-color: var(--ink); }
.ps-chips--items { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.ps-chip--item { min-height: var(--target-glove); padding: var(--space-2) var(--space-4); border-radius: var(--radius-md); border-width: 2px; border-color: var(--line); }
.ps-chip__text { display: grid; gap: 2px; min-width: 0; }
.ps-chip__label { overflow-wrap: anywhere; }
.ps-chip__zone { font-size: 13px; line-height: 18px; font-weight: 500; color: var(--ink-2); }
.ps-chip[aria-pressed="true"] .ps-chip__zone { color: inherit; }
@media (max-width: 599px) { .ps-chips--items { grid-template-columns: minmax(0, 1fr); } }
.ps-swatch { width: 12px; height: 12px; flex: none; border-radius: 3px; background: var(--zone-work); }
.ps-swatch[data-zone="plan"] { background: var(--zone-plan); }
.ps-swatch[data-zone="unplanned"] { background: var(--zone-unplanned); }
.ps-swatch[data-zone="pending"] { background: var(--chart-3); }
.ps-swatch[data-zone="failure"] { background-color: var(--zone-failure); background-image: repeating-linear-gradient(-45deg, transparent 0 3px, rgba(255, 255, 255, .45) 3px 5px); }

/* Поля формы */
.ps-field { display: grid; gap: 6px; min-width: 0; margin: 0; }
.ps-field__label { margin: 0; font-size: 14px; line-height: 20px; font-weight: 600; color: var(--ink-2); }
.ps-field__hint { font-size: 13px; line-height: 18px; color: var(--ink-3); }
.ps-field__error { margin: 0; font-size: 14px; line-height: 20px; font-weight: 600; color: var(--stop-ink); }
.ps-input { width: 100%; min-height: var(--target-min); margin: 0; padding: 0 var(--space-4); border-radius: var(--radius-sm); border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink); font: inherit; font-size: 16px; line-height: 24px; }
textarea.ps-input { min-height: 104px; padding: var(--space-3) var(--space-4); resize: vertical; }
.ps-input::placeholder { color: var(--ink-3); opacity: 1; }
.ps-input[aria-invalid="true"] { border-color: var(--stop-ink); box-shadow: 0 0 0 1px var(--stop-ink); }
.ps-input:focus { outline: 3px solid var(--focus); outline-offset: 1px; }

/* Карточка, лист «что сделали» */
.ps-card { display: grid; align-content: start; gap: var(--space-4); padding: var(--space-5); border-radius: var(--radius-md); background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow-1); min-width: 0; }
.ps-card h1.q { font-size: 22px; line-height: 28px; }
@media (max-width: 599px) { .ps-card { padding: var(--space-4); } }
.ps-restart .ps-field__hint { overflow-wrap: anywhere; }

/* Сообщение */
.ps-notice { display: flex; align-items: center; gap: var(--space-3); padding: var(--space-3) var(--space-4); border-radius: var(--radius-sm); background: var(--warn-soft); color: var(--warn-ink); font-size: 15px; line-height: 20px; font-weight: 600; overflow-wrap: anywhere; }
.ps-notice[data-tone="ok"] { background: var(--run-soft); color: var(--run-ink); }
.ps-notice[data-tone="stop"] { background: var(--stop-soft); color: var(--stop-ink); }
.ps-notice[data-tone="info"] { background: var(--surface-2); color: var(--ink-2); }
.ps-notice__body { display: grid; gap: var(--space-1); min-width: 0; }
.ps-notice__line { font-weight: 500; white-space: pre-wrap; }

/* Карточки звонка */
.ps-contacts { display: grid; gap: var(--space-3); }
.ps-contact { display: flex; align-items: center; gap: var(--space-4); width: 100%; min-height: 88px; padding: var(--space-4); border-radius: var(--radius-md); border: 1px solid var(--line); background: var(--surface); color: var(--ink); box-shadow: var(--shadow-1); text-align: left; text-decoration: none; cursor: pointer; }
.ps-contact:hover { background: var(--surface-2); }
.ps-contact__icon { display: grid; place-items: center; width: 56px; height: 56px; flex: none; border-radius: var(--radius-pill); background: var(--run-strong); color: var(--on-run); }
.ps-contact__text { display: grid; min-width: 0; }
.ps-contact__role { font-size: 13px; line-height: 18px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink-3); }
.ps-contact__name { font-size: 19px; line-height: 24px; font-weight: 700; overflow-wrap: anywhere; }
.ps-contact__phone { font-size: 16px; line-height: 22px; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.ps-contact[aria-disabled="true"] { background: var(--surface-2); box-shadow: none; cursor: default; }
.ps-contact[aria-disabled="true"] .ps-contact__icon { background: var(--surface-3); color: var(--ink-3); }
.ps-contact[aria-disabled="true"] .ps-contact__phone { color: var(--ink-3); }
@media (min-width: 600px) { .ps-contacts { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* Фокус и движение */
.ps-btn:focus-visible, .ps-chip:focus-visible, .ps-reason:focus-visible, .ps-contact:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { .ps-btn, .ps-reason { transition: none; } .ps-btn:active, .ps-reason:active { transform: none; } }

/* ---------- Экраны мастера смены: приём, простои, сдача ----------
   ps-shift, ps-row, ps-choice, ps-stepper, ps-checklist, ps-kpi перенесены из bundle.css дизайн-системы. */
.ps-card__head { display: flex; align-items: center; gap: var(--space-3); min-height: 28px; }
.ps-card__title { margin: 0; font-size: 20px; line-height: 26px; font-weight: 700; }
.ps-card__aside { margin-left: auto; font-size: 13px; line-height: 18px; font-weight: 500; color: var(--ink-3); }
/* Кнопка «Показать/Скрыть» разобранных простоев: текстовая, но с целью под палец не меньше 44 px */
.ps-card__toggle { margin-left: auto; min-height: 44px; padding: 0 var(--space-2); border: 0; background: none; font: inherit; font-size: 14px; font-weight: 600; color: var(--focus); cursor: pointer; border-radius: 8px; }
.ps-card__toggle:hover { text-decoration: underline; }
.ps-card__toggle:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

/* ---------- Мастер смены ---------- */
.ps-shift { display: grid; gap: var(--space-4); }
.ps-shift__who { display: flex; align-items: center; gap: var(--space-3); min-width: 0; }
.ps-avatar { display: grid; place-items: center; width: 52px; height: 52px; flex: none; border-radius: var(--radius-pill); background: var(--surface-3); color: var(--ink); font-size: 18px; font-weight: 800; }
.ps-shift__name { margin: 0; font-size: 20px; line-height: 26px; font-weight: 700; overflow-wrap: anywhere; }
.ps-shift__meta { font-size: 14px; line-height: 20px; color: var(--ink-2); }
.ps-progress { display: grid; gap: var(--space-2); }
.ps-progress__track { height: 10px; border-radius: var(--radius-pill); background: var(--surface-3); overflow: hidden; }
.ps-progress__fill { height: 100%; border-radius: inherit; background: var(--ink); }
.ps-progress__row { display: flex; justify-content: space-between; gap: var(--space-3); font-size: 14px; line-height: 20px; color: var(--ink-2); }
.ps-progress__row b { color: var(--ink); }

/* ---------- Итоги смены (показатели) ---------- */
.ps-kpis-cap { font-size: 13px; line-height: 18px; font-weight: 600; color: var(--ink-2); }
.ps-kpis { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-2); }
.ps-kpi { display: grid; gap: var(--space-1); padding: var(--space-3); border-radius: var(--radius-sm); background: var(--surface-2); min-width: 0; }
.ps-kpi__label { display: flex; align-items: center; gap: var(--space-2); font-size: 13px; line-height: 18px; font-weight: 600; color: var(--ink-2); }
.ps-kpi__value { font-family: var(--font-sans); font-variant-numeric: tabular-nums; font-size: 24px; line-height: 28px; font-weight: 700; color: var(--ink); white-space: nowrap; }
.ps-kpi__value { letter-spacing: 0; }
.ps-kpi__value small { font-size: 15px; font-weight: 600; color: var(--ink-3); }
.ps-kpi[data-zero] .ps-kpi__value { color: var(--ink-3); }
.ps-kpis--row { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.ps-tag { display: inline-block; max-width: 100%; overflow: hidden; text-overflow: ellipsis; vertical-align: top; padding: 2px 8px; border-radius: var(--radius-xs); background: var(--plan-soft); color: var(--plan-ink); font-size: 13px; line-height: 18px; font-weight: 700; white-space: nowrap; }
.ps-tag[data-zone="unplanned"] { background: var(--unplanned-soft); color: var(--unplanned-ink); }
.ps-tag[data-zone="failure"] { background: var(--stop-soft); color: var(--stop-ink); }
.ps-tag[data-zone="pending"] { background: var(--warn-soft); color: var(--warn-ink); }
.ps-tag[data-zone="work"] { background: var(--run-soft); color: var(--run-ink); }

/* ---------- Строка простоя ---------- */
.ps-rows { display: grid; gap: var(--space-2); }
/* Прошлые смены в разборе: группы по сменам с заголовком */
.ps-shift-groups { display: grid; gap: var(--space-4); }
.ps-shift-group { display: grid; gap: var(--space-2); }
.ps-shift-group__title { margin: 0; font-size: 14px; line-height: 20px; font-weight: 800; color: var(--ink-2); }
.ps-row { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: var(--space-2) var(--space-4); padding: var(--space-3) var(--space-4); border-radius: var(--radius-sm); background: var(--surface-2); color: var(--ink); text-align: left; border: 0; width: 100%; cursor: pointer; }
.ps-row:hover { background: var(--surface-3); }
.ps-row__time { font-family: var(--font-sans); font-variant-numeric: tabular-nums; font-size: 15px; line-height: 20px; font-weight: 700; white-space: nowrap; }
.ps-row__main { display: grid; gap: 2px; min-width: 0; }
.ps-row__main > * { min-width: 0; overflow: hidden; }
.ps-row__what { font-size: 14px; line-height: 20px; color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ps-row__what[data-missing] { color: var(--warn-ink); font-weight: 600; }
.ps-row__dur { font-family: var(--font-sans); font-variant-numeric: tabular-nums; font-size: 15px; line-height: 20px; font-weight: 700; white-space: nowrap; }
.ps-stepper { display: inline-grid; grid-template-columns: var(--target-min) minmax(88px, auto) var(--target-min); align-items: center; border: 1px solid var(--line-strong); border-radius: var(--radius-sm); background: var(--surface); overflow: hidden; }
.ps-stepper button { height: var(--target-min); border: 0; background: var(--surface-2); color: var(--ink); font-size: 22px; line-height: 1; font-weight: 700; cursor: pointer; }
.ps-stepper button:hover { background: var(--surface-3); }
.ps-stepper output { padding: 0 var(--space-2); text-align: center; font-size: 20px; line-height: 24px; font-weight: 700; font-variant-numeric: tabular-nums; }
.ps-form-row { display: flex; flex-wrap: wrap; align-items: end; gap: var(--space-3); }
.ps-form-row > .ps-field { flex: 1 1 200px; }

/* ---------- Выбор карточкой ---------- */
.ps-choices { display: grid; gap: var(--space-2); }
.ps-choice { display: flex; align-items: center; gap: var(--space-3); width: 100%; min-height: var(--target-glove); padding: var(--space-3) var(--space-4); border-radius: var(--radius-md); border: 2px solid var(--line); background: var(--surface); color: var(--ink); text-align: left; cursor: pointer; }
.ps-choice__radio { width: 24px; height: 24px; flex: none; border-radius: var(--radius-pill); border: 2px solid var(--line-strong); }
.ps-choice[aria-checked="true"] { border-color: var(--ink); }
.ps-choice[aria-checked="true"] .ps-choice__radio { border-color: var(--ink); background: var(--ink); box-shadow: inset 0 0 0 4px var(--surface); }
.ps-choice__text { display: grid; min-width: 0; }
.ps-choice__title { font-size: 17px; line-height: 22px; font-weight: 700; }
.ps-choice__sub { font-size: 13px; line-height: 18px; color: var(--ink-3); }
.ps-checklist { display: grid; gap: var(--space-2); margin: 0; padding: 0; list-style: none; }
.ps-check { display: flex; align-items: center; gap: var(--space-3); min-height: 56px; padding: var(--space-2) var(--space-4); border-radius: var(--radius-sm); background: var(--surface-2); font-size: 16px; line-height: 22px; }
.ps-check__mark { display: grid; place-items: center; width: 28px; height: 28px; flex: none; border-radius: var(--radius-pill); background: var(--run-strong); color: var(--on-run); }
.ps-check__mark .ps-ico { width: 16px; height: 16px; stroke-width: 3; }
.ps-check[data-status="todo"] { background: var(--warn-soft); color: var(--warn-ink); font-weight: 600; }
.ps-check[data-status="todo"] .ps-check__mark { background: var(--warn); color: var(--ink); }
.ps-check .ps-btn { margin-left: auto; min-height: var(--target-min); padding: 0 var(--space-4); }

/* Раскладка: одна колонка, от 1024 px — две; список простоев слева, редактор справа */
.ps-flow--narrow { max-width: 640px; }
main:has(.ps-cols) { max-width: var(--content-max); margin: 0 auto; }
.ps-head { display: flex; flex-wrap: wrap; align-items: end; gap: var(--space-3); }
.ps-head__text { display: grid; gap: 2px; margin-right: auto; min-width: 0; }
.ps-cols { display: grid; gap: var(--space-4); grid-template-columns: minmax(0, 1fr); align-items: start; }
.ps-stack { display: grid; gap: var(--space-4); align-content: start; min-width: 0; }
@media (min-width: 1024px) { .ps-cols { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); } }
.ps-actions--col .ps-btn { flex: 1 1 100%; }
.ps-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.ps-card h2.ps-card__title { font-size: 20px; line-height: 26px; }
.ps-choice:hover { background: var(--surface-2); }
.ps-choice[aria-current="true"] .ps-choice__sub { color: var(--ink-2); font-weight: 600; }
.ps-choice__text { flex: 1; }
.ps-choice__title { overflow-wrap: anywhere; }

/* Карточка смены на пульте */
.shift-block { display: grid; gap: var(--space-3); min-width: 0; }
.ps-shift__text { display: grid; gap: 2px; min-width: 0; }
.ps-shift .ps-notice .ps-btn { margin-left: auto; flex: none; }
.ps-shift .ps-notice { flex-wrap: wrap; }
.ps-notice__body { flex: 1; }
.ps-progress__fill { transition: width .6s linear; }

/* Простои смены */
.ps-row { min-height: var(--target-glove); }
.ps-row[aria-current="true"] { outline: 3px solid var(--ink); outline-offset: -3px; background: var(--surface); }
.ps-row__note { font-size: 13px; line-height: 18px; color: var(--ink-3); }
.ps-row__main > * { overflow: visible; }
.ps-row__main > .ps-row__what { overflow: hidden; }
.ps-row:focus-visible, .ps-choice:focus-visible, .ps-stepper button:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.ps-stepper button { min-height: var(--target-min); touch-action: manipulation; }
.ps-readout { display: block; min-height: var(--target-min); padding: 0 var(--space-4); border-radius: var(--radius-sm); background: var(--surface-2);
  font-size: 20px; line-height: var(--target-min); font-weight: 700; font-variant-numeric: tabular-nums; }
.ps-form-row > .ps-field__hint { flex: 1 1 100%; }
.ps-editor .ps-chips { gap: var(--space-2); }
.ps-editor-empty { display: none; }
.ps-close-link { margin-top: var(--space-2); }
.ps-back-narrow { display: inline-flex; }
@media (min-width: 1024px) {
  .ps-editor-empty { display: grid; }
  .ps-back-narrow { display: none; }
  .ps-cols--list { grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); }
}
/* Узкий экран: запись открывается под шапкой, список скрыт, назад — к списку */
@media (max-width: 1023.98px) {
  .ps-cols--list[data-editing] .ps-dt-list { display: none; }
  .ps-cols--list[data-editing] ~ .ps-close-link { display: none; }
}

/* Зоны и проверка */
.ps-kpi__value small { font-size: 15px; }
.ps-check { flex-wrap: wrap; }
.ps-check__text { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.ps-check .ps-btn { min-height: var(--target-min); }
.ps-stack > .ps-kpi { margin-top: 0; }
.ps-card > .ps-kpis + .ps-kpi { margin-top: calc(-1 * var(--space-2)); }
@media (prefers-reduced-motion: reduce) { .ps-progress__fill { transition: none; } }

/* Телефон: строка простоя — время и длительность сверху, причина и «что сделали» под ними на всю ширину */
@media (max-width: 599px) {
  .ps-row { grid-template-columns: minmax(0, 1fr) auto; row-gap: var(--space-1); }
  .ps-row__main { grid-column: 1 / -1; grid-row: 2; }
  .ps-row__what { white-space: normal; }
  .ps-row .ps-tag { white-space: normal; }
  .ps-editor .ps-form-row > .ps-field { flex-basis: 120px; }
}
/* Узкий экран: когда открыта запись, шапка списка не нужна — у записи своё название */
@media (max-width: 1023.98px) { .ps-head--list { display: none; } }

/* ---------- Этап 3: администратор, ассистент, показатели, шаги мастера ---------- */
.ps-lead { margin: 0; font-size: 16px; line-height: 24px; color: var(--ink-2); }
.ps-back { width: auto; justify-self: start; min-height: var(--target-min); margin: 0; padding: 0 var(--space-4); text-align: left; }
.ps-actions--col { flex-direction: column; }
.ps-actions--col .ps-btn { flex: none; }
.ps-note-preview { overflow-wrap: anywhere; }
.ps-saved { display: grid; gap: var(--space-1); }
.ps-saved p { margin: 0; font-size: 15px; line-height: 22px; color: var(--ink-2); overflow-wrap: anywhere; }

/* Сводка записи и строка «что исправить» */
.ps-summary { gap: var(--space-3); }
.ps-kv { display: grid; gap: 2px; }
.ps-kv__k { font-size: 13px; line-height: 18px; font-weight: 600; color: var(--ink-3); }
.ps-kv__v { font-size: 16px; line-height: 22px; font-weight: 600; color: var(--ink); overflow-wrap: anywhere; white-space: pre-wrap; }
.ps-edit { display: grid; gap: 2px; width: 100%; min-height: var(--target-glove); padding: var(--space-3) var(--space-4); border: 0; border-radius: var(--radius-sm);
  background: var(--surface-2); color: var(--ink); text-align: left; cursor: pointer; }
.ps-edit:hover { background: var(--surface-3); }
.ps-edit:focus-visible, .ps-subnav__item:focus-visible, .ps-segmented button:focus-visible, .ps-switch:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.ps-edit__label { font-size: 16px; line-height: 22px; font-weight: 700; }
.ps-edit__value { font-size: 14px; line-height: 20px; color: var(--ink-2); overflow-wrap: anywhere; white-space: pre-wrap; }

/* Панель «Нужно исправить» */
.rejects .reject { display: grid; gap: var(--space-2); justify-items: start; margin-top: var(--space-2); padding: var(--space-4); border-radius: var(--radius-md); background: var(--stop-soft); color: var(--stop-ink); border: 0; overflow-wrap: anywhere; }
.rejects .reject p { margin: 0; color: var(--ink); }
.rejects-heading { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-3); justify-content: space-between; margin-bottom: var(--space-2); }
.cancel { margin-top: var(--space-4); }

/* Переключатель периода */
.ps-segmented { display: inline-grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 2px; padding: 3px; border-radius: var(--radius-sm); background: var(--surface-3); }
.ps-segmented button { min-height: var(--target-min); margin: 0; padding: 0 var(--space-4); border: 0; border-radius: 8px; background: transparent; color: var(--ink-2); font-size: 15px; line-height: 20px; font-weight: 600; cursor: pointer; white-space: nowrap; touch-action: manipulation; }
.ps-segmented button:hover { color: var(--ink); }
.ps-segmented { max-width: 100%; }
.ps-segmented button { min-width: 0; }
/* Узкий экран: четыре периода — в два ряда по два */
@media (max-width: 479.98px) {
  .ps-period { grid-auto-flow: row; grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
.ps-segmented button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-1); }

/* Раскладки */
main:has(.ps-admin), main:has(.ps-stats) { max-width: var(--content-max); margin: 0 auto; }
main:has(.ps-flow--chat) { max-width: 1480px; width: 100%; padding-bottom: 0; }
.ps-cols--admin { grid-template-columns: minmax(0, 1fr); }
@media (min-width: 1024px) { .ps-cols--admin { grid-template-columns: 260px minmax(0, 1fr); } }

/* Разделы настроек: строка, при нехватке места — в несколько строк (все вкладки на виду, без прокрутки), колонка слева от 1024 px */
.ps-subnav { display: flex; flex-wrap: wrap; gap: var(--space-1); min-width: 0; max-width: 100%; padding-bottom: 2px; }
.ps-subnav::-webkit-scrollbar { display: none; }
.ps-subnav__item { display: inline-flex; align-items: center; gap: var(--space-2); flex: none; min-height: var(--target-min); margin: 0; padding: 0 var(--space-4); border: 0; border-radius: var(--radius-sm);
  background: var(--surface); color: var(--ink-2); font-size: 15px; line-height: 20px; font-weight: 600; white-space: nowrap; cursor: pointer; text-align: left; }
.ps-subnav__item:hover { background: var(--surface-3); color: var(--ink); }
.ps-subnav__item[aria-current="page"] { background: var(--ink); color: var(--ink-inverse); }
/* Телефон: четыре раздела — две строки по два, без внутренней прокрутки */
@media (max-width: 599px) {
  .ps-subnav { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-2); overflow: visible; padding-bottom: 0; }
  .ps-subnav__item { flex: initial; min-width: 0; width: 100%; padding: 0 var(--space-3); white-space: normal; overflow-wrap: anywhere; }
}
/* 320 px с полосой прокрутки: подпись «Номера «Связаться»» не должна выходить за кнопку */
@media (max-width: 359.98px) {
  .ps-subnav__item { gap: var(--space-1); padding: var(--space-1) var(--space-2); line-height: 18px; }
}
@media (min-width: 1024px) {
  .ps-subnav { display: grid; gap: 2px; align-content: start; position: sticky; top: 80px; overflow: visible; }
  .ps-subnav__item { min-height: 52px; width: 100%; }
}

/* Время смен, мастера, номера, рассылка */
.ps-time { display: flex; flex-wrap: wrap; align-items: end; gap: var(--space-3) var(--space-5); padding: var(--space-3) var(--space-4); border-radius: var(--radius-sm); background: var(--surface-2); }
.ps-time__name { display: flex; align-items: center; gap: var(--space-2); min-width: 160px; margin-right: auto; align-self: center; font-size: 17px; line-height: 22px; }
.ps-time__end { align-self: center; font-size: 15px; line-height: 20px; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.ps-time__end b { color: var(--ink); font-size: 18px; }
.ps-group { display: grid; gap: var(--space-2); }
.ps-group + .ps-group { margin-top: var(--space-2); padding-top: var(--space-4); border-top: 1px solid var(--line); }
.ps-group__title { margin: 0; font-size: 17px; line-height: 22px; font-weight: 800; }
.ps-group > .ps-btn { justify-self: start; }
.ps-person { display: grid; gap: var(--space-2) var(--space-3); grid-template-columns: minmax(0, 1fr); align-items: end; padding: var(--space-3); border-radius: var(--radius-sm); background: var(--surface-2); }
.ps-person .ps-btn { justify-self: start; }
@media (min-width: 600px) { .ps-person { grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr) auto; } }
.ps-switch { display: inline-flex; align-items: center; gap: var(--space-3); min-height: var(--target-min); padding: 0 var(--space-4) 0 var(--space-2); border-radius: var(--radius-pill);
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink); font-size: 15px; font-weight: 600; cursor: pointer; touch-action: manipulation; }
.ps-switch__knob { width: 32px; height: 32px; flex: none; border-radius: var(--radius-pill); border: 2px solid var(--line-strong); box-sizing: border-box; }
/* Переключатель — нейтральный: зелёный и красный только у состояния стана */
.ps-switch[aria-checked="true"] { border-color: var(--ink); }
.ps-switch[aria-checked="true"] .ps-switch__knob { background: var(--ink); border-color: var(--ink); }
/* Рассылка на почту: форма добавления сверху, получатели строками, редактор раскрывается под строкой */
.ml-add { display: grid; gap: var(--space-3); padding: var(--space-4); border-radius: var(--radius-sm); background: var(--surface-2); min-width: 0; }
.ml-add__top { display: grid; gap: var(--space-3); grid-template-columns: minmax(0, 1fr); align-items: start; }
@media (min-width: 720px) { .ml-add__top { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); } }
/* Подсказки раздела — 13 px и на широком экране (там --fs-s растёт вместе с окном), иначе форма не помещается в один экран */
.ml-add .ps-field__hint, .ps-card > .ml-lead { font-size: 13px; line-height: 18px; }
/* От 720 px кнопка «Добавить» стоит в одной строке с чипами «Когда слать» */
@media (min-width: 720px) {
  .ml-add { grid-template-columns: minmax(0, 1fr) auto; align-items: center; }
  .ml-add > .ps-group__title, .ml-add > .ml-add__top, .ml-add > .ml-custom, .ml-add > .ps-field__error { grid-column: 1 / -1; }
  .ml-add__go { flex-direction: row-reverse; justify-content: flex-end; }
}
.ml-add__emails, .ml-add__name { display: grid; gap: var(--space-1); align-content: start; min-width: 0; }
textarea.ml-emails { min-height: 72px; padding-block: var(--space-2); }
.ml-add__when { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2) var(--space-3); }
.ml-add__go { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2) var(--space-3); }
.ml-done { font-size: 14px; line-height: 20px; font-weight: 600; color: var(--ink-2); }
.ml-custom { min-width: 0; }
.ml-sends { display: grid; gap: var(--space-2); justify-items: start; min-width: 0; }
.ml-sends > .ml-send { justify-self: stretch; }
.ml-send { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2) var(--space-3); padding: var(--space-2) var(--space-3); border-radius: var(--radius-sm); background: var(--surface); border: 1px solid var(--line); min-width: 0; }
.ml-time { width: 120px; flex: none; padding: 0 var(--space-3); }
.ml-what { flex: none; }
.ml-days { gap: var(--space-1); }
.ml-month { display: flex; align-items: center; gap: var(--space-2); font-size: 15px; line-height: 20px; color: var(--ink-2); }
.ml-dom { width: 72px; flex: none; padding: 0 var(--space-3); text-align: center; }
.ml-days .ps-chip { min-width: 44px; padding: 0 var(--space-3); }
.ml-x { display: inline-grid; place-items: center; flex: none; width: var(--target-min); height: var(--target-min); margin: 0 0 0 auto; padding: 0; border-radius: var(--radius-sm); border: 1px solid var(--line-strong);
  background: transparent; color: var(--ink-2); font-size: 24px; line-height: 1; cursor: pointer; touch-action: manipulation; }
.ml-x:hover { background: var(--surface-3); color: var(--ink); }
.ml-list-head { display: flex; align-items: center; gap: var(--space-3); margin-top: var(--space-2); }
.ml-list { display: grid; gap: var(--space-2); margin: 0; padding: 0; list-style: none; container-type: inline-size; }
.ml-item { display: grid; gap: var(--space-2); padding: var(--space-2) var(--space-3); border-radius: var(--radius-sm); background: var(--surface-2); min-width: 0; }
.ml-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "who sw" "when acts"; align-items: center; gap: var(--space-2) var(--space-3); min-width: 0; }
.ml-who { grid-area: who; display: grid; min-width: 0; }
.ml-row > .ml-sw { grid-area: sw; justify-self: end; }
.ml-when { grid-area: when; min-width: 0; font-size: 14px; line-height: 20px; color: var(--ink); overflow-wrap: anywhere; }
.ml-when--none { color: var(--ink-3); }
.ml-acts { grid-area: acts; display: flex; align-items: center; gap: var(--space-2); }
.ml-name { font-size: 17px; line-height: 22px; font-weight: 700; overflow-wrap: anywhere; }
.ml-mail { font-size: 14px; line-height: 20px; color: var(--ink-2); overflow-wrap: anywhere; }
.ml-edit-btn { padding: 0 var(--space-4); }
.ml-edit { display: grid; gap: var(--space-3); padding-top: var(--space-3); border-top: 1px solid var(--line); min-width: 0; }
.ml-edit__who { display: flex; flex-wrap: wrap; align-items: end; gap: var(--space-3); }
.ml-edit__who > .ps-field { flex: 1 1 220px; }
.ml-foot { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2) var(--space-3); }
.ml-foot__gap { flex: 1 1 0; min-width: 0; }
.ml-foot .ps-btn { flex: none; }
.ml-sw__short { display: none; }
/* Широкий список (≥ 780 px у самого списка): имя · адрес · «Включён» · расписание · «Изменить» · «×» в одну строку */
@container (min-width: 780px) {
  .ml-row { grid-template-columns: minmax(100px, 1fr) minmax(150px, 1.4fr) auto minmax(180px, 2fr) auto; grid-template-areas: "name mail sw when acts"; gap: var(--space-2) var(--space-4); }
  .ml-who { display: contents; }
  .ml-name { grid-area: name; }
  .ml-mail { grid-area: mail; }
  .ml-name, .ml-mail { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .ml-row > .ml-sw { justify-self: start; }
  .ml-acts { justify-self: end; }
}
@media (max-width: 599px) {
  .ml-sw .ml-sw__text { display: none; }
  .ml-sw .ml-sw__short { display: inline; }
  .ml-sw { padding: 0 var(--space-3) 0 var(--space-2); }
  .ml-send { display: grid; grid-template-columns: minmax(0, 1fr) auto; }
  .ml-send > .ml-time { grid-column: 1; grid-row: 1; justify-self: start; }
  .ml-send > .ml-x { grid-column: 2; grid-row: 1; margin: 0; }
  .ml-send > .ml-what { grid-column: 1 / -1; grid-row: 2; display: grid; width: 100%; box-sizing: border-box; }
  .ml-send > .ml-days { grid-column: 1 / -1; grid-row: 3; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .ml-send > .ml-month { grid-column: 1 / -1; grid-row: 3; }
  .ml-days .ps-chip { min-width: 0; padding: 0 var(--space-2); }
  .ml-what button { padding: 0 var(--space-2); }
}
.ps-notice { flex-wrap: wrap; }
.ps-notice > .ps-btn { flex: none; margin-left: auto; min-height: var(--target-min); }
.ps-notice__body > span { display: block; }

/* Плавающая панель сохранения */
.ps-savebar { position: sticky; z-index: 5; bottom: calc(var(--tabbar-height) + var(--space-3)); display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-3); padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md); background: var(--ink); color: var(--ink-inverse); box-shadow: var(--shadow-2); }
.ps-savebar[hidden] { display: none; }
.ps-savebar__text { margin-right: auto; font-size: 15px; line-height: 20px; font-weight: 600; }
.ps-savebar .ps-btn--ghost { color: var(--ink-inverse); }
.ps-savebar .ps-btn--ghost:hover { background: transparent; text-decoration: underline; }
.ps-savebar .ps-btn--primary { background: var(--surface); color: var(--ink); }
.ps-savebar .ps-btn:focus-visible { outline-color: var(--ink-inverse); }
/* Нижнее меню: sticky внутри блока не может подняться выше верха блока, и высокая панель оказывалась под меню (320×568).
   До 1024 px панель закреплена у окна над меню (+ safe-area); место под неё — в конце страницы, чтобы не закрывать поля. */
@media (max-width: 1023px) {
  .ps-savebar { position: fixed; left: 12px; right: 12px; bottom: calc(var(--tabbar-height) + env(safe-area-inset-bottom) + var(--space-3)); }
  main:has(.ps-savebar:not([hidden])) { padding-bottom: calc(220px + env(safe-area-inset-bottom)); }
}
@media (min-width: 1024px) { .ps-savebar { bottom: var(--space-4); } }
@media (max-width: 599px) { .ps-savebar .ps-btn { flex: 1 1 120px; } }

/* Ассистент: лента сообщений */
body:has(.ps-flow--chat) { height: 100dvh; overflow: hidden; padding-bottom: 0; }
.ps-flow--chat { height: calc(100dvh - 180px); grid-template-rows: auto minmax(0, 1fr); align-content: stretch; gap: 12px; min-height: 0; }
.ai-chat-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.ai-new, .ai-copy { min-height: 44px; border: 0; border-radius: var(--radius-sm); padding: 8px 12px; background: transparent; color: var(--ink-2); font: inherit; font-size: 14px; cursor: pointer; }
.ai-new:hover, .ai-copy:hover { background: var(--surface-3); color: var(--ink); }
.ai-new { flex: none; }
.ai-card { min-height: 0; padding: 0; gap: 0; grid-template-rows: minmax(0, 1fr) auto; align-content: stretch; overflow: hidden; box-shadow: none; }
.ps-chat { display: grid; grid-auto-rows: max-content; align-content: start; gap: var(--space-3); min-width: 0; min-height: 0; overflow-y: auto; overscroll-behavior: contain; scrollbar-gutter: stable; scrollbar-color: var(--line-strong) var(--surface); padding: 16px 20px; }
.ai-composer { display: grid; gap: 8px; padding: 12px 20px; border-top: 1px solid var(--line); background: var(--surface); min-width: 0; }
.ai-composer .ps-chips { display: flex; flex-wrap: nowrap; overflow-x: auto; min-width: 0; max-width: 100%; padding: 3px; gap: 8px; scrollbar-width: thin; scrollbar-color: var(--line-strong) var(--surface); }
.ai-composer .ps-chip { flex: none; white-space: nowrap; font-size: 14px; min-height: 44px; }
.ai-compose-row { display: flex; align-items: end; gap: 10px; min-width: 0; }
.ai-compose-row .ai-input { flex: 1; min-width: 0; min-height: 48px; max-height: var(--ai-input-max, 160px); padding: 11px 12px; font-size: 16px; line-height: 22px; resize: none; overflow-y: auto; caret-color: var(--ink); }
.ai-send { flex: none; min-height: 48px; }
.ai-input-hint { font-size: 12px; line-height: 16px; color: var(--ink-2); }
.ai-message-head { display: flex; align-items: center; gap: 12px; min-height: 32px; margin-bottom: 4px; }
.ai-message-head time { font-size: 12px; font-variant-numeric: tabular-nums; opacity: .85; }
.ai-copy { margin-left: auto; }
.ai-welcome { align-self: center; justify-self: center; width: min(100%, 760px); padding-block: 24px; }
.ai-welcome h2 { font-size: 26px; line-height: 34px; margin: 0 0 12px; }
.ai-welcome p { font-size: 16px; line-height: 24px; color: var(--ink-2); margin: 0 0 24px; max-width: 65ch; }
.ai-welcome-chips { display: flex; flex-wrap: wrap; gap: 10px; }
.ai-welcome-chips .ps-chip { min-height: 48px; padding: 12px 16px; font-size: 16px; line-height: 22px; text-align: left; white-space: normal; }
.ps-chat:has(.ai-welcome) { grid-template-rows: 1fr; }
.ai-thinking { display: flex; align-items: center; gap: 10px; font-size: 16px; }
.ai-thinking-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--ink-2); animation: ai-thinking 1s ease-in-out infinite alternate; }
@keyframes ai-thinking { to { opacity: .3; transform: scale(.7); } }
.ai-new:focus-visible, .ai-copy:focus-visible, .ps-chat:focus-visible { outline: 3px solid var(--focus); outline-offset: -3px; }
@media (prefers-reduced-motion: reduce) { .ai-thinking-dot { animation: none; } }
@media (max-width: 599px) {
  .ps-flow--chat .ai-chat-head h1.q { font-size: 20px; line-height: 26px; }
  .ai-chat-head { gap: 4px; }
  .ai-new { width: 106px; padding-inline: 4px; line-height: 18px; }
  .ai-card .ps-chat { padding: 12px 8px; }
  .ai-card .ai-composer { padding: 8px; }
  .ai-compose-row { gap: 6px; }
  .ai-compose-row .ai-send { padding-inline: 10px; font-size: 14px; }
  .ai-welcome { padding-block: 8px; }
  .ai-welcome h2 { font-size: 22px; line-height: 28px; }
  .ai-input-hint { display: none; }
  .ai-card .ps-msg { padding: 10px; }
}
.ps-msg { display: grid; gap: 2px; max-width: 88%; padding: var(--space-3) var(--space-4); border-radius: var(--radius-md); background: var(--surface-2); color: var(--ink); min-width: 0; }
.ps-msg--user { justify-self: end; background: var(--ink); color: var(--ink-inverse); border-bottom-right-radius: var(--radius-xs); }
.ps-msg--assistant { justify-self: start; border-bottom-left-radius: var(--radius-xs); }
.ps-msg__who { font-size: 13px; line-height: 18px; font-weight: 700; opacity: .85; }
.ps-msg__text { margin: 0; font-size: 16px; line-height: 24px; white-space: pre-wrap; overflow-wrap: anywhere; }
/* Ответ ассистента с разметкой (ai-view.js): на всю ширину ленты, таблицы и схемы читаются на 390 и 1280 px */
.ps-msg--rich { max-width: 100%; width: 100%; }
.ai-answer { display: grid; gap: var(--space-3); min-width: 0; font-size: 16px; line-height: 24px; color: var(--ink); overflow-wrap: anywhere; }
.ai-answer > * { margin: 0; min-width: 0; }
.ai-h { font-size: 17px; line-height: 24px; font-weight: 800; color: var(--ink); padding-top: var(--space-2); border-top: 1px solid var(--line); }
.ai-answer > .ai-h:first-child { border-top: 0; padding-top: 0; }
h4.ai-h { font-size: 16px; border-top: 0; padding-top: 0; color: var(--ink-2); }
.ai-p { margin: 0; }
.ai-answer strong { font-weight: 800; }
.ai-list { margin: 0; padding-left: var(--space-5); display: grid; gap: var(--space-1); }
.ai-code { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: 14px; background: var(--surface-3); padding: 1px 5px; border-radius: var(--radius-xs); }
.ai-pre { margin: 0; padding: var(--space-3); background: var(--surface-3); border-radius: var(--radius-sm); font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: 13px; line-height: 18px; white-space: pre-wrap; overflow-wrap: anywhere; }
.ai-hr { border: 0; border-top: 1px solid var(--line); width: 100%; }
.ai-table-wrap { min-width: 0; max-width: 100%; overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface); -webkit-overflow-scrolling: touch; }
.ai-table { border-collapse: collapse; width: 100%; font-size: 14px; line-height: 20px; font-variant-numeric: tabular-nums; }
.ai-table th, .ai-table td { padding: var(--space-2) var(--space-3); text-align: left; vertical-align: top; border-bottom: 1px solid var(--line); overflow-wrap: normal; }
.ai-table th { background: var(--surface-3); color: var(--ink); font-weight: 800; white-space: nowrap; }
.ai-table tbody tr:nth-child(even) td { background: var(--surface-2); }
.ai-table tbody tr:last-child td { border-bottom: 0; }
.ai-table .ai-align-right { text-align: right; white-space: nowrap; }
.ai-table .ai-align-center { text-align: center; }
.ai-table td:not(:first-child) { min-width: 56px; }
.ai-chart { margin: 0; padding: var(--space-3); display: grid; gap: var(--space-2); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm); }
.ai-chart__title { font-size: 14px; line-height: 20px; font-weight: 800; color: var(--ink-2); }
.ai-svg { width: 100%; max-width: 420px; height: auto; display: block; overflow: visible; }
.ai-svg--donut { max-width: 200px; margin: 0 auto; }
.ai-svg text { fill: var(--ink); font-family: var(--font-sans); font-size: 12.5px; }
.ai-svg text.ai-svg__value { font-weight: 800; }
.ai-svg text.ai-svg__tick { fill: var(--ink-3); font-size: 12px; }
.ai-svg text.ai-svg__center { font-size: 16px; font-weight: 800; }
.ai-chart--trend { min-width: 0; }
.ai-chart--trend .ai-chart__title { font-size: 18px; line-height: 24px; overflow-wrap: anywhere; }
.ai-trend-scroll { min-width: 0; max-width: 100%; overflow-x: auto; padding-bottom: var(--space-2); }
.ai-trend-scroll:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.ai-svg.ai-trend-svg { width: auto; max-width: none; overflow: hidden; }
.ai-trend-svg text { font-size: 14px; }
.ai-trend-svg .ai-trend-tick { fill: var(--ink-2); }
.ai-trend-svg .ai-trend-value { font-weight: 700; }
.ai-trend-norm { stroke: var(--ink); stroke-width: 2; stroke-dasharray: 7 5; }
.ai-trend-legend { margin: 0; color: var(--ink-2); font-size: 14px; line-height: 20px; overflow-wrap: anywhere; }
.ai-track { fill: var(--surface-3); }
.ai-track-ring { stroke: var(--surface-3); }
.ai-axis { stroke: var(--line-strong); stroke-width: 1.5; }
.ai-grid { stroke: var(--line); stroke-width: 1; }
.ai-fill.ai-z-none { fill: var(--ink-3); }
.ai-fill.ai-z-work { fill: var(--zone-work); }
.ai-fill.ai-z-plan { fill: var(--zone-plan); }
.ai-fill.ai-z-unplanned { fill: var(--zone-unplanned); }
.ai-fill.ai-z-failure { fill: var(--zone-failure); }
.ai-fill.ai-z-pending { fill: var(--line-strong); }
.ai-stroke.ai-z-work { stroke: var(--zone-work); }
.ai-stroke.ai-z-plan { stroke: var(--zone-plan); }
.ai-stroke.ai-z-unplanned { stroke: var(--zone-unplanned); }
.ai-stroke.ai-z-failure { stroke: var(--zone-failure); }
.ai-stroke.ai-z-pending { stroke: var(--line-strong); }
.ai-stroke.ai-z-c0 { stroke: var(--zone-plan); }
.ai-stroke.ai-z-c1 { stroke: var(--zone-unplanned); }
.ai-stroke.ai-z-c2 { stroke: var(--zone-failure); }
.ai-stroke.ai-z-c3 { stroke: var(--zone-work); }
.ai-stroke.ai-z-c4 { stroke: var(--ink-3); }
.ai-stroke.ai-z-c5 { stroke: var(--focus); }
.ai-legend { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: var(--space-2) var(--space-4); font-size: 14px; line-height: 20px; color: var(--ink-2); }
.ai-legend--list { display: grid; gap: var(--space-1); }
.ai-legend__item { display: flex; align-items: flex-start; gap: var(--space-2); min-width: 0; }
.ai-legend__text { min-width: 0; overflow-wrap: anywhere; }
.ai-swatch { flex: none; width: 12px; height: 12px; margin-top: 4px; border-radius: 3px; background: var(--ink-3); }
.ai-swatch.ai-z-work { background: var(--zone-work); }
.ai-swatch.ai-z-failure { background: var(--zone-failure); }
.ai-swatch.ai-z-plan { background: var(--zone-plan); }
.ai-swatch.ai-z-unplanned { background: var(--zone-unplanned); }
.ai-swatch.ai-z-pending { background: var(--line-strong); }
.ai-swatch.ai-z-c0 { background: var(--zone-plan); }
.ai-swatch.ai-z-c1 { background: var(--zone-unplanned); }
.ai-swatch.ai-z-c2 { background: var(--zone-failure); }
.ai-swatch.ai-z-c3 { background: var(--zone-work); }
.ai-swatch.ai-z-c4 { background: var(--ink-3); }
.ai-swatch.ai-z-c5 { background: var(--focus); }
.ps-chip:disabled { opacity: .5; cursor: default; }
.ai-input { min-height: 96px; }

/* Показатели */
.ps-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-3); }
.ps-period { width: 100%; }
@media (min-width: 600px) { .ps-period { width: auto; } }
.ps-toolbar .ps-notice { flex: 1 1 260px; }
.ps-head--stats { position: relative; }
/* Панель отчёта привязана к полосе заголовка, а не к кнопке: иначе она сжимается до ширины кнопки */
.ps-head--stats .rep { margin-left: 0; position: static; }
.ps-head--stats .rep-btn { width: auto; min-height: var(--target-min); padding: 0 var(--space-4); border-radius: var(--radius-sm); border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink);
  font-size: 15px; line-height: 20px; font-weight: 600; box-shadow: none; }
.ps-head--stats .rep-btn:hover { background: var(--surface-2); }
.ps-head--stats .rep-label { display: inline; }
/* Значения «Работа», «Простой» и другие — цветом чернил: цвет состояния остаётся у маркера зоны */
.ps-kpi[data-tone] .ps-kpi__value { color: var(--ink); }
.ps-kpi__value { white-space: normal; }
.ps-kpis--row, .ps-kpis--auto { grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (min-width: 600px) { .ps-kpis--row { grid-template-columns: repeat(5, minmax(0, 1fr)); } .ps-kpis--auto { grid-template-columns: repeat(5, minmax(0, 1fr)); } }
.ps-bars { display: grid; gap: var(--space-3); }
.ps-bar { display: grid; gap: 6px; }
.ps-bar__head { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 2px var(--space-3); font-size: 14px; line-height: 20px; }
.ps-bar__name { display: inline-flex; align-items: center; gap: var(--space-2); min-width: 0; font-weight: 700; overflow-wrap: anywhere; }
.ps-bar__val { color: var(--ink-2); font-variant-numeric: tabular-nums; }
.ps-bar__track { display: flex; height: 12px; border-radius: var(--radius-pill); background: var(--surface-3); overflow: hidden; }
.ps-bar__fill { height: 100%; background: var(--zone-work); }
.ps-bar__fill[data-zone="plan"] { background: var(--zone-plan); }
.ps-bar__fill[data-zone="unplanned"] { background: var(--zone-unplanned); }
.ps-bar__fill[data-zone="failure"] { background-color: var(--zone-failure); background-image: repeating-linear-gradient(-45deg, transparent 0 6px, rgba(255, 255, 255, .4) 6px 10px); }
.ps-bar__fill[data-zone="neutral"] { background: var(--ink-3); }
.ps-zrows { display: grid; gap: var(--space-2); }
.ps-zrow { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: 2px var(--space-3); padding: var(--space-3); border-radius: var(--radius-sm); background: var(--surface-2); }
.ps-zrow__name { display: inline-flex; align-items: center; gap: var(--space-2); font-size: 15px; line-height: 20px; font-weight: 700; }
.ps-zrow__val { font-size: 14px; line-height: 20px; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.chart-legend { display: flex; flex-wrap: wrap; gap: var(--space-4); margin-top: var(--space-2); font-size: 13px; color: var(--ink-3); }

/* ---------- Исправления по проверке (3 октября) ---------- */

/* Невысокий экран (планшет и монитор 1280×800): пульт, плитки причин и шкала суток помещаются без прокрутки.
   Главная кнопка не ниже 64 px (перчатки), остальное — компактнее. */
@media (min-width: 1024px) and (max-height: 900px) {
  main:has(.with-scale) { padding-top: 8px; padding-bottom: 8px; }
  .with-scale { gap: var(--space-3); }
  .with-scale__main { gap: var(--space-3); }
  .pult { gap: var(--space-3); }
  /* Панель состояния: заголовок и таймер в одной строке */
  .ps-state { grid-template-columns: minmax(0, 1fr) auto; column-gap: var(--space-4); row-gap: 2px; align-items: center;
    padding: var(--space-3) var(--space-5) var(--space-4); }
  .ps-state > .pult-state__top, .ps-state > .ps-state__meta, .ps-state > .ps-state__stale { grid-column: 1 / -1; }
  .ps-state__title { grid-column: 1; font-size: 36px; line-height: 44px; }
  .ps-state__timer { grid-column: 2; font-size: 48px; line-height: 52px; }
  .ps-state__meta { font-size: 15px; line-height: 20px; }
  /* Карточка «Стан сейчас» в узкой колонке (приём смены, планшет 1024 px): заголовок и таймер в одну строку, только пока оба помещаются.
     Заголовок не сжимается ниже своей ширины и слово «работает» не рвётся: не хватает места — таймер уходит на строку ниже */
  .ps-state--compact { display: flex; flex-wrap: wrap; align-items: center; column-gap: var(--space-4); row-gap: 2px; }
  .ps-state--compact > .pult-state__top, .ps-state--compact > .ps-state__meta, .ps-state--compact > .ps-state__stale { flex: 0 0 100%; }
  .ps-state--compact > .ps-state__title { flex: 1 1 auto; overflow-wrap: normal; }
  .ps-state--compact > .ps-state__timer { flex: 0 0 auto; }
  .ps-action { min-height: 72px; padding: var(--space-2) var(--space-5); gap: var(--space-4); }
  .ps-action__icon { width: 52px; height: 52px; border-width: 3px; }
  .ps-action__icon .ico { width: 24px; height: 24px; }
  .ps-action__label { font-size: 26px; line-height: 30px; }
  .ps-action__hint { font-size: 14px; line-height: 18px; }
  /* Карточки правой колонки (смена, причина, передача ремонта) — плотнее */
  .with-scale__main .ps-card { padding: var(--space-3) var(--space-4); gap: var(--space-2); }
  .with-scale__main .ps-shift { gap: var(--space-2); }
  .with-scale__main .ps-avatar { width: 44px; height: 44px; }
  .with-scale__main .ps-card__title { font-size: 18px; line-height: 24px; }
  .with-scale__main .ps-actions .ps-btn { min-height: var(--target-min); flex: 1 1 140px; }
  /* «Указать брак» — главное действие карточки причины: крупнее остальных (перчатки) */
  .with-scale__main .ps-actions .ps-btn[data-act="billet"] { min-height: 60px; }
  .with-scale__main .ps-shift .ps-btn--lg { min-height: 56px; }
  /* Плитки причин: иконка рядом с названием, пояснение в две строки */
  .ps-pick { gap: var(--space-2); }
  .ps-reasons, .ps-reasons-box .ps-reasons { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--space-2); }
  .ps-reason { grid-template-columns: auto minmax(0, 1fr); align-items: center; column-gap: var(--space-2); row-gap: 4px; min-height: 0; padding: var(--space-2) var(--space-3); }
  .ps-reason__icon { width: 36px; height: 36px; }
  .ps-reason__icon svg { width: 20px; height: 20px; }
  .ps-reason__title { font-size: 18px; line-height: 22px; }
  /* Пояснение показываем целиком: обрезка до двух строк убирала окончания фраз */
  .ps-reason__sub { grid-column: 1 / -1; font-size: 13px; line-height: 17px; }
  /* Узкая колонка (планшет 1024 px): три плитки в ряд, значок над названием, пояснение скрыто — слова не рвутся */
  @container (max-width: 599px) {
    .ps-reasons { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--space-2); }
    .ps-reason { grid-template-columns: minmax(0, 1fr); align-items: start; row-gap: 2px; padding: var(--space-2) var(--space-3); min-height: 0; }
    .ps-reason__icon { grid-row: auto; width: 32px; height: 32px; }
    .ps-reason__title { font-size: 16px; line-height: 20px; padding-right: 0; overflow-wrap: normal; }
    .ps-reason__sub { display: none; }
  }
}
/* «Причина уже указана» без сигнала: пульт слева, карточка смены под ним, справа причина. Это раскладка низкого окна до сетки «во всю ширину»:
   от 1280×720 альбомно сетку ведёт wide.css (пульт слева на два ряда, справа смена и причина), а эти правила перекрывали её —
   причина ложилась под карточку смены, под пультом оставалась пустота, а главная кнопка сжималась (v146) */
@media (min-width: 1024px) and (max-height: 900px) and (not ((orientation: landscape) and (min-width: 1280px) and (min-height: 720px))) {
  /* Причина уже указана: левая колонка пуста под кнопкой — карточка смены встаёт под неё, справа остаются причина и передача ремонта.
     Не для .stop-stack («стан стоит» с указанной причиной, сигнал есть или нет): там пульт и причина — стопка в левой колонке, а правая часть сетки своя (wide.css, D3-6) */
  .with-scale__main:has(.stop-grid > :last-child:not(:empty)):not(:has(.ps-pick)):not(:has(.stop-stack)) > .stop-grid > :first-child { grid-row: 1; }
  .with-scale__main:has(.stop-grid > :last-child:not(:empty)):not(:has(.ps-pick)):not(:has(.stop-stack)) > .shift-block { grid-column: 1; grid-row: 2; }
  .with-scale__main:has(.stop-grid > :last-child:not(:empty)):not(:has(.ps-pick)):not(:has(.stop-stack)) > .stop-grid > :last-child { grid-column: 2; grid-row: 1 / span 2; }
  /* Карточка смены под кнопкой: мастер и ход смены — в одну строку, кнопка «Сдать смену» ниже */
  .with-scale__main:has(.stop-grid > :last-child:not(:empty)):not(:has(.ps-pick)):not(:has(.stop-stack)) > .shift-block .ps-shift {
    grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); column-gap: var(--space-5); align-items: center; }
  .with-scale__main:has(.stop-grid > :last-child:not(:empty)):not(:has(.ps-pick)):not(:has(.stop-stack)) > .shift-block .ps-shift > :not(.ps-shift__who):not(.ps-progress) { grid-column: 1 / -1; }
}
/* Совсем невысокое окно (768 px и ниже): ещё на несколько пикселей плотнее */
@media (min-width: 1024px) and (max-height: 780px) {
  .ps-state__title { font-size: 32px; line-height: 40px; }
  .ps-state__timer { font-size: 44px; line-height: 48px; }
  .ps-state { padding-block: var(--space-2) var(--space-3); }
}

/* Статус связи в шапке: при норме — только точка (текст в title и aria-label), при проблемах — текст в одну строку
   с многоточием в пределах своей ширины: он не заходит на часы и кнопки */
@media (min-width: 601px) {
  .topbar .save-status { flex: 0 1 auto; min-width: 44px; max-width: min(280px, 28vw); }
  .topbar .save-status .save-status-text { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .topbar .save-status.online { flex: none; max-width: none; justify-content: center; }
  .topbar .save-status.online .save-status-text { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
}

/* Разбор простоев: счётчик «Без причины», правка времени, строки простоев в подробностях шкалы */
.ps-review { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--space-3); }
.ps-review .ps-notice { flex: 1 1 100%; }
.ps-review__count { font-size: 20px; line-height: 26px; font-weight: 700; }
.ps-timefix .ps-stepper { margin-bottom: var(--space-2); }
.ps-timefix .ps-btn { justify-self: start; margin-top: var(--space-2); }
.ps-editor .ps-notice { flex-wrap: wrap; }
.ps-editor .ps-notice .ps-btn { margin-left: auto; flex: none; }
.ds-details__list { display: grid; gap: 6px; margin-top: 8px; }
.ds-detail { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; }
.ds-detail__text { flex: 1 1 140px; font-weight: 600; }
/* ---------- Предупреждения консультанта: «Администратор → Предупреждения» и флажок у получателя рассылки ---------- */
.al-master { display: flex; align-items: center; gap: var(--space-3); flex-wrap: wrap; }
.al-rules { display: grid; gap: var(--space-2); min-width: 0; }
.al-rule { display: grid; gap: var(--space-3); padding: var(--space-3) var(--space-4); border-radius: var(--radius-sm); background: var(--surface-2); min-width: 0; }
.al-rule__head { display: flex; align-items: flex-start; gap: var(--space-3); min-width: 0; }
.al-rule__head > .ps-switch { flex: none; }
.al-rule__text { display: grid; gap: var(--space-1); min-width: 0; }
.al-rule__title { font-size: 17px; line-height: 22px; font-weight: 700; }
.al-rule__params { display: flex; flex-wrap: wrap; gap: var(--space-3); min-width: 0; }
.al-field { flex: 0 1 220px; min-width: 0; }
.al-field__box { display: flex; align-items: center; gap: var(--space-2); }
.al-num { width: 110px; flex: none; padding: 0 var(--space-3); text-align: center; }
.al-unit { font-size: 15px; line-height: 20px; color: var(--ink-2); }
.al-channels { display: grid; gap: var(--space-3); min-width: 0; }
.al-channel { display: grid; gap: var(--space-1); padding: var(--space-3) var(--space-4); border-radius: var(--radius-sm); background: var(--surface-2); min-width: 0; }
.al-log-block { display: grid; gap: var(--space-2); min-width: 0; }
.al-log { display: grid; gap: var(--space-2); margin: 0; padding: 0; list-style: none; }
.al-log__item { display: grid; grid-template-columns: 84px 92px minmax(0, 1fr); gap: var(--space-2) var(--space-3); padding: var(--space-2) var(--space-3); border-radius: var(--radius-sm); background: var(--surface-2); font-size: 14px; line-height: 20px; min-width: 0; }
.al-log__item[data-type="error"] { background: var(--stop-soft); color: var(--stop-ink); }
.al-log__time { color: var(--ink-2); font-variant-numeric: tabular-nums; }
.al-log__rule { color: var(--ink-2); }
.al-log__body { display: grid; gap: 2px; min-width: 0; overflow-wrap: anywhere; }
.al-log__title { font-weight: 700; }
.al-log__text { color: var(--ink); }
.al-bot { display: grid; gap: var(--space-3); min-width: 0; }
.al-history__filters { display: flex; flex-wrap: wrap; align-items: end; gap: var(--space-3); }
.al-history__filters > .ps-field { flex: 1 1 220px; min-width: 0; }
.al-history select, .al-history input, .al-rule__params .ps-field { min-width: 0; max-width: 100%; }
.al-history__text { white-space: pre-wrap; overflow-wrap: anywhere; }
.ml-alerts { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2) var(--space-3); min-width: 0; }
@media (max-width: 599px) {
  .al-rule__head { flex-direction: column; gap: var(--space-2); }
  .al-field { flex: 1 1 100%; }
  .al-log__item { grid-template-columns: minmax(0, 1fr); gap: 2px; }
}
.ds-detail__btn { flex: none; min-height: var(--target-min, 44px); padding: 0 var(--space-4, 12px); font-size: 14px; }

/* ---------- Боковое меню (от 1024 px): всегда на виду и на всю высоту окна ---------- */
@media (min-width: 1024px) {
  /* Рейка на 8 px шире: «Показатели» жирным на активной кнопке не упирается в края */
  :root { --rail-width: 104px; }
  .appnav { height: 100vh; height: 100dvh; overflow-y: auto; overscroll-behavior: contain; scrollbar-width: none; }
  /* Фон рейки продолжается на всю длину страницы: на снимке «всей страницы» и при быстрой прокрутке меню не обрывается на первом экране.
     Живое меню (position: fixed) лежит поверх и от прокрутки не зависит */
  body { position: relative; }
  body::before { content: ""; position: absolute; z-index: 5; left: 0; top: 0; bottom: 0; width: var(--rail-width); background: var(--surface); border-right: 1px solid var(--line); pointer-events: none; }
  html[data-tablo] body::before { display: none; }
}

/* Крестик «Закрыть» у всплывающих окон (dismiss.js): ≥ 32 px на мониторе, ≥ 44 px при касании — как lv-sec__close */
.ps-close.ps-btn { flex: none; min-width: 32px; min-height: 32px; width: 32px; height: 32px; padding: 0; font-size: 23px; line-height: 30px; }
@media (pointer: coarse) { .ps-close.ps-btn { width: 44px; height: 44px; min-width: 44px; min-height: 44px; } }
/* Шапка складного окна: название слева, крестик справа, в одну строку */
.ps-fold__head { display: flex; align-items: center; justify-content: space-between; gap: var(--space-2); }
.ps-fold__title { font-size: var(--fs-s); line-height: 1.3; font-weight: 700; color: var(--ink); min-width: 0; }

/* Карточка «Сменился рецепт: что катаем?» (product-pick-ui.js): варианты позиции номенклатуры, кнопки не ниже 64 px на любом экране */
.pick-strips { display: grid; min-width: 0; }
.with-scale__main .review-strips.pick-strips { order: 0; }
.pick-card { display: grid; gap: var(--space-3); padding: var(--space-4); border-radius: var(--radius-md); border: 2px solid var(--zone-plan); background: var(--surface); min-width: 0; }
.pick-card__head { display: flex; align-items: center; justify-content: space-between; gap: var(--space-2); }
.pick-card__title { font-size: 20px; line-height: 26px; font-weight: 700; color: var(--ink); min-width: 0; }
.pick-card__recipe, .pick-card__sub { font-size: 15px; line-height: 20px; color: var(--ink-2); overflow-wrap: anywhere; }
.pick-card__recipe { font-weight: 600; color: var(--ink); }
.pick-card__opts { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: var(--space-3); min-width: 0; }
.pick-card__opts--list { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); max-height: 40vh; overflow-y: auto; }
.pick-strips .pick-card .ps-btn.pick-card__opt { min-height: 64px; padding-block: var(--space-2); font-size: 17px; line-height: 22px; white-space: normal; }
.pick-strips .pick-card .pick-card__back { justify-self: start; min-height: 48px; }
@media (max-width: 599px) {
  .pick-card__opts { grid-template-columns: minmax(0, 1fr); }
  .pick-card__opts--list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .pick-card__title { font-size: 18px; line-height: 24px; }
}
/* Пульт 1280×720 и шире (альбом) устроен без прокрутки. Карточка не лежит поверх него, а занимает своё место в левой колонке — в потоке, между
   «Сейчас» и «Ритмом смены»: ленты шкалы, кнопки, смена и план остаются на виду и не перекрыты (v146, B4). Место ей отдаёт «Ритм смены»:
   это второстепенный блок (график и цифры за смену), пока вопрос открыт, он уступает колонку; ответили или нажали «потом» — ритм на месте.
   Не помещается список изделий — прокручивается он сам внутри карточки. На планшете и телефоне страница прокручивается: там карточка идёт
   обычным блоком над «Ритмом смены». */
@media (orientation: landscape) and (min-width: 1280px) and (min-height: 720px) {
  .with-scale__main .pult > .pick-strips { flex: 0 1 auto; min-height: 0; grid-template-rows: minmax(0, 1fr); }
  .pick-strips .pick-card { min-height: 0; overflow-y: auto; overscroll-behavior: contain; }
  .pick-card:has(> .pick-card__opts--list) { grid-template-rows: auto auto auto minmax(0, 1fr) auto; }
  .pick-card__opts { grid-template-columns: repeat(auto-fit, minmax(128px, 1fr)); }
  .pick-card__opts--list { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); max-height: none; }
  .pult:has(> .pick-strips) > .rhythm { display: none; }
}

/* Форма «Уточнить позицию» (v147): текущая мерная длина обведена рамкой цвета карточки; кнопки остаются ≥ 64 px */
.pick-strips .pick-card .pick-card__opt[data-current="1"] { box-shadow: inset 0 0 0 3px var(--zone-plan); }
