/* Страница рабочего: две темы (тёмная и светлая), крупные элементы под перчатки.
   Версия 2: пошаговые экраны, один вопрос — один экран.

   Все цвета — токены (CSS-переменные), заданные только в трёх блоках ниже:
   тёмная тема (по умолчанию), светлая по настройке устройства и светлая по выбору
   рабочего (<html data-theme="light">). Вне этих блоков цветов нет — только var(--…).
   Тема сама ставится скриптом theme.js; кнопка #theme в шапке переключает её. */

/* ===== Тёмная тема ===== */
:root {
  color-scheme: dark;
  --mill-ring: conic-gradient(from -35deg, #f9fcff, #9caab7 13%, #f3f7fb 25%, #74828f 42%, #394652 52%, #b8c4ce 67%, #eff5fa 80%, #7d8c98 91%, #f9fcff);
  --mill-gap: #111a22;
  --mill-glint: #fff;

  /* Металл, пульт и поверхности главного экрана. */
  --metal-panel-top: #414c58;
  --metal-panel-bottom: #202933;
  --metal-brush: rgba(229, 240, 250, 0.035);
  --metal-edge: #64717e;
  --metal-highlight: rgba(255, 255, 255, 0.65);
  --metal-shadow: rgba(5, 13, 22, 0.42);
  --metal-plate: #1c2630;
  --metal-ink: #f4f7fa;
  --metal-muted: #d1dae3;
  --metal-chrome: linear-gradient(135deg, #f5f8fb 0%, #88939d 28%, #e6edf3 45%, #56616c 70%, #cad3dc 100%);
  --metal-screw: radial-gradient(circle at 35% 30%, #c9d2db, #606d7a 45%, #202b35 75%);
  --mill-green-top: #cbff9c;
  --mill-green-mid: #55d726;
  --mill-green-bottom: #12601e;
  --mill-green-glow: rgba(100, 234, 43, 0.48);
  --mill-red-top: #ffb4a8;
  --mill-red-mid: #ed4037;
  --mill-red-bottom: #78181c;
  --mill-red-glow: rgba(255, 66, 54, 0.42);
  --mill-status-green: #61bd43;
  --mill-status-red: #da4d4b;
  --mill-status-green-glow: rgba(107, 196, 63, 0.17);
  --mill-status-red-glow: rgba(225, 71, 65, 0.14);
  --mill-lamp-good: #68c644;
  --mill-lamp-warn: #e6ab32;
  --metal-page: linear-gradient(135deg, #27323d, #161d26 58%, #293440);
  --metal-card: linear-gradient(180deg, #323d48, #252e39);
  --metal-card-edge: #4a5968;
  --metal-card-glint: rgba(219, 237, 255, 0.12);
  --metal-card-shadow: 0 5px 18px rgba(0, 0, 0, 0.24);
  --metal-inset: linear-gradient(180deg, #202a35, #293541);
  --metal-avatar: linear-gradient(145deg, #627283, #344454);

  /* Фоны и поверхности */
  --bg: #14161a;               /* страница, шапка */
  --surface: #1b1e24;          /* табло, время смены, вкладки, фон графиков */
  --surface-2: #22252b;        /* поля ввода, плитки, карточки */
  --stat-bg: #22252b;          /* плашки внутри табло */
  --meter-track: #22252b;      /* дорожка полос в метриках */

  /* Текст */
  --text: #f2f4f8;             /* основной */
  --text-2: #f0f2f5;           /* значения на табло, подписи графиков */
  --text-soft: #b7bdc7;        /* пояснения, подписи шкалы */
  --text-sub: #c5cbd5;         /* подзаголовки групп причин, значения зон */
  --text-muted: #a0a6b1;       /* приглушённый */
  --text-attn: #ffcf70;        /* строка сохранения: нужно внимание */
  --text-good: #3fb950;        /* число/состояние: хорошо, работает */
  --text-bad: #f85149;         /* число плохо, текст ошибки */
  --text-stopped: #ff6b6b;     /* стан стоит */
  --blue: #58a6ff;             /* акцент: плановое, выбранная вкладка */
  --placeholder: #aeb6c4;      /* подсказка в пустом поле */

  /* Рамки и линии */
  --border: #3a3f4a;           /* рамки блоков, разделители */
  --border-strong: #4a505c;    /* рамки кнопок, полей, карточек */
  --border-note: #626b7a;      /* линии вокруг записки смене */
  --line-soft: #2d333b;        /* тонкие разделители блока метрик */
  --focus: #8cc8ff;            /* рамка фокуса и каретка */
  --selection-bg: #245477;     /* выделенный текст: фон */
  --selection-text: #fff;      /* выделенный текст: цвет */

  /* Насыщенные кнопки и пилюли */
  --on-solid: #fff;            /* текст на цветных пилюлях и плашке «Записано» */
  --btn-text: #f2f4f8;         /* текст на больших кнопках «СТАН ВСТАЛ» / «СТАН ПОШЁЛ» */
  --green-solid: #1a7f37;      /* зелёная кнопка, пилюля, плашка «Записано» */
  --green-solid-edge: #2ea043; /* рамка зелёной кнопки */
  --red-solid: #c5221f;        /* красная кнопка, пилюля */
  --red-solid-edge: #da3633;   /* рамка красной кнопки */
  --demo-solid: #6e4bd8;       /* пилюля «демо» */
  --pill-bg: #3a3e46;          /* обычная пилюля («Связаться», переключатель темы) */
  --pill-home-bg: #2d333b;     /* пилюля «На главный экран» */

  /* Акценты и их фоны */
  --green: #2ea043;            /* работа, успех: рамки, графики */
  --green-bg: #14532d;         /* фон полосы «стан работает», выбранной плитки */
  --red: #da3633;              /* простой, остановка: рамки, графики */
  --red-bg: #5c1a18;           /* фон полосы «стан стоит», отказов */
  --warn: #e3b341;             /* предупреждение: плашки и метки */
  --on-warn: #1a1c20;          /* текст на жёлтом */
  --warn-edge: #e3b341;        /* рамка жёлтых карточек и кнопок */
  --warn-bg: #4a3a10;          /* фон жёлтых карточек и кнопок */
  --tab-on-bg: #1f3350;        /* фон выбранной вкладки метрик */

  /* Нажатие и тень */
  --press-btn: brightness(1.25);  /* кнопка под пальцем */
  --press-tile: brightness(1.3);  /* плитка под пальцем */
  --shadow-toast: 0 6px 24px rgba(0, 0, 0, 0.5);

  /* Графики метрик */
  --chart-grid: #2d333b;       /* сетка */
  --chart-axis: #6e7681;       /* ось и рамка «нет данных» в легенде */
  --chart-0: #da3633;          /* доли кольца по порядку */
  --chart-1: #e3b341;
  --chart-2: #58a6ff;
  --chart-3: #a371f7;
  --chart-4: #3fb950;
  --chart-5: #f778ba;
  --chart-6: #8b949e;

  /* Зоны причин простоя в метриках и на выборе группы */
  --rz-work: #2ea043;
  --rz-plan: #4f8dff;
  --rz-unplanned: #e3b341;
  --rz-failure: #da3633;
  --mark-border: #808895;      /* рамка квадратика зоны */

  /* Шкала суток (timeline.css) */
  --ds-bg: #20242b;            /* карточка шкалы */
  --ds-track: #262a32;         /* фон строки */
  --ds-faint: #6b7280;         /* подпись будущего часа, пунктир границы смен */
  --ds-future-border: #3a3f4a; /* рамка будущей клетки (пунктир) */
  --ds-now: #f2f4f8;           /* рамка и черта «сейчас», плашка времени */
  --ds-now-text: #16181c;      /* текст на плашке времени */
  --ds-now-shadow: 0 0 4px rgba(0, 0, 0, 0.7);
  --ds-sel: #6ea8fe;           /* выбранная строка */
  --ds-shift-bg: #282e38;      /* заголовок смены */
  --ds-shift-active-bg: #333b48;
  --ds-shift-active-text: #ffffff;
  --ds-details-bg: #16181c;    /* подробности по нажатию */
  --ds-legend-text: #e6e9ee;
  --z-work: #2fd35f;           /* работает */
  --z-plan: #4f8dff;           /* плановый простой — синий (владелец, 01.10.2026) */
  --z-plan-edge: transparent;  /* рамка планового на шкале: не нужна, синий и так виден */
  --z-plan-chip-edge: #2f6fe0; /* рамка квадрата планового в легенде */
  --z-unplanned: #ffc93c;      /* внеплановый простой */
  --z-failure: #ff5252;        /* авария */
  --z-nodata: #565d66;         /* нет данных */
}

/* ===== Светлая тема по настройке устройства (если тема не выбрана вручную) =====
   Значения совпадают с блоком :root[data-theme="light"] ниже — менять в обоих. */
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    color-scheme: light;

    /* Металл, пульт и поверхности главного экрана. */
    --metal-panel-top: #414c58;
    --metal-panel-bottom: #202933;
    --metal-brush: rgba(229, 240, 250, 0.035);
    --metal-edge: #64717e;
    --metal-highlight: rgba(255, 255, 255, 0.65);
    --metal-shadow: rgba(5, 13, 22, 0.42);
    --metal-plate: #1c2630;
    --metal-ink: #f4f7fa;
    --metal-muted: #d1dae3;
    --metal-chrome: linear-gradient(135deg, #f5f8fb 0%, #88939d 28%, #e6edf3 45%, #56616c 70%, #cad3dc 100%);
    --metal-screw: radial-gradient(circle at 35% 30%, #c9d2db, #606d7a 45%, #202b35 75%);
    --mill-green-top: #cbff9c;
    --mill-green-mid: #55d726;
    --mill-green-bottom: #12601e;
    --mill-green-glow: rgba(100, 234, 43, 0.48);
    --mill-red-top: #ffb4a8;
    --mill-red-mid: #ed4037;
    --mill-red-bottom: #78181c;
    --mill-red-glow: rgba(255, 66, 54, 0.42);
    --mill-status-green: #61bd43;
    --mill-status-red: #da4d4b;
    --mill-status-green-glow: rgba(107, 196, 63, 0.17);
    --mill-status-red-glow: rgba(225, 71, 65, 0.14);
    --mill-lamp-good: #68c644;
    --mill-lamp-warn: #e6ab32;
    --metal-page: linear-gradient(125deg, #edf2f6 0%, #d7e1eb 48%, #eaf0f5 100%);
    --metal-card: linear-gradient(180deg, #fcfdfe, #e9eff5);
    --metal-card-edge: #b9c7d4;
    --metal-card-glint: #ffffff;
    --metal-card-shadow: 0 5px 16px rgba(47, 68, 88, 0.12);
    --metal-inset: linear-gradient(180deg, #dbe4ed, #edf2f7);
    --metal-avatar: linear-gradient(145deg, #f6f9fc, #b3c3d2);

    --bg: #e9edf2;
    --surface: #ffffff;
    --surface-2: #ffffff;
    --stat-bg: #f0f3f7;
    --meter-track: #d3dae3;

    --text: #12161c;
    --text-2: #12161c;
    --text-soft: #3a4250;
    --text-sub: #414a58;
    --text-muted: #4a5463;
    --text-attn: #8a4b00;
    --text-good: #17702f;
    --text-bad: #b61f29;
    --text-stopped: #b4232a;
    --blue: #0a5fc4;
    --placeholder: #5a6474;

    --border: #aab3c0;
    --border-strong: #6c7788;
    --border-note: #8a94a4;
    --line-soft: #d3d9e1;
    --focus: #0969da;
    --selection-bg: #b9d9fb;
    --selection-text: #0b1a2b;

    --on-solid: #fff;
    --btn-text: #ffffff;
    --green-solid: #1a7f37;
    --green-solid-edge: #0f5a26;
    --red-solid: #c5221f;
    --red-solid-edge: #8f1513;
    --demo-solid: #6e4bd8;
    --pill-bg: #d3dae3;
    --pill-home-bg: #c6cfdb;

    --green: #1f883d;
    --green-bg: #d3efdb;
    --red: #cf222e;
    --red-bg: #f9d3d0;
    --warn: #f0b429;
    --on-warn: #1a1c20;
    --warn-edge: #a8690a;
    --warn-bg: #fff0bf;
    --tab-on-bg: #d8e8fb;

    --press-btn: brightness(0.88);
    --press-tile: brightness(0.88);
    --shadow-toast: 0 6px 24px rgba(0, 0, 0, 0.28);

    --chart-grid: #dde2e9;
    --chart-axis: #57606a;
    --chart-0: #cf222e;
    --chart-1: #bf8700;
    --chart-2: #0969da;
    --chart-3: #8250df;
    --chart-4: #1a7f37;
    --chart-5: #bf3989;
    --chart-6: #6e7781;

    --rz-work: #1faa4b;
    --rz-plan: #2563eb;
    --rz-unplanned: #f2a900;
    --rz-failure: #e5383b;
    --mark-border: #5f6978;

    --ds-bg: #ffffff;
    --ds-track: #e3e8ee;
    --ds-faint: #5f6877;
    --ds-future-border: #7d8797;
    --ds-now: #12161c;
    --ds-now-text: #ffffff;
    --ds-now-shadow: 0 0 4px rgba(255, 255, 255, 0.9);
    --ds-sel: #0969da;
    --ds-shift-bg: #e3e8ef;
    --ds-shift-active-bg: #ccd6e3;
    --ds-shift-active-text: #0b0f15;
    --ds-details-bg: #f3f5f8;
    --ds-legend-text: #1f2630;
    --z-work: #1faa4b;
    --z-plan: #3b82f6;
    --z-plan-edge: transparent;
    --z-plan-chip-edge: #2563eb;
    --z-unplanned: #f2a900;
    --z-failure: #e5383b;
    --z-nodata: #98a1ae;
  }
}

/* ===== Светлая тема по выбору рабочего (кнопка #theme, theme.js ставит data-theme) ===== */
:root[data-theme="light"] {
  color-scheme: light;

  /* Металл, пульт и поверхности главного экрана. */
  --metal-panel-top: #414c58;
  --metal-panel-bottom: #202933;
  --metal-brush: rgba(229, 240, 250, 0.035);
  --metal-edge: #64717e;
  --metal-highlight: rgba(255, 255, 255, 0.65);
  --metal-shadow: rgba(5, 13, 22, 0.42);
  --metal-plate: #1c2630;
  --metal-ink: #f4f7fa;
  --metal-muted: #d1dae3;
  --metal-chrome: linear-gradient(135deg, #f5f8fb 0%, #88939d 28%, #e6edf3 45%, #56616c 70%, #cad3dc 100%);
  --metal-screw: radial-gradient(circle at 35% 30%, #c9d2db, #606d7a 45%, #202b35 75%);
  --mill-green-top: #cbff9c;
  --mill-green-mid: #55d726;
  --mill-green-bottom: #12601e;
  --mill-green-glow: rgba(100, 234, 43, 0.48);
  --mill-red-top: #ffb4a8;
  --mill-red-mid: #ed4037;
  --mill-red-bottom: #78181c;
  --mill-red-glow: rgba(255, 66, 54, 0.42);
  --mill-status-green: #61bd43;
  --mill-status-red: #da4d4b;
  --mill-status-green-glow: rgba(107, 196, 63, 0.17);
  --mill-status-red-glow: rgba(225, 71, 65, 0.14);
  --mill-lamp-good: #68c644;
  --mill-lamp-warn: #e6ab32;
  --metal-page: linear-gradient(125deg, #edf2f6 0%, #d7e1eb 48%, #eaf0f5 100%);
  --metal-card: linear-gradient(180deg, #fcfdfe, #e9eff5);
  --metal-card-edge: #b9c7d4;
  --metal-card-glint: #ffffff;
  --metal-card-shadow: 0 5px 16px rgba(47, 68, 88, 0.12);
  --metal-inset: linear-gradient(180deg, #dbe4ed, #edf2f7);
  --metal-avatar: linear-gradient(145deg, #f6f9fc, #b3c3d2);

  --bg: #e9edf2;
  --surface: #ffffff;
  --surface-2: #ffffff;
  --stat-bg: #f0f3f7;
  --meter-track: #d3dae3;

  --text: #12161c;
  --text-2: #12161c;
  --text-soft: #3a4250;
  --text-sub: #414a58;
  --text-muted: #4a5463;
  --text-attn: #8a4b00;
  --text-good: #17702f;
  --text-bad: #b61f29;
  --text-stopped: #b4232a;
  --blue: #0a5fc4;
  --placeholder: #5a6474;

  --border: #aab3c0;
  --border-strong: #6c7788;
  --border-note: #8a94a4;
  --line-soft: #d3d9e1;
  --focus: #0969da;
  --selection-bg: #b9d9fb;
  --selection-text: #0b1a2b;

  --on-solid: #fff;
  --btn-text: #ffffff;
  --green-solid: #1a7f37;
  --green-solid-edge: #0f5a26;
  --red-solid: #c5221f;
  --red-solid-edge: #8f1513;
  --demo-solid: #6e4bd8;
  --pill-bg: #d3dae3;
  --pill-home-bg: #c6cfdb;

  --green: #1f883d;
  --green-bg: #d3efdb;
  --red: #cf222e;
  --red-bg: #f9d3d0;
  --warn: #f0b429;
  --on-warn: #1a1c20;
  --warn-edge: #a8690a;
  --warn-bg: #fff0bf;
  --tab-on-bg: #d8e8fb;

  --press-btn: brightness(0.88);
  --press-tile: brightness(0.88);
  --shadow-toast: 0 6px 24px rgba(0, 0, 0, 0.28);

  --chart-grid: #dde2e9;
  --chart-axis: #57606a;
  --chart-0: #cf222e;
  --chart-1: #bf8700;
  --chart-2: #0969da;
  --chart-3: #8250df;
  --chart-4: #1a7f37;
  --chart-5: #bf3989;
  --chart-6: #6e7781;

  --rz-work: #1faa4b;
  --rz-plan: #2563eb;
  --rz-unplanned: #f2a900;
  --rz-failure: #e5383b;
  --mark-border: #5f6978;

  --ds-bg: #ffffff;
  --ds-track: #e3e8ee;
  --ds-faint: #5f6877;
  --ds-future-border: #7d8797;
  --ds-now: #12161c;
  --ds-now-text: #ffffff;
  --ds-now-shadow: 0 0 4px rgba(255, 255, 255, 0.9);
  --ds-sel: #0969da;
  --ds-shift-bg: #e3e8ef;
  --ds-shift-active-bg: #ccd6e3;
  --ds-shift-active-text: #0b0f15;
  --ds-details-bg: #f3f5f8;
  --ds-legend-text: #1f2630;
  --z-work: #1faa4b;
  --z-plan: #3b82f6;
  --z-plan-edge: transparent;
  --z-plan-chip-edge: #2563eb;
  --z-unplanned: #f2a900;
  --z-failure: #e5383b;
  --z-nodata: #98a1ae;
}
/* ===== Конец блоков токенов ===== */

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font: 20px/1.4 system-ui, sans-serif;
  background: var(--metal-page);
  background-attachment: fixed;
  color: var(--text);
  min-height: 100dvh;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  gap: 12px;
  align-items: center;
  padding: calc(8px + env(safe-area-inset-top)) 12px 8px;
  background: var(--bg);
}
.pill {
  display: inline-block;
  padding: 6px 14px;
  border-radius: 999px;
  font-size: 0.9em;
  font-weight: 700;
  background: var(--pill-bg);
}
.pill.ok { background: var(--green-solid); color: var(--on-solid); }
.pill.bad { background: var(--red-solid); color: var(--on-solid); }
.pill.warn { background: var(--warn); color: var(--on-warn); }
.pill.demo { background: var(--demo-solid); color: var(--on-solid); }

main {
  max-width: 760px;
  margin: 0 auto;
  padding: 12px 12px calc(24px + env(safe-area-inset-bottom));
}
h1 { font-size: 1.5em; margin: 4px 0 16px; }
h1.q { font-size: 1.6em; font-weight: 800; margin: 12px 0 16px; }
h2 { font-size: 1.15em; margin: 20px 0 12px; }
.muted { color: var(--text-muted); }
.hint { color: var(--text-muted); font-size: 0.85em; margin: 8px 2px 0; }
.step { color: var(--text-muted); font-size: 0.85em; margin: 12px 0 0; }

button, input, textarea {
  font: inherit;
  color: inherit;
  border-radius: 14px;
  border: 2px solid var(--border-strong);
  background: var(--surface-2);
}
input {
  width: 100%;
  min-height: 64px;
  padding: 12px 16px;
  margin-top: 12px;
  font-size: 1.1em;
}
.note-input {
  width: 100%;
  min-height: 120px;
  padding: 14px 16px;
  margin-top: 12px;
  font-size: 22px;
  line-height: 1.4;
  resize: vertical;
}
.btn {
  display: block;
  width: 100%;
  min-height: 64px;
  padding: 12px 16px;
  margin-top: 12px;
  font-size: 1.1em;
  font-weight: 700;
  text-align: center;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.btn:active { filter: var(--press-btn); }
.btn.primary { background: var(--green-solid); border-color: var(--green-solid-edge); color: var(--btn-text); }
.btn.danger { background: var(--red-solid); border-color: var(--red-solid-edge); color: var(--btn-text); }
.btn.warn-btn { background: var(--warn-bg); border-color: var(--warn-edge); }
.btn:disabled { opacity: 0.45; }

/* Кнопка «Назад»: первая строка вложенного экрана, серая рамка, не путается с действием */
.btn.back {
  background: transparent;
  border-color: var(--border-strong);
  color: var(--text-muted);
  text-align: left;
  font-weight: 400;
  margin-top: 0;
}
.btn-flat {
  background: transparent;
  border-color: var(--border-strong);
  color: var(--text-muted);
  font-weight: 400;
}
.btn-inline {
  width: auto;
  min-height: 48px;
  margin-top: 0;
  padding: 8px 16px;
  font-size: 0.85em;
  white-space: nowrap;
}

/* Шапка главного экрана: кто на посту + «Сменить» справа */
.runhead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 0.9em;
}

/* Главные кнопки поста */
.btn-huge {
  min-height: 45dvh;
  font-size: 2em;
  font-weight: 800;
  letter-spacing: 0.02em;
}
.btn-go {
  min-height: 22dvh;
  font-size: 1.6em;
  font-weight: 800;
}

/* Цветные полосы состояния */
.bar {
  border-radius: 14px;
  padding: 16px;
  margin-top: 12px;
  font-weight: 700;
}
.bar.green { background: var(--green-bg); border: 2px solid var(--green); }
.bar.red { background: var(--red-bg); border: 2px solid var(--red); }
.timer {
  display: block;
  font-size: 2.6em;
  font-weight: 800;
  text-align: center;
  font-variant-numeric: tabular-nums;
  margin-top: 4px;
}

/* Плитки выбора (бригады, люди, группы причин, причины, время) */
.tiles {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 12px;
}
.tile {
  min-height: 84px;
  padding: 14px;
  font-size: 1.05em;
  font-weight: 700;
  text-align: center;
  cursor: pointer;
  background: var(--surface-2);
  border: 2px solid var(--border-strong);
  border-radius: 14px;
  touch-action: manipulation;
}
.tile:active { filter: var(--press-tile); }
.tile.unknown { background: var(--warn-bg); border-color: var(--warn-edge); }
.tile .t-code {
  display: block;
  font-size: 0.75em;
  font-weight: 400;
  color: var(--text-muted);
  margin-top: 4px;
}
.tile.sel { border-color: var(--green); background: var(--green-bg); }

/* Две обычные кнопки в ряд */
.row2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.row2 .btn { margin-top: 12px; }

/* Карточка (причина на экране «Стан стоит», «Простой записан», «Проверьте») */
.card {
  margin-top: 12px;
  padding: 14px 16px;
  border-radius: 14px;
  background: var(--metal-card);
  border: 1px solid var(--metal-card-edge);
  box-shadow: inset 0 1px 0 var(--metal-card-glint), var(--metal-card-shadow);
}
.card.ok { border-color: var(--green); }
.card.none { border-color: var(--warn-edge); background: var(--warn-bg); }
.card-title { font-weight: 800; font-size: 1.15em; }
.card-line { font-weight: 700; margin-top: 6px; }
.card-note { color: var(--text-muted); margin-top: 6px; }

/* Плашка «Стан всё ещё стоит?» */
.banner-warn {
  margin-top: 12px;
  padding: 14px 16px;
  border-radius: 14px;
  background: var(--warn);
  color: var(--on-warn);
  font-weight: 800;
  text-align: center;
}
.earlier { margin-top: 12px; }
.earlier .hint { margin-top: 4px; }
.earlier-text { overflow-wrap: anywhere; white-space: pre-wrap; }

/* Сводка итога смены */
.stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 12px;
}
.stat {
  background: var(--surface-2);
  border: 2px solid var(--border-strong);
  border-radius: 14px;
  padding: 14px;
  text-align: center;
}
.stat .v { display: block; font-size: 1.4em; font-weight: 800; margin-top: 4px; }
.stat.good .v { color: var(--text-good); }
.stat.bad .v { color: var(--text-bad); }
.stat.planned .v { color: var(--blue); }

/* Список простоев смены */
.segs { margin-top: 12px; display: grid; gap: 12px; }
.seg {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 6px 12px;
  align-items: start;
  width: 100%;
  min-height: 64px;
  padding: 12px 14px;
  text-align: left;
  background: var(--surface-2);
  border: 2px solid var(--border-strong);
  border-radius: 14px;
  cursor: pointer;
}
.seg .when { font-weight: 800; font-variant-numeric: tabular-nums; }
.seg .dur { color: var(--text-muted); font-variant-numeric: tabular-nums; }
.seg .why { font-weight: 700; }
.badge-need {
  display: inline-block;
  background: var(--warn);
  color: var(--on-warn);
  border-radius: 8px;
  padding: 2px 10px;
  font-weight: 800;
  font-size: 0.85em;
}
.seg .badge-need { margin-top: 6px; }
.seg.open { border-color: var(--red); }
.seg .manual-tag { display: block; font-size: 0.75em; color: var(--text-muted); font-weight: 400; }

/* Крупное значение времени в мастере «Забыл отметить простой» */
.stepval {
  text-align: center;
  font-size: 1.6em;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  margin-top: 12px;
}

/* «Записано» внизу на 3 секунды */
.toast {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(20px + env(safe-area-inset-bottom));
  z-index: 10;
  background: var(--green-solid);
  border: 2px solid var(--green-solid-edge);
  color: var(--on-solid);
  font-weight: 800;
  padding: 14px 28px;
  border-radius: 999px;
  box-shadow: var(--shadow-toast);
}

/* Отказы сервера */
.rejects {
  max-width: 760px;
  margin: 0 auto;
  padding: 0 12px 24px;
}
.reject {
  margin-top: 8px;
  padding: 10px 14px;
  border-radius: 10px;
  background: var(--red-bg);
  border: 2px solid var(--red);
  font-size: 0.9em;
}
.error-text { color: var(--text-bad); font-weight: 700; }

/* Планшет в горизонтали: только экран «Стан стоит» шире, в две колонки */
@media (min-width: 900px) and (orientation: landscape) {
  main:has(.stop-grid) { max-width: 1240px; }
  .stop-grid {
    display: grid;
    grid-template-columns: minmax(380px, 5fr) 7fr;
    gap: 16px;
    align-items: start;
  }
  .btn-go { min-height: 30dvh; }
}

/* Атрибут hidden сильнее любых классов */
[hidden] { display: none !important; }

/* В карточке простоя: время и длительность в первой строке, причина и метки — ниже на всю ширину */
.seg .when { grid-column: 1; grid-row: 1; }
.seg .dur { grid-column: 2; grid-row: 1; text-align: right; }
.seg > span:nth-child(2) { grid-column: 1 / -1; grid-row: 2; }

/* Табло стана на первом экране */
.board { background: var(--surface); border: 2px solid var(--border); border-radius: 16px; padding: 14px 16px; margin: 4px 0 16px; }
.board-top { display: flex; align-items: baseline; gap: 12px; }
.board-clock { font-size: 2.4em; font-weight: 800; font-variant-numeric: tabular-nums; }
.board-date { color: var(--text-muted); }
.board-state { font-weight: 800; font-size: 1.1em; margin-top: 6px; }
.board-state.running { color: var(--text-good); }
.board-state.stopped { color: var(--text-stopped); }
.board-period { margin: 2px 0 10px; }
.board-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.board-stat { background: var(--stat-bg); border-radius: 12px; padding: 10px; text-align: center; color: var(--text-muted); font-size: 0.85em; }
.board-stat .v { display: block; white-space: nowrap; font-size: 1.15em; font-weight: 800; color: var(--text-2); font-variant-numeric: tabular-nums; }
.board-stat.good .v { color: var(--text-good); }
.board-stat.bad .v { color: var(--text-stopped); }

/* Московское время справа в полосе состояния */
.bar { position: relative; }
.bar .msk { float: right; font-variant-numeric: tabular-nums; font-weight: 800; opacity: 0.9; }

/* Смена и действия главного экрана оформлены рядом с пультом ниже. */
button.pill { cursor: pointer; font: inherit; font-weight: 700; }
.tiles.one { grid-template-columns: 1fr; }
a.tile { text-decoration: none; color: inherit; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.tile-off { opacity: 0.6; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.action-help { display: block; color: var(--text-soft); font-weight: 400; }
.handover-note { padding: 16px 0; border-block: 1px solid var(--border-note); color: var(--text); }
.receipt { font-weight: 700; }
.save-status { max-width: 760px; margin: 0 auto; padding: 8px 12px; color: var(--text-soft); font-size: 0.8em; }
.save-status.attention { color: var(--text-attn); }
.cancel { margin-top: 28px; }
.topbar { flex-wrap: wrap; }
button.pill { min-height: 52px; font-size: 0.8em; white-space: normal; }
.btn, .tile, .card-note, .action-help, .reject, .handover-note { overflow-wrap: anywhere; }
.card-note, .action-help { white-space: pre-wrap; }
.stop-grid > *, .stats > *, .board-stats > * { min-width: 0; }
button:focus-visible, a:focus-visible, input:focus-visible, textarea:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; }
input, textarea { caret-color: var(--focus); }
::selection { background: var(--selection-bg); color: var(--selection-text); }
input::placeholder, textarea::placeholder { color: var(--placeholder); opacity: 1; }
.btn:disabled, .tile:disabled { cursor: default; }
label { display: block; margin-top: 20px; }
@media (max-width: 480px) {
  .tiles, .row2 { grid-template-columns: 1fr; }
  .btn-huge { min-height: 32dvh; font-size: 1.7em; }
  .btn-go { min-height: 26dvh; }
  .board-top, .m-bar-head, .chart-legend { flex-wrap: wrap; }
  .board-clock { font-size: 2em; }
  .board-stats, .metrics .m-kpi { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .bar .msk { float: none; display: block; margin-top: 4px; font-size: 0.85em; }
  .m-bar-val { white-space: normal; text-align: right; }
}

/* Метрики работы стана */
.metrics { margin-top: 24px; padding-top: 16px; border-top: 2px solid var(--line-soft); }
.m-head { font-size: 1.2em; font-weight: 800; margin-bottom: 10px; }
.m-tabs { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 12px; }
.m-tab { min-height: 52px; border-radius: 12px; border: 2px solid var(--border); background: var(--surface); color: var(--text-2); font: inherit; font-weight: 700; cursor: pointer; }
.m-tab.on { border-color: var(--blue); background: var(--tab-on-bg); }
.m-kpi { grid-template-columns: repeat(3, 1fr); margin-bottom: 12px; }
.m-block { margin: 16px 0; }
.m-title { font-weight: 800; margin-bottom: 8px; }
.m-bar { margin: 8px 0; }
.m-bar-head { display: flex; justify-content: space-between; gap: 8px; font-size: 0.85em; }
.m-bar-name { font-weight: 700; }
.m-bar-val { color: var(--text-muted); white-space: nowrap; }
.m-track { height: 12px; background: var(--meter-track); border-radius: 6px; overflow: hidden; margin-top: 4px; display: flex; }
.m-fill { height: 100%; background: var(--red); }
.m-fill.work { background: var(--green); }
.m-fill.down { background: var(--red); }

/* Графики */
.chart { width: 100%; height: auto; display: block; background: var(--surface); border-radius: 12px; }
.chart .grid { stroke: var(--chart-grid); stroke-width: 1; }
.chart .ax { stroke: var(--chart-axis); stroke-width: 1.5; }
.chart .tick { fill: var(--text-muted); font-size: 12px; }
.chart .work { fill: var(--green); }
.chart .down { fill: var(--red); }
.chart .nodata { fill: none; stroke: var(--border-strong); stroke-dasharray: 3 3; }
.chart .legend { fill: var(--text-2); font-size: 13px; }
.chart .center { fill: var(--text-2); font-size: 16px; font-weight: 800; }
.chart .seg-0 { fill: var(--chart-0); stroke: var(--chart-0); } .chart .seg-1 { fill: var(--chart-1); stroke: var(--chart-1); }
.chart .seg-2 { fill: var(--chart-2); stroke: var(--chart-2); } .chart .seg-3 { fill: var(--chart-3); stroke: var(--chart-3); }
.chart .seg-4 { fill: var(--chart-4); stroke: var(--chart-4); } .chart .seg-5 { fill: var(--chart-5); stroke: var(--chart-5); }
.chart .seg-6 { fill: var(--chart-6); stroke: var(--chart-6); }
.chart .ring { fill: none; }
.chart-legend { display: flex; gap: 16px; margin-top: 8px; font-size: 0.8em; color: var(--text-muted); }
.lg::before { content: ""; display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.lg.work::before { background: var(--green); } .lg.down::before { background: var(--red); } .lg.nodata::before { border: 1px dashed var(--chart-axis); }

/* Три блока причин и единые цвета зон в метриках. */
.reason-zone-work { --reason-zone-color: var(--rz-work); }
.reason-zone-plan { --reason-zone-color: var(--rz-plan); }
.reason-zone-unplanned { --reason-zone-color: var(--rz-unplanned); }
.reason-zone-failure { --reason-zone-color: var(--rz-failure); }
.tiles.reason-groups { grid-template-columns: 1fr; }
.tile.reason-group { display: flex; flex-direction: column; align-items: flex-start;
  justify-content: center; gap: 8px; min-height: 112px; text-align: left;
  border-left: 10px solid var(--reason-zone-color); padding: 18px 20px; }
.reason-group-title { font-weight: 800; }
.reason-group-subtitle { font-size: 0.75em; font-weight: 400; line-height: 1.4; color: var(--text-sub); }
.btn.reason-later { min-height: 48px; padding: 10px 16px; font-size: 0.85em; margin-top: 12px; }
.reason-zone-mark { display: inline-block; flex: 0 0 14px; width: 14px; height: 14px;
  border: 1px solid var(--mark-border); border-radius: 3px; margin-right: 8px;
  vertical-align: -1px; background: var(--reason-zone-color); }
.zone-metric-row { display: flex; flex-wrap: wrap; justify-content: space-between;
  align-items: baseline; gap: 6px 16px; padding: 12px 0; border-bottom: 1px solid var(--border); }
.zone-metric-name { font-weight: 700; }
.zone-metric-value { color: var(--text-sub); font-size: 0.85em; font-variant-numeric: tabular-nums; }
@media (max-width: 480px) {
  .zone-metric-value { flex-basis: 100%; padding-left: 24px; }
}

/* Главный экран: холодный металл и промышленный пульт. */
.ico { width: 24px; height: 24px; flex: 0 0 auto; fill: none; stroke: currentColor;
  stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.topbar { flex-wrap: nowrap; gap: 12px; margin: 0 auto;
  padding-block: calc(20px + env(safe-area-inset-top)) 20px; background: none; }
.topbar::before { content: ''; position: absolute; inset: 0 var(--screen-gutter); z-index: -1;
  background: var(--metal-page); pointer-events: none; }
.topbar .pill { display: inline-flex; align-items: center; justify-content: center; gap: 9px;
  flex: 0 0 auto; min-height: 48px; padding: 10px 18px; font-size: 15px; white-space: nowrap;
  border: 1px solid var(--metal-edge); color: var(--metal-ink);
  background: linear-gradient(180deg, var(--metal-panel-top), var(--metal-panel-bottom));
  box-shadow: inset 0 1px 0 var(--metal-highlight), 0 3px 5px var(--metal-shadow); }
.topbar .pill .ico { width: 20px; height: 20px; }
.topbar .pill:active { transform: translateY(1px); }
.topbar .save-status { display: flex; align-items: center; gap: 8px; max-width: 280px; min-width: 0;
  margin: 0; padding: 0; font-size: 12px; line-height: 1.4; }
.save-status::before { content: ''; flex: 0 0 auto; width: 9px; height: 9px; border-radius: 50%;
  background: var(--mill-lamp-good); box-shadow: inset 0 1px 2px var(--metal-highlight), 0 0 6px var(--mill-green-glow); }
.save-status.attention::before { background: var(--mill-lamp-warn); box-shadow: 0 0 6px var(--mill-red-glow); }
.brand { margin-left: auto; flex: 0 0 auto; display: grid; gap: 3px; text-align: right; }
.brand strong { font-size: 25px; font-weight: 850; letter-spacing: 0.025em; }
.brand span { font-size: 10px; letter-spacing: 0.22em; text-transform: uppercase; color: var(--text-muted); }
.theme-toggle { display: grid; place-items: center; flex: 0 0 auto; margin-left: 6px;
  width: 52px; height: 52px; padding: 4px; border-radius: 50%; border: 1px solid var(--metal-edge);
  background: var(--metal-chrome); color: var(--metal-muted); cursor: pointer;
  box-shadow: inset 0 1px 1px var(--metal-highlight), 0 3px 7px var(--metal-shadow); }
.theme-toggle .bulb { width: 38px; height: 38px; padding: 5px; border-radius: 50%;
  background: var(--metal-plate); fill: none; stroke: currentColor; stroke-width: 1.6;
  stroke-linecap: round; stroke-linejoin: round; }
.theme-toggle .bulb-glass { fill: var(--mill-lamp-warn); }
.theme-toggle .bulb-rays { stroke: var(--mill-lamp-warn); }
:root[data-theme="dark"] .theme-toggle .bulb-glass { fill: none; }
:root[data-theme="dark"] .theme-toggle .bulb-rays { display: none; }
.mill-console { container-type: inline-size; }
.mill-status, .shift-card, .btn.shift-action { background: var(--metal-card); border: 1px solid var(--metal-card-edge);
  box-shadow: inset 0 1px 0 var(--metal-card-glint), var(--metal-card-shadow); border-radius: 16px; }
.mill-status { display: flex; align-items: center; justify-content: space-between; gap: 20px;
  min-height: 96px; padding: 17px 22px; margin-bottom: 18px; border-color: var(--mill-status-green);
  box-shadow: inset 0 1px 0 var(--metal-card-glint), 0 0 0 2px var(--mill-status-green-glow), 0 4px 18px var(--mill-status-green-glow); }
.mill-status.is-stop { border-color: var(--mill-status-red);
  box-shadow: inset 0 1px 0 var(--metal-card-glint), 0 0 0 2px var(--mill-status-red-glow), 0 4px 18px var(--mill-status-red-glow); }
.mill-state { display: flex; align-items: center; gap: 15px; min-width: 0; }
.mill-state > .ico { width: 36px; height: 36px; color: var(--text-good); }
.is-stop .mill-state > .ico { color: var(--text-stopped); }
.mill-state-title { font-size: clamp(20px, 2.6cqi, 30px); font-weight: 800; line-height: 1.25; }
.mill-info, .mill-timer { white-space: nowrap; font-variant-numeric: tabular-nums; }
.mill-subtitle { margin: 4px 0 0; color: var(--text-muted); font-size: 13px; font-weight: 400; }
.mill-clock { display: flex; align-items: center; gap: 12px; flex: 0 0 auto;
  border-left: 1px solid var(--metal-card-edge); padding-left: 22px;
  font-size: clamp(18px, 2.6cqi, 28px); font-weight: 750; font-variant-numeric: tabular-nums; }
.mill-clock > .ico { color: var(--text-muted); }
.mill-panel { position: relative; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px 0; padding: 28px 20px 16px; container-type: inline-size; border-radius: 18px;
  border: 1px solid var(--metal-edge); color: var(--metal-ink);
  background: repeating-linear-gradient(0deg, transparent 0 2px, var(--metal-brush) 2px 3px),
    linear-gradient(170deg, var(--metal-panel-top), var(--metal-panel-bottom));
  box-shadow: inset 0 2px 2px var(--metal-highlight), inset 0 -3px 4px var(--metal-shadow), 0 6px 12px var(--metal-shadow); }
/* По два винта на каждой стороне, у верхней и нижней кромки панели. */
.mill-panel::before, .mill-panel::after { content: ''; position: absolute; top: 10px; bottom: 10px; width: 7px;
  background-image: var(--metal-screw), var(--metal-screw); background-size: 7px 7px;
  background-position: center top, center bottom; background-repeat: no-repeat; }
.mill-panel::before { left: 10px; }
.mill-panel::after { right: 10px; }
.mill-btn { position: relative; display: flex; align-items: center; justify-content: center; gap: clamp(12px, 2cqi, 22px);
  min-width: 0; min-height: 142px; padding: 10px 12px; border: 0; border-radius: 0;
  font: inherit; font-weight: 800; color: var(--metal-ink); background: transparent; cursor: pointer; touch-action: manipulation; }
.mill-btn + .mill-btn { border-left: 1px solid var(--metal-edge); }
.mill-go { --mill-top: var(--mill-green-top); --mill-mid: var(--mill-green-mid); --mill-bottom: var(--mill-green-bottom); --mill-glow: var(--mill-green-glow); }
.mill-stop { --mill-top: var(--mill-red-top); --mill-mid: var(--mill-red-mid); --mill-bottom: var(--mill-red-bottom); --mill-glow: var(--mill-red-glow); }
.mill-lamp { display: block; flex: 0 0 auto; position: relative; width: clamp(132px, 18cqi, 156px); aspect-ratio: 1; border-radius: 50%;
  background: var(--mill-ring);
  box-shadow: 0 6px 7px var(--metal-shadow), inset 0 2px 2px var(--metal-highlight), inset 0 -3px 3px var(--metal-shadow), 0 0 0 2px var(--metal-plate), 0 0 0 3px var(--metal-edge);
  transition: transform 120ms ease-out, box-shadow 120ms ease-out; }
.mill-lamp::before { content: ''; position: absolute; inset: 13%; border-radius: 50%;
  background: radial-gradient(ellipse 38% 22% at 32% 22%, var(--mill-glint), var(--mill-top) 35%, transparent 100%),
    radial-gradient(ellipse at 38% 28%, var(--mill-top), var(--mill-mid) 43%, var(--mill-bottom) 85%);
  box-shadow: 0 0 0 2px var(--mill-gap), 0 3px 4px var(--metal-shadow), inset 0 2px 3px var(--metal-highlight), inset 0 -10px 12px var(--metal-shadow);
  filter: brightness(.76) saturate(.85); transition: filter 120ms ease-out; }
.mill-lamp::after { content: ''; position: absolute; inset: -3px; border-radius: 50%; opacity: 0;
  border: 3px solid transparent; border-bottom-color: var(--mill-mid);
  filter: drop-shadow(0 3px 4px var(--mill-glow)); pointer-events: none; }
.mill-btn.is-on .mill-lamp { transform: translateY(2px); }
.mill-btn.is-on .mill-lamp::before { filter: none; }
.mill-btn.is-on .mill-lamp::after { opacity: 1; }
@media (hover: hover) { .mill-btn:hover .mill-lamp::before { filter: brightness(.88) saturate(.9); }
  .mill-btn.is-on:hover .mill-lamp::before { filter: brightness(1.1); }
  .topbar .pill:hover, .btn.shift-action:hover { border-color: var(--focus); } }
.mill-btn:active .mill-lamp { transform: translateY(5px); }
.mill-btn:active .mill-lamp::before { box-shadow: inset 0 5px 10px var(--metal-shadow); }
.mill-label { display: grid; gap: 2px; min-width: 0; width: clamp(140px, 20cqi, 208px); max-width: 100%; padding: 10px 14px; border-radius: 6px;
  border: 1px solid var(--metal-edge);
  background: var(--metal-plate); box-shadow: inset 0 2px 4px var(--metal-shadow), 0 1px 0 var(--metal-edge);
  font-size: clamp(15px, 2.7cqi, 29px); letter-spacing: .035em; line-height: 1.2; text-align: left; white-space: nowrap; }
.mill-btn.is-on .mill-label { text-shadow: 0 0 8px var(--mill-glow); }
/* Надпись — только у горящей кнопки; у второй табличка скрыта, место под неё остаётся, кнопку называет aria-label */
.mill-btn:not(.is-on) .mill-label { visibility: hidden; }
.mill-hint { display: flex; align-items: center; justify-content: center; gap: 8px; grid-column: 1 / -1;
  max-width: 100%; width: fit-content; margin: 0 auto; padding: 7px 14px; border-radius: 7px;
  background: var(--metal-plate); color: var(--metal-muted); font-size: 13px; line-height: 1.4; }
.mill-hint .ico { width: 17px; height: 17px; }
.shift-block { display: grid; gap: 12px; margin-top: 18px; padding: 0; border: 0; }
.shift-card { padding: 18px 22px 14px; }
.shift-person { display: grid; grid-template-columns: 72px minmax(0, 1fr); align-items: center; gap: 18px; }
.shift-avatar { display: grid; place-items: center; align-self: start; width: 72px; height: 78px; border: 1px solid var(--metal-card-edge);
  border-radius: 12px; background: var(--metal-avatar); color: var(--text-soft); box-shadow: inset 0 1px 1px var(--metal-card-glint); }
.shift-avatar .ico { width: 46px; height: 46px; stroke-width: 1.35; }
.shift-person h2 { margin: 2px 0 3px; font-size: 24px; line-height: 1.25; font-weight: 800; }
.shift-person p { margin: 3px 0; font-size: 15px; }
.shift-person p.muted { font-size: 13px; }
.shift-block .shift-time { display: flex; flex-wrap: wrap; align-items: center; gap: 10px;
  margin: 14px 0 0; padding: 10px 14px; border: 1px solid var(--metal-card-edge); border-radius: 9px;
  background: var(--metal-inset); box-shadow: inset 0 1px 2px var(--metal-card-glint);
  font-size: 15px; font-variant-numeric: tabular-nums; }
.shift-time .ico { width: 19px; height: 19px; color: var(--text-muted); }
.shift-remaining { border-left: 1px solid var(--metal-card-edge); padding-left: 16px; margin-left: 8px; }
.shift-time > .ico:last-child { margin-left: auto; }
.btn.shift-action { display: grid; grid-template-columns: 50px minmax(0, 1fr) 24px; gap: 16px; align-items: center;
  margin: 0; padding: 14px 22px; min-height: 84px; text-align: left; font-size: 21px; line-height: 1.25; overflow-wrap: normal; }
.action-ico { display: grid; place-items: center; width: 50px; height: 50px; border-radius: 50%;
  color: var(--metal-ink); background: linear-gradient(145deg, var(--metal-panel-top), var(--metal-panel-bottom));
  border: 1px solid var(--metal-edge); box-shadow: inset 0 1px 1px var(--metal-highlight), 0 2px 4px var(--metal-shadow); }
.action-ico .ico { width: 26px; height: 26px; }
.shift-action .action-help { font-size: 14px; margin-top: 5px; line-height: 1.4; overflow-wrap: normal; }
.shift-action > .ico { color: var(--text-muted); width: 20px; }
.stop-grid { display: block; }
.stop-grid > * { min-width: 0; }
@media (min-width: 1500px) {
  .stop-grid { display: grid; grid-template-columns: minmax(0, 1fr) 240px; gap: 18px; align-items: start; }
  .stop-grid > :last-child .card:first-child { margin-top: 0; }
}
@container (max-width: 650px) {
  .mill-status { padding: 14px; gap: 12px; }
  .mill-state { gap: 10px; }
  .mill-state > .ico { width: 26px; height: 26px; }
  .mill-clock { padding-left: 14px; gap: 8px; }
  .mill-clock > .ico { display: none; }
  .mill-btn { flex-direction: column; padding: 10px; gap: 18px; }
  .mill-lamp { width: 132px; max-width: 100%; }
  .mill-label { width: 100%; max-width: 208px; padding: 9px;
    font-size: clamp(14px, 4.7cqi, 22px); text-align: center; }
}
@container (max-width: 480px) {
  .mill-status { align-items: stretch; flex-direction: column; gap: 10px; }
  .mill-clock { border-left: 0; border-top: 1px solid var(--metal-card-edge); padding: 8px 0 0; font-size: 17px; }
  .mill-clock > .ico { display: block; width: 18px; height: 18px; }
  .mill-clock > div { display: flex; align-items: baseline; gap: 12px; }
  .mill-clock .mill-subtitle { margin: 0; }
  .mill-btn { flex-direction: column; gap: 18px; padding: 6px 8px; }
}
@media (max-width: 1099px) {
  .topbar { padding-block: 14px; gap: 9px; }
  .topbar .pill { padding: 9px 12px; font-size: 13px; }
  .brand strong { font-size: 18px; }
  .brand span { font-size: 8px; letter-spacing: .13em; }
  .topbar .save-status { font-size: 11px; max-width: 120px; }
}
@media (max-width: 600px) {
  .brand { display: none; }
  .topbar .save-status { flex: 1; }
  .theme-toggle { margin-left: auto; }
}
@media (max-width: 480px) {
  .topbar { gap: 6px; padding-block: calc(8px + env(safe-area-inset-top)) 8px; }
  .topbar .pill { min-height: 44px; padding: 8px; gap: 5px; font-size: 11px; }
  .topbar .pill .ico { width: 16px; height: 16px; }
  .topbar .save-status { flex: 0 0 12px; justify-content: center; }
  .save-status-text { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }
  .save-status::before { width: 8px; height: 8px; }
  .theme-toggle { width: 40px; height: 40px; padding: 3px; }
  .theme-toggle .bulb { width: 32px; height: 32px; }
  main { padding: 10px 12px 24px; }
  .mill-panel { padding: 24px 12px 14px; gap: 18px 0; }
  .mill-hint { font-size: 12px; padding: 7px 8px; align-items: flex-start; }
  .shift-card { padding: 15px 14px 12px; }
  .shift-person { grid-template-columns: 52px minmax(0, 1fr); gap: 12px; }
  .shift-avatar { width: 52px; height: 60px; }
  .shift-avatar .ico { width: 36px; height: 36px; }
  .shift-person h2 { font-size: 20px; }
  .shift-person p { font-size: 13px; }
  .shift-person p.muted { font-size: 12px; }
  .shift-block .shift-time { font-size: 12px; gap: 7px; padding: 10px; }
  .shift-remaining { padding-left: 8px; margin-left: 0; }
  .shift-time > .ico:last-child { display: none; }
  .btn.shift-action { grid-template-columns: 42px minmax(0, 1fr) 16px; gap: 11px; padding: 14px; font-size: 18px; }
  .action-ico { width: 42px; height: 42px; }
  .shift-action .action-help { font-size: 12px; }
}
@media (prefers-reduced-motion: reduce) {
  .mill-lamp, .mill-lamp::before { transition: none; }
}
/* На невысоком мониторе все три действия остаются в первом экране. */
@media (min-width: 1100px) and (max-height: 950px) {
  .topbar { padding-block: calc(14px + env(safe-area-inset-top)) 14px; }
  .mill-panel { padding: 20px 20px 12px; gap: 14px 0; }
  .mill-btn { min-height: 120px; }
  .shift-card { padding: 14px 18px 12px; }
  .shift-person { grid-template-columns: 64px minmax(0, 1fr); gap: 16px; }
  .shift-avatar { width: 64px; height: 68px; }
  .shift-person h2 { font-size: 22px; }
  .shift-person p { font-size: 13px; }
  .shift-block { gap: 10px; margin-top: 16px; }
  .shift-block .shift-time { margin-top: 10px; padding-block: 8px; }
  .btn.shift-action { min-height: 74px; padding: 11px 20px; }
}

/* Кнопка «Администратор» в шапке и связь с сервером точкой: текст статуса — только когда что-то не так */
.topbar .pill.admin.is-on { border-color: var(--focus); }
.save-status:not(.attention) .save-status-text { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }
.topbar .save-status:not(.attention) { flex: 0 0 12px; justify-content: center; }
@media (max-width: 600px) {
  .topbar .pill.admin { padding-inline: 12px; }
  .topbar .pill.admin .pill-text { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }
}

/* Раздел «Администратор» */
main:has(.adm-card) { max-width: 1100px; }
.adm-card { margin-top: 18px; padding: 18px 22px 20px; border-radius: 16px; background: var(--metal-card);
  border: 1px solid var(--metal-card-edge); box-shadow: inset 0 1px 0 var(--metal-card-glint), var(--metal-card-shadow); }
.adm-card > h2 { margin: 0 0 6px; font-size: 1.1em; }
.adm-note { margin: 10px 0 0; font-size: 0.8em; }
.adm-shift { display: grid; grid-template-columns: minmax(150px, 1fr) minmax(120px, 180px) minmax(120px, 180px);
  align-items: end; gap: 12px 16px; padding: 12px 0; border-bottom: 1px solid var(--metal-card-edge); }
.adm-shift-name { display: flex; align-items: center; gap: 10px; align-self: center; }
.adm-shift-name .muted { font-size: 0.8em; }
.adm-field { display: grid; gap: 6px; margin: 0; min-width: 0; }
.adm-field > span { font-size: 0.75em; color: var(--text-muted); }
.adm-field input, .adm-field select { width: 100%; min-height: 52px; margin: 0; padding: 8px 12px; font-size: 0.9em; }
.adm-field select { font: inherit; font-size: 0.9em; color: inherit; border-radius: 14px;
  border: 2px solid var(--border-strong); background: var(--surface-2); }
.adm-group { padding-top: 10px; }
.adm-group + .adm-group { margin-top: 8px; border-top: 1px solid var(--metal-card-edge); }
.adm-group-title { margin: 6px 0 4px; font-size: 0.9em; }
.adm-row { display: grid; grid-template-columns: minmax(0, 1fr) 150px 210px auto; align-items: end; gap: 10px 12px;
  padding: 10px 0; }
.adm-card > .adm-row { grid-template-columns: minmax(0, 1fr) 210px auto; }
.adm-del { min-height: 52px; margin: 0; padding: 8px 14px; font-size: 0.8em; }
.btn.adm-add { width: auto; min-height: 48px; margin-top: 8px; padding: 8px 18px; font-size: 0.85em; }
.adm-errors { margin-top: 16px; }
.adm-errors .error-text { margin: 4px 0; }
.adm-actions { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 18px; }
.adm-actions .btn { flex: 1 1 220px; margin: 0; }
@media (max-width: 760px) {
  .adm-card { padding: 14px; }
  .adm-shift { grid-template-columns: 1fr 1fr; }
  .adm-shift-name { grid-column: 1 / -1; }
  .adm-row, .adm-card > .adm-row { grid-template-columns: 1fr 1fr; padding: 12px 0; border-bottom: 1px dashed var(--metal-card-edge); }
  .adm-row .adm-grow { grid-column: 1 / -1; }
  .adm-card > .adm-row { grid-template-columns: 1fr; }
  .adm-del { grid-column: 1 / -1; }
  .adm-field input, .adm-field select { min-height: 48px; padding-inline: 10px; font-size: 0.8em; }
}

/* Пульт: прямоугольные клавиши во всю половину панели (владелец, 01.10.2026), табличка под клавишей */
.mill-btn { flex-direction: column; gap: 16px; padding: 8px clamp(10px, 3cqi, 30px); }
.mill-lamp { width: 100%; max-width: 400px; aspect-ratio: 4 / 3; border-radius: 18px; }
.mill-lamp::before { inset: 8%; border-radius: 10px;
  background: radial-gradient(ellipse 46% 24% at 30% 16%, var(--mill-glint), var(--mill-top) 40%, transparent 100%),
    linear-gradient(180deg, var(--mill-top), var(--mill-mid) 42%, var(--mill-bottom)); }
.mill-lamp::after { inset: -5px; border-radius: 22px; border: 3px solid var(--mill-mid);
  filter: drop-shadow(0 0 6px var(--mill-glow)); }
.mill-label { width: 100%; max-width: 400px; text-align: center; }
@media (max-width: 480px) {
  .mill-btn { padding: 6px 8px; gap: 12px; }
  .mill-lamp { border-radius: 14px; }
  .mill-lamp::after { border-radius: 18px; }
}
/* Объём клавиши: снизу видна боковая стенка (тень цвета клавиши), сверху фаска и блик.
   Горящая клавиша утоплена наполовину, при нажатии — до упора. Двигается только клавиша, рамка стоит */
.mill-btn.is-on .mill-lamp, .mill-btn:active .mill-lamp { transform: none; }
.mill-lamp::before { inset: 8% 8% 15% 8%;
  box-shadow: inset 0 2px 1px var(--metal-highlight), inset 0 -9px 12px var(--metal-shadow),
    inset 5px 0 6px -4px var(--metal-highlight), inset -5px 0 6px -4px var(--metal-shadow),
    0 11px 0 var(--mill-bottom), 0 12px 0 var(--mill-gap), 0 17px 14px var(--metal-shadow);
  transition: transform 110ms ease-out, box-shadow 110ms ease-out, filter 120ms ease-out; }
.mill-btn.is-on .mill-lamp::before { transform: translateY(5px);
  box-shadow: inset 0 2px 1px var(--metal-highlight), inset 0 -9px 12px var(--metal-shadow),
    inset 5px 0 6px -4px var(--metal-highlight), inset -5px 0 6px -4px var(--metal-shadow),
    0 6px 0 var(--mill-bottom), 0 7px 0 var(--mill-gap), 0 10px 18px var(--mill-glow); }
.mill-btn:active .mill-lamp::before { transform: translateY(9px);
  box-shadow: inset 0 4px 8px var(--metal-shadow), 0 2px 0 var(--mill-bottom), 0 3px 0 var(--mill-gap); }
@media (prefers-reduced-motion: reduce) { .mill-lamp::before { transition: none; } }
/* Светлая тема: пульт — светлый шлифованный металл, а не тёмный блок (владелец, 01.10.2026).
   Те же переменные переопределены только внутри пульта: шапка и тёмная тема не меняются */
:root[data-theme="light"] .mill-panel {
  --metal-panel-top: #f4f7fa; --metal-panel-bottom: #cdd6de; --metal-brush: rgba(70, 86, 102, 0.05);
  --metal-edge: #9ba8b4; --metal-highlight: rgba(255, 255, 255, 0.95); --metal-shadow: rgba(35, 50, 66, 0.26);
  --metal-plate: #e2e8ee; --metal-ink: #18232e; --metal-muted: #46525e; --mill-gap: #5f6c78; }
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) .mill-panel {
    --metal-panel-top: #f4f7fa; --metal-panel-bottom: #cdd6de; --metal-brush: rgba(70, 86, 102, 0.05);
    --metal-edge: #9ba8b4; --metal-highlight: rgba(255, 255, 255, 0.95); --metal-shadow: rgba(35, 50, 66, 0.26);
    --metal-plate: #e2e8ee; --metal-ink: #18232e; --metal-muted: #46525e; --mill-gap: #5f6c78; }
}
/* Без серебряной рамки: клавиша во всю площадь кнопки (владелец, 01.10.2026).
   Снизу 12 px под боковую стенку; подсветка горящей — кольцо по краю самой клавиши */
.mill-lamp { background: none; box-shadow: none; border-radius: 16px; }
.mill-lamp::before { inset: 0 0 12px 0; border-radius: 16px; }
.mill-lamp::after { inset: -6px -6px 6px -6px; border-radius: 21px; transition: transform 110ms ease-out; }
.mill-btn.is-on .mill-lamp::after { transform: translateY(5px); }
@media (max-width: 480px) {
  .mill-lamp, .mill-lamp::before { border-radius: 12px; }
  .mill-lamp::after { border-radius: 17px; }
}
/* «ОСТАНОВЛЕН» длиннее «РАБОТАЕТ»: на узком телефоне табличке нужны меньшие отступы */
@media (max-width: 480px) { .mill-label { padding-inline: 4px; letter-spacing: 0; } }
/* Во всю ширину монитора клавиши растут вместе с пультом (до 560 px) */
@media (min-width: 1400px) { .mill-lamp, .mill-label { max-width: 560px; } }
/* Клавиши — максимально большие (владелец, 01.10.2026): вся ширина своей половины пульта */
.mill-lamp, .mill-label { max-width: none; }
.mill-lamp { width: 100%; }
/* Показатели: цвета зон, как на шкале суток (владелец, 01.10.2026) */
.m-fill.z-work { background: var(--z-work); }
.m-fill.z-plan { background: var(--z-plan); }
.m-fill.z-unplanned { background: var(--z-unplanned); }
.m-fill.z-failure { background: var(--z-failure); }
.m-fill.neutral { background: var(--chart-axis); }
.chart .z-work { fill: var(--z-work); stroke: var(--z-work); }
.chart .z-plan { fill: var(--z-plan); stroke: var(--z-plan); }
.chart .z-unplanned { fill: var(--z-unplanned); stroke: var(--z-unplanned); }
.chart .z-failure { fill: var(--z-failure); stroke: var(--z-failure); }
.chart .ring.z-work, .chart .ring.z-plan, .chart .ring.z-unplanned, .chart .ring.z-failure { fill: none; }
/* Строки «Исправить запись» и «Что изменить?»: тот же класс, что у кнопок смены, но без значка —
   подпись сверху, значение под ней (без этого подпись падала в узкую колонку значка) */
.btn.shift-action:not(:has(> .action-ico)) { display: flex; flex-direction: column; align-items: flex-start;
  justify-content: center; gap: 4px; min-height: 72px; text-align: left; }
.btn.shift-action:not(:has(> .action-ico)) > .action-help { margin-top: 0; }
