/* ==========================================================================
   Единый стиль сайта завода.
   Статусы везде одинаковые: зелёный — готово, жёлтый — в работе, серый — не начато.
   Анимации отключаются, если в системе включено «уменьшить движение».
   ========================================================================== */

@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url("fonts/inter-cyrillic.woff2") format("woff2");
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url("fonts/inter-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  --bg: #fafafa;
  --surface: #ffffff;
  --surface-2: #fafafa;
  --surface-3: #f4f4f5;
  --text: #18181b;
  --text-2: #3f3f46;
  --muted: #71717a;
  --line: #ececee;
  --line-strong: #dcdce0;

  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --accent-soft: #eef3fe;
  --accent-ring: rgba(37, 99, 235, .18);

  --sidebar: #ffffff;
  --sidebar-2: #ffffff;
  --sidebar-text: #52525b;
  --sidebar-hover: #f4f4f5;

  --ok: #15803d;      --ok-soft: #ecfdf3;     --ok-line: #86efac;
  --warn: #a16207;    --warn-soft: #fef9e7;   --warn-line: #facc15;
  --idle: #52525b;    --idle-soft: #f4f4f5;   --idle-line: #d4d4d8;
  --danger: #dc2626;  --danger-soft: #fef2f2; --danger-line: #fca5a5;
  --info: #2563eb;    --info-soft: #eef3fe;

  --radius-sm: 6px;
  --radius: 8px;
  --radius-lg: 12px;
  --gap: 16px;

  --shadow-xs: none;
  --shadow-sm: 0 1px 2px rgba(24, 24, 27, .04);
  --shadow-md: 0 8px 24px rgba(24, 24, 27, .06);
  --shadow-lg: 0 16px 48px rgba(24, 24, 27, .12);

  --ease: cubic-bezier(.22, 1, .36, 1);
  --ease-in-out: cubic-bezier(.65, 0, .35, 1);
  --t-fast: 180ms;
  --t: 280ms;

  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

/* ---------- Основа ---------- */
@view-transition { navigation: auto; }
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0; font: 14.5px/1.5 var(--font); background: var(--bg); color: var(--text);
  font-feature-settings: "cv11", "ss03"; -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
}
a { color: var(--accent); text-decoration: none; transition: color var(--t-fast); }
a:hover { color: var(--accent-hover); }
h1 { font-size: 22px; line-height: 1.25; font-weight: 600; letter-spacing: -.02em; margin: 0; }
h2 { font-size: 15px; font-weight: 600; letter-spacing: -.01em; margin: 0 0 12px; }
h3 { font-size: 14.5px; font-weight: 650; margin: 18px 0 8px; }
p { margin: 0 0 10px; }
b, strong { font-weight: 650; }
code { font: 12px/1.4 ui-monospace, "SF Mono", Consolas, monospace; background: var(--surface-3); padding: 2px 6px; border-radius: 5px; color: var(--text-2); }
::selection { background: var(--accent-soft); }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.danger-text { color: var(--danger); }
.ok-text { color: var(--ok); }
.nowrap { white-space: nowrap; }
.r { text-align: right; }
.c { text-align: center; }
* { scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent; }

/* ---------- Каркас: боковое меню + содержимое ---------- */
body.has-nav { display: grid; grid-template-columns: 248px minmax(0, 1fr); min-height: 100vh; }
.sidebar {
  background: var(--sidebar); color: var(--sidebar-text); border-right: 1px solid var(--line);
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; overflow-y: auto;
  scrollbar-color: var(--line-strong) transparent; view-transition-name: sidebar;
}
.sidebar-head { display: flex; align-items: center; justify-content: space-between; padding: 20px 20px 16px; }
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--text); font-weight: 650; font-size: 16px; letter-spacing: -.01em; }
.brand::before {
  content: ""; width: 10px; height: 10px; border-radius: 3px; flex: none; background: var(--accent);
}
.brand:hover { color: var(--text); }
.brand-wrap { display: grid; gap: 2px; min-width: 0; }
/* Вес вырезанного за сегодня / за месяц под словом «Завод» (cut_weight_summary). */
.brand-cut { padding-left: 20px; font-size: 12px; font-weight: 500; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.brand-cut:hover { color: var(--accent); text-decoration: none; }
.nav-toggle { display: none; background: none; border: 0; box-shadow: none; color: var(--text); font-size: 22px; cursor: pointer; padding: 4px 8px; border-radius: 8px; }
.nav-toggle:hover { background: var(--sidebar-hover); color: var(--text); }
.nav { flex: 1; padding: 4px 12px 12px; }
.nav-section { margin-bottom: 18px; }
.nav-title { font-size: 11.5px; font-weight: 500; letter-spacing: 0; color: #a1a1aa; padding: 6px 10px; }
.nav a {
  position: relative; display: flex; align-items: center; color: var(--sidebar-text); padding: 7px 10px; border-radius: 7px;
  font-size: 14px; font-weight: 450; transition: background var(--t-fast), color var(--t-fast), transform var(--t-fast);
}
.nav a:hover { background: var(--sidebar-hover); color: var(--text); }
.nav a:active { transform: scale(.98); }
.nav a.active { background: var(--surface-3); color: var(--text); font-weight: 550; }

.sidebar-user { border-top: 1px solid var(--line); padding: 14px 20px 18px; display: flex; flex-direction: column; gap: 2px; }
.sidebar-user a { color: var(--text); font-weight: 550; font-size: 14px; }
.sidebar-user a:hover { color: var(--accent); }
.sidebar-user .btn-link { color: var(--sidebar-text); padding: 0; font-size: 13px; }
.sidebar-user .btn-link:hover { color: var(--text); text-decoration: none; }

.main { padding: 32px 40px 64px; min-width: 0; max-width: 1440px; width: 100%; view-transition-name: main; }
body.no-nav { display: grid; place-items: start center; background: var(--bg); min-height: 100vh; }
body.no-nav .main { max-width: 420px; margin-top: 12vh; padding: 0 16px; }
body.no-nav .page-head { justify-content: center; margin-bottom: 20px; }
body.no-nav .page-head h1 { display: inline-flex; align-items: center; gap: 12px; }
body.no-nav .page-head h1::before {
  content: ""; width: 12px; height: 12px; border-radius: 3px; background: var(--accent);
}
body.no-nav .card { padding: 28px; }
body.no-nav button { width: 100%; justify-content: center; padding: 10px; margin-top: 4px; }
.page-head { display: flex; flex-wrap: wrap; gap: 12px 16px; align-items: center; justify-content: space-between; margin-bottom: 24px; }
.page-actions { display: flex; flex-wrap: wrap; gap: 8px; }

/* ---------- Карточки, сообщения ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 18px 20px; margin-bottom: var(--gap); box-shadow: var(--shadow-xs); }
.card > :last-child { margin-bottom: 0; }
.narrow { max-width: 460px; }
.grid { display: grid; gap: var(--gap); grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.flash {
  display: flex; align-items: center; gap: 10px; padding: 11px 16px; border-radius: var(--radius); margin-bottom: 14px;
  border: 1px solid transparent; font-weight: 450;
}
.flash::before { content: ""; width: 18px; height: 18px; flex: none; border-radius: 50%; background: center/12px no-repeat; }
.flash-float { position: fixed; top: 14px; left: 50%; transform: translateX(-50%); z-index: 60; max-width: min(640px, 92vw); box-shadow: var(--shadow-lg); cursor: pointer; animation: slide-down .25s var(--ease) both; }
.flash-ok { background: var(--ok-soft); color: #166534; }
.flash-ok::before { background-color: #16a34a; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M20 6 9 17l-5-5' fill='none' stroke='%23fff' stroke-width='3.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E"); }
.flash-err { background: var(--danger-soft); color: #991b1b; }
.flash-err::before { background-color: #dc2626; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 6v8m0 4h.01' fill='none' stroke='%23fff' stroke-width='3.5' stroke-linecap='round'/%3E%3C/svg%3E"); }
.notice { background: var(--warn-soft); color: #78350f; border: 0; padding: 11px 16px; border-radius: var(--radius); margin-bottom: 14px; }

/* ---------- Кнопки ---------- */
input, select, textarea, button { font: inherit; color: var(--text); }
button, .btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 36px; padding: 0 16px; border-radius: 8px;
  cursor: pointer; white-space: nowrap; font-weight: 500; font-size: 14px; letter-spacing: -.005em; text-decoration: none;
  border: 1px solid transparent; color: #fff;
  background: var(--accent); box-shadow: none;
  transition: background var(--t-fast), box-shadow var(--t-fast), transform var(--t-fast), border-color var(--t-fast), color var(--t-fast);
}
button:hover, .btn:hover { background: var(--accent-hover); color: #fff; text-decoration: none; }
button:active, .btn:active { transform: scale(.98); }
button:focus-visible, .btn:focus-visible, a:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--accent-ring); }
button:disabled { opacity: .5; cursor: default; transform: none; }
.btn-ghost, button.secondary {
  background: var(--surface); color: var(--text-2); border-color: var(--line-strong);
}
.btn-ghost:hover, button.secondary:hover { background: var(--surface-3); color: var(--text); border-color: var(--line-strong); }
.btn-ghost:active, button.secondary:active { box-shadow: none; }
button.danger, .btn-danger { background: var(--danger); }
button.danger:hover { background: #b91c1c; }
.btn-link, button.link {
  height: auto; background: none; border: 0; padding: 0; color: var(--accent); font-weight: 500; box-shadow: none; border-radius: 4px;
}
.btn-link:hover, button.link:hover { background: none; color: var(--accent-hover); box-shadow: none; }
.btn-link:active, button.link:active { transform: none; }
button.link.danger { color: var(--danger); background: none; box-shadow: none; }
.toolbar .btn, .toolbar button:not(.btn-link) { height: 34px; }

/* ---------- Формы ---------- */
input:not([type=checkbox]):not([type=radio]):not([type=file]), select, textarea {
  height: 36px; padding: 0 12px; border: 1px solid var(--line-strong); border-radius: 8px; background: #fff; min-width: 0;
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
}
textarea { height: auto; padding: 10px 12px; width: 100%; font: 13px/1.45 ui-monospace, "SF Mono", Consolas, monospace; margin-top: 6px; resize: vertical; }
select { padding-right: 32px; appearance: none; cursor: pointer;
  background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3E%3Cpath d='m6 8 4 4 4-4' fill='none' stroke='%2371717a' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") right 10px center/16px no-repeat; }
input:hover:not(:focus):not([type=checkbox]), select:hover:not(:focus), textarea:hover:not(:focus) { border-color: #c4c4ca; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-ring); }
input::placeholder, textarea::placeholder { color: #a1a1aa; }
input[type=checkbox] {
  appearance: none; width: 18px; height: 18px; margin: 0; border: 1.5px solid var(--line-strong); border-radius: 5px; background: #fff;
  vertical-align: middle; cursor: pointer; display: inline-grid; place-content: center; flex: none;
  transition: background var(--t-fast), border-color var(--t-fast), box-shadow var(--t-fast);
}
input[type=checkbox]::after {
  content: ""; width: 10px; height: 10px; transform: scale(0); transition: transform var(--t-fast) var(--ease);
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M20 6 9 17l-5-5' fill='none' stroke='%23fff' stroke-width='4' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center/contain no-repeat;
}
input[type=checkbox]:checked { background: var(--accent); border-color: var(--accent); }
input[type=checkbox]:checked::after { transform: scale(1); }
input[type=checkbox]:hover { border-color: var(--accent); }
input[type=checkbox]:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--accent-ring); }
input[type=checkbox]:disabled { opacity: .5; cursor: default; }
input[type=file] { font-size: 13.5px; }
input[type=file]::file-selector-button {
  height: 34px; padding: 0 14px; margin-right: 12px; border: 1px solid var(--line-strong); border-radius: 8px; background: var(--surface);
  color: var(--text-2); font: 500 13.5px var(--font); cursor: pointer; transition: background var(--t-fast);
}
input[type=file]::file-selector-button:hover { background: var(--surface-2); }
label { display: block; margin-bottom: 12px; color: var(--muted); font-size: 13px; font-weight: 500; }
label > input:not([type=checkbox]), label > select { display: block; width: 100%; margin-top: 6px; }
label.check { display: inline-flex; gap: 8px; align-items: center; margin: 0; color: var(--text-2); font-size: 14px; cursor: pointer; }
label.check input:not([type=checkbox]) { display: inline-block; width: auto; margin: 0; }
form.inline { display: inline-flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 4px 0; }
.toolbar { display: flex; flex-wrap: wrap; gap: 8px 14px; align-items: center; margin-bottom: 16px; }
.toolbar .spacer { flex: 1; }
.checks { display: flex; flex-wrap: wrap; gap: 8px 18px; margin-bottom: 12px; }

/* ---------- Таблицы ---------- */
.scroll { overflow-x: auto; border-radius: var(--radius); }
table { width: 100%; border-collapse: separate; border-spacing: 0; background: var(--surface); font-size: 14px; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
th {
  font-size: 12.5px; font-weight: 500; color: var(--muted);
  background: var(--surface); white-space: nowrap; vertical-align: middle;
}
td.r, th.r { text-align: right; font-variant-numeric: tabular-nums; }
td.c, th.c { text-align: center; }
tr:last-child td, tr:last-child th { border-bottom: 0; }
table tr td { transition: background var(--t-fast); }
table tr:hover td { background: var(--surface-2); }
tr:has(input.sel:checked) td { background: var(--accent-soft) !important; }
tr.inactive td { color: var(--muted); }
tr.row-done td { background: #f7fdf9; }
tr.row-taken td { background: #fffcf0; }
.card > table, .card > .scroll > table, .tree-body > .scroll > table, .tree-body > table { border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.card > .scroll, .tree-body > .scroll { border: 1px solid var(--line); }
.card > .scroll > table, .tree-body > .scroll > table { border: 0; }
table.matrix td.c { text-align: center; }
td input:not([type=checkbox]), td select { height: 32px; }

/* ---------- Метки, плашки, прогресс ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 6px; padding: 2px 10px 2px 8px; border-radius: 999px; font-size: 12.5px; font-weight: 500;
  font-variant-numeric: tabular-nums; white-space: nowrap; line-height: 20px; border: 0;
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .85; }
.badge-ok { background: var(--ok-soft); color: var(--ok); border-color: #bbf7d0; }
.badge-warn { background: var(--warn-soft); color: var(--warn); border-color: #fde68a; }
.badge-idle { background: var(--idle-soft); color: var(--idle); border-color: var(--line); }
.badge-info { background: var(--info-soft); color: var(--info); border-color: #c7d6ff; }
.badge-danger { background: var(--danger-soft); color: var(--danger); border-color: #fecaca; }
.tag { display: inline-block; font-size: 12px; font-weight: 600; background: var(--info-soft); color: var(--info); padding: 1px 8px; border-radius: 6px; white-space: nowrap; }
.chip {
  display: inline-flex; align-items: baseline; gap: 4px; background: var(--surface-3); border: 0; border-radius: 6px;
  padding: 1px 8px; margin: 2px 4px 2px 0; font-size: 12.5px; white-space: nowrap;
}
.progress { display: inline-flex; align-items: center; gap: 10px; }
.progress-bar { position: relative; display: inline-block; width: 120px; height: 6px; background: var(--surface-3); border-radius: 99px; overflow: hidden; }
.progress-bar i { display: block; height: 100%; border-radius: 99px; background: #22c55e; }
.progress b { font-variant-numeric: tabular-nums; min-width: 3em; text-align: right; font-size: 13px; color: var(--text-2); }
.util { font-size: 12px; font-weight: 700; padding: 1px 7px; border-radius: 6px; }
.util.hi { background: var(--ok-soft); color: var(--ok); }
.util.mid { background: var(--warn-soft); color: var(--warn); }
.util.lo { background: var(--danger-soft); color: var(--danger); }

/* ---------- Дерево (вложенные раскрывающиеся блоки) ---------- */
details.tree {
  position: relative; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); margin-bottom: 10px;
  box-shadow: var(--shadow-xs); transition: box-shadow var(--t), border-color var(--t);
}
details.tree::before {
  content: ""; position: absolute; left: -1px; top: 12px; bottom: 12px; width: 3px; border-radius: 0 4px 4px 0; background: var(--idle-line);
  transition: background var(--t);
}
details.tree.is-done::before { background: #22c55e; }
details.tree.is-work::before { background: #eab308; }
details.tree:hover { border-color: var(--line-strong); }
details.tree[open] { box-shadow: none; }
details.tree > summary {
  cursor: pointer; padding: 12px 16px 12px 20px; display: flex; flex-wrap: wrap; gap: 6px 16px; align-items: center; list-style: none;
  border-radius: var(--radius-lg); user-select: none; transition: background var(--t-fast);
}
details.tree > summary::-webkit-details-marker { display: none; }
details.tree > summary::before {
  content: ""; width: 18px; height: 18px; flex: none; margin-right: -6px; border-radius: 6px; background: transparent
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3E%3Cpath d='m8 5 5 5-5 5' fill='none' stroke='%23a1a1aa' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center/14px no-repeat;
  transition: transform var(--t) var(--ease), background-color var(--t-fast);
}
details.tree[open]:not(.closing) > summary::before { transform: rotate(90deg); background-color: var(--accent-soft); }
details.tree > summary:hover { background: var(--surface-2); }
details.tree > summary:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--accent-ring); }
details.tree[open] > summary { border-bottom-left-radius: 0; border-bottom-right-radius: 0; }
.tree-title { font-weight: 600; color: var(--text); letter-spacing: -.005em; }
.tree-body { padding: 4px 16px 8px 20px; border-top: 1px solid var(--line); }
.tree-body > :first-child { margin-top: 12px; }
.tree-body > table, .tree-body > .scroll { margin-bottom: 12px; }
.tree-extra { margin-left: auto; display: inline-flex; gap: 14px; align-items: center; font-size: 13.5px; }
details.tree details.tree { background: var(--surface); box-shadow: none; border-radius: var(--radius); }
details.tree details.tree > summary { border-radius: var(--radius); padding-top: 10px; padding-bottom: 10px; }
details.tree details.tree[open] { background: var(--surface); }
details.tree details.tree details.tree { background: var(--surface); }
.stats { display: inline-flex; flex-wrap: wrap; gap: 2px 16px; font-size: 13px; color: var(--muted); }
.stats b { color: var(--text-2); font-weight: 500; font-variant-numeric: tabular-nums; }

/* ---------- Панель действий над выбранными строками ---------- */
.actionbar {
  position: sticky; bottom: 16px; z-index: 5; display: flex; flex-wrap: wrap; gap: 10px; align-items: center; width: fit-content; max-width: 100%;
  margin: 12px auto 0; padding: 10px 12px 10px 18px; border-radius: 12px; color: var(--text-2);
  background: rgba(255, 255, 255, .9); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--line); box-shadow: var(--shadow-lg);
}
.actionbar b { color: var(--text); }
.actionbar label { display: inline-flex; gap: 6px; align-items: center; margin: 0; color: var(--text-2); font-size: 14px; }
.actionbar input:not([type=checkbox]) { width: 84px; }
.actionbar select { background-color: #fff; }



/* ---------- Диалоги и просмотр PDF ---------- */
dialog { border: 0; padding: 0; color: var(--text); }
dialog::backdrop { background: rgba(24, 24, 27, .35); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(3px); }
.dialog { border-radius: var(--radius-lg); padding: 22px 24px; width: min(440px, 94vw); box-shadow: var(--shadow-lg); }
.pdf-dialog { width: min(1100px, 96vw); height: 92vh; border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); overflow: hidden; }
.pdf-dialog[open] { display: flex; flex-direction: column; }
.pdf-dialog-head { display: flex; gap: 16px; align-items: center; padding: 12px 16px; border-bottom: 1px solid var(--line); background: var(--surface); }
.pdf-dialog-head b { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pdf-dialog-head .btn-link { font-size: 18px; color: var(--muted); width: 32px; height: 32px; border-radius: 8px; justify-content: center; }
.pdf-dialog-head .btn-link:hover { background: var(--surface-3); text-decoration: none; }
.pdf-dialog iframe { flex: 1; border: 0; width: 100%; background: #525659; }
.pdf-dialog iframe[hidden], .pdf-pages[hidden] { display: none; }
/* Телефоны: страницы PDF рисует pdf.js (встроенного просмотра PDF там нет). */
.pdf-pages { flex: 1; overflow: auto; background: #525659; padding: 8px; display: flex; flex-direction: column; align-items: center; gap: 8px; -webkit-overflow-scrolling: touch; }
.pdf-pages canvas { display: block; width: 100%; height: auto; background: #fff; box-shadow: 0 1px 4px rgba(0,0,0,.4); }
.pdf-pages .pdf-msg { color: #fff; margin: auto; text-align: center; padding: 16px; }

/* ---------- Сводные плитки ---------- */
.tiles { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); margin-bottom: 20px; }
.tile {
  position: relative; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 14px 16px 16px;
  box-shadow: var(--shadow-xs); overflow: hidden; transition: transform var(--t) var(--ease), box-shadow var(--t), border-color var(--t);
}
.tile span { display: block; font-size: 12.5px; font-weight: 450; color: var(--muted); margin-bottom: 4px; }
.tile b { font-size: 26px; font-weight: 600; letter-spacing: -.02em; font-variant-numeric: tabular-nums; line-height: 1.15; }
.tile b + span, .tile b ~ .muted { display: block; margin: 2px 0 0; font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
a.tile { color: inherit; }
a.tile:hover { text-decoration: none; border-color: var(--line-strong); background: var(--surface-2); }

/* ---------- Лазер: очередь ---------- */
.laser-queue { table-layout: fixed; min-width: 760px; }
.laser-queue col.lq-sheet { width: 25%; }
.laser-queue col.lq-size { width: 110px; }
.laser-queue col.lq-mass { width: 90px; }
.laser-queue col.lq-act { width: 330px; }
.laser-queue td { overflow-wrap: anywhere; }
.lq-form { display: flex; flex-wrap: nowrap; gap: 6px; align-items: center; margin: 0; }
.lq-form .btn, .lq-form button { height: 34px; padding: 0 12px; white-space: nowrap; }
.lq-who { font-size: 12px; color: var(--muted); margin-top: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- Детали по цехам: одна таблица, поиск по колонкам ---------- */
.parts-tiles .tile { display: block; height: auto; width: 100%; font: inherit; font-weight: 400; text-align: left; cursor: pointer; color: inherit; background: var(--surface); border: 1px solid var(--line); }
.parts-tiles .tile:active { transform: none; }
.parts-tiles .tile:hover { border-color: var(--line-strong); background: var(--surface-2); }
.parts-tiles .tile.active { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-ring); }
.parts-wrap { padding: 0; max-height: calc(100vh - 140px); overflow: auto; }
.parts-wrap > .parts-table { font-size: 13px; overflow: visible; border: 0; }
.parts-table th, .parts-table td { padding: 7px 8px; vertical-align: middle; }
.parts-table thead th { position: sticky; top: 0; z-index: 2; background: var(--surface-2); }
.parts-table thead tr.parts-filters th { top: 33px; padding: 4px 4px 6px; background: var(--surface-2); box-shadow: inset 0 -1px 0 var(--line); }
.parts-table .parts-filters input, .parts-table .parts-filters select { width: 100%; min-width: 64px; height: 30px; padding: 0 8px; font-size: 12.5px; }
.parts-table .parts-filters select { padding-right: 24px; background-position: right 6px center; }
.parts-table .parts-filters select[data-f="state"] { min-width: 112px; }
.parts-table .parts-filters input[data-f="part"] { min-width: 110px; }
.parts-table .parts-filters input[data-f="steel"], .parts-table .parts-filters input[data-f="total"] { min-width: 76px; }
.parts-empty { padding: 16px; }

/* ---------- Табель ---------- */
/* Страница табеля — на всю ширину экрана: дни месяца делят место поровну, без прокрутки вбок. */
.main:has(.ts-sheet) { max-width: none; padding-left: 24px; padding-right: 24px; }
.timesheet-wrap { border: 1px solid var(--line); box-shadow: var(--shadow-xs); }
table.timesheet { font-size: 12.5px; table-layout: fixed; min-width: 860px; }
table.timesheet col.ts-col-name { width: 150px; }
table.timesheet col.ts-col-hours { width: 54px; }
table.timesheet col.ts-col-sum { width: 76px; }
table.timesheet th, table.timesheet td { padding: 6px 1px; border-right: 1px solid var(--line); vertical-align: middle; }
table.timesheet th { text-transform: none; letter-spacing: 0; font-size: 12px; }
table.timesheet th.ts-day { font-size: 11.5px; line-height: 1.3; }
table.timesheet td.r, table.timesheet th.r { padding-right: 6px; }
table.timesheet .ts-name { position: sticky; left: 0; background: var(--surface); z-index: 1; padding-left: 10px; padding-right: 6px; box-shadow: 1px 0 0 var(--line);
  overflow: hidden; text-overflow: ellipsis; }
table.timesheet td.ts-name { white-space: nowrap; }
table.timesheet th.ts-name { background: var(--surface-2); }
.ts-cell { font-variant-numeric: tabular-nums; text-align: center; white-space: nowrap; }
.ts-cell[data-date] { cursor: pointer; }
.ts-cell[data-date]:hover { background: var(--accent-soft) !important; box-shadow: inset 0 0 0 2px var(--accent); }
.ts-weekend { background: #fafafa; color: var(--muted); }
.ts-has { background: var(--ok-soft) !important; color: #166534; font-weight: 600; }
.ts-multi { box-shadow: inset 0 0 0 2px #eab308; }
.ts-today { background: var(--accent-soft) !important; }
.ts-ot { font-size: 11.5px; color: var(--warn); }
.ts-salary { margin-top: 16px; }
.ts-salary-table td { vertical-align: middle; }
.ts-salary-table tr.ts-grand td { background: var(--surface-2); font-size: 14px; }
.ts-print-head, .ts-print-foot { display: none; }
@page ts { size: A4 landscape; margin: 6mm; }
@media print {
  .main:has(.ts-sheet) { padding: 0; }
  .main:has(.ts-sheet) .page-head { display: none; }
  .ts-sheet, .ts-salary { page: ts; }
  .ts-salary { break-before: page; margin: 0; }
  .ts-salary > h2 { display: none; }
  .ts-print-head { display: block; text-align: center; font-size: 15px; font-weight: 700; padding-bottom: 5px; margin-bottom: 8px; border-bottom: 2px solid #000; }
  .ts-print-head span { display: block; font-size: 12px; font-weight: 400; }
  .ts-print-foot { display: block; text-align: center; font-size: 8px; color: #555; margin-top: 6px; padding-top: 4px; border-top: 1px solid #ccc; }
  .timesheet-wrap { border: 0; }
  table.timesheet, .ts-salary-table { border-collapse: collapse; min-width: 0; font-size: 9px; border: 2px solid #000; }
  table.timesheet col.ts-col-name { width: 110px; }
  table.timesheet col.ts-col-hours { width: 40px; }
  table.timesheet col.ts-col-sum { width: 52px; }
  table.timesheet th, table.timesheet td, .ts-salary-table th, .ts-salary-table td { border: 1px solid #000; padding: 2px 2px; font-size: 9px; box-shadow: none; }
  .ts-salary-table th, .ts-salary-table td { padding: 3px 6px; font-size: 10px; }
  table.timesheet .ts-name { position: static; }
  table.timesheet td.ts-name a { color: #000; }
  table.timesheet th, .ts-salary-table th { background: #f0f0f0 !important; }
  .ts-has { background: #e8f5e9 !important; color: #000; }
  .ts-weekend { background: #ffebee !important; }
  .ts-today { background: inherit !important; }
  .ts-multi { box-shadow: none; }
  .ts-ot { color: #000; font-size: 8px; }
  .ts-salary-table tr.ts-grand td { background: #e8f5e9 !important; font-size: 11px; border-top: 2px solid #000; }
  table.timesheet td.ts-name .small, .ts-salary-table .small, .ts-salary-table .tag { font-size: 8px; padding: 0; background: none; color: #555; }
  .ts-cell[data-date]:hover { background: inherit !important; box-shadow: none; }
  .timesheet *, .ts-salary-table * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  table.timesheet tr, .ts-salary-table tr { break-inside: avoid; }
}

/* ---------- Техкарта и тара ---------- */
.tara-row { display: flex; flex-wrap: wrap; gap: 4px 12px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line); }
.tara-row:last-child { border-bottom: 0; }
.tree-title .badge { font-size: 12px; margin-left: 4px; }
.tree-title input[type=checkbox] { margin-right: 6px; }
.extra-link { color: #b45309; font-weight: 600; }
.extra-link:hover { color: #92400e; }

/* ---------- Меню: пункт с невыполненным мигает красным ---------- */
.nav a.nav-alert { color: var(--danger); }
.nav a.nav-alert::after { content: ""; margin-left: auto; width: 8px; height: 8px; border-radius: 50%; background: var(--danger); flex: none; }
@media (prefers-reduced-motion: no-preference) {
  .nav a.nav-alert { animation: nav-blink 1.6s var(--ease-in-out) infinite; }
  .nav a.nav-alert::after { animation: nav-dot 1.6s var(--ease-in-out) infinite; }
}
@keyframes nav-blink { 50% { color: #f87171; background: var(--danger-soft); } }
@keyframes nav-dot { 50% { transform: scale(1.5); opacity: .45; } }

/* Кнопка (цех, заказ, задание), где есть невыполненное: красная мигающая точка в углу */
.btn.has-alert { position: relative; }
.btn.has-alert::after {
  content: ""; position: absolute; top: -3px; right: -3px; width: 10px; height: 10px; border-radius: 50%;
  background: var(--danger); box-shadow: 0 0 0 2px var(--bg);
}
@media (prefers-reduced-motion: no-preference) {
  .btn.has-alert::after { animation: nav-dot 1.6s var(--ease-in-out) infinite; }
}

/* Та же точка внутри строки (тара в дереве) */
.alert-dot { display: inline-block; width: 9px; height: 9px; margin: 0 2px 1px 4px; border-radius: 50%; background: var(--danger); vertical-align: middle; }
@media (prefers-reduced-motion: no-preference) {
  .alert-dot { animation: nav-dot 1.6s var(--ease-in-out) infinite; }
}

/* ---------- Чат ---------- */
.nav a .nav-count { margin-left: auto; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 99px; background: #ef4444; color: #fff;
  font-size: 11.5px; font-weight: 600; display: inline-grid; place-items: center; }
.chat { display: grid; grid-template-columns: 320px minmax(0, 1fr); height: calc(100vh - 140px); min-height: 460px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); overflow: hidden; }
.chat-list { display: flex; flex-direction: column; border-right: 1px solid var(--line); background: var(--surface-2); min-height: 0; }
.chat-list-head { display: flex; flex-wrap: wrap; gap: 8px; padding: 12px; border-bottom: 1px solid var(--line); }
.chat-list-head input { flex: 1 1 100%; }
.chat-list-head button { flex: 1; height: 32px; font-size: 13px; padding: 0 10px; }
.chat-items { flex: 1; overflow-y: auto; padding: 6px; }
.chat-list-empty { padding: 16px 10px; }
.chat-section { font-size: 11.5px; font-weight: 500; color: var(--muted); padding: 10px 10px 4px; }
.chat-item { all: unset; box-sizing: border-box; display: flex; gap: 10px; align-items: center; width: 100%; padding: 9px 10px; border-radius: 10px; cursor: pointer;
  transition: background var(--t-fast); }
.chat-item:hover { background: var(--surface-3); }
.chat-item.active { background: var(--accent-soft); }
.chat-item:focus-visible { box-shadow: 0 0 0 3px var(--accent-ring); }
.chat-item-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.chat-item-top, .chat-item-bottom { display: flex; gap: 8px; align-items: center; min-width: 0; }
.chat-item-top b { flex: 1; font-weight: 600; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-item.has-unread .chat-item-top b { font-weight: 700; }
.chat-item-time { font-size: 11.5px; color: var(--muted); flex: none; }
.chat-item-text { flex: 1; font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-item.has-unread .chat-item-text { color: var(--text-2); }
.chat-unread { flex: none; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 99px; background: var(--accent); color: #fff; font-size: 11.5px; font-weight: 700; display: inline-grid; place-items: center; }
.chat-notify-btn { margin: 8px 12px 12px; font-size: 13px; }
.avatar { flex: none; width: 36px; height: 36px; border-radius: 50%; display: inline-grid; place-items: center; color: #fff; font-size: 13px; font-weight: 700;
  letter-spacing: .02em; }
.avatar-channel { background: var(--accent); border-radius: 10px; font-size: 16px; }
.avatar-gap { flex: none; width: 36px; }

.chat-main { position: relative; display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--surface); }
.chat-empty { margin: auto; text-align: center; color: var(--muted); }
.chat-empty-icon { font-size: 44px; margin-bottom: 6px; opacity: .7; }
.chat-head { display: flex; align-items: center; gap: 12px; padding: 12px 18px; border-bottom: 1px solid var(--line); background: rgba(255,255,255,.92); backdrop-filter: blur(6px); }
.chat-head-title { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.chat-head-title b { font-size: 15.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-back { display: none; font-size: 22px; }
.chat-messages { flex: 1; overflow-y: auto; padding: 16px 18px 8px; display: flex; flex-direction: column; gap: 2px; }
.chat-day { align-self: center; margin: 14px 0 8px; padding: 3px 12px; border-radius: 99px; background: var(--surface-3); color: var(--muted); font-size: 12px; font-weight: 600; }
.chat-system { align-self: center; margin: 6px 0; font-size: 12.5px; color: var(--muted); font-style: italic; text-align: center; }
.msg { display: flex; align-items: flex-end; gap: 8px; margin-top: 8px; max-width: 78%; }
.msg.grouped { margin-top: 2px; }
.msg.mine { align-self: flex-end; flex-direction: row-reverse; }
.bubble { position: relative; padding: 7px 12px 6px; border-radius: 16px 16px 16px 6px; background: var(--surface-3); border: 1px solid transparent;
  box-shadow: var(--shadow-xs); min-width: 60px; }
.msg.grouped .bubble { border-radius: 16px 16px 16px 6px; }
.msg.mine .bubble { background: var(--accent); color: #fff; border-color: transparent; border-radius: 16px 16px 6px 16px; }
.msg-author { font-size: 12.5px; font-weight: 650; margin-bottom: 1px; }
.msg-text { white-space: pre-wrap; word-break: break-word; font-size: 14.5px; line-height: 1.45; }
.msg.mine .msg-text a { color: #fff; text-decoration: underline; }
.msg-time { float: right; margin: 4px 0 -2px 10px; font-size: 11px; color: var(--muted); }
.msg.mine .msg-time { color: rgba(255,255,255,.75); }
.msg.deleted .msg-text { font-style: italic; opacity: .7; }
.msg-del { position: absolute; top: -8px; right: -8px; width: 22px; height: 22px; padding: 0; border-radius: 50%; font-size: 11px;
  background: var(--surface); color: var(--muted); border: 1px solid var(--line); box-shadow: var(--shadow-sm); opacity: 0; transition: opacity var(--t-fast); }
.msg-del:hover { background: var(--danger-soft); color: var(--danger); }
.msg:hover .msg-del, .msg-del:focus-visible { opacity: 1; }
.chat-compose { display: flex; gap: 10px; align-items: flex-end; padding: 12px 16px 14px; border-top: 1px solid var(--line); background: var(--surface); }
.chat-compose textarea { flex: 1; margin: 0; max-height: 180px; min-height: 40px; font: 14.5px/1.45 var(--font); padding: 9px 14px; border-radius: 20px; resize: none; }
.chat-compose button { width: 40px; height: 40px; padding: 0; border-radius: 50%; font-size: 16px; flex: none; }
.chat-new-pill { position: absolute; left: 50%; bottom: 80px; transform: translateX(-50%); height: 32px; border-radius: 99px; font-size: 13px; box-shadow: var(--shadow-md); }
.pick-list { max-height: 46vh; overflow-y: auto; margin-top: 8px; display: flex; flex-direction: column; gap: 2px; }
.pick-item { all: unset; box-sizing: border-box; display: flex; align-items: center; gap: 10px; padding: 7px 8px; border-radius: 10px; cursor: pointer; margin: 0; color: var(--text); }
.pick-item:hover { background: var(--surface-2); }
.pick-text { display: flex; flex-direction: column; }
.pick-text b { font-weight: 600; font-size: 14px; }

.toasts { position: fixed; right: 18px; bottom: 18px; z-index: 50; display: flex; flex-direction: column; gap: 10px; width: min(360px, calc(100vw - 36px)); pointer-events: none; }
.toast { pointer-events: auto; display: grid; gap: 1px; padding: 12px 14px 12px 52px; border-radius: 14px; color: var(--text); text-decoration: none;
  background: rgba(255,255,255,.97); border: 1px solid var(--line); box-shadow: var(--shadow-lg); position: relative; backdrop-filter: blur(8px); }
.toast::before { content: "💬"; position: absolute; left: 14px; top: 12px; width: 28px; height: 28px; display: grid; place-items: center; border-radius: 9px; background: var(--accent-soft); font-size: 15px; }
.toast:hover { text-decoration: none; color: var(--text); border-color: #c7d6ff; }
.toast b { font-size: 14px; }
.toast-who { font-size: 12px; color: var(--muted); }
.toast-text { font-size: 13.5px; color: var(--text-2); overflow: hidden; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; }

@media (prefers-reduced-motion: no-preference) {
  .msg.is-new, .chat-messages > .is-new { animation: msg-in 260ms var(--ease) both; }
  .toast { animation: toast-in 320ms var(--ease) both; }
  .toast.is-leaving { animation: toast-out 380ms var(--ease-in-out) forwards; }
  .chat-new-pill { animation: slide-up 220ms var(--ease) both; }
}
@keyframes msg-in { from { opacity: 0; transform: translateY(8px) scale(.98); } }
@keyframes toast-in { from { opacity: 0; transform: translateX(24px) scale(.97); } }
@keyframes toast-out { to { opacity: 0; transform: translateX(24px); } }

@media (max-width: 900px) {
  .chat { grid-template-columns: 1fr; height: calc(100vh - 150px); }
  .chat-main { display: none; }
  .chat.show-main .chat-list { display: none; }
  .chat.show-main .chat-main { display: flex; }
  .chat-back { display: inline-flex; }
  .msg { max-width: 92%; }
  .toasts { right: 10px; left: 10px; bottom: 10px; width: auto; }
}

/* ---------- Заготовки при загрузке ---------- */
.skeleton { height: 14px; margin: 10px 0; border-radius: 6px; background: linear-gradient(90deg, var(--surface-3) 0%, #ececee 40%, var(--surface-3) 80%); background-size: 300% 100%; }
.skeleton:nth-child(2) { width: 85%; } .skeleton:nth-child(3) { width: 60%; }

/* ---------- Анимации ---------- */
@media (prefers-reduced-motion: no-preference) {
  ::view-transition-old(main) { animation: vt-out 120ms var(--ease-in-out) both; }
  ::view-transition-new(main) { animation: vt-in 200ms var(--ease) both; }
  ::view-transition-old(root), ::view-transition-new(root) { animation: none; }
  .flash { animation: slide-down 320ms var(--ease) both; }
  .flash.is-leaving { animation: fade-out 400ms var(--ease-in-out) forwards; }
  .actionbar:not([hidden]) { animation: slide-up 260ms var(--ease) both; }
  .progress-bar i { animation: grow 900ms var(--ease) both; transform-origin: left; }
  dialog[open] { animation: pop-in 200ms var(--ease) both; }
  dialog[open]::backdrop { animation: fade-in 200ms ease both; }
  .skeleton { animation: shimmer 1.2s linear infinite; }
  .tiles .tile { animation: rise 360ms var(--ease) both; }
  .tiles .tile:nth-child(2) { animation-delay: 40ms; } .tiles .tile:nth-child(3) { animation-delay: 80ms; }
  .tiles .tile:nth-child(4) { animation-delay: 120ms; } .tiles .tile:nth-child(5) { animation-delay: 160ms; }
  .tree-body.is-loaded > * { animation: fade-in 260ms ease both; }
}
@keyframes vt-out { to { opacity: 0; } }
@keyframes vt-in { from { opacity: 0; transform: translateY(4px); } }
@keyframes slide-down { from { opacity: 0; transform: translateY(-8px); } }
@keyframes slide-up { from { opacity: 0; transform: translateY(14px) scale(.98); } }
@keyframes fade-in { from { opacity: 0; } }
@keyframes fade-out { to { opacity: 0; transform: translateY(-6px); height: 0; padding-top: 0; padding-bottom: 0; margin-bottom: 0; border-width: 0; } }
@keyframes grow { from { transform: scaleX(0); } }
@keyframes pop-in { from { opacity: 0; transform: translateY(8px) scale(.97); } }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } }
@keyframes shimmer { from { background-position: 100% 0; } to { background-position: -100% 0; } }

/* ---------- Отчёт по заготовке: строки итогов как в старом отчёте ---------- */
.report-period { margin: -12px 0 16px; color: var(--text-2); }
table.report-table td { vertical-align: middle; }
table.report-table tr.sub-order td { background: #f3f7ff; font-weight: 600; }
table.report-table tr.sub-shop td { background: var(--ok-soft); font-weight: 600; }
table.report-table tr.sub-workplace td { background: var(--warn-soft); font-weight: 600; }
table.report-table tr.sub-total td { background: var(--danger-soft); font-weight: 700; }
table.report-table tr:hover td { filter: brightness(.985); }

/* ---------- Печать ---------- */
.print-warning { text-align: center; margin: 12px 0; }
.signatures { display: flex; justify-content: space-between; gap: 24px; margin-top: 32px; }
@media print {
  body, body.has-nav { display: block; background: #fff; font-size: 12px; }
  .sidebar, .page-actions, .flash, .pdf-dialog, .actionbar, .no-print, .toasts { display: none !important; }
  .page-head { justify-content: center; margin-bottom: 4px; }
  .report-period { text-align: center; margin: 0 0 12px; }
  .report h2 { text-align: center; }
  table.report-table { border-collapse: collapse; }
  table.report-table th, table.report-table td { border: 1px solid #000; padding: 5px 8px; }
  table.report-table tr.sub-order td, table.report-table tr.sub-shop td, table.report-table tr.sub-workplace td, table.report-table tr.sub-total td {
    background: #e5e5e5 !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  table.report-table tr.sub-total td { background: #ccc !important; }
  .scroll { overflow: visible; }
  .main { padding: 0; max-width: none; }
  .card { border: 0; padding: 0; box-shadow: none; }
  table { font-size: 12px; }
  th { background: none; }
  tr.row-done td, tr.row-taken td { background: none; }
  .tile { box-shadow: none; }
}

/* ---------- Линейный раскрой ---------- */
.cut-fields { display: grid; gap: 0 var(--gap); grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); margin-bottom: 8px; }
.cut-fields label:first-child { grid-column: span 2; }
.cut-table-wrap { border: 1px solid var(--line); max-height: 60vh; overflow-y: auto; }
.cut-table th { position: sticky; top: 0; z-index: 1; }
.cut-table td { padding: 4px 6px; vertical-align: middle; }
.cut-table td:first-child { width: 44px; }
.cut-table td:nth-child(2) { width: 150px; }
.cut-table td:nth-child(3) { width: 130px; }
.cut-table td:last-child { width: 40px; }
.cut-table input:not([type=checkbox]) { width: 100%; height: 32px; }
.cut-table input.bad:not([type=checkbox]) { border-color: var(--danger); background: var(--danger-soft); }
.cut-table .cut-del { color: var(--muted); font-size: 14px; }
.cut-table .cut-del:hover { color: var(--danger); }
.cut-table tr:last-child .cut-del { visibility: hidden; }
button.cut-submit { height: 40px; padding: 0 28px; font-size: 15px; }
.cut-wait { display: flex; align-items: center; gap: 14px; }
.cut-wait span:nth-child(2) { flex: 1; }
.cut-spinner { width: 20px; height: 20px; border-radius: 50%; border: 2.5px solid var(--accent-soft); border-top-color: var(--accent); animation: cut-spin .8s linear infinite; }
@keyframes cut-spin { to { transform: rotate(360deg); } }
#cutResult > * { animation: rise .35s var(--ease) both; }
.cut-title { text-align: center; font-size: 17px; margin: 4px 0 16px; }
.cut-map td { vertical-align: middle; }
.cut-parts { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.cut-bar { display: flex; height: 14px; border-radius: 4px; overflow: hidden; min-width: 220px;
  background: repeating-linear-gradient(135deg, var(--surface-3) 0 6px, var(--line-strong) 6px 7px); }
.cut-bar i { background: #93b4f5; border-right: 2px solid var(--surface); }
.cut-bar i:nth-child(even) { background: #b8cdf8; }
tr.cut-last td { background: var(--ok-soft); }
table.cut-report, .cut-plan > .scroll { max-width: 560px; }
table.cut-report td:first-child { color: var(--muted); }
@media print {
  #cutResult > * { animation: none; }
  .cut-map th, .cut-map td, .cut-plan th, .cut-plan td, table.cut-report td { border: 1px solid #000; padding: 4px 6px; }
  .cut-map table, .cut-plan table { border-collapse: collapse; }
  .cut-bar, .cut-bar i, tr.cut-last td { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .cut-map tr { break-inside: avoid; }
}

/* ---------- Слои DXF ---------- */
.dxf-drop { position: relative; display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 36px 16px; margin: 0;
  border: 2px dashed var(--line-strong); border-radius: var(--radius-lg); text-align: center; cursor: pointer; color: var(--text-2);
  transition: border-color var(--t-fast), background var(--t-fast); }
.dxf-drop:hover, .dxf-drop.over { border-color: var(--accent); background: var(--accent-soft); }
.dxf-drop input[type=file] { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.dxf-drop b { font-size: 15px; color: var(--text); }
.dxf-picked { font-weight: 600; color: var(--accent); }
.dxf-progress { display: flex; align-items: center; gap: 12px; margin-top: 14px; font-size: 13.5px; color: var(--text-2); }
.dxf-progress .progress-bar { flex: 1; width: auto; max-width: 480px; height: 8px; }
.dxf-progress .progress-bar i { transition: width .3s var(--ease); }
.dxf-layers td { vertical-align: middle; }
.dxf-layers td:first-child { width: 36px; }
.dxf-layer { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; margin: 0; color: var(--text); font-size: 14px; font-weight: 500; cursor: pointer; }
.dxf-layer i { width: 12px; height: 12px; border-radius: 3px; flex: none; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .15); }

/* ---------- Телефон и планшет ---------- */
@media (max-width: 900px) {
  body.has-nav { display: block; }
  .sidebar { position: sticky; height: auto; z-index: 20; border-right: 0; border-bottom: 1px solid var(--line); }
  .sidebar-head { padding: 12px 16px; }
  .nav-toggle { display: block; }
  .nav, .sidebar-user { display: none; }
  body.nav-open .nav { display: block; max-height: 70vh; overflow-y: auto; }
  body.nav-open .sidebar-user { display: flex; }
  .main { padding: 18px 14px 48px; }
  h1 { font-size: 20px; }
  .tree-body { padding-left: 12px; padding-right: 12px; }
  details.tree > summary { padding-left: 16px; }
  .progress-bar { width: 70px; }
  .tree-extra { margin-left: 0; }
  .tile b { font-size: 22px; }
  .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .actionbar { bottom: 10px; }
  .cut-fields label:first-child { grid-column: auto; }
  .cut-table { table-layout: fixed; }
  .cut-table :is(td, th):first-child { width: 30px; padding: 4px 2px; }
  .cut-table :is(td, th):nth-child(2) { width: 84px; }
  .cut-table :is(td, th):nth-child(3) { width: 68px; }
  .cut-table :is(td, th):last-child { width: 28px; padding: 4px 2px; }
}

/* Сверка DXF */
.dxfc-help p { margin: 0 0 8px; }
.dxfc-help p:last-child { margin: 0; }
.dxfc-filter { display: inline-flex; flex-wrap: wrap; gap: 4px 10px; align-items: center; }
.dxfc-filter button.link { padding: 2px 4px; border-radius: 8px; opacity: .65; }
.dxfc-filter button.link.is-active { opacity: 1; box-shadow: 0 0 0 2px var(--accent-ring); }
.dxfc-pair > details.tree { margin-top: 10px; }
.dxfc-list { margin: 0 0 10px; padding-left: 20px; }
.dxfc-list li { margin: 3px 0; }
.dxfc-list.bad li { color: var(--danger); }
.dxfc-pics { display: flex; flex-wrap: wrap; gap: 16px; margin: 6px 0 12px; }
.dxfc-pics figure { margin: 0; flex: 1 1 320px; max-width: 640px; }
.dxfc-pics img { display: block; width: 100%; max-height: 460px; object-fit: contain; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); }
.dxfc-pics figcaption { font-size: 12.5px; color: var(--text-2); margin-top: 4px; }
.dxfc-key { display: inline-block; width: 22px; height: 0; vertical-align: middle; margin: 0 2px 0 8px; border-top: 3px solid; }
.dxfc-key.p { border-top: 6px solid #7cc4fa; }
.dxfc-key.d { border-color: #1f2937; border-top-width: 2px; }
.dxfc-key.m { border-color: #dc2626; }
.dxfc-key.x { border-color: #f59e0b; border-top-style: dashed; }

/* ---------- Раскрой листового металла ---------- */
.sn-lists { display: grid; gap: 0 var(--gap); grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); margin-top: 16px; }
.sn-lists .small { display: block; margin-top: 4px; font-weight: 400; }
.sn-relist { margin-top: 14px; align-items: end; }
.sn-relist > div { margin-bottom: 12px; }
.sn-parts { max-height: 60vh; overflow-y: auto; }
.sn-parts th { position: sticky; top: 0; z-index: 1; }
.sn-fields { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
.sn-fields label:first-child { grid-column: auto; }
#snSettings label.check { display: flex; margin: 0 0 8px; }
.sn-sum { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.sn-sum > div { display: flex; flex-direction: column; gap: 2px; padding: 10px 12px; background: var(--surface-2); border-radius: var(--radius); }
.sn-sum span { font-size: 12.5px; color: var(--muted); }
.sn-sum b { font-size: 18px; font-weight: 600; font-variant-numeric: tabular-nums; }
.sn-sum small { font-size: 12.5px; color: var(--text-2); }
.sn-map { display: grid; gap: 16px; grid-template-columns: minmax(0, 1fr) 260px; align-items: start; margin: 6px 0 12px; }
.sn-map img { display: block; width: 100%; max-height: 70vh; object-fit: contain; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); }
.sn-map .scroll { max-height: 70vh; overflow-y: auto; }
@media (max-width: 760px) { .sn-map { grid-template-columns: 1fr; } }

/* Загрузка сервера (значок в меню, только администраторам) */
.srv { margin-left: auto; margin-right: 4px; }
.srv-badge { display: inline-flex; align-items: center; gap: 6px; padding: 3px 9px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); box-shadow: none; color: var(--text-2); font-size: 12px; font-weight: 550; font-variant-numeric: tabular-nums; cursor: pointer; }
.srv-badge:hover { background: var(--surface-3); color: var(--text); }
.srv-badge i { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); transition: background .3s; }
.srv-badge.ok i { background: var(--ok); }
.srv-badge.warn i { background: var(--warn-line); }
.srv-badge.bad i { background: var(--danger); }
.srv-panel { position: fixed; z-index: 70; width: 290px; max-width: calc(100vw - 32px); padding: 14px 16px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow-lg); font-size: 13px; color: var(--text-2); }
.srv-panel b { color: var(--text); font-weight: 600; }
.srv-row { display: flex; justify-content: space-between; gap: 12px; margin-bottom: 6px; }
.srv-bar { height: 6px; border-radius: 3px; background: var(--surface-3); overflow: hidden; margin: -2px 0 10px; }
.srv-bar i { display: block; height: 100%; background: var(--ok); transition: width .4s; }
.srv-bar i.warn { background: var(--warn-line); }
.srv-bar i.bad { background: var(--danger); }
.srv-tasks { margin: 10px 0 0; padding: 10px 0 0; border-top: 1px solid var(--line); list-style: none; }
.srv-tasks li { margin-bottom: 6px; }
.srv-tasks small, .srv-note { color: var(--muted); }
.srv-note { margin-top: 8px; font-size: 12px; }

/* Детали в строке очереди станка — под спойлером */
.parts-spoiler > summary { display: inline-flex; white-space: nowrap; align-items: center; gap: 6px; cursor: pointer; color: var(--text-2); font-size: 13px; padding: 2px 8px 2px 4px; border-radius: var(--radius-sm); list-style: none; user-select: none; }
.parts-spoiler > summary::-webkit-details-marker { display: none; }
.parts-spoiler > summary::before { content: "▸"; color: var(--muted); transition: transform .15s; }
.parts-spoiler[open] > summary::before { transform: rotate(90deg); }
.parts-spoiler > summary:hover { background: var(--surface-3); color: var(--text); }
.parts-spoiler-list { margin-top: 6px; }

/* Редактор марки техкарты — таблица «как в Excel» */
.tc-mark-head { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px 14px; margin-bottom: 16px; }
.xl-wrap { overflow-x: auto; border: 1px solid var(--line-strong); border-radius: var(--radius-sm); max-height: 70vh; overflow-y: auto; }
.xl { border-collapse: collapse; width: 100%; min-width: 720px; font-size: 13px; font-variant-numeric: tabular-nums; }
.xl th, .xl td { border: 1px solid var(--line); padding: 0; height: 30px; }
.xl thead th { position: sticky; top: 0; z-index: 1; background: var(--surface-3); color: var(--text-2); font-weight: 600; font-size: 12px; padding: 0 8px; text-align: left; white-space: nowrap; }
.xl thead th.r { text-align: right; }
.xl tfoot td { position: sticky; bottom: 0; background: var(--surface-3); font-weight: 600; padding: 0 8px; }
.xl .xl-n { width: 40px; background: var(--surface-3); color: var(--muted); text-align: center; font-size: 12px; user-select: none; }
.xl .xl-x { width: 30px; text-align: center; }
.xl .xl-sum { padding: 0 8px; color: var(--muted); white-space: nowrap; width: 90px; }
#xl td input:not([type]) { display: block; width: 100%; height: 30px; margin: 0; border: 0; border-radius: 0; padding: 0 8px; background: transparent; box-shadow: none; font: inherit; color: var(--text); }
#xl td input:not([type]):hover { border: 0; }
#xl td input.r { text-align: right; }
#xl td input:not([type]):focus { outline: 2px solid var(--accent); outline-offset: -2px; background: var(--surface); box-shadow: none; border: 0; }
#xl td input.xl-bad { background: var(--danger-soft); color: var(--danger); }
.xl td { vertical-align: middle; }
.xl tbody tr:hover td:not(.xl-n) { background: var(--surface-2); }
.xl-del { border: 0; background: none; box-shadow: none; color: var(--muted); cursor: pointer; padding: 0 6px; height: 28px; font-size: 12px; }
.xl-del:hover { color: var(--danger); background: none; }

/* Вход: пароль точками без type=password — чтобы браузер не предлагал его сохранить */
.pw-mask { -webkit-text-security: disc; text-security: disc; }

/* Профильный раскрой: отменённые заготовки */
.tag.tag-cancel { background: var(--danger-soft, #fdecec); color: var(--danger, #c0392b); cursor: help; }
tr.row-cancelled td { opacity: .55; }
tr.row-cancelled .chip { text-decoration: line-through; }

/* Детали по цехам: чёткая таблица — сетка, полосы, тёмный текст, цифры по смыслу */
.parts-wrap > .parts-table { font-size: 13.5px; color: var(--text); }
.parts-table td { border-bottom: 1px solid var(--line-strong); border-right: 1px solid var(--line); }
.parts-table thead tr:first-child th { background: var(--surface-3); color: var(--text-2); font-weight: 600; font-size: 12.5px; border-right: 1px solid var(--line-strong); box-shadow: inset 0 -1px 0 var(--line-strong); }
.parts-table thead tr.parts-filters th { background: var(--surface-3); border-right: 1px solid var(--line-strong); box-shadow: inset 0 -2px 0 var(--line-strong); }
.parts-table th:last-child, .parts-table td:last-child { border-right: 0; }
.parts-table .grp { border-left: 2px solid var(--line-strong); }
.parts-table tr.row-done td { background: transparent; }
.parts-table tr.zebra td { background: #f6f6f8; }
.parts-table tbody tr:hover td { background: var(--accent-soft); }
.parts-table td.r { font-variant-numeric: tabular-nums; }
.parts-table .n-date { color: var(--text-2); font-variant-numeric: tabular-nums; }
.parts-table .n-total { font-weight: 600; }
.parts-table .n-done { color: var(--ok); font-weight: 600; }
.parts-table .n-done.n-zero { color: var(--muted); font-weight: 400; }
.parts-table .n-work { display: inline-block; min-width: 26px; padding: 0 6px; border-radius: 6px; background: var(--warn-soft); color: var(--warn); font-weight: 600; }
.parts-table .n-left { font-weight: 700; color: var(--danger); }
.parts-table .parts-filters select[data-f="state"] { min-width: 100px; }
.parts-table .parts-filters input[data-f="steel"], .parts-table .parts-filters input[data-f="total"] { min-width: 60px; }
.parts-table .parts-filters input[data-f="metal"] { min-width: 90px; }
.parts-table th, .parts-table td { padding-left: 7px; padding-right: 7px; }

/* Чёткая таблица с сеткой (склад и др.; класс .dg — .grid уже занят раскладкой форм): серая шапка, линии, полосы через строку, тёмный текст */
table.dg { font-size: 14px; color: var(--text); border: 1px solid var(--line-strong); border-radius: var(--radius-sm, 8px); }
table.dg th, table.dg td { padding: 8px 10px; vertical-align: middle; border-bottom: 1px solid var(--line-strong); border-right: 1px solid var(--line); }
table.dg th { background: var(--surface-3); color: var(--text-2); font-weight: 600; font-size: 12.5px; border-right-color: var(--line-strong); }
table.dg th:last-child, table.dg td:last-child { border-right: 0; }
table.dg tr:last-child td { border-bottom: 0; }
table.dg .grp { border-left: 2px solid var(--line-strong); }
table.dg tr:nth-child(odd) td { background: #f6f6f8; }
table.dg tr:hover td { background: var(--accent-soft); }
table.dg td.r { font-variant-numeric: tabular-nums; }
table.dg tr.dg-total td { background: var(--surface-3); font-weight: 700; border-top: 2px solid var(--line-strong); }
/* таблица ввода: поля во всю ширину колонки, числа справа */
table.dg-form tr:nth-child(odd) td, table.dg-form tr:hover td { background: var(--surface); }
table.dg-form td { padding: 6px; }
table.dg-form td input, table.dg-form td select { width: 100%; min-width: 70px; }
table.dg-form td input.r { text-align: right; font-variant-numeric: tabular-nums; }
table.dg-form td input.bad:not([type=checkbox]) { border-color: var(--danger); background: var(--danger-soft); }
.err-text { color: var(--danger); font-weight: 500; margin: 0 0 8px; }
/* живой фильтр (склад): полосы считает JS по видимым строкам, поля поиска — над своими колонками */
table.dg-live tr:nth-child(odd) td { background: transparent; }
table.dg-live tbody tr.zebra td { background: #f6f6f8; }
table.dg-live tbody tr:hover td { background: var(--accent-soft); }
table.dg tr.dg-filters th { padding: 5px 6px 7px; background: var(--surface-3); box-shadow: inset 0 -2px 0 var(--line-strong); }
table.dg tr.dg-filters input, table.dg tr.dg-filters select { width: 100%; min-width: 64px; height: 30px; padding: 0 8px; font-size: 12.5px; font-weight: 400; }
table.dg tr.dg-filters select { padding-right: 24px; background-position: right 6px center; }
table.dg tr.dg-filters input.r { text-align: right; }
table.dg tfoot tr.dg-total td { border-bottom: 0; }
.tile em.st-f { font-style: normal; }

/* Плашка на резервном адресе 147.45.145.15: основной адрес снова работает (app.js). */
.main-back { position: fixed; z-index: 60; left: 50%; top: 12px; transform: translateX(-50%); max-width: calc(100vw - 32px);
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 10px 12px 10px 16px; border-radius: var(--radius-lg);
  background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow-lg); font-weight: 500; }
.main-back a { font-weight: 600; }
.main-back button { border: 0; background: none; color: var(--muted); font-size: 16px; cursor: pointer; padding: 2px 6px; border-radius: 8px; }
.main-back button:hover { background: var(--surface-3); }
/* подтверждение внештатного при загрузке раскроя */
.confirm-card { border-color: var(--warn-line); background: var(--warn-soft); }
.confirm-card h3 { margin: 16px 0 6px; font-size: 15px; }
.confirm-q { padding: 10px 12px; margin: 8px 0; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; }
.confirm-q p { margin: 0 0 6px; }
.confirm-q label.check { display: flex; gap: 8px; align-items: center; margin: 4px 0; }

/* Тестовая версия test.zmkosnova.ru: оранжевая полоса сверху, чтобы не спутать с рабочим сайтом. */
.is-test { box-shadow: inset 0 4px 0 #f59e0b; }
