/* Палитра и вёрстка веб-доступа.
 *
 * Цвета — те же, что в настольном клиенте (theme.py): человек переходит из
 * программы в браузер и не должен видеть чужой продукт.
 *
 * Шрифты только системные. Внешние подключать нельзя: сторонние сервисы вроде
 * Google Fonts на каждый заход отдают IP посетителя за границу, и по 152-ФЗ
 * это трансграничная передача. Системный набор к тому же не тормозит и не
 * мигает подменой шрифта.
 *
 * Никаких фреймворков и сборки: один файл, обычный CSS, переменные темы.
 */

/* Марка набрана Space Grotesk Light. Шрифт лежит рядом со стилями, подрезан
   до заглавной латиницы (1,8 КБ): страница ни за чем в сеть не ходит, это
   запрещено законодательством. Адрес относительный, поэтому работает и в
   корне сайта, и под префиксом программы. */
@font-face {
  font-family: "Northen Mark";
  font-style: normal;
  font-weight: 300;
  font-display: swap;
  src: local("Space Grotesk Light"), local("SpaceGrotesk-Light"),
       url("northen-mark.woff2") format("woff2");
}

:root {
  --bg: #FFFFFF;
  --panel: #F6F6F7;
  --content-bg: #EEEEF0;
  --card: #FFFFFF;
  --text: #1A1A1A;
  --muted: #75757A;
  --border: #DCDCE0;
  --border-strong: #B4B4BA;
  --hover: #F0F0F1;
  --rail-sel: #ECECEE;
  --accent: #2F6FEB;
  --focus-ring: rgba(26, 26, 26, 0.13);
  --primary-bg: #1A1A1A;
  --primary-text: #FFFFFF;
  --primary-hover: #333333;
  --back-hover: #4A4A4A;
  --success-bg: rgba(46, 160, 67, 0.12);
  --success-border: rgba(46, 160, 67, 0.55);
  --success-text: #1E7B34;
  --error-bg: rgba(220, 64, 52, 0.10);
  --error-border: rgba(220, 64, 52, 0.50);
  --error-text: #B4271B;
  --warn-bg: rgba(212, 160, 23, 0.14);
  --warn-border: rgba(212, 160, 23, 0.45);
  --warn-text: #7A5B06;
  --shadow: 0 2px 12px rgba(0, 0, 0, 0.13);
}

/* Тёмная — по настройке системы; переключатель в шапке перебивает её. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { color-scheme: dark; }
}
:root:not([data-theme="light"]) {
  --dark-bg: #161616;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #161616; --panel: #101010; --card: #1C1C1E;
    --content-bg: #1C1C1C;
    --text: #ECECEC; --muted: #9E9EA6; --border: #36363C;
    --border-strong: #55555E; --hover: #242426; --rail-sel: #242426;
    --accent: #5B8DEF;
    --focus-ring: rgba(236, 236, 236, 0.18);
    --primary-bg: #ECECEC; --primary-text: #161616; --primary-hover: #FFFFFF;
    --back-hover: #BFBFBF;
    --success-bg: rgba(46, 160, 67, 0.16); --success-border: rgba(46, 160, 67, 0.60);
    --success-text: #6FD98A;
    --error-bg: rgba(220, 64, 52, 0.16); --error-border: rgba(220, 64, 52, 0.55);
    --error-text: #F0857A;
    --warn-bg: rgba(224, 177, 42, 0.16); --warn-border: rgba(224, 177, 42, 0.45);
    --warn-text: #E4C15F;
    --shadow: 0 2px 12px rgba(0, 0, 0, 0.42);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #161616; --panel: #101010; --card: #1C1C1E;
  --content-bg: #1C1C1C;
  --text: #ECECEC; --muted: #9E9EA6; --border: #36363C;
  --border-strong: #55555E; --hover: #242426; --rail-sel: #242426;
  --accent: #5B8DEF;
  --focus-ring: rgba(236, 236, 236, 0.18);
  --primary-bg: #ECECEC; --primary-text: #161616; --primary-hover: #FFFFFF;
  --back-hover: #BFBFBF;
  --success-bg: rgba(46, 160, 67, 0.16); --success-border: rgba(46, 160, 67, 0.60);
  --success-text: #6FD98A;
  --error-bg: rgba(220, 64, 52, 0.16); --error-border: rgba(220, 64, 52, 0.55);
  --error-text: #F0857A;
  --warn-bg: rgba(224, 177, 42, 0.16); --warn-border: rgba(224, 177, 42, 0.45);
  --warn-text: #E4C15F;
  --shadow: 0 2px 12px rgba(0, 0, 0, 0.42);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  /* Chrome на телефоне сам раздувает шрифт, и заданные размеры перестают
     значить что-либо. */
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", "Inter", system-ui, -apple-system, "Noto Sans", Arial, sans-serif;
  font-size: 14px;
  line-height: 1.45;
}

a { color: var(--accent); }

/* ---- каркас: рейл слева, содержимое справа ---- */

.shell {
  display: flex;
  /* dvh, а не vh: на телефоне адресная строка съезжает, и 100vh даёт высоту
     больше видимой — страница дёргается при прокрутке. vh оставлен запасом
     для браузеров постарше. */
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--content-bg);
}

.rail {
  width: 210px;
  flex: 0 0 210px;
  /* Панель остаётся на месте, пока прокручивается содержимое. Без этого на
     длинной странице низ панели с переключателем темы уезжает за экран. */
  position: sticky;
  top: 0;
  align-self: flex-start;
  height: 100vh;
  overflow-y: auto;
  background: var(--panel);
  border-right: 1px solid var(--border);
  padding: 18px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.rail .brand {
  font-weight: 600;
  padding: 0 10px 14px;
  font-size: 15px;
}
.rail a {
  display: block;
  padding: 9px 12px;
  border-radius: 8px;
  color: var(--text);
  text-decoration: none;
}
.rail a:hover { background: var(--hover); }
.rail a.on { background: var(--rail-sel); font-weight: 600; }
.rail .spacer { flex: 1; }
.rail-foot { border-top: 1px solid var(--border); padding-top: 8px; margin-top: 8px; }
.rail-foot a { color: var(--muted); }
.rail-foot a:hover { color: var(--text); }

/* min-width: 0 — не косметика: без него флекс-элемент не сжимается ниже
   собственного содержимого, и широкая таблица внутри растягивала всю
   страницу, хотя сама лежала в обёртке с прокруткой. */
.content { flex: 1; min-width: 0; padding: 28px 40px 48px; max-width: 1100px; }
h1 { font-size: 22px; font-weight: 600; margin: 0 0 6px; }
.hint { color: var(--muted); font-size: 13px; margin: 0 0 22px; }
.muted { color: var(--muted); }

/* ---- карточки ---- */

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
}
.card + .card { margin-top: 12px; }
.col { max-width: 440px; }

/* Вход — такая же вкладка, как остальные: панель на месте, а карточка узкая и
   по центру области. Поля по бокам берёт у области, своих не держит. */
.gate { margin: 0 auto; max-width: 420px; padding-top: 8vh; }
/* Вход — самая простая страница сайта, и потому единственная, где виден каждый
   пиксель. Ритм задаём здесь, а не разметкой: у первой подписи был свой отступ
   сверху, и она отходила от края карточки на 28px против 16px у низа — форма
   заметно съезжала вверх. */
.gate .card { padding: 24px; }
.gate label { margin: 0 0 7px; }
.gate input + label { margin-top: 18px; }   /* воздух между полями */
.gate input { padding: 10px 12px; }
.gate-go { margin-top: 22px; }

/* Две формы, видна одна. Какая, решает data-gate-mode на обёртке; без JS
   его ставит сервер по ?mode=, с JS меняет gate.js. */
.gate-form, .gate-flip { display: none; }
/* Смена формы: уходящая гаснет и чуть уезжает, приходящая проявляется.
   Классы ставит gate.js на время перехода; reduce-motion гасит всё это
   общим правилом ниже по файлу. */
.gate .gate-form { transition: opacity .16s ease, transform .16s ease; }
.gate.gate-leaving .gate-form  { opacity: 0; transform: translateY(6px); }
.gate.gate-arriving .gate-form { animation: gate-in .22s ease both; }
@keyframes gate-in {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: none; }
}
.gate[data-gate-mode="login"]    .gate-form[data-gate="login"],
.gate[data-gate-mode="login"]    .gate-form[data-gate="login"] + .gate-flip,
.gate[data-gate-mode="register"] .gate-form[data-gate="register"],
.gate[data-gate-mode="register"] .gate-form[data-gate="register"] + .gate-flip { display: block; }
.gate-flip { text-align: center; margin: 14px 0 0; font-size: 13px; }
.gate-flip a { color: var(--muted); }
.gate-flip a:hover { color: var(--text); }

/* Подсказка под ключом и полоса надёжности: заполняет gate.js. */
.gate-note { min-height: 18px; margin: 6px 0 0; font-size: 12px; color: var(--muted); }
.gate-note.ok  { color: var(--success-text); }
.gate-note.bad { color: var(--error-text); }
.gate-strength { display: flex; align-items: center; gap: 6px; margin: 8px 0 0; }
.gate-strength .bar { width: 28px; height: 4px; border-radius: 2px; background: var(--border); }
.gate-strength[data-score="1"] .bar:nth-child(-n+1),
.gate-strength[data-score="2"] .bar:nth-child(-n+2),
.gate-strength[data-score="3"] .bar:nth-child(-n+3) { background: var(--success-text); }
.gate-strength[data-score="1"] .bar:nth-child(1) { background: var(--warn-text); }
.gate-strength-text { font-size: 12px; color: var(--muted); margin-left: 4px; }

/* ---- поля и кнопки ---- */

input[type="text"], input[type="password"], input[type="email"], input[type="search"], textarea, select {
  width: 100%;
  background: var(--card);
  color: var(--text);
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  padding: 8px 10px;
  font: inherit;
}
/* Поле в работе обводится цветом текста, а не синим: синий тут был единственным
   чужим цветом на всю страницу. Чистый белый брать нельзя — на светлой теме он
   исчез бы на белой карточке. Мягкий ободок вокруг вместо контура: он не
   прыгает по вёрстке и читается спокойнее. */
input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--text);
  box-shadow: 0 0 0 3px var(--focus-ring);
}
textarea { resize: vertical; min-height: 76px; }
label { display: block; margin: 12px 0 4px; font-size: 13px; }
/* Флажок с подписью в одну строку: обычная подпись стоит блоком над полем. */
label.check { display: flex; align-items: center; gap: 8px; margin: 6px 0; font-size: 14px; }
label.check input { width: auto; }
/* Форма ключа в админке: узкая, как карточка входа, а не во всю ширину. */
.key-form { max-width: 420px; margin-bottom: 14px; }

.btn {
  display: inline-block;
  background: var(--primary-bg);
  color: var(--primary-text);
  border: none;
  border-radius: 8px;
  padding: 9px 18px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
}
.btn:hover { background: var(--primary-hover); }
.btn:disabled { background: transparent; color: var(--muted); border: 1px solid var(--border-strong); cursor: default; }

.btn-ghost {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  padding: 8px 14px;
  font: inherit;
  cursor: pointer;
  text-decoration: none;
}
.btn-ghost:hover { border-color: var(--accent); background: var(--hover); }
/* Форма в ячейке таблицы: поле и кнопка в одну строку, без переносов. */
form.inline { display: flex; gap: 6px; align-items: center; margin: 0; }
form.inline input { width: 140px; padding: 6px 8px; }

/* Кнопка скачивания зеленеет под курсором — как в программе. */
.btn-dl {
  display: inline-block; box-sizing: border-box;
  background: transparent; color: var(--text);
  border: 1px solid var(--border-strong); border-radius: 8px;
  padding: 8px 14px; font: inherit; line-height: 1.2; cursor: pointer; text-decoration: none;
}

/* Действия у готового чертежа: «Скачать» с меню и «Предпросмотр». Пункты с
   воздухом, меню закрывается кликом мимо (menu.js). */
.acts { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.menu-dl { position: relative; }
.menu-dl > summary { list-style: none; user-select: none; }
.menu-dl > summary::-webkit-details-marker { display: none; }
.menu-dl > summary::after { content: ""; display: inline-block; width: 6px; height: 6px; margin-left: 9px;
  border-right: 1.5px solid currentColor; border-bottom: 1.5px solid currentColor;
  transform: translateY(-2px) rotate(45deg); opacity: .7; }
.menu-dl[open] > summary { border-color: var(--accent); }
.menu-dl-list {
  position: absolute; right: 0; top: calc(100% + 8px); z-index: 30;
  min-width: 300px; padding: 8px;
  background: var(--card); border: 1px solid var(--border); border-radius: 14px;
  box-shadow: 0 18px 44px -18px rgba(30, 32, 38, .4), 0 0 0 1px rgba(0, 0, 0, .04);
}
.menu-dl-list a { display: block; padding: 11px 14px; border-radius: 9px; color: var(--text);
  text-decoration: none; font-size: 14px; white-space: nowrap; }
.menu-dl-list a:hover { background: var(--hover); }
.menu-dl-list a + a { margin-top: 2px; }
.btn-dl:hover {
  color: var(--success-text);
  border-color: var(--success-border);
  background: var(--success-bg);
}

/* ---- уведомления ---- */

.notice {
  border-radius: 10px;
  padding: 10px 12px;
  margin: 12px 0;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--muted);
}
.notice.success { background: var(--success-bg); border-color: var(--success-border); color: var(--success-text); }
.notice.error   { background: var(--error-bg);   border-color: var(--error-border);   color: var(--error-text); }
.notice.warn    { background: var(--warn-bg);    border-color: var(--warn-border);    color: var(--warn-text); }
.notice span { opacity: .85; }

/* ---- зона загрузки ---- */

/* ---- загрузка чертежа: три плитки на мягком поле, как в DAZZL ----
   Зерно за плитками статичное: SVG-шум в data-URI растрируется один раз
   как картинка фона, фильтров в реальном времени нет. Размытое пятно тоже
   нарисовано градиентом, а не blur(). Слой лежит под содержимым области. */
.shell:has(.upload) { position: relative; isolation: isolate; }
.shell:has(.upload)::before {
  content: ""; position: absolute; inset: 0; z-index: -1; pointer-events: none;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200'%3E%3Cfilter id='n' x='0' y='0'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='1.1' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .5 0 0 0 0 .5 0 0 0 0 .5 0 0 0 .16 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  background-size: 200px 200px;
  opacity: .5;
}
:root[data-theme="dark"] .shell:has(.upload)::before { opacity: .3; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .shell:has(.upload)::before { opacity: .3; }
}
.upload { max-width: 640px; }
.upload-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.utile {
  display: flex; flex-direction: column; gap: 6px;
  padding: 22px 24px;
  border-radius: 22px;
  background: var(--card);
  color: var(--text);
  box-shadow: 0 18px 44px -18px rgba(30, 32, 38, .28), 0 0 0 1px rgba(0, 0, 0, .05);
  transition: transform .2s ease, box-shadow .2s ease, background .2s ease;
}
.utile-title { font-size: 17px; font-weight: 600; letter-spacing: -.01em; }
.utile-text { color: var(--muted); font-size: 14px; line-height: 1.45; }
.utile-drop { grid-column: 1 / -1; cursor: pointer; min-height: 168px; }
.utile-drop input[type="file"] { position: absolute; width: 0; height: 0; opacity: 0; }
.utile-drop:hover, .utile-drop.drag { transform: translateY(-2px);
  box-shadow: 0 24px 54px -18px rgba(30, 32, 38, .36), 0 0 0 2px var(--focus-ring); }
.utile-drop:focus-within { box-shadow: 0 18px 44px -18px rgba(30, 32, 38, .28), 0 0 0 2px var(--focus-ring); }
.utile-pick { display: flex; align-items: center; gap: 12px; margin-top: auto; padding-top: 14px; flex-wrap: wrap; }
.utile-pick .btn-ghost { pointer-events: none; }   /* клик ловит вся плитка (label) */
.utile-file { font-size: 13px; overflow-wrap: anywhere; }
/* Атрибут hidden сильнее любой раскладки: display:flex у .utile иначе
   показал бы скрытую плитку. */
[hidden] { display: none !important; }

.utile-switch { flex-direction: row; align-items: center; gap: 10px; cursor: pointer; font-size: 14px; user-select: none; }
.utile-switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.utile-switch b { font-weight: 600; }
/* Точка: 12px при кегле 14px (0,85em), обводка 1,5px, заливка при включении. */
.utile-switch .dot {
  flex: 0 0 auto; width: 12px; height: 12px; border-radius: 50%;
  border: 1.5px solid var(--text); background: transparent;
  transition: background .15s ease, box-shadow .15s ease;
}
.utile-switch input:checked + .dot { background: var(--text); }
.utile-switch:hover { box-shadow: 0 18px 44px -18px rgba(30, 32, 38, .28), 0 0 0 2px var(--focus-ring); }
.utile-switch input:focus-visible + .dot { box-shadow: 0 0 0 3px var(--focus-ring); }
.utile-go {
  grid-column: 1 / -1;   /* во всю ширину: выбор формата скрыт, спорить не с кем */
  align-items: center; justify-content: center;
  font: inherit; font-size: 16px; font-weight: 600; cursor: pointer; border: 0;
  background: var(--primary-bg); color: var(--primary-text);
  min-height: 72px;
}
.utile-go:hover { background: var(--primary-hover); transform: translateY(-1px); }
.utile-go:disabled { background: var(--card); color: var(--muted); cursor: default; transform: none; }
.utile-go:focus-visible { outline: none; box-shadow: 0 0 0 2px var(--focus-ring); }

/* Крошки вместо заголовка: «Главное меню / Сейчас в обработке / имя».
   Тем же кеглем, что h1; ссылки в цвет текста, текущий шаг жирный. */
.crumbs { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; margin-bottom: 18px; }
.crumbs a { color: var(--muted); text-decoration: none; font-weight: 500; }
.crumbs a:hover { color: var(--text); }
.crumbs span { color: var(--border-strong); font-weight: 400; }
.crumbs b { font-weight: 600; }

/* Разделитель и строка «Сейчас в обработке … N» под плитками. */
.sep { border: 0; border-top: 1px solid var(--border); margin: 22px 0 14px; }
.utile-row { flex-direction: row; align-items: baseline; gap: 12px; text-decoration: none; padding: 16px 24px; }
.utile-row:hover { transform: translateY(-1px); box-shadow: 0 24px 54px -18px rgba(30, 32, 38, .36), 0 0 0 2px var(--focus-ring); }
.utile-row .leader { flex: 1; }   /* просто пустота: подпись слева, число справа */
.utile-row b { font-size: 17px; }
.utile-more {
  margin-top: 4px; text-decoration: none;
  width: 50%; min-height: 48px; padding: 12px 20px; font-size: 15px; font-weight: 500;
  background: var(--card); color: var(--text); box-shadow: 0 0 0 1px var(--border-strong);
}
.utile-more:hover { background: var(--hover); transform: none; box-shadow: 0 0 0 2px var(--focus-ring); }
.more-row { display: flex; gap: 14px; margin-top: 14px; }   /* строка кнопок стоит от плиток на тот же зазор */
.more-row .utile-more { flex: 0 1 calc(50% - 7px); width: auto; }   /* одна кнопка не растягивается на всю ширину */

/* Крестик у выполненной задачи: видим при наведении, на телефоне всегда.
   Зона нажатия 40px, сам знак маленький. */
.utile.job { position: relative; }
.job-x {
  position: absolute; top: 10px; right: 10px; width: 40px; height: 40px;
  border: 0; border-radius: 12px; background: transparent; color: var(--muted);
  font: inherit; font-size: 22px; line-height: 1; cursor: pointer;
  opacity: 0; transition: opacity .15s ease, background .15s ease, color .15s ease;
}
.utile.job:hover .job-x, .job-x:focus-visible { opacity: 1; }
.job-x:hover { background: var(--hover); color: var(--text); }
@media (hover: none) { .job-x { opacity: .7; } }

/* Подтверждение: маленькая плитка посередине, две негромкие кнопки. */
dialog.confirm { border: 0; padding: 0; background: transparent; }
dialog.confirm::backdrop { background: rgba(0, 0, 0, .45); }
.confirm-box { width: min(360px, 92vw); padding: 20px 22px; border-radius: 18px; margin: 0;
  background: var(--card); color: var(--text); box-shadow: 0 24px 60px -20px rgba(0, 0, 0, .5), 0 0 0 1px var(--border); }
.confirm-text { margin: 0 0 16px; font-size: 14px; line-height: 1.5; }
.confirm-actions { display: flex; justify-content: flex-end; gap: 8px; }

/* задача: та же плитка, полоса выше и с плавным ходом */
.utile.job { grid-column: 1 / -1; gap: 10px; }
.upload > .utile + .utile { margin-top: 14px; }
.job-step { font-size: 14px; }
.job-eta { font-size: 13px; }
.job-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }

/* ---- переключатель ---- */

.switch { display: flex; align-items: center; gap: 10px; margin: 14px 0; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch .track {
  position: relative;
  margin: 0;   /* общее правило label дало бы 12px сверху и перекос */
  flex: 0 0 auto;
  width: 48px; height: 26px;
  border-radius: 13px;
  background: var(--panel);
  border: 1px solid var(--border-strong);
  transition: background .14s ease, border-color .14s ease;
  cursor: pointer;
}
.switch .track::after {
  content: "";
  position: absolute;
  top: 2px; left: 2px;
  width: 20px; height: 20px;
  border-radius: 50%;
  background: #FFFFFF;
  border: 1px solid var(--border-strong);
  transition: transform .14s ease, border-color .14s ease;
}
.switch input:checked + .track {
  background: var(--success-text);
  border-color: var(--success-text);
}
.switch input:checked + .track::after { transform: translateX(22px); border-color: transparent; }
.switch input:focus-visible + .track { outline: 2px solid var(--accent); outline-offset: 2px; }
.switch .text b { font-size: 13px; font-weight: 600; display: block; }
.switch .text small { color: var(--muted); font-size: 12px; }

/* ---- список работ и история ---- */

/* Просмотр чертежа: во всю область содержимого, панель сверху, сцена ниже.
   Фон сцены тёмный по умолчанию, как в AutoCAD; переключатель меняет и
   цвет линий цвета 7 (viewer.js); толщину линий он же держит около пикселя при любом зуме. */
.viewer { display: flex; flex-direction: column; height: calc(100vh - 48px); min-height: 480px; margin: -8px 0 0; }
.viewer-bar { display: flex; align-items: center; gap: 10px; padding: 0 0 10px; flex-wrap: wrap; }
.viewer-title { font-weight: 600; overflow-wrap: anywhere; }
.viewer-note { color: var(--muted); font-size: 12px; flex: 1; }
.viewer-tools { display: flex; gap: 6px; margin-left: auto; }
.viewer-stage { flex: 1; min-height: 0; border: 1px solid var(--border); border-radius: 12px; overflow: hidden;
  cursor: grab; touch-action: none; user-select: none; background: #000; }
.viewer[data-bg="light"] .viewer-stage { background: #fff; }
.viewer.dragging .viewer-stage { cursor: grabbing; }
.viewer-stage svg { display: block; width: 100%; height: 100%; }

/* Поиск по списку: поле во всю ширину карточки, счётчик справа. */
.find { display: flex; align-items: center; gap: 12px; margin: -8px 0 14px; }
.find input { flex: 1; max-width: 480px; }
.find [data-find-count] { font-size: 12px; white-space: nowrap; }
input[type="search"] { -webkit-appearance: none; appearance: none; }
input[type="search"]::-webkit-search-cancel-button { -webkit-appearance: none; }

.row {
  display: flex; align-items: center; gap: 14px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 14px;
  margin-bottom: 10px;
}
.row:hover { border-color: var(--muted); }
.row .grow { flex: 1; min-width: 0; }
.row .name { font-weight: 600; overflow-wrap: anywhere; }
.row .meta { color: var(--muted); font-size: 12px; margin-top: 2px; }

.badge {
  border-radius: 6px; padding: 2px 8px; font-size: 12px;
  border: 1px solid var(--border); background: var(--panel); color: var(--muted);
  white-space: nowrap;
}
.badge.done  { background: var(--success-bg); border-color: var(--success-border); color: var(--success-text); }
.badge.error { background: var(--error-bg);   border-color: var(--error-border);   color: var(--error-text); }

/* ---- полоса выполнения ---- */

.bar {
  height: 12px; border-radius: 6px;
  background: var(--panel);
  border: 1px solid var(--border);
  padding: 2px;
  margin: 10px 0 2px;
  overflow: hidden;
}
.bar > i { display: block; height: 100%; border-radius: 4px; background: var(--success-text);
  transition: width .7s cubic-bezier(.2, .8, .2, 1); }

/* Разделы админки. Переносятся по строкам: на телефоне четыре в один ряд не
   влезали и вылезали за экран. */
.tabs { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 18px; }

/* Обёртка для широких таблиц: катается сама, а не растягивает страницу. */
.scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.scroll table { min-width: 520px; }

table { border-collapse: collapse; width: 100%; font-size: 13px; }
th, td { text-align: left; padding: 7px 10px; border-bottom: 1px solid var(--border); }
th { color: var(--muted); font-weight: 600; }

/* ---- плитки программ на главной ---- */

/* Марка в углу панели: своей гарнитурой, чтобы читалась как имя компании, а
   не как ещё один пункт меню. */
/* Марка теперь ссылка, и .rail a красил бы её как пункт панели. */
.rail a.brand:hover { background: none; opacity: .7; }
.rail .brand.mark {
  font-family: "Northen Mark", "Segoe UI", system-ui, sans-serif;
  font-size: 20px;
  font-weight: 300;
  letter-spacing: 2px;
}

/* Три в ряд, но плитка лежачая: в высоту ей нечего занимать, внутри только
   название и кнопка. */
.tiles {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  max-width: 920px;
  margin-top: 20px;
}

.tile {
  position: relative;
  display: flex;
  flex-direction: column;
  min-height: 140px;
  padding: 16px 18px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--card);
  color: inherit;
  text-decoration: none;
  transition: border-color .15s, background .15s;
}
.tile:hover { border-color: var(--border-strong); background: var(--hover); }

.tile-head { position: relative; z-index: 1; }
.tile-name { font-size: 16px; font-weight: 600; letter-spacing: .3px; }
.tile-note { font-size: 12px; color: var(--muted); margin-top: 2px; }

.tile-foot { margin-top: auto; display: flex; justify-content: flex-end; position: relative; z-index: 1; }
.tile-open {
  border: 1px solid var(--border-strong);
  border-radius: 18px;
  padding: 6px 16px;
  font-size: 13px;
  color: var(--text);
}
.tile:hover .tile-open {
  color: var(--success-text);
  border-color: var(--success-border);
  background: var(--success-bg);
}

@media (max-width: 900px) { .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 620px) { .tiles { grid-template-columns: minmax(0, 1fr); } }

/* ---- отказ в доступе ---- */

/* Для отказа область отдаётся целиком: свой предел ширины и разные отступы
   сверху и снизу увели бы середину блока от середины видимой плоскости. */
.content:has(.denied) { max-width: none; padding: 0; display: flex; }
.denied {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
  padding: 40px 20px;
  text-align: center;
}
.denied-mark {
  width: 56px; height: 56px;
  fill: none;
  stroke: var(--text);        /* чёрный на светлой теме, светлый на тёмной */
  stroke-width: 6;
  stroke-linecap: round;      /* те самые закруглённые края */
}
.denied-title { font-size: 28px; font-weight: 600; }
/* Кнопка та же, что везде: чёрная на светлой теме, белая на тёмной. Отличие
   одно - под курсором серая, а не ярче. */
.btn-back:hover { background: var(--back-hover); }

/* ---- о компании ---- */

/* Засечный шрифт и колонка в 640 px: страница читается, а не просматривается.
   Шрифты только системные - подключать чужие нельзя. */
.about {
  max-width: 640px;
  margin: 0 auto;
  padding: 56px 0 80px;
  font-family: "Times New Roman", Times, "Georgia", serif;
  font-size: 17px;
  line-height: 1.72;
}
.about-mark {
  font-family: "Northen Mark", "Segoe UI", system-ui, sans-serif;
  font-size: clamp(26px, 7.5vw, 40px);
  font-weight: 300;
  letter-spacing: clamp(2px, 1vw, 5px);
  text-align: center;
  margin: 0 0 14px;
}
.about-lead {
  text-align: center;
  color: var(--muted);
  font-size: 18px;
  margin: 0 0 44px;
}
.about p { margin: 0 0 20px; text-align: justify; hyphens: auto; }

/* ---- телефон ----
 *
 * Панель из боковой становится верхней и остаётся на месте при прокрутке.
 * Порядок в ней меняется, а не разметка: марка и переключатель темы в одну
 * строку, разделы — во вторую. Ничего не прячем за кнопкой-гамбургером: все
 * три-четыре пункта короткие и влезают, а спрятанное меню — лишнее нажатие
 * ради экономии, которой тут нет.
 *
 * Воздуха на телефоне больше, а не меньше: поля по бокам держат строку
 * читаемой, а заголовок наверху крупнее, чем на широком экране.
 */
@media (max-width: 720px) {
  .upload-grid { grid-template-columns: 1fr; }
  .menu-dl-list { left: 0; right: auto; min-width: 260px; }   /* у левого края экрана меню растёт вправо */
  .utile { padding: 18px 18px; border-radius: 18px; }
  .shell { flex-direction: column; }

  .rail {
    width: auto;
    flex: none;
    height: auto;
    align-self: stretch;
    z-index: 5;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px 6px;
    padding: 14px 16px 12px;
    border-right: none;
    border-bottom: 1px solid var(--border);
    overflow: visible;
  }
  /* Разделы идут последними, но в разметке стоят до распорки: порядок задаём
     здесь, чтобы не держать два варианта разметки. */
  .rail > a { order: 4; }
  .rail > a.brand { order: 1; margin-right: auto; padding: 0; }
  .rail > .rail-foot { order: 2; border-top: none; margin: 0; padding: 0; }
  .rail > .spacer { order: 3; flex: 0 0 100%; height: 0; }

  /* Палец — не курсор: 44px по высоте, меньше промахов. */
  .rail > a:not(.brand), .rail-foot a { padding: 12px 12px; }

  .content { padding: 28px 20px 56px; }
  h1 { font-size: 26px; margin-bottom: 8px; }
  .hint { margin-bottom: 26px; }
  .col { max-width: none; }

  /* Меньше 16px — и iOS сам увеличивает страницу, когда встаёшь в поле. */
  input[type="text"], input[type="password"], input[type="email"],
  textarea, select { font-size: 16px; padding: 11px 12px; }
  .btn, .btn-ghost, .btn-dl { padding: 12px 18px; }

  /* Имя, метка и кнопки в истории перестают тесниться в одну строку. */
  .row { flex-wrap: wrap; }
  .row .grow { flex: 1 1 100%; }

  .tile { min-height: 0; padding: 18px; }
  .tiles { margin-top: 16px; }

  /* Колонка узкая, а слова в русском длинные: выключка по формату рвала бы
     строку пробелами. */
  .about { padding: 36px 0 64px; font-size: 16px; }
  .about p { text-align: left; }
  .about-lead { font-size: 17px; margin-bottom: 32px; }

  .card { padding: 14px; }
  .gate { padding-top: 4vh; }
}

/* Совсем узкие экраны: боковые поля ещё меньше, иначе строка становится
   короче читаемой. */
@media (max-width: 400px) {
  .content { padding: 24px 14px 48px; }
  .rail { padding: 12px 14px 10px; }
}

/* Кому анимация мешает — тому её нет. */
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

/* Ходить по сайту с клавиатуры должно быть видно. */
a:focus-visible, button:focus-visible, .btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
/* У полей своя обводка выше; без этой строки поверх неё ложился синий контур. */
input:focus-visible, textarea:focus-visible, select:focus-visible { outline: none; }
