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

@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: #f4f6fa;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --surface-3: #f1f5f9;
  --text: #0f172a;
  --text-2: #334155;
  --muted: #64748b;
  --line: #e2e8f0;
  --line-strong: #cbd5e1;

  --accent: #2f5bea;
  --accent-hover: #2449c9;
  --accent-soft: #e6edff;
  --accent-ring: rgba(47, 91, 234, .22);

  --sidebar: #0f172a;
  --sidebar-2: #131c33;
  --sidebar-text: #a9b4c8;
  --sidebar-hover: rgba(255, 255, 255, .06);

  --ok: #15803d;      --ok-soft: #dcfce7;     --ok-line: #86efac;
  --warn: #a16207;    --warn-soft: #fef3c7;   --warn-line: #facc15;
  --idle: #475569;    --idle-soft: #f1f5f9;   --idle-line: #cbd5e1;
  --danger: #c02626;  --danger-soft: #fee2e2; --danger-line: #fca5a5;
  --info: #2f5bea;    --info-soft: #e6edff;

  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 14px;
  --gap: 16px;

  --shadow-xs: 0 1px 2px rgba(15, 23, 42, .05);
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, .04), 0 2px 6px rgba(15, 23, 42, .05);
  --shadow-md: 0 4px 10px rgba(15, 23, 42, .06), 0 12px 28px rgba(15, 23, 42, .08);
  --shadow-lg: 0 12px 24px rgba(15, 23, 42, .12), 0 30px 60px rgba(15, 23, 42, .16);

  --ease: cubic-bezier(.2, .8, .2, 1);
  --ease-in-out: cubic-bezier(.4, 0, .2, 1);
  --t-fast: 120ms;
  --t: 200ms;

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

/* ---------- Основа ---------- */
*, *::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); text-decoration: underline; text-underline-offset: 3px; }
h1 { font-size: 24px; line-height: 1.25; font-weight: 700; letter-spacing: -.02em; margin: 0; }
h2 { font-size: 16px; font-weight: 650; 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: linear-gradient(180deg, var(--sidebar) 0%, var(--sidebar-2) 100%); color: var(--sidebar-text);
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; overflow-y: auto;
  scrollbar-color: rgba(255,255,255,.15) transparent;
}
.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: #fff; font-weight: 700; font-size: 17px; letter-spacing: -.01em; }
.brand::before {
  content: ""; width: 28px; height: 28px; border-radius: 8px; flex: none;
  background: linear-gradient(135deg, #5b82ff, #2f5bea 55%, #1e3fae);
  box-shadow: 0 4px 12px rgba(47, 91, 234, .45), inset 0 1px 0 rgba(255,255,255,.25);
}
.brand:hover { color: #fff; text-decoration: none; }
.nav-toggle { display: none; background: none; border: 0; color: #fff; font-size: 22px; cursor: pointer; padding: 4px 8px; border-radius: 8px; }
.nav { flex: 1; padding: 4px 12px 12px; }
.nav-section { margin-bottom: 18px; }
.nav-title { font-size: 10.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .09em; color: #6b7a96; padding: 6px 10px; }
.nav a {
  position: relative; display: flex; align-items: center; color: var(--sidebar-text); padding: 8px 12px; border-radius: 8px;
  font-size: 14px; font-weight: 500; transition: background var(--t-fast), color var(--t-fast), transform var(--t-fast);
}
.nav a:hover { background: var(--sidebar-hover); color: #fff; text-decoration: none; }
.nav a:active { transform: scale(.98); }
.nav a.active { background: linear-gradient(90deg, rgba(47,91,234,.35), rgba(47,91,234,.12)); color: #fff; }
.nav a.active::before {
  content: ""; position: absolute; left: -12px; top: 8px; bottom: 8px; width: 3px; border-radius: 0 3px 3px 0; background: #6d8dff;
}
.sidebar-user { border-top: 1px solid rgba(255,255,255,.07); padding: 14px 20px 18px; display: flex; flex-direction: column; gap: 2px; }
.sidebar-user a { color: #fff; font-weight: 600; font-size: 14px; }
.sidebar-user a:hover { color: #fff; }
.sidebar-user .btn-link { color: var(--sidebar-text); padding: 0; font-size: 13px; }
.sidebar-user .btn-link:hover { color: #fff; }

.main { padding: 28px 36px 64px; min-width: 0; max-width: 1440px; width: 100%; }
body.no-nav { display: grid; place-items: start center; background: radial-gradient(1200px 600px at 50% -10%, #dfe7ff 0%, var(--bg) 60%); 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: 34px; height: 34px; border-radius: 10px; background: linear-gradient(135deg, #5b82ff, #2f5bea 55%, #1e3fae);
  box-shadow: 0 6px 16px rgba(47, 91, 234, .4);
}
body.no-nav .card { padding: 24px; box-shadow: var(--shadow-md); }
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: 20px; }
.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: 500; box-shadow: var(--shadow-xs);
}
.flash::before { content: ""; width: 20px; height: 20px; flex: none; border-radius: 50%; background: center/12px no-repeat; }
.flash-ok { background: #f0fdf4; color: #166534; border-color: #bbf7d0; }
.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: #fef2f2; color: #991b1b; border-color: #fecaca; }
.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: #fffbeb; color: #78350f; border: 1px solid #fde68a; 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: 9px;
  cursor: pointer; white-space: nowrap; font-weight: 600; font-size: 14px; letter-spacing: -.005em; text-decoration: none;
  border: 1px solid transparent; color: #fff;
  background: linear-gradient(180deg, #3d67f0 0%, var(--accent) 100%);
  box-shadow: 0 1px 2px rgba(30, 64, 175, .3), inset 0 1px 0 rgba(255,255,255,.16);
  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: linear-gradient(180deg, #3560e6 0%, var(--accent-hover) 100%); color: #fff; text-decoration: none; box-shadow: 0 3px 8px rgba(30, 64, 175, .3), inset 0 1px 0 rgba(255,255,255,.16); }
button:active, .btn:active { transform: translateY(1px) scale(.99); box-shadow: 0 1px 1px rgba(30, 64, 175, .3); }
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); box-shadow: var(--shadow-xs);
}
.btn-ghost:hover, button.secondary:hover { background: var(--surface-2); color: var(--text); border-color: #94a3b8; box-shadow: var(--shadow-sm); }
.btn-ghost:active, button.secondary:active { box-shadow: none; }
button.danger, .btn-danger { background: linear-gradient(180deg, #e04040, var(--danger)); box-shadow: 0 1px 2px rgba(153, 27, 27, .3), inset 0 1px 0 rgba(255,255,255,.14); }
button.danger:hover { background: linear-gradient(180deg, #d63636, #a81f1f); }
.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); text-decoration: underline; text-underline-offset: 3px; 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: 9px; background: #fff; min-width: 0;
  box-shadow: var(--shadow-xs); 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='%2364748b' 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: #94a3b8; }
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: #94a3b8; }
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: 9px; background: var(--surface);
  color: var(--text-2); font: 600 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: 11.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--muted);
  background: var(--surface-2); 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: #f8fafc; }
tr:has(input.sel:checked) td { background: var(--accent-soft) !important; }
tr.inactive td { color: var(--muted); }
tr.row-done td { background: #f6fef9; }
tr.row-taken td { background: #fffbeb; }
.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: 600;
  font-variant-numeric: tabular-nums; white-space: nowrap; line-height: 20px; border: 1px solid transparent;
}
.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); border: 1px solid var(--line); border-radius: 7px;
  padding: 1px 8px; margin: 2px 4px 2px 0; font-size: 12.5px; white-space: nowrap; box-shadow: var(--shadow-xs);
}
.progress { display: inline-flex; align-items: center; gap: 10px; }
.progress-bar { position: relative; display: inline-block; width: 120px; height: 8px; background: var(--surface-3); border-radius: 99px; overflow: hidden; box-shadow: inset 0 1px 2px rgba(15,23,42,.06); }
.progress-bar i { display: block; height: 100%; border-radius: 99px; background: linear-gradient(90deg, #22c55e, #16a34a); }
.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: 10px; bottom: 10px; width: 4px; 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: var(--shadow-sm); }
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: var(--surface-3)
    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='%2364748b' 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: 650; 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-2); 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); box-shadow: var(--shadow-xs); }
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: 600; 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: 14px; color: #e2e8f0;
  background: rgba(15, 23, 42, .92); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  box-shadow: var(--shadow-lg), inset 0 1px 0 rgba(255,255,255,.06);
}
.actionbar b { color: #fff; }
.actionbar label { display: inline-flex; gap: 6px; align-items: center; margin: 0; color: #e2e8f0; font-size: 14px; }
.actionbar input:not([type=checkbox]) { width: 84px; }
.actionbar select { background-color: #fff; }
.actionbar .muted { color: #94a3b8; }
.actionbar .btn-link { color: #a5b4fc; }
.actionbar button.secondary { background: rgba(255,255,255,.08); color: #fff; border-color: rgba(255,255,255,.18); box-shadow: none; }
.actionbar button.secondary:hover { background: rgba(255,255,255,.16); border-color: rgba(255,255,255,.3); }

/* ---------- Диалоги и просмотр PDF ---------- */
dialog { border: 0; padding: 0; color: var(--text); }
dialog::backdrop { background: rgba(15, 23, 42, .5); backdrop-filter: blur(3px); -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-2); }
.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; }

/* ---------- Сводные плитки ---------- */
.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: 12px; font-weight: 500; color: var(--muted); margin-bottom: 4px; }
.tile b { font-size: 26px; font-weight: 700; 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; transform: translateY(-2px); box-shadow: var(--shadow-md); border-color: #c7d6ff; }

/* ---------- Табель ---------- */
.timesheet-wrap { border: 1px solid var(--line); box-shadow: var(--shadow-xs); }
table.timesheet { font-size: 13px; }
table.timesheet th, table.timesheet td { padding: 6px 4px; border-right: 1px solid var(--line); }
table.timesheet th { text-transform: none; letter-spacing: 0; font-size: 12px; }
table.timesheet .ts-name { position: sticky; left: 0; background: var(--surface); min-width: 180px; z-index: 1; padding-left: 12px; box-shadow: 1px 0 0 var(--line); }
table.timesheet th.ts-name { background: var(--surface-2); }
.ts-cell { min-width: 32px; font-variant-numeric: tabular-nums; text-align: center; }
.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: #fafbfd; color: var(--muted); }
.ts-has { background: #ecfdf3 !important; color: #166534; font-weight: 600; }
.ts-multi { box-shadow: inset 0 0 0 2px #eab308; }
.ts-today { background: var(--accent-soft) !important; }

/* ---------- Техкарта и тара ---------- */
.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-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: 700; display: inline-grid; place-items: center; box-shadow: 0 2px 6px rgba(239, 68, 68, .45); }
.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: 10.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .08em; 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; box-shadow: inset 0 -2px 0 rgba(0,0,0,.12); }
.avatar-channel { background: linear-gradient(135deg, #5b82ff, #2f5bea); border-radius: 11px; 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:
  radial-gradient(circle at 1px 1px, rgba(15,23,42,.045) 1px, transparent 0) 0 0/22px 22px, 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); border: 1px solid var(--line);
  box-shadow: var(--shadow-xs); min-width: 60px; }
.msg.grouped .bubble { border-radius: 16px 16px 16px 6px; }
.msg.mine .bubble { background: linear-gradient(180deg, #3d67f0, 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%, #e9eef5 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) {
  .main { animation: page-in 260ms var(--ease) both; }
  .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 page-in { from { opacity: 0; transform: translateY(6px); } }
@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; } }

/* ---------- Печать ---------- */
.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 { display: none !important; }
  .main { padding: 0; max-width: none; animation: 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; }
}

/* ---------- Телефон и планшет ---------- */
@media (max-width: 900px) {
  body.has-nav { display: block; }
  .sidebar { position: sticky; height: auto; z-index: 20; box-shadow: var(--shadow-md); }
  .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; }
  .actionbar { bottom: 10px; }
}
