/* Кабинет ЦехМетрики. Направление «Панель» (выбор Александра, 31.08.2026).
 * Шрифты системные: продукт ставится on-prem, интернета у заказчика может не быть,
 * а подключение к Google Fonts на изолированном контуре просто не откроется.
 */

:root {
  --paper:      oklch(97.5% 0.004 250);
  --card:       oklch(99.5% 0.002 250);
  --paper-2:    oklch(95%   0.006 250);
  --paper-3:    oklch(91.5% 0.008 250);
  --rule:       oklch(88%   0.009 250);
  --neutral:    oklch(54%   0.014 250);
  --muted:      oklch(38%   0.016 250);
  --ink:        oklch(19%   0.016 255);
  --accent:     oklch(52%   0.185 255);
  --accent-2:   oklch(92%   0.038 255);
  --chart-bar:  oklch(74%   0.105 255);
  --warn:       oklch(60%   0.120 62);
  --warn-2:     oklch(93%   0.038 62);
  --ok:         oklch(55%   0.115 150);
  --focus:      oklch(52%   0.185 255);
  --font-display: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-body:    system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-num:     ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  --radius: 6px;
  --radius-l: 10px;
  --rule-w: 1px;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { overflow-x: clip; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 400 15.5px/1.55 var(--font-body);
}
h1, h2, h3 { font-style: normal; margin: 0; text-wrap: balance; overflow-wrap: anywhere; }
p { margin: 0; }
ul, ol, dl { margin: 0; padding: 0; list-style: none; }
img, svg { max-width: 100%; }
button, select, input { font: inherit; color: inherit; }
button { cursor: pointer; }
:where(button, select, input, a):focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

/* ── каркас кабинета ─────────────────────────────── */

.shell { max-width: 1220px; margin: 0 auto; padding: 0 20px 56px; }

.top {
  position: sticky; top: 0; z-index: 30;
  background: var(--card);
  border-bottom: var(--rule-w) solid var(--rule);
  margin: 0 -20px 20px; padding: 0 20px;
}
.top__in {
  max-width: 1220px; margin: 0 auto;
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px 22px;
  min-height: 56px; padding: 8px 0;
}
.top__brand { display: flex; align-items: center; gap: 10px; font-weight: 600; font-size: 15.5px; white-space: nowrap; }
.top__mark {
  display: inline-grid; place-items: center; width: 28px; height: 28px;
  background: var(--accent); color: var(--card);
  border-radius: var(--radius); font-family: var(--font-num); font-size: 12px; font-weight: 600;
}
.steps { display: flex; gap: 4px; flex: 1 1 auto; min-width: 0; flex-wrap: wrap; }
.step {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 6px 12px; border-radius: 999px;
  font-size: 13.5px; color: var(--neutral); text-decoration: none;
  border: 1px solid transparent;
  transition: background 140ms cubic-bezier(0.22, 1, 0.36, 1);
}
.step:hover { background: var(--paper-2); }
.step__n {
  display: inline-grid; place-items: center; width: 19px; height: 19px;
  border: 1px solid var(--rule); border-radius: 50%;
  font-family: var(--font-num); font-size: 11px; color: var(--neutral);
}
.step.is-here { color: var(--accent); border-color: var(--accent); background: var(--card); }
.step.is-here .step__n { border-color: var(--accent); color: var(--accent); }
.step.is-off { opacity: 0.55; pointer-events: none; }
.top__reset {
  border: 0; background: none; color: var(--neutral);
  font-size: 12.5px; text-decoration: underline; text-underline-offset: 3px; white-space: nowrap;
}
.top__reset:hover { color: var(--muted); }

.demo-flag {
  font-size: 13px; line-height: 1.45; color: var(--muted);
  background: var(--card); border-left: 3px solid var(--accent);
  padding: 9px 14px; border-radius: 0 var(--radius) var(--radius) 0;
  margin-bottom: 22px;
}

.fineprint { font-size: 12.5px; line-height: 1.55; color: var(--neutral); max-width: 82ch; }
.fineprint + .fineprint { margin-top: 8px; }
.fineprint b { color: var(--muted); font-weight: 600; }
.foot { margin-top: 30px; padding-top: 18px; border-top: var(--rule-w) solid var(--rule); }

/* ── плитки/карточки ─────────────────────────────── */

.tile {
  background: var(--card);
  border: var(--rule-w) solid var(--rule);
  border-radius: var(--radius-l);
  padding: 16px 18px 18px;
  min-width: 0;
}
.tile__lbl {
  display: flex; justify-content: space-between; align-items: baseline; gap: 12px;
  font-family: var(--font-num); font-size: 11px;
  letter-spacing: 0.04em; text-transform: uppercase; color: var(--neutral);
  margin-bottom: 12px;
}

.btn {
  display: inline-flex; align-items: center; gap: 8px;
  border: 1px solid var(--accent); background: var(--accent); color: var(--card);
  padding: 9px 16px; border-radius: var(--radius);
  font-size: 14px; font-weight: 500; white-space: nowrap; text-decoration: none;
  transition: filter 140ms cubic-bezier(0.22, 1, 0.36, 1);
}
.btn:hover { filter: brightness(1.1); }
.btn:disabled { opacity: 0.45; cursor: default; filter: none; }
.btn--ghost { background: var(--card); color: var(--accent); }
.btn--ghost:hover { background: var(--accent-2); filter: none; }
.btn--warn { border-color: var(--rule); background: var(--card); color: var(--muted); }
.btn--warn:hover { border-color: var(--warn); color: var(--warn); filter: none; }

.chip {
  display: inline-block; padding: 2px 8px; border-radius: 999px;
  font-size: 11.5px; border: 1px solid var(--rule); color: var(--muted); white-space: nowrap;
}
.chip--w { border-color: var(--accent); color: var(--accent); }
.chip--r { border-color: var(--warn); color: oklch(45% 0.11 62); }
.chip--ok { border-color: var(--ok); color: var(--ok); }

/* ── экран «Материалы» ───────────────────────────── */

.mats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.mat { display: flex; gap: 14px; align-items: stretch; }
.mat__pic {
  flex: 0 0 148px; border-radius: var(--radius); overflow: hidden; line-height: 0;
  background: var(--paper-2); align-self: center; border: var(--rule-w) solid var(--rule);
}
.mat__pic img { display: block; width: 100%; aspect-ratio: 3 / 2; object-fit: cover; }
.mat__body { display: flex; flex-direction: column; gap: 4px; min-width: 0; flex: 1 1 auto; }
.mat__name { font-weight: 600; font-size: 15px; overflow-wrap: anywhere; }
.mat__meta { font-family: var(--font-num); font-size: 12px; color: var(--neutral); }
.mat__src { font-size: 12.5px; color: var(--neutral); }
.mat__row { margin-top: auto; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; padding-top: 8px; }
.mat--new {
  border-style: dashed; display: grid; place-items: center; text-align: center;
  color: var(--neutral); font-size: 14px; gap: 10px; padding: 26px 18px; cursor: pointer;
  transition: border-color 140ms cubic-bezier(0.22, 1, 0.36, 1), background 140ms cubic-bezier(0.22, 1, 0.36, 1);
}
.mat--new:hover { border-color: var(--accent); background: var(--accent-2); color: var(--accent); }
.mat--new b { font-size: 15px; color: var(--muted); }

/* ── экран «Зоны» ────────────────────────────────── */

.zgrid { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 14px; align-items: start; }
.zstage { position: relative; }
.zstage svg.zcanvas { display: block; width: 100%; height: auto; border-radius: var(--radius); cursor: crosshair; }
.zhint { margin-top: 10px; font-size: 12.5px; color: var(--neutral); }
.zlist { display: grid; gap: 10px; }
.zrow {
  border: var(--rule-w) solid var(--rule); border-radius: var(--radius);
  padding: 10px 12px; display: grid; gap: 8px; background: var(--card);
}
.zrow__head { display: flex; align-items: center; gap: 8px; }
.zrow__name { flex: 1 1 auto; min-width: 0; font-weight: 600; font-size: 14px; border: 0; background: transparent; padding: 2px 4px; border-radius: 4px; }
.zrow__name:hover, .zrow__name:focus { background: var(--paper-2); }
.zrow__del { border: 0; background: none; color: var(--neutral); font-size: 15px; padding: 2px 6px; border-radius: 4px; }
.zrow__del:hover { color: var(--warn); background: var(--warn-2); }
.zrow__opts { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; font-size: 12.5px; color: var(--neutral); }
.zrow__opts select {
  border: 1px solid var(--rule); border-radius: 4px; background: var(--card);
  padding: 3px 6px; font-size: 12.5px;
}
.zrow__helm { display: inline-flex; gap: 5px; align-items: center; cursor: pointer; }
.zempty { border: 1px dashed var(--rule); border-radius: var(--radius); padding: 18px; text-align: center; color: var(--neutral); font-size: 13.5px; }

/* прогресс-оверлей обработки */
.proc {
  position: fixed; inset: 0; z-index: 50; display: none;
  background: oklch(97.5% 0.004 250 / 0.92);
  place-items: center; padding: 20px;
}
.proc.is-on { display: grid; }
.proc__card {
  width: min(440px, 100%); background: var(--card);
  border: var(--rule-w) solid var(--rule); border-radius: var(--radius-l);
  padding: 26px 28px; display: grid; gap: 14px;
}
.proc__t { font-weight: 600; font-size: 17px; }
.proc__bar { height: 10px; background: var(--paper-3); border-radius: 5px; overflow: hidden; }
.proc__bar > i { display: block; height: 100%; width: 0%; background: var(--accent); border-radius: 5px; transition: width 300ms linear; }
.proc__meta { display: flex; justify-content: space-between; font-family: var(--font-num); font-size: 12.5px; color: var(--neutral); }
.proc__note { font-size: 12.5px; color: var(--neutral); }

/* ── экран «Отчёт» ───────────────────────────────── */

.bento { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 14px; }
.tile--kpi { grid-column: span 1; grid-row: span 2; }
.tile--frame { grid-column: span 2; grid-row: span 2; }
.tile--nums { grid-column: span 1; grid-row: span 2; }
.tile--zones { grid-column: span 2; }
.tile--strip { grid-column: span 4; }
.tile--ppe { grid-column: span 4; }

.kpi {
  font-family: var(--font-num); font-weight: 600;
  font-size: clamp(3rem, 6.5vw, 4.2rem); line-height: 0.92; letter-spacing: -0.04em;
  color: var(--accent); font-variant-numeric: tabular-nums;
}
.kpi span { font-size: 0.44em; }
.kpi__sub { margin-top: 8px; font-size: 13px; color: var(--muted); font-family: var(--font-num); }
.kpi__note { margin-top: 10px; font-size: 12.5px; color: var(--neutral); line-height: 1.5; }

.numlist { display: grid; gap: 9px; }
.numlist > div { display: flex; justify-content: space-between; gap: 12px; align-items: baseline; }
.numlist dt { font-size: 13.5px; color: var(--neutral); min-width: 0; }
.numlist dd { margin: 0; font-family: var(--font-num); font-weight: 600; font-size: 16px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.numlist dd.is-warn { color: var(--warn); }

.ztable { width: 100%; border-collapse: collapse; font-size: 14px; }
.ztable th { text-align: left; font-weight: 500; font-size: 12px; color: var(--neutral); padding: 0 0 8px; border-bottom: var(--rule-w) solid var(--rule); }
.ztable th:nth-child(n+3), .ztable td.num { text-align: right; }
.ztable td { padding: 9px 0; border-bottom: var(--rule-w) solid var(--paper-3); }
.ztable td.num { font-family: var(--font-num); font-variant-numeric: tabular-nums; font-weight: 500; }
.ztable tr:last-child td { border-bottom: 0; }

.framebox { background: var(--paper-2); border: var(--rule-w) solid var(--rule); border-radius: var(--radius); overflow: hidden; line-height: 0; }
.tile--frame .framebox { border: 0; }
.framebox__cap { margin-top: 10px; font-size: 12.5px; color: var(--neutral); line-height: 1.5; }

/* лента смены (рыночный паттерн: занятость + метки нарушений на одной оси) */
.strip__lane { position: relative; margin-top: 14px; }
.strip__bars { display: flex; gap: 3px; align-items: flex-end; height: 88px; }
.strip__bars > i {
  flex: 1 1 0; min-width: 0; height: var(--h);
  background: var(--chart-bar); border-top: 3px solid var(--accent);
  border-radius: 2px 2px 0 0;
}
.strip__marks { position: absolute; left: 0; right: 0; top: -10px; height: 0; }
.strip__mark {
  position: absolute; left: var(--x); transform: translateX(-50%);
  width: 0; height: 0; border-left: 6px solid transparent; border-right: 6px solid transparent;
  border-top: 8px solid var(--warn);
}
.strip__hours { display: flex; gap: 3px; margin-top: 6px; }
.strip__hours span { flex: 1 1 0; min-width: 0; text-align: center; font-family: var(--font-num); font-size: 11.5px; color: var(--neutral); }
.strip__vals { display: flex; gap: 3px; margin-bottom: 4px; }
.strip__vals span { flex: 1 1 0; min-width: 0; text-align: center; font-family: var(--font-num); font-size: 11px; color: var(--neutral); white-space: nowrap; }
.strip__cap { margin-top: 10px; font-size: 12.5px; color: var(--neutral); }
.strip__legend { display: inline-flex; gap: 12px; align-items: center; font-size: 12px; color: var(--neutral); text-transform: none; letter-spacing: 0; }
.lg { display: inline-block; width: 9px; height: 9px; border-radius: 2px; margin-right: 4px; vertical-align: -1px; }
.lg--busy { background: var(--chart-bar); }
.lg--ppe { background: var(--warn); }

.ppe__count { font-size: 15px; font-weight: 500; margin-bottom: 12px; }
.ppe-row { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.ppe {
  display: flex; gap: 12px; align-items: flex-start;
  border: var(--rule-w) solid var(--rule); border-radius: var(--radius); padding: 10px; min-width: 0;
}
.ppe__thumb { flex: 0 0 118px; border-radius: 4px; overflow: hidden; line-height: 0; background: var(--paper-2); }
.ppe__thumb--photo { aspect-ratio: 4 / 3; background-repeat: no-repeat; border: 2px solid var(--warn); }
.ppe__body { display: flex; flex-direction: column; gap: 3px; min-width: 0; font-size: 13px; }
.ppe__body b { font-family: var(--font-num); font-weight: 600; font-size: 14.5px; font-variant-numeric: tabular-nums; }
.ppe__d { color: var(--neutral); font-size: 12.5px; }
.ppe--empty { border-style: dashed; display: grid; place-items: center; color: var(--neutral); font-size: 13px; text-align: center; padding: 16px; }

/* ── схема кадра (общая) ─────────────────────────── */
.fb { display: block; width: 100%; height: auto; }
.fb-floor { fill: oklch(80% 0.006 250); }
.fb-persp path { stroke: oklch(72% 0.006 250); stroke-width: 1; fill: none; }
.z--work { fill: oklch(65% 0.16 255); fill-opacity: 0.22; stroke: oklch(80% 0.12 255); stroke-width: 3; }
.z--pass { fill: oklch(80% 0.01 250); fill-opacity: 0.16; stroke: oklch(92% 0.01 250); stroke-width: 3; stroke-dasharray: 12 8; }
.z--rest { fill: oklch(70% 0.14 70); fill-opacity: 0.20; stroke: oklch(82% 0.13 75); stroke-width: 3; stroke-dasharray: 12 8; }
.fb-zlabels text, .zone-label {
  font: 600 26px/1 var(--font-body); fill: #fff;
  paint-order: stroke; stroke: oklch(20% 0.03 255 / 0.85); stroke-width: 5px;
}
.fb-zvals text {
  font: 600 24px/1 var(--font-num); fill: #fff;
  paint-order: stroke; stroke: oklch(35% 0.12 255 / 0.9); stroke-width: 5px;
}
.fb-boxes .bx rect { fill: none; stroke: oklch(85% 0.09 190); stroke-width: 4; }
.fb-boxes .bx text {
  font: 600 22px/1 var(--font-num); fill: #fff;
  paint-order: stroke; stroke: oklch(20% 0.03 255 / 0.85); stroke-width: 5px;
}
.fb-boxes .bx--ppe rect { stroke: oklch(78% 0.15 70); stroke-width: 5; }
.fb-boxes .bx--ppe text { fill: oklch(90% 0.1 80); }
.tb { display: block; width: 100%; height: auto; }
.tb-floor { fill: oklch(78% 0.006 250); }
.tb-persp path { stroke: oklch(70% 0.006 250); stroke-width: 1; fill: none; }
.tb-zone { fill: var(--accent); fill-opacity: 0.12; stroke: var(--accent); stroke-width: 1.5; }
.tb-box rect, .tb-box circle { fill: none; stroke: var(--warn); stroke-width: 2.5; }

/* ── адаптив ─────────────────────────────────────── */
@media (max-width: 980px) {
  .mats { grid-template-columns: minmax(0, 1fr); }
  .tile--kpi, .tile--nums { grid-row: auto; }
  .zgrid { grid-template-columns: minmax(0, 1fr); }
  .bento { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .tile--frame, .tile--zones, .tile--strip, .tile--ppe { grid-column: span 2; }
  .tile--frame { grid-row: auto; }
  .ppe-row { grid-template-columns: minmax(0, 1fr); }
  .ppe--empty { display: none; }
}
@media (max-width: 620px) {
  .bento { grid-template-columns: minmax(0, 1fr); }
  .tile--frame, .tile--zones, .tile--strip, .tile--ppe, .tile--kpi, .tile--nums { grid-column: span 1; grid-row: span 2; }
  .strip__vals { display: none; }
  .strip__bars { height: 64px; }
  .mat { flex-wrap: wrap; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition-duration: 1ms !important; animation-duration: 1ms !important; }
}


/* ── добавлено в T-14: состояния живого кабинета ──────────────── */

.state { padding: 22px; text-align: center; color: var(--neutral); font-size: 14px; }
.state--error { color: var(--warn); }
.upload-error {
  margin-top: 10px; padding: 10px 12px; border-radius: var(--radius);
  background: var(--warn-2); color: var(--warn); font-size: 13.5px;
}
.upload-error:empty { display: none; }
.mat__pic--blank { background: var(--paper-3); }
.ppe__thumb--live {
  /* Пропорция и рамка — как у прототипной плашки: без aspect-ratio блок
     с фоновой картинкой получает нулевую высоту и кадр не виден. */
  aspect-ratio: 4 / 3; border: 2px solid var(--warn);
  background-size: cover; background-position: center; background-repeat: no-repeat;
}
.attribution { font-size: 12px; color: var(--neutral); }
.btn[disabled] { opacity: .5; cursor: default; }

/* Короткий ролик даёт одну-две корзины: без ограничения ширины столбик
   растягивается на всю ленту и читается как сплошная заливка. */
.strip__bars i, .strip__hours span, .strip__vals span { max-width: 96px; }
.strip__bars, .strip__hours, .strip__vals { justify-content: flex-start; }

/* Разметка поверх кадра не должна ловить мышь. Иначе первый клик пары рисует
   вершину прямо под курсором, второй попадает уже в неё, у двух кликов разные
   цели — и браузер не порождает dblclick. Зона переставала замыкаться. */
#zlayer, #zdraft, .zcanvas polygon, .zcanvas text, .zcanvas image { pointer-events: none; }

/* Индикаторы занятости. Без них загрузка большого файла и опрос списка выглядят
   как зависший интерфейс: браузер молчит, и человек жмёт кнопку второй раз. */
.spinner {
  display: inline-block;
  width: 13px; height: 13px;
  margin-right: 7px;
  vertical-align: -2px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: cm-spin .7s linear infinite;
}
@keyframes cm-spin { to { transform: rotate(360deg); } }

.is-busy { opacity: .75; cursor: progress; }

.uploading {
  position: fixed; inset: 0; z-index: 200;
  display: flex; align-items: center; justify-content: center;
  background: rgba(15, 23, 42, .45);
}
.uploading__box {
  min-width: 320px;
  padding: 22px 24px;
  border-radius: var(--radius, 12px);
  background: #fff;
  box-shadow: 0 18px 48px rgba(15, 23, 42, .25);
  text-align: center;
}
.uploading__label { font-size: 14px; margin-bottom: 14px; }
.uploading__track {
  height: 6px; border-radius: 3px; overflow: hidden;
  background: rgba(15, 23, 42, .1);
}
.uploading__track i {
  display: block; height: 100%; width: 0;
  background: var(--brand, #1d4ed8);
  transition: width .15s linear;
}
.uploading__pct {
  margin-top: 9px;
  font-family: var(--font-num, ui-monospace, monospace);
  font-size: 12.5px;
  color: var(--neutral, #64748b);
}

/* Скелет списка материалов: список опрашивает отчёт по каждому ролику, и на
   секунду-две пустая страница читается как поломка. */
.skeleton {
  height: 96px;
  border-radius: var(--radius, 12px);
  background: linear-gradient(90deg, rgba(15,23,42,.05) 25%, rgba(15,23,42,.09) 37%, rgba(15,23,42,.05) 63%);
  background-size: 400% 100%;
  animation: cm-shimmer 1.3s ease-in-out infinite;
}
@keyframes cm-shimmer { to { background-position: -135% 0; } }

