/* Тёплые нейтральные поверхности и синий акцент действий.
   Статусы, виды заметок и серии графиков имеют собственную семантику. */
:root {
  color-scheme: light;
  --bg: #f7f6f2;
  --panel: #ffffff;
  --raise: #f1f0eb;
  --side-bg: #ffffff;
  --line: #d9d7cf;
  --line-soft: #eae8e1;
  --control-line: #85867b;
  --hover: #eeede6;
  --ink: #24251f;
  --muted: #66675e;
  --faint: #66675e;
  --accent: #74b5ff;
  --accent-ink: #24251f;
  --accent-soft: #e8f1ff;
  --accent-text: #1e4f9c;
  --accent-hover: #60a5fa;
  --accent-active: #4b95ed;
  --focus: #1e4f9c;
  --disabled-bg: #e8e7df;
  --disabled-ink: #62645a;
  --ok: #236644; --ok-bg: #edf6ee; --ok-line: #abcdb7;
  --warn: #815500; --warn-bg: #fff1d6; --warn-line: #dec18a;
  --info: #225d8a; --info-bg: #eaf1f8; --info-line: #adc8df;
  --err: #b22e25; --err-bg: #fbece9; --err-line: #e5b8b0;
  --k-sheet: #326f9b;
  --k-entry: #6c7163;
  --k-employee: #34794f;
  --k-index: #9c6b16;
  --s-rec: #326f9b;
  --s-res: #2c805f;
  --shadow: 0 1px 2px rgba(36, 37, 31, .04), 0 2px 8px rgba(36, 37, 31, .025);
  --shadow-pop: 0 12px 36px rgba(36, 37, 31, .16);
  --r-card: 16px;
  --r-ctl: 11px;
  --r-pill: 999px;
  --side: 264px;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #171816;
  --panel: #22231f;
  --raise: #2b2d27;
  --side-bg: #22231f;
  --line: #484b42;
  --line-soft: #34372f;
  --control-line: #797d6e;
  --hover: #34372f;
  --ink: #f3f2ec;
  --muted: #b8baad;
  --faint: #b8baad;
  --accent: #8ec1ff;
  --accent-ink: #24251f;
  --accent-soft: #1d3049;
  --accent-text: #8ec1ff;
  --accent-hover: #acd1ff;
  --accent-active: #74b5ff;
  --focus: #8ec1ff;
  --disabled-bg: #35382f;
  --disabled-ink: #a3a698;
  --ok: #83d8a2; --ok-bg: #21372c; --ok-line: #436d52;
  --warn: #efca7e; --warn-bg: #39301e; --warn-line: #7b6740;
  --info: #9fc8ec; --info-bg: #233440; --info-line: #486c87;
  --err: #f5a49c; --err-bg: #402925; --err-line: #87524c;
  --k-sheet: #91bfe2;
  --k-entry: #b6bca8;
  --k-employee: #83c699;
  --k-index: #e4bb72;
  --s-rec: #8cbee1;
  --s-res: #83d1b0;
  --shadow: 0 1px 3px rgba(0, 0, 0, .15), 0 2px 8px rgba(0, 0, 0, .08);
  --shadow-pop: 0 12px 36px rgba(0, 0, 0, .4);
}

/* Без JavaScript тема остаётся читаемой и следует настройкам системы.
   Явный выбор приложения всегда приоритетнее prefers-color-scheme. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    color-scheme: dark;
    --bg: #171816;
    --panel: #22231f;
    --raise: #2b2d27;
    --side-bg: #22231f;
    --line: #484b42;
    --line-soft: #34372f;
    --control-line: #797d6e;
    --hover: #34372f;
    --ink: #f3f2ec;
    --muted: #b8baad;
    --faint: #b8baad;
    --accent: #8ec1ff;
    --accent-ink: #24251f;
    --accent-soft: #1d3049;
    --accent-text: #8ec1ff;
    --accent-hover: #acd1ff;
    --accent-active: #74b5ff;
    --focus: #8ec1ff;
    --disabled-bg: #35382f;
    --disabled-ink: #a3a698;
    --ok: #83d8a2; --ok-bg: #21372c; --ok-line: #436d52;
    --warn: #efca7e; --warn-bg: #39301e; --warn-line: #7b6740;
    --info: #9fc8ec; --info-bg: #233440; --info-line: #486c87;
    --err: #f5a49c; --err-bg: #402925; --err-line: #87524c;
    --k-sheet: #91bfe2;
    --k-entry: #b6bca8;
    --k-employee: #83c699;
    --k-index: #e4bb72;
    --s-rec: #8cbee1;
    --s-res: #83d1b0;
    --shadow: 0 1px 3px rgba(0, 0, 0, .15), 0 2px 8px rgba(0, 0, 0, .08);
    --shadow-pop: 0 12px 36px rgba(0, 0, 0, .4);
  }
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font: 15px/1.55 ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI",
        Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent-text); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }

svg.i { width: 18px; height: 18px; flex: 0 0 18px; stroke: currentColor; fill: none;
  stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

/* --- Оболочка ------------------------------------------------------------ */

.shell { display: flex; min-height: 100%; }

.side {
  width: var(--side);
  flex: 0 0 var(--side);
  background: var(--side-bg);
  border-right: 1px solid var(--line);
  padding: 18px 14px 14px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: hidden;
}

.side-top { display: flex; align-items: center; gap: 10px; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--ink); padding: 2px 6px; }
.brand:hover { text-decoration: none; }
.brand-mark {
  width: 30px; height: 30px; border-radius: 8px; flex: 0 0 30px;
  background: var(--accent); color: var(--accent-ink);
  display: grid; place-items: center;
}
.brand-mark svg.i { width: 17px; height: 17px; stroke-width: 2; }
.brand b { font-weight: 650; letter-spacing: -.01em; font-size: 15.5px; line-height: 1.15; }
.brand small { display: block; font-size: 11.5px; color: var(--faint); font-weight: 400; }

/* Кнопка меню видна только на узком экране. */
.side .menu-btn { display: none; margin-left: auto; }

.side-body { display: flex; flex-direction: column; gap: 14px; min-height: 0; flex: 1; }

.work {
  flex: 1;
  min-width: 0;
  padding: 28px 40px 80px;
  max-width: 1320px;
}
/* Без входа панели слева нет, и .work стоит один: без центровки он
   прижимался к левому краю, а форма входа — вместе с ним, на широком
   экране заметно левее середины. */
.work.solo { margin: 0 auto; }

/* --- Поиск объекта в панели -------------------------------------------- */

.side-search { position: relative; }
.side-search svg.i {
  position: absolute; left: 11px; top: 50%; transform: translateY(-50%);
  width: 16px; height: 16px; color: var(--faint); pointer-events: none;
}
.side .side-search input[type=search] {
  padding: 9px 12px 9px 36px;
  border-radius: var(--r-ctl);
  background: var(--panel);
}

/* --- Меню ------------------------------------------------------------------ */

.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-sep { height: 1px; background: var(--line); margin: 8px 6px; }

.nav a {
  display: flex; align-items: center; gap: 11px;
  padding: 8px 10px;
  border-radius: var(--r-ctl);
  color: var(--muted);
  font-size: 14.5px;
}
.nav a:hover { background: var(--hover); color: var(--ink); text-decoration: none; }
.nav a.on { background: var(--accent-soft); color: var(--ink); font-weight: 600; box-shadow: inset 3px 0 0 var(--accent-text); }
.nav a span { flex: 1; min-width: 0; }
.nav a small { display: block; font-size: 11.5px; color: var(--faint); font-weight: 400; margin-top: -1px; }
.nav a.on small { color: var(--accent-text); opacity: .75; }

.side-label {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 11px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase;
  color: var(--faint); padding: 0 10px;
}
.side-label a {
  color: var(--faint); display: grid; place-items: center;
  width: 24px; height: 24px; border-radius: 6px;
}
.side-label a:hover { background: var(--hover); color: var(--ink); }
.side-label a svg.i { width: 16px; height: 16px; }

.side-list { overflow-y: auto; flex: 1; min-height: 60px; margin: -6px -4px 0; padding: 0 4px; }
.side-item {
  display: block;
  padding: 7px 10px;
  border-radius: var(--r-ctl);
  color: var(--ink);
  margin-bottom: 1px;
}
.side-item:hover { background: var(--hover); text-decoration: none; }
.side-item.on { background: var(--panel); box-shadow: inset 0 0 0 1px var(--line); }
.side-item b { display: block; font-weight: 500; font-size: 13.5px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-item span {
  display: block; color: var(--faint); font-size: 12px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.side-empty { font-size: 13px; color: var(--faint); padding: 4px 10px; margin: 0; }

.side-user {
  display: flex; align-items: center; gap: 10px;
  border-top: 1px solid var(--line);
  padding: 12px 4px 0;
}
.ava {
  width: 32px; height: 32px; flex: 0 0 32px; border-radius: 50%;
  background: var(--accent-soft); color: var(--accent-text);
  display: grid; place-items: center;
  font-size: 12px; font-weight: 600; letter-spacing: .02em;
}
.side-user .who { min-width: 0; flex: 1; line-height: 1.3; }
.side-user .who b { display: block; font-weight: 550; font-size: 13.5px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-user .who span { color: var(--faint); font-size: 12px; }
.side-user form { margin: 0; }

/* Кабинет подрядчика: шапка вместо боковой панели. */
.portal-top {
  display: flex; align-items: center; gap: 16px;
  padding: 12px 24px; background: var(--panel); border-bottom: 1px solid var(--line);
}
.portal-top .side-user { margin-left: auto; border-top: 0; padding: 0; min-width: 0; max-width: 60%; }
.portal-work { margin: 0 auto; max-width: 960px; }
@media (max-width: 700px) {
  .portal-top { padding: 10px 16px; }
  .portal-top .brand small, .portal-top .ava { display: none; }
  .portal-work .stats { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
  .portal-work .stat { padding: 10px 12px; }
  .portal-work .stat b { font-size: 22px; }
  .portal-work .stat span { font-size: 12px; }
}

/* Одно управление темой для сайта, входа, кабинета и самостоятельного чата. */
.theme-control { display: flex; align-items: center; gap: 10px; margin: 0; min-width: 0; }
.theme-control > span { color: var(--muted); font-size: 12px; margin: 0; white-space: nowrap; }
.theme-control select { width: auto; min-width: 0; min-height: 44px; max-width: 170px; padding-top: 9px; padding-bottom: 9px; font-size: 13px; background-color: var(--panel); }
.side-preferences { padding: 8px 4px 0; border-top: 1px solid var(--line-soft); }
.side-preferences .theme-control { justify-content: space-between; }
.solo-tools { display: flex; justify-content: flex-end; margin-bottom: 24px; }
.portal-top > .theme-control { margin-left: auto; }
.portal-top > .theme-control + .side-user { margin-left: 0; }
@media (max-width: 700px) {
  .portal-top { flex-wrap: wrap; }
  .portal-top > .theme-control { order: 3; width: 100%; justify-content: flex-end; border-top: 1px solid var(--line-soft); padding-top: 10px; }
  .portal-top > .theme-control + .side-user { margin-left: auto; }
}

/* --- Шапка страницы ------------------------------------------------------- */

.crumbs {
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px;
  font-size: 13.5px; color: var(--faint); margin-bottom: 10px;
}
.crumbs a { color: var(--muted); }
.crumbs a:hover { color: var(--ink); }
.crumbs .sep { color: var(--faint); opacity: .6; }

.page-head {
  display: flex; gap: 16px 24px; align-items: flex-start; justify-content: space-between;
  flex-wrap: wrap; margin-bottom: 22px;
}
.page-head .title { min-width: 0; flex: 1 1 360px; }
.page-head .actions { flex: 0 0 auto; }

h1 {
  font-size: 30px; line-height: 1.15; letter-spacing: -.02em;
  font-weight: 650; margin: 0 0 4px;
}
h2 {
  font-size: 18px; font-weight: 650; letter-spacing: -.01em; margin: 34px 0 12px;
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
}
h2 .count { font-size: 13px; font-weight: 500; color: var(--faint); }
h3 { font-size: 15px; font-weight: 600; margin: 0 0 6px; }
.sub { color: var(--muted); margin: 0; }

.section-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  flex-wrap: wrap; margin: 30px 0 12px;
}
.section-head h2 { margin: 0; }

/* Реквизиты строкой ячеек: подпись мелко сверху, значение под ней.
   Читаются слева направо одним взглядом и не спорят с заголовком. */
.facts {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 1px; background: var(--line);
  border: 1px solid var(--line); border-radius: var(--r-card);
  overflow: hidden; margin: 0 0 24px;
}
.facts > div { background: var(--panel); padding: 12px 16px; min-width: 0; }
.facts dt { font-size: 12px; color: var(--faint); margin-bottom: 3px; }
.facts dd { margin: 0; font-weight: 550; overflow-wrap: anywhere; }
.facts dd .muted { font-weight: 400; }

/* Сводка числами — на радаре. */
.stats {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px; margin: 0 0 8px;
}
.stat {
  display: block; background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--r-card); padding: 14px 16px; color: var(--ink);
  box-shadow: var(--shadow);
}
a.stat:hover { border-color: var(--faint); text-decoration: none; }
.stat b { display: block; font-size: 28px; font-weight: 650; letter-spacing: -.02em; line-height: 1.1;
  font-variant-numeric: tabular-nums; }
.stat span { font-size: 13px; color: var(--muted); }
.stat.late b { color: var(--err); }
.stat.warn b { color: var(--warn); }
.stat.ok b   { color: var(--ok); }

/* --- Кнопки --------------------------------------------------------------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 8px 15px;
  border-radius: var(--r-ctl);
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  font: inherit; font-size: 14px; font-weight: 500; line-height: 1.35;
  cursor: pointer;
  white-space: nowrap;
  box-shadow: var(--shadow);
}
.btn svg.i { width: 16px; height: 16px; }
.btn:hover { border-color: var(--faint); text-decoration: none; }
.btn.primary { background: var(--accent); border-color: var(--accent-text); color: var(--accent-ink); }
.btn.primary:hover { background: var(--accent-hover); border-color: var(--accent-text); }
.btn.primary:active { background: var(--accent-active); border-color: var(--accent-text); }
.btn.danger { color: var(--err); }
.btn.danger:hover { border-color: var(--err); background: var(--err-bg); }
.btn.small { padding: 5px 11px; font-size: 13px; }
.btn.ghost { background: transparent; border-color: transparent; box-shadow: none; color: var(--muted); }
.btn.ghost:hover { background: var(--hover); color: var(--ink); }
.btn.icon { padding: 7px; }
.btn.block { width: 100%; }
.btn[disabled] { background: var(--disabled-bg); color: var(--disabled-ink); border-color: var(--line); box-shadow: none; cursor: not-allowed; }
.btn[disabled]:hover { background: var(--disabled-bg); color: var(--disabled-ink); border-color: var(--line); }

.bar { display: flex; gap: 9px; align-items: center; flex-wrap: wrap; margin-bottom: 16px; }
.bar:last-child { margin-bottom: 0; }
.bar .grow { flex: 1; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.actions form { margin: 0; }

/* Выпадающее меню «Ещё» на <details>: работает без скрипта, а редкие и
   опасные действия (удалить, импорт) не стоят в одном ряду с частыми. */
.menu { position: relative; }
.menu > summary { list-style: none; }
.menu > summary::-webkit-details-marker { display: none; }
.menu-pop {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 20;
  min-width: 230px; padding: 6px;
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--r-card); box-shadow: var(--shadow-pop);
}
.menu-pop a, .menu-pop button {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 8px 10px; border-radius: 7px; border: none; background: none;
  font: inherit; font-size: 14px; color: var(--ink); text-align: left; cursor: pointer;
}
.menu-pop a:hover, .menu-pop button:hover { background: var(--hover); text-decoration: none; }
.menu-pop svg.i { width: 16px; height: 16px; color: var(--muted); }
.menu-pop .danger, .menu-pop .danger svg.i { color: var(--err); }
.menu-pop hr { border: none; border-top: 1px solid var(--line); margin: 6px 0; }
.menu-pop form { margin: 0; }

/* --- Карточки и таблицы ---------------------------------------------------- */

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--r-card);
  padding: 20px 22px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
}
.panel > :last-child { margin-bottom: 0; }

.callout {
  background: var(--panel); border: 1px solid var(--line); border-left: 3px solid var(--accent);
  border-radius: var(--r-card); padding: 12px 18px; margin-bottom: 18px;
}
.callout .lbl { font-size: 12px; color: var(--faint); display: block; margin-bottom: 2px; }

/* Раскрывающаяся форма. Новый лист, новая запись, параметры листа — формы,
   которые нужны в одну из десяти минут. Свёрнутые, они не отодвигают вниз
   то, ради чего страницу открыли. */
.fold {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--r-card); margin-bottom: 16px; box-shadow: var(--shadow);
}
.fold > summary {
  list-style: none; cursor: pointer;
  display: flex; align-items: center; gap: 10px;
  padding: 13px 20px; font-weight: 600; border-radius: var(--r-card);
}
.fold > summary::-webkit-details-marker { display: none; }
.fold > summary .chev { margin-left: auto; color: var(--faint); transition: transform .15s; }
.fold[open] > summary .chev { transform: rotate(180deg); }
.fold > summary:hover { background: var(--hover); }
.fold[open] > summary { border-radius: var(--r-card) var(--r-card) 0 0; }
.fold > summary small { font-weight: 400; color: var(--faint); font-size: 13px; }
.fold-body { padding: 18px 20px 20px; border-top: 1px solid var(--line-soft); }
.fold.accent { border-color: var(--accent); }
.fold.accent > summary { color: var(--accent-text); }

.danger-zone {
  margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--line);
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
}
.danger-zone p { margin: 0; font-size: 13px; color: var(--muted); }
.danger-zone form { margin: 0; }

.table-wrap {
  overflow-x: auto; border: 1px solid var(--line); border-radius: var(--r-card);
  background: var(--panel); box-shadow: var(--shadow);
}
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 12px 16px; vertical-align: top; }
th {
  font-size: 12.5px; font-weight: 550; color: var(--faint);
  border-bottom: 1px solid var(--line); background: var(--raise);
  white-space: nowrap;
}
td { border-top: 1px solid var(--line-soft); }
tbody tr:first-child td { border-top: none; }
td.num { color: var(--muted); width: 56px; font-variant-numeric: tabular-nums; }
td.wrap { white-space: pre-wrap; }
th.num, td.num.right { text-align: right; width: auto; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.empty { padding: 36px 20px; text-align: center; color: var(--muted); }
.empty b { display: block; color: var(--ink); font-size: 15.5px; margin-bottom: 4px; }
.empty p { margin: 0 auto 14px; max-width: 460px; }
.empty p:last-child { margin-bottom: 0; }

/* Строка-ссылка: щелчок в любом месте строки открывает карточку. Сама ссылка
   — на названии, а растянута на всю строку псевдоэлементом, поэтому она
   по-прежнему одна, по ней ходят с клавиатуры и её читает скринридер. */
tr.link { position: relative; cursor: pointer; }
tr.link:hover td { background: var(--hover); }
tr.link a.row-link { color: var(--ink); font-weight: 600; }
tr.link a.row-link::after { content: ""; position: absolute; inset: 0; }
tr.link a:not(.row-link) { position: relative; z-index: 1; }
/* Кнопка в строке-ссылке: над растянутой ссылкой строки, иначе щелчок по ней
   открывает карточку вместо действия. */
tr.link form.row-action { position: relative; z-index: 1; margin: 4px 0 0; }
td.go { width: 36px; color: var(--faint); padding-left: 0; }
td.go svg.i { width: 16px; height: 16px; }

/* --- Формы ---------------------------------------------------------------- */

/* Поля без type (подрядчик с подсказками) — тоже текст; раньше они выпадали
   из правила и рисовались белым квадратиком браузера. */
input:not([type]), input[type=text], input[type=email], input[type=password], input[type=date],
input[type=search], input[type=number], select, textarea {
  width: 100%;
  padding: 9px 13px;
  border: 1px solid var(--control-line);
  border-radius: var(--r-ctl);
  font: inherit;
  background: var(--panel);
  color: var(--ink);
}
select { appearance: none; padding-right: 34px;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%),
                    linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: right 16px center, right 11px center;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat; }
textarea { min-height: 90px; resize: vertical; line-height: 1.5; }
input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--focus); outline-offset: 2px;
  border-color: var(--focus); background-color: var(--panel);
  box-shadow: none;
}
input::placeholder, textarea::placeholder { color: var(--faint); opacity: 1; }
input:disabled, select:disabled, textarea:disabled { background-color: var(--disabled-bg); color: var(--disabled-ink); cursor: not-allowed; }
input[readonly], textarea[readonly] { background-color: var(--raise); }
input[type=checkbox] { accent-color: var(--accent); width: 16px; height: 16px; margin: 0; }
input[type=file] { font: inherit; font-size: 13.5px; color: var(--muted); max-width: 100%; }
input[type=file]::file-selector-button {
  font: inherit; font-size: 13px; margin-right: 10px; padding: 6px 12px; cursor: pointer;
  border: 1px solid var(--line); border-radius: var(--r-ctl); background: var(--panel); color: var(--ink);
}

label { display: block; margin-bottom: 16px; }
label > span { display: block; font-size: 13px; font-weight: 500; color: var(--muted); margin-bottom: 6px; }
label > span em { font-style: normal; color: var(--err); }
.field-label { display: block; font-size: 13px; font-weight: 500; color: var(--muted); margin-bottom: 8px; }
.hint { display: block; font-size: 12px; color: var(--faint); margin-top: 5px; font-weight: 400; }

/* Галочки специалистов — «чипами»: в них легко попасть пальцем на планшете. */
.checks { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
label.check {
  display: inline-flex; align-items: center; gap: 8px; margin: 0;
  padding: 7px 12px; border: 1px solid var(--line); border-radius: var(--r-ctl);
  background: var(--raise); cursor: pointer; font-size: 14px;
}
label.check:hover { border-color: var(--faint); }
label.check:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-text); }
label.check > span { display: inline; margin: 0; color: inherit; font-size: inherit; font-weight: 400; }

/* Статус — сегментами, а не списком: три варианта видны сразу, и выбор — одно
   касание вместо двух. Внутри обычные радиокнопки, форма их и отправляет. */
.seg { display: inline-flex; flex-wrap: wrap; gap: 4px; padding: 3px; margin-bottom: 16px;
  border: 1px solid var(--line); border-radius: calc(var(--r-ctl) + 3px); background: var(--raise); }
.seg label { margin: 0; position: relative; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg label > span {
  display: inline-flex; align-items: center; gap: 7px; margin: 0;
  padding: 6px 13px; border-radius: var(--r-ctl); cursor: pointer;
  font-size: 13.5px; color: var(--muted); font-weight: 500;
}
.seg label > span:hover { color: var(--ink); }
.seg input:checked + span { background: var(--panel); color: var(--ink); box-shadow: var(--shadow), inset 0 0 0 1px var(--line); }
.seg input:focus-visible + span { outline: 2px solid var(--focus); outline-offset: 2px; }
.seg .dot { width: 8px; height: 8px; border-radius: 50%; }

/* Переключатель-вкладки из ссылок (Активные / Архив / Все). */
.tabs { display: inline-flex; gap: 4px; padding: 3px; border: 1px solid var(--line);
  border-radius: calc(var(--r-ctl) + 3px); background: var(--raise); }
.tabs a { padding: 6px 14px; border-radius: var(--r-ctl); color: var(--muted); font-size: 14px; font-weight: 500; }
.tabs a:hover { color: var(--ink); text-decoration: none; }
.tabs a.on { background: var(--panel); color: var(--ink); box-shadow: var(--shadow), inset 0 0 0 1px var(--line); }

.search-field { position: relative; flex: 1 1 260px; max-width: 420px; }
.search-field svg.i { position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
  width: 16px; height: 16px; color: var(--faint); pointer-events: none; }
.search-field input[type=search] { padding-left: 36px; background-color: var(--panel); }

.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 18px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0 18px; }

/* --- Метки статусов -------------------------------------------------------- */

.pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 1px 10px; border-radius: var(--r-pill);
  font-size: 12.5px; font-weight: 550; white-space: nowrap; line-height: 1.6;
  border: 1px solid transparent;
}
.pill.open, .pill.in_progress, .pill.resolved { padding-left: 8px; }
.pill.open::before, .pill.in_progress::before, .pill.resolved::before {
  content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor;
}
.pill.open        { background: var(--warn-bg); color: var(--warn); border-color: var(--warn-line); }
.pill.in_progress { background: var(--info-bg); color: var(--info); border-color: var(--info-line); }
.pill.resolved    { background: var(--ok-bg);   color: var(--ok);   border-color: var(--ok-line); }
.pill.active      { background: var(--ok-bg);   color: var(--ok);   border-color: var(--ok-line); }
.pill.archived    { background: var(--raise);   color: var(--muted); border-color: var(--line); }
.pill.late        { background: var(--err-bg);  color: var(--err);  border-color: var(--err-line); }
.pill.soon        { background: var(--warn-bg); color: var(--warn); border-color: var(--warn-line); }
.pill.plain       { background: var(--raise);   color: var(--muted); border-color: var(--line); }

.dot.open { background: var(--warn); }
.dot.in_progress { background: var(--info); }
.dot.resolved { background: var(--ok); }

.count-badge {
  display: inline-grid; place-items: center; min-width: 24px; height: 22px; padding: 0 7px;
  border-radius: var(--r-pill); font-size: 12.5px; font-weight: 650;
  background: var(--warn-bg); color: var(--warn); font-variant-numeric: tabular-nums;
}
.count-badge.late { background: var(--err-bg); color: var(--err); }
.zero { color: var(--faint); }

.alert { padding: 12px 16px; border-radius: var(--r-card); margin-bottom: 16px; border: 1px solid; }
.alert.ok   { background: var(--ok-bg);  border-color: var(--ok-line);  color: var(--ok); }
.alert.err  { background: var(--err-bg); border-color: var(--err-line); color: var(--err); }
.alert.info { background: var(--panel);  border-color: var(--line);     color: var(--muted); }
.alert ul { margin: 6px 0 0; padding-left: 20px; }

.muted { color: var(--muted); }
.faint { color: var(--faint); }
.small { font-size: 13px; }
.err-text { color: var(--err); }
code { font-size: .92em; background: var(--raise); border: 1px solid var(--line-soft);
  padding: 1px 5px; border-radius: 5px; }

/* --- Записи листа ---------------------------------------------------------- */

/* Запись — карточка, а не строка таблицы на восемь колонок: текст замечания
   и решения — главное в журнале, и ему нужна ширина, а не колонка в 150 px.
   Цветная полоса слева повторяет статус, чтобы лист читался с одного взгляда:
   много жёлтого и красного — на объекте плохо. */
.entries { display: flex; flex-direction: column; gap: 10px; }
.entry {
  position: relative;
  background: var(--panel); border: 1px solid var(--line);
  border-left: 4px solid var(--line);
  border-radius: var(--r-card); padding: 14px 18px 12px;
  box-shadow: var(--shadow);
  scroll-margin-top: 20px;
}
.entry.open        { border-left-color: var(--warn); }
.entry.in_progress { border-left-color: var(--info); }
.entry.resolved    { border-left-color: var(--ok); }
.entry.late        { border-left-color: var(--err); }
.entry:target { box-shadow: 0 0 0 3px var(--accent-soft), var(--shadow); }

.entry-top { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.entry-num { font-weight: 650; color: var(--muted); font-variant-numeric: tabular-nums; margin-right: 2px; }
.entry-top .grow { flex: 1; }
.entry-actions { display: flex; gap: 4px; }

.entry-text { white-space: pre-wrap; font-size: 15.5px; line-height: 1.55; margin: 0 0 10px; }
.entry-fix {
  white-space: pre-wrap; margin: 0 0 10px; padding: 8px 12px;
  background: var(--raise); border-radius: var(--r-ctl); font-size: 14.5px;
}
.entry-fix .lbl { display: block; font-size: 12px; font-weight: 600; color: var(--ok); margin-bottom: 2px; white-space: normal; }
.entry-fix.none { color: var(--faint); font-size: 13.5px; }

/* Отчёт подрядчика ждёт решения: заметно, но не как ошибка. */
.report {
  margin: 0 0 10px; padding: 10px 12px; border: 1px solid var(--info-line);
  background: var(--info-bg); border-radius: var(--r-ctl);
}
.report .lbl { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px;
  font-size: 12.5px; font-weight: 600; color: var(--info); }
.report .lbl small { font-weight: 400; color: var(--muted); }
.report .lbl svg.i { width: 14px; height: 14px; }
.report p { margin: 4px 0 8px; white-space: pre-wrap; font-size: 14.5px; }
.report .quick { margin: 0; }
.quick-fix.reject[open] > summary { background: var(--err-bg); border-color: var(--err-line); color: var(--err); }
.quick-fix.reject form { border-color: var(--err-line); }

.entry-meta { display: flex; flex-wrap: wrap; gap: 4px 18px; font-size: 13px; color: var(--muted); }
.entry-meta span { display: inline-flex; align-items: center; gap: 6px; }
.entry-meta svg.i { width: 14px; height: 14px; color: var(--faint); }

/* Быстрые действия со статусом под текстом записи. */
.quick { display: flex; flex-wrap: wrap; gap: 6px; align-items: flex-start; margin: 0 0 10px; }
.quick-fix { flex: 1 1 100%; }
.quick-fix > summary { list-style: none; }
.quick-fix > summary::-webkit-details-marker { display: none; }
.quick-fix[open] > summary { background: var(--ok-bg); border-color: var(--ok-line); color: var(--ok); }
.quick-fix form {
  margin-top: 8px; padding: 12px 14px; border: 1px solid var(--ok-line);
  border-radius: var(--r-ctl); background: var(--raise);
}
.quick-fix label { margin-bottom: 10px; }
.quick-fix textarea { min-height: 64px; }
.quick:has(.quick-fix:not([open])) .quick-fix { flex: 0 0 auto; }

.quick-fix.not-fixed[open] > summary { background: var(--err-bg); border-color: var(--err-line); color: var(--err); }
.quick-fix.not-fixed form { border-color: var(--err-line); }
.quick-fix.not-fixed input[type=date] { max-width: 220px; }

/* Проверенное на этом выезде — приглушено и уходит вниз списка: на виду
   остаётся то, до чего ещё надо дойти. */
.entry.ctl.checked { opacity: .72; }
.entry.ctl.checked:hover { opacity: 1; }
.entry.ctl .pill svg.i { width: 12px; height: 12px; }

/* Выбор фото: крупная кнопка вместо системного «Choose Files», в неё легко
   попасть пальцем. Сам input скрыт, но доступен с клавиатуры и скринридером. */
label.file-pick {
  display: inline-flex; align-items: center; gap: 8px; margin: 0;
  padding: 7px 12px; border: 1px dashed var(--faint); border-radius: var(--r-ctl);
  background: var(--panel); color: var(--muted); cursor: pointer; font-size: 13.5px; position: relative;
}
label.file-pick > span { display: inline; margin: 0; font-size: inherit; color: inherit; font-weight: 500; }
label.file-pick:hover { border-color: var(--accent); color: var(--accent-text); }
label.file-pick input { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; }
label.file-pick:focus-within { outline: 2px solid var(--accent); outline-offset: 2px; }
label.file-pick.has-files { border-style: solid; border-color: var(--accent); color: var(--accent-text); background: var(--accent-soft); }
label.file-pick.big { padding: 12px 16px; margin-bottom: 16px; }
label.file-pick svg.i { width: 18px; height: 18px; }

/* История записи — свёрнута под карточкой. Тихая: открывают её при споре, а не
   каждый день, и она не должна спорить с текстом замечания. */
.hist { margin-top: 8px; }
.hist > summary {
  list-style: none; cursor: pointer; display: inline-flex; align-items: center; gap: 6px;
  font-size: 12.5px; color: var(--faint); padding: 2px 0;
}
.hist > summary::-webkit-details-marker { display: none; }
.hist > summary:hover { color: var(--ink); }
.hist > summary svg.i { width: 14px; height: 14px; }
.hist-body { margin-top: 8px; padding: 10px 14px; background: var(--raise); border-radius: var(--r-ctl); }
.history { list-style: none; margin: 0; padding: 0; }
.history > li { padding: 8px 0; border-top: 1px solid var(--line-soft); font-size: 13.5px; }
.history > li:first-child { border-top: none; padding-top: 0; }
.h-head { display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: baseline; }
.h-head .faint { font-size: 12.5px; }
.h-changes { list-style: none; margin: 4px 0 0; padding: 0; }
.h-changes li { margin-top: 2px; overflow-wrap: anywhere; }
.h-note { margin-top: 2px; color: var(--muted); overflow-wrap: anywhere; }

.entry.editing { border-left-color: var(--accent); padding: 18px 20px; }
.entry.editing h3 { margin-bottom: 14px; }

.files { list-style: none; margin: 0 0 10px; padding: 0; font-size: 13.5px; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
/* Список собирается фильтром по виду файла и бывает пустым — тогда без отступа. */
.files:empty { display: none; }
.files li { display: inline-flex; align-items: center; gap: 6px;
  border: 1px solid var(--line); border-radius: var(--r-ctl); padding: 3px 10px; background: var(--raise); }
.files li a { color: var(--ink); display: inline-flex; align-items: center; gap: 6px; }
.files li svg.i { width: 14px; height: 14px; color: var(--faint); }
.files li .btn { margin-right: -6px; }
.files .lbl { font-size: 12px; color: var(--faint); margin-right: 2px; }

.upload {
  margin-top: 16px; padding: 14px 16px; border: 1px dashed var(--line);
  border-radius: var(--r-card); background: var(--raise);
}
.upload .field-label { margin-bottom: 10px; }
.upload .bar { margin: 0; }
.upload select { width: auto; background-color: var(--panel); }

/* --- Мелочи ---------------------------------------------------------------- */

/* Плашка ошибки HTMX-запроса (static/app.js). Поверх страницы, а не в потоке:
   форма, на которую пришла ошибка, часто в самом низу длинного листа. */
.toast {
  position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%);
  width: min(560px, calc(100vw - 32px)); z-index: 50; cursor: pointer;
}
.toast[hidden] { display: none; }
.toast .alert { margin: 0; box-shadow: var(--shadow-pop); }

.htmx-request .spin, .htmx-request.spin { display: inline; }
.spin { display: none; color: var(--muted); font-size: 13px; }

.login-wrap { max-width: 400px; margin: 12vh auto 40px; padding: 0 16px; }
.login-wrap .brand { justify-content: center; margin-bottom: 22px; }
.login-wrap .panel { padding: 26px 26px 24px; }
.login-wrap h1 { font-size: 24px; }
.login-wrap .sub { margin-bottom: 20px; }

.hit {
  border: 1px solid var(--line); border-radius: var(--r-card);
  padding: 14px 18px; margin-bottom: 10px; background: var(--panel); box-shadow: var(--shadow);
}
.hit .src { font-size: 12.5px; color: var(--faint); display: flex;
  justify-content: space-between; gap: 14px; margin-bottom: 6px; }
.hit .src span:first-child { color: var(--muted); font-weight: 550; }
.hit .text { white-space: pre-wrap; }
.answer {
  background: var(--panel); border: 1px solid var(--line); border-left: 3px solid var(--accent);
  border-radius: var(--r-card); padding: 16px 20px;
  white-space: pre-wrap; margin-bottom: 12px; font-size: 15.5px;
}

.search-box { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.search-box .search-field { max-width: none; flex: 1 1 420px; }
.search-box .search-field input[type=search] { padding-top: 11px; padding-bottom: 11px; font-size: 16px; }

/* Совпадения в выдаче поиска. Фон, а не жирный: жирный в русском тексте
   почти не отличим от обычного на телефоне под солнцем. */
mark { background: var(--warn-bg); color: inherit; border-radius: 3px; padding: 0 2px;
  box-shadow: inset 0 -2px 0 var(--warn-line); }
.hit-where { font-weight: 600; color: var(--ink); }

.steps { margin: 0; padding-left: 20px; color: var(--muted); font-size: 14px; }
.steps li { margin-bottom: 4px; }

/* --- Радар ----------------------------------------------------------------- */

tr.row-late td:first-child { box-shadow: inset 3px 0 0 var(--err); }

.radar-probe { margin: -4px 0 18px; }
.radar-title {
  display: flex; align-items: center; gap: 6px;
  font-size: 12px; font-weight: 600; color: var(--accent-text); margin-bottom: 6px;
}
.radar-title svg.i { width: 14px; height: 14px; }
.radar-panel {
  border: 1px solid var(--line); border-left: 3px solid var(--accent);
  border-radius: var(--r-ctl); background: var(--raise); padding: 10px 14px;
}
.radar-panel p:first-child { margin-top: 0; }
.radar-panel p:last-child { margin-bottom: 0; }
.radar-verdict { margin: 0 0 8px; color: var(--err); }

.radar-list { list-style: none; margin: 0; padding: 0; }
.radar-list li { padding: 10px 0; border-top: 1px solid var(--line); font-size: 14px; }
.radar-list li:first-child { border-top: none; }
.radar-list li.strong .score { background: var(--err-bg); color: var(--err); border-color: var(--err-line); }

.radar-head { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.radar-body { margin-top: 4px; }
.radar-fix { margin-top: 6px; padding-left: 12px; border-left: 2px solid var(--ok-line); color: var(--muted); }
.tag {
  display: inline-block; font-size: 10.5px; font-weight: 650; color: var(--ok);
  text-transform: uppercase; letter-spacing: .06em; margin-right: 7px;
}
.score {
  display: inline-block; min-width: 46px; text-align: center;
  padding: 1px 8px; border-radius: 6px; font-size: 12px; font-weight: 650;
  background: var(--panel); color: var(--muted); border: 1px solid var(--line);
  font-variant-numeric: tabular-nums;
}

.radar-section { scroll-margin-top: 16px; }
.repeat { padding: 14px 18px; border-left: 4px solid var(--err); }
.repeat-head { display: flex; gap: 9px; align-items: center; flex-wrap: wrap; }
.repeat-body { margin: 8px 0 10px; }
.note-text { font-size: 13px; color: var(--faint); margin: 10px 0 0; max-width: 820px; }

/* --- База знаний ------------------------------------------------------------ */

.graph-wrap {
  position: relative;
  /* Доля от высоты окна не годится: над полем ещё шапка страницы, и при
     любой её высоте 70vh уезжают за нижний край — граф приходится
     подкручивать колесом, чтобы увидеть целиком. Считаем остаток. */
  height: calc(100vh - 300px);
  min-height: 380px;
  max-height: 760px;
  border: 1px solid var(--line);
  border-radius: var(--r-card);
  background: var(--panel);
  overflow: hidden;
  margin-bottom: 10px;
  box-shadow: var(--shadow);
}
/* touch-action: none — иначе браузер забирает палец себе: прокручивает
   страницу и масштабирует её щипком, а до графа не доходит ни то, ни другое. */
#graph { width: 100%; height: 100%; display: block; cursor: grab; touch-action: none; }
#graph:active { cursor: grabbing; }

.graph-tip {
  position: absolute; left: 14px; top: 14px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--r-ctl);
  padding: 6px 12px; font-size: 13px;
  pointer-events: none; box-shadow: var(--shadow-pop);
}

/* Легенда — она же фильтр: щелчок убирает вид из графа. Поэтому это кнопки,
   а не подписи, и у выключенной видно, что она выключена. */
.graph-legend {
  position: absolute; right: 12px; bottom: 12px;
  display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end;
  max-width: 70%;
}
.graph-legend .lg {
  display: inline-flex; align-items: center; gap: 7px;
  font: inherit; font-size: 12.5px; line-height: 1;
  padding: 6px 11px; border-radius: var(--r-pill);
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--faint);
  cursor: pointer;
  transition: color .12s, border-color .12s, opacity .12s;
}
.graph-legend .lg:hover { border-color: var(--faint); color: var(--ink); }
.graph-legend .lg.on { color: var(--muted); }
.graph-legend .lg i {
  width: 8px; height: 8px; border-radius: 50%; display: inline-block;
  transition: opacity .12s;
}
.graph-legend .lg:not(.on) { opacity: .55; text-decoration: line-through; }
.graph-legend .lg:not(.on) i { opacity: .3; }

/* Подсказка «что делать мышью». Гаснет, как только мышь оказалась над полем:
   дальше она только мешает смотреть. */
.graph-hint {
  position: absolute; left: 14px; bottom: 14px;
  font-size: 12px; color: var(--faint);
  pointer-events: none;
  transition: opacity .25s;
}
.graph-wrap:hover .graph-hint { opacity: 0; }

/* На телефоне поле занимает не весь экран: граф держит палец, и страницу
   прокручивают за его пределами — над ним и под ним должно оставаться место.
   Легенда уходит наверх в одну прокручиваемую строку: внизу справа она
   закрывала треть графа и подсказку. */
@media (max-width: 600px) {
  .graph-wrap { height: 62vh; min-height: 320px; }
  .graph-legend {
    left: 8px; right: 8px; top: 8px; bottom: auto; max-width: none;
    flex-wrap: nowrap; justify-content: flex-start; overflow-x: auto;
    scrollbar-width: none;
  }
  .graph-legend .lg { flex: 0 0 auto; padding: 8px 11px; }
  .graph-tip { top: auto; bottom: 12px; left: 8px; right: 8px; }
  .graph-hint { left: 10px; right: 10px; bottom: 10px; }
}

.note-group .field-label { margin-bottom: 10px; }
.note-grid { display: flex; flex-wrap: wrap; gap: 8px; }
.note-chip {
  display: block; color: var(--ink);
  border: 1px solid var(--line); border-radius: var(--r-ctl);
  padding: 8px 12px; max-width: 320px;
  background: var(--raise);
}
.note-chip:hover { border-color: var(--faint); text-decoration: none; }
.note-chip b { display: block; font-weight: 500; font-size: 14px; }
.note-chip span { display: block; font-size: 12px; color: var(--faint); margin-top: 1px; }

.props { display: grid; grid-template-columns: auto 1fr; gap: 8px 18px; margin: 0; }
.props dt { font-size: 12.5px; color: var(--faint); padding-top: 2px; }
.props dd { margin: 0; font-weight: 500; overflow-wrap: anywhere; }
.props .pill { margin: 0 4px 4px 0; }

.note-body { line-height: 1.65; }
.note-body h3 { font-size: 17px; margin: 22px 0 8px; }
.note-body h3:first-child { margin-top: 0; }
.note-body h4 { font-size: 15px; margin: 18px 0 6px; color: var(--muted); }
.note-body p { margin: 0 0 10px; }
.note-body ul { margin: 0 0 12px; padding-left: 20px; }
.note-body li { margin-bottom: 4px; }

.two-col { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 18px; align-items: start; }

/* --- Предписание ------------------------------------------------------------ */

.contractor-chip b { display: flex; align-items: center; gap: 6px; }
.contractor-chip b svg.i { width: 15px; height: 15px; color: var(--accent-text); }
.contractor-chip em.late-text { font-style: normal; color: var(--err); }

/* На экране — лист бумаги, при печати — просто лист. Цвета документа заданы
   явно, а не токенами темы: предписание печатают и подписывают, и в тёмной
   теме оно должно выглядеть так же, как на бумаге. */
.doc {
  background: #fff; color: #111; max-width: 820px; margin: 0 auto 40px;
  padding: 48px 56px; border: 1px solid var(--line); border-radius: 4px;
  box-shadow: var(--shadow-pop); font-size: 14.5px; line-height: 1.5;
}
.doc p { margin: 0 0 12px; }
.doc-head { text-align: center; margin-bottom: 22px; }
.doc-title { font-weight: 700; font-size: 18px; letter-spacing: .04em; }
.doc-title .blank { display: inline-block; min-width: 90px; border-bottom: 1px solid #111; }
.doc-sub { margin-top: 2px; }
.doc-date { margin-top: 10px; text-align: right; }
.doc-req { margin: 0 0 16px; }
.doc-req > div { display: grid; grid-template-columns: 110px 1fr; gap: 12px; padding: 3px 0; }
.doc-req dt { color: #555; }
.doc-req dd { margin: 0; font-weight: 600; }
.doc-table { width: 100%; border-collapse: collapse; margin: 6px 0 16px; background: #fff; }
.doc-table th, .doc-table td { border: 1px solid #333; padding: 6px 8px; vertical-align: top; color: #111; background: #fff; }
.doc-table th { font-size: 12.5px; font-weight: 700; text-align: left; white-space: normal; }
.doc-table .n { width: 34px; text-align: center; }
.doc-table .d { width: 104px; white-space: nowrap; }
.doc-ref { font-size: 12px; color: #555; margin-top: 2px; }
.doc-late { font-size: 12px; color: #a40000; font-weight: 700; }
.doc-photos { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.doc-photos img { height: 110px; width: auto; max-width: 180px; object-fit: cover; border: 1px solid #ccc; }
.doc-none { color: #555; font-style: italic; }
.doc-signs { margin-top: 36px; display: grid; gap: 26px; }
.doc-signs .sign { display: grid; grid-template-columns: 200px 1fr; column-gap: 14px; row-gap: 2px; align-items: end; }
.doc-signs .lbl { font-weight: 600; }
.doc-signs .line { border-bottom: 1px solid #111; height: 22px; }
.doc-signs .who { grid-column: 2; font-size: 12px; color: #555; }
/* Отчёт за неделю: разделы, числовые колонки и решение под замечанием. */
.doc-section { font-weight: 700; font-size: 14px; margin: 20px 0 6px; }
.doc-table .c { width: 96px; text-align: center; white-space: nowrap; }
.doc-sum td:first-child { width: auto; }
.doc-fix { font-size: 12.5px; color: #333; margin-top: 3px; }
.doc-ref a { color: inherit; }

@media print {
  @page { size: A4; margin: 15mm 15mm 18mm; }
  /* Тёмная схема красит поля страницы за пределами документа: печатаем
     всегда в светлой, на бумаге другой не бывает. */
  :root, :root[data-theme] {
  color-scheme: light;
  --bg: #f7f6f2;
  --panel: #ffffff;
  --raise: #f1f0eb;
  --side-bg: #ffffff;
  --line: #d9d7cf;
  --line-soft: #eae8e1;
  --control-line: #85867b;
  --hover: #eeede6;
  --ink: #24251f;
  --muted: #66675e;
  --faint: #66675e;
  --accent: #74b5ff;
  --accent-ink: #24251f;
  --accent-soft: #e8f1ff;
  --accent-text: #1e4f9c;
  --accent-hover: #60a5fa;
  --accent-active: #4b95ed;
  --focus: #1e4f9c;
  --disabled-bg: #e8e7df;
  --disabled-ink: #62645a;
  --ok: #236644; --ok-bg: #edf6ee; --ok-line: #abcdb7;
  --warn: #815500; --warn-bg: #fff1d6; --warn-line: #dec18a;
  --info: #225d8a; --info-bg: #eaf1f8; --info-line: #adc8df;
  --err: #b22e25; --err-bg: #fbece9; --err-line: #e5b8b0;
  --k-sheet: #326f9b;
  --k-entry: #6c7163;
  --k-employee: #34794f;
  --k-index: #9c6b16;
  --s-rec: #326f9b;
  --s-res: #2c805f;
  --shadow: 0 1px 2px rgba(36, 37, 31, .04), 0 2px 8px rgba(36, 37, 31, .025);
  --shadow-pop: 0 12px 36px rgba(36, 37, 31, .16);
    color-scheme: light !important;
  }
  .side, .no-print, .toast { display: none !important; }
  html, body { background: #fff !important; }
  .shell { display: block; }
  .work { padding: 0; max-width: none; }
  .doc { border: none; box-shadow: none; padding: 0; margin: 0; max-width: none; font-size: 11.5pt; }
  .doc-table tr { break-inside: avoid; }
  .doc-signs { break-inside: avoid; }
  .doc-section { break-after: avoid; }
}

/* На телефоне лист во всю ширину, а широкая таблица прокручивается внутри
   себя и не сдвигает страницу. Только screen: печать идёт на ширину листа. */
@media screen and (max-width: 700px) {
  .page-head .actions { flex: 1 1 100%; }
  .doc { padding: 20px 16px; }
  .doc-table { display: block; overflow-x: auto; }
  .doc-req > div { grid-template-columns: 1fr; gap: 0; }
  .doc-signs .sign { grid-template-columns: 1fr; }
  .doc-signs .who { grid-column: 1; }
}

/* --- Дашборд ---------------------------------------------------------------- */

.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.filter-inline { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.filter-inline select { min-width: 220px; max-width: 100%; }

/* Диаграммы и карточки — в dashboard.css, загружаемом только на дашборде. */
@media (min-width: 961px) { .filter-inline { flex-wrap: nowrap; } }

/* --- Голосовой черновик ------------------------------------------------------- */

.voice { margin: -6px 0 14px; }
.voice-draft { margin-top: 8px; padding: 10px 12px; border: 1px dashed var(--line);
  border-radius: var(--r-ctl); background: var(--raise); }
.voice-state { display: block; color: var(--muted); margin-bottom: 4px; }
.voice-state.err { color: var(--err); }
.voice-text { margin: 0 0 10px; white-space: pre-wrap; min-height: 1.5em; }
.voice-draft .bar { margin: 0; }

/* --- Журнал ----------------------------------------------------------------- */

.journal-view { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.seg-links { margin: 0; }
.seg-links a { display: inline-block; padding: 6px 12px; border-radius: 7px; color: var(--muted); font-size: 13.5px; }
.seg-links a:hover { color: var(--ink); text-decoration: none; }
.seg-links a[aria-current] { background: var(--panel); color: var(--ink); box-shadow: var(--shadow), inset 0 0 0 1px var(--line); }

.journal-search { display: flex; align-items: center; gap: 10px; background: var(--panel);
  border: 1px solid var(--line); border-radius: var(--r-card); padding: 6px 6px 6px 14px;
  margin-bottom: 16px; box-shadow: var(--shadow); color: var(--faint); }
.journal-search input[type=search] { flex: 1; border: none; background: transparent; padding: 6px 0;
  font: inherit; color: var(--ink); min-width: 0; }
.journal-search input[type=search]:focus { outline: none; }
.journal-search:focus-within { border-color: var(--accent); }

.journal-layout { display: grid; grid-template-columns: 250px minmax(0, 1fr); gap: 20px; align-items: start; }
.journal-main { min-width: 0; }

.facets { position: sticky; top: 16px; max-height: calc(100vh - 32px); overflow-y: auto;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-card);
  padding: 4px 0 10px; box-shadow: var(--shadow); }
.facets > summary { list-style: none; display: flex; align-items: center; gap: 8px; padding: 10px 14px;
  font-weight: 600; cursor: pointer; }
.facets > summary::-webkit-details-marker { display: none; }
.facet { padding: 6px 8px 4px; border-top: 1px solid var(--line-soft); }
.facet h3 { font-size: 11.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em;
  color: var(--faint); margin: 4px 6px 4px; }
.facet-item { display: flex; align-items: center; gap: 8px; padding: 5px 6px; border-radius: 7px;
  color: var(--ink); font-size: 13.5px; line-height: 1.3; }
.facet-item:hover { background: var(--hover); text-decoration: none; }
.facet-item span { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.facet-item b { font-weight: 500; color: var(--faint); font-size: 12.5px; font-variant-numeric: tabular-nums; }
.facet-item .box { width: 14px; height: 14px; flex: 0 0 14px; border: 1.5px solid var(--faint); border-radius: 4px; }
.facet-item.radio .box { border-radius: 50%; }
.facet-item.on { background: var(--accent-soft); }
.facet-item.on .box { border-color: var(--accent); background: var(--accent);
  box-shadow: inset 0 0 0 2px var(--panel); }
.facet-item .dot { width: 8px; height: 8px; border-radius: 50%; flex: 0 0 8px; }

.chips { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; min-height: 32px; }
.chips-count { color: var(--muted); font-size: 14px; margin-right: 4px; }
.chips-count { color: var(--ink); font-weight: 550; font-variant-numeric: tabular-nums; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 6px 4px 10px; border-radius: var(--r-pill);
  background: var(--raise); border: 1px solid var(--line); color: var(--ink); font-size: 13px; }
.chip small { color: var(--faint); font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em; }
.chip svg.i { width: 14px; height: 14px; flex-basis: 14px; color: var(--faint); }
.chip:hover { border-color: var(--faint); text-decoration: none; }

.journal-table td { font-size: 14px; }
.journal-table .j-text { min-width: 12em; width: 40%; }
.journal-table th, .journal-table td { padding: 10px 12px; }
@media (max-width: 1500px) { .hide-md { display: none; } }
@media (max-width: 1100px) { .hide-tab { display: none; } }
/* Подсказки «что делать мышью» и «что делать пальцем». По наличию наведения,
   а не по ширине окна: планшет широкий, а мыши у него всё равно нет. */
.only-touch { display: none; }
@media (hover: none) and (pointer: coarse) {
  .only-mouse { display: none; }
  .only-touch { display: revert; }
}

/* --- Кран ------------------------------------------------------------------
   Сам план рисует scene.css (общий с отчётом для пересылки); здесь — только
   то, что вокруг него на странице журнала. */
.cr-desk { margin: 18px 0 28px; }
.cr-variants { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; margin-bottom: 12px; }
.cr-var { flex: 0 0 auto; min-width: 150px; display: flex; flex-direction: column; gap: 1px; padding: 9px 13px;
  border: 1px solid var(--line); border-radius: var(--r-card); background: var(--panel); color: var(--ink); box-shadow: var(--shadow); }
.cr-var:hover { text-decoration: none; border-color: var(--faint); }
.cr-var b { font-size: 14px; }
.cr-var-n { font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em; color: var(--faint); font-weight: 600; }
.cr-var-cost { font-variant-numeric: tabular-nums; font-weight: 600; margin-top: 3px; }
.cr-var.no .cr-var-cost { color: var(--err); }
.cr-var.on { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
.cr-var.own { border-style: dashed; }

.cr-stage { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 14px; align-items: start; }
@media (max-width: 1180px) { .cr-stage { grid-template-columns: 1fr; } }
.cr-view { margin: 0; position: relative; padding: 12px; }
.cr-bar { display: flex; flex-wrap: wrap; gap: 8px 14px; align-items: center; margin-bottom: 10px; }
.cr-bar .tabs { margin: 0; }
.cr-bar .grow { flex: 1; }
.cr-layer { display: inline-flex; align-items: center; gap: 5px; margin: 0; font-size: 13px; color: var(--muted); cursor: pointer; }
.cr-layer input { margin: 0; }
.cr-view[data-view="3d"] .cr-2d-only, .cr-view[data-view="2d"] .cr-3d-only { display: none; }
.cr-speed { display: inline-flex; align-items: center; gap: 4px; margin: 0; }
.cr-speed > span { margin: 0; font-size: 13px; color: var(--muted); }
/* Справа место под стрелку: общий стиль select рисует её фоном, и с
   отступом в 6px она ложилась поверх цифр. */
.cr-speed select { width: auto; padding: 4px 26px 4px 8px; background-position: right 14px center, right 9px center; }
.cr-canvas { position: relative; height: min(70vh, 680px); min-height: 380px; border-radius: 10px; overflow: hidden;
  background: linear-gradient(#cfe2f3, #eef3f6); touch-action: none; }
.cr-canvas canvas { display: block; width: 100%; height: 100%; }
.cr-canvas.drag canvas { cursor: grabbing; }
/* На телефоне сцена держит палец (поворот, щипок), и страницу листают только
   за её пределами. При 70% высоты экрана места для этого не оставалось —
   страница будто застревала на сцене. Ширина ограничивает высоту, чтобы
   сцена не была вытянутой вверх полосой: в ней не видно площадки по бокам. */
@media (max-width: 600px) {
  .cr-canvas { height: min(56vh, 115vw); min-height: 300px; }
}
.cr-hud { position: absolute; left: 12px; bottom: 12px; max-width: calc(100% - 24px); padding: 6px 11px; border-radius: 8px;
  background: rgba(20, 18, 15, .72); color: #fff; font-size: 13px; pointer-events: none; }
.cr-hud:empty { display: none; }
.cr-2d .cr-plan { cursor: crosshair; }
.cr-2d .cr-grip { cursor: grab; }
.cr-2d.drag .cr-plan, .cr-2d.drag .cr-grip { cursor: grabbing; }
.cr-2d.drag #cr-hit { display: none; }
.cr-heatnote { margin: 10px 2px 0; }
.cr-hint { margin: 6px 2px 0; }
.cr-tip {
  position: absolute; pointer-events: none; z-index: 5; padding: 5px 9px; border-radius: 7px;
  background: var(--ink); color: var(--panel); font-size: 12.5px; white-space: nowrap; box-shadow: var(--shadow-pop);
}
.cr-busy .cr-insp { opacity: .7; transition: opacity .2s .15s; }

.cr-insp { padding: 16px; position: sticky; top: 12px; max-height: calc(100vh - 24px); overflow-y: auto; }
.cr-insp h2 { margin: 2px 0 8px; font-size: 21px; }
.cr-insp h3 { font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--faint); margin: 0 0 8px; font-weight: 650; }
.cr-kind { font-size: 12px; color: var(--muted); }
.cr-jibs { display: flex; flex-wrap: wrap; gap: 4px; }
.cr-jibs a { padding: 3px 10px; border: 1px solid var(--line); border-radius: var(--r-pill); font-size: 13px; color: var(--muted); }
.cr-jibs a:hover { text-decoration: none; color: var(--ink); border-color: var(--faint); }
.cr-jibs a.on { background: var(--ink); border-color: var(--ink); color: var(--panel); }
.cr-verdict { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; margin: 14px 0 10px; padding: 10px 12px; border-radius: 10px; }
.cr-verdict b { font-size: 17px; }
.cr-verdict span { font-size: 13px; color: var(--muted); }
.cr-verdict.ok { background: var(--ok-bg); } .cr-verdict.ok b { color: var(--ok); }
.cr-verdict.bad { background: var(--err-bg); } .cr-verdict.bad b { color: var(--err); }
.cr-nums { display: grid; grid-template-columns: repeat(auto-fit, minmax(104px, 1fr)); gap: 8px; margin: 0 0 14px; }
.cr-nums div { padding: 8px 10px; border: 1px solid var(--line-soft); border-radius: 9px; background: var(--raise); }
.cr-nums dt { font-size: 12px; color: var(--muted); }
.cr-nums dd { margin: 2px 0 0; font-weight: 650; font-variant-numeric: tabular-nums; white-space: nowrap; font-size: 15px; }
.cr-nums .good dd { color: var(--ok); } .cr-nums .worse dd { color: var(--err); }
.cr-block { margin: 0 0 16px; }
.cr-problems { margin: 0; padding-left: 18px; color: var(--err); font-size: 14px; }
.cr-flags { margin: 0; padding-left: 18px; color: var(--warn); font-size: 14px; }
.cr-lifts { list-style: none; margin: 0; padding: 0; }
.cr-lifts li { display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; padding: 6px 4px; border-radius: 7px; font-size: 13.5px; cursor: default; }
.cr-lifts li.hl { background: var(--hover); }
.cr-lname { display: flex; align-items: center; min-width: 0; }
.cr-lload { font-variant-numeric: tabular-nums; color: var(--muted); }
.cr-lbar { grid-column: 1 / -1; height: 4px; border-radius: 2px; background: var(--line-soft); overflow: hidden; }
.cr-lbar i { display: block; height: 100%; }
.cr-lwhy { grid-column: 1 / -1; font-size: 12.5px; color: var(--err); }
.cr-lbar i.ok { background: var(--cr-ok); } .cr-lbar i.high { background: var(--cr-high); }
.cr-lbar i.limit { background: var(--cr-limit); } .cr-lbar i.fail { background: var(--cr-fail); width: 100% !important; }
.cr-costs summary { cursor: pointer; font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--faint); font-weight: 650; }
.cr-mini { width: 100%; font-size: 13px; margin-top: 6px; }
.cr-mini td, .cr-mini th { padding: 4px 6px; }
.cr-mini .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.cr-where { display: flex; gap: 8px; align-items: flex-end; border-top: 1px solid var(--line-soft); padding-top: 12px; }
.cr-where label { margin: 0; }
.cr-where input[type=text] { width: 5.5em; }

.cr-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; margin-bottom: 24px; }
.cr-card { border: 1px solid var(--line); border-radius: var(--r-card); background: var(--panel); box-shadow: var(--shadow); padding: 12px 12px 8px; }
.cr-card.on { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
.cr-card header { display: flex; flex-direction: column; gap: 2px; margin-bottom: 8px; }
.cr-card ul { list-style: none; margin: 0; padding: 0; }
.cr-jibrow { display: grid; grid-template-columns: 48px 1fr; gap: 0 10px; padding: 7px 8px; border-radius: 8px; color: var(--ink); }
.cr-jibrow:hover { background: var(--hover); text-decoration: none; }
.cr-jibrow.on { background: var(--accent-soft); }
.cr-jibm { grid-row: span 2; font-weight: 650; font-variant-numeric: tabular-nums; align-self: center; }
.cr-fit { color: var(--ok); }
.cr-jibrow.no .cr-fit { color: var(--muted); }
/* Между телефоном и широким экраном фильтры встают над таблицей: сбоку они
   оставляют таблице меньше половины ширины. */
@media (max-width: 1360px) {
  .journal-layout { grid-template-columns: 1fr; gap: 12px; }
  .facets { position: static; max-height: none; }
}
.show-sm { display: none; }
.journal-table.detailed td { vertical-align: top; }
.journal-table .entry-fix { margin-top: 6px; }
tr.link.selected td { background: var(--accent-soft); }

.pager { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 12px; }
.pager .grow { flex: 1; }

/* Панель записи справа поверх журнала. */
dialog.drawer { margin: 0 0 0 auto; height: 100%; max-height: none; width: min(560px, 100vw);
  border: none; border-left: 1px solid var(--line); padding: 0; background: var(--panel); color: var(--ink);
  box-shadow: var(--shadow-pop); display: none; flex-direction: column; }
dialog.drawer[open] { display: flex; }
dialog.drawer::backdrop { background: rgba(20, 18, 15, .35); }
.drawer-head { display: flex; align-items: center; gap: 4px; padding: 12px 14px 12px 20px;
  border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--panel); }
.drawer-head .grow { flex: 1; }
.drawer-body { padding: 18px 20px 28px; overflow-y: auto; flex: 1; }
.je-where { margin: 0 0 10px; }
.je .field-label { margin: 14px 0 4px; }
.je-facts { margin: 16px 0; grid-template-columns: repeat(2, minmax(0, 1fr)); }

/* --- Узкий экран ------------------------------------------------------------ */

@media (max-width: 960px) {
  .shell { flex-direction: column; }
  .side {
    width: auto; flex: none; height: auto; position: sticky; top: 0; z-index: 30;
    border-right: none; border-bottom: 1px solid var(--line);
    padding: 10px 14px; gap: 0;
  }
  .side .menu-btn { display: inline-flex; }
  /* Меню на телефоне свёрнуто: иначе список объектов и пункты меню занимают
     весь первый экран, и до самой страницы надо листать. */
  .side-body { display: none; padding-top: 14px; max-height: calc(100vh - 60px); overflow-y: auto; }
  .side.open .side-body { display: flex; }
  .side-list { max-height: 260px; flex: none; }
  .work { padding: 20px 16px 60px; }
  h1 { font-size: 25px; }
  .grid2, .grid3 { grid-template-columns: 1fr; }
  .two-col { grid-template-columns: 1fr; }
  th, td { padding: 10px 12px; }
  .hide-sm, .fold > summary small { display: none; }
  .show-sm { display: block; margin-top: 6px; }
  .journal-view { width: 100%; }

}

/* ── Зимний бетон ─────────────────────────────────────────────────────────
   Форма — плоскими разделами, результат — таблица сравнения, проверки и
   картинки. Цвета температуры живут в winter.js: шкала там и считается. */
.wc-form fieldset { border: 1px solid var(--line); margin: 0 0 16px; min-width: 0; }
.wc-form legend { font-weight: 600; padding: 0 6px; }
.wc-form fieldset.wc-face { border: 1px dashed var(--line); border-radius: var(--r-ctl); padding: 12px 14px 0; }
.wc-checks { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }
.wc-checks label.check { margin: 0; }
.wc-variant { border-top: 1px solid var(--line-soft); padding-top: 14px; margin-top: 6px; }
.wc-variant-head { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 10px; }
.wc-variant-head label.check { margin: 0; }
.wc-variant-head label.check:first-child { font-weight: 600; }

.pill.risk-green  { background: var(--ok-bg);   color: var(--ok);   border-color: var(--ok-line); }
.pill.risk-yellow { background: var(--warn-bg); color: var(--warn); border-color: var(--warn-line); }
.pill.risk-red    { background: var(--err-bg);  color: var(--err);  border-color: var(--err-line); }
.wc-table td { vertical-align: top; }
.wc-table tr.row-off td { color: var(--muted); }
.wc-advice p { margin: 0 0 8px; }
.wc-advice p:first-of-type { font-weight: 550; }
.wc-detail summary { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; cursor: pointer; }
.wc-detail[open] summary { margin-bottom: 12px; }
.wc-checks-list { list-style: none; padding: 0; margin: 0 0 14px; }
.wc-checks-list li { display: flex; gap: 8px; padding: 5px 0; border-bottom: 1px solid var(--line-soft); font-size: 13px; }
.wc-checks-list li b { width: 14px; flex: 0 0 auto; text-align: center; }
.wc-checks-list li.ok b { color: var(--ok); }
.wc-checks-list li.bad { color: var(--err); }
.wc-checks-list li.adv b { color: var(--warn); }
.wc-checks-list small { display: block; }
.wc-cost { margin: 0 0 12px; padding-left: 18px; font-size: 13px; }

.wc-viz-head { display: flex; gap: 12px 18px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
.wc-viz-head .seg { margin: 0; }
.wc-time { display: flex; gap: 10px; align-items: center; flex: 1 1 320px; min-width: 0; }
.wc-time input[type=range] { flex: 1 1 auto; min-width: 120px; accent-color: var(--accent); }
.wc-time output { font-size: 13px; color: var(--muted); min-width: 15em; }
.wc-viz-grid { display: grid; grid-template-columns: minmax(0, 1fr) 240px; gap: 18px; }
.wc-canvas { display: block; width: 100%; background: var(--raise); border-radius: var(--r-ctl); touch-action: pan-y; }
.wc-canvas.short { height: 130px; }
.wc-canvas.tall { height: 240px; cursor: crosshair; }
/* Профиль занимает столбец под своей подписью, не больше. Холст — абсолютно в
   обёртке: высота «100 %» самого холста считалась от всего столбца, и он
   вылезал из блока на высоту подписи, а размер, который скрипт выставляет
   холсту, не должен влиять на раскладку — иначе блок растёт от перерисовки. */
.wc-viz-side { display: flex; flex-direction: column; min-width: 0; }
.wc-profile-box { position: relative; flex: 1 1 auto; min-height: 300px; }
.wc-canvas.side { position: absolute; inset: 0; width: 100%; height: 100%; }
.wc-cap { font-size: 12px; color: var(--faint); margin: 10px 0 5px; }
.wc-cap:first-child { margin-top: 0; }
.wc-scale { height: 22px; margin-top: 4px; position: relative; font-size: 11px; color: var(--faint); }
.wc-scale span { position: absolute; top: 10px; transform: translateX(-50%); }
.wc-scale::before { content: ""; position: absolute; inset: 0 0 auto; height: 8px; border-radius: 4px; background: var(--wc-gradient, var(--line)); }
@media (max-width: 860px) {
  .wc-viz-grid { grid-template-columns: 1fr; }
  .wc-profile-box { min-height: 240px; }
  .wc-time output { min-width: 0; }
}
.dot.late { background: var(--err); }
.wc-mark { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin: 0 3px 0 6px; vertical-align: middle; }
.wc-mark.warn { background: var(--warn); }
.wc-mark.ok { background: var(--ok); }
.wc-mark.err { background: var(--err); }
@media (max-width: 600px) {
  .wc-time { flex-wrap: wrap; }
  .wc-time output { flex-basis: 100%; }
}

/* Черновик ТК: тот же лист, что у предписания, плюс журнал контроля —
   широкая таблица с пустыми графами под замеры. */
.wc-doc h3.wc-doc-h { font-size: 15px; margin: 22px 0 6px; color: #111; }
.wc-doc-table th { width: 34%; }
.wc-doc-list { margin: 0 0 12px; padding-left: 20px; }
.wc-fill { display: inline-block; width: 70%; border-bottom: 1px solid #111; height: 1.2em; }
.wc-journal th, .wc-journal td { font-size: 11.5px; padding: 3px 5px; }
.wc-journal td:nth-child(n+7) { min-width: 52px; }
@media print {
  .wc-doc h3.wc-break { break-before: page; }
  .wc-journal tr { break-inside: avoid; }
}

/* --- Конструктор площадки крана ------------------------------------------
   План рисуется SVG в экранных пикселях: толщина линий и подписи одинаковы
   при любом масштабе. Цвета зон — те же, что в 3D и на плане расчёта:
   красный — над этим не носить, жёлтый — предупредить, коричневая штриховка —
   кран не ставить. */
.warn-text { color: var(--warn); }
.ok-text { color: var(--ok); }
.ce { --ce-site: #efe7d4; --ce-bld: #d9dee8; --ce-bld-line: #56607a; --ce-grid: rgba(22, 50, 81, .06); --ce-grid2: rgba(22, 50, 81, .13);
  --ce-plan-bg: #ffffff; --ce-excl: #8d6e63; --ce-forb: #e53935; --ce-warn: #f9a825; --ce-ppr: #6b7280; }

.ce-head { display: flex; flex-wrap: wrap; gap: 10px 12px; align-items: center; margin: 4px 0 14px; }
.ce-name { flex: 1 1 320px; margin: 0; }
.ce-name input { font-size: 22px; font-weight: 650; padding: 8px 12px; border-color: transparent; background: transparent; }
.ce-name input:hover { border-color: var(--line); }
.ce-name input:focus { border-color: var(--accent); background: var(--panel); }
.ce-object { margin: 0; flex: 0 1 260px; }
.ce-actions { display: flex; gap: 8px; margin-left: auto; }
.ce-actions .busy { opacity: .8; cursor: progress; }

.ce-steps { list-style: none; display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 6px; margin: 0 0 12px; padding: 0; }
.ce-steps button { width: 100%; display: flex; gap: 9px; align-items: center; text-align: left; padding: 8px 10px; border: 1px solid var(--line);
  border-radius: 10px; background: var(--panel); color: var(--ink); cursor: pointer; font: inherit; }
.ce-steps button:hover { border-color: var(--faint); }
.ce-steps i { flex: 0 0 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; font-style: normal; font-size: 12.5px;
  font-weight: 700; background: var(--raise); color: var(--muted); border: 1px solid var(--line); }
.ce-steps span { display: flex; flex-direction: column; min-width: 0; font-size: 13.5px; font-weight: 600; line-height: 1.2; }
.ce-steps small { font-weight: 400; color: var(--muted); font-size: 11.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ce-steps [data-state="done"] i { background: var(--ok); border-color: var(--ok); color: #fff; font-size: 0; }
.ce-steps [data-state="done"] i::before { content: "✓"; font-size: 13px; }
.ce-steps [data-state="warn"] i { background: var(--warn-bg); border-color: var(--warn-line); color: var(--warn); }
.ce-steps [data-state="ready"] button { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
.ce-steps [data-state="ready"] i { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.ce-steps [data-state="skip"] { opacity: .85; }

.ce-err { margin: 0 0 12px; padding: 10px 14px; border-radius: 10px; background: var(--err-bg); border: 1px solid var(--err-line); color: var(--err); font-size: 14px; }
.ce-err.info { background: var(--info-bg); border-color: var(--info-line); color: var(--ink); }
.ce-err .btn { margin-left: 6px; }

.ce-stage { display: grid; grid-template-columns: 76px minmax(0, 1fr) 380px; gap: 12px; align-items: start; }
.ce-tools { display: flex; flex-direction: column; gap: 4px; position: sticky; top: 12px; padding: 6px; border: 1px solid var(--line);
  border-radius: 12px; background: var(--panel); box-shadow: var(--shadow); }
.ce-tools button, .ce-file { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 7px 2px 6px; border: 1px solid transparent;
  border-radius: 9px; background: transparent; color: var(--muted); font: inherit; font-size: 10.5px; line-height: 1.1; cursor: pointer; margin: 0; text-align: center; }
.ce-tools svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.ce-tools button:hover, .ce-file:hover { background: var(--hover); color: var(--ink); }
.ce-tools button.on { background: var(--accent-soft); color: var(--accent-text); border-color: var(--accent); }
.ce-tools hr { border: 0; border-top: 1px solid var(--line); margin: 4px 2px; }
.ce-file { position: relative; overflow: hidden; }
.ce-file input { position: absolute; left: 0; top: 0; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.ce-file:focus-within { outline: 2px solid var(--accent); }

.ce-view { margin: 0; padding: 10px; }
.ce-bar { display: flex; flex-wrap: wrap; gap: 6px 12px; align-items: center; margin-bottom: 8px; }
.ce-bar .tabs { margin: 0; }
.ce-bar .grow { flex: 1; }
.ce-bar input[type="range"] { width: 90px; vertical-align: middle; padding: 0; }
.ce:not(.has-under) .ce-under-only, .ce-view[data-view="3d"] .ce-plan-only { display: none; }
.ce-canvas { position: relative; height: max(420px, min(calc(100vh - 300px), 820px)); border-radius: 10px; overflow: hidden;
  background: var(--ce-plan-bg); border: 1px solid var(--line-soft); touch-action: none; user-select: none; -webkit-user-select: none; }
.ce-canvas > svg { display: block; width: 100%; height: 100%; cursor: crosshair; }
.ce-canvas[data-tool="select"] > svg { cursor: default; }
.ce-canvas[data-tool="move-underlay"] > svg, .ce-canvas.pan > svg { cursor: grab; }
.ce-3d { position: absolute; inset: 0; height: auto; min-height: 0; border-radius: 0; }
.ce-hint { position: absolute; left: 10px; bottom: 10px; max-width: min(620px, calc(100% - 200px)); padding: 5px 10px; border-radius: 8px; line-height: 1.35;
  background: color-mix(in srgb, var(--panel) 88%, transparent); border: 1px solid var(--line); font-size: 12.5px; color: var(--muted);
  pointer-events: none; box-shadow: var(--shadow); }
.ce-hint { transition: opacity .4s; }
.ce-hint.faded { opacity: 0; }
.ce-hint:empty, .ce-view[data-view="3d"] .ce-hint, .ce-view[data-view="3d"] .ce-coords { display: none; }
.ce-coords { position: absolute; right: 10px; top: 10px; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums;
  background: color-mix(in srgb, var(--panel) 80%, transparent); padding: 2px 8px; border-radius: 6px; pointer-events: none; }
.ce-coords:empty { display: none; }
.ce-ask, .ce-pdf { position: absolute; right: 12px; top: 12px; width: 280px; padding: 12px; border-radius: 12px; background: var(--panel);
  border: 1px solid var(--line); box-shadow: var(--shadow-pop); z-index: 3; }
.ce-ask label { margin: 0 0 8px; }
.ce-pdf p { margin: 0 0 8px; font-size: 14px; }
.ce-pdf input { width: 70px; }

/* SVG плана */
.ce-g1 { stroke: var(--ce-grid); stroke-width: 1; fill: none; }
.ce-g2 { stroke: var(--ce-grid2); stroke-width: 1; fill: none; }
.ce-g0 { stroke: var(--faint); stroke-width: 1; stroke-dasharray: 4 4; opacity: .5; fill: none; }
.ce-gl { font-size: 10px; fill: var(--faint); }
.ce-scalebar path { stroke: var(--ink); stroke-width: 1.5; fill: none; }
.ce-scalebar text { font-size: 11px; fill: var(--ink); text-anchor: middle; }
.ce-bound { fill: var(--ce-site); fill-opacity: .55; stroke: var(--ink); stroke-width: 2; stroke-dasharray: 9 4; }
.ce-bld { fill: var(--ce-bld); fill-opacity: .9; stroke: var(--ce-bld-line); stroke-width: 1.6; }
/* Над генпланом заливки почти прозрачные: обводят по чертежу, его должно быть видно. */
.ce.has-under .ce-bound { fill-opacity: .1; }
.ce.has-under .ce-bld { fill-opacity: .45; }
.ce.has-under .ce-sens { fill-opacity: .1; }
.ce-excl { stroke: var(--ce-excl); stroke-width: 1.5; fill-opacity: 1; }
.ce-hatch { stroke: var(--ce-excl); stroke-width: 2; opacity: .55; }
.ce-sens { stroke-width: 1.5; stroke-dasharray: 6 3; }
.ce-sens.forb { fill: var(--ce-forb); fill-opacity: .15; stroke: var(--ce-forb); }
.ce-sens.warn { fill: var(--ce-warn); fill-opacity: .18; stroke: var(--ce-warn); }
.ce-canvas[data-tool="select"] [data-k] { cursor: move; }
[data-k].hov { stroke-width: 2.4; filter: brightness(1.03); }
[data-k].on { stroke: var(--accent); stroke-width: 2.6; stroke-dasharray: none; }
.ce-lbl { font-size: 13px; font-weight: 650; text-anchor: middle; fill: var(--ink); paint-order: stroke; stroke: var(--ce-plan-bg); stroke-width: 3.5px; pointer-events: none; }
.ce-lbl.forb { fill: #b3261e; } .ce-lbl.warn { fill: #8a5a00; } .ce-lbl.excl { fill: var(--ce-excl); font-weight: 600; }
.ce-sub { font-size: 11.5px; text-anchor: middle; fill: var(--muted); paint-order: stroke; stroke: var(--ce-plan-bg); stroke-width: 3px; pointer-events: none; }
.ce-len { font-size: 11.5px; font-weight: 600; text-anchor: middle; fill: var(--accent-text); paint-order: stroke; stroke: var(--ce-plan-bg); stroke-width: 3px; pointer-events: none; }
.ce-vtx { fill: var(--panel); stroke: var(--accent); stroke-width: 2; cursor: grab; }
.ce-vtx:hover { fill: var(--accent); }
.ce-mid { fill: var(--accent); fill-opacity: .35; stroke: var(--accent); stroke-width: 1; cursor: copy; }
.ce-mid:hover { fill-opacity: .9; }
.ce-draft { fill: var(--accent); fill-opacity: .08; stroke: var(--accent); stroke-width: 2; stroke-dasharray: 6 4; pointer-events: none; }
.ce-dpt { fill: var(--panel); stroke: var(--accent); stroke-width: 2; pointer-events: none; }
.ce-dpt.close { fill: var(--accent); }
.ce-snapmark { fill: none; stroke: var(--accent); stroke-width: 2; pointer-events: none; }
.ce-scale { stroke: var(--err); stroke-width: 2; stroke-dasharray: 5 3; }
.ce-lift { fill: var(--muted); fill-opacity: .7; stroke: var(--ce-plan-bg); stroke-width: 1; }
.ce-sup rect { fill: #a77b4a; stroke: #6b4a26; stroke-width: 1.5; }
.ce-sup text { font-size: 11.5px; font-weight: 600; text-anchor: middle; fill: var(--ink); paint-order: stroke; stroke: var(--ce-plan-bg); stroke-width: 3px; }
.ce-sup.on rect { stroke: var(--accent); stroke-width: 3; }
.ce-rpt path { fill: var(--accent); fill-opacity: .8; stroke: var(--panel); stroke-width: 1.5; }
.ce-rpt.on path { fill: var(--accent); stroke: var(--ink); }
.ce-ppr rect { fill: var(--ce-ppr); stroke: var(--ink); stroke-width: 1; }
.ce-ppr-r { fill: var(--ce-ppr); fill-opacity: .05; stroke: var(--ce-ppr); stroke-width: 1.4; stroke-dasharray: 8 5; }
.ce-ppr text { font-size: 12px; fill: var(--ink); paint-order: stroke; stroke: var(--ce-plan-bg); stroke-width: 3px; }
.ce-ppr.on rect { stroke: var(--accent); stroke-width: 3; }

/* Боковая панель */
.ce-side { padding: 12px 14px 14px; position: sticky; top: 12px; max-height: calc(100vh - 24px); overflow-y: auto; }
.ce-sidetabs { display: flex; margin: 0 0 12px; }
.ce-sidetabs a { flex: 1; text-align: center; padding: 6px 8px; font-size: 13.5px; }
.ce-sidetabs b { display: inline-block; min-width: 18px; padding: 0 5px; border-radius: 9px; background: var(--accent-soft); color: var(--accent-text); font-size: 11.5px; }
.ce-sidetabs b:empty { display: none; }
.ce-pane h3 { font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--faint); margin: 14px 0 8px; font-weight: 650; }
.ce-pane h3:first-child, .ce-itemhead + h3 { margin-top: 2px; }
.ce-pane label { margin: 0 0 9px; }
.ce-pane label > span { font-size: 12.5px; }
.ce-pane input, .ce-pane select { padding: 6px 9px; font-size: 14px; }
.ce-pane input.bad { border-color: var(--err); background: var(--err-bg); }
.ce-grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 10px; }
.ce-grid3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 0 8px; }
.ce-range { display: flex; align-items: center; gap: 4px; }
.ce-range input { min-width: 0; }
.ce-itemhead { display: flex; justify-content: space-between; margin: -4px -6px 6px; }
.ce-list { list-style: none; margin: 0 0 10px; padding: 0; display: flex; flex-direction: column; gap: 3px; }
.ce-list button, .ce-list li > span { width: 100%; display: flex; flex-direction: column; align-items: flex-start; padding: 7px 10px; border: 1px solid var(--line-soft);
  border-radius: 9px; background: var(--raise); font: inherit; color: var(--ink); cursor: pointer; text-align: left; }
.ce-list button:hover { border-color: var(--faint); }
.ce-list b { font-size: 14px; font-weight: 600; }
.ce-list small { color: var(--muted); font-size: 12.5px; }
.ce-lifts li { display: flex; gap: 4px; align-items: center; }
.ce-lifts li > span { cursor: default; flex: 1; }
.ce-rule { border: 1px solid var(--line); border-radius: 10px; margin: 0 0 8px; background: var(--panel); }
.ce-rule > summary { list-style: none; cursor: pointer; padding: 9px 12px; display: flex; flex-direction: column; }
.ce-rule > summary::-webkit-details-marker { display: none; }
.ce-rule > summary b { font-size: 14px; }
.ce-rule > summary small { color: var(--muted); font-size: 12.5px; }
.ce-rule[open] { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
.ce-rule[open] > summary { border-bottom: 1px solid var(--line-soft); margin-bottom: 10px; }
.ce-rule > :not(summary) { margin-left: 12px; margin-right: 12px; }
.ce-rule > .bar { margin-bottom: 10px; }
.ce-more { margin: 2px 0 8px; }
.ce-more > summary { cursor: pointer; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.ce-add { width: 100%; }
.ce-addrow { margin: 10px 0 4px; }
.ce-coordsbox { margin-top: 10px; }
.ce-coordsbox summary { cursor: pointer; font-size: 13px; color: var(--muted); }
.ce-coordsbox table { width: 100%; margin-top: 6px; border-collapse: collapse; }
.ce-coordsbox th { font-size: 12px; color: var(--faint); font-weight: 500; width: 22px; text-align: right; padding-right: 6px; }
.ce-coordsbox td { padding: 2px; }
.ce-prices { width: 100%; border-collapse: collapse; margin: 6px 0 10px; font-size: 13px; }
.ce-prices th { text-align: left; font-weight: 500; padding: 3px 4px; }
.ce-prices thead th { color: var(--faint); font-size: 12px; }
.ce-prices td { padding: 2px; }
.ce-prices input { width: 100%; text-align: right; font-variant-numeric: tabular-nums; }
.ce-summary { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); }
.ce-summary .cr-nums { margin-bottom: 8px; }
.ce-keys { margin-top: 14px; }
.ce-foot { margin: 12px 2px 0; max-width: 980px; }

@media (max-width: 1280px) {
  .ce-stage { grid-template-columns: 70px minmax(0, 1fr); }
  .ce-side { grid-column: 1 / -1; position: static; max-height: none; }
  .ce-steps { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
.ce-stage > * { min-width: 0; }
@media (max-width: 700px) {
  .ce-name input { font-size: 18px; padding: 6px 8px; }
  .ce-hint { max-width: calc(100% - 20px); }
  .ce-stage { grid-template-columns: minmax(0, 1fr); }
  .ce-tools { flex-direction: row; overflow-x: auto; position: static; }
  .ce-tools button, .ce-file { flex: 0 0 62px; }
  .ce-tools hr { border-top: 0; border-left: 1px solid var(--line); margin: 2px 4px; }
  .ce-steps { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .ce-steps small { display: none; }
  .ce-canvas { height: 62vh; min-height: 320px; }
  .ce-name input { font-size: 18px; }
  .ce-actions { width: 100%; }
  .ce-actions .btn { flex: 1; justify-content: center; }
}

.cr-start { display: grid; grid-template-columns: 1.4fr 1fr; gap: 12px; margin-bottom: 14px; }
.cr-start a { display: flex; gap: 14px; align-items: flex-start; padding: 18px 20px; color: var(--ink); border: 1px solid var(--line); }
.cr-start a:hover { text-decoration: none; border-color: var(--faint); }
.cr-start b { display: block; font-size: 17px; margin-bottom: 4px; }
.cr-start small { color: var(--muted); font-size: 14px; line-height: 1.45; }
.cr-start-ico { flex: 0 0 40px; height: 40px; border-radius: 11px; display: grid; place-items: center; background: var(--raise); color: var(--muted); }
.cr-start-main { border-color: var(--accent) !important; box-shadow: 0 0 0 3px var(--accent-soft); }
.cr-start-main .cr-start-ico { background: var(--accent); color: var(--accent-ink); }
.cr-upload { margin-bottom: 18px; }
@media (max-width: 760px) { .cr-start { grid-template-columns: 1fr; } }

/* Сечение в 3D. */
.wc3d-title { display: flex; flex-direction: column; gap: 2px; min-width: 200px; }
.wc3d-stage { position: relative; height: 460px; background: var(--raise); border-radius: var(--r-ctl); overflow: hidden; }
.wc3d-stage canvas { width: 100%; height: 100%; display: block; cursor: grab; touch-action: none; }
.wc3d-stage canvas:active { cursor: grabbing; }
.wc3d-labels { position: absolute; inset: 0; pointer-events: none; }
.wc3d-labels span { position: absolute; transform: translate(-50%, -50%); font-size: 11.5px; padding: 2px 6px; border-radius: 6px;
  background: color-mix(in srgb, var(--panel) 82%, transparent); color: var(--ink); white-space: nowrap; box-shadow: var(--shadow); }
.wc3d-labels span.cut { color: var(--muted); font-style: italic; }
.wc3d-status { position: absolute; inset: auto 12px 12px 12px; font-size: 13px; color: var(--muted); }
.wc3d-status[hidden] { display: none; }
.wc3d-legend { list-style: none; padding: 0; margin: 10px 0 0; display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 12.5px; color: var(--muted); }
.wc3d-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 6px; vertical-align: -1px; }
.wc3d-summary { margin: 12px 0 6px; padding-left: 18px; }
.wc3d-summary li { margin-bottom: 4px; }
@media (max-width: 600px) { .wc3d-stage { height: 340px; } }

/* Разделы работ и фильтры журнала. */
.section-grid { display:grid; grid-template-columns:repeat(auto-fit,minmax(min(100%,340px),1fr)); gap:20px; }
.work-section.panel { margin:0; padding:22px; }
.section-heading { display:flex; gap:12px; align-items:start; margin-bottom:16px; }
.section-heading h2 { margin:0 0 6px; }
.section-heading p { margin:0; }
.section-heading > div { flex:1; min-width:0; }
.section-icon { display:grid; place-items:center; width:42px; height:42px; border-radius:12px; background:var(--accent-soft); color:var(--accent); flex-shrink:0; }
.subsection-link { display:flex; justify-content:space-between; gap:14px; padding:12px 0; border-top:1px solid var(--line-soft); font-size:14px; }
.subsection-link b { color:var(--muted); }
.unassigned.panel { display:flex; justify-content:space-between; align-items:center; margin-top:20px; }
.unassigned > span { display:flex; align-items:center; flex-wrap:wrap; gap:10px; }
.unassigned small { color:var(--muted); }
.category-filter { display:flex; align-items:end; flex-wrap:wrap; gap:14px; }
.category-filter label { flex:1 1 220px; margin:0; }
.category-tag { font-size:12px; padding:4px 9px; background:var(--accent-soft); border-radius:6px; }
